Example #1
0
 public function match(Zend_Controller_Request_Http $request)
 {
     if (!Mage::isInstalled()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
         exit;
     }
     $pathInfo = trim($request->getPathInfo(), '/');
     $params = explode('/', $pathInfo);
     if (isset($params[0]) && $params[0] == 'miembro' || isset($params[0]) && $params[0] == 'member') {
         //redirect to mymodule/brands/index/brand_name/addidas
         $request->setModuleName('member')->setControllerName('index')->setActionName('index');
         if (isset($params[1])) {
             $request->setParam('member_url', $params[1]);
         }
         $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $pathInfo);
         return true;
     }
     if (isset($params[0]) && $params[0] == 'mwcon') {
         $request->setModuleName('member')->setControllerName('index')->setActionName('signin');
         if (isset($params[1])) {
             $request->setParam('member_id', $params[1]);
         }
         $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $pathInfo);
         return true;
     }
     return false;
 }
 /**
  * Match a specific route for an already matched prefix.
  *
  * @see XenForo_Route_Interface::match()
  */
 public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
 {
     $components = explode('/', $routePath);
     $action = strtolower(array_shift($components));
     if (count($components) == 1) {
         // permission/<action>, etc
         $action .= reset($components);
     } else {
         switch ($action) {
             case 'permission':
                 // permission/<group>/<permission>/<action>
                 $request->setParam('permission_group_id', array_shift($components));
                 $request->setParam('permission_id', array_shift($components));
                 break;
             case 'permission-group':
                 // permission-group/<group>/<action>
                 $request->setParam('permission_group_id', array_shift($components));
                 break;
             case 'interface-group':
                 // interface-group/<group>/<action>
                 $request->setParam('interface_group_id', array_shift($components));
                 break;
         }
         $action .= implode('', $components);
     }
     return $router->getRouteMatch('XenForo_ControllerAdmin_Permission', $action, 'permissionsDevelopment');
 }
Example #3
0
 /**
  * Match a specific route for an already matched prefix.
  *
  * @see XenForo_Route_Interface::match()
  */
 public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
 {
     $components = explode('/', $routePath);
     if (isset($components[1]) && preg_match('#^([0-9]*)$#', $components[1], $matches)) {
         $request->setParam('chapter', $components[1]);
         $request->setParam('url_portion', $components[0]);
         unset($components[0], $components[1]);
         $action = implode('', $components);
     } elseif (isset($components[1]) && preg_match('#^([0-9]*):([0-9]*)$#', $components[1], $matches)) {
         $request->setParam('chapter', $matches[1]);
         $request->setParam('verse', $matches[2]);
         $request->setParam('url_portion', $components[0]);
         unset($components[0], $components[1]);
         $action = implode('', $components);
     } elseif (isset($components[1]) && preg_match('#^([0-9]*):([0-9]*)-([0-9]*)$#', $components[1], $matches)) {
         $request->setParam('chapter', $matches[1]);
         $request->setParam('verse', $matches[2]);
         $request->setParam('verse_to', $matches[3]);
         $request->setParam('url_portion', $components[0]);
         unset($components[0], $components[1]);
         $action = implode('', $components);
     } else {
         $action = $router->resolveActionWithStringParam($routePath, $request, 'url_portion');
     }
     return $router->getRouteMatch('ThemeHouse_Bible_ControllerPublic_Bible', $action, 'bible');
 }
 /**
  * Match the request
  *
  * @param Zend_Controller_Request_Http $request
  * @return boolean
  */
 public function match(Zend_Controller_Request_Http $request)
 {
     //checking before even try to find out that current module
     //should use this router
     if (!$this->_beforeModuleMatch()) {
         return false;
     }
     $front = $this->getFront();
     $path = trim($request->getPathInfo(), '/');
     $p = explode('/', $path);
     if (count($p) == 0 || !$this->_pluarizeName($p[0])) {
         return false;
     } else {
         $module = $this->_pluarizeName($p[0]);
         $modules = $this->getModuleByFrontName($module);
         if ($modules === false) {
             return false;
         }
         // checks after we found out that this router should be used for current module
         if (!$this->_afterModuleMatch()) {
             return false;
         }
         // set values only after all the checks are done
         $request->setModuleName($module);
         $request->setControllerName('index');
         $action = $this->_getActionFromPathInfo($p);
         $request->setActionName($action);
         $realModule = 'Zefir_Dealers';
         $request->setControllerModule($realModule);
         $request->setRouteName('dealers');
         // dispatch action
         $request->setDispatched(true);
         /**
          * Set params for the request
          */
         if ($action == 'view') {
             $request->setParam('dealer_code', $p[1]);
         } else {
             // set parameters from pathinfo
             for ($i = 3, $l = sizeof($p); $i < $l; $i += 2) {
                 $request->setParam($p[$i], isset($p[$i + 1]) ? urldecode($p[$i + 1]) : '');
             }
         }
         // instantiate controller class and dispatch action
         $controllerClassName = $this->_validateControllerClassName($realModule, 'index');
         $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $front->getResponse());
         $controllerInstance->dispatch($action);
         return true;
     }
 }
