当前位置: 首页>>代码示例>>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;未经允许,请勿转载。