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


PHP custom_menu_item::has_children方法代码示例

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


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

示例1: render_custom_menu_item

 /**
  * Renders a custom menu node as part of a submenu
  *
  * The custom menu this method override the render_custom_menu_item function
  * in outputrenderers.php
  *
  * @see render_custom_menu()
  *
  * @staticvar int $submenucount
  * @param custom_menu_item $menunode
  * @return string
  */
 protected function render_custom_menu_item(custom_menu_item $menunode)
 {
     // Required to ensure we get unique trackable id's
     static $submenucount = 0;
     $content = html_writer::start_tag('li');
     if ($menunode->has_children()) {
         // If the child has menus render it as a sub menu
         $submenucount++;
         if ($menunode->get_url() !== null) {
             $url = $menunode->get_url();
         } else {
             $url = '#cm_submenu_' . $submenucount;
         }
         $content .= html_writer::start_tag('span', array('class' => 'customitem'));
         $content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
         $content .= html_writer::end_tag('span');
         $content .= html_writer::start_tag('ul');
         foreach ($menunode->get_children() as $menunode) {
             $content .= $this->render_custom_menu_item($menunode);
         }
         $content .= html_writer::end_tag('ul');
     } else {
         // The node doesn't have children so produce a final menuitem
         if ($menunode->get_url() !== null) {
             $url = $menunode->get_url();
         } else {
             $url = '#';
         }
         $content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
     }
     $content .= html_writer::end_tag('li');
     // Return the sub menu
     return $content;
 }
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:46,代码来源:renderers.php

示例2: render_custom_menu_item

 protected function render_custom_menu_item(custom_menu_item $menunode, $level = 0)
 {
     static $submenucount = 0;
     if ($menunode->has_children()) {
         if ($level == 1) {
             $class = 'dropdown';
         } else {
             $class = 'dropdown-submenu';
         }
         if ($menunode === $this->language) {
             $class .= ' langmenu';
         }
         $content = html_writer::start_tag('li', array('class' => $class));
         // If the child has menus render it as a sub menu.
         $submenucount++;
         if ($menunode->get_url() !== null) {
             $url = $menunode->get_url();
             $richID = $menunode->get_text();
             //************added by Richard to give custom IDs to menu itmes based on the title************
         } else {
             $url = '#cm_submenu_' . $submenucount;
         }
         $content .= html_writer::start_tag('a', array('href' => $url, 'class' => 'dropdown-toggle', 'id' => $richID, 'data-toggle' => 'dropdown', 'title' => $menunode->get_title()));
         $content .= $menunode->get_text();
         if ($level == 1) {
             $content .= '<b class="caret"></b>';
         }
         $content .= '</a>';
         $content .= '<ul class="dropdown-menu">';
         foreach ($menunode->get_children() as $menunode) {
             $content .= $this->render_custom_menu_item($menunode, 0);
         }
         $content .= '</ul>';
     } else {
         $content = '<li>';
         // The node doesn't have children so produce a final menuitem.
         if ($menunode->get_url() !== null) {
             $url = $menunode->get_url();
             $richID = $menunode->get_text();
             //************added by Richard to give custom IDs to menu itmes based on the title************
         } else {
             $url = '#';
         }
         $content .= html_writer::link($url, $menunode->get_text(), array('id' => $richID, 'title' => $menunode->get_title()));
     }
     return $content;
 }
开发者ID:digitalquest,项目名称:moodle_themex,代码行数:47,代码来源:core_renderer_back020714.php

示例3: render_custom_menu_item

    protected function render_custom_menu_item(custom_menu_item $menunode, $level = 0, $direction = '' ) {
        static $submenucount = 0;

        if ($menunode->has_children()) {

            if ($level == 1) {
                $dropdowntype = 'dropdown';
            } else {
                $dropdowntype = 'dropdown-submenu';
            }

            $content = html_writer::start_tag('li', array('class' => $dropdowntype));
            // If the child has menus render it as a sub menu.
            $submenucount++;
            if ($menunode->get_url() !== null) {
                $url = $menunode->get_url();
            } else {
                $url = '#cm_submenu_'.$submenucount;
            }
            $linkattributes = array(
                'href' => $url,
                'class' => 'dropdown-toggle',
                'data-toggle' => 'dropdown',
                'title' => $menunode->get_title(),
            );
            $content .= html_writer::start_tag('a', $linkattributes);
            $content .= $menunode->get_text();
            if ($level == 1) {
                $content .= '<b class="caret"></b>';
            }
            $content .= '</a>';
            $content .= '<ul class="dropdown-menu '.$direction.'">';
            foreach ($menunode->get_children() as $menunode) {
                $content .= $this->render_custom_menu_item($menunode, 0);
            }
            $content .= '</ul>';
        } else {
            $content = '<li>';
            // The node doesn't have children so produce a final menuitem.
            $class = $menunode->get_title();
            if (preg_match("/^#+$/", $menunode->get_text())) {
                $content = '<li class="divider" role="presentation">';
            } else  {
                $content = '<li>';
            // The node doesn't have children so produce a final menuitem.
                if ($menunode->get_url() !== null) {
                    $url = $menunode->get_url();
                } else {
                    $url = '#';
                }
                $content .= html_writer::link($url, $menunode->get_text(), array('class' => $class, 'title' => $menunode->get_title()));
            }
        }
        return $content;
    }
