From 8ca6cc32b2c789a3149861159ad258f2cb9491e3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:39:39 +0200 Subject: Adding upstream version 2.11.4. Signed-off-by: Daniel Baumann --- library/vendor/Zend/View/Helper/HeadTitle.php | 218 ++++++++++++++++++++++++++ 1 file changed, 218 insertions(+) create mode 100644 library/vendor/Zend/View/Helper/HeadTitle.php (limited to 'library/vendor/Zend/View/Helper/HeadTitle.php') diff --git a/library/vendor/Zend/View/Helper/HeadTitle.php b/library/vendor/Zend/View/Helper/HeadTitle.php new file mode 100644 index 0000000..77aef26 --- /dev/null +++ b/library/vendor/Zend/View/Helper/HeadTitle.php @@ -0,0 +1,218 @@ +getDefaultAttachOrder()) + ? Zend_View_Helper_Placeholder_Container_Abstract::APPEND + : $this->getDefaultAttachOrder(); + } + $title = (string) $title; + if ($title !== '') { + if ($setType == Zend_View_Helper_Placeholder_Container_Abstract::SET) { + $this->set($title); + } elseif ($setType == Zend_View_Helper_Placeholder_Container_Abstract::PREPEND) { + $this->prepend($title); + } else { + $this->append($title); + } + } + + return $this; + } + + /** + * Set a default order to add titles + * + * @param string $setType + */ + public function setDefaultAttachOrder($setType) + { + if (!in_array($setType, array( + Zend_View_Helper_Placeholder_Container_Abstract::APPEND, + Zend_View_Helper_Placeholder_Container_Abstract::SET, + Zend_View_Helper_Placeholder_Container_Abstract::PREPEND + ))) { + throw new Zend_View_Exception("You must use a valid attach order: 'PREPEND', 'APPEND' or 'SET'"); + } + + $this->_defaultAttachOrder = $setType; + return $this; + } + + /** + * Get the default attach order, if any. + * + * @return mixed + */ + public function getDefaultAttachOrder() + { + return $this->_defaultAttachOrder; + } + + /** + * Sets a translation Adapter for translation + * + * @param Zend_Translate|Zend_Translate_Adapter $translate + * @return Zend_View_Helper_HeadTitle + */ + public function setTranslator($translate) + { + if ($translate instanceof Zend_Translate_Adapter) { + $this->_translator = $translate; + } elseif ($translate instanceof Zend_Translate) { + $this->_translator = $translate->getAdapter(); + } else { + $e = new Zend_View_Exception("You must set an instance of Zend_Translate or Zend_Translate_Adapter"); + $e->setView($this->view); + throw $e; + } + return $this; + } + + /** + * Retrieve translation object + * + * If none is currently registered, attempts to pull it from the registry + * using the key 'Zend_Translate'. + * + * @return Zend_Translate_Adapter|null + */ + public function getTranslator() + { + if (null === $this->_translator) { + if (Zend_Registry::isRegistered('Zend_Translate')) { + $this->setTranslator(Zend_Registry::get('Zend_Translate')); + } + } + return $this->_translator; + } + + /** + * Enables translation + * + * @return Zend_View_Helper_HeadTitle + */ + public function enableTranslation() + { + $this->_translate = true; + return $this; + } + + /** + * Disables translation + * + * @return Zend_View_Helper_HeadTitle + */ + public function disableTranslation() + { + $this->_translate = false; + return $this; + } + + /** + * Turn helper into string + * + * @param string|null $indent + * @param string|null $locale + * @return string + */ + public function toString($indent = null, $locale = null) + { + $indent = (null !== $indent) + ? $this->getWhitespace($indent) + : $this->getIndent(); + + $items = array(); + + if($this->_translate && $translator = $this->getTranslator()) { + foreach ($this as $item) { + $items[] = $translator->translate($item, $locale); + } + } else { + foreach ($this as $item) { + $items[] = $item; + } + } + + $separator = $this->getSeparator(); + $output = ''; + if(($prefix = $this->getPrefix())) { + $output .= $prefix; + } + $output .= implode($separator, $items); + if(($postfix = $this->getPostfix())) { + $output .= $postfix; + } + + $output = ($this->_autoEscape) ? $this->_escape($output) : $output; + + return $indent . '' . $output . ''; + } +} -- cgit v1.2.3