/** * 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['action'] = $this->_action; } elseif (!array_key_exists('action', $myParams)) { $myParams['action'] = $front->getDefaultAction(); } foreach ($myParams as $key => $value) { if (null === $value) { unset($myParams[$key]); } } if (count(array_intersect_assoc($reqParams, $myParams)) == count($myParams)) { $this->_active = true; return true; } $this->_active = false; } return parent::isActive($recursive); }