diff options
Diffstat (limited to 'engine/classes/ElggMenuItem.php')
-rw-r--r-- | engine/classes/ElggMenuItem.php | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php index 61dbf539e..cd6267ad6 100644 --- a/engine/classes/ElggMenuItem.php +++ b/engine/classes/ElggMenuItem.php @@ -132,7 +132,7 @@ class ElggMenuItem { $item->setItemClass($options['item_class']); unset($options['item_class']); } - + foreach ($options as $key => $value) { $item->$key = $value; } @@ -153,9 +153,20 @@ class ElggMenuItem { public function getName() { return $this->name; } + + /** + * Set the display text of the menu item + * + * @param string $text The display text + * + * @return void + */ + public function setText($text) { + $this->text = $text; + } /** - * Get the display text of the menu + * Get the display text of the menu item * * @return string */ @@ -164,6 +175,15 @@ class ElggMenuItem { } /** + * Set the URL of the menu item + * + * @return void + */ + public function setHref($href) { + $this->href = $href; + } + + /** * Get the URL of the menu item * * @return string @@ -325,7 +345,16 @@ class ElggMenuItem { * @return string */ public function getItemClass() { - return implode(' ', $this->itemClass); + //allow people to specify name with underscores and colons + $name = str_replace('_', '-', $this->getName()); + $name = str_replace(':', '-', $name); + + $class = implode(' ', $this->itemClass); + if ($class) { + return "elgg-menu-item-$name $class"; + } else { + return "elgg-menu-item-$name"; + } } /** @@ -420,6 +449,17 @@ class ElggMenuItem { } /** + * Set the menu item's children + * + * @param array $children Array of ElggMenuItems + * + * @return void + */ + public function setChildren($children) { + $this->children = $children; + } + + /** * Get the children menu items * * @return array @@ -445,7 +485,7 @@ class ElggMenuItem { * @params array $vars Options to pass to output/url if a link * * @return string - * + * * @todo View code in a model. How do we feel about that? */ public function getContent(array $vars = array()) { @@ -455,7 +495,7 @@ class ElggMenuItem { } $vars['text'] = $this->text; - + if ($this->href) { $vars['href'] = $this->href; } @@ -463,15 +503,15 @@ class ElggMenuItem { if ($this->linkClass) { $vars['class'] = $this->getLinkClass(); } - + if ($this->rel) { $vars['rel'] = $this->rel; } - + if ($this->title) { $vars['title'] = $this->title; } - + if ($this->is_action) { $vars['is_action'] = $this->is_action; } |