本文整理汇总了PHP中navigation_node::create方法的典型用法代码示例。如果您正苦于以下问题:PHP navigation_node::create方法的具体用法?PHP navigation_node::create怎么用?PHP navigation_node::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类navigation_node
的用法示例。
在下文中一共展示了navigation_node::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: local_compile_extends_settings_navigation
/**
* Add a "Compile" menu link to the Course Admin block as the top link.
*
* @author Gerald Albion
* date 2014-10-31
* @copyright 2014 Royal Roads University
* @param object $settingsnav Main navigation object.
* @param object $context Course context.
*/
function local_compile_extends_settings_navigation($settingsnav, $context)
{
// Context must be course.
if ($context->contextlevel != CONTEXT_COURSE) {
return;
}
// Must be in a valid course: Cannot be course id 0.
if ($context->instanceid == 0) {
return;
}
// Must be in a valid course: Course must be retrievable.
if (!($course = get_course($context->instanceid))) {
return;
}
// Must be enrolled or otherwise allowed to view the course.
if (!(is_enrolled($context) || is_viewing($context))) {
return;
}
// Must have a course admin menu in which to add link.
if (!($coursenode = $settingsnav->find('courseadmin', navigation_node::TYPE_COURSE))) {
return;
}
// Good to go. Build the menu item.
$url = new moodle_url('/local/compile/list_modules.php', array('id' => $course->id));
$newnode = navigation_node::create(get_string('menucaption', 'local_compile'), $url, navigation_node::NODETYPE_LEAF, 'compile', 'compile', new pix_icon('i/settings', ''));
// We want to put this link at the top: find the existing top (first) node.
$firstnode = $coursenode->get_children_key_list()[0];
// Add the menu item to the menu, before the first node.
$coursenode->add_node($newnode, $firstnode);
}
示例2: add_modchoosertoggle
/**
* Adds the item in course settings navigation to toggle modchooser
*
* Theme can overwrite as an empty function to exclude it (for example if theme does not
* use modchooser at all)
*/
protected function add_modchoosertoggle()
{
global $CFG;
static $modchoosertoggleadded = false;
// Add the module chooser toggle to the course page
if ($modchoosertoggleadded || $this->page->state > moodle_page::STATE_PRINTING_HEADER || $this->page->course->id == SITEID || !$this->page->user_is_editing() || !($context = context_course::instance($this->page->course->id)) || !has_capability('moodle/course:update', $context) || !course_ajax_enabled($this->page->course) || !($coursenode = $this->page->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE)) || !$coursenode->get('editsettings')) {
// too late or we are on site page or we could not find the course settings node
// or we are not allowed to edit
return;
}
$modchoosertoggleadded = true;
if ($this->page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
// We are on the course page, retain the current page params e.g. section.
$modchoosertoggleurl = clone $this->page->url;
} else {
// Edit on the main course page.
$modchoosertoggleurl = new moodle_url('/course/view.php', array('id' => $this->page->course->id, 'return' => $this->page->url->out_as_local_url(false)));
}
$modchoosertoggleurl->param('sesskey', sesskey());
if ($usemodchooser = get_user_preferences('usemodchooser', $CFG->modchooserdefault)) {
$modchoosertogglestring = get_string('modchooserdisable', 'moodle');
$modchoosertoggleurl->param('modchooser', 'off');
} else {
$modchoosertogglestring = get_string('modchooserenable', 'moodle');
$modchoosertoggleurl->param('modchooser', 'on');
}
$modchoosertoggle = navigation_node::create($modchoosertogglestring, $modchoosertoggleurl, navigation_node::TYPE_SETTING);
$coursenode->add_node($modchoosertoggle, 'editsettings');
$modchoosertoggle->add_class('modchoosertoggle');
$modchoosertoggle->add_class('visibleifjs');
user_preference_allow_ajax_update('usemodchooser', PARAM_BOOL);
}
示例3: local_metadata_extends_settings_navigation
/**
* Sets up the main navigation
* @param settingsnav $settingsnav navigation settings object
* @param context $context Context of the form
*/
function local_metadata_extends_settings_navigation($settingsnav, $context)
{
global $CFG, $PAGE, $USER;
// Setup navigation for Admin metadata
if (is_null($PAGE->course)) {
//return;
} else {
if ($categorynode = $settingsnav->find('categorysettings', null)) {
$url = new moodle_url('/local/metadata/admview_knowledge.php', array('categoryid' => $PAGE->category->id));
$foonode = navigation_node::create(get_string('manage_pluginname', 'local_metadata'), $url, navigation_node::NODETYPE_LEAF, 'metadata', 'metadata', new pix_icon('i/report', ''));
if ($PAGE->url->compare($url, URL_MATCH_BASE)) {
$foonode->make_active();
}
$categorynode->add_node($foonode);
//$categorynode->add(get_string('manage_pluginname', 'local_metadata'), $url, self::TYPE_SETTING, null, 'permissions', new pix_icon('i/permissions', ''));
}
}
// Only add this settings item on non-site course pages.
if (!$PAGE->course or $PAGE->course->id == 1) {
return;
}
// TODO: Only let users with the appropriate capability see this settings item.
//if (!has_capability('local/metadata:ins_view', context_course::instance($PAGE->course->id))) {
// return;
//}
if ($settingnode = $settingsnav->find('courseadmin', navigation_node::TYPE_COURSE)) {
$url = new moodle_url('/local/metadata/insview_general.php', array('id' => $PAGE->course->id));
// TODO: Should change the name to something more descriptive
$foonode = navigation_node::create(get_string('ins_pluginname', 'local_metadata'), $url, navigation_node::NODETYPE_LEAF, 'metadata', 'metadata', new pix_icon('i/report', ''));
if ($PAGE->url->compare($url, URL_MATCH_BASE)) {
$foonode->make_active();
}
$settingnode->add_node($foonode);
}
}
示例4: tool_kent_extend_navigation_user_settings
/**
* This function extends the navigation with the tool items for user settings node.
*
* @param navigation_node $navigation The navigation node to extend
* @param stdClass $user The user object
* @param context $usercontext The context of the user
* @param stdClass $course The course to object for the tool
* @param context $coursecontext The context of the course
*/
function tool_kent_extend_navigation_user_settings($navigation, $user, $usercontext, $course, $coursecontext)
{
$url = new moodle_url('/local/kent/preferences.php');
$subsnode = navigation_node::create('Kent Preferences', $url, navigation_node::TYPE_SETTING, null, 'kent');
if (isset($subsnode) && !empty($navigation)) {
$navigation->add_node($subsnode);
}
}
示例5: tool_monitor_extend_navigation_user_settings
/**
* This function extends the navigation with the tool items for user settings node.
*
* @param navigation_node $navigation The navigation node to extend
* @param stdClass $user The user object
* @param context $usercontext The context of the user
* @param stdClass $course The course to object for the tool
* @param context $coursecontext The context of the course
*/
function tool_monitor_extend_navigation_user_settings($navigation, $user, $usercontext, $course, $coursecontext)
{
global $USER;
if ($USER->id == $user->id && has_capability('tool/monitor:subscribe', $coursecontext)) {
$url = new moodle_url('/admin/tool/monitor/index.php', array('courseid' => $course->id));
$subsnode = navigation_node::create(get_string('managesubscriptions', 'tool_monitor'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
if (isset($subsnode) && !empty($navigation)) {
$navigation->add_node($subsnode);
}
}
}
示例6: tool_monitor_extend_navigation_user_settings
/**
* This function extends the navigation with the tool items for user settings node.
*
* @param navigation_node $navigation The navigation node to extend
* @param stdClass $user The user object
* @param context $usercontext The context of the user
* @param stdClass $course The course to object for the tool
* @param context $coursecontext The context of the course
*/
function tool_monitor_extend_navigation_user_settings($navigation, $user, $usercontext, $course, $coursecontext)
{
global $USER, $SITE;
// Don't show the setting if the event monitor isn't turned on. No access to other peoples subscriptions.
if (get_config('tool_monitor', 'enablemonitor') && $USER->id == $user->id) {
// Now let's check to see if the user has any courses / site rules that they can subscribe to.
if ($courses = tool_monitor_get_user_courses()) {
$url = new moodle_url('/admin/tool/monitor/index.php');
$subsnode = navigation_node::create(get_string('managesubscriptions', 'tool_monitor'), $url, navigation_node::TYPE_SETTING, null, 'monitor', new pix_icon('i/settings', ''));
if (isset($subsnode) && !empty($navigation)) {
$navigation->add_node($subsnode);
}
}
}
}
示例7: local_forum2pdf_extends_settings_navigation
function local_forum2pdf_extends_settings_navigation(settings_navigation $nav, context $context)
{
global $PAGE;
// 教師にのみPDF出力を許可
if (!has_capability('moodle/course:manageactivities', $context)) {
return;
}
//echo "<pre>"; var_dump($PAGE->cm->instance); echo "</pre>";
if ($PAGE->context->contextlevel == CONTEXT_MODULE && $PAGE->cm->modname === 'forum') {
$pdflink = navigation_node::create(get_string('pdflink', 'local_forum2pdf'));
$pdflink->key = 'forum2pdf';
$pdflink->action = new moodle_url('/local/forum2pdf/export.php', array('f' => $PAGE->cm->instance));
$modulesettings = $nav->get('modulesettings');
$modulesettings->add_node($pdflink);
}
}
示例8: local_saml_site_extend_settings_navigation
function local_saml_site_extend_settings_navigation($settingsnav, $context)
{
global $CFG, $PAGE;
if (has_capability('local/saml_site:addrules', context_course::instance($PAGE->course->id))) {
$settingnode = $settingsnav->find('root', navigation_node::TYPE_SITE_ADMIN);
if ($settingnode) {
$setMotdMenuLbl = get_string('adminmenutitle', 'local_saml_site');
$setMotdUrl = new moodle_url('/local/saml_site/samlsitepermissions.php');
$setMotdnode = navigation_node::create($setMotdMenuLbl, $setMotdUrl, navigation_node::NODETYPE_LEAF, 'saml_site', 'saml_site', new pix_icon('i/settings', $setMotdMenuLbl));
if ($PAGE->url->compare($setMotdUrl, URL_MATCH_BASE)) {
$setMotdnode->make_active();
}
$settingnode->add_node($setMotdnode);
}
}
}
示例9: local_saml_siteenrol_extend_settings_navigation
function local_saml_siteenrol_extend_settings_navigation($settingsnav, $context)
{
global $CFG, $PAGE;
// Only let users with the appropriate capability see this settings item.
if (has_capability('local/saml_siteenrol:addorremoveusers', context_course::instance($PAGE->course->id))) {
if ($settingnode = $settingsnav->find('users', navigation_node::TYPE_CONTAINER)) {
$url = new moodle_url('/local/saml_siteenrol/usermanager.php', array('id' => $PAGE->course->id));
$strfoo = get_string('menuname', 'local_saml_siteenrol');
$foonode = navigation_node::create($strfoo, $url, navigation_node::NODETYPE_LEAF, 'saml_siteenrol', 'saml_siteenrol', new pix_icon('i/enrolusers', $strfoo));
if ($PAGE->url->compare($url, URL_MATCH_BASE)) {
$foonode->make_active();
}
$settingnode->add_node($foonode);
}
}
}
示例10: tool_monitor_extend_navigation_user_settings
/**
* This function extends the navigation with the tool items for user settings node.
*
* @param navigation_node $navigation The navigation node to extend
* @param stdClass $user The user object
* @param context $usercontext The context of the user
* @param stdClass $course The course to object for the tool
* @param context $coursecontext The context of the course
*/
function tool_monitor_extend_navigation_user_settings($navigation, $user, $usercontext, $course, $coursecontext)
{
global $USER, $SITE;
if ($USER->id == $user->id && (has_capability('tool/monitor:subscribe', $coursecontext) && get_config('tool_monitor', 'enablemonitor'))) {
// The $course->id will always be the course that corresponds to the current context.
$courseid = $course->id;
// A $course->id of $SITE->id might either be the frontpage or the site. So if we get the site ID back, check the...
// ...courseid parameter passed to the page so we can know if we are looking at the frontpage rules or site level rules.
if ($course->id == $SITE->id && optional_param('courseid', $course->id, PARAM_INT) == 0) {
$courseid = 0;
}
$url = new moodle_url('/admin/tool/monitor/index.php', array('courseid' => $courseid));
$subsnode = navigation_node::create(get_string('managesubscriptions', 'tool_monitor'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
if (isset($subsnode) && !empty($navigation)) {
$navigation->add_node($subsnode);
}
}
}
示例11: local_enrolmentreminder_extends_settings_navigation
function local_enrolmentreminder_extends_settings_navigation($settingsnav)
{
global $PAGE;
global $DB;
global $USER;
global $SITE;
if (has_capability('moodle/site:config', context_system::instance())) {
if ($PAGE->context->contextlevel == CONTEXT_COURSE && $PAGE->course->id != $SITE->id) {
if ($settingnode = $settingsnav->find('courseadmin', navigation_node::TYPE_COURSE)) {
$url = new moodle_url('/local/enrolmentreminder/index.php', array('courseid' => $PAGE->course->id));
$mynode = navigation_node::create(get_string('enrolmentreminder', 'local_enrolmentreminder'), $url, navigation_node::NODETYPE_LEAF, 'local_enrolmentreminder', 'local_enrolmentreminder', new pix_icon('enrolmentreminder-16', get_string('enrolmentreminder', 'local_enrolmentreminder'), 'local_enrolmentreminder'));
if ($PAGE->url->compare($url, URL_MATCH_BASE)) {
$mynode->make_active();
}
$settingnode->add_node($mynode);
}
}
}
}
示例12: local_syncgroups_extends_settings_navigation
function local_syncgroups_extends_settings_navigation(settings_navigation $nav, context $context = null)
{
global $PAGE;
// Only add this settings item on non-site course pages.
if (!$PAGE->course or $PAGE->course->id == 1) {
return;
}
if ($coursenode = $nav->get('courseadmin')) {
if ($usersnode = $coursenode->get('users')) {
$str = get_string('pluginname', 'local_syncgroups');
$url = new moodle_url('/local/syncgroups/index.php', array('courseid' => $context->instanceid));
$node = navigation_node::create($str, $url, navigation_node::NODETYPE_LEAF, 'local_syncgroups', 'local_syncgroups');
if ($PAGE->url->compare($url, URL_MATCH_BASE)) {
$node->make_active();
}
$usersnode->add_node($node, 'override');
}
}
}
示例13: get_course_categories
/**
* Get the list of categories leading to this course.
*
* This function is used by {@link navbar::get_items()} to add back the "courses"
* node and category chain leading to the current course. Note that this is only ever
* called for the current course, so we don't need to bother taking in any parameters.
*
* @return array
*/
private function get_course_categories()
{
global $CFG;
require_once $CFG->dirroot . '/course/lib.php';
$categories = array();
$cap = 'moodle/category:viewhiddencategories';
foreach ($this->page->categories as $category) {
if (!$category->visible && !has_capability($cap, get_category_or_system_context($category->parent))) {
continue;
}
$url = new moodle_url('/course/index.php', array('categoryid' => $category->id));
$name = format_string($category->name, true, array('context' => context_coursecat::instance($category->id)));
$categorynode = navigation_node::create($name, $url, self::TYPE_CATEGORY, null, $category->id);
if (!$category->visible) {
$categorynode->hidden = true;
}
$categories[] = $categorynode;
}
if (is_enrolled(context_course::instance($this->page->course->id))) {
$courses = $this->page->navigation->get('mycourses');
} else {
$courses = $this->page->navigation->get('courses');
}
if (!$courses) {
// Courses node may not be present.
$courses = navigation_node::create(get_string('courses'), new moodle_url('/course/index.php'), self::TYPE_CONTAINER);
}
$categories[] = $courses;
return $categories;
}
示例14: quiz_extend_settings_navigation
/**
* This function extends the settings navigation block for the site.
*
* It is safe to rely on PAGE here as we will only ever be within the module
* context when this is called
*
* @param settings_navigation $settings
* @param navigation_node $quiznode
*/
function quiz_extend_settings_navigation($settings, $quiznode) {
global $PAGE, $CFG;
// Require {@link questionlib.php}
// Included here as we only ever want to include this file if we really need to.
require_once($CFG->libdir . '/questionlib.php');
// We want to add these new nodes after the Edit settings node, and before the
// Locally assigned roles node. Of course, both of those are controlled by capabilities.
$keys = $quiznode->get_children_key_list();
$beforekey = null;
$i = array_search('modedit', $keys);
if ($i === false and array_key_exists(0, $keys)) {
$beforekey = $keys[0];
} else if (array_key_exists($i + 1, $keys)) {
$beforekey = $keys[$i + 1];
}
if (has_capability('mod/quiz:manageoverrides', $PAGE->cm->context)) {
$url = new moodle_url('/mod/quiz/overrides.php', array('cmid'=>$PAGE->cm->id));
$node = navigation_node::create(get_string('groupoverrides', 'quiz'),
new moodle_url($url, array('mode'=>'group')),
navigation_node::TYPE_SETTING, null, 'mod_quiz_groupoverrides');
$quiznode->add_node($node, $beforekey);
$node = navigation_node::create(get_string('useroverrides', 'quiz'),
new moodle_url($url, array('mode'=>'user')),
navigation_node::TYPE_SETTING, null, 'mod_quiz_useroverrides');
$quiznode->add_node($node, $beforekey);
}
if (has_capability('mod/quiz:manage', $PAGE->cm->context)) {
$node = navigation_node::create(get_string('editquiz', 'quiz'),
new moodle_url('/mod/quiz/edit.php', array('cmid'=>$PAGE->cm->id)),
navigation_node::TYPE_SETTING, null, 'mod_quiz_edit',
new pix_icon('t/edit', ''));
$quiznode->add_node($node, $beforekey);
}
if (has_capability('mod/quiz:preview', $PAGE->cm->context)) {
$url = new moodle_url('/mod/quiz/startattempt.php',
array('cmid'=>$PAGE->cm->id, 'sesskey'=>sesskey()));
$node = navigation_node::create(get_string('preview', 'quiz'), $url,
navigation_node::TYPE_SETTING, null, 'mod_quiz_preview',
new pix_icon('t/preview', ''));
$quiznode->add_node($node, $beforekey);
}
question_extend_settings_navigation($quiznode, $PAGE->cm->context)->trim_if_empty();
}
示例15: customcert_extend_settings_navigation
/**
* This function extends the settings navigation block for the site.
*
* It is safe to rely on PAGE here as we will only ever be within the module
* context when this is called.
*
* @param settings_navigation $settings
* @param navigation_node $customcertnode
*/
function customcert_extend_settings_navigation(settings_navigation $settings, navigation_node $customcertnode)
{
global $PAGE;
$keys = $customcertnode->get_children_key_list();
$beforekey = null;
$i = array_search('modedit', $keys);
if ($i === false and array_key_exists(0, $keys)) {
$beforekey = $keys[0];
} else {
if (array_key_exists($i + 1, $keys)) {
$beforekey = $keys[$i + 1];
}
}
if (has_capability('mod/customcert:manage', $PAGE->cm->context)) {
$node = navigation_node::create(get_string('editcustomcert', 'customcert'), new moodle_url('/mod/customcert/edit.php', array('cmid' => $PAGE->cm->id)), navigation_node::TYPE_SETTING, null, 'mod_customcert_edit', new pix_icon('t/edit', ''));
$customcertnode->add_node($node, $beforekey);
}
return $customcertnode->trim_if_empty();
}