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