mirror of
https://github.com/Pathduck/gallery3.git
synced 2024-10-29 21:07:18 -04:00
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
This commit is contained in:
parent
3b66ea3c3a
commit
13faf6035d
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
|
@ -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() {
|
||||
|
@ -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 ?>
|
||||
|
Loading…
Reference in New Issue
Block a user