| 1 |
<?php |
<?php |
| 2 |
//$Id: menutree.module,v 1.4 2008/01/22 02:56:59 crell Exp $ |
//$Id: menutree.module,v 1.4.2.1 2008/05/04 23:25:40 crell Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 11 |
*/ |
*/ |
| 12 |
|
|
| 13 |
/** |
/** |
| 14 |
|
* Page title handling option constant definitions. |
| 15 |
|
*/ |
| 16 |
|
|
| 17 |
|
/** |
| 18 |
|
* Display the menu title as the page title. |
| 19 |
|
*/ |
| 20 |
|
define('MENUTREE_TITLE_PAGE', 0x0001); |
| 21 |
|
|
| 22 |
|
/** |
| 23 |
|
* Display the menu title inline in the body of the page. |
| 24 |
|
*/ |
| 25 |
|
define('MENUTREE_TITLE_BODY', 0x0002); |
| 26 |
|
|
| 27 |
|
/** |
| 28 |
* Implementation of hook_theme() |
* Implementation of hook_theme() |
| 29 |
*/ |
*/ |
| 30 |
function menutree_theme() { |
function menutree_theme() { |
| 31 |
return array( |
return array( |
| 32 |
'menutree_page' => array('arguments' => array('output' => NULL)), |
'menutree_page' => array( |
| 33 |
|
'arguments' => array( |
| 34 |
|
'title' => NULL, |
| 35 |
|
'description' => NULL, |
| 36 |
|
'tree' => NULL, |
| 37 |
|
), |
| 38 |
|
'file' => 'menutree.pages.inc', |
| 39 |
|
), |
| 40 |
'menutree_tree' => array('arguments' => array('menu_name' => NULL)), |
'menutree_tree' => array('arguments' => array('menu_name' => NULL)), |
| 41 |
); |
); |
| 42 |
} |
} |
| 55 |
$items = array(); |
$items = array(); |
| 56 |
$items['menutree'] = array( |
$items['menutree'] = array( |
| 57 |
'title' => 'Sitemap', |
'title' => 'Sitemap', |
| 58 |
'page callback' => 'menutree_display', |
'page callback' => 'menutree_display_page', |
| 59 |
'page arguments' => array(menu_load('primary-links')), |
'page arguments' => array(menu_load('primary-links')), |
| 60 |
'access arguments' => array('view site tree'), |
'access arguments' => array('view site tree'), |
| 61 |
'type' => MENU_CALLBACK, |
'type' => MENU_CALLBACK, |
| 62 |
|
'file' => 'menutree.pages.inc', |
| 63 |
); |
); |
| 64 |
$items['menutree/%menu'] = array( |
$items['menutree/%menu'] = array( |
| 65 |
'title' => 'Sitemap', |
'title' => 'Sitemap', |
| 66 |
'page arguments' => array(1), |
'page arguments' => array(1), |
| 67 |
'type' => MENU_CALLBACK, |
'type' => MENU_CALLBACK, |
| 68 |
'access arguments' => array('view site tree'), |
'access arguments' => array('view site tree'), |
| 69 |
|
'file' => 'menutree.pages.inc', |
| 70 |
|
); |
| 71 |
|
$items['menutree/all'] = array( |
| 72 |
|
'title' => 'Sitemap', |
| 73 |
|
'page callback' => 'menutree_display_all', |
| 74 |
|
'page arguments' => array(), |
| 75 |
|
'access arguments' => array('view site tree'), |
| 76 |
|
'type' => MENU_CALLBACK, |
| 77 |
|
'file' => 'menutree.pages.inc', |
| 78 |
); |
); |
| 79 |
$items['admin/build/menutree'] = array( |
$items['admin/build/menutree'] = array( |
| 80 |
'title' => 'Menu trees', |
'title' => 'Menu trees', |
| 86 |
); |
); |
| 87 |
return $items; |
return $items; |
| 88 |
} |
} |
|
|
|
|
/** |
|
|
* Display a fully-expanded version of the menu specified on the path |
|
|
* |
|
|
* @param $menu |
|
|
* The menu to display. |
|
|
*/ |
|
|
function menutree_display($menu) { |
|
|
$output = ''; |
|
|
|
|
|
$title = variable_get('menutree_title_'. $menu['menu_name'], ''); |
|
|
drupal_set_title(check_plain(!empty($title) ? $title : $menu['title'])); |
|
|
|
|
|
// Output custom intro text. |
|
|
$intro = variable_get('menutree_intro_text_'. $menu['menu_name'], ''); |
|
|
if (!empty($intro)) { |
|
|
$output .= check_markup($intro, FILTER_FORMAT_DEFAULT, FALSE); |
|
|
} |
|
|
|
|
|
$tree = menu_tree_output(menu_tree_all_data($menu['menu_name'])); |
|
|
$output .= theme('menutree_page', $tree); |
|
|
|
|
|
return $output; |
|
|
} |
|
|
|
|
|
/** |
|
|
* Theme the menutree |
|
|
* |
|
|
* In practice this is already themed into lists, so this just wraps it in a div |
|
|
* |
|
|
* @param string $output |
|
|
* The menutree, pre-rendered |
|
|
* |
|
|
* @ingroup themeable |
|
|
*/ |
|
|
function theme_menutree_page($output) { |
|
|
return '<div class="menutree-page">'. $output ."</div>\n"; |
|
|
} |
|