Example #5
0
 /**
  * Init method.
  * Call during construction of the controller to perform some default initialization.
  */
 public function init()
 {
     parent::init();
     $this->getResponse()->setHeader('Content-Type', $this->_mimetype);
     $this->_request->setParam('view', $this->_helper->viewRenderer);
     $this->_helper->viewRenderer->setViewScriptPathSpec(":action.phtml");
     $this->view->addHelperPath(USVN_HELPERS_DIR, 'USVN_View_Helper');
     $this->_helper->layout->setLayout('default');
     $this->_request->setParam('project', $this->_request->getParam('project', '__NONE__'));
     $this->_request->setParam('area', $this->_request->getParam('area', '__NONE__'));
     if ($this->_mimetype != 'text/html') {
         $this->_helper->viewRenderer->setNoRender();
     }
 }
Example #6
0
 /**
  * Match a specific route for an already matched prefix.
  *
  * @see XenForo_Route_Interface::match()
  */
 public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
 {
     if (strpos($routePath, '/') !== false) {
         list($action, $value) = explode('/', $routePath);
         if (strpos($action, '-option') !== false) {
             $request->setParam('option_id', $value);
         } else {
             $request->setParam('group_id', $value);
         }
     } else {
         $action = $routePath;
     }
     return $router->getRouteMatch('XenForo_ControllerAdmin_Option', $action, 'optionsLink');
 }
Example #7
0
 function testYearAlnumSelected()
 {
     $vehicle = $this->createMMY('Honda', 'Civic', '2000');
     $request = new Zend_Controller_Request_Http();
     $request->setParam('make', $vehicle->getLevel('make')->getTitle());
     $request->setParam('model', $vehicle->getLevel('model')->getTitle());
     $request->setParam('year', $vehicle->getLevel('year')->getTitle());
     $search = new VF_Search_Form();
     VF_Singleton::getInstance()->setRequest($request);
     $searchlevel = new VF_Search_Level();
     $searchlevel->display($search, 'year');
     $entity = $vehicle->getLevel('year');
     $this->assertTrue($searchlevel->isLevelSelected($entity));
 }
 /**
  * Match a specific route for an already matched prefix.
  *
  * @see XenForo_Route_Interface::match()
  */
 public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
 {
     $components = explode('/', $routePath);
     $componentCount = count($components);
     if ($componentCount >= 3) {
         $request->setParam('route_type', array_shift($components));
         $request->setParam('original_prefix', array_shift($components));
     } else {
         if ($componentCount == 2) {
             $request->setParam('route_type', array_shift($components));
         }
     }
     $action = implode('', $components);
     return $router->getRouteMatch('XenForo_ControllerAdmin_RoutePrefix', $action, 'routePrefixes');
 }
Example #9
0
 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(), '/');
     /* @var $parser Hackathon_Layeredlanding_Model_Layeredlanding */
     $landingPage = Mage::getModel('layeredlanding/layeredlanding')->loadByUrl($identifier);
     if (!$landingPage->getId()) {
         return false;
     }
     Mage::register('current_landingpage', $landingPage);
     Mage::app()->getStore()->setConfig(Mage_Catalog_Helper_Category::XML_PATH_USE_CATEGORY_CANONICAL_TAG, 0);
     // disable canonical tag
     // if successfully gained url parameters, use them and dispatch ActionController action
     $categoryIdsValue = $landingPage->getCategoryIds();
     $categoryIds = explode(',', $categoryIdsValue);
     $firstCategoryId = $categoryIds[0];
     $request->setRouteName('catalog')->setModuleName('catalog')->setControllerName('category')->setActionName('view')->setParam('id', $firstCategoryId);
     /** @var $attribute Hackathon_Layeredlanding_Model_Attributes */
     foreach ($landingPage->getAttributes() as $attribute) {
         $attr = Mage::getModel('eav/entity_attribute')->load($attribute->getAttributeId());
         $request->setParam($attr->getAttributeCode(), $attribute->getValue());
     }
     $controllerClassName = $this->_validateControllerClassName('Mage_Catalog', 'category');
     $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $this->getFront()->getResponse());
     $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
     // dispatch action
     $request->setDispatched(true);
     $controllerInstance->dispatch('view');
     return true;
 }
Example #10
0
 public function testGetAliasedParamZF2455()
 {
     $this->_request->setParam('controller', 'value');
     $this->_request->setAlias('var1', 'controller');
     $this->assertEquals('value', $this->_request->getParam('controller'));
     $this->assertEquals('value', $this->_request->getParam('var1'));
 }
Example #11
0
 public function testSetNullParamUnsetsKey()
 {
     $this->_request->setParam('foo', 'bar');
     $this->assertEquals('bar', $this->_request->getParam('foo'));
     $this->_request->setParam('foo', null);
     $params = $this->_request->getParams();
     $this->assertFalse(isset($params['foo']));
 }
 /**
  * Set a userland parameter
  *
  * Uses $key to set a userland parameter. If $key is an alias, the actual
  * key will be retrieved and used to set the parameter.
  *
  * @param mixed $key
  * @param mixed $value
  * @return Zend_Controller_Request_Http
  */
 public function setParam($key, $value)
 {
     if (Zend_Registry::isRegistered('Zend_Translate')) {
         if (false !== ($keySearch = array_search($this->getPrefix() . $key, Zend_Registry::get('Zend_Translate')->getMessages()))) {
             $key = $keySearch;
         }
     }
     return parent::setParam($key, $value);
 }
