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

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

00001 <?php
00026 require_once 'Zend/View/Helper/Navigation/HelperAbstract.php';
00027 
00037 class Zend_View_Helper_Navigation
00038     extends Zend_View_Helper_Navigation_HelperAbstract
00039 {
00045     const NS = 'Zend_View_Helper_Navigation';
00046 
00052     protected $_defaultProxy = 'menu';
00053 
00059     protected $_helpers = array();
00060 
00066     protected $_injectContainer = true;
00067 
00073     protected $_injectAcl = true;
00074 
00080     protected $_injectTranslator = true;
00081 
00090     public function navigation(Zend_Navigation_Container $container = null)
00091     {
00092         if (null !== $container) {
00093             $this->setContainer($container);
00094         }
00095 
00096         return $this;
00097     }
00098 
00124     public function __call($method, array $arguments = array())
00125     {
00126         // check if call should proxy to another helper
00127         if ($helper = $this->findHelper($method, false)) {
00128             return call_user_func_array(array($helper, $method), $arguments);
00129         }
00130 
00131         // default behaviour: proxy call to container
00132         return parent::__call($method, $arguments);
00133     }
00134 
00153     public function findHelper($proxy, $strict = true)
00154     {
00155         if (isset($this->_helpers[$proxy])) {
00156             return $this->_helpers[$proxy];
00157         }
00158 
00159         if (!$this->view->getPluginLoader('helper')->getPaths(self::NS)) {
00160             $this->view->addHelperPath(
00161                     str_replace('_', '/', self::NS),
00162                     self::NS);
00163         }
00164 
00165         if ($strict) {
00166             $helper = $this->view->getHelper($proxy);
00167         } else {
00168             try {
00169                 $helper = $this->view->getHelper($proxy);
00170             } catch (Zend_Loader_PluginLoader_Exception $e) {
00171                 return null;
00172             }
00173         }
00174 
00175         if (!$helper instanceof Zend_View_Helper_Navigation_Helper) {
00176             if ($strict) {
00177                 require_once 'Zend/View/Exception.php';
00178                 throw new Zend_View_Exception(sprintf(
00179                         'Proxy helper "%s" is not an instance of ' .
00180                         'Zend_View_Helper_Navigation_Helper',
00181                         get_class($helper)));
00182             }
00183 
00184             return null;
00185         }
00186 
00187         $this->_inject($helper);
00188         $this->_helpers[$proxy] = $helper;
00189 
00190         return $helper;
00191     }
00192 
00200     protected function _inject(Zend_View_Helper_Navigation_Helper $helper)
00201     {
00202         if ($this->getInjectContainer() && !$helper->hasContainer()) {
00203             $helper->setContainer($this->getContainer());
00204         }
00205 
00206         if ($this->getInjectAcl()) {
00207             if (!$helper->hasAcl()) {
00208                 $helper->setAcl($this->getAcl());
00209             }
00210             if (!$helper->hasRole()) {
00211                 $helper->setRole($this->getRole());
00212             }
00213         }
00214 
00215         if ($this->getInjectTranslator() && !$helper->hasTranslator()) {
00216             $helper->setTranslator($this->getTranslator());
00217         }
00218     }
00219 
00220     // Accessors:
00221 
00228     public function setDefaultProxy($proxy)
00229     {
00230         $this->_defaultProxy = (string) $proxy;
00231         return $this;
00232     }
00233 
00239     public function getDefaultProxy()
00240     {
00241         return $this->_defaultProxy;
00242     }
00243 
00252     public function setInjectContainer($injectContainer = true)
00253     {
00254         $this->_injectContainer = (bool) $injectContainer;
00255         return $this;
00256     }
00257 
00263     public function getInjectContainer()
00264     {
00265         return $this->_injectContainer;
00266     }
00267 
00276     public function setInjectAcl($injectAcl = true)
00277     {
00278         $this->_injectAcl = (bool) $injectAcl;
00279         return $this;
00280     }
00281 
00287     public function getInjectAcl()
00288     {
00289         return $this->_injectAcl;
00290     }
00291 
00300     public function setInjectTranslator($injectTranslator = true)
00301     {
00302         $this->_injectTranslator = (bool) $injectTranslator;
00303         return $this;
00304     }
00305 
00311     public function getInjectTranslator()
00312     {
00313         return $this->_injectTranslator;
00314     }
00315 
00316     // Zend_View_Helper_Navigation_Helper:
00317 
00331     public function render(Zend_Navigation_Container $container = null)
00332     {
00333         $helper = $this->findHelper($this->getDefaultProxy());
00334         return $helper->render($container);
00335     }
00336 }

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