Esempio n. 1
1
 /**
  * Validate and Match Cms Page and modify request
  *
  * @param Zend_Controller_Request_Http $request
  * @return bool
  *
  * @SuppressWarnings(PHPMD.ExitExpression)
  */
 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 Mage::getControllerInstance('Mage_Core_Controller_Varien_Action_Forward', $request, Mage::app()->getFrontController()->getResponse());
     }
     if (!$condition->getContinue()) {
         return null;
     }
     $page = Mage::getModel('Mage_Cms_Model_Page');
     $pageId = $page->checkIdentifier($identifier, Mage::app()->getStore()->getId());
     if (!$pageId) {
         return null;
     }
     $request->setModuleName('cms')->setControllerName('page')->setActionName('view')->setParam('page_id', $pageId);
     $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
     return Mage::getControllerInstance('Mage_Core_Controller_Varien_Action_Forward', $request, Mage::app()->getFrontController()->getResponse());
 }
 public function match(Zend_Controller_Request_Http $request)
 {
     /* @var $adminPageHelper Mana_Admin_Helper_Page */
     $adminPageHelper = Mage::helper('mana_admin/page');
     $p = $adminPageHelper->getExplodedPath($request);
     $adminModule = (string) Mage::getConfig()->getNode('admin/routers/adminhtml/args/frontName');
     if ($adminPageHelper->getRequestModule($request) != $adminModule) {
         return false;
     }
     if ($adminPageHelper->hasPageController($request)) {
         $controller = $adminPageHelper->getRequestController($request);
         $action = $adminPageHelper->getRequestAction($request);
         $controllerInstance = Mage::getControllerInstance('Mana_Admin_Controller', $request, $this->getFront()->getResponse());
         // set values only after all the checks are done
         $request->setModuleName($adminModule);
         $request->setControllerName($controller);
         $request->setActionName($action);
         $request->setControllerModule('mana_admin');
         for ($i = 3, $l = sizeof($p); $i < $l; $i += 2) {
             $request->setParam($p[$i], isset($p[$i + 1]) ? urldecode($p[$i + 1]) : '');
         }
         // dispatch action
         $request->setDispatched(true);
         $controllerInstance->dispatch($action);
         return true;
     } else {
         return false;
     }
 }
Esempio n. 3
0
 /**
  * Gets us to Pulsestorm_Simplepage::IndexController->indexAction()
  *
  * Original designs were going to route to a standard Magento controller
  * until the django style pattern matching was decided.  The serves mainly
  * to ensure that the module has been installed correctly, and the jigger
  * the request object the same as default Magento routing would, while still
  * bypassing that routing system.
  */
 protected function _matchStandardController($request)
 {
     $path = trim($request->getPathInfo(), '/');
     if (!$path) {
         return false;
     }
     $parts = explode('/', $path);
     //         $controller = array_shift($parts);
     //         $action     = array_shift($parts);
     //         $action     = $action ? $action : 'index';
     //         $params     = $parts;
     $controller = 'index';
     $action = 'index';
     $controller_name = $this->_validateControllerClassName('Pulsestorm_Simplepage', $controller);
     if (!$controller_name) {
         return false;
     }
     $controller_instance = Mage::getControllerInstance($controller_name, $request, $this->getFront()->getResponse());
     if (!$controller_instance) {
         return false;
     }
     $request->setModuleName('pulsestorm_simplepage');
     $request->setRouteName('pulsestorm_simplepage');
     $request->setControllerName($controller);
     $request->setActionName($action);
     $request->setControllerModule('Pulsestorm_Simplepage');
     for ($i = 3, $l = sizeof($parts); $i < $l; $i += 2) {
         $request->setParam($parts[$i], isset($parts[$i + 1]) ? urldecode($parts[$i + 1]) : '');
     }
     return array($controller_instance, $action);
 }