Example #13
0
 public function test_getProjectSubMenu()
 {
     $http = new Zend_Controller_Request_Http();
     $http->setParam('project', 'test');
     $menu = new menus_browser($http, null);
     $menuEntries = $menu->getProjectSubMenu();
     $this->assertEquals(1, count($menuEntries));
     $this->assertContains(array("title" => T_("Browser"), "link" => "project/test/browser/", "controller" => "index", "action" => ""), $menuEntries);
 }
Example #14
0
 public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
 {
     $ourAction = 'tagged';
     if (strpos($routePath, $ourAction . '/') === 0) {
         // this is our request
         $action = $ourAction;
         $request->setParam('entity_id', str_replace('/', ',', trim(substr($routePath, strlen($ourAction)), '/')));
         return $router->getRouteMatch('XenForo_ControllerPublic_Member', $action, 'members');
     }
     return parent::match($routePath, $request, $router);
 }
Example #15
0
 public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
 {
     $parts = explode('/', $routePath);
     if (count($parts) > 1) {
         $data = array_pop($parts);
         $request->setParam('data', $data);
         $action = implode('/', $parts);
     } else {
         $action = $routePath;
     }
     return $router->getRouteMatch('DTUI_ControllerPublic_EntryPoint', $action, 'dtui');
 }
Example #16
0
 /**
  * @param string $cat
  * @return bool True for success
  */
 protected function forwardCategory($cat)
 {
     // if somebody has old urls in the cache.
     if (!Mage::getStoreConfig('amshopby/seo/urls')) {
         return false;
     }
     $cat = trim($cat, '/');
     // we do not use Mage::getVersion() here as it is not defined in the old versions.
     $isVersionEE13 = 'true' == (string) Mage::getConfig()->getNode('modules/Enterprise_UrlRewrite/active');
     $suffix = $this->getUrlHelper()->getUrlSuffix();
     if ($isVersionEE13) {
         $urlRewrite = Mage::getModel('enterprise_urlrewrite/url_rewrite');
         /* @var $urlRewrite Enterprise_UrlRewrite_Model_Url_Rewrite */
         if (version_compare(Mage::getVersion(), '1.13.0.2', '>=')) {
             $catReqPath = array('request' => $cat . $suffix, 'whole' => $cat);
         } else {
             $catReqPath = array($cat);
         }
         $urlRewrite->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($catReqPath);
     } else {
         $urlRewrite = Mage::getModel('core/url_rewrite');
         /* @var $urlRewrite Mage_Core_Model_Url_Rewrite */
         $cat = $cat . $suffix;
         $catReqPath = $cat;
         $urlRewrite->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($catReqPath);
     }
     if (!$urlRewrite->getId()) {
         $store = $this->request->getParam('___from_store');
         $store = Mage::app()->getStore($store)->getId();
         if (!$store) {
             return false;
         }
         $urlRewrite->setData(array())->setStoreId($store)->loadByRequestPath($catReqPath);
         if (!$urlRewrite->getId()) {
             return false;
         }
     }
     $this->request->setPathInfo($cat);
     $this->request->setModuleName('catalog');
     $this->request->setControllerName('category');
     $this->request->setActionName('view');
     if ($isVersionEE13) {
         $categoryId = str_replace('catalog/category/view/id/', '', $urlRewrite->getTargetPath());
         $this->request->setParam('id', $categoryId);
     } else {
         $categoryId = $urlRewrite->getCategoryId();
         $this->request->setParam('id', $categoryId);
         $urlRewrite->rewrite($this->request);
     }
     Mage::register('amshopby_forwarded_category_id', $categoryId);
     return true;
 }
Example #17
0
 /**
  * @param string $cat
  * @throws Mage_Core_Controller_Varien_Exception
  */
 protected function forwardCategory($cat)
 {
     $cat = trim($cat, '/');
     // we do not use Mage::getVersion() here as it is not defined in the old versions.
     $isVersionEE13 = Mage::helper('amshopby')->isModuleEnabled('Enterprise_UrlRewrite');
     $suffix = $this->getUrlHelper()->getUrlSuffix();
     if ($isVersionEE13) {
         $urlRewrite = Mage::getModel('enterprise_urlrewrite/url_rewrite');
         /* @var $urlRewrite Enterprise_UrlRewrite_Model_Url_Rewrite */
         if (version_compare(Mage::getVersion(), '1.13.0.2', '>=')) {
             $catReqPath = array('request' => $cat . $suffix, 'whole' => $cat);
         } else {
             $catReqPath = array($cat);
         }
         $urlRewrite->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($catReqPath);
     } else {
         /* @var Mage_Core_Model_Url_Rewrite $urlRewrite */
         $urlRewrite = Mage::getModel('core/url_rewrite');
         $cat = $cat . $suffix;
         $catReqPath = $cat;
         $urlRewrite->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($catReqPath);
     }
     if (!$urlRewrite->getId()) {
         $store = $this->request->getParam('___from_store');
         $store = Mage::app()->getStore($store)->getId();
         if ($store) {
             $urlRewrite->setData(array())->setStoreId($store)->loadByRequestPath($catReqPath);
         }
         if (!$urlRewrite->getId()) {
             if (is_array($catReqPath)) {
                 $catReqPath = current($catReqPath);
             }
             throw new Mage_Core_Controller_Varien_Exception("Routing: Cannot forward to category view page: " . $catReqPath);
         }
     }
     $this->request->setPathInfo($cat);
     $this->request->setModuleName('catalog');
     $this->request->setControllerName('category');
     $this->request->setActionName('view');
     if ($isVersionEE13) {
         $categoryId = str_replace('catalog/category/view/id/', '', $urlRewrite->getTargetPath());
         $this->request->setParam('id', $categoryId);
     } else {
         $categoryId = $urlRewrite->getCategoryId();
         $this->request->setParam('id', $categoryId);
         $urlRewrite->rewrite($this->request);
     }
     Mage::register('amshopby_forwarded_category_id', $categoryId);
 }
