当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Controller_Request_Http::setRouteName方法代码示例

本文整理汇总了PHP中Zend_Controller_Request_Http::setRouteName方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Request_Http::setRouteName方法的具体用法?PHP Zend_Controller_Request_Http::setRouteName怎么用?PHP Zend_Controller_Request_Http::setRouteName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Controller_Request_Http的用法示例。


在下文中一共展示了Zend_Controller_Request_Http::setRouteName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: match

 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(), '/');
     $parts = explode('/', $identifier);
     if (isset($parts[1]) && $parts[1] == 'reviews') {
         $product = Mage::getModel('catalog/product')->loadByAttribute('url_key', $parts[0]);
         if (isset($parts[2])) {
             $p = explode('-', $parts[2]);
             $id = (int) end($p);
             $request->setRouteName('review')->setModuleName('review')->setControllerName('product')->setActionName('view')->setParam('id', $id)->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, 'reviews');
             return true;
         } else {
             if ($product) {
                 $request->setRouteName('review')->setModuleName('review')->setControllerName('product')->setActionName('list')->setParam('id', $product->getId())->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, 'reviews');
                 return true;
             }
         }
     } elseif ($parts[0] == 'tag' && isset($parts[1])) {
         $p = explode('-', $parts[1]);
         $id = (int) end($p);
         $request->setRouteName('tag')->setModuleName('tag')->setControllerName('product')->setActionName('list')->setParam('tagId', $id)->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, 'tags');
         return true;
     }
     return false;
 }
开发者ID:technomagegithub,项目名称:olgo.nl,代码行数:29,代码来源:Router.php

示例2: match

 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;
 }
开发者ID:Mohitsahu123,项目名称:layered-landing,代码行数:33,代码来源:Router.php

示例3: match

 /**
  * Rewritten function of the standard controller. Tries to match the pathinfo on url parameters.
  * 
  * @see Mage_Core_Controller_Varien_Router_Standard::match()
  * @param Zend_Controller_Request_Http $request The http request object that needs to be mapped on Action Controllers.
  */
 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(), '/');
     // try to gather url parameters from parser.
     /* @var $parser Flagbit_FilterUrls_Model_Parser */
     $parser = Mage::getModel('filterurls/parser');
     $parsedRequestInfo = $parser->parseFilterInformationFromRequest($identifier, Mage::app()->getStore()->getId());
     if (!$parsedRequestInfo) {
         return false;
     }
     Mage::register('filterurls_active', true);
     // if successfully gained url parameters, use them and dispatch ActionController action
     $request->setRouteName('catalog')->setModuleName('catalog')->setControllerName('category')->setActionName('view')->setParam('id', $parsedRequestInfo['categoryId']);
     $pathInfo = 'catalog/category/view/id/' . $parsedRequestInfo['categoryId'];
     $requestUri = '/' . $pathInfo . '?';
     foreach ($parsedRequestInfo['additionalParams'] as $paramKey => $paramValue) {
         $requestUri .= $paramKey . '=' . $paramValue . '&';
     }
     $controllerClassName = $this->_validateControllerClassName('Mage_Catalog', 'category');
     $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $this->getFront()->getResponse());
     $request->setRequestUri(substr($requestUri, 0, -1));
     $request->setPathInfo($pathInfo);
     // dispatch action
     $request->setDispatched(true);
     $controllerInstance->dispatch('view');
     $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
     return true;
 }
开发者ID:konstantins90,项目名称:Magento-FilterUrls,代码行数:38,代码来源:Router.php

