diff options
| author | Nathan Kinkade <nkinkade@nkinka.de> | 2010-02-27 14:03:01 +0000 | 
|---|---|---|
| committer | Nathan Kinkade <nkinkade@nkinka.de> | 2010-02-27 14:03:01 +0000 | 
| commit | a58aa6e97b0e44adf7a878db6e276b081e202192 (patch) | |
| tree | cecc68b1222cb283a021478b822952c468d64393 /modules/gallery/libraries/Menu.php | |
| parent | 10e36fcf1b5acf07c5cc128105af03fb09aac89e (diff) | |
| parent | d9707ae749df2770370dc4eeeeaddda28f092d4d (diff) | |
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules/gallery/libraries/Menu.php')
| -rw-r--r-- | modules/gallery/libraries/Menu.php | 30 | 
1 files changed, 29 insertions, 1 deletions
| diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php index e2b68d1a..fef07916 100644 --- a/modules/gallery/libraries/Menu.php +++ b/modules/gallery/libraries/Menu.php @@ -184,7 +184,7 @@ class Menu_Core extends Menu_Element {    }    /** -   * Add a new element to this menu +   * Add a new element to this menu, after the specific element     */    public function add_after($target_id, $new_menu_element) {      $copy = array(); @@ -199,6 +199,21 @@ class Menu_Core extends Menu_Element {    }    /** +   * Add a new element to this menu, before the specific element +   */ +  public function add_before($target_id, $new_menu_element) { +    $copy = array(); +    foreach ($this->elements as $id => $menu_element) { +      if ($id == $target_id) { +        $copy[$new_menu_element->id] = $new_menu_element; +      } +      $copy[$id] = $menu_element; +    } +    $this->elements = $copy; +    return $this; +  } + +  /**     * Remove an element from the menu     */    public function remove($target_id) { @@ -216,6 +231,19 @@ class Menu_Core extends Menu_Element {      return null;    } +  public function is_empty() { +    foreach ($this->elements as $element) { +      if ($element instanceof Menu) { +        if (!$element->is_empty()) { +          return false; +        } +      } else { +        return false; +      } +    } +    return true; +  } +    public function render() {      $view = new View(isset($this->view) ? $this->view : "menu.html");      $view->menu = $this; | 
