本文整理汇总了PHP中navigation_node::autofindactive方法的典型用法代码示例。如果您正苦于以下问题:PHP navigation_node::autofindactive方法的具体用法?PHP navigation_node::autofindactive怎么用?PHP navigation_node::autofindactive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类navigation_node
的用法示例。
在下文中一共展示了navigation_node::autofindactive方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load_administration_settings
/**
* Load the site administration tree
*
* This function loads the site administration tree by using the lib/adminlib library functions
*
* @param navigation_node $referencebranch A reference to a branch in the settings
* navigation tree
* @param part_of_admin_tree $adminbranch The branch to add, if null generate the admin
* tree and start at the beginning
* @return mixed A key to access the admin tree by
*/
protected function load_administration_settings(navigation_node $referencebranch = null, part_of_admin_tree $adminbranch = null)
{
global $CFG;
// Check if we are just starting to generate this navigation.
if ($referencebranch === null) {
// Require the admin lib then get an admin structure
if (!function_exists('admin_get_root')) {
require_once $CFG->dirroot . '/lib/adminlib.php';
}
$adminroot = admin_get_root(false, false);
// This is the active section identifier
$this->adminsection = $this->page->url->param('section');
// Disable the navigation from automatically finding the active node
navigation_node::$autofindactive = false;
$referencebranch = $this->add(get_string('administrationsite'), null, self::TYPE_SETTING, null, 'root');
foreach ($adminroot->children as $adminbranch) {
$this->load_administration_settings($referencebranch, $adminbranch);
}
navigation_node::$autofindactive = true;
// Use the admin structure to locate the active page
if (!$this->contains_active_node() && ($current = $adminroot->locate($this->adminsection, true))) {
$currentnode = $this;
while (($pathkey = array_pop($current->path)) !== null && $currentnode) {
$currentnode = $currentnode->get($pathkey);
}
if ($currentnode) {
$currentnode->make_active();
}
} else {
$this->scan_for_active_node($referencebranch);
}
return $referencebranch;
} else {
if ($adminbranch->check_access()) {
// We have a reference branch that we can access and is not hidden `hurrah`
// Now we need to display it and any children it may have
$url = null;
$icon = null;
if ($adminbranch instanceof admin_settingpage) {
$url = new moodle_url('/' . $CFG->admin . '/settings.php', array('section' => $adminbranch->name));
} else {
if ($adminbranch instanceof admin_externalpage) {
$url = $adminbranch->url;
} else {
if (!empty($CFG->linkadmincategories) && $adminbranch instanceof admin_category) {
$url = new moodle_url('/' . $CFG->admin . '/category.php', array('category' => $adminbranch->name));
}
}
}
// Add the branch
$reference = $referencebranch->add($adminbranch->visiblename, $url, self::TYPE_SETTING, null, $adminbranch->name, $icon);
if ($adminbranch->is_hidden()) {
if (($adminbranch instanceof admin_externalpage || $adminbranch instanceof admin_settingpage) && $adminbranch->name == $this->adminsection) {
$reference->add_class('hidden');
} else {
$reference->display = false;
}
}
// Check if we are generating the admin notifications and whether notificiations exist
if ($adminbranch->name === 'adminnotifications' && admin_critical_warnings_present()) {
$reference->add_class('criticalnotification');
}
// Check if this branch has children
if ($reference && isset($adminbranch->children) && is_array($adminbranch->children) && count($adminbranch->children) > 0) {
foreach ($adminbranch->children as $branch) {
// Generate the child branches as well now using this branch as the reference
$this->load_administration_settings($reference, $branch);
}
} else {
$reference->icon = new pix_icon('i/settings', '');
}
}
}
}