/** * Constructs a new global navigation * * @param moodle_page $page The page this navigation object belongs to */ public function __construct(moodle_page $page) { global $CFG, $SITE, $USER; if (during_initial_install()) { return; } if (get_home_page() == HOMEPAGE_SITE) { // We are using the site home for the root element $properties = array('key' => 'home', 'type' => navigation_node::TYPE_SYSTEM, 'text' => get_string('home'), 'action' => new moodle_url('/')); } else { // We are using the users my moodle for the root element $properties = array('key' => 'myhome', 'type' => navigation_node::TYPE_SYSTEM, 'text' => get_string('myhome'), 'action' => new moodle_url('/my/')); } // Use the parents constructor.... good good reuse parent::__construct($properties); // Initalise and set defaults $this->page = $page; $this->forceopen = true; $this->cache = new navigation_cache(NAVIGATION_CACHE_NAME); }
/** * A proxy constructor * * @param mixed $navnode A navigation_node or an array */ public function __construct($navnode) { if (is_array($navnode)) { parent::__construct($navnode); } else { if ($navnode instanceof navigation_node) { // Just clone everything. $objvalues = get_object_vars($navnode); foreach ($objvalues as $key => $value) { $this->{$key} = $value; } } else { throw coding_exception('Not a valid breadcrumb_navigation_node'); } } }