Example #18
0
 public function actionView()
 {
     $mediaId = $this->_input->filterSingle('media_id', XenForo_Input::UINT);
     $controllerRequest = new Zend_Controller_Request_Http();
     $controllerRequest->setParam('media_id', $mediaId);
     $routeMatch = new XenForo_RouteMatch();
     $controllerResponse = new Zend_Controller_Response_Http();
     $mediaController = new XenGallery_ControllerPublic_Media($controllerRequest, $controllerResponse, $routeMatch);
     $mediaController->preDispatch('view', get_class($mediaController));
     $controllerResponse = $mediaController->{'actionView'}();
     $mediaParams = $controllerResponse->params;
     if (isset($mediaParams['media']['social_group_id'])) {
         list($team, $category) = $this->_getTeamHelper()->assertTeamValidAndViewable($mediaParams['media']['social_group_id']);
     }
     return $this->_getTeamHelper()->getTeamViewWrapper('photos', $team, $category, $this->responseView('XenGallery_ViewPublic_Media_View', 'Team_xenmedia_view', array_merge($mediaParams, array('team' => $team, 'category' => $category))));
 }
 /**
  * Validate and Match FAQ 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;
     }
     $router = 'faq';
     $identifier = trim(str_replace('/faq/', '', $request->getPathInfo()), '/');
     $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
     Mage::dispatchEvent('faq_controller_router_match_before', array('router' => $this, 'condition' => $condition));
     if ($condition->getRedirectUrl()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
         $request->setDispatched(true);
         return true;
     }
     if (!$condition->getContinue()) {
         return false;
     }
     $category = Mage::getModel('zeon_faq/category');
     $categoryId = $category->checkIdentifier($identifier, Mage::app()->getStore()->getId());
     if (!$categoryId && $identifier == 'mfaq') {
         $request->setModuleName('faq')->setControllerName('index')->setActionName('index');
         if (Mage::helper('zeon_faq')->getIsDisplayMfaq()) {
             $request->setParam('mfaq', 1);
         }
         $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $router);
         return true;
     } elseif ($categoryId) {
         $request->setModuleName('faq')->setControllerName('index')->setActionName('index')->setParam('category_id', $categoryId);
         $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $router . '/' . $identifier);
         return true;
     } else {
         return false;
     }
     return false;
 }
 /**
  * Returns information about how to reroute if a server error occurs.
  *
  * @param Exception Exception object that triggered the error
  *
  * @return array Reroute array
  */
 protected function _rerouteServerError(Exception $e)
 {
     $this->_request->setParam('_exception', $e);
     list($controllerName, $action) = $this->_dependencies->getServerErrorRoute();
     return array('controllerName' => $controllerName, 'action' => $action);
 }
 /**
  * @group ZF-9115
  */
 public function test_request_get_user_params()
 {
     $uri = Zend_Uri::factory('http://localhost.com/user/index?a=1&b=2');
     $request = new Zend_Controller_Request_Http($uri);
     $request->setParam('test', 5);
     $config = array('mod' => array('user'));
     $this->_invokeRouteMatch($request, $config);
     $this->assertEquals(array("test" => 5), $request->getUserParams());
     $this->assertEquals(array("test" => 5, "a" => 1, "b" => 2), $request->getParams());
 }
Example #22
0
 /**
  * Match a specific route for an already matched prefix.
  *
  * @see XenForo_Route_Interface::match()
  */
 public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
 {
     $request->setParam('page_name', $routePath);
     return $router->getRouteMatch('XenForo_ControllerPublic_Help', 'index');
 }
