Backup of db before drupal security update
[yaffs-website] / web / core / modules / book / book.views.inc
1 <?php
2
3 /**
4  * @file
5  * Provide views data for book.module.
6  *
7  * @ingroup views_module_handlers
8  */
9
10 /**
11  * Implements hook_views_data().
12  */
13 function book_views_data() {
14   $data = [];
15   $data['book'] = [];
16   $data['book']['table'] = [];
17   $data['book']['table']['group'] = t('Book');
18
19   $data['book']['table']['join'] = [
20     'node_field_data' => [
21       'left_field' => 'nid',
22       'field' => 'nid',
23     ],
24   ];
25
26   $data['book']['nid'] = [
27     'title' => t('Page'),
28     'help' => t('The book page node.'),
29     'relationship' => [
30       'base' => 'node_field_data',
31       'id' => 'standard',
32       'label' => t('Book Page'),
33     ],
34   ];
35
36   $data['book']['bid'] = [
37     'title' => t('Top level book'),
38     'help' => t('The book the node is in.'),
39     'relationship' => [
40       'base' => 'node_field_data',
41       'id' => 'standard',
42       'label' => t('Book'),
43     ],
44   ];
45
46   $data['book']['pid'] = [
47     'title' => t('Parent'),
48     'help' => t('The parent book node.'),
49     'relationship' => [
50       'base' => 'node_field_data',
51       'id' => 'standard',
52       'label' => t('Book Parent'),
53     ],
54   ];
55
56   $data['book']['has_children'] = [
57     'title' => t('Page has Children'),
58     'help' => t('Flag indicating whether this book page has children'),
59     'field' => [
60       'id' => 'boolean',
61     ],
62     'sort' => [
63       'id' => 'standard',
64     ],
65     'filter' => [
66       'id' => 'boolean',
67       'label' => t('Has Children'),
68     ],
69     'argument' => [
70       'id' => 'numeric',
71     ],
72   ];
73
74   $data['book']['weight'] = [
75     'title' => t('Weight'),
76     'help' => t('The weight of the book page.'),
77     'field' => [
78       'id' => 'numeric',
79     ],
80     'sort' => [
81       'id' => 'standard',
82     ],
83   ];
84
85   $data['book']['depth'] = [
86     'title' => t('Depth'),
87     'help' => t('The depth of the book page in the hierarchy; top level books have a depth of 1.'),
88     'field' => [
89       'id' => 'numeric',
90     ],
91     'sort' => [
92       'id' => 'standard',
93     ],
94     'filter' => [
95       'id' => 'numeric',
96     ],
97     'argument' => [
98       'id' => 'standard',
99     ],
100   ];
101   $parents = [
102     1 => t('1st parent'),
103     2 => t('2nd parent'),
104     3 => t('3rd parent'),
105     4 => t('4th parent'),
106     5 => t('5th parent'),
107     6 => t('6th parent'),
108     7 => t('7th parent'),
109     8 => t('8th parent'),
110     9 => t('9th parent'),
111   ];
112   foreach ($parents as $i => $parent_label) {
113     $data['book']["p$i"] = [
114       'title' => $parent_label,
115       'help' => t('The @parent of book node.', ['@parent' => $parent_label]),
116       'relationship' => [
117         'base' => 'node_field_data',
118         'id' => 'standard',
119         'label' => t('Book @parent', ['@parent' => $parent_label]),
120       ],
121     ];
122   }
123
124   return $data;
125 }