navigation MDL-14632 Added prepend method to settings navigation class to allow for the addition of branches to the top of the settings navigation block

This commit is contained in:
samhemelryk 2009-09-16 07:52:36 +00:00
parent 42d4579123
commit a6e34701cb

View File

@ -2150,6 +2150,31 @@ class settings_navigation extends navigation_node {
$this->get($key)->preceedwithhr = true; $this->get($key)->preceedwithhr = true;
return $key; return $key;
} }
/**
* This function allows the user to add something to the start of the settings
* navigation, which means it will be at the top of the settings navigation block
*
* @param string $text
* @param sting|moodle_url $url
* @param string $shorttext
* @param string|int $key
* @param int $type
* @param string $icon
* @return sting|int A key that can be used to reference the newly added node
*/
public function prepend($text, $url=null, $type=null, $shorttext=null, $key=null, $icon=null) {
$key = $this->add($text, $url, $type, $shorttext, $key, $icon);
$children = $this->children;
$this->children = array();
$this->children[$key] = array_pop($children);
foreach ($children as $k=>$child) {
$this->children[$k] = $child;
$this->get($k)->add_class('root_node');
$this->get($k)->preceedwithhr = true;
}
return $key;
}
/** /**
* Load the site administration tree * Load the site administration tree
* *