本文整理汇总了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']);
}
示例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);
}