當前位置: 首頁>>代碼示例>>PHP>>正文


PHP navigation_node::get_css_type方法代碼示例

本文整理匯總了PHP中navigation_node::get_css_type方法的典型用法代碼示例。如果您正苦於以下問題:PHP navigation_node::get_css_type方法的具體用法?PHP navigation_node::get_css_type怎麽用?PHP navigation_node::get_css_type使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在navigation_node的用法示例。


在下文中一共展示了navigation_node::get_css_type方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: convert_child

 /**
  * Recusively converts a child node and its children to XML for output
  *
  * @param navigation_node $child The child to convert
  * @param int $depth Pointlessly used to track the depth of the XML structure
  * @return string JSON
  */
 protected function convert_child($child, $depth = 1)
 {
     if (!$child->display) {
         return '';
     }
     $attributes = array();
     $attributes['id'] = $child->id;
     $attributes['name'] = $child->text;
     $attributes['type'] = $child->type;
     $attributes['key'] = $child->key;
     $attributes['class'] = $child->get_css_type();
     if ($child->icon instanceof pix_icon) {
         $attributes['icon'] = array('component' => $child->icon->component, 'pix' => $child->icon->pix);
         foreach ($child->icon->attributes as $key => $value) {
             if ($key == 'class') {
                 $attributes['icon']['classes'] = explode(' ', $value);
             } else {
                 if (!array_key_exists($key, $attributes['icon'])) {
                     $attributes['icon'][$key] = $value;
                 }
             }
         }
     } else {
         if (!empty($child->icon)) {
             $attributes['icon'] = (string) $child->icon;
         }
     }
     if ($child->forcetitle || $child->title !== $child->text) {
         $attributes['title'] = htmlentities($child->title, ENT_QUOTES, 'UTF-8');
     }
     if (array_key_exists($child->key . ':' . $child->type, $this->expandable)) {
         $attributes['expandable'] = $child->key;
         $child->add_class($this->expandable[$child->key . ':' . $child->type]['id']);
     }
     if (count($child->classes) > 0) {
         $attributes['class'] .= ' ' . join(' ', $child->classes);
     }
     if (is_string($child->action)) {
         $attributes['link'] = $child->action;
     } else {
         if ($child->action instanceof moodle_url) {
             $attributes['link'] = $child->action->out();
         } else {
             if ($child->action instanceof action_link) {
                 $attributes['link'] = $child->action->url->out();
             }
         }
     }
     $attributes['hidden'] = $child->hidden;
     $attributes['haschildren'] = $child->children->count() > 0 || $child->type == navigation_node::TYPE_CATEGORY;
     if ($child->children->count() > 0) {
         $attributes['children'] = array();
         foreach ($child->children as $subchild) {
             $attributes['children'][] = $this->convert_child($subchild, $depth + 1);
         }
     }
     if ($depth > 1) {
         return $attributes;
     } else {
         return json_encode($attributes);
     }
 }
開發者ID:saurabh947,項目名稱:MoodleLearning,代碼行數:69,代碼來源:navigationlib.php


注:本文中的navigation_node::get_css_type方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。