示例4: match

 public function match(Zend_Controller_Request_Http $request)
 {
     $helper = Mage::helper('sm_shopby');
     if (!$helper->isEnabled()) {
         return false;
     }
     $suffix = Mage::getStoreConfig('catalog/seo/category_url_suffix');
     $identifier = ltrim($request->getPathInfo(), '/');
     $identifier = substr($identifier, 0, strlen($identifier) - strlen($suffix));
     $urlSplit = explode($helper->getRoutingSuffix(), $identifier, 2);
     if (!isset($urlSplit[1])) {
         return false;
     }
     $urlRewrite = Mage::getModel('core/url_rewrite');
     $urlRewrite->setStoreId(Mage::app()->getStore()->getId());
     $cat = $urlSplit[0];
     $catPath = $cat . $suffix;
     $urlRewrite->loadByRequestPath($catPath);
     if ($urlRewrite->getId()) {
         $modules = $this->getModuleByFrontName('catalog');
         $found = false;
         foreach ($modules as $realModule) {
             $request->setRouteName($this->getRouteByFrontName('catalog'));
             $this->_checkShouldBeSecure($request, '/catalog/category/view');
             $controllerClassName = $this->_validateControllerClassName($realModule, 'category');
             if (!$controllerClassName) {
                 continue;
             }
             $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $this->getFront()->getResponse());
             if (!$controllerInstance->hasAction('view')) {
                 continue;
             }
             $found = true;
             break;
         }
         if (!$found) {
             return false;
         }
         $request->setPathInfo($urlRewrite->getTargetPath());
         $request->setRequestUri('/' . $urlRewrite->getTargetPath());
         $request->setModuleName('catalog')->setControllerName('category')->setActionName('view')->setControllerModule($realModule)->setParam('id', $urlRewrite->getCategoryId())->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $catPath);
         $params = explode('/', trim($urlSplit[1], '/'));
         $layerParams = array();
         $total = count($params);
         for ($i = 0; $i < $total - 1; $i++) {
             if (isset($params[$i + 1])) {
                 $layerParams[$params[$i]] = urldecode($params[$i + 1]);
                 ++$i;
             }
         }
         $layerParams += $request->getPost();
         $request->setParams($layerParams);
         Mage::register('layer_params', $layerParams);
         $request->setDispatched(true);
         $controllerInstance->dispatch('view');
         return true;
     }
     return false;
 }
开发者ID:mSupply,项目名称:runnable_test_repo,代码行数:59,代码来源:Router.php

示例5: match

 public function match(Zend_Controller_Request_Http $request)
 {
     if (!Mage::isInstalled()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
         exit;
     }
     $pathInfo = $request->getPathInfo();
     $result = Mage::helper('mstcore/urlrewrite')->match($pathInfo);
     if ($result) {
         $request->setRouteName($result->getRouteName())->setModuleName($result->getModuleName())->setControllerName($result->getControllerName())->setActionName($result->getActionName())->setParam('id', $result->getEntityId())->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $result->getRouteName());
         return true;
     }
     return false;
 }
开发者ID:vinayshuklasourcefuse,项目名称:sareez,代码行数:14,代码来源:Mirasvit_MstCore_Controller_Router.php

