*/ class Mage_Cms_Controller_Router extends Mage_Core_Controller_Varien_Router_Abstract { /** * Initialize Controller Router * * @param Varien_Event_Observer $observer */ public function initControllerRouters($observer) { /* @var $front Mage_Core_Controller_Varien_Front */ $front = $observer->getEvent()->getFront(); $front->addRouter('cms', $this); } /** * Validate and Match Cms Page and modify request * * @param Zend_Controller_Request_Http $request * @return bool */ public function match(Zend_Controller_Request_Http $request) { if (!Mage::isInstalled()) { Mage::app()->getFrontController()->getResponse() ->setRedirect(Mage::getUrl('install')) ->sendResponse(); exit; } $identifier = trim($request->getPathInfo(), '/'); $condition = new Varien_Object(array( 'identifier' => $identifier, 'continue' => true )); Mage::dispatchEvent('cms_controller_router_match_before', array( 'router' => $this, 'condition' => $condition )); $identifier = $condition->getIdentifier(); if ($condition->getRedirectUrl()) { Mage::app()->getFrontController()->getResponse() ->setRedirect($condition->getRedirectUrl()) ->sendResponse(); $request->setDispatched(true); return true; } if (!$condition->getContinue()) { return false; } $page = Mage::getModel('cms/page'); $pageId = $page->checkIdentifier($identifier, Mage::app()->getStore()->getId()); if (!$pageId) { return false; } $request->setModuleName('cms') ->setControllerName('page') ->setActionName('view') ->setParam('page_id', $pageId); $request->setAlias( Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier ); return true; } }