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