Esempio n. 4
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;
 }
 /**
  * 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;
 }
Esempio n. 6
0
 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;
 }
Esempio n. 7
0
 /**
  * Match the request
  *
  * @param Zend_Controller_Request_Http $request
  * @return boolean
  */
 public function match(Zend_Controller_Request_Http $request)
 {
     if (!$this->_beforeModuleMatch()) {
         return false;
     }
     $front = $this->getFront();
     $path = trim($request->getPathInfo(), '/');
     $pathParts = explode('/', $path, 4);
     if (!isset($pathParts[0])) {
         return parent::match($request);
     }
     switch ($pathParts[0]) {
         case Mage::getStoreConfig('arioem/parts/shortname'):
             $request->setRouteName('arioem');
             $request->setModuleName('Vikont_ARIOEM');
             $request->setControllerModule('Vikont_ARIOEM');
             $controllerName = 'parts';
             // empty($pathParts[1]) ? 'index' : $pathParts[1];
             $request->setControllerName($controllerName);
             $actionName = 'index';
             // empty($pathParts[2]) ? 'index' : $pathParts[2];
             $request->setActionName($actionName);
             $request->setDispatched(true);
             $brand = empty($pathParts[1]) ? false : $pathParts[1];
             Mage::register('oem_brand', $brand);
             $request->setParam('brand', $brand);
             $partNumber = empty($pathParts[2]) ? false : $pathParts[2];
             Mage::register('oem_part_number', $partNumber);
             $request->setParam('partNumber', $partNumber);
             $controllerClassName = $this->_validateControllerClassName('Vikont_ARIOEM', $controllerName);
             $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $front->getResponse());
             $controllerInstance->dispatch('index');
             return true;
             break;
         case Mage::getStoreConfig('arioem/partcenter/shortname'):
             $request->setRouteName('arioem');
             $request->setModuleName('Vikont_ARIOEM');
             $request->setControllerModule('Vikont_ARIOEM');
             $controllerName = 'partcenter';
             $request->setControllerName($controllerName);
             $actionName = empty($pathParts[1]) ? 'index' : $pathParts[1];
             //'index';
             $request->setActionName($actionName);
             $request->setDispatched(true);
             $controllerClassName = $this->_validateControllerClassName('Vikont_ARIOEM', $controllerName);
             $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $front->getResponse());
             $controllerInstance->dispatch('index');
             break;
     }
     return parent::match($request);
 }
 /**
  * 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;
     }
 }
Esempio n. 9
0
 public function checkTypeHints(Mage_Catalog_Model_Category $category, $noHint, Mage_Core_Helper_Data $data)
 {
     $job = Mage::getModel("monkey/bulksync{$entity}")->load($id);
     $new = new Mage_Admin_Model_Acl();
     // done
     $lifetime = Mage_Core_Model_Cache::DEFAULT_LIFETIME;
     // done
     $model = Mage::getModel('customer/customer');
     $singleton = Mage::getSingleton('admin/session');
     $resource = Mage::getResourceModel('admin/roles_user_collection');
     $resourceSingleton = Mage::getResourceSingleton('catalog/category_tree');
     $createBlock = $this->getLayout()->createBlock('adminhtml/widget_button');
     $blockSingleton = Mage::getBlockSingleton('core/text_list');
     $resourceHelper = Mage::getResourceHelper('catalog');
     $controllerInstance = Mage::getControllerInstance('Mage_Adminhtml_Rss_CatalogController', new stdClass(), new stdClass());
     $dataHelper = Mage::helper('reports');
     $helper = Mage::helper('adminhtml/rss');
 }
Esempio n. 10
0
 /**
  * Modify request and set to no-route action
  * If store is admin and specified different admin front name,
  * change store to default (Possible when enabled Store Code in URL)
  *
  * @param Zend_Controller_Request_Http $request
  * @return boolean
  */
 public function match(Zend_Controller_Request_Http $request)
 {
     $noRoute = explode('/', Mage::app()->getStore()->getConfig('web/default/no_route'));
     $moduleName = isset($noRoute[0]) ? $noRoute[0] : 'core';
     $controllerName = isset($noRoute[1]) ? $noRoute[1] : 'index';
     $actionName = isset($noRoute[2]) ? $noRoute[2] : 'index';
     if (Mage::app()->getStore()->isAdmin()) {
         $adminFrontName = (string) Mage::getConfig()->getNode('admin/routers/adminhtml/args/frontName');
         if ($adminFrontName != $moduleName) {
             $moduleName = 'core';
             $controllerName = 'index';
             $actionName = 'noRoute';
             Mage::app()->setCurrentStore(Mage::app()->getDefaultStoreView());
         }
     }
     $request->setModuleName($moduleName)->setControllerName($controllerName)->setActionName($actionName);
     return Mage::getControllerInstance('Mage_Core_Controller_Varien_Action_Forward', $request, $this->getFront()->getResponse());
 }
