当前位置: 首页>>代码示例>>PHP>>正文


PHP navigation_node::find方法代码示例

本文整理汇总了PHP中navigation_node::find方法的典型用法代码示例。如果您正苦于以下问题:PHP navigation_node::find方法的具体用法?PHP navigation_node::find怎么用?PHP navigation_node::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在navigation_node的用法示例。


在下文中一共展示了navigation_node::find方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: local_ltiprovider_extend_navigation

/**
 * Change the navigation block and bar only for external users
 * Force course or activity navigation and modify CSS also
 * Please note that this function is only called in pages where the navigation block is present
 *
 * @global moodle_user $USER
 * @global moodle_database $DB
 * @param navigation_node $nav Current navigation object
 */
function local_ltiprovider_extend_navigation($nav) {
    global $USER, $PAGE, $SESSION;

    // Check capabilities for tool providers
    // TODO Change this for Moodle 2.3:
    // use extend_navigation_course and extend_navigation_user
    if ($PAGE->course->id and $PAGE->course->id != SITEID and has_capability('local/ltiprovider:view', $PAGE->context)) {
        $ltiurl = new moodle_url('/local/ltiprovider/index.php', array('courseid' => $PAGE->course->id));
        $coursenode = $nav->find($PAGE->course->id, $nav::TYPE_COURSE);
        $coursenode->add(get_string('pluginname', 'local_ltiprovider'), $ltiurl, $nav::TYPE_CONTAINER, null, 'ltiprovider' . $PAGE->course->id);
    }

    if (isset($USER) and isset($USER->auth) and $USER->auth == 'nologin' and strpos($USER->username, 'ltiprovider') === 0) {
        // Force course or activity navigation
        if (isset($SESSION->ltiprovider) and $SESSION->ltiprovider->forcenavigation) {
            $context = $SESSION->ltiprovider->context;
            $urltogo = '';
            if ($context->contextlevel == CONTEXT_COURSE and $PAGE->course->id != $SESSION->ltiprovider->courseid) {
                $urltogo = new moodle_url('/course/view.php', array('id' => $SESSION->ltiprovider->courseid));
            } else if ($context->contextlevel == CONTEXT_MODULE and $PAGE->context->id != $context->id) {
                $cm = get_coursemodule_from_id(false, $context->instanceid, 0, false, MUST_EXIST);
                $urltogo = new moodle_url('/mod/' . $cm->modname . '/view.php', array('id' => $cm->id));
            }

            if ($urltogo) {
                redirect($urltogo);
            }
        }

        // Delete all the navigation nodes except the course one
        $coursenode = $nav->find($PAGE->course->id, $nav::TYPE_COURSE);
        foreach (array('myprofile', 'users', 'site', 'home', 'myhome', 'mycourses', 'courses', '1') as $nodekey) {
            if ($node = $nav->get($nodekey)) {
                $node->remove();
            }
        }
        $nav->children->add($coursenode);

        // Custom CSS
        if (isset($SESSION->ltiprovider)) {
            $PAGE->requires->css(new moodle_url('/local/ltiprovider/styles.php', array('id' => $SESSION->ltiprovider->id)));
        }
    }
}
开发者ID:anilch,项目名称:Personel,代码行数:53,代码来源:lib.php

示例2: test_find

 public function test_find() {
     $node1 = $this->node->find('demo1', navigation_node::TYPE_COURSE);
     $node2 = $this->node->find('demo5', navigation_node::TYPE_COURSE);
     $node3 = $this->node->find('demo5', navigation_node::TYPE_CATEGORY);
     $node4 = $this->node->find('demo0', navigation_node::TYPE_COURSE);
     $this->assertIsA($node1, 'navigation_node');
     $this->assertIsA($node2, 'navigation_node');
     $this->assertNotA($node3, 'navigation_node');
     $this->assertNotA($node4, 'navigation_node');
 }
开发者ID:nfreear,项目名称:moodle,代码行数:10,代码来源:testnavigationlib.php

示例3: test_find

 public function test_find() {
     $node1 = $this->node->find('demo1', navigation_node::TYPE_COURSE);
     $node2 = $this->node->find('demo5', navigation_node::TYPE_COURSE);
     $node3 = $this->node->find('demo5', navigation_node::TYPE_CATEGORY);
     $node4 = $this->node->find('demo0', navigation_node::TYPE_COURSE);
     $this->assertInstanceOf('navigation_node', $node1);
     $this->assertInstanceOf('navigation_node', $node2);
     $this->assertNotInstanceOf('navigation_node', $node3);
     $this->assertNotInstanceOf('navigation_node', $node4);
 }
开发者ID:robadobdob,项目名称:moodle,代码行数:10,代码来源:navigationlib_test.php

示例4: local_ltiprovider_extends_navigation

/**
 * Change the navigation block and bar only for external users
 * Force course or activity navigation and modify CSS also
 * Please note that this function is only called in pages where the navigation block is present
 *
 * @global moodle_user $USER
 * @global moodle_database $DB
 * @param navigation_node $nav Current navigation object
 */
