Permalink
Browse files

Merge commit 'upstream/master'

  • Loading branch information...
2 parents ff9129c + 9b7542b commit 95374070db74362bc1481e3fdcdab0d89678c1bc @andyst andyst committed Feb 22, 2010
Showing with 16 additions and 1 deletion.
  1. +16 −1 modules/gallery/libraries/Menu.php
@@ -184,7 +184,7 @@ public function append($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 @@ public function add_after($target_id, $new_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) {

0 comments on commit 9537407

Please sign in to comment.