--- a/web/lib/Zend/View/Helper/Navigation/HelperAbstract.php Thu Mar 21 17:31:31 2013 +0100
+++ b/web/lib/Zend/View/Helper/Navigation/HelperAbstract.php Thu Mar 21 19:50:53 2013 +0100
@@ -15,9 +15,9 @@
* @category Zend
* @package Zend_View
* @subpackage Helper
- * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: HelperAbstract.php 20096 2010-01-06 02:05:09Z bkarwin $
+ * @version $Id: HelperAbstract.php 25239 2013-01-22 09:45:01Z frosch $
*/
/**
@@ -36,7 +36,7 @@
* @category Zend
* @package Zend_View
* @subpackage Helper
- * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_View_Helper_Navigation_HelperAbstract
@@ -72,6 +72,27 @@
protected $_indent = '';
/**
+ * Whether HTML/XML output should be formatted
+ *
+ * @var bool
+ */
+ protected $_formatOutput = true;
+
+ /**
+ * Prefix for IDs when they are normalized
+ *
+ * @var string|null
+ */
+ protected $_prefixForId = null;
+
+ /**
+ * Skip current prefix for IDs when they are normalized (flag)
+ *
+ * @var bool
+ */
+ protected $_skipPrefixForId = false;
+
+ /**
* Translator
*
* @var Zend_Translate_Adapter
@@ -264,16 +285,108 @@
}
/**
- * Returns indentation
+ * Returns indentation (format output is respected)
*
- * @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 prefix for IDs when they are normalized
+ *
+ * @param string $prefix Prefix for IDs
+ * @return Zend_View_Helper_Navigation_HelperAbstract fluent interface, returns self
+ */
+ public function setPrefixForId($prefix)
+ {
+ if (is_string($prefix)) {
+ $this->_prefixForId = trim($prefix);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns prefix for IDs when they are normalized
+ *
+ * @return string Prefix for
+ */
+ public function getPrefixForId()
+ {
+ if (null === $this->_prefixForId) {
+ $prefix = get_class($this);
+ $this->_prefixForId = strtolower(
+ trim(substr($prefix, strrpos($prefix, '_')), '_')
+ ) . '-';
+ }
+
+ return $this->_prefixForId;
+ }
+
+ /**
+ * Skip the current prefix for IDs when they are normalized
+ *
+ * @param bool $flag
+ * @return Zend_View_Helper_Navigation_HelperAbstract fluent interface, returns self
+ */
+ public function skipPrefixForId($flag = true)
+ {
+ $this->_skipPrefixForId = (bool) $flag;
+ return $this;
+ }
+
+ /**
* Sets translator to use in helper
*
* Implements {@link Zend_View_Helper_Navigation_Helper::setTranslator()}.
@@ -377,7 +490,7 @@
} else {
require_once 'Zend/View/Exception.php';
$e = new Zend_View_Exception(sprintf(
- '$role must be a string, null, or an instance of '
+ '$role must be a string, null, or an instance of '
. 'Zend_Acl_Role_Interface; %s given',
gettype($role)
));
@@ -669,12 +782,15 @@
}
// get attribs for anchor element
- $attribs = array(
- 'id' => $page->getId(),
- 'title' => $title,
- 'class' => $page->getClass(),
- 'href' => $page->getHref(),
- 'target' => $page->getTarget()
+ $attribs = array_merge(
+ array(
+ 'id' => $page->getId(),
+ 'title' => $title,
+ 'class' => $page->getClass(),
+ 'href' => $page->getHref(),
+ 'target' => $page->getTarget()
+ ),
+ $page->getCustomHtmlAttribs()
);
return '<a' . $this->_htmlAttribs($attribs) . '>'
@@ -800,17 +916,22 @@
/**
* Normalize an ID
*
- * Overrides {@link Zend_View_Helper_HtmlElement::_normalizeId()}.
+ * Extends {@link Zend_View_Helper_HtmlElement::_normalizeId()}.
*
- * @param string $value
- * @return string
+ * @param string $value ID
+ * @return string Normalized ID
*/
protected function _normalizeId($value)
- {
- $prefix = get_class($this);
- $prefix = strtolower(trim(substr($prefix, strrpos($prefix, '_')), '_'));
+ {
+ if (false === $this->_skipPrefixForId) {
+ $prefix = $this->getPrefixForId();
- return $prefix . '-' . $value;
+ if (strlen($prefix)) {
+ return $prefix . $value;
+ }
+ }
+
+ return parent::_normalizeId($value);
}
// Static methods: