summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-10-27 14:00:32 -0700
committerBharat Mediratta <bharat@menalto.com>2009-10-27 14:00:32 -0700
commit13faf6035d726f8a77b7dcac7e8e8fa3b24bfaf2 (patch)
treec458a11bbe520834ffd20ffe9ccc35e30152a458
parent3b66ea3c3a4889c3ab3a2da0626fa5b554c1a7c9 (diff)
Remove Menu::compact() in favor of putting an if-then clause in
menu.html.php. This serves two purposes: 1) It's more efficient since we're doing less passes over the Menu tree 2) We're allowing themers to decide whether or not to show empty menus
-rw-r--r--modules/gallery/libraries/Admin_View.php2
-rw-r--r--modules/gallery/libraries/Menu.php13
-rw-r--r--modules/gallery/libraries/Theme_View.php12
-rw-r--r--modules/gallery/views/menu.html.php2
4 files changed, 9 insertions, 20 deletions
diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php
index 4cbefbbd..cbb781a1 100644
--- a/modules/gallery/libraries/Admin_View.php
+++ b/modules/gallery/libraries/Admin_View.php
@@ -47,7 +47,7 @@ class Admin_View_Core extends Gallery_View {
public function admin_menu() {
$menu = Menu::factory("root");
module::event("admin_menu", $menu, $this);
- return $menu->compact()->render();
+ return $menu->render();
}
/**
diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php
index 22261557..fba21e09 100644
--- a/modules/gallery/libraries/Menu.php
+++ b/modules/gallery/libraries/Menu.php
@@ -155,19 +155,6 @@ class Menu_Core extends Menu_Element {
}
}
- public function compact() {
- foreach ($this->elements as $target_id => $element) {
- if ($element->type == "submenu") {
- if (empty($element->elements)) {
- $this->remove($target_id);
- } else {
- $element->compact();
- }
- }
- }
- return $this;
- }
-
public function __construct($type) {
parent::__construct($type);
$this->elements = array();
diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php
index d4d8ee2a..9670313d 100644
--- a/modules/gallery/libraries/Theme_View.php
+++ b/modules/gallery/libraries/Theme_View.php
@@ -81,19 +81,19 @@ class Theme_View_Core extends Gallery_View {
public function site_menu() {
$menu = Menu::factory("root");
module::event("site_menu", $menu, $this);
- return $menu->compact()->render();
+ return $menu->render();
}
public function album_menu() {
$menu = Menu::factory("root");
module::event("album_menu", $menu, $this);
- return $menu->compact()->render();
+ return $menu->render();
}
public function tag_menu() {
$menu = Menu::factory("root");
module::event("tag_menu", $menu, $this);
- return $menu->compact()->render();
+ return $menu->render();
}
public function photo_menu() {
@@ -107,13 +107,13 @@ class Theme_View_Core extends Gallery_View {
}
module::event("photo_menu", $menu, $this);
- return $menu->compact()->render();
+ return $menu->render();
}
public function movie_menu() {
$menu = Menu::factory("root");
module::event("movie_menu", $menu, $this);
- return $menu->compact()->render();
+ return $menu->render();
}
public function context_menu($item, $thumbnail_css_selector) {
@@ -124,7 +124,7 @@ class Theme_View_Core extends Gallery_View {
->css_class("g-context-menu");
module::event("context_menu", $menu, $this, $item, $thumbnail_css_selector);
- return $menu->compact()->render();
+ return $menu->render();
}
public function pager() {
diff --git a/modules/gallery/views/menu.html.php b/modules/gallery/views/menu.html.php
index ba16ef36..b4b38c93 100644
--- a/modules/gallery/views/menu.html.php
+++ b/modules/gallery/views/menu.html.php
@@ -1,4 +1,5 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
+<? if ($menu->elements): // Don't show the menu if it has no choices ?>
<? if ($menu->is_root): ?>
<ul class="<?= $menu->css_class ?>">
@@ -21,3 +22,4 @@
</li>
<? endif ?>
+<? endif ?>