开发者ID:syedhameed,项目名称:sc,代码行数:55,代码来源:core_renderer.php

示例4: render_custom_menu_item

    /**
     * Renders a custom menu node as part of a submenu
     *
     * The custom menu this method produces makes use of the YUI3 menunav widget
     * and requires very specific html elements and classes.
     *
     * @see core:renderer::render_custom_menu()
     *
     * @staticvar int $submenucount
     * @param custom_menu_item $menunode
     * @return string
     */
    protected function render_custom_menu_item(custom_menu_item $menunode) {
        // Required to ensure we get unique trackable id's
        static $submenucount = 0;
        if ($menunode->has_children()) {
            // If the child has menus render it as a sub menu
            $submenucount++;
            $content = html_writer::start_tag('li');
            if ($menunode->get_url() !== null) {
                $url = $menunode->get_url();
            } else {
                $url = '#cm_submenu_'.$submenucount;
            }
            $content .= html_writer::link($url, $menunode->get_text(), array('class'=>'yui3-menu-label', 'title'=>$menunode->get_title()));
            $content .= html_writer::start_tag('div', array('id'=>'cm_submenu_'.$submenucount, 'class'=>'yui3-menu custom_menu_submenu'));
            $content .= html_writer::start_tag('div', array('class'=>'yui3-menu-content'));
            $content .= html_writer::start_tag('ul');
            foreach ($menunode->get_children() as $menunode) {
                $content .= $this->render_custom_menu_item($menunode);
            }
            $content .= html_writer::end_tag('ul');
            $content .= html_writer::end_tag('div');
            $content .= html_writer::end_tag('div');
            $content .= html_writer::end_tag('li');
        } else {
            // The node doesn't have children so produce a final menuitem.
            // Also, if the node's text matches '####', add a class so we can treat it as a divider.
            $content = '';
            if (preg_match("/^#+$/", $menunode->get_text())) {

                // This is a divider.
                $content = html_writer::start_tag('li', array('class' => 'yui3-menuitem divider'));
            } else {
                $content = html_writer::start_tag(
                    'li',
                    array(
                        'class' => 'yui3-menuitem'
                    )
                );
                if ($menunode->get_url() !== null) {
                    $url = $menunode->get_url();
                } else {
                    $url = '#';
                }
                $content .= html_writer::link(
                    $url,
                    $menunode->get_text(),
                    array('class' => 'yui3-menuitem-content', 'title' => $menunode->get_title())
                );
            }
            $content .= html_writer::end_tag('li');
        }
        // Return the sub menu
        return $content;
    }
开发者ID:afgal,项目名称:moodle-1,代码行数:66,代码来源:outputrenderers.php

示例5: render_custom_menu_item

 protected function render_custom_menu_item(custom_menu_item $menunode, $level = 0)
 {
     static $submenucount = 0;
     $content = '';
     if ($menunode->has_children()) {
         if ($level == 1) {
             $class = 'dropdown';
         } else {
             $class = 'dropdown-submenu';
         }
         if ($menunode === $this->language) {
             $class .= ' langmenu';
         }
         $content = html_writer::start_tag('li', array('class' => $class));
         // If the child has menus render it as a sub menu.
         $submenucount++;
         if ($menunode->get_url() !== null) {
             $url = $menunode->get_url();
         } else {
             $url = '#cm_submenu_' . $submenucount;
         }
         $content .= html_writer::start_tag('a', array('href' => $url, 'class' => 'dropdown-toggle', 'data-toggle' => 'dropdown', 'title' => $menunode->get_title()));
         $content .= $menunode->get_text();
         if ($level == 1) {
             $content .= '<b class="caret"></b>';
         }
         $content .= '</a>';
         $content .= '<ul class="dropdown-menu">';
         foreach ($menunode->get_children() as $menunode) {
             $content .= $this->render_custom_menu_item($menunode, 0);
         }
         $content .= '</ul>';
     } else {
         // The node doesn't have children so produce a final menuitem.
         // Also, if the node's text matches '####', add a class so we can treat it as a divider.
         if (preg_match("/^#+\$/", $menunode->get_text())) {
             // This is a divider.
             $content = '<li class="divider">&nbsp;</li>';
         } else {
             $content = '<li>';
             if ($menunode->get_url() !== null) {
                 $url = $menunode->get_url();
             } else {
                 $url = '#';
             }
             $content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
             $content .= '</li>';
         }
     }
     return $content;
 }
