Exemplo n.º 1
1
 /**
  *
  */
 public function initControllerRouters($observer)
 {
     $request = $observer->getEvent()->getFront()->getRequest();
     $identifier = trim($request->getPathInfo(), '/');
     $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
     Mage::dispatchEvent('brand_controller_router_match_before', array('router' => $this, 'condition' => $condition));
     $identifier = $condition->getIdentifier();
     if ($condition->getRedirectUrl()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
         $request->setDispatched(true);
         return true;
     }
     if (!$condition->getContinue()) {
         return false;
     }
     $route = trim(Mage::getStoreConfig('ves_brand/general_setting/route'));
     if ($identifier) {
         if (preg_match("#^" . $route . "(\\.html)?\$#", $identifier, $match)) {
             $request->setModuleName('venusbrand')->setControllerName('brand')->setActionName('index');
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
             return true;
         }
         return true;
     }
     return false;
 }
Exemplo n.º 2
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());
 }
Exemplo n.º 3
0
 public function render(Varien_Object $row)
 {
     // Get the bank's identifier value
     $bankid = $row->getIdentifier();
     // Match this to M2E Pro's Ebay identifiers (stop searching if one is found)
     $orders = Mage::getModel('M2ePro/ebay_order')->getCollection();
     foreach ($orders as $order) {
         // See if the bank's identifier matches an Ebay identifier
         if ($bankid == $order->getData('ebay_order_id')) {
             // Return the normal Magento order ID
             $order_id = $order->getData('order_id');
             $magento_order_id = Mage::getModel('M2ePro/order')->load($order_id)->getMagentoOrderId();
             return Mage::getModel('sales/order')->load($magento_order_id)->getIncrementId();
         }
     }
     // Match this to M2E Pro's Amazon identifiers (stop searching if one is found)
     $orders = Mage::getModel('M2ePro/amazon_order')->getCollection();
     foreach ($orders as $order) {
         // See if the bank's identifier matches an Amazon identifier
         if ($bankid == $order->getData('amazon_order_id')) {
             // Return the normal Magento order ID
             $order_id = $order->getData('order_id');
             $magento_order_id = Mage::getModel('M2ePro/order')->load($order_id)->getMagentoOrderId();
             return Mage::getModel('sales/order')->load($magento_order_id)->getIncrementId();
         }
     }
     // Could not find a match, return nothing
     return "(not translated)";
 }
Exemplo 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(), '/');
     $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
     Mage::dispatchEvent('magicproduct_controller_router_match_before', array('router' => $this, 'condition' => $condition));
     $identifier = $condition->getIdentifier();
     if ($condition->getRedirectUrl()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
         $request->setDispatched(true);
         return true;
     }
     if (!$condition->getContinue()) {
         return false;
     }
     if (!in_array($identifier, $this->router)) {
         return false;
     }
     $request->setModuleName('magicproduct')->setControllerName('index')->setActionName('product')->setParam('type', $identifier);
     $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
     return true;
 }
Exemplo n.º 5
0
 /**
  *
  */
 public function initControllerRouters($observer)
 {
     Mage::getSingleton('core/session', array('name' => 'adminhtml'));
     if (!is_null(Mage::registry("_singleton/admin/session"))) {
         if (Mage::getSingleton('admin/session')->isLoggedIn()) {
             /*Is admin*/
             //do stuff
             return;
         }
     }
     $request = $observer->getEvent()->getFront()->getRequest();
     if (!Mage::app()->isInstalled()) {
         /*
         Mage::app()->getFrontController()->getResponse()
             ->setRedirect(Mage::getUrl('install'))
             ->sendResponse();
         */
         return;
     }
     $identifier = trim($request->getPathInfo(), '/');
     $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
     Mage::dispatchEvent('blog_controller_router_match_before', array('router' => $this, 'condition' => $condition));
     $identifier = $condition->getIdentifier();
     $identifier = trim($identifier, "/");
     if ($condition->getRedirectUrl()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
         $request->setDispatched(true);
         return true;
     }
     if (!$condition->getContinue()) {
         return false;
     }
     $route = trim(Mage::getStoreConfig('ves_blog/general_setting/route'));
     if ($identifier) {
         if (preg_match("#^" . $route . "(\\.html)?\$#", $identifier, $match)) {
             $request->setModuleName('venusblog')->setControllerName('index')->setActionName('index');
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
             return true;
         } elseif (str_replace('/rss', '', str_replace($route, '', $identifier)) == '') {
             $request->setModuleName('venusblog')->setControllerName('rss')->setActionName('index');
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
             return true;
         } elseif (preg_match("#" . $route . "/tag/(\\w+)\\.?#", $identifier, $match)) {
             if (count($match) <= 1) {
                 return false;
             }
             $request->setModuleName('venusblog')->setControllerName('list')->setActionName('show')->setParam("tag", $match[1]);
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
             return true;
         } elseif (preg_match("#" . $route . "/archive/(\\w+)\\.?#", $identifier, $match)) {
             if (count($match) <= 1) {
                 return false;
             }
             $request->setModuleName('venusblog')->setControllerName('list')->setActionName('show')->setParam("archive", $match[1]);
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
             return true;
         }
     }
     return false;
 }