function local_ltiprovider_extends_navigation($nav)
{
    global $CFG, $USER, $PAGE, $SESSION, $ME;
    // Check capabilities for tool providers
    // Only for Moodle < 2.3 versions
    if ($CFG->version < 2012062500 and $PAGE->course->id and $PAGE->course->id != SITEID and has_capability('local/ltiprovider:view', $PAGE->context)) {
        $ltiurl = new moodle_url('/local/ltiprovider/index.php', array('courseid' => $PAGE->course->id));
        $coursenode = $nav->find($PAGE->course->id, $nav::TYPE_COURSE);
        $coursenode->add(get_string('pluginname', 'local_ltiprovider'), $ltiurl, $nav::TYPE_CONTAINER, null, 'ltiprovider' . $PAGE->course->id);
    }
    if (isset($USER) and isset($USER->auth) and strpos($USER->username, 'ltiprovider') === 0) {
        // Force course or activity navigation
        if (isset($SESSION->ltiprovider) and $SESSION->ltiprovider->forcenavigation) {
            $context = $SESSION->ltiprovider->context;
            $urltogo = '';
            if ($context->contextlevel == CONTEXT_COURSE and $PAGE->course->id != $SESSION->ltiprovider->courseid) {
                $urltogo = new moodle_url('/course/view.php', array('id' => $SESSION->ltiprovider->courseid));
            } else {
                if ($context->contextlevel == CONTEXT_MODULE and $PAGE->context->id != $context->id) {
                    $cm = get_coursemodule_from_id(false, $context->instanceid, 0, false, MUST_EXIST);
                    $urltogo = new moodle_url('/mod/' . $cm->modname . '/view.php', array('id' => $cm->id));
                }
            }
            // Special case, user policy, we don't have to do nothing to avoid infinites loops.
            if (strpos($ME, 'user/policy.php')) {
                return;
            }
            if ($urltogo) {
                redirect($urltogo);
            }
        }
        // Delete all the navigation nodes except the course one
        if ($coursenode = $nav->find($PAGE->course->id, $nav::TYPE_COURSE)) {
            foreach (array('myprofile', 'users', 'site', 'home', 'myhome', 'mycourses', 'courses', '1') as $nodekey) {
                if ($node = $nav->get($nodekey)) {
                    $node->remove();
                }
            }
            $nav->children->add($coursenode);
        }
        // Custom CSS
        if (isset($SESSION->ltiprovider) and !$PAGE->requires->is_head_done()) {
            $PAGE->requires->css(new moodle_url('/local/ltiprovider/styles.php', array('id' => $SESSION->ltiprovider->id)));
        } else {
            $url = new moodle_url('/local/ltiprovider/styles.js.php', array('id' => $SESSION->ltiprovider->id, 'rand' => rand(0, 1000)));
            $PAGE->requires->js($url);
        }
    }
}
开发者ID:gabrielrosset,项目名称:moodle-local_ltiprovider,代码行数:58,代码来源:lib.php

示例5: find

 /**
  * Searches this nodes children and their children to find a navigation node
  * with the matching key and type.
  *
  * This method is recursive and searches children so until either a node is
  * found or there are no more nodes to search.
  *
  * If you know that the node being searched for is a child of this node
  * then use the {@link global_navigation::get()} method instead.
  *
  * Note: If you are trying to set the active node {@link navigation_node::override_active_url()}
  * may be of more use to you.
  *
  * @param string|int $key The key of the node you wish to receive.
  * @param int $type One of navigation_node::TYPE_*
  * @return navigation_node|false
  */
 public function find($key, $type)
 {
     if (!$this->initialised) {
         $this->initialise();
     }
     return parent::find($key, $type);
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:24,代码来源:navigationlib.php

示例6: find

 /**
  * Searches this nodes children and their children to find a navigation node
  * with the matching key and type.
  *
  * This method is recursive and searches children so until either a node is
  * found or there are no more nodes to search.
  *
  * If you know that the node being searched for is a child of this node
  * then use the {@link global_navigation::get()} method instead.
  *
  * Note: If you are trying to set the active node {@link navigation_node::override_active_url()}
  * may be of more use to you.
  *
  * @param string|int $key The key of the node you wish to receive.
  * @param int $type One of navigation_node::TYPE_*
  * @return navigation_node|false
  */
 public function find($key, $type)
 {
     if (!$this->initialised) {
         $this->initialise();
     }
     if ($type == self::TYPE_ROOTNODE && array_key_exists($key, $this->rootnodes)) {
         return $this->rootnodes[$key];
     }
     return parent::find($key, $type);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:27,代码来源:navigationlib.php

示例7: add_category

 /**
  * Adds a structured category to the navigation in the correct order/place
  *
  * @param stdClass $category
  * @param navigation_node $parent
  */
 protected function add_category(stdClass $category, navigation_node $parent, $nodetype = self::TYPE_CATEGORY)
 {
     if (!$this->expandtocourses && $parent->key == 'courses' || $parent->find($category->id, self::TYPE_CATEGORY)) {
         return;
     }
     $url = new moodle_url('/course/category.php', array('id' => $category->id));
     $context = context_coursecat::instance($category->id);
     $categoryname = format_string($category->name, true, array('context' => $context));
     $categorynode = $parent->add($categoryname, $url, $nodetype, $categoryname, $category->id);
     if (empty($category->visible)) {
         if (has_capability('moodle/category:viewhiddencategories', context_system::instance())) {
             $categorynode->hidden = true;
         } else {
             $categorynode->display = false;
         }
     }
     $this->addedcategories[$category->id] = $categorynode;
 }
开发者ID:actXc,项目名称:moodle-theme_decaf,代码行数:24,代码来源:lib.php


注:本文中的navigation_node::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。