Example #23
0
 public function match(Zend_Controller_Request_Http $request)
 {
     if (!Mage::app()->isInstalled()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
         exit;
     }
     $helper = Mage::helper('blog');
     $route = $helper->getRoute();
     /*  redirect if store was changed  */
     $helper->ifStoreChangedRedirect();
     $identifier = $request->getPathInfo();
     if (substr(str_replace("/", "", $identifier), 0, strlen($route)) != $route) {
         return false;
     }
     $identifier = substr_replace($request->getPathInfo(), '', 0, strlen("/" . $route . "/"));
     $identifier = str_replace('.html', '', $identifier);
     $identifier = str_replace('.htm', '', $identifier);
     if ($identifier == '') {
         $request->setModuleName('blog')->setControllerName('index')->setActionName('index');
         return true;
     }
     if (strpos($identifier, '/')) {
         $page = substr($identifier, strpos($identifier, '/') + 1);
     }
     if (substr($identifier, 0, strlen('tag/')) == 'tag/') {
         $identifier = substr_replace($identifier, '', 0, strlen('cat/'));
         if (strpos($identifier, '/page/')) {
             $page = substr($identifier, strpos($identifier, '/page/') + 6);
             $identifier = substr_replace($identifier, '', strpos($identifier, '/page/'), strlen($page) + 6);
         }
         $rss = false;
         if (strpos($identifier, '/rss')) {
             $rss = true;
             $identifier = substr_replace($identifier, '', strpos($identifier, '/rss'), strlen($page) + 4);
         }
         $identifier = str_replace('/', '', $identifier);
         if ($rss) {
             $request->setModuleName('blog')->setControllerName('rss')->setActionName('index')->setParam('tag', $identifier);
             return true;
         } else {
             $identifier = str_replace('/', '', $identifier);
             $request->setModuleName('blog')->setControllerName('index')->setActionName('list')->setParam('tag', $identifier);
             return true;
         }
     } elseif (substr($identifier, 0, strlen('cat/')) == 'cat/') {
         $identifier = substr_replace($identifier, '', 0, strlen('cat/'));
         if (strpos($identifier, '/page/')) {
             $page = substr($identifier, strpos($identifier, '/page/') + 6);
             $identifier = substr_replace($identifier, '', strpos($identifier, '/page/'), strlen($page) + 6);
         }
         if (strpos($identifier, '/post/')) {
             $postident = substr($identifier, strpos($identifier, '/post/') + 6);
             $identifier = substr_replace($identifier, '', strpos($identifier, '/post/'), strlen($postident) + 6);
             $postident = str_replace('/', '', $postident);
         }
         $rss = false;
         if (strpos($identifier, '/rss')) {
             $rss = true;
             $identifier = substr_replace($identifier, '', strpos($identifier, '/rss'), strlen($page) + 4);
         }
         $identifier = str_replace('/', '', $identifier);
         $cat = Mage::getSingleton('blog/cat');
         if (!$cat->load($identifier)->getCatId()) {
             return false;
         }
         if ($rss) {
             $request->setModuleName('blog')->setControllerName('rss')->setActionName('index')->setParam('identifier', $identifier);
         } else {
             if (isset($postident)) {
                 $post = Mage::getSingleton('blog/post');
                 if (!$post->load($postident)->getId()) {
                     return false;
                 }
                 $request->setModuleName('blog')->setControllerName('post')->setActionName('view')->setParam('identifier', $postident)->setParam('cat', $identifier);
                 return true;
             } else {
                 $request->setModuleName('blog')->setControllerName('cat')->setActionName('view')->setParam('identifier', $identifier);
                 if (isset($page)) {
                     $request->setParam('page', $page);
                 }
             }
         }
         return true;
     } else {
         if (substr($identifier, 0, strlen('page/')) == 'page/') {
             $identifier = substr_replace($identifier, '', 0, strlen('page/'));
             $request->setModuleName('blog')->setControllerName('index')->setActionName('index');
             if (isset($page)) {
                 $request->setParam('page', $page);
             }
             return true;
         } else {
             if (substr($identifier, 0, strlen('rss')) == 'rss') {
                 $identifier = substr_replace($identifier, '', 0, strlen('rss/'));
                 $request->setModuleName('blog')->setControllerName('rss')->setActionName('index');
                 return true;
             } else {
                 $identifier = str_replace('/', '', $identifier);
                 $post = Mage::getSingleton('blog/post');
                 if (!$post->load($identifier)->getId()) {
                     if (!$post->load($identifier . ".htm")->getId()) {
                         if (!$post->load($identifier . ".html")->getId()) {
                             return false;
                         }
                     }
                 }
                 $request->setModuleName('blog')->setControllerName('post')->setActionName('view')->setParam('identifier', $identifier);
                 if (isset($page)) {
                     $request->setParam('page', $page);
                 }
                 return true;
             }
         }
     }
     return false;
 }
Example #24
0
 /**
  * Method gets called when the PreDispatcher's dispatchLoopStartup
  * method gets called.
  * This method is API only.
  *
  * @param Zend_Controller_Request_Abstract $request
  *
  * @packageprotected
  */
 public function notifyDispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     if ($this->_preProcessRequest($request)) {
         return;
     }
     if ($this->_isExtMultiRequest) {
         return;
     }
     $config =& $this->_config;
     $extDirectData = $request->getParam($config['extParameter'], null);
     if ($extDirectData && is_string($extDirectData)) {
         $decoded = Zend_Json::decode($extDirectData);
         if (!Conjoon_Util_Array::isAssociative($decoded)) {
             $this->_isExtMultiRequest = true;
             $this->_isExtRequest = true;
             for ($i = count($decoded) - 1; $i >= 0; $i--) {
                 $controller = strtolower(preg_replace('/([a-z])([A-Z])/', "\$1.\$2", $decoded[$i]['action']));
                 $action = strtolower(preg_replace('/([a-z])([A-Z])/', "\$1.\$2", $decoded[$i]['method']));
                 $req = new Zend_Controller_Request_Http();
                 $req->setActionName($action)->setControllerName($controller)->setModuleName($request->module);
                 $this->_requestStack[] = $req;
                 $this->_requestInfo[] = array('action' => $action, 'controller' => $controller, 'module' => $request->module);
                 $decoded[$i][$config['indexKey']] = count($this->_requestStack) - 1;
                 foreach ($config['additionalParams'] as $pKey => $pValue) {
                     $req->setParam($pKey, $pValue);
                 }
                 $this->_applyParams($req, $decoded[$i]);
             }
             foreach ($config['additionalParams'] as $pKey => $pValue) {
                 $request->setParam($pKey, $pValue);
             }
             if ($config['module']) {
                 $request->setModuleName($config['module']);
             }
             if ($config['controller']) {
                 $request->setControllerName($config['controller']);
             }
             if ($config['action']) {
                 $request->setActionName($config['action']);
             }
             $this->_copyParams();
             $this->_copyHelper();
             $this->_copyPlugins();
         } else {
             $this->_isExtRequest = true;
             $this->_applyParams($request, $decoded);
         }
     }
     $this->_processed = true;
 }