Exemplo n.º 6
0
 /**
  * Validate and Match Manufacturer Page and modify request
  *
  * @param Zend_Controller_Request_Http $request
  * @return bool
  */
 public function match(Zend_Controller_Request_Http $request)
 {
     if (!Mage::isInstalled()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
         exit;
     }
     $router = 'manufacturers';
     $identifier = trim(str_replace('/manufacturers/', '', $request->getPathInfo()), '/');
     $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
     Mage::dispatchEvent('manufacturer_controller_router_match_before', array('router' => $this, 'condition' => $condition));
     $identifier = $condition->getIdentifier();
     if ($condition->getRedirectUrl()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
         $request->setDispatched(true);
         return true;
     }
     if (!$condition->getContinue()) {
         return false;
     }
     $manufacturer = Mage::getModel('zeon_manufacturer/manufacturer');
     $manufacturerId = $manufacturer->checkIdentifier($identifier, Mage::app()->getStore()->getId());
     if (trim($identifier) && $manufacturerId) {
         $request->setModuleName('manufacturers')->setControllerName('index')->setActionName('view')->setParam('manufacturer_id', $manufacturerId);
         $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $router . '/' . $identifier);
         return true;
     }
     return false;
 }
Exemplo n.º 7
0
 public function render(Varien_Object $row)
 {
     Mage::dispatchEvent('adminhtml_cms_page_grid_renderer_action_before_render', array('row' => $row));
     if ($row->getPreviewUrl()) {
         $href = $row->getPreviewUrl();
     } else {
         $urlModel = Mage::getModel('core/url')->setStore($row->getData('_first_store_id'));
         $href = $urlModel->getUrl($row->getIdentifier(), array('_current' => false, '_query' => '___store=' . $row->getStoreCode()));
     }
     return '<a href="' . $href . '" target="_blank">' . $this->__('Preview') . '</a>';
 }
 public function render(Varien_Object $row)
 {
     $SelectedEntityIdGrid = Mage::registry('SelectedEntityIdGrid');
     if ($SelectedEntityIdGrid) {
         $is_checked = isset($SelectedEntityIdGrid[$row->getIdentifier()]);
     } else {
         $is_checked = (int) Mage::app()->getRequest()->getParam('theme_id') == (int) Mage::helper('thememanager')->getCmsPageConfigByEntity($row);
     }
     return '<input class="massaction-checkbox" ' . ($is_checked ? 'checked="checked"' : '') . ' type="checkbox" value="' . $row->getIdentifier() . '" name="__CheckedCmsPages[]">
             <input type="hidden" value="' . $row->getIdentifier() . '" name="__CheckCmsPagesList[]">';
 }
Exemplo n.º 9
0
 /**
  * @param Varien_Object $page
  * @return $this
  */
 public function clearPageCache(Varien_Object $page)
 {
     if ($page->getId()) {
         foreach (Mage::app()->getStores() as $store) {
             $identifier = $page->getIdentifier();
             if (empty($identifier)) {
                 $this->clearCacheItem(FPC_HOME_FILENAME, $store);
             } else {
                 $this->clearCacheItem($identifier, $store);
             }
         }
     }
     return $this;
 }