开发者ID:educakanchay,项目名称:campus,代码行数:51,代码来源:core_renderer.php

示例6: render_custom_menu_item

 protected function render_custom_menu_item(custom_menu_item $menunode, $level = 0)
 {
     global $COURSE, $USER, $CFG;
     static $submenucount = 0;
     if ($menunode->has_children()) {
         if ($level == 1) {
             $class = 'dropdown';
         } else {
             $class = 'dropdown-submenu';
         }
         if ($menunode->get_url() !== null) {
             $url = $menunode->get_url();
         } else {
             $url = '#cm_submenu_' . $submenucount;
         }
         // allow protected menu items to only logged in
         if (preg_match('/^!/', $url)) {
             if (!isloggedin() || isguestuser()) {
                 return;
             } else {
                 $url = preg_replace('/^!/', '', $url);
             }
         }
         // Url context variables replacement if needed in menu (first catch escaped form).
         $url = preg_replace('/%25WWWROOT%25/', $CFG->wwwroot, $url);
         $url = preg_replace('/%WWWROOT%/', $CFG->wwwroot, $url);
         $url = preg_replace('/%25COURSEID%25/', $COURSE->id, $url);
         $url = preg_replace('/%COURSEID%/', $COURSE->id, $url);
         $url = preg_replace('/%25USERID%25/', $USER->id, $url);
         $url = preg_replace('/%USERID%/', $USER->id, $url);
         if ($menunode === $this->language) {
             $class .= ' langmenu';
         }
         $content = html_writer::start_tag('li', array('class' => $class));
         // If the child has menus render it as a sub menu.
         $submenucount++;
         if ($menunode->get_url() !== null) {
             $url = $menunode->get_url();
         } else {
             $url = '#cm_submenu_' . $submenucount;
         }
         $content .= html_writer::start_tag('a', array('href' => $url, 'class' => 'dropdown-toggle', 'data-toggle' => 'dropdown', 'title' => $menunode->get_title()));
         $content .= $menunode->get_text();
         if ($level == 1) {
             $content .= '<b class="caret"></b>';
         }
         $content .= '</a>';
         $content .= '<ul class="dropdown-menu">';
         foreach ($menunode->get_children() as $menunode) {
             $content .= $this->render_custom_menu_item($menunode, 0);
         }
         $content .= '</ul>';
     } else {
         $content = '<li>';
         // The node doesn't have children so produce a final menuitem.
         if ($menunode->get_url() !== null) {
             $url = $menunode->get_url();
         } else {
             $url = '#';
         }
         $coursecontext = context_course::instance($COURSE->id);
         // allow protected menu items to only logged in
         if (preg_match('/^([^!]*)!(.*)$/', $url, $matches)) {
             if (empty($matches[1])) {
                 if (!isloggedin() || isguestuser()) {
                     return;
                 } else {
                     $url = preg_replace('/^!/', '', $url);
                 }
             } else {
                 if (has_capability($matches[1], $coursecontext)) {
                     $url = $matches[2];
                 } else {
                     return;
                 }
             }
         }
         // Url context variables replacement if needed in menu (first catch escaped form).
         $url = preg_replace('/%25WWWROOT%25/', $CFG->wwwroot, $url);
         $url = preg_replace('/%WWWROOT%/', $CFG->wwwroot, $url);
         $url = preg_replace('/%25COURSEID%25/', $COURSE->id, $url);
         $url = preg_replace('/%COURSEID%/', $COURSE->id, $url);
         $url = preg_replace('/%25USERID%25/', $USER->id, $url);
         $url = preg_replace('/%USERID%/', $USER->id, $url);
         $content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
     }
     return $content;
 }
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:88,代码来源:renderers.php