示例6: match

 /**
  * 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;
     }
 }
开发者ID:kalburgimanjunath,项目名称:magento-dealers,代码行数:56,代码来源:Router.php

示例7: match

 /**
  * 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::app()->getStore()->isAdmin()) {
         return false;
     }
     $sellerAtttributeName = Mage::getConfig()->getNode('default/seller_page/attribute_name');
     $seoDisplay = Mage::getConfig()->getNode('default/seller_page/seo_display');
     if (empty($sellerAtttributeName)) {
         //Seller attribute not configured
         return false;
     }
     $pageId = $request->getPathInfo();
     $param = explode('/', $pageId);
     $seller = '';
     if (count($param) > 1 and strtolower($param[1]) == $seoDisplay and !empty($param[2])) {
         //Identify Seller
         $sellerPage = $param[2];
         if (strpos($sellerPage, '.') !== false) {
             $sellerPage = urldecode(substr($sellerPage, 0, -5));
             if ($sellerPage) {
                 $seller = str_replace('-', ' ', $sellerPage);
             } else {
                 return false;
             }
         } else {
             $seller = $sellerPage;
         }
     } else {
         return false;
     }
     if ($seller) {
         Mage::register('seller_company', $seller);
         $realModule = 'Cybage_Marketplace';
         $request->setModuleName('marketplace');
         $request->setRouteName('marketplace');
         $request->setControllerName('seller');
         $request->setActionName('sellerinfo');
         $request->setControllerModule($realModule);
         $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, ltrim($request->getRequestString(), '/'));
         $file = Mage::getModuleDir('controllers', $realModule) . DS . 'SellerController.php';
         include $file;
         //compatibility with 1.3
         $class = $realModule . '_SellerController';
         $controllerInstance = new $class($request, $this->getFront()->getResponse());
         $request->setDispatched(true);
         $controllerInstance->dispatch('sellerinfo');
     }
     return true;
 }
开发者ID:DeveshKumarThakur,项目名称:cosmetics,代码行数:55,代码来源:Router.php

示例8: forwardShopby

 protected function forwardShopby()
 {
     $reservedKey = Mage::getStoreConfig('amshopby/seo/key');
     $realModule = 'Amasty_Shopby';
     $this->request->setPathInfo($reservedKey);
     $this->request->setModuleName('amshopby');
     $this->request->setRouteName('amshopby');
     $this->request->setControllerName('index');
     $this->request->setActionName('index');
     $this->request->setControllerModule($realModule);
     $file = Mage::getModuleDir('controllers', $realModule) . DS . 'IndexController.php';
     include $file;
     //compatibility with 1.3
     $class = $realModule . '_IndexController';
     $controllerInstance = new $class($this->request, $this->getFront()->getResponse());
     $this->request->setDispatched(true);
     $controllerInstance->dispatch('index');
 }
开发者ID:victorkho,项目名称:telor,代码行数:18,代码来源:Router.php

示例9: match

 /**
  * Rewritten function of the standard controller. Tries to match the pathinfo on url parameters.
  *
  * @see Mage_Core_Controller_Varien_Router_Standard::match()
  *
  * @param Zend_Controller_Request_Http $request The http request object that needs to be mapped on Action
  *                                              Controllers.
  */
 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(), '/');
     //URL Search after habbeda
     $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     //$identifier = trim($request->getPathInfo(), '/');
     if (strpos($url, "/alle/") <= 0 && strpos($url, "/all/") <= 0) {
         return false;
     }
     // if successfully gained url parameters, use them and dispatch ActionController action
     $request->setRouteName('landingpagesaa')->setModuleName('landingpagesaa')->setControllerName('index')->setActionName('index');
     //->setParam('test', "test");
     $urlpara = explode("/filter/", $url);
     if (!empty($urlpara[1])) {
         $urlparas = explode("?", $urlpara[1]);
         // Parse url params
         $params = explode('/', trim($urlparas[0], '/'));
         $layerParams = array();
         $total = count($params);
         for ($i = 0; $i < $total - 1; $i++) {
             if (isset($params[$i + 1])) {
                 $layerParams[$params[$i]] = urldecode($params[$i + 1]);
                 ++$i;
             }
         }
         // Add post params to parsed ones from url
         // Usefull to easily override params
         $layerParams += $request->getPost();
         // Add params to request
         $request->setParams($layerParams);
         // Save params in registry - used later to generate links
         Mage::register('layer_params', $layerParams);
     }
     $request->setRequestUri($url);
     $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
     return true;
 }
开发者ID:jronatay,项目名称:ultimo-magento-jron,代码行数:49,代码来源:Router.php

