summaryrefslogtreecommitdiff
path: root/modules/gallery
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery')
-rw-r--r--modules/gallery/helpers/gallery_menu.php3
-rw-r--r--modules/gallery/libraries/Admin_View.php1
-rw-r--r--modules/gallery/libraries/Menu.php31
-rw-r--r--modules/gallery/libraries/Theme_View.php1
4 files changed, 29 insertions, 7 deletions
diff --git a/modules/gallery/helpers/gallery_menu.php b/modules/gallery/helpers/gallery_menu.php
index fb0234b1..a25832fe 100644
--- a/modules/gallery/helpers/gallery_menu.php
+++ b/modules/gallery/helpers/gallery_menu.php
@@ -149,6 +149,9 @@ class gallery_menu_Core {
->id("theme_options")
->label(t("Theme Options"))
->url(url::site("admin/theme_options"))))
+ ->append(Menu::factory("submenu")
+ ->id("statistics_menu")
+ ->label(t("Statistics")))
->append(Menu::factory("link")
->id("maintenance")
->label(t("Maintenance"))
diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php
index 1f976871..7a7396eb 100644
--- a/modules/gallery/libraries/Admin_View.php
+++ b/modules/gallery/libraries/Admin_View.php
@@ -69,6 +69,7 @@ class Admin_View_Core extends View {
}
}
+ $menu->compact();
print $menu;
}
diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php
index 83bd1616..6d0881ce 100644
--- a/modules/gallery/libraries/Menu.php
+++ b/modules/gallery/libraries/Menu.php
@@ -23,6 +23,11 @@ class Menu_Element {
public $css_id;
public $css_class;
public $id;
+ public $type;
+
+ public function __construct($type) {
+ $this->type = $type;
+ }
/**
* Set the id
@@ -125,26 +130,38 @@ class Menu_Core extends Menu_Element {
public static function factory($type) {
switch($type) {
case "link":
- return new Menu_Element_Link();
+ return new Menu_Element_Link($type);
case "dialog":
- return new Menu_Element_Dialog();
+ return new Menu_Element_Dialog($type);
case "root":
- $menu = new Menu();
- $menu->is_root = true;
- return $menu;
+ return new Menu("root");
case "submenu":
- return new Menu();
+ return new Menu("submenu");
default:
throw Exception("@todo UNKNOWN_MENU_TYPE");
}
}
- public function __construct() {
+ 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();
+ }
+ }
+ }
+ }
+
+ public function __construct($type) {
+ parent::__construct($type);
$this->elements = array();
+ $this->is_root = $type == "root";
}
/**
diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php
index 31c2faa7..7b2ca840 100644
--- a/modules/gallery/libraries/Theme_View.php
+++ b/modules/gallery/libraries/Theme_View.php
@@ -105,6 +105,7 @@ class Theme_View_Core extends View {
}
}
+ $menu->compact();
print $menu;
}