| 1 |
<?php |
<?php |
| 2 |
|
|
| 3 |
//$Id: $ |
//$Id: menutree.pages.inc,v 1.1.2.2 2008/08/19 22:19:21 crell Exp $ |
| 4 |
|
|
| 5 |
/** |
/** |
| 6 |
* @file |
* @file |
| 24 |
* |
* |
| 25 |
*/ |
*/ |
| 26 |
function menutree_display_all() { |
function menutree_display_all() { |
| 27 |
|
|
| 28 |
$trees = array(); |
$trees = array(); |
| 29 |
|
|
| 30 |
$menus = menu_get_menus(); |
$menus = menu_get_menus(); |
| 31 |
|
|
| 32 |
foreach ($menus as $menu_name => $menu_title) { |
foreach ($menus as $menu_name => $menu_title) { |
| 33 |
if (($weight = variable_get('menutree_all_weight_'. $menu_name, '<none>')) !== '<none>') { |
|
| 34 |
$trees[$weight] = menutree_display(menu_load($menu_name), MENUTREE_TITLE_BODY); |
$weight = trim(variable_get('menutree_all_weight_'. $menu_name, '<none>')); |
| 35 |
|
|
| 36 |
|
if (is_numeric($weight)) { |
| 37 |
|
$trees[$weight] = menutree_display(menu_load($menu_name), $menu_title); |
| 38 |
} |
} |
| 39 |
} |
|
|
|
|
|
if (empty($trees)) { |
|
|
drupal_not_found(); |
|
|
exit(); |
|
| 40 |
} |
} |
| 41 |
ksort($trees); |
ksort($trees); |
| 42 |
|
|
| 43 |
return implode($trees); |
return implode($trees); |
| 44 |
} |
} |
| 45 |
|
|
| 50 |
* @param $menu |
* @param $menu |
| 51 |
* The menu to display. |
* The menu to display. |
| 52 |
* @param $title_display |
* @param $title_display |
| 53 |
* How to handle the display of the title. This is a bitmask that can take |
* How to handle the display of the title. This is a bitmask that can take |
| 54 |
* multiple values. |
* multiple values. |
| 55 |
* - MENUTREE_TITLE_PAGE: Set the title of this menu as the page title. |
* - MENUTREE_TITLE_PAGE: Set the title of this menu as the page title. |
| 56 |
* - MENUTREE_TITLE_BODY: Include the title of the menu in the body of the page. |
* - MENUTREE_TITLE_BODY: Include the title of the menu in the body of the page. |
| 57 |
*/ |
*/ |
| 58 |
function menutree_display($menu, $title_display = MENUTREE_TITLE_PAGE) { |
function menutree_display($menu, $title_display = MENUTREE_TITLE_PAGE) { |
| 59 |
|
|
|
/* |
|
| 60 |
$output = ''; |
$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); |
|
| 61 |
|
|
|
return $output; |
|
|
*/ |
|
|
|
|
|
$output = ''; |
|
|
|
|
| 62 |
// The title could be displayed in various ways. |
// The title could be displayed in various ways. |
| 63 |
$title = variable_get('menutree_title_'. $menu['menu_name'], ''); |
$title = variable_get('menutree_title_'. $menu['menu_name'], ''); |
| 64 |
if (!$title) { |
if (!$title) { |
| 65 |
$title = $menu['title']; |
$title = $menu['title']; |
| 66 |
} |
} |
| 67 |
$title = check_plain($title); |
$title = check_plain($title); |
| 68 |
|
|
| 69 |
if ($title_display & MENUTREE_TITLE_PAGE) { |
if ($title_display & MENUTREE_TITLE_PAGE) { |
| 70 |
drupal_set_title($title); |
drupal_set_title($title); |
| 71 |
} |
} |
| 72 |
|
|
|
$tree_title = ''; |
|
|
if ($title_display & MENUTREE_TITLE_BODY) { |
|
|
$tree_title = $title; |
|
|
} |
|
|
|
|
| 73 |
// Output custom intro text. |
// Output custom intro text. |
| 74 |
$intro = variable_get('menutree_intro_text_'. $menu['menu_name'], ''); |
$intro = variable_get('menutree_intro_text_'. $menu['menu_name'], ''); |
| 75 |
$description = ''; |
$description = ''; |
| 76 |
if (!empty($intro)) { |
if (!empty($intro)) { |
| 77 |
$description = check_markup($intro, FILTER_FORMAT_DEFAULT, FALSE); |
$description = check_markup($intro, FILTER_FORMAT_DEFAULT, FALSE); |
| 78 |
} |
} |
| 79 |
|
|
| 80 |
$tree = menu_tree_output(menu_tree_all_data($menu['menu_name'])); |
$tree = menu_tree_output(menu_tree_all_data($menu['menu_name'])); |
| 81 |
|
|
| 82 |
return theme('menutree_page', $tree_title, $description, $tree); |
return theme('menutree_page', $title, $description, $tree); |
| 83 |
} |
} |
| 84 |
|
|
| 85 |
/** |
/** |
| 86 |
* Theme the menutree. |
* Theme the menutree. |
| 87 |
* |
* |
| 88 |
* @param string $title |
* @param string $title |
| 89 |
* The title of this tree, if any. |
* The title of this tree, if any. |
| 90 |
* @param $description |
* @param $description |
| 94 |
* @ingroup themeable |
* @ingroup themeable |
| 95 |
*/ |
*/ |
| 96 |
function theme_menutree_page($title, $description, $tree) { |
function theme_menutree_page($title, $description, $tree) { |
| 97 |
|
|
| 98 |
$output = ''; |
$output = ''; |
| 99 |
|
|
| 100 |
if ($title) { |
if ($title) { |
| 101 |
$output .= '<h3>'. $title ."</h3>\n"; |
$output .= '<h3>'. $title ."</h3>\n"; |
| 102 |
} |
} |
| 103 |
if ($description) { |
if ($description) { |
| 104 |
$output .= '<div class="menutree-description">'. $description ."</div>\n"; |
$output .= '<div class="menutree-description">'. $description ."</div>\n"; |
| 105 |
} |
} |
| 106 |
|
|
| 107 |
$output .= $tree; |
$output .= $tree; |
| 108 |
|
|
| 109 |
|
|
| 110 |
return '<div class="menutree-page">' . $output . "</div>\n"; |
return '<div class="menutree-page">' . $output . "</div>\n"; |
| 111 |
} |
} |