示例7: render_custom_menu_item

 protected function render_custom_menu_item(custom_menu_item $menunode, $submenu = null)
 {
     if ('list_divider' === $menunode->get_text()) {
         return bootstrap::list_divider();
     }
     if (!$menunode->has_children()) {
         return $this->render_custom_menu_leaf($menunode);
     }
     foreach ($menunode->get_children() as $child) {
         $items[] = $this->render_custom_menu_item($child, true);
     }
     if ($submenu === true) {
         return html::li(bootstrap::dropdown_submenu($menunode->get_text(), $items));
     } else {
         return html::li(bootstrap::dropdown_menu($menunode->get_text(), $items));
     }
 }
开发者ID:rbclark,项目名称:moodle-theme_bootstrap_renderers,代码行数:17,代码来源:core_renderer.php

示例8: render_custom_menu_item

 /**
  * Output custom menu items as flat list.
  *
  * @return string
  */
 protected function render_custom_menu_item(\custom_menu_item $menunode)
 {
     $content = html_writer::start_tag('li');
     if ($menunode->get_url() !== null) {
         $url = $menunode->get_url();
         $content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
     } else {
         $content .= $menunode->get_text();
     }
     $content .= html_writer::end_tag('li');
     if ($menunode->has_children()) {
         foreach ($menunode->get_children() as $menunode) {
             $content .= $this->render_custom_menu_item($menunode);
         }
     }
     return $content;
 }
开发者ID:pramithkm,项目名称:moodle-theme_snap,代码行数:22,代码来源:core_renderer.php

示例9: custommenu_out

 /**
  * Support function that takes a custom_menu_item and converts it to a string.
  *
  * @param custom_menu_item $item
  * @param int $depth
  * @return string
  */
 protected function custommenu_out(custom_menu_item $item, $depth = 0)
 {
     $str = str_repeat('-', $depth);
     $str .= $item->get_text();
     $str .= '|' . $item->get_url();
     $str .= '|' . $item->get_title();
     if ($item->has_children()) {
         $str .= '|' . count($item->get_children());
         foreach ($item->get_children() as $child) {
             $str .= "\n" . $this->custommenu_out($child, $depth + 1);
         }
     }
     return $str;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:21,代码来源:outputcomponents_test.php

示例10: render_custom_menu_item

 protected function render_custom_menu_item(custom_menu_item $menunode, $level = 0)
 {
     static $submenucount = 0;
     if ($menunode->has_children()) {
         $dropdowntype = $level == 1 ? 'parent dcjq-parent-li' : 'parent dcjq-parent-li';
         $content = html_writer::start_tag('li', array('class' => $dropdowntype));
         // If the child has menus, render it as a sub menu.
         $submenucount++;
         $url = $menunode->get_url() !== null ? $menunode->get_url() : '#cm_submenu_' . $submenucount;
         $content .= html_writer::start_tag('a', array('href' => 'javascript:void(0)', 'class' => 'dcjq-parent'));
         $content .= $menunode->get_title();
         $content .= html_writer::tag('i', '');
         $content .= html_writer::tag('span', '', array('class' => 'dcjq-icon'));
         $content .= html_writer::tag('span', '', array('class' => 'dcjq-icon'));
         $content .= html_writer::end_tag('a');
         $content .= html_writer::start_tag('ul');
         foreach ($menunode->get_children() as $menunode) {
             $content .= $this->render_custom_menu_item($menunode, 0);
         }
         $content .= html_writer::end_tag('ul');
     } else {
         $content = html_writer::start_tag('li');
         // The node doesn't have children so produce a final menuitem.
         $url = $menunode->get_url() !== null ? $menunode->get_url() : '#';
         $content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
     }
     return $content;
 }
开发者ID:bmbrands,项目名称:moodle-theme_leaf,代码行数:28,代码来源:leaf_renderer.php

示例11: render_custom_menu_item

 /**
  * Renders menu items for the custom_menu
  * @param custom_menu_item $menunode
  * @param int $level
  * @return string $content
  */
 protected function render_custom_menu_item(custom_menu_item $menunode, $level = 0)
 {
     static $submenucount = 0;
     if ($menunode->has_children()) {
         if ($level == 1) {
             $class = 'dropdown';
         } else {
             $class = 'dropdown-submenu';
         }
         if ($menunode === $this->language) {
             $class .= ' langmenu';
         }
         $content = html_writer::start_tag('li', array('class' => $class));
         // If the child has menus render it as a sub menu.
         $submenucount++;
         if ($menunode->get_url() !== null) {
             $url = $menunode->get_url();
         } else {
             $url = '#cm_submenu_' . $submenucount;
         }
         $content .= html_writer::start_tag('a', array('href' => $url, 'class' => 'dropdown-toggle', 'data-toggle' => 'dropdown', 'title' => $menunode->get_title()));
         $content .= $menunode->get_text();
         if ($level == 1) {
             $content .= '<i class="fa fa-caret-right"></i>';
         }
         $content .= '</a>';
         $content .= '<ul class="dropdown-menu">';
         foreach ($menunode->get_children() as $menunode) {
             $content .= $this->render_custom_menu_item($menunode, 0);
         }
         $content .= '</ul>';
     } else {
         $content = '<li>';
         // The node doesn't have children so produce a final menuitem.
         $class = '';
         if ($menunode->get_url() !== null) {
             $url = $menunode->get_url();
             $class = $url->get_param('essentialcolours');
         } else {
             $url = '#';
         }
         $content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title(), 'class' => $class));
     }
     return $content;
 }