Exemplo n.º 10
0
 public function initControllerRouters($observer)
 {
     if (!Mage::app()->getStore()->isAdmin()) {
         Mage::getSingleton('core/session', array('name' => 'adminhtml'));
         if (!is_null(Mage::registry("_singleton/admin/session"))) {
             if (Mage::getSingleton('admin/session')->isLoggedIn()) {
                 /*Is admin*/
                 return;
             }
         }
         $request = $observer->getEvent()->getFront()->getRequest();
         if (!Mage::app()->isInstalled()) {
             return;
         }
         $identifier = trim($request->getPathInfo(), '/');
         $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
         Mage::dispatchEvent('productlist_controller_router_match_before', array('router' => $this, 'condition' => $condition));
         $identifier = $condition->getIdentifier();
         $identifier = trim($identifier, "/");
         if ($condition->getRedirectUrl()) {
             Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
             $request->setDispatched(true);
             return true;
         }
         if (!$condition->getContinue()) {
             return false;
         }
         if ($identifier) {
             $identifier = str_replace('.html', '', $identifier);
             $idarray = explode('/', $identifier);
             $rule = Mage::getModel('productlist/rule')->getCollection()->addFieldToFilter('identifier', $identifier)->addStatusFilter()->addDateFilter()->addStoreFilter()->addCustomerGroupFilter()->getFirstItem();
             $data = $rule->getData();
             $show = Mage::getStoreConfig('productlist/general_setting/show');
             if (empty($data) || !$show) {
                 return false;
             }
             $request->setModuleName('productlist')->setControllerName('rule')->setActionName('view')->setParam('id', $rule->getId());
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier . '.html');
             return true;
         }
         return false;
     }
 }
Exemplo n.º 11
0
 public function match(Zend_Controller_Request_Http $request)
 {
     $identifier = trim($request->getPathInfo(), '/');
     $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
     $identifier = $condition->getIdentifier();
     if ($condition->getRedirectUrl()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
         $request->setDispatched(true);
         return true;
     }
     if (!$condition->getContinue()) {
         return false;
     }
     $page = Mage::getModel('searchlandingpage/page')->checkIdentifier($identifier);
     if (!$page) {
         return false;
     }
     $request->setModuleName('searchlandingpage')->setControllerName('page')->setActionName('view')->setParam('q', $page->getQueryText())->setParam('id', $page->getId());
     $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
     return true;
 }
Exemplo n.º 12
0
 /**
  *
  */
 public function initControllerRouters($observer)
 {
     $request = $observer->getEvent()->getFront()->getRequest();
     if (!Mage::app()->isInstalled()) {
         return;
     }
     $identifier = trim($request->getPathInfo(), '/');
     $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
     Mage::dispatchEvent('deals_controller_router_match_before', array('router' => $this, 'condition' => $condition));
     $identifier = $condition->getIdentifier();
     $identifier = trim($identifier, "/");
     if ($condition->getRedirectUrl()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
         $request->setDispatched(true);
         return true;
     }
     if (!$condition->getContinue()) {
         return false;
     }
     $route = trim(Mage::getStoreConfig('ves_deals/deals_setting/route'));
     if ($identifier) {
         if (preg_match("#^" . $route . "(\\.html)?\$#", $identifier, $match)) {
             $request->setModuleName('vesdeals')->setControllerName('index')->setActionName('index');
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
             return true;
         } elseif (str_replace('/rss', '', str_replace($route, '', $identifier)) == '') {
             $request->setModuleName('vesdeals')->setControllerName('rss')->setActionName('index');
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
             return true;
         } elseif (preg_match("#" . $route . "/filter/(\\w+)\\.?#", $identifier, $match)) {
             if (count($match) <= 1) {
                 return false;
             }
             $request->setModuleName('vesdeals')->setControllerName('index')->setActionName('index')->setParam("filter", $match[1]);
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
             return true;
         }
     }
     return false;
 }