Esempio n. 11
0
 public function match(Zend_Controller_Request_Http $request)
 {
     $path = explode('/', trim($request->getPathInfo(), '/'));
     if ($path[0] != Mageplace_Backup_Helper_Const::NAME || !array_key_exists($path[1], self::$ALLOWED_ACTIONS) || !in_array($path[2], self::$ALLOWED_ACTIONS[$path[1]])) {
         return parent::match($request);
     }
     if (!$this->isOwnOriginUrl($request)) {
         Mage::log('MPBACKUP WRONG OWN ORIGIN URL');
         return false;
     }
     Mage::setIsDeveloperMode(true);
     @error_reporting(E_ALL ^ E_NOTICE);
     require_once 'Mageplace/Backup/controllers/' . ucfirst($path[1]) . 'Controller.php';
     $controllerClassName = 'Mageplace_Backup_' . ucfirst($path[1]) . 'Controller';
     /** @var Mageplace_Backup_BackupController|Mageplace_Backup_ProgressController $controllerInstance */
     $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $this->getFront()->getResponse());
     $request->setDispatched(true);
     Mage::getSingleton('mpbackup/session', array('sid' => $request->getParam(Mage_Core_Model_Session_Abstract::SESSION_ID_QUERY_PARAM), 'name' => $controllerInstance->getSessionNamespace() . '_' . $path[1]))->start();
     $actionMethodName = $controllerInstance->getActionMethodName($path[2]);
     $controllerInstance->{$actionMethodName}();
     return true;
 }
Esempio n. 12
0
 /**
  * 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;
             }
             // instantiate controller class
             $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $front->getResponse());
             if (!$controllerInstance->hasAction($action)) {
                 return false;
             }
         } else {
             return false;
         }
     }
     // set values only after all the checks are done
     $request->setModuleName($module);
     $request->setControllerName($controller);
     $request->setActionName($action);
     $request->setControllerModule($realModule);
     // 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]) : '');
     }
     // dispatch action
     $request->setDispatched(true);
     $controllerInstance->dispatch($action);
     return true;
 }
Esempio n. 13
0
 /**
  * Get new controller instance
  *
  * @param $controllerClassName
  * @param Zend_Controller_Request_Http $request
  * @return Mage_Core_Controller_Varien_Action
  */
 protected function _getControllerInstance($controllerClassName, Zend_Controller_Request_Http $request)
 {
     return Mage::getControllerInstance($controllerClassName, $request, $this->getFront()->getResponse(), array('areaCode' => $this->_area));
 }
