Example #1
0
 /**
  * Get current instance of dispatcher (singleton)
  *
  * @return Dispatcher
  */
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new Dispatcher();
     }
     return self::$instance;
 }
 protected function setRequestUri()
 {
     parent::setRequestUri();
     if (Module::isInstalled('yamodule') && strpos($this->request_uri, 'module/yamodule/')) {
         $this->request_uri = iconv('windows-1251', 'UTF-8', $this->request_uri);
     }
 }
Example #3
0
 public function __construct()
 {
     /**
      * @var array List of default routes
      */
     $this->default_routes = array('supplier_rule' => array('controller' => 'supplier', 'rule' => 'supplier/{rewrite}', 'keywords' => array('id' => array('regexp' => '[0-9]+'), 'rewrite' => array('regexp' => '[_a-zA-Z0-9\\pL\\pS-]*', 'param' => 'supplier_rewrite'), 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9\\pL-]*'), 'meta_title' => array('regexp' => '[_a-zA-Z0-9\\pL-]*'))), 'manufacturer_rule' => array('controller' => 'manufacturer', 'rule' => 'manufacturer/{rewrite}', 'keywords' => array('id' => array('regexp' => '[0-9]+'), 'rewrite' => array('regexp' => '[_a-zA-Z0-9\\pL\\pS-]*', 'param' => 'manufacturer_rewrite'), 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9\\pL-]*'), 'meta_title' => array('regexp' => '[_a-zA-Z0-9\\pL-]*'))), 'cms_rule' => array('controller' => 'cms', 'rule' => 'info/{rewrite}', 'keywords' => array('id' => array('regexp' => '[0-9]+'), 'rewrite' => array('regexp' => '[_a-zA-Z0-9\\pL\\pS-]*', 'param' => 'cms_rewrite'), 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9\\pL-]*'), 'meta_title' => array('regexp' => '[_a-zA-Z0-9\\pL-]*'))), 'cms_category_rule' => array('controller' => 'cms', 'rule' => 'info/{rewrite}/', 'keywords' => array('id' => array('regexp' => '[0-9]+'), 'rewrite' => array('regexp' => '[_a-zA-Z0-9\\pL\\pS-]*', 'param' => 'cms_category_rewrite'), 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9\\pL-]*'), 'meta_title' => array('regexp' => '[_a-zA-Z0-9\\pL-]*'))), 'module' => array('controller' => null, 'rule' => 'module/{module}{/:controller}', 'keywords' => array('module' => array('regexp' => '[_a-zA-Z0-9-]+', 'param' => 'module'), 'controller' => array('regexp' => '[_a-zA-Z0-9-]+', 'param' => 'controller')), 'params' => array('fc' => 'module')), 'product_rule' => array('controller' => 'product', 'rule' => '{category:/}{rewrite}', 'keywords' => array('id' => array('regexp' => '[0-9]+'), 'rewrite' => array('regexp' => '[_a-zA-Z0-9\\pL\\pS-]*', 'param' => 'product_rewrite'), 'ean13' => array('regexp' => '[0-9\\pL]*'), 'category' => array('regexp' => '[_a-zA-Z0-9\\pL-]*'), 'categories' => array('regexp' => '[/_a-zA-Z0-9\\pL-]*'), 'reference' => array('regexp' => '[_a-zA-Z0-9\\pL-]*'), 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9\\pL-]*'), 'meta_title' => array('regexp' => '[_a-zA-Z0-9\\pL-]*'), 'manufacturer' => array('regexp' => '[_a-zA-Z0-9\\pL-]*'), 'supplier' => array('regexp' => '[_a-zA-Z0-9\\pL-]*'), 'price' => array('regexp' => '[0-9\\.,]*'), 'tags' => array('regexp' => '[a-zA-Z0-9\\pL-]*'))), 'layered_rule' => array('controller' => 'category', 'rule' => '{rewrite}/f{/:selected_filters}', 'keywords' => array('id' => array('regexp' => '[0-9]+'), 'selected_filters' => array('regexp' => '.*', 'param' => 'selected_filters'), 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\\pL]*', 'param' => 'category_rewrite'), 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\\pL]*'), 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\\pL]*'))), 'category_rule' => array('controller' => 'category', 'rule' => '{rewrite}/', 'keywords' => array('id' => array('regexp' => '[0-9]+'), 'categories' => array('regexp' => '[/_a-zA-Z0-9\\pL-]*'), 'rewrite' => array('regexp' => '[_a-zA-Z0-9\\pL\\pS-]*', 'param' => 'category_rewrite'), 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9\\pL-]*'), 'meta_title' => array('regexp' => '[_a-zA-Z0-9\\pL-]*'))));
     parent::__construct();
 }
Example #4
0
 /**
  * Adapter to get Admin HTTP link.
  *
  * @param string $controller the controller name
  * @param bool $withToken
  * @param array[string] $extraParams
  * @return string
  */
 public function getAdminLink($controller, $withToken = true, $extraParams = array())
 {
     $id_lang = OldContext::getContext()->language->id;
     $params = $extraParams;
     if ($withToken) {
         $params['token'] = \ToolsCore::getAdminTokenLite($controller);
     }
     $link = new \LinkCore();
     return $link->getBaseLink() . basename(_PS_ADMIN_DIR_) . '/' . \DispatcherCore::getInstance()->createUrl($controller, $id_lang, $params, false);
 }
