當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。