Example #25
0
 public function match(Zend_Controller_Request_Http $request)
 {
     if (Mage::app()->getStore()->isAdmin()) {
         return false;
     }
     $pageId = $request->getPathInfo();
     // remove suffix if any
     $suffix = Mage::getStoreConfig('catalog/seo/category_url_suffix');
     if ($suffix && '/' != $suffix) {
         $pageId = str_replace($suffix, '', $pageId);
     }
     //add trailing slash
     $pageId = trim($pageId, '/') . '/';
     $reservedKey = Mage::getStoreConfig('amshopby/seo/key') . '/';
     //check if we have reserved word in the url
     if (false === strpos($pageId, '/' . $reservedKey)) {
         if (substr($pageId, 0, strlen($reservedKey)) != $reservedKey) {
             return false;
         }
     } else {
         $reservedKey = '/' . $reservedKey;
     }
     // get layered navigation params as string
     list($cat, $params) = explode($reservedKey, $pageId, 2);
     $params = trim($params, '/');
     if ($params) {
         $params = explode('/', $params);
     }
     // remember for futire use in the helper
     if ($params) {
         Mage::register('amshopby_current_params', $params);
     }
     $cat = trim($cat, '/');
     if ($cat) {
         // normal category
         // if somebody has old urls in the cache.
         if (!Mage::getStoreConfig('amshopby/seo/urls')) {
             return false;
         }
         Varien_Autoload::registerScope('catalog');
         $cat = $cat . $suffix;
         $urlRewrite = Mage::getModel('core/url_rewrite')->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($cat);
         if (!$urlRewrite->getId()) {
             $store = $request->getParam('___from_store');
             $store = Mage::app()->getStore($store)->getId();
             if (!$store) {
                 return false;
             }
             $urlRewrite = Mage::getModel('core/url_rewrite')->setStoreId($store)->loadByRequestPath($cat);
         }
         if (!$urlRewrite->getId()) {
             return false;
         }
         $request->setPathInfo($cat);
         $request->setModuleName('catalog');
         $request->setControllerName('category');
         $request->setActionName('view');
         $request->setParam('id', $urlRewrite->getCategoryId());
         $urlRewrite->rewrite($request);
     } else {
         // root category
         $realModule = 'Amasty_Shopby';
         $request->setPathInfo(trim($reservedKey, '/'));
         $request->setModuleName('amshopby');
         $request->setRouteName('amshopby');
         $request->setControllerName('index');
         $request->setActionName('index');
         $request->setControllerModule($realModule);
         $file = Mage::getModuleDir('controllers', $realModule) . DS . 'IndexController.php';
         include $file;
         //compatibility with 1.3
         $class = $realModule . '_IndexController';
         $controllerInstance = new $class($request, $this->getFront()->getResponse());
         $request->setDispatched(true);
         $controllerInstance->dispatch('index');
     }
     return true;
 }
 /**
  * Test that classes are found in modules, using a prefix
  */
 public function testNamespacedModules()
 {
     $this->_dispatcher->setControllerDirectory(array('default' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files', 'admin' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files/Admin'));
     $request = new Zend_Controller_Request_Http();
     $request->setControllerName('foo');
     $request->setActionName('bar');
     $request->setParam('module', 'admin');
     $this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1));
     $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files/Admin', $this->_dispatcher->getDispatchDirectory());
     $response = new Zend_Controller_Response_Cli();
     $this->_dispatcher->dispatch($request, $response);
     $body = $this->_dispatcher->getResponse()->getBody();
     $this->assertContains("Admin_Foo::bar action called", $body, $body);
 }
Example #27
0
 public function test_getSubSubMenu()
 {
     $request = new Zend_Controller_Request_Http();
     $request->setParam('project', 'bidon');
     $request->setParam('controller', 'alpha');
     $menu = new USVN_Menu($this->_menudir, $request, null);
     $menuEntries = $menu->getSubSubMenu();
     $this->assertContains(array("title" => "Alpha new user", "link" => "admin/user/new/", "controller" => "alpha", "action" => "new"), $menuEntries);
     $this->assertNotContains(array("title" => "Beta new user", "link" => "admin/user/new/", "controller" => "beta", "action" => "new"), $menuEntries);
 }
