summaryrefslogtreecommitdiff
path: root/modules/gallery/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/libraries')
-rw-r--r--modules/gallery/libraries/Admin_View.php3
-rw-r--r--modules/gallery/libraries/Menu.php74
-rw-r--r--modules/gallery/libraries/Theme_View.php12
3 files changed, 23 insertions, 66 deletions
diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php
index 6eedec0d..cbb781a1 100644
--- a/modules/gallery/libraries/Admin_View.php
+++ b/modules/gallery/libraries/Admin_View.php
@@ -47,8 +47,7 @@ class Admin_View_Core extends Gallery_View {
public function admin_menu() {
$menu = Menu::factory("root");
module::event("admin_menu", $menu, $this);
- $menu->compact();
- return $menu;
+ return $menu->render();
}
/**
diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php
index 47af8531..fba21e09 100644
--- a/modules/gallery/libraries/Menu.php
+++ b/modules/gallery/libraries/Menu.php
@@ -80,19 +80,10 @@ class Menu_Element {
* Menu element that provides a link to a new page.
*/
class Menu_Element_Link extends Menu_Element {
- public function __toString() {
- if (isset($this->css_id) && !empty($this->css_id)) {
- $css_id = " id=\"$this->css_id\"";
- } else {
- $css_id = "";
- }
- if (isset($this->css_class) && !empty($this->css_class)) {
- $css_class = " $this->css_class";
- } else {
- $css_class = "";
- }
- return "<li><a$css_id class=\"g-menu-link $css_class\" href=\"$this->url\" " .
- "title=\"$this->label\">$this->label</a></li>";
+ public function render() {
+ $view = new View("menu_link.html");
+ $view->menu = $this;
+ return $view;
}
}
@@ -111,19 +102,10 @@ class Menu_Element_Ajax_Link extends Menu_Element {
return $this;
}
- public function __toString() {
- if (isset($this->css_id) && !empty($this->css_id)) {
- $css_id = " id=\"$this->css_id\"";
- } else {
- $css_id = "";
- }
- if (isset($this->css_class) && !empty($this->css_class)) {
- $css_class = " $this->css_class";
- } else {
- $css_class = "";
- }
- return "<li><a$css_id class=\"g-ajax-link $css_class\" href=\"$this->url\" " .
- "title=\"$this->label\" ajax_handler=\"$this->ajax_handler\">$this->label</a></li>";
+ public function render() {
+ $view = new View("menu_ajax_link.html");
+ $view->menu = $this;
+ return $view;
}
}
@@ -131,19 +113,10 @@ class Menu_Element_Ajax_Link extends Menu_Element {
* Menu element that provides a pop-up dialog
*/
class Menu_Element_Dialog extends Menu_Element {
- public function __toString() {
- if (isset($this->css_id) && !empty($this->css_id)) {
- $css_id = " id=\"$this->css_id\"";
- } else {
- $css_id = "";
- }
- if (isset($this->css_class) && !empty($this->css_class)) {
- $css_class = " $this->css_class";
- } else {
- $css_class = "";
- }
- return "<li><a$css_id class=\"g-dialog-link $css_class\" href=\"$this->url\" " .
- "title=\"$this->label\">$this->label</a></li>";
+ public function render() {
+ $view = new View("menu_dialog.html");
+ $view->menu = $this;
+ return $view;
}
}
@@ -182,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();
@@ -242,11 +202,9 @@ class Menu_Core extends Menu_Element {
return null;
}
- public function __toString() {
- $html = $this->is_root ? "<ul class=\"$this->css_class\">" :
- "<li title=\"$this->label\"><a href=\"#\">$this->label</a><ul>";
- $html .= implode("\n", $this->elements);
- $html .= $this->is_root ? "</ul>" : "</ul></li>";
- return $html;
+ public function render() {
+ $view = new View("menu.html");
+ $view->menu = $this;
+ return $view;
}
}
diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php
index 68ec325f..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();
+ return $menu->render();
}
public function album_menu() {
$menu = Menu::factory("root");
module::event("album_menu", $menu, $this);
- return $menu->compact();
+ return $menu->render();
}
public function tag_menu() {
$menu = Menu::factory("root");
module::event("tag_menu", $menu, $this);
- return $menu->compact();
+ 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();
+ return $menu->render();
}
public function movie_menu() {
$menu = Menu::factory("root");
module::event("movie_menu", $menu, $this);
- return $menu->compact();
+ 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();
+ return $menu->render();
}
public function pager() {