本文整理汇总了PHP中Mage::getControllerInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage::getControllerInstance方法的具体用法?PHP Mage::getControllerInstance怎么用?PHP Mage::getControllerInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage
的用法示例。
在下文中一共展示了Mage::getControllerInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: match
/**
* 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());
}
示例2: match
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;
}
}
示例3: _matchStandardController
/**
* 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);
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: match
/**
* 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);
}
示例8: 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;
}
}
示例9: checkTypeHints
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');
}
示例10: match
/**
* 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());
}
示例11: match
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;
}
示例12: 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;
}
//.........这里部分代码省略.........
示例13: _getControllerInstance
/**
* 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));
}
示例14: _standardRouterMatch
/**
*
*
* @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) {
//.........这里部分代码省略.........
示例15: 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::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);
//.........这里部分代码省略.........