示例10: match

 /**
  * 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;
     }
     $this->fetchDefault();
     $front = $this->getFront();
     $path = trim($request->getPathInfo(), '/');
     if ($path) {
         $p = explode('/', $path);
     } else {
         $p = explode('/', $this->_getDefaultPath());
     }
     // get module name
     if ($request->getModuleName()) {
         $module = $request->getModuleName();
     } else {
         if (!empty($p[0])) {
             $module = $p[0];
         } else {
             $module = $this->getFront()->getDefault('module');
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, '');
         }
     }
     if (!$module) {
         if (Mage::app()->getStore()->isAdmin()) {
             $module = 'admin';
         } else {
             return false;
         }
     }
     /**
      * Searching router args by module name from route using it as key
      */
     $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;
     }
     /**
      * Going through modules to find appropriate controller
      */
     $found = false;
     foreach ($modules as $realModule) {
         $request->setRouteName($this->getRouteByFrontName($module));
         // get controller name
         if ($request->getControllerName()) {
             $controller = $request->getControllerName();
         } else {
             if (!empty($p[1])) {
                 $controller = $p[1];
             } else {
                 $controller = $front->getDefault('controller');
                 $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, ltrim($request->getOriginalPathInfo(), '/'));
             }
         }
         // get action name
         if (empty($action)) {
             if ($request->getActionName()) {
                 $action = $request->getActionName();
             } else {
                 $action = !empty($p[2]) ? $p[2] : $front->getDefault('action');
             }
         }
         //checking if this place should be secure
         $this->_checkShouldBeSecure($request, '/' . $module . '/' . $controller . '/' . $action);
         $controllerClassName = $this->_validateControllerClassName($realModule, $controller);
         if (!$controllerClassName) {
             continue;
         }
         // instantiate controller class
         $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $front->getResponse());
         if (!$controllerInstance->hasAction($action)) {
             continue;
         }
         $found = true;
         break;
     }
     /**
      * if we did not found any suitable
      */
     if (!$found) {
         if ($this->_noRouteShouldBeApplied()) {
             $controller = 'index';
             $action = 'noroute';
             $controllerClassName = $this->_validateControllerClassName($realModule, $controller);
             if (!$controllerClassName) {
                 return false;
             }
//.........这里部分代码省略.........
开发者ID:hientruong90,项目名称:ee_14_installer,代码行数:101,代码来源:Standard.php

示例11: match

 public function match(Zend_Controller_Request_Http $request)
 {
     //checkings before even try to findout that current module should use this router
     if (!$this->_beforeModuleMatch()) {
         return false;
     }
     $this->fetchDefault();
     $front = $this->getFront();
     $p = explode('/', trim($request->getPathInfo(), '/'));
     // get module name
     if ($request->getModuleName()) {
         $module = $request->getModuleName();
     } else {
         if (!empty($p[0])) {
             $module = $p[0];
         } else {
             $module = $this->getFront()->getDefault('module');
             $request->setAlias('rewrite_request_path', '');
         }
     }
     if (!$module) {
         if (App_Main::isAdmin()) {
             $module = 'admin';
         }
     }
     if (empty($module)) {
         return false;
     }
     // Searching router args by module name from route using it as key
     $modules = $this->getModuleByFrontName($module);
     // If we did not found anything  we searching exact this module name in array values
     if ($modules === false) {
         if ($moduleFrontName = $this->getModuleByName($module, $this->_modules)) {
             $modules = array($module);
             $module = $moduleFrontName;
         }
     }
     if (empty($modules)) {
         return false;
     }
     /**
      * Going through modules to find appropriate controller
      */
     $found = false;
     foreach ($modules as $realModule) {
         $request->setRouteName($this->getRouteByFrontName($module));
         // get controller name
         if ($request->getControllerName()) {
             $controller = $request->getControllerName();
         } else {
             if (!empty($p[1])) {
                 $controller = $p[1];
             } else {
                 $controller = $front->getDefault('controller');
                 $request->setAlias('rewrite_request_path', ltrim($request->getOriginalPathInfo(), '/'));
             }
         }
         // get action name
         if (empty($action)) {
             if ($request->getActionName()) {
                 $action = $request->getActionName();
             } else {
                 $action = !empty($p[2]) ? $p[2] : $front->getDefault('action');
             }
         }
         //checking if this place should be secure
         $this->_checkShouldBeSecure($request, '/' . $module . '/' . $controller . '/' . $action);
         $controllerClassName = $this->_validateControllerClassName($realModule, $controller);
         if (!$controllerClassName) {
             continue;
         }
         // instantiate controller class
         $controllerInstance = new $controllerClassName($request, $front->getResponse());
         if (!$controllerInstance->hasAction($action)) {
             continue;
         }
         $found = true;
         break;
     }
     /**
      * if we did not found any siutibul
      */
     if (!$found) {
         if ($this->_noRouteShouldBeApplied()) {
             $controller = 'index';
             $action = 'noroute';
             $controllerClassName = $this->_validateControllerClassName($realModule, $controller);
             if (!$controllerClassName) {
                 return false;
             }
             // instantiate controller class
             $controllerInstance = new $controllerClassName($request, $front->getResponse());
             if (!$controllerInstance->hasAction($action)) {
                 return false;
             }
         } else {
             return false;
         }
     }
     // set values only after all the checks are done
//.........这里部分代码省略.........
开发者ID:hettema,项目名称:Stages,代码行数:101,代码来源:Standard.php

示例12: match

 /**
  * Validate and Match shop view and modify request
  */
 public function match(Zend_Controller_Request_Http $request)
 {
     $front = $this->getFront();
     if (!Mage::isInstalled()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
         exit;
     }
     $routerConfig = Mage::getStoreConfig('shopbybrand/general/router');
     $_end = Mage::getStoreConfig(Magestore_Shopbybrand_Helper_Data::XML_FRONTEND_LINK);
     $_path = urldecode(trim($request->getPathInfo(), '/'));
     if (strpos($_path, $_end)) {
         $_link_params = explode('/', str_replace($_end, '/', $_path), -1);
     } else {
         $_link_params = explode('/', $_path . '/', -1);
     }
     $_count_params = count($_link_params);
     $found = false;
     if (isset($_link_params[0])) {
         $router = $_link_params[0];
         if ($router == $routerConfig) {
             $request->setRouteName('shopbybrand')->setControllerModule('Magestore_Shopbybrand')->setModuleName('brand');
             $module = 'shopbybrand';
             if (isset($_link_params[1]) && $_link_params[1]) {
                 $request->setControllerName($_link_params[1]);
             }
             if (isset($_link_params[2]) && $_link_params[2]) {
                 $request->setActionName($_link_params[2]);
             }
             // get controller name
             if ($request->getControllerName()) {
                 $controller = $request->getControllerName();
             } else {
                 if (!empty($_link_params[1])) {
                     $controller = $_link_params[1];
                 } else {
                     $controller = $front->getDefault('controller');
                     $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, ltrim($request->getOriginalPathInfo(), '/'));
                 }
             }
             // get action name
             if (empty($action)) {
                 if ($request->getActionName()) {
                     $action = $request->getActionName();
                 } else {
                     $action = !empty($_link_params[2]) ? $_link_params[2] : $front->getDefault('action');
                 }
             }
             //checking if this place should be secure
             $this->_checkShouldBeSecure($request, '/' . $module . '/' . $controller . '/' . $action);
             $controllerClassName = $this->_validateControllerClassName('Magestore_Shopbybrand', $controller);
             if (!$controllerClassName) {
                 return false;
             }
             $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $front->getResponse());
             if (!$controllerInstance->hasAction($action)) {
                 return false;
             }
             $found = true;
         }
     }
     if (!$found) {
         if ($this->_noRouteShouldBeApplied()) {
             $controller = 'index';
             $action = 'noroute';
             $controllerClassName = $this->_validateControllerClassName($realModule, $controller);
             if (!$controllerClassName) {
                 return false;
             }
             // instantiate controller class
             $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $front->getResponse());
             if (!$controllerInstance->hasAction($action)) {
                 return false;
             }
         } else {
             return false;
         }
     } else {
         return true;
     }
 }