Esempio n. 14
0
 /**
  *
  *
  * @return bool
  */
 protected function _standardRouterMatch()
 {
     $router = Mage::app()->getFrontController()->getRouter('standard');
     // $router->fetchDefault();
     $front = $router->getFront();
     $path = trim($this->getPathInfo(), '/');
     if ($path) {
         $p = explode('/', $path);
     } else {
         // was $router->_getDefaultPath()
         $p = explode('/', Mage::getStoreConfig('web/default/front'));
     }
     // get module name
     if ($this->getModuleName()) {
         $module = $this->getModuleName();
     } else {
         if (!empty($p[0])) {
             $module = $p[0];
         } else {
             $module = $router->getFront()->getDefault('module');
             $this->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 = $router->getModuleByFrontName($module);
     if ($modules === false) {
         return false;
     }
     /**
      * Going through modules to find appropriate controller
      */
     $found = false;
     foreach ($modules as $realModule) {
         $this->setRouteName($router->getRouteByFrontName($module));
         // get controller name
         if ($this->getControllerName()) {
             $controller = $this->getControllerName();
         } else {
             if (!empty($p[1])) {
                 $controller = $p[1];
             } else {
                 $controller = $front->getDefault('controller');
                 $this->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, ltrim($this->getOriginalPathInfo(), '/'));
             }
         }
         // get action name
         if (empty($action)) {
             if ($this->getActionName()) {
                 $action = $this->getActionName();
             } else {
                 $action = !empty($p[2]) ? $p[2] : $front->getDefault('action');
             }
         }
         //checking if this place should be secure
         // $router->_checkShouldBeSecure($this, '/'.$module.'/'.$controller.'/'.$action);
         // $controllerClassName = $router->_validateControllerClassName($realModule, $controller);
         $controllerClassName = $router->getControllerClassName($realModule, $controller);
         if (!$controllerClassName) {
             continue;
         } else {
             $controllerFileName = $router->getControllerFileName($realModule, $controller);
             if (!$router->validateControllerFileName($controllerFileName)) {
                 return false;
             }
             if (!class_exists($controllerClassName, false)) {
                 if (!file_exists($controllerFileName)) {
                     return false;
                 }
                 include_once $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 = Mage::getControllerInstance($controllerClassName, $this, $front->getResponse());
         if (!$controllerInstance->hasAction($action)) {
             continue;
         }
         $found = true;
         break;
     }
     /**
      * if we did not found any suitable
      */
     if (!$found) {
         /*
         if ($router->_noRouteShouldBeApplied()) {
             $controller = 'index';
             $action = 'noroute';
         
             $controllerClassName = $router->_validateControllerClassName($realModule, $controller);
             if (!$controllerClassName) {
                 return false;
             }
         
             // instantiate controller class
             $controllerInstance = Mage::getControllerInstance($controllerClassName, $this,
                 $front->getResponse());
         
             if (!$controllerInstance->hasAction($action)) {
                 return false;
             }
         } else {
             return false;
         }
         */
         return false;
     }
     // set values only after all the checks are done
     $this->setModuleName($module);
     $this->setControllerName($controller);
     $this->setActionName($action);
     $this->setControllerModule($realModule);
     // set parameters from pathinfo
     for ($i = 3, $l = sizeof($p); $i < $l; $i += 2) {
         $this->setParam($p[$i], isset($p[$i + 1]) ? urldecode($p[$i + 1]) : '');
     }
     // dispatch action
     $this->setDispatched(true);
     // $controllerInstance->dispatch($action);
     return true;
 }
 /**
  * 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::helper('core')->isModuleEnabled('ArtsOnIT_OfflineMaintenance')) {
         $storeenabled = Mage::getStoreConfig('offlineMaintenance/settings/enabled', $request->getStoreCodeFromPath());
         if ($storeenabled) {
             Mage::getSingleton('core/session', array('name' => 'adminhtml'));
             if (!Mage::getSingleton('admin/session')->isLoggedIn()) {
                 Mage::getSingleton('core/session', array('name' => 'front'));
                 $front = $this->getFront();
                 $response = $front->getResponse();
                 $response->setHeader('HTTP/1.1', '503 Service Temporarily Unavailable');
                 $response->setHeader('Status', '503 Service Temporarily Unavailable');
                 $response->setHeader('Retry-After', '5000');
                 $response->setBody(html_entity_decode(Mage::getStoreConfig('offlineMaintenance/settings/message', $request->getStoreCodeFromPath()), ENT_QUOTES, "utf-8"));
                 $response->sendHeaders();
                 $response->outputBody();
                 exit;
             } else {
                 $showreminder = Mage::getStoreConfig('offlineMaintenance/settings/showreminder', $request->getStoreCodeFromPath());
                 if ($showreminder) {
                     $front = $this->getFront();
                     $response = $front->getResponse()->appendBody('<div style="height:12px; background:red; color: white; position:relative; width:100%;padding:3px; z-index:100000;text-trasform:capitalize;">Offline</div>');
                 }
             }
         }
     }
     if (!Mage::helper('smvendors')->enableVendorSlug()) {
         return parent::match($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) {
         return parent::match($request);
     }
     $p = explode('/', $path);
     if (strpos($p[0], '.html') !== false) {
         return parent::match($request);
     }
     $vendorCollection = Mage::getResourceModel('smvendors/vendor_collection')->addFieldToFilter('vendor_slug', $p[0]);
     if ($vendorCollection->count() && ($vendor = $vendorCollection->getFirstItem()) && $vendor->getId()) {
         Mage::register('current_vendor', $vendor, true);
         Mage::register('in_vendor', true, true);
         /**
          * Searching router args by module name from route using it as key
          */
         $frontName = 'vendor';
         $modules = $this->getModuleByFrontName($frontName);
         if ($modules === false) {
             continue;
         }
         /**
          * Going through modules to find appropriate controller
          */
         $found = false;
         foreach ($modules as $realModule) {
             $request->setRouteName($this->getRouteByFrontName($frontName));
             // get controller name
             if (!empty($p[1])) {
                 $controller = $p[1];
             } else {
                 //                    $controller = $front->getDefault('controller');
                 $controller = 'products';
                 $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, ltrim($request->getOriginalPathInfo(), '/'));
             }
             // get action name
             if ($realModule == 'SM_Vendors') {
                 $action = !empty($p[2]) ? $p[2] : 'index';
             } else {
                 $action = !empty($p[2]) ? $p[2] : $front->getDefault('action');
             }
             //checking if this place should be secure
             $this->_checkShouldBeSecure($request, '/' . $frontName . '/' . $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;
         }
         // set values only after all the checks are done
         $request->setModuleName($frontName);
         $request->setControllerName($controller);
         $request->setActionName($action);
         $request->setControllerModule($realModule);
         // 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]) : '');
         }
         // dispatch action
         $request->setDispatched(true);
         $controllerInstance->dispatch($action);
         return true;
     }
     return parent::match($request);
 }
 /**
  * helper
  * @param $moduleName
  * @param $controllerName
  * @param $request
  * @param $response
  *
  * @return Mage_Core_Controller_Front_Action|null
  */
 private function _createController($moduleName, $controllerName, $request, $response)
 {
     $router = Mage::app()->getFrontController()->getRouter('standard');
     $controllerFileName = $router->getControllerFileName($moduleName, $controllerName);
     if (!$router->validateControllerFileName($controllerFileName)) {
         return null;
     }
     $controllerClassName = $router->getControllerClassName($moduleName, $controllerName);
     if (!$controllerClassName) {
         return null;
     }
     if (!class_exists($controllerClassName, false)) {
         if (!file_exists($controllerFileName)) {
             return null;
         }
         include $controllerFileName;
         if (!class_exists($controllerClassName, false)) {
             return null;
         }
     }
     $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $response);
     return $controllerInstance;
 }
