• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List

E:/E/GEAMP/www/openbiz/openbiz/others/Zend/View/Helper/HeadTitle.php

00001 <?php
00024 require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php';
00025 
00035 class Zend_View_Helper_HeadTitle extends Zend_View_Helper_Placeholder_Container_Standalone
00036 {
00041     protected $_regKey = 'Zend_View_Helper_HeadTitle';
00042 
00047     protected $_translate = false;
00048 
00054     protected $_translator;
00055 
00064     public function headTitle($title = null, $setType = Zend_View_Helper_Placeholder_Container_Abstract::APPEND)
00065     {
00066         $title = (string) $title;
00067         if ($title !== '') {
00068             if ($setType == Zend_View_Helper_Placeholder_Container_Abstract::SET) {
00069                 $this->set($title);
00070             } elseif ($setType == Zend_View_Helper_Placeholder_Container_Abstract::PREPEND) {
00071                 $this->prepend($title);
00072             } else {
00073                 $this->append($title);
00074             }
00075         }
00076 
00077         return $this;
00078     }
00079 
00086     public function setTranslator($translate)
00087     {
00088         if ($translate instanceof Zend_Translate_Adapter) {
00089             $this->_translator = $translate;
00090         } elseif ($translate instanceof Zend_Translate) {
00091             $this->_translator = $translate->getAdapter();
00092         } else {
00093             require_once 'Zend/View/Exception.php';
00094             throw new Zend_View_Exception("You must set an instance of Zend_Translate or Zend_Translate_Adapter");
00095         }
00096         return $this;
00097     }
00098 
00099     /*
00100      * Retrieve translation object
00101      *
00102      * If none is currently registered, attempts to pull it from the registry
00103      * using the key 'Zend_Translate'.
00104      *
00105      * @return Zend_Translate_Adapter|null
00106      */
00107     public function getTranslator()
00108     {
00109         if (null === $this->_translator) {
00110             require_once 'Zend/Registry.php';
00111             if (Zend_Registry::isRegistered('Zend_Translate')) {
00112                 $this->setTranslator(Zend_Registry::get('Zend_Translate'));
00113             }
00114         }
00115         return $this->_translator;
00116     }
00117 
00123     public function enableTranslation()
00124     {
00125         $this->_translate = true;
00126         return $this;
00127     }
00128 
00134     public function disableTranslation()
00135     {
00136         $this->_translate = false;
00137         return $this;
00138     }
00139 
00147     public function toString($indent = null, $locale = null)
00148     {
00149         $indent = (null !== $indent)
00150                 ? $this->getWhitespace($indent)
00151                 : $this->getIndent();
00152 
00153         $items = array();
00154 
00155         if($this->_translate && $translator = $this->getTranslator()) {
00156             foreach ($this as $item) {
00157                 $items[] = $translator->translate($item, $locale);
00158             }
00159         } else {
00160             foreach ($this as $item) {
00161                 $items[] = $item;
00162             }
00163         }
00164 
00165         $separator = $this->getSeparator();
00166         $output = '';
00167         if(($prefix = $this->getPrefix())) {
00168             $output  .= $prefix;
00169         }
00170         $output .= implode($separator, $items);
00171         if(($postfix = $this->getPostfix())) {
00172             $output .= $postfix;
00173         }
00174 
00175         $output = ($this->_autoEscape) ? $this->_escape($output) : $output;
00176 
00177         return $indent . '<title>' . $output . '</title>';
00178     }
00179 }

Generated on Thu Apr 19 2012 17:01:18 for openbiz by  doxygen 1.7.2