开发者ID:santhosh400,项目名称:ecart,代码行数:83,代码来源:Router.php

示例13: match

 /**
  * Match the request
  *
  * @param Zend_Controller_Request_Http $request
  * @return boolean
  */
 public function match(Zend_Controller_Request_Http $request)
 {
     $helper = Mage::helper('catalin_seo');
     if (!$helper->isEnabled()) {
         return false;
     }
     $suffix = Mage::getStoreConfig('catalog/seo/category_url_suffix');
     $identifier = ltrim($request->getPathInfo(), '/');
     $identifier = substr($identifier, 0, strlen($identifier) - strlen($suffix));
     $urlSplit = explode($helper->getRoutingSuffix(), $identifier, 2);
     // Check if it is a link generated by the SEO module
     if (!isset($urlSplit[1])) {
         return false;
     }
     $urlRewrite = Mage::getModel('core/url_rewrite');
     $urlRewrite->setStoreId(Mage::app()->getStore()->getId());
     $cat = $urlSplit[0];
     $catPath = $cat . $suffix;
     $urlRewrite->loadByRequestPath($catPath);
     // Check if a valid category is found
     if ($urlRewrite->getId()) {
         $modules = $this->getModuleByFrontName('catalog');
         $found = false;
         // Find the controller to be executed
         // It takes in account rewrites
         foreach ($modules as $realModule) {
             $request->setRouteName($this->getRouteByFrontName('catalog'));
             // Check if this place should be secure
             $this->_checkShouldBeSecure($request, '/catalog/category/view');
             // Find controller class name
             $controllerClassName = $this->_validateControllerClassName($realModule, 'category');
             if (!$controllerClassName) {
                 continue;
             }
             // Instantiate controller class
             $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $this->getFront()->getResponse());
             // Check if controller has viewAction() method
             if (!$controllerInstance->hasAction('view')) {
                 continue;
             }
             $found = true;
             break;
         }
         // Check if we found a controller
         if (!$found) {
             return false;
         }
         // Set the required data on $request object
         $request->setPathInfo($urlRewrite->getTargetPath());
         $request->setRequestUri('/' . $urlRewrite->getTargetPath());
         $request->setModuleName('catalog')->setControllerName('category')->setActionName('view')->setControllerModule($realModule)->setParam('id', $urlRewrite->getCategoryId())->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $catPath);
         // Parse url params
         $params = explode('/', trim($urlSplit[1], '/'));
         $layerParams = array();
         $total = count($params);
         for ($i = 0; $i < $total - 1; $i++) {
             if (isset($params[$i + 1])) {
                 $layerParams[$params[$i]] = urldecode($params[$i + 1]);
                 ++$i;
             }
         }
         // Add post params to parsed ones from url
         // Useful to easily override params
         $layerParams += $request->getPost();
         // Add params to request
         $request->setParams($layerParams);
         // Save params in registry - used later to generate links
         Mage::register('layer_params', $layerParams);
         // dispatch action
         $request->setDispatched(true);
         $controllerInstance->dispatch('view');
         return true;
     }
     return false;
 }
