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


PHP Navigation::items方法代码示例

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


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

示例1: testNavOverwrite

 public function testNavOverwrite()
 {
     $defaults = Navigation::getDefaults();
     Hash::merge($defaults, array('title' => 'Permissions', 'url' => array('admin' => true, 'plugin' => 'acl', 'controller' => 'acl_permissions', 'action' => 'index'), 'weight' => 30));
     $item = array('title' => 'Permissions', 'url' => array('admin' => true, 'plugin' => 'acl_extras', 'controller' => 'acl_extras_permissions', 'action' => 'index'), 'weight' => 30);
     Navigation::add('users.children.permissions', $item);
     $items = Navigation::items();
     $expected = Hash::merge($defaults, array('title' => 'Permissions', 'url' => array('admin' => true, 'plugin' => 'acl_extras', 'controller' => 'acl_extras_permissions', 'action' => 'index'), 'weight' => 30));
     $this->assertEquals($expected, $items['users']['children']['permissions']);
 }
开发者ID:gourmet,项目名称:common,代码行数:10,代码来源:NavigationTest.php

示例2: _render

 /**
  * [_render description]
  * @param [type] $path [description]
  * @param [type] $attrs [description]
  * @return [type]
  */
 protected function _render($nav)
 {
     extract($nav);
     $items = Navigation::order(Navigation::items($path));
     if (empty($items)) {
         return false;
     }
     $defaults = array($this->_tag => array(), $this->_tags[$this->_tag] => array(), 'a' => array());
     $list = array();
     foreach ($items as $key => $options) {
         $title = Inflector::humanize($key);
         extract($options);
         $htmlAttributes = Hash::merge($defaults, $htmlAttributes);
         Reveal::addRule('Page.current', array('self', '__isPageCurrent'), Router::normalize($url));
         if (Reveal::is('Page.current')) {
             $class = 'active';
             if (!empty($htmlAttributes[$this->_tags[$this->_tag]]['class'])) {
                 $class = $htmlAttributes[$this->_tags[$this->_tag]]['class'] . ' ' . $class;
             }
             $htmlAttributes = Hash::merge($htmlAttributes, array($this->_tags[$this->_tag] => compact('class')));
         }
         if (method_exists($this->Html, 'icon') && !empty($icon) && count(explode(' ', $icon)) == 1) {
             $icon = $this->Html->icon($icon);
         }
         $title = $icon . $title;
         // Link-ify item's title when it does not match the current page.
         if (!empty($url)) {
             // Allow for link tag customization using `HtmlHelper::loadConfig()`.
             $configPath = dirname(__FILE__) . DS . 'Navigation' . DS;
             $reset = false;
             if (!empty($htmlAttributes['a']['tag'])) {
                 $this->Html->loadConfig($htmlAttributes['a']['tag'], $configPath);
                 $reset = true;
                 unset($htmlAttributes['a']['tag']);
             }
             if (isset($url['prefix']) && false === $url['prefix'] && !empty($this->_View->request->prefix)) {
                 $url[$this->_View->request->prefix] = false;
             }
             if (is_array($url) && !isset($url['plugin'])) {
                 $url['plugin'] = null;
             }
             $title = $this->Html->link($title, $url, $htmlAttributes['a'], $confirmMessage);
             $reset && $this->Html->loadConfig('reset', $configPath);
         }
         if (!empty($children)) {
             // if (!)$title = $this->Html->tag('span', $title, array('class' => 'title'));
             $title .= $this->_render(array('path' => "{$path}.{$key}.children", 'attrs' => $htmlAttributes[$this->_tag]));
         }
         $list[] = $this->Html->tag($this->_tags[$this->_tag], $title, $htmlAttributes[$this->_tags[$this->_tag]]);
     }
     return $this->Html->tag($this->_tag, implode('', $list), $attrs);
 }
开发者ID:gourmet,项目名称:common,代码行数:58,代码来源:NavigationHelper.php


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