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


PHP ElggMenuItem::getChildren方法代码示例

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


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

示例1: orderMenuItem

 /**
  * Reorders menu item and adds an add button
  *
  * @param \ElggMenuItem $item  menu item
  * @param int           $depth depth of the menu item
  *
  * @return \ElggMenuItem
  */
 private static function orderMenuItem(\ElggMenuItem $item, $depth)
 {
     $depth = (int) $depth;
     $children = $item->getChildren();
     if (empty($children)) {
         return $item;
     }
     // sort children
     $ordered_children = [];
     foreach ($children as $child) {
         $child = self::orderMenuItem($child, $depth + 1);
         $child_priority = $child->getPriority();
         while (array_key_exists($child_priority, $ordered_children)) {
             $child_priority++;
         }
         $ordered_children[$child_priority] = $child;
     }
     ksort($ordered_children);
     $item->setChildren($ordered_children);
     return $item;
 }
开发者ID:coldtrick,项目名称:menu_builder,代码行数:29,代码来源:MenuHooks.php

示例2: theme_haarlem_add_toggle_link

/**
 * Adds a toggle link for use in responsive
 *
 * @param \ElggMenuItem $item
 */
function theme_haarlem_add_toggle_link(\ElggMenuItem &$item)
{
    $children = $item->getChildren();
    if (empty($children)) {
        return;
    }
    $item->setText($item->getText() . elgg_view_icon('angle-right', 'elgg-menu-site-toggle'));
    foreach ($children as $child) {
        theme_haarlem_add_toggle_link($child);
    }
}
开发者ID:coldtrick,项目名称:theme_haarlem_intranet,代码行数:16,代码来源:functions.php

示例3: menu_builder_order_menu_item

/**
 * Reorders menu item and adds an add button
 *
 * @param ElggMenuItem $item  menu item
 * @param int          $depth depth of the menu item
 *
 * @return ElggMenuItem
 */
function menu_builder_order_menu_item(ElggMenuItem $item, $depth)
{
    $depth = (int) $depth;
    if ($children = $item->getChildren()) {
        // sort children
        $ordered_children = array();
        foreach ($children as $child) {
            $child = menu_builder_order_menu_item($child, $depth + 1);
            $child_priority = $child->getPriority();
            while (array_key_exists($child_priority, $ordered_children)) {
                $child_priority++;
            }
            $ordered_children[$child_priority] = $child;
            if (isset($_SESSION["menu_builder_edit_mode"]) && $depth < 5) {
                // add button
                $child_add = ElggMenuItem::factory(array("name" => 'menu_builder_add', "text" => elgg_view_icon("round-plus"), "href" => '/menu_builder/edit?parent_guid=' . $child->getName(), "class" => "menu_builder_add_link", "title" => elgg_echo("menu_builder:edit_mode:add")));
                $child->addChild($child_add);
            }
        }
        ksort($ordered_children);
        $item->setChildren($ordered_children);
    }
    return $item;
}
开发者ID:n8b,项目名称:VMN,代码行数:32,代码来源:functions.php


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