Index: library/Zend/View/Helper/Navigation/Links.php =================================================================== --- library/Zend/View/Helper/Navigation/Links.php (revision 24555) +++ library/Zend/View/Helper/Navigation/Links.php (working copy) @@ -769,7 +769,7 @@ foreach ($types as $relation => $pages) { foreach ($pages as $page) { if ($r = $this->renderLink($page, $attrib, $relation)) { - $output .= $indent . $r . self::EOL; + $output .= $indent . $r . $this->getEOL(); } } } Index: library/Zend/View/Helper/Navigation/Sitemap.php =================================================================== --- library/Zend/View/Helper/Navigation/Sitemap.php (revision 24555) +++ library/Zend/View/Helper/Navigation/Sitemap.php (working copy) @@ -52,7 +52,7 @@ * @var string */ const SITEMAP_XSD = 'http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd'; - + /** * Whether XML output should be formatted * @@ -106,34 +106,9 @@ return $this; } - // Accessors: + // Accessors: /** - * Sets whether XML output should be formatted - * - * @param bool $formatOutput [optional] whether output - * should be formatted. Default - * is true. - * @return Zend_View_Helper_Navigation_Sitemap fluent interface, returns - * self - */ - public function setFormatOutput($formatOutput = true) - { - $this->_formatOutput = (bool) $formatOutput; - return $this; - } - - /** - * Returns whether XML output should be formatted - * - * @return bool whether XML output should be formatted - */ - public function getFormatOutput() - { - return $this->_formatOutput; - } - - /** * Sets whether the XML declaration should be used in output * * @param bool $useXmlDecl whether XML delcaration @@ -478,6 +453,6 @@ $dom->saveXML() : $dom->saveXML($dom->documentElement); - return rtrim($xml, PHP_EOL); + return rtrim($xml, self::EOL); } } Index: library/Zend/View/Helper/Navigation/HelperAbstract.php =================================================================== --- library/Zend/View/Helper/Navigation/HelperAbstract.php (revision 24555) +++ library/Zend/View/Helper/Navigation/HelperAbstract.php (working copy) @@ -70,6 +70,13 @@ * @var string */ protected $_indent = ''; + + /** + * Whether HTML/XML output should be formatted + * + * @var bool + */ + protected $_formatOutput = true; /** * Translator @@ -264,16 +271,64 @@ } /** - * Returns indentation + * Returns indentation (format output is respected) + * + * @see getFormatOutput() * - * @return string + * @return string indentation string or an empty string */ public function getIndent() { + if (false === $this->getFormatOutput()) { + return ''; + } + return $this->_indent; } + + /** + * Returns the EOL character (format output is respected) + * + * @see self::EOL + * @see getFormatOutput() + * + * @return string standard EOL charater or an empty string + */ + public function getEOL() + { + if (false === $this->getFormatOutput()) { + return ''; + } + + return self::EOL; + } /** + * Sets whether HTML/XML output should be formatted + * + * @param bool $formatOutput [optional] whether output + * should be formatted. Default + * is true. + * @return Zend_View_Helper_Navigation_Sitemap fluent interface, returns + * self + */ + public function setFormatOutput($formatOutput = true) + { + $this->_formatOutput = (bool) $formatOutput; + return $this; + } + + /** + * Returns whether HTML/XML output should be formatted + * + * @return bool whether HTML/XML output should be formatted + */ + public function getFormatOutput() + { + return $this->_formatOutput; + } + + /** * Sets translator to use in helper * * Implements {@link Zend_View_Helper_Navigation_Helper::setTranslator()}. Index: library/Zend/View/Helper/Navigation/Menu.php =================================================================== --- library/Zend/View/Helper/Navigation/Menu.php (revision 24555) +++ library/Zend/View/Helper/Navigation/Menu.php (working copy) @@ -64,6 +64,13 @@ * @var string|array */ protected $_partial = null; + + /** + * Inner indentation string + * + * @var string + */ + protected $_innerIndent = ' '; /** * View helper entry point: @@ -194,7 +201,38 @@ { return $this->_partial; } + + /** + * Set the inner indentation string for using in {@link render()}, optionally + * a number of spaces to indent with + * + * @param string|int $indent indentation string or + * number of spaces + * @return Zend_View_Helper_Navigation_HelperAbstract fluent interface, + * returns self + */ + public function setInnerIndent($indent) + { + $this->_innerIndent = $this->_getWhitespace($indent); + return $this; + } + /** + * Returns inner indentation (format output is respected) + * + * @see getFormatOutput() + * + * @return string indentation string or an empty string + */ + public function getInnerIndent() + { + if (false === $this->getFormatOutput()) { + return ''; + } + + return $this->_innerIndent; + } + // Public methods: /** @@ -252,18 +290,28 @@ */ protected function _normalizeOptions(array $options = array()) { + // Indent if (isset($options['indent'])) { $options['indent'] = $this->_getWhitespace($options['indent']); } else { $options['indent'] = $this->getIndent(); } + + // Inner ident + if (isset($options['innerIndent'])) { + $options['innerIndent'] = $this->_getWhitespace($options['innerIndent']); + } else { + $options['innerIndent'] = $this->getInnerIndent(); + } + // UL class if (isset($options['ulClass']) && $options['ulClass'] !== null) { $options['ulClass'] = (string) $options['ulClass']; } else { $options['ulClass'] = $this->getUlClass(); } + // Min depth if (array_key_exists('minDepth', $options)) { if (null !== $options['minDepth']) { $options['minDepth'] = (int) $options['minDepth']; @@ -276,6 +324,7 @@ $options['minDepth'] = 0; } + // Max depth if (array_key_exists('maxDepth', $options)) { if (null !== $options['maxDepth']) { $options['maxDepth'] = (int) $options['maxDepth']; @@ -284,10 +333,12 @@ $options['maxDepth'] = $this->getMaxDepth(); } + // Only active branch if (!isset($options['onlyActiveBranch'])) { $options['onlyActiveBranch'] = $this->getOnlyActiveBranch(); } + // Render parents if (!isset($options['renderParents'])) { $options['renderParents'] = $this->getRenderParents(); } @@ -301,17 +352,19 @@ * Renders the deepest active menu within [$minDepth, $maxDeth], (called * from {@link renderMenu()}) * - * @param Zend_Navigation_Container $container container to render - * @param array $active active page and depth - * @param string $ulClass CSS class for first UL - * @param string $indent initial indentation - * @param int|null $minDepth minimum depth - * @param int|null $maxDepth maximum depth - * @return string rendered menu + * @param Zend_Navigation_Container $container container to render + * @param array $active active page and depth + * @param string $ulClass CSS class for first UL + * @param string $indent initial indentation + * @param string $innerIndent inner indentation + * @param int|null $minDepth minimum depth + * @param int|null $maxDepth maximum depth + * @return string rendered menu */ protected function _renderDeepestMenu(Zend_Navigation_Container $container, $ulClass, $indent, + $innerIndent, $minDepth, $maxDepth) { @@ -333,16 +386,17 @@ } $ulClass = $ulClass ? ' class="' . $ulClass . '"' : ''; - $html = $indent . '