Example #5
0
 /**
  * Bootstrap Illuminate before PrestaShop dispatch (first function call in prestashop)
  */
 public function dispatch()
 {
     /*
     |--------------------------------------------------------------------------
     | Register The Auto Loader
     |--------------------------------------------------------------------------
     |
     | Composer provides a convenient, automatically generated class loader for
     | our application. We just need to utilize it! We'll simply require it
     | into the script here so that we don't have to worry about manual
     | loading any of our classes later on. It feels nice to relax.
     |
     */
     require _PS_MODULE_DIR_ . '/illuminato/src/bootstrap/autoload.php';
     // @todo Don't know why yet but this file isn't loaded with autoload...
     require_once _PS_MODULE_DIR_ . '/illuminato/src/Module.php';
     /*
     |--------------------------------------------------------------------------
     | Turn On The Lights
     |--------------------------------------------------------------------------
     |
     | We need to illuminate PHP development, so let us turn on the lights.
     | This bootstraps the framework and gets it ready for use, then it
     | will load up this application so that we can run it and send
     | the responses back to the browser and delight our users.
     |
     */
     $app = (require_once _PS_MODULE_DIR_ . '/illuminato/src/bootstrap/app.php');
     /*
     |--------------------------------------------------------------------------
     | Run The Application
     |--------------------------------------------------------------------------
     |
     | Once we have the application, we can handle the incoming request
     | through the kernel, and send the associated response back to
     | the client's browser allowing them to enjoy the creative
     | and wonderful application we have prepared for them.
     |
     */
     $kernel = $app->make('Illuminate\\Contracts\\Http\\Kernel');
     $response = $kernel->handle($request = Illuminate\Http\Request::capture());
     /*
     | Set locale from Prestashop context
     */
     $context = \Context::getContext();
     $app->setLocale($context->language->iso_code);
     /*
     
     $response->send();
     
     $kernel->terminate($request, $response);
     */
     parent::dispatch();
 }
Example #6
0
 public function createUrl($route_id, $id_lang = null, array $params = array(), $force_routes = false, $anchor = '', $id_shop = null)
 {
     global $link;
     if ($route_id == "agilesellers") {
         return $link->getAgileSellersLink(Tools::getValue('filter'), $id_lang, Tools::getValue('loclevel'), Tools::getValue('parentid'));
     }
     if ($route_id == "sellerlocation") {
         return $link->getSellerLocationLink(Tools::getValue('$id_location'), Tools::getValue('location_level'), NULL, $id_lang);
     }
     if ($route_id == "sellercountry") {
         return $link->getSellerCountryLink(Tools::getValue('id_seller_country'), NULL, $id_lang);
     }
     return parent::createUrl($route_id, $id_lang, $params, $force_routes, $anchor);
 }
 public function createUrl($route_id, $id_lang = null, array $params = array(), $force_routes = false, $anchor = '', $id_shop = null)
 {
     require_once dirname(__FILE__) . '../../../modules/designerpreview/defines.inc.php';
     $params = addThemlerParam($params, $route_id);
     return parent::createUrl($route_id, $id_lang, $params, $force_routes, $anchor, $id_shop);
 }
 /**
  *
  * @param string $route_id Name of the route (need to be uniq, a second route with same name will override the first)
  * @param string $rule Url rule
  * @param string $controller Controller to call if request uri match the rule
  * @param int $id_lang
  * @param int $id_shop
  */
 public function addRoute($route_id, $rule, $controller, $id_lang = null, array $keywords = array(), array $params = array(), $id_shop = null)
 {
     parent::addRoute($route_id, $rule, $controller, $id_lang, $keywords, $params, $id_shop);
     if ($id_lang === null) {
         $id_lang = (int) Context::getContext()->language->id;
     }
     if ($id_shop === null) {
         $id_shop = (int) Context::getContext()->shop->id;
     }
     // On récupère l'ancienne règle :
     $oldRule = $this->getOldRule($route_id, $rule);
     $oldRegexp = preg_quote($oldRule, '#');
     if ($keywords) {
         $transform_keywords = array();
         preg_match_all('#\\\\{(([^{}]*)\\\\:)?(' . implode('|', array_keys($keywords)) . ')(\\\\:([^{}]*))?\\\\}#', $oldRegexp, $m);
         for ($i = 0, $total = count($m[0]); $i < $total; $i++) {
             $prepend = $m[2][$i];
             $keyword = $m[3][$i];
             $append = $m[5][$i];
             $transform_keywords[$keyword] = array('required' => isset($keywords[$keyword]['param']), 'prepend' => stripslashes($prepend), 'append' => stripslashes($append));
             $prepend_regexp = $append_regexp = '';
             if ($prepend || $append) {
                 $prepend_regexp = '(' . preg_quote($prepend);
                 $append_regexp = preg_quote($append) . ')?';
             }
             if (isset($keywords[$keyword]['param'])) {
                 $oldRegexp = str_replace($m[0][$i], $prepend_regexp . '(?P<' . $keywords[$keyword]['param'] . '>' . $keywords[$keyword]['regexp'] . ')' . $append_regexp, $oldRegexp);
             } else {
                 $oldRegexp = str_replace($m[0][$i], $prepend_regexp . '(' . $keywords[$keyword]['regexp'] . ')' . $append_regexp, $oldRegexp);
             }
         }
     }
     $oldRegexp = '#^/' . $oldRegexp . '(\\?.*)?$#u';
     $this->routes[$id_shop][$id_lang][$route_id]['oldRegexp'] = $oldRegexp;
 }