Esempio n. 17
0
 /**
  * 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;
     }
 }
Esempio n. 18
0
 /**
  * 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;
 }
 /**
  * order view info
  * 
  * call=orders.view
  * &params={
  *      "id":"string",
  *      "order_status":"string|array(string1,string2,...)",
  *      "store":"int",
  *      
  *      /----tab order
  *      "tab":"this_month",
  *      "filter":"string",
  *      
  *      /----search_product
  *      "product_id":int|string,
  *      "from_date":"date",
  *      "to_date":"date",
  *      "from_value":int,
  *      "to_value":int,
  *      
  *      /----search
  *      "from_date":"date", //2013-12-13
  *      "to_date":"date",
  *      "product":"string",
  *      "from_value":int,
  *      "to_value":int,
  * }
  * 
  * @param type $params
  * 
  */
 public function apiView($params)
 {
     if (!isset($params['id']) || $params['id'] == '') {
         throw new Exception($this->_helper->__('Not defined param name "id" or value is null'), 21);
     }
     $next_ids = $this->getNextIds($params);
     $prev_ids = $this->getPrevIds($params);
     //zend_debug::dump($prev_ids);
     //zend_debug::dump($next_ids); die;
     $order = Mage::getModel('sales/order')->load($params['id']);
     //zend_debug::dump($order->getData());die;
     if ($order->getId() == '') {
         throw new Exception($this->_helper->__('No order'), 22);
     }
     Mage::register('current_order', $order);
     //set current order
     Mage::register('sales_order', $order);
     //load layout for update handle to get total info
     $controller = Mage::getControllerInstance('Mage_Core_Controller_Front_Action', Mage::app()->getRequest(), Mage::app()->getResponse());
     //if(version_compare(Mage::getVersion(),'1.5','<=')){//lt 1.4
     $controller->loadLayout('default');
     //}
     $controller->loadLayout('adminhtml_sales_order_view');
     $block = Mage::getBlockSingleton('simisalestrackingapi/orders_detail');
     $_totals = Mage::getBlockSingleton('simisalestrackingapi/orders_totals')->getTotals();
     if (version_compare(Mage::getVersion(), '1.5', '>=')) {
         $order_totals = $controller->getLayout()->getBlock('order_totals');
     } else {
         $order_totals = Mage::getBlockSingleton('adminhtml/sales_order_totals');
     }
     if (is_object($order_totals)) {
         //add totals
         foreach ($_totals as $total) {
             $order_totals->addTotal($total, 'last');
         }
         //call init total function
         $childs = $order_totals->getChild();
         foreach ($childs as $child) {
             $child->initTotals();
         }
         $total_info = $order_totals->getTotals();
     } else {
         $total_info = $_totals;
     }
     $telephone = '';
     if ($billing_address = $order->getBillingAddress()) {
         $telephone = $billing_address->getTelephone();
     }
     $created_date = Mage::helper('core')->formatDate($order->getCreatedAtStoreDate(), 'medium', false);
     $created_time = Mage::helper('core')->formatTime($order->getCreatedAtStoreDate(), 'medium');
     $order_items = array();
     foreach ($order->getItemsCollection() as $item) {
         if ($item->getParentItem()) {
             continue;
         }
         $block->setItem($item);
         $options = array();
         if ($block->getOrderOptions()) {
             foreach ($block->getOrderOptions() as $_option) {
                 $options[] = array('label' => $_option['label'], 'value' => isset($_option['custom_view']) && $_option['custom_view'] ? $block->getCustomizedOptionValue($_option) : is_array($_option['value']) ? $_option['value'][0]['qty'] . ' x ' . $_option['value'][0]['title'] . ' (' . Mage::helper('core')->currency($_option['value'][0]['price'], true, false) . ')' : $_option['value']);
             }
         }
         $order_items[] = array('name' => $item->getName(), 'sku' => $block->getSku(), 'options' => $options, 'qty' => (int) $item->getQtyOrdered(), 'row_total' => Mage::helper('core')->currency($item->getBaseRowTotal(), true, false));
     }
     //total info to array data
     $total_inf = array();
     foreach ($total_info as $_code => $_row) {
         $total_inf[] = array('code' => $_code, 'is_strong' => $_row->getStrong() ? 1 : 0, 'label' => $_row->getLabel() ? $_row->getLabel() : $_code, 'value' => Mage::helper('core')->currency($_row->getValue(), true, false));
     }
     $data = array('id' => (int) $order->getId(), 'next_ids' => $next_ids, 'prev_ids' => $prev_ids, 'increment_id' => $order->getIncrementId(), 'customer_name' => $order->getCustomerName(), 'customer_email' => $order->getCustomerEmail(), 'customer_id' => (int) $order->getCustomerId(), 'created_date' => $created_date, 'created_time' => $created_time, 'telephone' => $telephone, 'status' => $order->getStatus(), 'order_items' => $order_items, 'total_info' => $total_inf);
     $this->_helper->readNewOrder($order->getId());
     //set is read new order
     return $data;
 }
Esempio n. 20
0
 /**
  * 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;
 }