1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Provide views data and handlers for book.module.
|
6
|
*
|
7
|
* @ingroup views_module_handlers
|
8
|
*/
|
9
|
|
10
|
/**
|
11
|
* Implements hook_views_data().
|
12
|
*/
|
13
|
function book_views_data() {
|
14
|
// ----------------------------------------------------------------------
|
15
|
// 'book' table.
|
16
|
$data['book']['table']['group'] = t('Book');
|
17
|
$data['book']['table']['join'] = array(
|
18
|
'node' => array(
|
19
|
'left_field' => 'nid',
|
20
|
'field' => 'nid',
|
21
|
),
|
22
|
);
|
23
|
|
24
|
$data['book']['bid'] = array(
|
25
|
'title' => t('Top level book'),
|
26
|
'help' => t('The book the node is in.'),
|
27
|
'relationship' => array(
|
28
|
'base' => 'node',
|
29
|
'handler' => 'views_handler_relationship',
|
30
|
'label' => t('Book'),
|
31
|
),
|
32
|
// There is no argument here; if you need an argument, add the relationship
|
33
|
// and use the node: nid argument.
|
34
|
);
|
35
|
|
36
|
// ----------------------------------------------------------------------
|
37
|
// 'menu_links' table -- this is aliased so we can get just book relations.
|
38
|
// Book hierarchy and weight data are now in {menu_links}.
|
39
|
$data['book_menu_links']['table']['group'] = t('Book');
|
40
|
$data['book_menu_links']['table']['join'] = array(
|
41
|
'node' => array(
|
42
|
'table' => 'menu_links',
|
43
|
'left_table' => 'book',
|
44
|
'left_field' => 'mlid',
|
45
|
'field' => 'mlid',
|
46
|
),
|
47
|
);
|
48
|
|
49
|
$data['book_menu_links']['weight'] = array(
|
50
|
'title' => t('Weight'),
|
51
|
'help' => t('The weight of the book page.'),
|
52
|
'field' => array(
|
53
|
'handler' => 'views_handler_field_numeric',
|
54
|
'click sortable' => TRUE,
|
55
|
),
|
56
|
'sort' => array(
|
57
|
'handler' => 'views_handler_sort',
|
58
|
),
|
59
|
);
|
60
|
|
61
|
$data['book_menu_links']['depth'] = array(
|
62
|
'title' => t('Depth'),
|
63
|
'help' => t('The depth of the book page in the hierarchy; top level books have a depth of 1.'),
|
64
|
'field' => array(
|
65
|
'handler' => 'views_handler_field_numeric',
|
66
|
'click sortable' => TRUE,
|
67
|
),
|
68
|
'sort' => array(
|
69
|
'handler' => 'views_handler_sort',
|
70
|
),
|
71
|
'filter' => array(
|
72
|
'handler' => 'views_handler_filter_numeric',
|
73
|
),
|
74
|
'argument' => array(
|
75
|
'handler' => 'views_handler_argument',
|
76
|
),
|
77
|
);
|
78
|
|
79
|
$data['book_menu_links']['p'] = array(
|
80
|
'title' => t('Hierarchy'),
|
81
|
'help' => t('The order of pages in the book hierarchy.'),
|
82
|
'sort' => array(
|
83
|
'handler' => 'views_handler_sort_menu_hierarchy',
|
84
|
),
|
85
|
);
|
86
|
|
87
|
// ----------------------------------------------------------------------
|
88
|
// 'book_parent' table -- this is an alias of the book table which
|
89
|
// represents the parent book.
|
90
|
// The {book} record for the parent node.
|
91
|
$data['book_parent']['table']['group'] = t('Book');
|
92
|
$data['book_parent']['table']['join'] = array(
|
93
|
'node' => array(
|
94
|
'table' => 'book',
|
95
|
'left_table' => 'book_menu_links',
|
96
|
'left_field' => 'plid',
|
97
|
'field' => 'mlid',
|
98
|
),
|
99
|
);
|
100
|
|
101
|
$data['book_parent']['nid'] = array(
|
102
|
'title' => t('Parent'),
|
103
|
'help' => t('The parent book node.'),
|
104
|
'relationship' => array(
|
105
|
'base' => 'node',
|
106
|
'base field' => 'nid',
|
107
|
'handler' => 'views_handler_relationship',
|
108
|
'label' => t('Book parent'),
|
109
|
),
|
110
|
);
|
111
|
|
112
|
return $data;
|
113
|
}
|
114
|
|
115
|
/**
|
116
|
* Implements hook_views_plugins().
|
117
|
*/
|
118
|
function book_views_plugins() {
|
119
|
return array(
|
120
|
'module' => 'views',
|
121
|
'argument default' => array(
|
122
|
'book_root' => array(
|
123
|
'title' => t('Book root from current node'),
|
124
|
'handler' => 'views_plugin_argument_default_book_root',
|
125
|
),
|
126
|
),
|
127
|
);
|
128
|
}
|