Perforce Chronicle 2012.2/486814
API Documentation
|
Enhanced version of Zend's menu helper. More...
Public Member Functions | |
htmlify ($page) | |
Replaces parent htmlify so that we can produce customized markup for page types that require it. | |
menu ($container=null, array $options=array()) | |
This is the menu helper entry point. | |
render (Zend_Navigation_Container $container=null) | |
Renders menu - extended to pass instance options to renderMenu method. | |
renderMenu (Zend_Navigation_Container $container=null, array $options=array()) | |
Extends the parent helper renderer to capture the options so that they can be re-used by the htmlify method. | |
Protected Attributes | |
$_options = array() |
Enhanced version of Zend's menu helper.
Menu_View_Helper_Menu::htmlify | ( | $ | page | ) |
Replaces parent htmlify so that we can produce customized markup for page types that require it.
Overrides Zend_View_Helper_Navigation_Menu::htmlify().
Zend_Navigation_Page | $page | page to generate HTML for |
Reimplemented in Ui_View_Helper_Toolbar.
{ // get label and title for translating $label = $page->getLabel(); $title = $page->getTitle(); // translate label and title? if ($this->getUseTranslator() && $t = $this->getTranslator()) { if (is_string($label) && !empty($label)) { $label = $t->translate($label); } if (is_string($title) && !empty($title)) { $title = $t->translate($title); } } // always provide a type class for styling purposes. $typeClass = 'type-' . strtolower(end(explode('_', get_class($page)))); // get attribs for element $attribs = array( 'id' => $page->getId(), 'title' => $title, 'class' => trim($page->getClass() . " " . $typeClass), 'onclick' => $page->get("onClick"), ); // does page have a href? $beforeLabel = $afterLabel = ''; if ($href = $page->getHref()) { $element = 'a'; $attribs['href'] = $href; $attribs['target'] = $page->getTarget(); $beforeLabel = array_key_exists('beforeLabel', $this->_options) ? $this->_options['beforeLabel'] : ''; $afterLabel = array_key_exists('afterLabel', $this->_options) ? $this->_options['afterLabel'] : ''; } else { $element = 'span'; } return '<' . $element . $this->_htmlAttribs($attribs) . '>' . $beforeLabel . $this->view->escape($label) . $afterLabel . '</' . $element . '>'; }
Menu_View_Helper_Menu::menu | ( | $ | container = null , |
array $ | options = array() |
||
) |
This is the menu helper entry point.
It has been extended to add support for passing a menu object or id (string) as well as options.
If the menu exists, it will be fetched; otherwise, an empty container will be used.
mixed | $container | optional - menu or container to operate on |
array | $options | options to apply when rendering this menu |
{ if ($container && !$container instanceof Zend_Navigation_Container) { if (!$container instanceof P4Cms_Menu && P4Cms_Menu::exists($container)) { $container = P4Cms_Menu::fetch($container); } if ($container instanceof P4Cms_Menu) { // tag the page cache so it can be appropriately cleared later if (P4Cms_Cache::canCache('page')) { P4Cms_Cache::getCache('page') ->addTag('p4cms_menu') ->addTag('p4cms_menu_' . bin2hex($container->getId())); } $container = $container->getExpandedContainer(); } else { $container = new Zend_Navigation; } } if (null !== $container) { $this->setContainer($container); } // keep options around for render time. $this->_options = $options; return $this; }
Menu_View_Helper_Menu::render | ( | Zend_Navigation_Container $ | container = null | ) |
Renders menu - extended to pass instance options to renderMenu method.
If a partial view is registered in the helper, the menu will be rendered using the given partial script. If no partial is registered, the menu will be rendered as an 'ul' element by the helper's internal method.
Zend_Navigation_Container | $container | [optional] container to render. Default is to render the container registered in the helper. |
{ if ($partial = $this->getPartial()) { return $this->renderPartial($container, $partial); } else { return $this->renderMenu($container, $this->_options); } }
Menu_View_Helper_Menu::renderMenu | ( | Zend_Navigation_Container $ | container = null , |
array $ | options = array() |
||
) |
Extends the parent helper renderer to capture the options so that they can be re-used by the htmlify method.
Zend_Navigation_Container | $container | [optional] container to create menu from. Default is to use the container retrieved from getContainer(). |
array | $options | [optional] options for controlling rendering |
Reimplemented in Ui_View_Helper_Toolbar.
{ $this->_options = $options = $this->_normalizeOptions($options); return parent::renderMenu($container, $options); }
Menu_View_Helper_Menu::$_options = array() [protected] |