summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/book.views.inc
blob: 2b1a82a47074be57d3be1498a590de979ad45b68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
/**
 * @file
 * Provide views data and handlers for book.module
 */

/**
 * @defgroup views_book_module book.module handlers
 *
 * @{
 */

/**
 * Implements hook_views_data()
 */
function book_views_data() {
  // ----------------------------------------------------------------------
  // book table

  $data['book']['table']['group']  = t('Book');
  $data['book']['table']['join'] = array(
    'node' => array(
      'left_field' => 'nid',
      'field' => 'nid',
    ),
  );

  $data['book']['bid'] = array(
    'title' => t('Top level book'),
    'help' => t('The book the node is in.'),
    'relationship' => array(
      'base' => 'node',
      'handler' => 'views_handler_relationship',
      'label' => t('Book'),
    ),
    // There is no argument here; if you need an argument, add the relationship
    // and use the node: nid argument.
  );

  // ----------------------------------------------------------------------
  // menu_links table -- this is aliased so we can get just book relations

  // Book hierarchy and weight data are now in {menu_links}.
  $data['book_menu_links']['table']['group'] = t('Book');
  $data['book_menu_links']['table']['join'] = array(
    'node' => array(
      'table' => 'menu_links',
      'left_table' => 'book',
      'left_field' => 'mlid',
      'field' => 'mlid',
    ),
  );

  $data['book_menu_links']['weight'] = array(
    'title' => t('Weight'),
    'help' => t('The weight of the book page.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  $data['book_menu_links']['depth'] = array(
    'title' => t('Depth'),
    'help' => t('The depth of the book page in the hierarchy; top level books have a depth of 1.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'argument' => array(
      'handler' => 'views_handler_argument',
    ),
  );

  $data['book_menu_links']['p'] = array(
    'title' => t('Hierarchy'),
    'help' => t('The order of pages in the book hierarchy.'),
    'sort' => array(
      'handler' => 'views_handler_sort_menu_hierarchy',
    ),
  );

  // ----------------------------------------------------------------------
  // book_parent table -- this is an alias of the book table which
  // represents the parent book.

  // The {book} record for the parent node.
  $data['book_parent']['table']['group'] = t('Book');
  $data['book_parent']['table']['join'] = array(
    'node' => array(
      'table' => 'book',
      'left_table' => 'book_menu_links',
      'left_field' => 'plid',
      'field' => 'mlid',
    ),
  );

  $data['book_parent']['nid'] = array(
    'title' => t('Parent'),
    'help' => t('The parent book node.'),
    'relationship' => array(
      'base' => 'node',
      'base field' => 'nid',
      'handler' => 'views_handler_relationship',
      'label' => t('Book parent'),
    ),
  );

  return $data;
}

/**
 * @}
 */