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