开发者ID:Keneth1212,项目名称:moodle,代码行数:51,代码来源:core_renderer.php

示例12: render_custom_menu_item

 /**
  * Renders a custom menu node as part of a submenu
  *
  * The custom menu this method produces makes use of the foundation
  * top-bar element and requires specific markup and classes
  *
  * @see core:renderer::render_custom_menu()
  *
  * @staticvar int $submenucount
  * @param custom_menu_item $menunode
  * @return string
  */
 protected function render_custom_menu_item(custom_menu_item $menunode)
 {
     if (right_to_left()) {
         $direction = array('left-side' => 'right', 'right-side' => 'left');
         $dir = 'right';
     } else {
         $direction = array('left-side' => 'left', 'right-side' => 'right');
         $dir = '';
     }
     if ($menunode->has_children()) {
         // If the child has menus render it as a sub menu
         $content = html_writer::start_tag('li', array('class' => 'has-dropdown ' . $dir));
         if ($menunode->get_url() !== null) {
             $url = $menunode->get_url();
         } else {
             $url = '#';
         }
         $content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
         $content .= html_writer::start_tag('ul', array('class' => 'dropdown'));
         foreach ($menunode->get_children() as $menunode) {
             // If the child has menus render it as a sub menu (it's a loop!)
             $content .= $this->render_custom_menu_item($menunode);
         }
         $content .= html_writer::end_tag('ul');
         $content .= html_writer::end_tag('li');
     } else {
         // The node doesn't have children so produce a menuitem
         $content = html_writer::start_tag('li');
         if ($menunode->get_url() !== null) {
             $url = $menunode->get_url();
         } else {
             $url = '#';
         }
         $content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
         $content .= html_writer::end_tag('li');
     }
     // Return the sub menu
     return $content;
 }
开发者ID:HaakonME,项目名称:foundation4-for-moodle2,代码行数:51,代码来源:outputrenderers.php

示例13: render_custom_menu_item

 protected function render_custom_menu_item(custom_menu_item $menunode, $level = 0)
 {
     static $submenucount = 0;
     // Add additional class for custom envelope/messages selector.
     $customclass = '';
     if (preg_match('/fa-envelope/', $menunode->get_text())) {
         $customclass = ' messages';
     }
     if ($menunode->has_children()) {
         if ($level == 1) {
             $dropdowntype = 'dropdown';
         } else {
             $dropdowntype = 'dropdown-submenu';
         }
         $content = html_writer::start_tag('li', array('class' => $dropdowntype . $customclass));
         // If the child has menus render it as a sub menu.
         $submenucount++;
         if ($menunode->get_url() !== null) {
             $url = $menunode->get_url();
         } else {
             $url = '#cm_submenu_' . $submenucount;
         }
         $linkattributes = array('href' => $url, 'class' => 'dropdown-toggle', 'data-toggle' => 'dropdown', 'title' => $menunode->get_title());
         $content .= html_writer::start_tag('a', $linkattributes);
         $content .= $menunode->get_text();
         if ($level == 1) {
             $content .= '<b class="caret"></b>';
         }
         $content .= '</a>';
         $content .= '<ul class="dropdown-menu">';
         foreach ($menunode->get_children() as $menunode) {
             $content .= $this->render_custom_menu_item($menunode, 0);
         }
         $content .= '</ul>';
     } else {
         $content = '<li>';
         // The node doesn't have children so produce a final menuitem.
         if ($menunode->get_url() !== null) {
             $url = $menunode->get_url();
         } else {
             $url = '#';
         }
         $content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
     }
     return $content;
 }
开发者ID:simonsCatalyst,项目名称:simonsCatalyst-keats,代码行数:46,代码来源:renderers.php


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