Exemplo n.º 13
0
 public function render(Varien_Object $row)
 {
     $out = '';
     $skipAllStoresLabel = $this->_getShowAllStoresLabelFlag();
     $skipEmptyStoresLabel = $this->_getShowEmptyStoresLabelFlag();
     $origStores = $row->getData($this->getColumn()->getIndex());
     if (is_null($origStores) && $row->getStoreName()) {
         $scopes = array();
         foreach (explode("\n", $row->getStoreName()) as $k => $label) {
             $scopes[] = str_repeat('&nbsp;', $k * 3) . $label;
         }
         $out .= implode('<br/>', $scopes) . $this->__(' [deleted]');
         return $out;
     }
     if (empty($origStores) && !$skipEmptyStoresLabel) {
         return '';
     }
     if (!is_array($origStores)) {
         $origStores = array($origStores);
     }
     if (empty($origStores)) {
         return '';
     } elseif (in_array(0, $origStores) && count($origStores) == 1 && !$skipAllStoresLabel) {
         return Mage::helper('adminhtml')->__('All Store Views');
     }
     $data = $this->_getStoreModel()->getStoresStructure(false, $origStores);
     foreach ($data as $website) {
         $out .= $website['label'] . '<br/>';
         foreach ($website['children'] as $group) {
             $out .= str_repeat('&nbsp;', 3) . $group['label'] . '<br/>';
             foreach ($group['children'] as $store) {
                 $href = Mage::app()->getStore($store['value'])->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK) . $row->getIdentifier();
                 $out .= str_repeat('&nbsp;', 6) . '<a target="blank" href="' . $href . '">' . $store['label'] . '</a><br/>';
             }
         }
     }
     return $out;
 }
Exemplo n.º 14
0
 /**
  * Validate and Match News and modify request
  *
  * @param Zend_Controller_Request_Http $request
  * @return bool
  */
 public function match(Zend_Controller_Request_Http $request)
 {
     $identifier = trim($request->getPathInfo(), '/');
     $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
     Mage::dispatchEvent('magna_news_controller_router_match_before', array('router' => $this, 'condition' => $condition));
     $identifier = $condition->getIdentifier();
     if ($condition->getRedirectUrl()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
         $request->setDispatched(true);
         return true;
     }
     if (!$condition->getContinue()) {
         return false;
     }
     $news = Mage::getModel('magna_news/news');
     $newsId = $news->checkIdentifier($identifier, Mage::app()->getStore()->getId());
     if (!$newsId) {
         return false;
     }
     $request->setModuleName('magna_news')->setControllerName('view')->setActionName('show')->setParam('news_id', $newsId);
     $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
     return true;
 }
Exemplo n.º 15
0
 public function render(Varien_Object $row)
 {
     $urlModel = Mage::getModel('core/url')->setStore($row->getData('_first_store_id'));
     $href = $urlModel->getUrl($row->getIdentifier(), array('_current' => false, '_query' => '___store=' . $row->getStoreCode()));
     return '<a href="' . $href . '" target="_blank">' . $this->__('Preview') . '</a>';
 }
Exemplo n.º 16
0
 /**
  * Check whether redirect exists.
  *
  * @param Varien_Object $redirect
  * @return bool
  */
 public function exists(Varien_Object $redirect)
 {
     $select = $this->_getReadAdapter()->select()->from($this->getMainTable(), array(new Zend_Db_Expr('COUNT(*)')))->where('identifier = ?', $redirect->getIdentifier())->where('store_id = ?', $redirect->getStoreId());
     return (bool) $this->_getReadAdapter()->fetchOne($select);
 }
Exemplo n.º 17
0
 /**
  *
  *
  * @return bool
  */
 protected function _cmsRouterMatch()
 {
     $router = Mage::app()->getFrontController()->getRouter('cms');
     $identifier = trim($this->getPathInfo(), '/');
     $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
     Mage::dispatchEvent('cms_controller_router_match_before', array('router' => $router, 'condition' => $condition));
     $identifier = $condition->getIdentifier();
     if ($condition->getRedirectUrl()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
         $this->setDispatched(true);
         return true;
     }
     if (!$condition->getContinue()) {
         return false;
     }
     $page = Mage::getModel('cms/page');
     $pageId = $page->checkIdentifier($identifier, Mage::app()->getStore()->getId());
     if (!$pageId) {
         return false;
     }
     $this->setModuleName('cms')->setControllerName('page')->setActionName('view')->setParam('page_id', $pageId);
     $this->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
     return true;
 }