Example #28
0
 /**
  * @param Zend_Controller_Request_Http $request
  * @return $this|Zend_Controller_Request_Http
  * @throws EcommerceTeam_Sln_Exception_Rewrite
  */
 protected function _oldRewrite(Zend_Controller_Request_Http $request)
 {
     /** @var $helper EcommerceTeam_Sln_Helper_Data */
     $helper = Mage::helper('ecommerceteam_sln');
     $separator = $helper->getConfigData('url_separator');
     $requestPath = trim($request->getPathInfo(), '/');
     $requestPath = Mage::helper('ecommerceteam_sln/request')->clearSuffix($requestPath);
     $path = explode('/', $requestPath);
     $filterKey = array_search($separator, $path);
     if ($filterKey !== false) {
         $filterParams = array_slice($path, $filterKey + 1);
         if (count($filterParams) % 2) {
             array_unshift($filterParams, 'attributes');
         }
         if ($filterKey) {
             $categoryUrlKey = implode('/', array_slice($path, 0, $filterKey));
         } else {
             $categoryUrlKey = implode('/', $path);
         }
         if ($filterKey && $categoryUrlKey) {
             if (Mage::getStoreConfig("catalog/seo/category_url_suffix") == "/") {
                 $categoryUrlKey = $categoryUrlKey . '/';
             } else {
                 $categoryUrlKey = trim($categoryUrlKey, '/') . $helper->getUrlSuffix();
             }
             /** @var $urlRewriteModel Mage_Core_Model_Url_Rewrite */
             $urlRewriteModel = Mage::getModel('core/url_rewrite');
             if ($helper->isMagentoEnterprise()) {
                 $urlRewriteModel = Mage::getModel('enterprise_urlrewrite/url_rewrite');
             }
             $urlRewriteModel->setData('store_id', Mage::app()->getStore()->getId());
             $targetPath = $urlRewriteModel->loadByRequestPath(array($categoryUrlKey))->getTargetPath();
             if (!$urlRewriteModel->getData('category_id')) {
                 throw new EcommerceTeam_Sln_Exception_Rewrite($this->__("Can't resolve category request path."));
             }
             $currentCategory = Mage::getModel('catalog/category')->load($urlRewriteModel->getData('category_id'));
             Mage::getSingleton('catalog/layer')->setCurrentCategory($currentCategory);
             $itemsLength = count($filterParams);
             $request->setParam('layered_navigation_base_url', Mage::getBaseUrl('web') . $urlRewriteModel->getRequestPath());
             for ($i = 0; $i < $itemsLength; $i += 2) {
                 $request->setParam($filterParams[$i], isset($filterParams[$i + 1]) ? explode(',', $filterParams[$i + 1]) : null);
             }
             if ($targetPath) {
                 $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, trim($request->getPathInfo(), '/'));
                 $request->setPathInfo($targetPath);
                 return $request;
             }
         }
     }
     return $this;
 }
 public function match(Zend_Controller_Request_Http $request)
 {
     if (Mage::app()->getStore()->isAdmin()) {
         return false;
     }
     $pageId = $request->getPathInfo();
     // remove suffix if any
     $suffix = Mage::helper('amshopby/url')->getUrlSuffix();
     if ($suffix && '/' != $suffix) {
         $pageId = str_replace($suffix, '', $pageId);
     }
     //add trailing slash
     $pageId = trim($pageId, '/') . '/';
     $reservedKey = Mage::getStoreConfig('amshopby/seo/key') . '/';
     //  canon/
     //  electronics - false
     //  electronics/shopby/canon/
     //  electronics/shopby/red/
     //  electronics/shopby/
     //  shopby/
     //  shopby/red/
     //  shopby/canon/ - false
     //  shopby/manufacturer-canon/ - false
     //  manufacturer-canon/ - true
     // starts from shopby
     $isAllProductsPage = substr($pageId, 0, strlen($reservedKey)) == $reservedKey;
     // has shopby in the middle
     $isCategoryPage = false !== strpos($pageId, '/' . $reservedKey);
     if (!Mage::getStoreConfig('amshopby/seo/urls')) {
         // If path info have something after reserved key
         if (($isAllProductsPage || $isCategoryPage) && substr($pageId, -strlen($reservedKey), strlen($reservedKey)) != $reservedKey) {
             return false;
         }
     }
     if ($isAllProductsPage) {
         // no support for old style urls
         if ($this->hasBrandIn(self::MIDDLE, $pageId)) {
             return false;
         }
     }
     if (!$isAllProductsPage && !$isCategoryPage) {
         if (!$this->hasBrandIn(self::BEGINNING, $pageId)) {
             return false;
         }
         //it is brand page and we modify the url to be in the old style
         $pageId = $reservedKey . $pageId;
     }
     // get layered navigation params as string
     list($cat, $params) = explode($reservedKey, $pageId, 2);
     $params = trim($params, '/');
     if ($params) {
         $params = explode('/', $params);
     }
     // remember for futire use in the helper
     if ($params) {
         Mage::register('amshopby_current_params', $params);
     }
     $cat = trim($cat, '/');
     if ($cat) {
         // normal category
         // if somebody has old urls in the cache.
         if (!Mage::getStoreConfig('amshopby/seo/urls')) {
             return false;
         }
         // we do not use Mage::getVersion() here as it is not defined in the old versions.
         $isVersionEE13 = 'true' == (string) Mage::getConfig()->getNode('modules/Enterprise_UrlRewrite/active');
         if ($isVersionEE13) {
             $urlRewrite = Mage::getModel('enterprise_urlrewrite/url_rewrite');
             /* @var $urlRewrite Enterprise_UrlRewrite_Model_Url_Rewrite */
             if (version_compare(Mage::getVersion(), '1.13.0.2', '>=')) {
                 $catReqPath = array('request' => $cat . $suffix, 'whole' => $cat);
             } else {
                 $catReqPath = array($cat);
             }
             $urlRewrite->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($catReqPath);
         } else {
             $urlRewrite = Mage::getModel('core/url_rewrite');
             /* @var $urlRewrite Mage_Core_Model_Url_Rewrite */
             $cat = $cat . $suffix;
             $catReqPath = $cat;
             $urlRewrite->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($catReqPath);
         }
         // todo check in ee13
         if (!$urlRewrite->getId()) {
             $store = $request->getParam('___from_store');
             $store = Mage::app()->getStore($store)->getId();
             if (!$store) {
                 return false;
             }
             $urlRewrite->setData(array())->setStoreId($store)->loadByRequestPath($catReqPath);
             if (!$urlRewrite->getId()) {
                 return false;
             }
         }
         $request->setPathInfo($cat);
         $request->setModuleName('catalog');
         $request->setControllerName('category');
         $request->setActionName('view');
         if ($isVersionEE13) {
             $categoryId = str_replace('catalog/category/view/id/', '', $urlRewrite->getTargetPath());
             $request->setParam('id', $categoryId);
         } else {
             $request->setParam('id', $urlRewrite->getCategoryId());
             $urlRewrite->rewrite($request);
         }
     } else {
         // root category
         $realModule = 'Amasty_Shopby';
         $request->setPathInfo(trim($reservedKey, '/'));
         $request->setModuleName('amshopby');
         $request->setRouteName('amshopby');
         $request->setControllerName('index');
         $request->setActionName('index');
         $request->setControllerModule($realModule);
         $file = Mage::getModuleDir('controllers', $realModule) . DS . 'IndexController.php';
         include $file;
         //compatibility with 1.3
         $class = $realModule . '_IndexController';
         $controllerInstance = new $class($request, $this->getFront()->getResponse());
         $request->setDispatched(true);
         $controllerInstance->dispatch('index');
     }
     return true;
 }
