Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- C:/Users/User/AppData/Local/Temp/Menu.php-rev10.svn000.tmp.php Thu Sep 5 10:55:15 2013
- +++ C:/Users/User/AppData/Local/Temp/Menu.php-rev2097.svn000.tmp.php Mon Jul 13 19:19:20 2015
- @@ -44,7 +44,24 @@ class Zend_View_Helper_Navigation_Menu
- */
- protected $_ulClass = 'navigation';
- + /**
- + *
- + * want a way to set aria role on menu li elements because its 2015 yo.
- + *
- + * @var string
- + */
- + protected $_liRole = '';
- +
- /**
- + * Workaround so I can render the damn thing twice on the same page and not collide IDs on the <a>'s
- + * Issue arose when adopting bootstrap and rendering both full page nav and collapsed nav bar
- + *
- + * @var string
- + */
- + protected $_idAlias = '';
- +
- + /**
- * Whether only active branch should be rendered
- *
- * @var bool
- @@ -110,6 +127,30 @@ class Zend_View_Helper_Navigation_Menu
- return $this->_ulClass;
- }
- +
- +
- + public function setLiRole($liRole)
- + {
- + if (is_string($liRole)) {
- + $this->_liRole = $liRole;
- + }
- + return $this;
- + }
- + public function getLiRole()
- + {
- + return $this->_liRole;
- + }
- +
- + public function setIdAlias($alias)
- + {
- + $this->_idAlias = $alias;
- + return $this;
- + }
- + public function getIdAlias()
- + {
- + return $this->_idAlias;
- + }
- +
- /**
- * Sets a flag indicating whether only active branch should be rendered
- *
- @@ -224,7 +265,7 @@ class Zend_View_Helper_Navigation_Menu
- // get attribs for element
- $attribs = array(
- - 'id' => $page->getId(),
- + 'id' => $this->getIdAlias() . $page->getId(),
- 'title' => $title,
- 'class' => $page->getClass()
- );
- @@ -238,9 +279,9 @@ class Zend_View_Helper_Navigation_Menu
- $element = 'span';
- }
- - return '<' . $element . $this->_htmlAttribs($attribs) . '>'
- - . $this->view->escape($label)
- - . '</' . $element . '>';
- + return '<' . $element . $this->_htmlAttribs($attribs) . '><span class="span-nav-icon"></span><span>'
- + . str_replace(chr(32), ' ', $this->view->escape($label))
- + . '</span></' . $element . '>';
- }
- /**
- @@ -263,6 +304,18 @@ class Zend_View_Helper_Navigation_Menu
- $options['ulClass'] = $this->getUlClass();
- }
- + if (isset($options['liRole']) && $options['liRole'] !== null) {
- + $options['liRole'] = (string) $options['liRole'];
- + } else {
- + $options['liRole'] = $this->getLiRole();
- + }
- +
- + if (isset($options['idAlias']) && $options['idAlias'] !== null) {
- + $options['idAlias'] = (string) $options['idAlias'];
- + } else {
- + $options['idAlias'] = '';
- + }
- +
- if (array_key_exists('minDepth', $options)) {
- if (null !== $options['minDepth']) {
- $options['minDepth'] = (int) $options['minDepth'];
- @@ -334,12 +387,14 @@ class Zend_View_Helper_Navigation_Menu
- $ulClass = $ulClass ? ' class="' . $ulClass . '"' : '';
- $html = $indent . '<ul' . $ulClass . '>' . self::EOL;
- + $liRole = (! empty($this->getLiRole())) ? "role=\"{$this->getLiRole()}\"" : "";
- +
- foreach ($active['page'] as $subPage) {
- if (!$this->accept($subPage)) {
- continue;
- }
- $liClass = $subPage->isActive(true) ? ' class="active"' : '';
- - $html .= $indent . ' <li' . $liClass . '>' . self::EOL;
- + $html .= $indent . ' <li' . $liClass . ' ' . $liRole . '>' . self::EOL;
- $html .= $indent . ' ' . $this->htmlify($subPage) . self::EOL;
- $html .= $indent . ' </li>' . self::EOL;
- }
- @@ -415,6 +470,9 @@ class Zend_View_Helper_Navigation_Menu
- }
- }
- + $liRole = (! empty($this->getLiRole())) ? "role=\"{$this->getLiRole()}\"" : "";
- +
- +
- // make sure indentation is correct
- $depth -= $minDepth;
- $myIndent = $indent . str_repeat(' ', $depth);
- @@ -443,7 +501,7 @@ class Zend_View_Helper_Navigation_Menu
- // render li tag and page
- $liClass = $isActive ? ' class="active"' : '';
- - $html .= $myIndent . ' <li' . $liClass . '>' . self::EOL
- + $html .= $myIndent . ' <li' . $liClass . ' ' . $liRole . '>' . self::EOL
- . $myIndent . ' ' . $this->htmlify($page) . self::EOL;
- // store as previous depth for next iteration
- @@ -490,6 +548,9 @@ class Zend_View_Helper_Navigation_Menu
- $options = $this->_normalizeOptions($options);
- + $this->setLiRole($options['liRole']);
- + $this->setIdAlias($options['idAlias']);
- +
- if ($options['onlyActiveBranch'] && !$options['renderParents']) {
- $html = $this->_renderDeepestMenu($container,
- $options['ulClass'],
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement