Advertisement
Guest User

TNG

a guest
Aug 6th, 2015
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.95 KB | None | 0 0
  1. --- C:/Users/User/AppData/Local/Temp/Menu.php-rev10.svn000.tmp.php Thu Sep 5 10:55:15 2013
  2. +++ C:/Users/User/AppData/Local/Temp/Menu.php-rev2097.svn000.tmp.php Mon Jul 13 19:19:20 2015
  3. @@ -44,7 +44,24 @@ class Zend_View_Helper_Navigation_Menu
  4. */
  5. protected $_ulClass = 'navigation';
  6.  
  7. + /**
  8. + *
  9. + * want a way to set aria role on menu li elements because its 2015 yo.
  10. + *
  11. + * @var string
  12. + */
  13. + protected $_liRole = '';
  14. +
  15. /**
  16. + * Workaround so I can render the damn thing twice on the same page and not collide IDs on the <a>'s
  17. + * Issue arose when adopting bootstrap and rendering both full page nav and collapsed nav bar
  18. + *
  19. + * @var string
  20. + */
  21. + protected $_idAlias = '';
  22. +
  23. + /**
  24. * Whether only active branch should be rendered
  25. *
  26. * @var bool
  27. @@ -110,6 +127,30 @@ class Zend_View_Helper_Navigation_Menu
  28. return $this->_ulClass;
  29. }
  30.  
  31. +
  32. +
  33. + public function setLiRole($liRole)
  34. + {
  35. + if (is_string($liRole)) {
  36. + $this->_liRole = $liRole;
  37. + }
  38. + return $this;
  39. + }
  40. + public function getLiRole()
  41. + {
  42. + return $this->_liRole;
  43. + }
  44. +
  45. + public function setIdAlias($alias)
  46. + {
  47. + $this->_idAlias = $alias;
  48. + return $this;
  49. + }
  50. + public function getIdAlias()
  51. + {
  52. + return $this->_idAlias;
  53. + }
  54. +
  55. /**
  56. * Sets a flag indicating whether only active branch should be rendered
  57. *
  58. @@ -224,7 +265,7 @@ class Zend_View_Helper_Navigation_Menu
  59.  
  60. // get attribs for element
  61. $attribs = array(
  62. - 'id' => $page->getId(),
  63. + 'id' => $this->getIdAlias() . $page->getId(),
  64. 'title' => $title,
  65. 'class' => $page->getClass()
  66. );
  67. @@ -238,9 +279,9 @@ class Zend_View_Helper_Navigation_Menu
  68. $element = 'span';
  69. }
  70.  
  71. - return '<' . $element . $this->_htmlAttribs($attribs) . '>'
  72. - . $this->view->escape($label)
  73. - . '</' . $element . '>';
  74. + return '<' . $element . $this->_htmlAttribs($attribs) . '><span class="span-nav-icon"></span><span>'
  75. + . str_replace(chr(32), '&nbsp;', $this->view->escape($label))
  76. + . '</span></' . $element . '>';
  77. }
  78.  
  79. /**
  80. @@ -263,6 +304,18 @@ class Zend_View_Helper_Navigation_Menu
  81. $options['ulClass'] = $this->getUlClass();
  82. }
  83.  
  84. + if (isset($options['liRole']) && $options['liRole'] !== null) {
  85. + $options['liRole'] = (string) $options['liRole'];
  86. + } else {
  87. + $options['liRole'] = $this->getLiRole();
  88. + }
  89. +
  90. + if (isset($options['idAlias']) && $options['idAlias'] !== null) {
  91. + $options['idAlias'] = (string) $options['idAlias'];
  92. + } else {
  93. + $options['idAlias'] = '';
  94. + }
  95. +
  96. if (array_key_exists('minDepth', $options)) {
  97. if (null !== $options['minDepth']) {
  98. $options['minDepth'] = (int) $options['minDepth'];
  99. @@ -334,12 +387,14 @@ class Zend_View_Helper_Navigation_Menu
  100. $ulClass = $ulClass ? ' class="' . $ulClass . '"' : '';
  101. $html = $indent . '<ul' . $ulClass . '>' . self::EOL;
  102.  
  103. + $liRole = (! empty($this->getLiRole())) ? "role=\"{$this->getLiRole()}\"" : "";
  104. +
  105. foreach ($active['page'] as $subPage) {
  106. if (!$this->accept($subPage)) {
  107. continue;
  108. }
  109. $liClass = $subPage->isActive(true) ? ' class="active"' : '';
  110. - $html .= $indent . ' <li' . $liClass . '>' . self::EOL;
  111. + $html .= $indent . ' <li' . $liClass . ' ' . $liRole . '>' . self::EOL;
  112. $html .= $indent . ' ' . $this->htmlify($subPage) . self::EOL;
  113. $html .= $indent . ' </li>' . self::EOL;
  114. }
  115. @@ -415,6 +470,9 @@ class Zend_View_Helper_Navigation_Menu
  116. }
  117. }
  118.  
  119. + $liRole = (! empty($this->getLiRole())) ? "role=\"{$this->getLiRole()}\"" : "";
  120. +
  121. +
  122. // make sure indentation is correct
  123. $depth -= $minDepth;
  124. $myIndent = $indent . str_repeat(' ', $depth);
  125. @@ -443,7 +501,7 @@ class Zend_View_Helper_Navigation_Menu
  126.  
  127. // render li tag and page
  128. $liClass = $isActive ? ' class="active"' : '';
  129. - $html .= $myIndent . ' <li' . $liClass . '>' . self::EOL
  130. + $html .= $myIndent . ' <li' . $liClass . ' ' . $liRole . '>' . self::EOL
  131. . $myIndent . ' ' . $this->htmlify($page) . self::EOL;
  132.  
  133. // store as previous depth for next iteration
  134. @@ -490,6 +548,9 @@ class Zend_View_Helper_Navigation_Menu
  135.  
  136. $options = $this->_normalizeOptions($options);
  137.  
  138. + $this->setLiRole($options['liRole']);
  139. + $this->setIdAlias($options['idAlias']);
  140. +
  141. if ($options['onlyActiveBranch'] && !$options['renderParents']) {
  142. $html = $this->_renderDeepestMenu($container,
  143. $options['ulClass'],
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement