| | 41 | /** |
| | 42 | * Returns a rendered menu tree for Drupal 6.x. |
| | 43 | * |
| | 44 | * @param $tree |
| | 45 | * A data structure representing the tree as returned from menu_tree_data. |
| | 46 | * @return |
| | 47 | * The rendered HTML of that data structure. |
| | 48 | */ |
| | 49 | function front_menu_tree_output_d6($tree) { |
| | 50 | $tree = front_menu_tree_d6($tree); |
| | 51 | if (!empty($tree)) { |
| | 52 | return '<ul class="footer-menu">' . $tree . '</ul>'; |
| | 53 | } |
| | 54 | } |
| | 55 | |
| | 56 | function front_menu_tree_d6($tree) { |
| | 57 | $output = ''; |
| | 58 | $items = array(); |
| | 59 | |
| | 60 | // Pull out just the menu items we are going to render so that we |
| | 61 | // get an accurate count for the first/last classes. |
| | 62 | foreach ($tree as $data) { |
| | 63 | if (!$data['link']['hidden']) { |
| | 64 | $items[] = $data; |
| | 65 | } |
| | 66 | } |
| | 67 | |
| | 68 | $num_items = count($items); |
| | 69 | foreach ($items as $i => $data) { |
| | 70 | $link = front_menu_item_link_d6($data['link']); |
| | 71 | if ($data['below']) { |
| | 72 | $output .= front_menu_item_d6($link, front_menu_tree_d6($data['below'])); |
| | 73 | } |
| | 74 | else { |
| | 75 | $output .= front_menu_item_d6($link, ''); |
| | 76 | } |
| | 77 | } |
| | 78 | |
| | 79 | return $output; |
| | 80 | } |
| | 81 | |
| | 82 | /** |
| | 83 | * Generate the HTML output for a menu item and submenu for Drupal 6.x. |
| | 84 | * |
| | 85 | * @ingroup themeable |
| | 86 | */ |
| | 87 | function front_menu_item_d6($link, $menu = '') { |
| | 88 | if ('' != $menu) { |
| | 89 | $menu = "<ul>\n" . $menu . "</ul>\n"; |
| | 90 | } |
| | 91 | return '<li class="'. $class .'">'. $link . $menu . "</li>\n"; |
| | 92 | } |
| | 93 | |
| | 94 | /** |
| | 95 | * Generate the HTML output for a single menu link for Drupal 6.x. |
| | 96 | * |
| | 97 | * @ingroup themeable |
| | 98 | */ |
| | 99 | function front_menu_item_link_d6($link) { |
| | 100 | if (empty($link['localized_options'])) { |
| | 101 | $link['localized_options'] = array(); |
| | 102 | } |
| | 103 | |
| | 104 | $link = l($link['title'], $link['href'], $link['localized_options']); |
| | 105 | return preg_replace('~(<a [^>]*>)(.*)(</a>)~', '$1$2$3', $link); |
| | 106 | } |