Ejemplo n.º 1
0
 /**
  * Sets view helper for assembling URLs with schemes
  *
  * @see getHref()
  *
  * @param  IfwPsn_Vendor_Zend_View_Helper_ServerUrl $sh   scheme helper
  * @return void
  */
 public static function setSchemeHelper(IfwPsn_Vendor_Zend_View_Helper_ServerUrl $sh)
 {
     self::$_schemeHelper = $sh;
 }
Ejemplo n.º 2
0
 /**
  * Returns whether page should be considered active or not
  *
  * This method will compare the page properties against the request object
  * that is found in the front controller.
  *
  * @param  bool $recursive  [optional] whether page should be considered
  *                          active if any child pages are active. Default is
  *                          false.
  * @return bool             whether page should be considered active or not
  */
 public function isActive($recursive = false)
 {
     if (null === $this->_active) {
         $front = IfwPsn_Vendor_Zend_Controller_Front::getInstance();
         $request = $front->getRequest();
         $reqParams = array();
         if ($request) {
             $reqParams = $request->getParams();
             if (!array_key_exists('module', $reqParams)) {
                 $reqParams['module'] = $front->getDefaultModule();
             }
         }
         $myParams = $this->_params;
         if ($this->_route && method_exists($front->getRouter(), 'getRoute')) {
             $route = $front->getRouter()->getRoute($this->_route);
             if (method_exists($route, 'getDefaults')) {
                 $myParams = array_merge($route->getDefaults(), $myParams);
             }
         }
         if (null !== $this->_module) {
             $myParams['module'] = $this->_module;
         } elseif (!array_key_exists('module', $myParams)) {
             $myParams['module'] = $front->getDefaultModule();
         }
         if (null !== $this->_controller) {
             $myParams['controller'] = $this->_controller;
         } elseif (!array_key_exists('controller', $myParams)) {
             $myParams['controller'] = $front->getDefaultControllerName();
         }
         if (null !== $this->_action) {
             $myParams[$request->getActionKey()] = $this->_action;
         } elseif (!array_key_exists($request->getActionKey(), $myParams)) {
             $myParams[$request->getActionKey()] = $front->getDefaultAction();
         }
         if (!isset($reqParams[$request->getActionKey()])) {
             $reqParams[$request->getActionKey()] = $front->getDefaultAction();
         }
         foreach ($myParams as $key => $value) {
             if (null === $value) {
                 unset($myParams[$key]);
             }
         }
         $exactActiveMatch = $this->get('exactActiveMatch');
         if (count(array_intersect_assoc($reqParams, $myParams)) == count($myParams) || empty($exactActiveMatch) && $reqParams['module'] == $myParams['module'] && isset($reqParams['controller']) && $reqParams['controller'] == $myParams['controller']) {
             $this->_active = true;
             return true;
         }
         $this->_active = false;
     }
     return parent::isActive($recursive);
 }