Example #30
0
 public function match(Zend_Controller_Request_Http $request)
 {
     $this->fetchDefault();
     $front = $this->getFront();
     $p = explode('/', trim($request->getPathInfo(), '/'));
     // get module name
     if ($request->getModuleName()) {
         $module = $request->getModuleName();
     } else {
         $p = explode('/', trim($request->getPathInfo(), '/'));
         $module = !empty($p[0]) ? $p[0] : $this->getFront()->getDefault('module');
     }
     if (!$module) {
         return false;
     }
     $realModule = $this->getModuleByFrontName($module);
     if (!$realModule) {
         if ($moduleFrontName = array_search($module, $this->_modules)) {
             $realModule = $module;
             $module = $moduleFrontName;
         } else {
             return false;
         }
     }
     if (!Mage::app()->isInstalled()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
         exit;
     }
     if (Mage::app()->isInstalled() && !$request->isPost()) {
         $shouldBeSecure = substr(Mage::getStoreConfig('web/unsecure/base_url'), 0, 5) === 'https' || Mage::getStoreConfigFlag('web/secure/use_in_adminhtml') && substr(Mage::getStoreConfig('web/secure/base_url'), 0, 5) === 'https';
         if ($shouldBeSecure && !Mage::app()->getStore()->isCurrentlySecure()) {
             $url = Mage::getBaseUrl('link', true) . ltrim($request->getPathInfo(), '/');
             Mage::app()->getFrontController()->getResponse()->setRedirect($url)->sendResponse();
             exit;
         }
     }
     // get controller name
     if ($request->getControllerName()) {
         $controller = $request->getControllerName();
     } else {
         $controller = !empty($p[1]) ? $p[1] : $front->getDefault('controller');
     }
     $controllerFileName = $this->getControllerFileName($realModule, $controller);
     if (!$controllerFileName || !is_readable($controllerFileName)) {
         $controller = 'index';
         $action = 'noroute';
         $controllerFileName = $this->getControllerFileName($realModule, $controller);
     }
     $controllerClassName = $this->getControllerClassName($realModule, $controller);
     if (!$controllerClassName) {
         $controller = 'index';
         $action = 'noroute';
         $controllerFileName = $this->getControllerFileName($realModule, $controller);
     }
     // get action name
     if (empty($action)) {
         if ($request->getActionName()) {
             $action = $request->getActionName();
         } else {
             $action = !empty($p[2]) ? $p[2] : $front->getDefault('action');
         }
     }
     // include controller file if needed
     if (!class_exists($controllerClassName, false)) {
         include $controllerFileName;
         if (!class_exists($controllerClassName)) {
             throw Mage::exception('Mage_Core', Mage::helper('core')->__('Controller file was loaded but class does not exist'));
         }
     }
     // instantiate controller class
     $controllerInstance = new $controllerClassName($request, $front->getResponse());
     if (!$controllerInstance->hasAction($action)) {
         return false;
     }
     // set values only after all the checks are done
     $request->setModuleName($module);
     $request->setControllerName($controller);
     $request->setActionName($action);
     // set parameters from pathinfo
     for ($i = 3, $l = sizeof($p); $i < $l; $i += 2) {
         $request->setParam($p[$i], isset($p[$i + 1]) ? $p[$i + 1] : '');
     }
     // dispatch action
     $request->setDispatched(true);
     $controllerInstance->dispatch($action);
     return true;
     #$request->isDispatched();
 }