/** * [_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); }
public function testIsUndefinedCallback() { Reveal::addRule('Foo.bar', array('Foo', 'bar')); $this->expectException('CommonRevealException', "Callback 'Foo::bar()' is not defined."); Reveal::is('Foo.bar'); }