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


PHP ElggMenuItem::getName方法代码示例

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


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

示例1: getMenuItem

 public function getMenuItem(ElggMenuItem $parent, $top_only = false)
 {
     if ($parent) {
         $menu_item = array('name' => "{$parent->getName()}:{$this->guid}", 'parent_name' => "{$parent->getName()}", 'text' => "<img class=\"hj-categories-tree-icon\" src=\"{$this->getIconURL('tiny')}\" width=\"12\" />" . $this->title . ' (' . $this->getFiledEntitiesCount() . ')', 'href' => $this->getURL(), 'class' => 'hj-categories-menu-child', 'priority' => $this->priority, 'data' => array('category_guid' => $this->guid));
     } else {
         $menu_item = array('name' => "{$this->guid}", 'text' => "<img class=\"hj-categories-tree-icon\" src=\"{$this->getIconURL('tiny')}\" width=\"12\" />" . $this->title . ' (' . $this->getFiledEntitiesCount() . ')', 'href' => $this->getURL(), 'class' => 'hj-categories-menu-root', 'priority' => $this->priority, 'data' => array('category_guid' => $this->guid));
     }
     $menu_item = ElggMenuItem::factory($menu_item);
     $return[] = $menu_item;
     // Empty menu item to create html markup
     if ($this->canEdit() && elgg_get_context() == 'category') {
         $add_new = array('name' => "{$menu_item->getName()}:addnew", 'parent_name' => "{$menu_item->getName()}", 'text' => '', 'item_class' => 'hidden', 'href' => false, 'priority' => 1);
         $return[] = ElggMenuItem::factory($add_new);
     }
     if (!$top_only) {
         $children = $this->getChildren();
         if (is_array($children)) {
             foreach ($children as $child) {
                 $submenu = $child->getMenuItem($menu_item);
                 if (is_array($submenu)) {
                     foreach ($submenu as $submenu_item) {
                         $return[] = $submenu_item;
                     }
                 }
             }
         }
     }
     return $return;
 }
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:29,代码来源:hjCategory.php

示例2: _elgg_site_menu_setup

/**
 * Set up the site menu
 *
 * Handles default, featured, and custom menu items
 *
 * @access private
 */
function _elgg_site_menu_setup($hook, $type, $return, $params)
{
    $featured_menu_names = elgg_get_config('site_featured_menu_names');
    $custom_menu_items = elgg_get_config('site_custom_menu_items');
    if ($featured_menu_names || $custom_menu_items) {
        // we have featured or custom menu items
        $registered = $return['default'];
        /* @var \ElggMenuItem[] $registered */
        // set up featured menu items
        $featured = array();
        foreach ($featured_menu_names as $name) {
            foreach ($registered as $index => $item) {
                if ($item->getName() == $name) {
                    $featured[] = $item;
                    unset($registered[$index]);
                }
            }
        }
        // add custom menu items
        $n = 1;
        foreach ($custom_menu_items as $title => $url) {
            $item = new \ElggMenuItem("custom{$n}", $title, $url);
            $featured[] = $item;
            $n++;
        }
        $return['default'] = $featured;
        if (count($registered) > 0) {
            $return['more'] = $registered;
        }
    } else {
        // no featured menu items set
        $max_display_items = 5;
        // the first n are shown, rest added to more list
        // if only one item on more menu, stick it with the rest
        $num_menu_items = count($return['default']);
        if ($num_menu_items > $max_display_items + 1) {
            $return['more'] = array_splice($return['default'], $max_display_items);
        }
    }
    // check if we have anything selected
    $selected = false;
    foreach ($return as $section) {
        /* @var \ElggMenuItem[] $section */
        foreach ($section as $item) {
            if ($item->getSelected()) {
                $selected = true;
                break 2;
            }
        }
    }
    if (!$selected) {
        // nothing selected, match name to context or match url
        $current_url = current_page_url();
        foreach ($return as $section_name => $section) {
            foreach ($section as $key => $item) {
                // only highlight internal links
                if (strpos($item->getHref(), elgg_get_site_url()) === 0) {
                    if ($item->getName() == elgg_get_context()) {
                        $return[$section_name][$key]->setSelected(true);
                        break 2;
                    }
                    if ($item->getHref() == $current_url) {
                        $return[$section_name][$key]->setSelected(true);
                        break 2;
                    }
                }
            }
        }
    }
    return $return;
}
开发者ID:epsylon,项目名称:Hydra-dev,代码行数:78,代码来源:navigation.php

示例3: compareByName

 /**
  * Compare two menu items by their identifiers
  *
  * @param \ElggMenuItem $a Menu item
  * @param \ElggMenuItem $b Menu item
  * @return bool
  */
 public static function compareByName($a, $b)
 {
     $an = $a->getName();
     $bn = $b->getName();
     $result = strnatcmp($an, $bn);
     if ($result === 0) {
         return $a->getData('original_order') - $b->getData('original_order');
     }
     return $result;
 }
开发者ID:thehereward,项目名称:Elgg,代码行数:17,代码来源:ElggMenuBuilder.php


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