/[drupal]/contributions/modules/menutree/menutree.pages.inc
ViewVC logotype

Diff of /contributions/modules/menutree/menutree.pages.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Tue Aug 19 22:18:48 2008 UTC revision 1.1.2.1, Tue Aug 19 22:18:48 2008 UTC
# Line 0  Line 1 
1    <?php
2    
3    //$Id: $
4    
5    /**
6     * @file
7     * User-facing page callbacks for the menutree module.
8     *
9     */
10    
11    
12    /**
13     * Menu callback; Display a menu tree for a single specified menu.
14     *
15     * @param $menu
16     *  The menu to display.
17     */
18    function menutree_display_page($menu) {
19      return menutree_display($menu, MENUTREE_TITLE_PAGE);
20    }
21    
22    /**
23     * Menu callback; Display a fully-expanded version of all flagged menus.
24     *
25     */
26    function menutree_display_all() {
27    
28      $trees = array();
29    
30      $menus = menu_get_menus();
31      foreach ($menus as $menu_name => $menu_title) {
32        if (($weight = variable_get('menutree_all_weight_'. $menu_name, '<none>')) !== '<none>') {
33          $trees[$weight] = menutree_display(menu_load($menu_name), MENUTREE_TITLE_BODY);
34        }
35      }
36    
37      if (empty($trees)) {
38        drupal_not_found();
39        exit();
40      }
41      ksort($trees);
42    
43      return implode($trees);
44    }
45    
46    
47    /**
48     * Display a fully-expanded version of the menu specified on the path
49     *
50     * @param $menu
51     *  The menu to display.
52     * @param $title_display
53     *   How to handle the display of the title.  This is a bitmask that can take
54     *   multiple values.
55     *     - 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.
57     */
58    function menutree_display($menu, $title_display = MENUTREE_TITLE_PAGE) {
59    
60      /*
61      $output = '';
62    
63      $title = variable_get('menutree_title_'. $menu['menu_name'], '');
64      drupal_set_title(check_plain(!empty($title) ? $title : $menu['title']));
65    
66      // Output custom intro text.
67      $intro = variable_get('menutree_intro_text_'. $menu['menu_name'], '');
68      if (!empty($intro)) {
69        $output .= check_markup($intro, FILTER_FORMAT_DEFAULT, FALSE);
70      }
71    
72      $tree = menu_tree_output(menu_tree_all_data($menu['menu_name']));
73      $output .= theme('menutree_page', $tree);
74    
75      return $output;
76    */
77    
78      $output = '';
79    
80      // The title could be displayed in various ways.
81      $title = variable_get('menutree_title_'. $menu['menu_name'], '');
82      if (!$title) {
83        $title = $menu['title'];
84      }
85      $title = check_plain($title);
86    
87      if ($title_display & MENUTREE_TITLE_PAGE) {
88        drupal_set_title($title);
89      }
90    
91      $tree_title = '';
92      if ($title_display & MENUTREE_TITLE_BODY) {
93        $tree_title = $title;
94      }
95    
96      // Output custom intro text.
97      $intro = variable_get('menutree_intro_text_'. $menu['menu_name'], '');
98      $description = '';
99      if (!empty($intro)) {
100        $description = check_markup($intro, FILTER_FORMAT_DEFAULT, FALSE);
101      }
102    
103      $tree = menu_tree_output(menu_tree_all_data($menu['menu_name']));
104    
105      return theme('menutree_page', $tree_title, $description, $tree);
106    }
107    
108    /**
109     * Theme the menutree.
110     *
111     * @param string $title
112     *   The title of this tree, if any.
113     * @param $description
114     *   The descriptive intro text for this tree, if any.
115     * @param $tree
116     *   The pre-rendered menu tree itself.
117     * @ingroup themeable
118     */
119    function theme_menutree_page($title, $description, $tree) {
120    
121      $output = '';
122    
123      if ($title) {
124        $output .= '<h3>'. $title ."</h3>\n";
125      }
126      if ($description) {
127        $output .= '<div class="menutree-description">'. $description ."</div>\n";
128      }
129    
130      $output .= $tree;
131    
132    
133      return  '<div class="menutree-page">' . $output . "</div>\n";
134    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

  ViewVC Help
Powered by ViewVC 1.1.2