Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:gallery/gallery3
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Almdal committed Oct 27, 2009
2 parents 3228f04 + 13faf60 commit dbf1831
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 66 deletions.
3 changes: 1 addition & 2 deletions modules/gallery/libraries/Admin_View.php
Expand Up @@ -47,8 +47,7 @@ public function __construct($name) {
public function admin_menu() {
$menu = Menu::factory("root");
module::event("admin_menu", $menu, $this);
$menu->compact();
return $menu;
return $menu->render();
}

/**
Expand Down
74 changes: 16 additions & 58 deletions modules/gallery/libraries/Menu.php
Expand Up @@ -80,19 +80,10 @@ public function css_class($css_class) {
* 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;
}
}

Expand All @@ -111,39 +102,21 @@ public function ajax_handler($ajax_handler) {
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;
}
}

/**
* 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;
}
}

Expand Down Expand Up @@ -182,19 +155,6 @@ public static function factory($type) {
}
}

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();
Expand Down Expand Up @@ -242,11 +202,9 @@ public function get($id) {
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;
}
}
12 changes: 6 additions & 6 deletions modules/gallery/libraries/Theme_View.php
Expand Up @@ -81,19 +81,19 @@ public function page_type() {
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() {
Expand All @@ -107,13 +107,13 @@ public function photo_menu() {
}

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) {
Expand All @@ -124,7 +124,7 @@ public function context_menu($item, $thumbnail_css_selector) {
->css_class("g-context-menu");

module::event("context_menu", $menu, $this, $item, $thumbnail_css_selector);
return $menu->compact();
return $menu->render();
}

public function pager() {
Expand Down
25 changes: 25 additions & 0 deletions modules/gallery/views/menu.html.php
@@ -0,0 +1,25 @@
<?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 ?>">
<? foreach ($menu->elements as $element): ?>
<?= $element->render() ?>
<? endforeach ?>
</ul>

<? else: ?>

<li title="<?= $menu->label->for_html_attr() ?>">
<a href="#">
<?= $menu->label->for_html() ?>
</a>
<ul>
<? foreach ($menu->elements as $element): ?>
<?= $element->render() ?>
<? endforeach ?>
</ul>
</li>

<? endif ?>
<? endif ?>
10 changes: 10 additions & 0 deletions modules/gallery/views/menu_ajax_link.html.php
@@ -0,0 +1,10 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<li>
<a id="<?= $menu->css_id ?>"
class="g-ajax-link <?= $menu->css_class ?>"
href="<?= $menu->url ?>"
title="<?= $menu->label->for_html_attr() ?>"
ajax_handler="<?= $menu->ajax_handler ?>">
<?= $menu->label->for_html() ?>
</a>
</li>
9 changes: 9 additions & 0 deletions modules/gallery/views/menu_dialog.html.php
@@ -0,0 +1,9 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<li>
<a id="<?= $menu->css_id ?>"
class="g-dialog-link <?= $menu->css_class ?>"
href="<?= $menu->url ?>"
title="<?= $menu->label->for_html_attr() ?>">
<?= $menu->label->for_html() ?>
</a>
</li>
9 changes: 9 additions & 0 deletions modules/gallery/views/menu_link.html.php
@@ -0,0 +1,9 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<li>
<a id="<?= $menu->css_id ?>"
class="g-menu-link <?= $menu->css_class ?>"
href="<?= $menu->url ?>"
title="<?= $menu->label->for_html_attr() ?>">
<?= $menu->label->for_html() ?>
</a>
</li>

0 comments on commit dbf1831

Please sign in to comment.