开发者ID:santhosh400,项目名称:ecart,代码行数:81,代码来源:Router.php

示例14: match

 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 {
         $module = !empty($p[0]) ? $p[0] : $this->getFront()->getDefault('module');
     }
     if (!$module) {
         if (Mage::app()->getStore()->isAdmin()) {
             $module = 'admin';
         } else {
             return false;
         }
     }
     $realModule = $this->getModuleByFrontName($module);
     if (!$realModule) {
         if ($moduleFrontName = array_search($module, $this->_modules)) {
             $realModule = $module;
             $module = $moduleFrontName;
         } else {
             return false;
         }
     }
     $request->setRouteName($this->getRouteByFrontName($module));
     if (!Mage::isInstalled()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
         exit;
     }
     $this->_checkShouldBeSecure($request);
     // 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 (!$this->validateControllerFileName($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)) {
         if (!file_exists($controllerFileName)) {
             return false;
         }
         include $controllerFileName;
         if (!class_exists($controllerClassName, false)) {
             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();
 }
开发者ID:HelioFreitas,项目名称:magento-pt_br,代码行数:88,代码来源:Admin.php

示例15: match

 /**
  * Match the request.
  *
  * @param Zend_Controller_Request_Http $request The request object.
  * 
  * @return boolean
  */
 public function match(Zend_Controller_Request_Http $request)
 {
     if (!$this->_beforeModuleMatch()) {
         return false;
     }
     $this->fetchDefault();
     $front = $this->getFront();
     $path = trim($request->getPathInfo(), '/');
     $module = null;
     if ($path) {
         $parts = explode('/', $path);
     } else {
         $parts = explode('/', $this->_getDefaultPath());
     }
     // get module name
     if ($request->getModuleName()) {
         $module = $request->getModuleName();
     }
     if (!$module) {
         if (Mage::app()->getStore()->isAdmin()) {
             return false;
         }
     }
     // Does module match front name
     $loadByPath = false;
     if ($module != Mage::helper('link')->getFrontName()) {
         // If not, check the table for a match on the path
         if ($link = Mage::getModel('link/node')->loadByRequestPath($path)) {
             $module = Mage::helper('link')->getFrontName();
             $loadByPath = true;
         }
     }
     // Translate frontName to module
     $realModule = Mage::helper('link')->getModuleName();
     $request->setRouteName($this->getRouteByFrontName($module));
     // Get controller name
     $controller = $front->getDefault('controller');
     // Get action name
     $action = $front->getDefault('action');
     if ($loadByPath) {
         $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, ltrim(implode('/', $parts), '/'));
     } else {
         $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, ltrim(implode('/', array_slice($parts, 1)), '/'));
     }
     // Checking if this place should be secure
     $this->_checkShouldBeSecure($request, "/{$module}/{$controller}/{$action}");
     $controllerClassName = $this->_validateControllerClassName($realModule, $controller);
     if (!$controllerClassName) {
         return false;
     }
     // Instantiate controller class
     $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $front->getResponse());
     if (!$controllerInstance->hasAction($action)) {
         return false;
     }
     // Set values
     $request->setModuleName($module);
     $request->setControllerName($controller);
     $request->setActionName($action);
     $request->setControllerModule($realModule);
     // Set parameters from pathinfo
     for ($i = 1, $length = sizeof($parts); $i < $length; $i += 2) {
         $request->setParam($parts[$i], isset($parts[$i + 1]) ? urldecode($parts[$i + 1]) : '');
     }
     // Dispatch action
     $request->setDispatched(true);
     $controllerInstance->dispatch($action);
     return true;
 }
开发者ID:beejhuff,项目名称:rootd-link,代码行数:76,代码来源:Router.php


注:本文中的Zend_Controller_Request_Http::setRouteName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。