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


PHP navigation_node::set_parent方法代码示例

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


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

示例1: add_node

 /**
  * Adds a navigation node as a child of this one, given a $node object
  * created using the create function.
  * @param navigation_node $childnode Node to add
  * @param string $beforekey
  * @return navigation_node The added node
  */
 public function add_node(navigation_node $childnode, $beforekey = null)
 {
     // First convert the nodetype for this node to a branch as it will now have children
     if ($this->nodetype !== self::NODETYPE_BRANCH) {
         $this->nodetype = self::NODETYPE_BRANCH;
     }
     // Set the parent to this node
     $childnode->set_parent($this);
     // Default the key to the number of children if not provided
     if ($childnode->key === null) {
         $childnode->key = $this->children->count();
     }
     // Add the child using the navigation_node_collections add method
     $node = $this->children->add($childnode, $beforekey);
     // If added node is a category node or the user is logged in and it's a course
     // then mark added node as a branch (makes it expandable by AJAX)
     $type = $childnode->type;
     if ($type == self::TYPE_CATEGORY || isloggedin() && $type == self::TYPE_COURSE) {
         $node->nodetype = self::NODETYPE_BRANCH;
     }
     // If this node is hidden mark it's children as hidden also
     if ($this->hidden) {
         $node->hidden = true;
     }
     // Return added node (reference returned by $this->children->add()
     return $node;
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:34,代码来源:navigationlib.php


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