From 3c3c2d0818d62421e2454d84c040092abb3e16af Mon Sep 17 00:00:00 2001 From: Lebioda Date: Fri, 25 Oct 2013 23:34:39 +0200 Subject: [PATCH 001/174] Update README.md --- README.md | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 4f38b77..1c314a2 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,20 @@ README ABOUT -------- -This PrestaShop 1.5 module/override allows removal of number ID's from all URLs. +This PrestaShop 1.5 module is based on [PrestaShop-modules-CleanURLs](https://github.com/Ha99y/PrestaShop-modules-CleanURLs) +Thanks to original version you can delete IDs from all friendly links. +This version gives additional possibility to use templates of links to achieve links like below: +* domain.com/product +* domain.com/parent_categories/category +* domain.com/category +* domain.com/manufacturer +* domain.com/supplier +* domain.com/cms + +Just use {rewrite} for: products, manufacturer, supplier, cms. For category you can use the same or {parent_categories:/}{rewrite}. + +**Important:** categories of CMS are currently not supported. You can use only main category. INSTALLATION -------- @@ -15,23 +27,11 @@ Install the module from the Backoffice (administration panel) In the modules tab, click on add a new module. Click on Browse to open the dialogue box letting you search your computer, select the file then validate the dialogue box. Finally click on Upload this module. - UNINSTALLATION -------- Go to modules -> Find and uninstall "CleanURL". -Open folder /override/classes/ --> Remove "Link.php" --> Remove "Dispatcher.php" - -Open folder /override/controllers/front/ --> Remove "CategoryController.php" --> Remove "CmsController.php" --> Remove "ManufacturerController.php" --> Remove "ProductController.php" --> Remove "SupplierController.php" - Open folder /cache/ -> Remove "class_index.php" @@ -39,4 +39,3 @@ Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL off -> Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL on -> Save If you got any other override modules, you should now go to you back office, uninstall them, and reinstall them again to work correctly. - From 26bb0bd87f6fd7bcc76da9b12584f6c9427d8808 Mon Sep 17 00:00:00 2001 From: Lebioda Date: Fri, 25 Oct 2013 23:47:16 +0200 Subject: [PATCH 002/174] Update README.md --- README.md | 43 ++----------------------------------------- 1 file changed, 2 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 1c314a2..781693a 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,2 @@ -README -====== - - -ABOUT --------- - -This PrestaShop 1.5 module is based on [PrestaShop-modules-CleanURLs](https://github.com/Ha99y/PrestaShop-modules-CleanURLs) - -Thanks to original version you can delete IDs from all friendly links. -This version gives additional possibility to use templates of links to achieve links like below: -* domain.com/product -* domain.com/parent_categories/category -* domain.com/category -* domain.com/manufacturer -* domain.com/supplier -* domain.com/cms - -Just use {rewrite} for: products, manufacturer, supplier, cms. For category you can use the same or {parent_categories:/}{rewrite}. - -**Important:** categories of CMS are currently not supported. You can use only main category. - -INSTALLATION --------- - -Install the module from the Backoffice (administration panel) - -In the modules tab, click on add a new module. Click on Browse to open the dialogue box letting you search your computer, select the file then validate the dialogue box. Finally click on Upload this module. - -UNINSTALLATION --------- - -Go to modules -> Find and uninstall "CleanURL". - -Open folder /cache/ --> Remove "class_index.php" - -Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL off -> Save -Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL on -> Save - -If you got any other override modules, you should now go to you back office, uninstall them, and reinstall them again to work correctly. +[ABOUT](http://lebioda.github.io/PrestaShop-modules-CleanURLs/) +=============================================================== From 28e809403fdb0f805caa2023db5f840022fe99b2 Mon Sep 17 00:00:00 2001 From: Lebioda Date: Mon, 28 Oct 2013 15:09:23 +0100 Subject: [PATCH 003/174] possibility to add any words before /{rewrite} --- cleanurls/override/classes/Dispatcher.php | 24 +++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/cleanurls/override/classes/Dispatcher.php b/cleanurls/override/classes/Dispatcher.php index 8dc83a4..77b6ca1 100644 --- a/cleanurls/override/classes/Dispatcher.php +++ b/cleanurls/override/classes/Dispatcher.php @@ -107,9 +107,13 @@ class Dispatcher extends DispatcherCore */ public static function isProductLink($short_link) { + // check if any keyword + $explode_product_link = explode("/", $short_link); + $count = count($explode_product_link); + $sql = 'SELECT `id_product` FROM `'._DB_PREFIX_.'product_lang` - WHERE `link_rewrite` = \''.$short_link.'\' AND `id_lang` = '. Context::getContext()->language->id; + WHERE `link_rewrite` = \''.$explode_product_link[$count-1].'\' AND `id_lang` = '. Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { @@ -153,10 +157,14 @@ public static function isCategoryLink($short_link) */ public static function isCmsLink($short_link) { + // check if any keyword + $explode_cms_link = explode("/", $short_link); + $count = count($explode_cms_link); + $sql = 'SELECT l.`id_cms` FROM `'._DB_PREFIX_.'cms_lang` l LEFT JOIN `'._DB_PREFIX_.'cms_shop` s ON (l.`id_cms` = s.`id_cms`) - WHERE l.`link_rewrite` = \''.$short_link.'\''; + WHERE l.`link_rewrite` = \''.$explode_cms_link[$count-1].'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { @@ -176,7 +184,11 @@ public static function isCmsLink($short_link) */ public static function isManufacturerLink($short_link) { - $name_manufacturer = str_replace('-', '%', $short_link); + // check if any keyword + $explode_manufacturer_link = explode("/", $short_link); + $count = count($explode_manufacturer_link); + + $name_manufacturer = str_replace('-', '%', $explode_manufacturer_link[$count-1]); $sql = 'SELECT m.`id_manufacturer` FROM `'._DB_PREFIX_.'manufacturer` m @@ -201,7 +213,11 @@ public static function isManufacturerLink($short_link) */ public static function isSupplierLink($short_link) { - $name_supplier = str_replace('-', '%', $short_link); + // check if any keyword + $explode_supplier_link = explode("/", $short_link); + $count = count($explode_supplier_link); + + $name_supplier = str_replace('-', '%', $explode_supplier_link[$count-1]); $sql = 'SELECT sp.`id_supplier` FROM `'._DB_PREFIX_.'supplier` sp From d3fd8f21c32e4e11f473f17872e422d3ca5d8f1d Mon Sep 17 00:00:00 2001 From: Lebioda Date: Mon, 28 Oct 2013 15:38:58 +0100 Subject: [PATCH 004/174] New version in config file --- cleanurls/config.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cleanurls/config.xml b/cleanurls/config.xml index 4e546bc..58849e0 100644 --- a/cleanurls/config.xml +++ b/cleanurls/config.xml @@ -1,9 +1,9 @@ cleanurls - - - + + + 1 From a8fe02a5c1456231188e25757721b0cf3b78a9e5 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 25 Nov 2013 12:10:52 +0100 Subject: [PATCH 005/174] Fixed getCategoryLink method: - passed missing $id_shop to the getLangLink and createUrl methods - remove only root and current category from the URL Tested on PrestaShop v1.5.6.1. Now working fine! --- cleanurls/config.xml | 6 +++--- cleanurls/override/classes/Link.php | 28 +++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/cleanurls/config.xml b/cleanurls/config.xml index 58849e0..168a88e 100644 --- a/cleanurls/config.xml +++ b/cleanurls/config.xml @@ -3,10 +3,10 @@ cleanurls - - + + 1 0 - \ No newline at end of file + diff --git a/cleanurls/override/classes/Link.php b/cleanurls/override/classes/Link.php index 830fd4b..78a6c79 100644 --- a/cleanurls/override/classes/Link.php +++ b/cleanurls/override/classes/Link.php @@ -1,6 +1,16 @@ language->id; - $url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang); + + $url = $this->getBaseLink($id_shop).$this->getLangLink($id_lang, null, $id_shop); if (!is_object($category)) $category = new Category($category, $id_lang); @@ -48,12 +59,19 @@ public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $sele //RETRIEVING ALL THE PARENT CATEGORIES $cats = array(); foreach ($category->getParentsCategories() as $cat) - if (!in_array($cat['id_category'], array(1, 2, $category->id)))//remove root, home and current category from the URL + { + $category_disable_rewrite[] = $category->id; + + // remove root and current category from the URL + if (!in_array($cat['id_category'], $category_disable_rewrite)) { $cats[] = $cat['link_rewrite']; //THE CATEGORIES ARE BEING ASSIGNED IN THE WRONG ORDER (?) - $params['parent_categories'] = implode('/', array_reverse($cats));//ADD THE URL SLASHES TO THE CATEGORIES IN REVERSE ORDER + } + } + + $params['parent_categories'] = implode('/', array_reverse($cats)); //ADD THE URL SLASHES TO THE CATEGORIES IN REVERSE ORDER } - return $url.Dispatcher::getInstance()->createUrl($rule, $id_lang, $params, $this->allow); + return $url.Dispatcher::getInstance()->createUrl($rule, $id_lang, $params, $this->allow, '', $id_shop); } From 0559ef3a6b8e955c4b5565d09092454e0daf1c6c Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 18 Feb 2014 01:39:02 +0100 Subject: [PATCH 006/174] Fixed canonicalRedirection() canonicalRedirection has to remove rewrite ids from _GET before redirect, as it does in the FrontController for ordinary id_* --- .../classes/controller/FrontController.php | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 cleanurls/override/classes/controller/FrontController.php diff --git a/cleanurls/override/classes/controller/FrontController.php b/cleanurls/override/classes/controller/FrontController.php new file mode 100644 index 0000000..897e5b4 --- /dev/null +++ b/cleanurls/override/classes/controller/FrontController.php @@ -0,0 +1,45 @@ + +* @copyright 2007-2013 PrestaShop SA +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +class FrontController extends FrontControllerCore +{ + public function __construct() + { + parent::__construct(); + } + + protected function canonicalRedirection($canonical_url = '') + { + $excluded_keys = array('product_rewrite', 'category_rewrite', 'manufacturer_rewrite', 'supplier_rewrite', + 'cms_rewrite', 'cms_category_rewrite'); + + $unfiltered_GET = $_GET; + $_GET = array_diff_key($_GET, array_flip($excluded_keys)); + parent::canonicalRedirection($canonical_url); + $_GET = $unfiltered_GET; + } +} + From 1975ad2fc84da4d5b29f3597ea57d390741a5881 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 18 Feb 2014 13:54:50 +0100 Subject: [PATCH 007/174] Merge duplicate-URL-check-fix into master --- cleanurls/cleanurls.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cleanurls/cleanurls.php b/cleanurls/cleanurls.php index 96df801..edd5dbd 100644 --- a/cleanurls/cleanurls.php +++ b/cleanurls/cleanurls.php @@ -56,7 +56,7 @@ public function getContent() $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); } - if ($results = (int)Db::getInstance()->ExecuteS($sql)) + if ($results = Db::getInstance()->ExecuteS($sql)) { $output .= 'You need to fix duplicate URL entries
'; foreach ($results AS $row) From 22153e5817f5a0756172012dc98d66bb46407b2c Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 22 Apr 2014 23:01:41 +0200 Subject: [PATCH 008/174] Update config.xml --- cleanurls/config.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cleanurls/config.xml b/cleanurls/config.xml index 168a88e..b4ef123 100644 --- a/cleanurls/config.xml +++ b/cleanurls/config.xml @@ -3,8 +3,8 @@ cleanurls - - + + 1 0 From 5bbe43932c86b3dc2d4e378acf84d9b72e23fa10 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 22 Apr 2014 23:02:56 +0200 Subject: [PATCH 009/174] Update config.xml From 625ad7dfbfd82ebd798fb68e241b291227a969ca Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 22 Apr 2014 23:05:01 +0200 Subject: [PATCH 010/174] Update Link.php --- cleanurls/override/classes/Link.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cleanurls/override/classes/Link.php b/cleanurls/override/classes/Link.php index 78a6c79..9ed5732 100644 --- a/cleanurls/override/classes/Link.php +++ b/cleanurls/override/classes/Link.php @@ -20,7 +20,7 @@ public function __construct($protocol_link = null, $protocol_content = null) * @param string $selected_filters Url parameter to autocheck filters of the module blocklayered * @return string */ - //MODIFIED BY LAPY90 + ZiZuu + //MODIFIED BY LAPY90 public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $selected_filters = NULL, $id_shop = NULL) { From 96c7d405d87f1f2d2cd1b0d7f7ffd382da5fb354 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 29 Apr 2014 16:24:20 +0200 Subject: [PATCH 011/174] Link.php: Fix category_disable_rewrite assignation BIG Fixed: Configuration::get('PS_ROOT_CATEGORY') has to be used *after* parent constructor has been invoked --- cleanurls/override/classes/Link.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cleanurls/override/classes/Link.php b/cleanurls/override/classes/Link.php index 9ed5732..45f1ae5 100644 --- a/cleanurls/override/classes/Link.php +++ b/cleanurls/override/classes/Link.php @@ -5,10 +5,10 @@ class Link extends LinkCore public function __construct($protocol_link = null, $protocol_content = null) { + parent::__construct($protocol_link, $protocol_content); + // Disable only root category self::$category_disable_rewrite = array(Configuration::get('PS_ROOT_CATEGORY')); - - parent::__construct($protocol_link, $protocol_content); } /** From db6e2a0a6ce5d02d20955469b7fa790a6a8c48c5 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 29 Apr 2014 17:20:44 +0200 Subject: [PATCH 012/174] BUG FIXED Fixed wrong PHP syntax (use of self:: in the constructor instead of Link::) causing "root" node not to be added to the excluded categories array ... Static variables work differently :) --- cleanurls/override/classes/Link.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cleanurls/override/classes/Link.php b/cleanurls/override/classes/Link.php index 45f1ae5..1add56d 100644 --- a/cleanurls/override/classes/Link.php +++ b/cleanurls/override/classes/Link.php @@ -1,14 +1,12 @@ getParentsCategories() as $cat) { - $category_disable_rewrite[] = $category->id; + self::$category_disable_rewrite[] = $category->id; // remove root and current category from the URL - if (!in_array($cat['id_category'], $category_disable_rewrite)) { + if (!in_array($cat['id_category'], self::$category_disable_rewrite)) { $cats[] = $cat['link_rewrite']; //THE CATEGORIES ARE BEING ASSIGNED IN THE WRONG ORDER (?) } } From e0ec0adb01c6cd7162ad475d156075f50a29d480 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 29 Apr 2014 17:56:14 +0200 Subject: [PATCH 013/174] Update Link.php Better implementation. Do exactly what we want, not what is supposed to give the same result --- cleanurls/override/classes/Link.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cleanurls/override/classes/Link.php b/cleanurls/override/classes/Link.php index 1add56d..d84b8e8 100644 --- a/cleanurls/override/classes/Link.php +++ b/cleanurls/override/classes/Link.php @@ -3,10 +3,10 @@ class Link extends LinkCore { public function __construct($protocol_link = null, $protocol_content = null) { - // Disable only root category - Link::$category_disable_rewrite = array(Configuration::get('PS_ROOT_CATEGORY')); - parent::__construct($protocol_link, $protocol_content); + + // Re-add Home category + Link::$category_disable_rewrite = array_diff(Link::$category_disable_rewrite, array(Configuration::get('PS_HOME_CATEGORY'))); } /** From 2987e3d87b9e0f3c7b890e465be13f0fa086838e Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 19 Sep 2014 12:11:35 +0200 Subject: [PATCH 014/174] Restore hide Home category until a conf switch --- cleanurls/override/classes/Link.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cleanurls/override/classes/Link.php b/cleanurls/override/classes/Link.php index d84b8e8..676ad2b 100644 --- a/cleanurls/override/classes/Link.php +++ b/cleanurls/override/classes/Link.php @@ -5,8 +5,10 @@ public function __construct($protocol_link = null, $protocol_content = null) { parent::__construct($protocol_link, $protocol_content); + /* TODO add a configuration switch to hide or show the Home category // Re-add Home category Link::$category_disable_rewrite = array_diff(Link::$category_disable_rewrite, array(Configuration::get('PS_HOME_CATEGORY'))); + */ } /** @@ -18,7 +20,6 @@ public function __construct($protocol_link = null, $protocol_content = null) * @param string $selected_filters Url parameter to autocheck filters of the module blocklayered * @return string */ - //MODIFIED BY LAPY90 public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $selected_filters = NULL, $id_shop = NULL) { From a341331377dc51609dfe8c3e3b768e59792d6a1f Mon Sep 17 00:00:00 2001 From: Wayann Date: Sun, 28 Dec 2014 18:08:27 +0100 Subject: [PATCH 015/174] added smartblog url rewrite support hack to make smartblog category path work. Remember to deactivate html in the smartblog module configuration --- cleanurls/override/classes/Dispatcher.php | 24 ++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/cleanurls/override/classes/Dispatcher.php b/cleanurls/override/classes/Dispatcher.php index 77b6ca1..01fd9e2 100644 --- a/cleanurls/override/classes/Dispatcher.php +++ b/cleanurls/override/classes/Dispatcher.php @@ -15,6 +15,15 @@ class Dispatcher extends DispatcherCore 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), ), ), + 'smartblog_rule' => array( + 'controller' => 'category', + 'rule' => 'blog/', + 'keywords' => array(), + 'params' => array( + 'fc' => 'module', + 'module' => 'smartblog', + ), + ), 'manufacturer_rule' => array( 'controller' => 'manufacturer', 'rule' => 'manufacturer/{rewrite}/', @@ -337,6 +346,19 @@ public function getController($id_shop = null) $req_url = explode("?", $req_url); // remove all after '?' $short_link = $req_url[0]; + // hack to make smartblog category path work. Remember to deactivate html in the smartblog module configuration + if (null !== Configuration::get('smartmainblogurl')) { + $blog_url = Configuration::get('smartmainblogurl'); + } + else { + // no smart blog we assume a generic blog path + $blog_url = 'blog/' + } + + if ($req_url[0] == $blog_url) { + $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['smartblog_rule']; + } + // $firephp->log($short_link, 'Short Link'); if(!Dispatcher::isProductLink($short_link)) @@ -400,4 +422,4 @@ public function getController($id_shop = null) $_GET['controller'] = $this->controller; return $this->controller; } -} \ No newline at end of file +} From 9ff7df783a776ed1c58bc0c8f2d1549a7cfb99f0 Mon Sep 17 00:00:00 2001 From: Wayann Date: Sun, 28 Dec 2014 18:26:30 +0100 Subject: [PATCH 016/174] Update README.md works on prestashop 1.6.0.9 --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 781693a..41d085b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ [ABOUT](http://lebioda.github.io/PrestaShop-modules-CleanURLs/) =============================================================== +it works on my 1.6.0.9 +don't ask me how and why, hack away, +btw I added support for smartblog url rewrite, so now both module play nicely along, or at least for my needs... From c3e1e9c1b38e956c46386e8162d466aeadf800ef Mon Sep 17 00:00:00 2001 From: Wayann Date: Sun, 28 Dec 2014 19:47:06 +0100 Subject: [PATCH 017/174] Update Dispatcher.php argh that semicolon... --- cleanurls/override/classes/Dispatcher.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cleanurls/override/classes/Dispatcher.php b/cleanurls/override/classes/Dispatcher.php index 01fd9e2..13d5f1f 100644 --- a/cleanurls/override/classes/Dispatcher.php +++ b/cleanurls/override/classes/Dispatcher.php @@ -352,7 +352,7 @@ public function getController($id_shop = null) } else { // no smart blog we assume a generic blog path - $blog_url = 'blog/' + $blog_url = 'blog/'; } if ($req_url[0] == $blog_url) { From a7298d75476a67e4d1c174e728d21244da32956e Mon Sep 17 00:00:00 2001 From: Wayann Date: Sun, 28 Dec 2014 20:23:57 +0100 Subject: [PATCH 018/174] Update Dispatcher.php --- cleanurls/override/classes/Dispatcher.php | 1 + 1 file changed, 1 insertion(+) diff --git a/cleanurls/override/classes/Dispatcher.php b/cleanurls/override/classes/Dispatcher.php index 13d5f1f..ed044f2 100644 --- a/cleanurls/override/classes/Dispatcher.php +++ b/cleanurls/override/classes/Dispatcher.php @@ -349,6 +349,7 @@ public function getController($id_shop = null) // hack to make smartblog category path work. Remember to deactivate html in the smartblog module configuration if (null !== Configuration::get('smartmainblogurl')) { $blog_url = Configuration::get('smartmainblogurl'); + $blog_url = $blog_url.'/'; } else { // no smart blog we assume a generic blog path From e1deb7333823bd4c041f14a6e2867c2bd5b702de Mon Sep 17 00:00:00 2001 From: Wayann Date: Fri, 23 Jan 2015 17:05:34 +0100 Subject: [PATCH 019/174] Update README.md --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index 41d085b..e7cf35c 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,35 @@ it works on my 1.6.0.9 don't ask me how and why, hack away, btw I added support for smartblog url rewrite, so now both module play nicely along, or at least for my needs... + +INSTALLATION +-------- + +Install the module from the Backoffice (administration panel) + +In the modules tab, click on add a new module. Click on Browse to open the dialogue box letting you search your computer, select the file then validate the dialogue box. Finally click on Upload this module. + + +UNINSTALLATION +-------- + +Go to modules -> Find and uninstall "CleanURL". + +Open folder /override/classes/ +-> Remove "Link.php" +-> Remove "Dispatcher.php" + +Open folder /override/controllers/front/ +-> Remove "CategoryController.php" +-> Remove "CmsController.php" +-> Remove "ManufacturerController.php" +-> Remove "ProductController.php" +-> Remove "SupplierController.php" + +Open folder /cache/ +-> Remove "class_index.php" + +Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL off -> Save +Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL on -> Save + +If you got any other override modules, you should now go to you back office, uninstall them, and reinstall them again to work correctly. From a1baa108be7cffc68b237e1a0900f88beabc08d1 Mon Sep 17 00:00:00 2001 From: Wayann Date: Fri, 23 Jan 2015 17:06:28 +0100 Subject: [PATCH 020/174] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e7cf35c..9e1cdef 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[ABOUT](http://lebioda.github.io/PrestaShop-modules-CleanURLs/) +[ABOUT](https://github.com/Ha99y/PrestaShop-modules-CleanURLs) =============================================================== it works on my 1.6.0.9 don't ask me how and why, hack away, From af66e33b26b9b0da7e0da6da88801eb7c0049fd7 Mon Sep 17 00:00:00 2001 From: Wayann Date: Fri, 23 Jan 2015 23:19:37 +0100 Subject: [PATCH 021/174] Update Link.php Meta keywords and title can be passed to the function as an array or string. This update ensures that the array is flatened to a single string prior to asking Tools:str2url to work with it. If Tools::str2url recieves an array it throws our lots of 'Warning' messages when PHP debugging is enabled in PS. merged from mrtwister76 https://github.com/mrtwister76/PrestaShop-modules-CleanURLs/commit/0b50f2afe6b216f13da552a0924e668658c1098c --- cleanurls/override/classes/Link.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cleanurls/override/classes/Link.php b/cleanurls/override/classes/Link.php index 676ad2b..1ab7e43 100644 --- a/cleanurls/override/classes/Link.php +++ b/cleanurls/override/classes/Link.php @@ -37,8 +37,22 @@ public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $sele $params = array(); $params['id'] = $category->id; $params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias; - $params['meta_keywords'] = Tools::str2url($category->meta_keywords); - $params['meta_title'] = Tools::str2url($category->meta_title); + + /* + /* keywords and metatitle can be supplied by PS as an array, if so make + /* sure we implode to a single string for further processing by str2url + */ + $tmpKwds = $category->meta_keywords; + if(is_array($tmpKwds)) { + $tmpKwds = implode(" ", $category->meta_keywords); + } + $params['meta_keywords'] = Tools::str2url($tmpKwds); + + $tmpTitle = $category->meta_title; + if(is_array($tmpTitle)) { + $tmpTitle = implode(" ", $category->meta_title); + } + $params['meta_title'] = Tools::str2url($tmpTitle); // Selected filters is used by the module blocklayered $selected_filters = is_null($selected_filters) ? '' : $selected_filters; From dc0d1bf96ab2e6628d79a10147c2b6e0dbf0582b Mon Sep 17 00:00:00 2001 From: Wayann Date: Fri, 23 Jan 2015 23:33:56 +0100 Subject: [PATCH 022/174] Update Link.php make getCategoryLink compatible with new prestashop 1.6.0.12 --- cleanurls/override/classes/Link.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cleanurls/override/classes/Link.php b/cleanurls/override/classes/Link.php index 1ab7e43..1aa5a76 100644 --- a/cleanurls/override/classes/Link.php +++ b/cleanurls/override/classes/Link.php @@ -20,7 +20,7 @@ public function __construct($protocol_link = null, $protocol_content = null) * @param string $selected_filters Url parameter to autocheck filters of the module blocklayered * @return string */ - public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $selected_filters = NULL, $id_shop = NULL) + public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $selected_filters = NULL, $id_shop = NULL, $relative_protocol = false) { $dispatcher = Dispatcher::getInstance(); From 0fa2e90b930c7aec79f8e9b83af4257c5347742d Mon Sep 17 00:00:00 2001 From: Wayann Date: Thu, 5 Feb 2015 12:08:05 +0100 Subject: [PATCH 023/174] Update README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 9e1cdef..8bed735 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,15 @@ Install the module from the Backoffice (administration panel) In the modules tab, click on add a new module. Click on Browse to open the dialogue box letting you search your computer, select the file then validate the dialogue box. Finally click on Upload this module. +Make sure your seo and url settings are as follows: + +This is MANDATORY +products: {categories:/}{rewrite} (no .html at the end OBLIGATORY) +categories: {parent_categories:/}{rewrite}/ +manufacturers: {rewrite} +CMS: "WHAT YOU WANT"/{rewrite} ex info/{rewrite} + +Keep in mind to clear browser cache / PS cache under smarty/cache and smarty/compile UNINSTALLATION -------- From 16d0c76ea11653be10951ca4097fa110088a0ab4 Mon Sep 17 00:00:00 2001 From: Wayann Date: Thu, 5 Feb 2015 12:10:19 +0100 Subject: [PATCH 024/174] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8bed735..23c98fd 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,10 @@ Install the module from the Backoffice (administration panel) In the modules tab, click on add a new module. Click on Browse to open the dialogue box letting you search your computer, select the file then validate the dialogue box. Finally click on Upload this module. -Make sure your seo and url settings are as follows: +###Make sure your seo and url settings are as follows: -This is MANDATORY -products: {categories:/}{rewrite} (no .html at the end OBLIGATORY) +This is __MANDATORY__ +products: {categories:/}{rewrite} (no .html at the end **OBLIGATORY**) categories: {parent_categories:/}{rewrite}/ manufacturers: {rewrite} CMS: "WHAT YOU WANT"/{rewrite} ex info/{rewrite} From 67c49cd94efddc6ff3a3ce8388a818f958f8ddb2 Mon Sep 17 00:00:00 2001 From: Wayann Date: Thu, 5 Feb 2015 12:11:32 +0100 Subject: [PATCH 025/174] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 23c98fd..90f853f 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,10 @@ In the modules tab, click on add a new module. Click on Browse to open the dialo ###Make sure your seo and url settings are as follows: This is __MANDATORY__ -products: {categories:/}{rewrite} (no .html at the end **OBLIGATORY**) -categories: {parent_categories:/}{rewrite}/ -manufacturers: {rewrite} -CMS: "WHAT YOU WANT"/{rewrite} ex info/{rewrite} +* products: {categories:/}{rewrite} (no .html at the end **OBLIGATORY**) +* categories: {parent_categories:/}{rewrite}/ +* manufacturers: {rewrite} +* CMS: "WHAT YOU WANT"/{rewrite} ex info/{rewrite} Keep in mind to clear browser cache / PS cache under smarty/cache and smarty/compile From f8f67cb2ec2bc3eb9aff81c596aefc54481a90f2 Mon Sep 17 00:00:00 2001 From: Wayann Date: Thu, 5 Feb 2015 12:12:30 +0100 Subject: [PATCH 026/174] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 90f853f..0b0a28c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [ABOUT](https://github.com/Ha99y/PrestaShop-modules-CleanURLs) =============================================================== -it works on my 1.6.0.9 +it works on my 1.6.0.9 sadly not working on 1.6.0.11 and onwards at the moment don't ask me how and why, hack away, btw I added support for smartblog url rewrite, so now both module play nicely along, or at least for my needs... From 63464f80c7a25e525b41e9c4708d3273627fdf3d Mon Sep 17 00:00:00 2001 From: Wayann Date: Thu, 5 Feb 2015 12:12:58 +0100 Subject: [PATCH 027/174] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0b0a28c..e144b6a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [ABOUT](https://github.com/Ha99y/PrestaShop-modules-CleanURLs) =============================================================== -it works on my 1.6.0.9 sadly not working on 1.6.0.11 and onwards at the moment -don't ask me how and why, hack away, +it works on my 1.6.0.9 sadly not working on 1.6.0.11 and onwards at the moment. + btw I added support for smartblog url rewrite, so now both module play nicely along, or at least for my needs... INSTALLATION From e330c7519ed2494e1aa43005a8c78056b4257433 Mon Sep 17 00:00:00 2001 From: Wayann Date: Thu, 5 Feb 2015 14:28:43 +0100 Subject: [PATCH 028/174] Update Dispatcher.php added addRoute function to the override on ps 1.6.0.11 var $regex has changed to '#^/'.$regexp.'$#u' changed back to '#^/'.$regexp.'(\?.*)?$#u' so now cleanurl cart, login, quickview and pagination, basically whenever there's a ? in the url works again --- cleanurls/override/classes/Dispatcher.php | 72 ++++++++++++++++++++--- 1 file changed, 63 insertions(+), 9 deletions(-) diff --git a/cleanurls/override/classes/Dispatcher.php b/cleanurls/override/classes/Dispatcher.php index ed044f2..1cea4b1 100644 --- a/cleanurls/override/classes/Dispatcher.php +++ b/cleanurls/override/classes/Dispatcher.php @@ -15,15 +15,6 @@ class Dispatcher extends DispatcherCore 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), ), ), - 'smartblog_rule' => array( - 'controller' => 'category', - 'rule' => 'blog/', - 'keywords' => array(), - 'params' => array( - 'fc' => 'module', - 'module' => 'smartblog', - ), - ), 'manufacturer_rule' => array( 'controller' => 'manufacturer', 'rule' => 'manufacturer/{rewrite}/', @@ -242,7 +233,70 @@ public static function isSupplierLink($short_link) return ($id_supplier > 0) ? true : false; } + + /** + * + * @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) + { + if (isset(Context::getContext()->language) && $id_lang === null) + $id_lang = (int)Context::getContext()->language->id; + + if (isset(Context::getContext()->shop) && $id_shop === null) + $id_shop = (int)Context::getContext()->shop->id; + $regexp = preg_quote($rule, '#'); + if ($keywords) + { + $transform_keywords = array(); + preg_match_all('#\\\{(([^{}]*)\\\:)?('.implode('|', array_keys($keywords)).')(\\\:([^{}]*))?\\\}#', $regexp, $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'])) + $regexp = str_replace($m[0][$i], $prepend_regexp.'(?P<'.$keywords[$keyword]['param'].'>'.$keywords[$keyword]['regexp'].')'.$append_regexp, $regexp); + else + $regexp = str_replace($m[0][$i], $prepend_regexp.'('.$keywords[$keyword]['regexp'].')'.$append_regexp, $regexp); + + } + $keywords = $transform_keywords; + } + + $regexp = '#^/'.$regexp.'(\?.*)?$#u'; + if (!isset($this->routes[$id_shop])) + $this->routes[$id_shop] = array(); + if (!isset($this->routes[$id_shop][$id_lang])) + $this->routes[$id_shop][$id_lang] = array(); + + $this->routes[$id_shop][$id_lang][$route_id] = array( + 'rule' => $rule, + 'regexp' => $regexp, + 'controller' => $controller, + 'keywords' => $keywords, + 'params' => $params, + ); + } + /** * Retrieve the controller from url or request uri if routes are activated * From 0270361f22e38bfed534ba160e50d363deb45018 Mon Sep 17 00:00:00 2001 From: Wayann Date: Thu, 5 Feb 2015 23:12:17 +0100 Subject: [PATCH 029/174] Update Dispatcher.php now it has the routes hack for smartblog --- cleanurls/override/classes/Dispatcher.php | 109 +++++++++++++++------- 1 file changed, 74 insertions(+), 35 deletions(-) diff --git a/cleanurls/override/classes/Dispatcher.php b/cleanurls/override/classes/Dispatcher.php index 1cea4b1..8769a34 100644 --- a/cleanurls/override/classes/Dispatcher.php +++ b/cleanurls/override/classes/Dispatcher.php @@ -7,47 +7,47 @@ class Dispatcher extends DispatcherCore public $default_routes = array( 'supplier_rule' => array( 'controller' => 'supplier', - 'rule' => 'supplier/{rewrite}/', + 'rule' => 'supplier/{rewrite}/.html', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'supplier_rewrite'), + '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}/', + 'rule' => 'manufacturer/{rewrite}/.html', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'manufacturer_rewrite'), + '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}', + 'rule' => 'page/{rewrite}.html', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'cms_rewrite'), + '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}/', + 'rule' => 'page/{rewrite}/.html', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'cms_category_rewrite'), + '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}', + 'rule' => 'module/{module}{/:controller}.html', 'keywords' => array( 'module' => array('regexp' => '[_a-zA-Z0-9_-]+', 'param' => 'module'), 'controller' => array('regexp' => '[_a-zA-Z0-9_-]+', 'param' => 'controller'), @@ -61,7 +61,7 @@ class Dispatcher extends DispatcherCore 'rule' => '{category:/}{rewrite}.html', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'product_rewrite'), + '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]*'), @@ -76,7 +76,7 @@ class Dispatcher extends DispatcherCore ), 'layered_rule' => array( 'controller' => 'category', - 'rule' => '{rewrite}/filter{selected_filters}', + 'rule' => '{rewrite}/filter/{selected_filters}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), /* Selected filters is used by the module blocklayered */ @@ -88,15 +88,46 @@ class Dispatcher extends DispatcherCore ), 'category_rule' => array( 'controller' => 'category', - 'rule' => '{parent_categories:/}{rewrite}/', + 'rule' => '{parent_categories:/}{rewrite}/.html', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'category_rewrite'), + '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_categories' => array('regexp' => '[/_a-zA-Z0-9-\pL]*'), ), ), + // added smartblog rules + 'smartblog_rule' => array( + 'controller' => 'category', + 'rule' => 'blog/', + 'keywords' => array(), + 'params' => array( + 'fc' => 'module', + 'module' => 'smartblog', + ), + ), + 'smartblog_category_rule' => array( + 'controller' => 'category', + 'rule' => 'blog/motif/{category}', + 'keywords' => array( + 'id_category' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'id_category'), + 'category' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'category'), + ), + 'params' => array( + 'fc' => 'module', + 'module' => 'smartblog', + ), + ), + 'category_page_rule' => array( + 'controller' => 'category', + 'rule' => '{parent_categories:/}{rewrite}/page/{p}', + 'keywords' => array( + 'rewrite' => array('regexp' => '[_a-zA-Z0-9\pL\pS-]*', 'param' => 'category_rewrite'), + 'p' => array('regexp' => '[0-9]+', 'param' => 'p'), + 'parent_categories' => array('regexp' => '[/_a-zA-Z0-9-\pL]*'), + ), + ), ); /** @@ -233,8 +264,9 @@ public static function isSupplierLink($short_link) return ($id_supplier > 0) ? true : false; } - - /** + + + /** * * @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 @@ -296,7 +328,7 @@ public function addRoute($route_id, $rule, $controller, $id_lang = null, array $ 'params' => $params, ); } - + /** * Retrieve the controller from url or request uri if routes are activated * @@ -312,11 +344,11 @@ public function getController($id_shop = null) return $this->controller; } - if ($id_shop === null) + if (isset(Context::getContext()->shop) && $id_shop === null) $id_shop = (int)Context::getContext()->shop->id; $controller = Tools::getValue('controller'); - + if (isset($controller) && is_string($controller) && preg_match('/^([0-9a-z_-]+)\?(.*)=(.*)$/Ui', $controller, $m)) { $controller = $m[1]; @@ -335,7 +367,6 @@ public function getController($id_shop = null) if (!$this->request_uri) return strtolower($this->controller_not_found); $controller = $this->controller_not_found; - // If the request_uri matches a static file, then there is no need to check the routes, we keep "controller_not_found" (a static file should not go through the dispatcher) if (!preg_match('/\.(gif|jpe?g|png|css|js|ico)$/i', $this->request_uri)) { @@ -392,6 +423,30 @@ public function getController($id_shop = null) } } } + + // hack to make smartblog category path work. Remember to deactivate html in the module configuration + if (null !== Configuration::get('smartmainblogurl')) { + $blog_url = Configuration::get('smartmainblogurl'); + $blog_url = '/'.$blog_url.'/'; + } + else { + // no smart blog we assume a generic blog path + $blog_url = '/blog/'; + } + + if ($this->request_uri === $blog_url) { + + $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['smartblog_rule']; + + } + + if (strpos($this->request_uri,'/motif/') !== false ) { + $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['smartblog_category_rule']; + } + + if (strpos($this->request_uri,'/page/') !== false ) { + $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['category_page_rule']; + } // if route is not found, we have to find rewrite link in database if(empty($findRoute)) @@ -400,20 +455,6 @@ public function getController($id_shop = null) $req_url = explode("?", $req_url); // remove all after '?' $short_link = $req_url[0]; - // hack to make smartblog category path work. Remember to deactivate html in the smartblog module configuration - if (null !== Configuration::get('smartmainblogurl')) { - $blog_url = Configuration::get('smartmainblogurl'); - $blog_url = $blog_url.'/'; - } - else { - // no smart blog we assume a generic blog path - $blog_url = 'blog/'; - } - - if ($req_url[0] == $blog_url) { - $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['smartblog_rule']; - } - // $firephp->log($short_link, 'Short Link'); if(!Dispatcher::isProductLink($short_link)) @@ -437,14 +478,12 @@ public function getController($id_shop = null) if(!empty($findRoute)) { // $firephp->log($findRoute['rule'], 'Find Route Template'); - if (preg_match($findRoute['regexp'], $this->request_uri, $m)) { // Route found ! Now fill $_GET with parameters of uri foreach ($m as $k => $v) if (!is_numeric($k)) $_GET[$k] = $v; - $controller = $findRoute['controller'] ? $findRoute['controller'] : $_GET['controller']; if (!empty($findRoute['params'])) foreach ($findRoute['params'] as $k => $v) From 900ee0a79efc01e68eee0efeaabf638a146ab6d1 Mon Sep 17 00:00:00 2001 From: Wayann Date: Sat, 7 Feb 2015 09:36:13 +0100 Subject: [PATCH 030/174] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e144b6a..134c1d8 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ In the modules tab, click on add a new module. Click on Browse to open the dialo ###Make sure your seo and url settings are as follows: This is __MANDATORY__ -* products: {categories:/}{rewrite} (no .html at the end **OBLIGATORY**) +* products: {category:/}{rewrite} (no .html at the end **OBLIGATORY**) * categories: {parent_categories:/}{rewrite}/ * manufacturers: {rewrite} * CMS: "WHAT YOU WANT"/{rewrite} ex info/{rewrite} From 4c5256e7fe0f37b9a18def0006633985bd614fa3 Mon Sep 17 00:00:00 2001 From: Wayann Date: Sat, 7 Feb 2015 09:37:23 +0100 Subject: [PATCH 031/174] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 134c1d8..c27cc7d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [ABOUT](https://github.com/Ha99y/PrestaShop-modules-CleanURLs) =============================================================== -it works on my 1.6.0.9 sadly not working on 1.6.0.11 and onwards at the moment. +it works on my 1.6.0.12. btw I added support for smartblog url rewrite, so now both module play nicely along, or at least for my needs... From a7e9b0137485b01ccc01dcedff19b442c138f9cd Mon Sep 17 00:00:00 2001 From: Wayann Date: Mon, 9 Feb 2015 02:51:28 +0100 Subject: [PATCH 032/174] Create Meta.php Fix so CMS pages works --- cleanurls/override/classes/Meta.php | 57 +++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 cleanurls/override/classes/Meta.php diff --git a/cleanurls/override/classes/Meta.php b/cleanurls/override/classes/Meta.php new file mode 100644 index 0000000..761afd6 --- /dev/null +++ b/cleanurls/override/classes/Meta.php @@ -0,0 +1,57 @@ +shop->id ? ' AND id_shop = '.(int)Context::getContext()->shop->id : ''; + + $sql = 'SELECT `meta_title`, `meta_description`, `meta_keywords` + FROM `'._DB_PREFIX_.'cms_lang` + WHERE id_lang = '.(int)$id_lang.' + AND id_cms = '.(int)$id_cms. + $multishop; + if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql)) + { + $row['meta_title'] = $row['meta_title'].' - '.Configuration::get('PS_SHOP_NAME'); + return Meta::completeMetaTags($row, $row['meta_title']); + } + + return Meta::getHomeMetas($id_lang, $page_name); + } + + /** + * Get CMS category meta tags + * + * @since 1.5.0 + * @param int $id_cms_category + * @param int $id_lang + * @param string $page_name + * @return array + */ + public static function getCmsCategoryMetas($id_cms_category, $id_lang, $page_name) + { + $multishop = (int)Context::getContext()->shop->id ? ' AND id_shop = '.(int)Context::getContext()->shop->id : ''; + + $sql = 'SELECT `meta_title`, `meta_description`, `meta_keywords` + FROM `'._DB_PREFIX_.'cms_category_lang` + WHERE id_lang = '.(int)$id_lang.' + AND id_cms_category = '.(int)$id_cms_category. + $multishop; + if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql)) + { + $row['meta_title'] = $row['meta_title'].' - '.Configuration::get('PS_SHOP_NAME'); + return Meta::completeMetaTags($row, $row['meta_title']); + } + + return Meta::getHomeMetas($id_lang, $page_name); + } +} From 4e84fe5eb963889fb309cad503274c99f84873ff Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 26 Feb 2015 20:14:36 +0100 Subject: [PATCH 033/174] Revert "merge changes by wayann" --- README.md | 46 +------ cleanurls/override/classes/Dispatcher.php | 154 +++------------------- cleanurls/override/classes/Link.php | 20 +-- cleanurls/override/classes/Meta.php | 57 -------- 4 files changed, 23 insertions(+), 254 deletions(-) delete mode 100644 cleanurls/override/classes/Meta.php diff --git a/README.md b/README.md index c27cc7d..781693a 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,2 @@ -[ABOUT](https://github.com/Ha99y/PrestaShop-modules-CleanURLs) +[ABOUT](http://lebioda.github.io/PrestaShop-modules-CleanURLs/) =============================================================== -it works on my 1.6.0.12. - -btw I added support for smartblog url rewrite, so now both module play nicely along, or at least for my needs... - -INSTALLATION --------- - -Install the module from the Backoffice (administration panel) - -In the modules tab, click on add a new module. Click on Browse to open the dialogue box letting you search your computer, select the file then validate the dialogue box. Finally click on Upload this module. - -###Make sure your seo and url settings are as follows: - -This is __MANDATORY__ -* products: {category:/}{rewrite} (no .html at the end **OBLIGATORY**) -* categories: {parent_categories:/}{rewrite}/ -* manufacturers: {rewrite} -* CMS: "WHAT YOU WANT"/{rewrite} ex info/{rewrite} - -Keep in mind to clear browser cache / PS cache under smarty/cache and smarty/compile - -UNINSTALLATION --------- - -Go to modules -> Find and uninstall "CleanURL". - -Open folder /override/classes/ --> Remove "Link.php" --> Remove "Dispatcher.php" - -Open folder /override/controllers/front/ --> Remove "CategoryController.php" --> Remove "CmsController.php" --> Remove "ManufacturerController.php" --> Remove "ProductController.php" --> Remove "SupplierController.php" - -Open folder /cache/ --> Remove "class_index.php" - -Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL off -> Save -Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL on -> Save - -If you got any other override modules, you should now go to you back office, uninstall them, and reinstall them again to work correctly. diff --git a/cleanurls/override/classes/Dispatcher.php b/cleanurls/override/classes/Dispatcher.php index 8769a34..77b6ca1 100644 --- a/cleanurls/override/classes/Dispatcher.php +++ b/cleanurls/override/classes/Dispatcher.php @@ -7,47 +7,47 @@ class Dispatcher extends DispatcherCore public $default_routes = array( 'supplier_rule' => array( 'controller' => 'supplier', - 'rule' => 'supplier/{rewrite}/.html', + 'rule' => 'supplier/{rewrite}/', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9\pL\pS-]*', 'param' => 'supplier_rewrite'), + 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', '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}/.html', + 'rule' => 'manufacturer/{rewrite}/', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9\pL\pS-]*', 'param' => 'manufacturer_rewrite'), + 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', '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' => 'page/{rewrite}.html', + 'rule' => 'info/{rewrite}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9\pL\pS-]*', 'param' => 'cms_rewrite'), + 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', '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' => 'page/{rewrite}/.html', + 'rule' => 'info/{rewrite}/', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9\pL\pS-]*', 'param' => 'cms_category_rewrite'), + 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', '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}.html', + 'rule' => 'module/{module}{/:controller}', 'keywords' => array( 'module' => array('regexp' => '[_a-zA-Z0-9_-]+', 'param' => 'module'), 'controller' => array('regexp' => '[_a-zA-Z0-9_-]+', 'param' => 'controller'), @@ -61,7 +61,7 @@ class Dispatcher extends DispatcherCore 'rule' => '{category:/}{rewrite}.html', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9\pL\pS-]*', 'param' => 'product_rewrite'), + 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', '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]*'), @@ -76,7 +76,7 @@ class Dispatcher extends DispatcherCore ), 'layered_rule' => array( 'controller' => 'category', - 'rule' => '{rewrite}/filter/{selected_filters}', + 'rule' => '{rewrite}/filter{selected_filters}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), /* Selected filters is used by the module blocklayered */ @@ -88,46 +88,15 @@ class Dispatcher extends DispatcherCore ), 'category_rule' => array( 'controller' => 'category', - 'rule' => '{parent_categories:/}{rewrite}/.html', + 'rule' => '{parent_categories:/}{rewrite}/', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9\pL\pS-]*', 'param' => 'category_rewrite'), + '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]*'), 'parent_categories' => array('regexp' => '[/_a-zA-Z0-9-\pL]*'), ), ), - // added smartblog rules - 'smartblog_rule' => array( - 'controller' => 'category', - 'rule' => 'blog/', - 'keywords' => array(), - 'params' => array( - 'fc' => 'module', - 'module' => 'smartblog', - ), - ), - 'smartblog_category_rule' => array( - 'controller' => 'category', - 'rule' => 'blog/motif/{category}', - 'keywords' => array( - 'id_category' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'id_category'), - 'category' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'category'), - ), - 'params' => array( - 'fc' => 'module', - 'module' => 'smartblog', - ), - ), - 'category_page_rule' => array( - 'controller' => 'category', - 'rule' => '{parent_categories:/}{rewrite}/page/{p}', - 'keywords' => array( - 'rewrite' => array('regexp' => '[_a-zA-Z0-9\pL\pS-]*', 'param' => 'category_rewrite'), - 'p' => array('regexp' => '[0-9]+', 'param' => 'p'), - 'parent_categories' => array('regexp' => '[/_a-zA-Z0-9-\pL]*'), - ), - ), ); /** @@ -265,70 +234,6 @@ public static function isSupplierLink($short_link) return ($id_supplier > 0) ? true : false; } - - /** - * - * @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) - { - if (isset(Context::getContext()->language) && $id_lang === null) - $id_lang = (int)Context::getContext()->language->id; - - if (isset(Context::getContext()->shop) && $id_shop === null) - $id_shop = (int)Context::getContext()->shop->id; - - $regexp = preg_quote($rule, '#'); - if ($keywords) - { - $transform_keywords = array(); - preg_match_all('#\\\{(([^{}]*)\\\:)?('.implode('|', array_keys($keywords)).')(\\\:([^{}]*))?\\\}#', $regexp, $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'])) - $regexp = str_replace($m[0][$i], $prepend_regexp.'(?P<'.$keywords[$keyword]['param'].'>'.$keywords[$keyword]['regexp'].')'.$append_regexp, $regexp); - else - $regexp = str_replace($m[0][$i], $prepend_regexp.'('.$keywords[$keyword]['regexp'].')'.$append_regexp, $regexp); - - } - $keywords = $transform_keywords; - } - - $regexp = '#^/'.$regexp.'(\?.*)?$#u'; - if (!isset($this->routes[$id_shop])) - $this->routes[$id_shop] = array(); - if (!isset($this->routes[$id_shop][$id_lang])) - $this->routes[$id_shop][$id_lang] = array(); - - $this->routes[$id_shop][$id_lang][$route_id] = array( - 'rule' => $rule, - 'regexp' => $regexp, - 'controller' => $controller, - 'keywords' => $keywords, - 'params' => $params, - ); - } - /** * Retrieve the controller from url or request uri if routes are activated * @@ -344,11 +249,11 @@ public function getController($id_shop = null) return $this->controller; } - if (isset(Context::getContext()->shop) && $id_shop === null) + if ($id_shop === null) $id_shop = (int)Context::getContext()->shop->id; $controller = Tools::getValue('controller'); - + if (isset($controller) && is_string($controller) && preg_match('/^([0-9a-z_-]+)\?(.*)=(.*)$/Ui', $controller, $m)) { $controller = $m[1]; @@ -367,6 +272,7 @@ public function getController($id_shop = null) if (!$this->request_uri) return strtolower($this->controller_not_found); $controller = $this->controller_not_found; + // If the request_uri matches a static file, then there is no need to check the routes, we keep "controller_not_found" (a static file should not go through the dispatcher) if (!preg_match('/\.(gif|jpe?g|png|css|js|ico)$/i', $this->request_uri)) { @@ -423,30 +329,6 @@ public function getController($id_shop = null) } } } - - // hack to make smartblog category path work. Remember to deactivate html in the module configuration - if (null !== Configuration::get('smartmainblogurl')) { - $blog_url = Configuration::get('smartmainblogurl'); - $blog_url = '/'.$blog_url.'/'; - } - else { - // no smart blog we assume a generic blog path - $blog_url = '/blog/'; - } - - if ($this->request_uri === $blog_url) { - - $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['smartblog_rule']; - - } - - if (strpos($this->request_uri,'/motif/') !== false ) { - $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['smartblog_category_rule']; - } - - if (strpos($this->request_uri,'/page/') !== false ) { - $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['category_page_rule']; - } // if route is not found, we have to find rewrite link in database if(empty($findRoute)) @@ -478,12 +360,14 @@ public function getController($id_shop = null) if(!empty($findRoute)) { // $firephp->log($findRoute['rule'], 'Find Route Template'); + if (preg_match($findRoute['regexp'], $this->request_uri, $m)) { // Route found ! Now fill $_GET with parameters of uri foreach ($m as $k => $v) if (!is_numeric($k)) $_GET[$k] = $v; + $controller = $findRoute['controller'] ? $findRoute['controller'] : $_GET['controller']; if (!empty($findRoute['params'])) foreach ($findRoute['params'] as $k => $v) @@ -516,4 +400,4 @@ public function getController($id_shop = null) $_GET['controller'] = $this->controller; return $this->controller; } -} +} \ No newline at end of file diff --git a/cleanurls/override/classes/Link.php b/cleanurls/override/classes/Link.php index 1aa5a76..676ad2b 100644 --- a/cleanurls/override/classes/Link.php +++ b/cleanurls/override/classes/Link.php @@ -20,7 +20,7 @@ public function __construct($protocol_link = null, $protocol_content = null) * @param string $selected_filters Url parameter to autocheck filters of the module blocklayered * @return string */ - public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $selected_filters = NULL, $id_shop = NULL, $relative_protocol = false) + public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $selected_filters = NULL, $id_shop = NULL) { $dispatcher = Dispatcher::getInstance(); @@ -37,22 +37,8 @@ public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $sele $params = array(); $params['id'] = $category->id; $params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias; - - /* - /* keywords and metatitle can be supplied by PS as an array, if so make - /* sure we implode to a single string for further processing by str2url - */ - $tmpKwds = $category->meta_keywords; - if(is_array($tmpKwds)) { - $tmpKwds = implode(" ", $category->meta_keywords); - } - $params['meta_keywords'] = Tools::str2url($tmpKwds); - - $tmpTitle = $category->meta_title; - if(is_array($tmpTitle)) { - $tmpTitle = implode(" ", $category->meta_title); - } - $params['meta_title'] = Tools::str2url($tmpTitle); + $params['meta_keywords'] = Tools::str2url($category->meta_keywords); + $params['meta_title'] = Tools::str2url($category->meta_title); // Selected filters is used by the module blocklayered $selected_filters = is_null($selected_filters) ? '' : $selected_filters; diff --git a/cleanurls/override/classes/Meta.php b/cleanurls/override/classes/Meta.php deleted file mode 100644 index 761afd6..0000000 --- a/cleanurls/override/classes/Meta.php +++ /dev/null @@ -1,57 +0,0 @@ -shop->id ? ' AND id_shop = '.(int)Context::getContext()->shop->id : ''; - - $sql = 'SELECT `meta_title`, `meta_description`, `meta_keywords` - FROM `'._DB_PREFIX_.'cms_lang` - WHERE id_lang = '.(int)$id_lang.' - AND id_cms = '.(int)$id_cms. - $multishop; - if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql)) - { - $row['meta_title'] = $row['meta_title'].' - '.Configuration::get('PS_SHOP_NAME'); - return Meta::completeMetaTags($row, $row['meta_title']); - } - - return Meta::getHomeMetas($id_lang, $page_name); - } - - /** - * Get CMS category meta tags - * - * @since 1.5.0 - * @param int $id_cms_category - * @param int $id_lang - * @param string $page_name - * @return array - */ - public static function getCmsCategoryMetas($id_cms_category, $id_lang, $page_name) - { - $multishop = (int)Context::getContext()->shop->id ? ' AND id_shop = '.(int)Context::getContext()->shop->id : ''; - - $sql = 'SELECT `meta_title`, `meta_description`, `meta_keywords` - FROM `'._DB_PREFIX_.'cms_category_lang` - WHERE id_lang = '.(int)$id_lang.' - AND id_cms_category = '.(int)$id_cms_category. - $multishop; - if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql)) - { - $row['meta_title'] = $row['meta_title'].' - '.Configuration::get('PS_SHOP_NAME'); - return Meta::completeMetaTags($row, $row['meta_title']); - } - - return Meta::getHomeMetas($id_lang, $page_name); - } -} From 5fbd0d5335f5aac6a565aa86a5d340a462746630 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 26 Feb 2015 20:18:58 +0100 Subject: [PATCH 034/174] Update config.xml v 0.6 --- cleanurls/config.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cleanurls/config.xml b/cleanurls/config.xml index b4ef123..6905103 100644 --- a/cleanurls/config.xml +++ b/cleanurls/config.xml @@ -2,9 +2,9 @@ cleanurls - - - + + + 1 0 From b3b78f5745db77ecdda1cd59582ebd03b39f87c4 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 26 Feb 2015 20:34:33 +0100 Subject: [PATCH 035/174] Update Dispatcher.php just some meaningless code cleanup --- cleanurls/override/classes/Dispatcher.php | 153 ++++++++++------------ 1 file changed, 71 insertions(+), 82 deletions(-) diff --git a/cleanurls/override/classes/Dispatcher.php b/cleanurls/override/classes/Dispatcher.php index 77b6ca1..e933792 100644 --- a/cleanurls/override/classes/Dispatcher.php +++ b/cleanurls/override/classes/Dispatcher.php @@ -6,95 +6,95 @@ class Dispatcher extends DispatcherCore */ public $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]*', 'param' => 'supplier_rewrite'), - 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), - 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), + 'controller' => 'supplier', + 'rule' => 'supplier/{rewrite}/', + 'keywords' => array( + 'id' => array('regexp' => '[0-9]+'), + 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', '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]*', 'param' => 'manufacturer_rewrite'), - 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), - 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), + 'rule' => 'manufacturer/{rewrite}/', + 'keywords' => array( + 'id' => array('regexp' => '[0-9]+'), + 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', '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]*', 'param' => 'cms_rewrite'), - 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), - 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), + 'rule' => 'info/{rewrite}', + 'keywords' => array( + 'id' => array('regexp' => '[0-9]+'), + 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', '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]*', 'param' => 'cms_category_rewrite'), - 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), - 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), + 'rule' => 'info/{rewrite}/', + 'keywords' => array( + 'id' => array('regexp' => '[0-9]+'), + 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', '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'), + '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( + 'params' => array( 'fc' => 'module', ), ), 'product_rule' => array( 'controller' => 'product', - 'rule' => '{category:/}{rewrite}.html', - 'keywords' => array( - 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', '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]*'), + 'rule' => '{category:/}{rewrite}.html', + 'keywords' => array( + 'id' => array('regexp' => '[0-9]+'), + 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', '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}/filter{selected_filters}', - 'keywords' => array( - 'id' => array('regexp' => '[0-9]+'), + 'rule' => '{rewrite}/filter{selected_filters}', + 'keywords' => array( + 'id' => array('regexp' => '[0-9]+'), /* Selected filters is used by the module blocklayered */ - '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]*'), + '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' => '{parent_categories:/}{rewrite}/', - 'keywords' => array( - 'id' => array('regexp' => '[0-9]+'), - '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]*'), - 'parent_categories' => array('regexp' => '[/_a-zA-Z0-9-\pL]*'), + 'rule' => '{parent_categories:/}{rewrite}/', + 'keywords' => array( + 'id' => array('regexp' => '[0-9]+'), + '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]*'), + 'parent_categories' => array('regexp' => '[/_a-zA-Z0-9-\pL]*'), ), ), ); @@ -108,7 +108,7 @@ class Dispatcher extends DispatcherCore public static function isProductLink($short_link) { // check if any keyword - $explode_product_link = explode("/", $short_link); + $explode_product_link = explode('/', $short_link); $count = count($explode_product_link); $sql = 'SELECT `id_product` @@ -122,7 +122,7 @@ public static function isProductLink($short_link) $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - return ($id_product > 0) ? true : false; + return ($id_product > 0); } /** @@ -134,7 +134,7 @@ public static function isProductLink($short_link) public static function isCategoryLink($short_link) { // check if parent categories - $categories = explode("/", $short_link); + $categories = explode('/', $short_link); $sql = 'SELECT `id_category` FROM `'._DB_PREFIX_.'category_lang` WHERE `link_rewrite` = \''.$categories[0].'\' AND `id_lang` = '. Context::getContext()->language->id; @@ -146,7 +146,7 @@ public static function isCategoryLink($short_link) $id_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - return ($id_category > 0) ? true : false; + return ($id_category > 0); } /** @@ -158,7 +158,7 @@ public static function isCategoryLink($short_link) public static function isCmsLink($short_link) { // check if any keyword - $explode_cms_link = explode("/", $short_link); + $explode_cms_link = explode('/', $short_link); $count = count($explode_cms_link); $sql = 'SELECT l.`id_cms` @@ -173,7 +173,7 @@ public static function isCmsLink($short_link) $id_cms = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - return ($id_cms > 0) ? true : false; + return ($id_cms > 0); } /** @@ -185,7 +185,7 @@ public static function isCmsLink($short_link) public static function isManufacturerLink($short_link) { // check if any keyword - $explode_manufacturer_link = explode("/", $short_link); + $explode_manufacturer_link = explode('/', $short_link); $count = count($explode_manufacturer_link); $name_manufacturer = str_replace('-', '%', $explode_manufacturer_link[$count-1]); @@ -202,7 +202,7 @@ public static function isManufacturerLink($short_link) $id_manufacturer = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - return ($id_manufacturer > 0) ? true : false; + return ($id_manufacturer > 0); } /** @@ -214,7 +214,7 @@ public static function isManufacturerLink($short_link) public static function isSupplierLink($short_link) { // check if any keyword - $explode_supplier_link = explode("/", $short_link); + $explode_supplier_link = explode('/', $short_link); $count = count($explode_supplier_link); $name_supplier = str_replace('-', '%', $explode_supplier_link[$count-1]); @@ -231,7 +231,7 @@ public static function isSupplierLink($short_link) $id_supplier = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - return ($id_supplier > 0) ? true : false; + return ($id_supplier > 0); } /** @@ -282,18 +282,13 @@ public function getController($id_shop = null) if (isset($this->routes[$id_shop][Context::getContext()->language->id])) { -// $firephp = FirePHP::getInstance(true); $findRoute = array(); // check, whether request_uri is template or not foreach ($this->routes[$id_shop][Context::getContext()->language->id] as $route) { -// $firephp->log($route['rule'], 'Rule'); - if (preg_match($route['regexp'], $this->request_uri, $m)) { -// $firephp->log('RegExp Pass!'); - $isTemplate = false; switch($route['controller']) @@ -320,8 +315,6 @@ public function getController($id_shop = null) break; } -// $firephp->log((int)$isTemplate, 'Template'); - if($isTemplate == false) { $findRoute = $route; @@ -333,12 +326,10 @@ public function getController($id_shop = null) // if route is not found, we have to find rewrite link in database if(empty($findRoute)) { - $req_url = substr($this->request_uri, 1); // remove '/' from begining - $req_url = explode("?", $req_url); // remove all after '?' + $req_url = substr($this->request_uri, 1); // remove '/' from begining + $req_url = explode('?', $req_url); // remove all after '?' $short_link = $req_url[0]; -// $firephp->log($short_link, 'Short Link'); - if(!Dispatcher::isProductLink($short_link)) if(!Dispatcher::isCategoryLink($short_link)) if(!Dispatcher::isCmsLink($short_link)) @@ -359,8 +350,6 @@ public function getController($id_shop = null) if(!empty($findRoute)) { -// $firephp->log($findRoute['rule'], 'Find Route Template'); - if (preg_match($findRoute['regexp'], $this->request_uri, $m)) { // Route found ! Now fill $_GET with parameters of uri @@ -400,4 +389,4 @@ public function getController($id_shop = null) $_GET['controller'] = $this->controller; return $this->controller; } -} \ No newline at end of file +} From d52de682b56506cb5e77944e8cd7221bae3e0695 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 26 Feb 2015 20:43:31 +0100 Subject: [PATCH 036/174] Update Link.php --- cleanurls/override/classes/Link.php | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/cleanurls/override/classes/Link.php b/cleanurls/override/classes/Link.php index 676ad2b..151df0b 100644 --- a/cleanurls/override/classes/Link.php +++ b/cleanurls/override/classes/Link.php @@ -5,7 +5,8 @@ public function __construct($protocol_link = null, $protocol_content = null) { parent::__construct($protocol_link, $protocol_content); - /* TODO add a configuration switch to hide or show the Home category + /* TODO + * add a configuration switch to hide or show the Home category // Re-add Home category Link::$category_disable_rewrite = array_diff(Link::$category_disable_rewrite, array(Configuration::get('PS_HOME_CATEGORY'))); */ @@ -35,10 +36,10 @@ public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $sele // Set available keywords $params = array(); - $params['id'] = $category->id; - $params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias; - $params['meta_keywords'] = Tools::str2url($category->meta_keywords); - $params['meta_title'] = Tools::str2url($category->meta_title); + $params['id'] = $category->id; + $params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias; + $params['meta_keywords'] = Tools::str2url($category->meta_keywords); + $params['meta_title'] = Tools::str2url($category->meta_title); // Selected filters is used by the module blocklayered $selected_filters = is_null($selected_filters) ? '' : $selected_filters; @@ -50,12 +51,10 @@ public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $sele $rule = 'layered_rule'; $params['selected_filters'] = $selected_filters; } - - if ($dispatcher->hasKeyword('category_rule', $id_lang, 'parent_categories')) { - //RETRIEVING ALL THE PARENT CATEGORIES + //Retrieve all parent categories $cats = array(); foreach ($category->getParentsCategories() as $cat) { @@ -63,18 +62,17 @@ public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $sele // remove root and current category from the URL if (!in_array($cat['id_category'], self::$category_disable_rewrite)) { - $cats[] = $cat['link_rewrite']; //THE CATEGORIES ARE BEING ASSIGNED IN THE WRONG ORDER (?) + $cats[] = $cat['link_rewrite']; } } - - $params['parent_categories'] = implode('/', array_reverse($cats)); //ADD THE URL SLASHES TO THE CATEGORIES IN REVERSE ORDER + // Add the URL slashes among categories, in reverse order + $params['parent_categories'] = implode('/', array_reverse($cats)); } return $url.Dispatcher::getInstance()->createUrl($rule, $id_lang, $params, $this->allow, '', $id_shop); - } - + /** * Get pagination link * @@ -116,7 +114,7 @@ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, foreach ($_GET as $k => $value) { - // Ha!*!*y strip var like category_rewrite from url + // strip var like category_rewrite from url if ($k != 'id_'.$type && $k != $type.'_rewrite' && $k != 'controller') { if (Configuration::get('PS_REWRITING_SETTINGS') && ($k == 'isolang' || $k == 'id_lang')) @@ -155,5 +153,4 @@ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, $vars['controller'] = Dispatcher::getInstance()->getController(); return $vars; } - } From 5428e301f8db0afd38e23ce9876c5ca41077d7bf Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 26 Feb 2015 20:53:18 +0100 Subject: [PATCH 037/174] Update cleanurls.php --- cleanurls/cleanurls.php | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/cleanurls/cleanurls.php b/cleanurls/cleanurls.php index edd5dbd..0e11b3e 100644 --- a/cleanurls/cleanurls.php +++ b/cleanurls/cleanurls.php @@ -24,21 +24,19 @@ public function __construct() { $this->name = 'cleanurls'; $this->tab = 'seo'; - $this->version = '0.42.1'; + $this->version = '0.6'; $this->need_instance = 0; - $this->author = 'ha!*!*y'; + $this->author = 'ZiZuu Store'; parent::__construct(); - $this->displayName = $this->l('Clean URLs'); + $this->displayName = $this->l('ZZ Clean URLs'); $this->description = $this->l('This override-Module allows you to remove URL ID\'s.'); } public function getContent() { - $output = ''; - - $output .= '
+ $output = '
On some versions you have to disable Cache save than open your shop home page than go back and enable it.
Advanced Parameters > Performance > Clear Smarty cache

Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL off -> Save
@@ -76,13 +74,13 @@ public function getContent() } function checkWritable($directories) - { - foreach ($directories as $dir) { - if (!file_exists(_PS_ROOT_DIR_ . "/" . $dir) && - strpos($dir, "override/", 0) === 0 && + { + foreach ($directories as $dir) { + if (!file_exists(_PS_ROOT_DIR_ . '/' . $dir) && + strpos($dir, 'override/', 0) === 0 && !copy(_PS_ROOT_DIR_ ."/modules/cleanurls/empty_".$dir, _PS_ROOT_DIR_ . "/" . $dir)) return false; - if (!is_writable(_PS_ROOT_DIR_ . "/" . $dir)) + if (!is_writable(_PS_ROOT_DIR_ . '/' . $dir)) return false; } return true; @@ -90,12 +88,12 @@ function checkWritable($directories) public function install() { - if (!$this->checkWritable(array("override/classes/Dispatcher.php", "override/classes/Link.php", "override/controllers/front/CategoryController.php", "override/controllers/front/CmsController.php", "override/controllers/front/ManufacturerController.php","override/controllers/front/ProductController.php"),"override/controllers/front/SupplierController.php") ) { - $this->_errors[] = $this->l('Files in /override folder are not writable, these files need to be writable: classes: Dispatcher.php, Link.php; controllers/front: CategoryController.php, CmsController.php, ManufacturerController.php, ProductController.php, SupplierController.php'); - return false; + $this->_errors[] = $this->l('Files in /override folder are not writable, these files need to be writable: classes: Dispatcher.php, Link.php; controllers/front: CategoryController.php, CmsController.php, ManufacturerController.php, ProductController.php, SupplierController.php') +; + return false; } // add link_rewrite as index to improve search $table_list = array('category_lang','cms_category_lang','cms_lang','product_lang'); From b7b6ea53c6d4df69e1b0b1b5d83c3d6734f57211 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 26 Feb 2015 20:54:58 +0100 Subject: [PATCH 038/174] Update config.xml --- cleanurls/config.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cleanurls/config.xml b/cleanurls/config.xml index 6905103..35684b2 100644 --- a/cleanurls/config.xml +++ b/cleanurls/config.xml @@ -1,10 +1,10 @@ - cleanurls - + zzcleanurls + - + 1 0 From 7577a94e7ec616f023458fc1f23d40ba46490352 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 26 Feb 2015 20:56:24 +0100 Subject: [PATCH 039/174] Update cleanurls.php --- cleanurls/cleanurls.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cleanurls/cleanurls.php b/cleanurls/cleanurls.php index 0e11b3e..912d5ed 100644 --- a/cleanurls/cleanurls.php +++ b/cleanurls/cleanurls.php @@ -30,7 +30,7 @@ public function __construct() parent::__construct(); - $this->displayName = $this->l('ZZ Clean URLs'); + $this->displayName = $this->l('ZiZuu Clean URLs'); $this->description = $this->l('This override-Module allows you to remove URL ID\'s.'); } @@ -41,7 +41,7 @@ public function getContent() Advanced Parameters > Performance > Clear Smarty cache

Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL off -> Save
Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL on -> Save
-

'; +

'; $sql = 'SELECT * FROM `'._DB_PREFIX_.'product_lang` WHERE `link_rewrite` From 85843220f194f55d8860a729764ce0ab78fb4ba9 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 26 Feb 2015 20:57:15 +0100 Subject: [PATCH 040/174] Update config.xml leave the module name untouched for maximum compatibility .. at least for now --- cleanurls/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cleanurls/config.xml b/cleanurls/config.xml index 35684b2..b5ab827 100644 --- a/cleanurls/config.xml +++ b/cleanurls/config.xml @@ -1,6 +1,6 @@ - zzcleanurls + cleanurls From fcfa16c9f09a0ba55563e05a8aa92fac4f0703c6 Mon Sep 17 00:00:00 2001 From: Wayann Date: Fri, 27 Feb 2015 18:52:37 +0100 Subject: [PATCH 041/174] Fix wrong category link in blocklanguages when multilanguage is enabled if you had a rule with parent category blocklanguages module would parse the subcategory with the previous selected language. --- cleanurls/override/classes/Link.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cleanurls/override/classes/Link.php b/cleanurls/override/classes/Link.php index 1aa5a76..798416a 100644 --- a/cleanurls/override/classes/Link.php +++ b/cleanurls/override/classes/Link.php @@ -71,7 +71,7 @@ public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $sele { //RETRIEVING ALL THE PARENT CATEGORIES $cats = array(); - foreach ($category->getParentsCategories() as $cat) + foreach ($category->getParentsCategories($id_lang) as $cat) { self::$category_disable_rewrite[] = $category->id; From b2ada65627469f52c490e69b98a498ae583ce1c8 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 10 Mar 2015 15:43:41 +0100 Subject: [PATCH 042/174] Update README.md --- README.md | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 781693a..3cc58e2 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,46 @@ -[ABOUT](http://lebioda.github.io/PrestaShop-modules-CleanURLs/) +[ABOUT](https://github.com/ZiZuu-store/PrestaShop-modules-CleanURLs) =============================================================== +It works on our 1.6.0.9. We are going to merge other users' contributions and ideas as soon as we note them and find the time to test. + +If you fork please make every change the way we can pull, don't reinvent the wheel .. make every custom changeon a private branch, so you can merge your own changes to the community mintained full branch every time a new release is out. + +INSTALLATION +-------- + +Install the module from the Backoffice (administration panel), download the release ZIP binary as it already contains the right folder name (cleanurls, not cleanurls-version_x.y.z !) + +In the modules tab, click on **add a new module**. Click on Browse to open the dialogue box letting you search your computer, select the file then validate the dialogue box. Finally click on Upload this module. + +###Make sure your seo and url settings are as follows: + +This is __MANDATORY__ +* products: {category:/}{rewrite} (**NO .html** at the end) +* categories: {parent_categories:/}{rewrite}/ +* manufacturers: {rewrite} +* CMS: "WHAT YOU WANT"/{rewrite} (ex info/{rewrite}) + +Keep in mind to clear browser cache / PS cache under smarty/cache and smarty/compile + +UNINSTALLATION +-------- + +Go to modules -> Find and uninstall "CleanURL". + +Open folder /override/classes/ +-> Remove "Link.php" +-> Remove "Dispatcher.php" + +Open folder /override/controllers/front/ +-> Remove "CategoryController.php" +-> Remove "CmsController.php" +-> Remove "ManufacturerController.php" +-> Remove "ProductController.php" +-> Remove "SupplierController.php" + +Open folder /cache/ +-> Remove "class_index.php" + +Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL off -> Save +Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL on -> Save + +If you got any other override modules, you should now go to you back office, uninstall them, and reinstall them again to work correctly. From 8fa86548cbb3dc0e7b98c2ea9d290e6d1f1b251d Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 10 Mar 2015 15:52:20 +0100 Subject: [PATCH 043/174] Just some indentation cleanup on config.xml --- cleanurls/config.xml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cleanurls/config.xml b/cleanurls/config.xml index b5ab827..41d6b0c 100644 --- a/cleanurls/config.xml +++ b/cleanurls/config.xml @@ -1,12 +1,12 @@ - - cleanurls - - - - - - 1 - 0 + + cleanurls + + + + + + 1 + 0 - + From 4a0b271e36124d5fca75757a5c2645ecdf2282e9 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 10 Mar 2015 18:18:16 +0100 Subject: [PATCH 044/174] Updated .. should work with current PS to be tested .. --- README.md | 15 ++++-- cleanurls/override/classes/Dispatcher.php | 58 +++++++++++------------ cleanurls/override/classes/Link.php | 18 +++---- 3 files changed, 48 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 3cc58e2..610f6d7 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,17 @@ In the modules tab, click on **add a new module**. Click on Browse to open the d ###Make sure your seo and url settings are as follows: This is __MANDATORY__ -* products: {category:/}{rewrite} (**NO .html** at the end) +* products: {categories:/}{rewrite} (**NO .html** at the end) * categories: {parent_categories:/}{rewrite}/ -* manufacturers: {rewrite} -* CMS: "WHAT YOU WANT"/{rewrite} (ex info/{rewrite}) - -Keep in mind to clear browser cache / PS cache under smarty/cache and smarty/compile +* manufacturers: manufactures/{rewrite} +* suppliers: suppliers/{rewrite} +* CMS page: info/{rewrite} +* CMS category: info/{rewrite}/ +* modules: modules/{module}{/:controller} + +You can replace "info" with whatever you want given that it does not conflicts with a category name + +Keep in mind to **clear the browser cache**, **clear PS cache** under smarty->cache and smarty->compile UNINSTALLATION -------- diff --git a/cleanurls/override/classes/Dispatcher.php b/cleanurls/override/classes/Dispatcher.php index e933792..ce77814 100644 --- a/cleanurls/override/classes/Dispatcher.php +++ b/cleanurls/override/classes/Dispatcher.php @@ -10,9 +10,9 @@ class Dispatcher extends DispatcherCore 'rule' => 'supplier/{rewrite}/', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'supplier_rewrite'), - 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), - 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), + '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( @@ -20,9 +20,9 @@ class Dispatcher extends DispatcherCore 'rule' => 'manufacturer/{rewrite}/', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'manufacturer_rewrite'), - 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), - 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), + '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( @@ -30,9 +30,9 @@ class Dispatcher extends DispatcherCore 'rule' => 'info/{rewrite}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'cms_rewrite'), - 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), - 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), + '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( @@ -40,17 +40,17 @@ class Dispatcher extends DispatcherCore 'rule' => 'info/{rewrite}/', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'cms_category_rewrite'), - 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), - 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), + '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'), + 'module' => array('regexp' => '[_a-zA-Z0-9-]+', 'param' => 'module'), + 'controller' => array('regexp' => '[_a-zA-Z0-9-]+', 'param' => 'controller'), ), 'params' => array( 'fc' => 'module', @@ -61,27 +61,27 @@ class Dispatcher extends DispatcherCore 'rule' => '{category:/}{rewrite}.html', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'product_rewrite'), + '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]*'), + '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]*'), + 'tags' => array('regexp' => '[a-zA-Z0-9\pL-]*'), ), ), 'layered_rule' => array( 'controller' => 'category', - 'rule' => '{rewrite}/filter{selected_filters}', + 'rule' => '{rewrite}/filter/{selected_filters}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), /* Selected filters is used by the module blocklayered */ 'selected_filters' => array('regexp' => '.*', 'param' => 'selected_filters'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'category_rewrite'), + '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]*'), ), @@ -91,10 +91,10 @@ class Dispatcher extends DispatcherCore 'rule' => '{parent_categories:/}{rewrite}/', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - '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]*'), - 'parent_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_categories' => array('regexp' => '[/_a-zA-Z0-9\pL-]*'), ), ), ); diff --git a/cleanurls/override/classes/Link.php b/cleanurls/override/classes/Link.php index 44d16b1..cde8a24 100644 --- a/cleanurls/override/classes/Link.php +++ b/cleanurls/override/classes/Link.php @@ -21,15 +21,12 @@ public function __construct($protocol_link = null, $protocol_content = null) * @param string $selected_filters Url parameter to autocheck filters of the module blocklayered * @return string */ - public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $selected_filters = NULL, $id_shop = NULL) + public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $selected_filters = NULL, $id_shop = NULL, $relative_protocol = false) { - - $dispatcher = Dispatcher::getInstance(); - if (!$id_lang) $id_lang = Context::getContext()->language->id; - $url = $this->getBaseLink($id_shop).$this->getLangLink($id_lang, null, $id_shop); + $url = $this->getBaseLink($id_shop, null, $relative_protocol).$this->getLangLink($id_lang, null, $id_shop); if (!is_object($category)) $category = new Category($category, $id_lang); @@ -38,8 +35,8 @@ public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $sele $params = array(); $params['id'] = $category->id; $params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias; - $params['meta_keywords'] = Tools::str2url($category->meta_keywords); - $params['meta_title'] = Tools::str2url($category->meta_title); + $params['meta_keywords'] = Tools::str2url($category->getFieldByLang('meta_keywords')); + $params['meta_title'] = Tools::str2url($category->getFieldByLang('meta_title')); // Selected filters is used by the module blocklayered $selected_filters = is_null($selected_filters) ? '' : $selected_filters; @@ -51,7 +48,10 @@ public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $sele $rule = 'layered_rule'; $params['selected_filters'] = $selected_filters; } - + + $dispatcher = Dispatcher::getInstance(); + + //XXX: replace 'category_rule' with $rule ? if ($dispatcher->hasKeyword('category_rule', $id_lang, 'parent_categories')) { //Retrieve all parent categories @@ -69,7 +69,7 @@ public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $sele $params['parent_categories'] = implode('/', array_reverse($cats)); } - return $url.Dispatcher::getInstance()->createUrl($rule, $id_lang, $params, $this->allow, '', $id_shop); + return $url.$dispatcher->createUrl($rule, $id_lang, $params, $this->allow, '', $id_shop); } From 4c2c8d1cc77893856a6ff9c89b8bcb51546b62c3 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 10 Mar 2015 18:24:36 +0100 Subject: [PATCH 045/174] test release v0.7 --- README.md | 4 +++- cleanurls/cleanurls.php | 2 +- cleanurls/config.xml | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 610f6d7..566f5c7 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,9 @@ This is __MANDATORY__ You can replace "info" with whatever you want given that it does not conflicts with a category name -Keep in mind to **clear the browser cache**, **clear PS cache** under smarty->cache and smarty->compile +Keep in mind to +* **clear the browser cache** +* **clear PS cache** (under smarty -> cache and smarty -> compile) UNINSTALLATION -------- diff --git a/cleanurls/cleanurls.php b/cleanurls/cleanurls.php index 912d5ed..62c1387 100644 --- a/cleanurls/cleanurls.php +++ b/cleanurls/cleanurls.php @@ -24,7 +24,7 @@ public function __construct() { $this->name = 'cleanurls'; $this->tab = 'seo'; - $this->version = '0.6'; + $this->version = '0.7'; $this->need_instance = 0; $this->author = 'ZiZuu Store'; diff --git a/cleanurls/config.xml b/cleanurls/config.xml index 41d6b0c..b1ad84e 100644 --- a/cleanurls/config.xml +++ b/cleanurls/config.xml @@ -2,7 +2,7 @@ cleanurls - + From fdc34d2d5425aa4042604e8b36e71b7c18c75a2a Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 11 Mar 2015 17:16:51 +0100 Subject: [PATCH 046/174] Directories levels prune --- cleanurls/cleanurls.php => cleanurls.php | 0 cleanurls/PRTSC_Preferences_SEO_URLs.png | Bin 35249 -> 0 bytes cleanurls/config.xml => config.xml | 0 .../classes/Dispatcher.php | 0 .../classes/Link.php | 0 .../controllers/front/CategoryController.php | 0 .../controllers/front/CmsController.php | 0 .../front/ManufacturerController.php | 0 .../controllers/front/ProductController.php | 0 .../controllers/front/SupplierController.php | 0 cleanurls/index.php => index.php | 0 cleanurls/logo.gif => logo.gif | Bin cleanurls/logo.png => logo.png | Bin .../classes/Dispatcher.php | 0 .../override => override}/classes/Link.php | 0 .../classes/controller/FrontController.php | 0 .../override => override}/classes/index.php | 0 .../controllers/front/CategoryController.php | 0 .../controllers/front/CmsController.php | 0 .../front/ManufacturerController.php | 0 .../controllers/front/ProductController.php | 0 .../controllers/front/SupplierController.php | 0 .../controllers/front/index.php | 0 .../override => override}/controllers/index.php | 0 {cleanurls/override => override}/index.php | 0 25 files changed, 0 insertions(+), 0 deletions(-) rename cleanurls/cleanurls.php => cleanurls.php (100%) delete mode 100644 cleanurls/PRTSC_Preferences_SEO_URLs.png rename cleanurls/config.xml => config.xml (100%) rename {cleanurls/empty_override => empty_override}/classes/Dispatcher.php (100%) rename {cleanurls/empty_override => empty_override}/classes/Link.php (100%) rename {cleanurls/empty_override => empty_override}/controllers/front/CategoryController.php (100%) rename {cleanurls/empty_override => empty_override}/controllers/front/CmsController.php (100%) rename {cleanurls/empty_override => empty_override}/controllers/front/ManufacturerController.php (100%) rename {cleanurls/empty_override => empty_override}/controllers/front/ProductController.php (100%) rename {cleanurls/empty_override => empty_override}/controllers/front/SupplierController.php (100%) rename cleanurls/index.php => index.php (100%) rename cleanurls/logo.gif => logo.gif (100%) rename cleanurls/logo.png => logo.png (100%) rename {cleanurls/override => override}/classes/Dispatcher.php (100%) rename {cleanurls/override => override}/classes/Link.php (100%) rename {cleanurls/override => override}/classes/controller/FrontController.php (100%) rename {cleanurls/override => override}/classes/index.php (100%) rename {cleanurls/override => override}/controllers/front/CategoryController.php (100%) rename {cleanurls/override => override}/controllers/front/CmsController.php (100%) rename {cleanurls/override => override}/controllers/front/ManufacturerController.php (100%) rename {cleanurls/override => override}/controllers/front/ProductController.php (100%) rename {cleanurls/override => override}/controllers/front/SupplierController.php (100%) rename {cleanurls/override => override}/controllers/front/index.php (100%) rename {cleanurls/override => override}/controllers/index.php (100%) rename {cleanurls/override => override}/index.php (100%) diff --git a/cleanurls/cleanurls.php b/cleanurls.php similarity index 100% rename from cleanurls/cleanurls.php rename to cleanurls.php diff --git a/cleanurls/PRTSC_Preferences_SEO_URLs.png b/cleanurls/PRTSC_Preferences_SEO_URLs.png deleted file mode 100644 index 9cb8dfc64d59a592a55839b65335ab55b653d35d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 35249 zcmaHS1yEdD*CioBfB?a*akmg8K;!OCaCe8`PKOYJI}O3z-5r8M6Wl#WMp9e_wKWg?Y-98=LRdvOQ0YTAi=@Gp-4%JD#O9SW5T{{Z{cD8`DFV}4EE=R zld^;`T-h*S2lnHYxsaR?99(52^1b0}*l)xylA2C%aHw6+-xq!M1txHC!QxV)LZ99B z4qETrbY{RS!6e-4c03`bnrK@`{ZR}uI|I@Ji~>ztZj6+g+lFQiZ}6L!IK;jQ{C*CM-+i32vlseJW?t76vb#lD)g1D7(FMGRApWm3#r1hO3*Iz;*)+6=|lRTjUO zw|tKH>UYyT^|0D%t)zOiw{9A@_K)W77P+?>5*SV&>KUxld1q`}jG- z`-lVWK$Mk`38D#F?l{s3LOV$o@FsIizs&bDg2`E6W~#wFM1sJ838HG1_?-(Xuo`S zdxzPg=;M$kQx*?dI{I?=&L>nRKJ>&s?e43d2ba3T5ny@-c_Z%Vj)O;^@>OxuQ{;E2Bs8$)+W9R!(ipu+}PoOIU zjq-RR7VF?%=>Wx{G#3^%}P5p|rL~gjZ~tB1OMT$C*|klV3gzg2;H`=G^@DlJo7R&qm`uzw7c6MZQTB}^b+LtwEjkXwin?^?@eBo zHwLlA8!zcPy+w%^6V0Ub%nziiI^rsJOZO}ciN5VzPak*RQH9v50VjPNE_-(`ChJ3E zcjP~Paf^EW$`uHk3$pyR8Q&Vwj)F*m=0_T4-m^(I{hQs$cuo@j58!%!ZO~CJuH?tG zyP?>p+Vf+Fn^of`{<~7?@>{igTeqG5^iQX&9 zF~{~4*0w;sm$6G+_6bkzpd4Hi8a>f;*e3P*9Upm6DEbJMi(M-1}tbWjUBW!01NB z^J!=RbiXm7e?6TJs?*a$S4Y}|B0!&RY4m+=XMQ}!T?&g@PxAMnSmxV32BiicJ>;U) z*{Dt0g&=_?q3#aDqQX2}3^mty<&X|Gv zh)tiPxJ7iSS1%~jlr{1W{cNh^{OCqG9VJwP|RN+SidwRKnS zZPp(I9_O7vR{+a~CJP?T%>j4w|@An~z%j-cD5y)hzqY;e8NT zkA%iSJSxD+@mQx=bp`8bC2cs3YmW4C$xpOHcP&ky<5PyG=d&Ebq(m-N~)@ z40kfE;O>HIA}=OYp8l+S7~grhIfVaugB1EDtyFp8V#Ars>5&&@N^nv#t{ zNEm*Syyo_3I=Z=@-9E@yS}AVB;t$W>N6YynhW>twoVu30=KE<_YdVy?jEJ5 z?zK9)OU^6W>1AL^muZfb`azJ^@5iBQ0q;|wTdatknRk^QT?x+7=(r2i+_+QMJt1LX z?cq?$@YX(B&8JGMN#dwBFd5M0ac>}JadNvp2xOY?S2d4(4f~q}b8L#mo~vk8C^e zbY{P~fB>25tV8d9yV~t>(CcY;1@I6nfX{c4uJ^E){!kB(-B5K|pLbc%I2Mk3u-H=Z zgji&{EkOVDwU3?Zec3OBSbZAi12o#IZcVdCDi8Z7XEiS6Vei;b(s8(=lS_%7DYWhh z6-M`9?CIWcil=Ltjkk~0)o4G1FM+ho^*PtK0=bWm*#b9DVYtGCAC0Od_B|xUr06A1 zD8?#4#}9k_bbD=rd>#92x;zXq3oC25%&i#@mDEN6a_Y~-9V**FKSI5 zf5j^JS{|qLL$L~+1}xiaH4FQjH4DCwDe#^oQy^!(-?8R?`IWUu&2oS~(!<1mU?34Vm9u4!>}Y zWYV)W;@HMqL|iWW!=p?Vv%>u3zsdc<;A2&x;7~|ST(d6na#9r)S|&XzkzHKu4*Sxi z)BLJSsFL;Id{L7}*!ku78*$)4S>v~v3&W@;5&8Coj6gf}Z8>7`=*hL#Bhba1{@pHG z`P;ecZK0h<|EtIC`n1PI-1NuR8EF!}*%s!Na-S_H1^&CnOrW$A$mO6q{E8e>>AD`N zCwcGuXQb_cq5XCev*kplzYO%Wr+;%g13FHh5~T;7?u3IR)YE)#)1UMm#S|>3`ERO^ zV$g5EnI3+pn1161JGGZf$$>k)^hex-Em667B6+wmE3)ZiZZC?6*{!WfuMn=yExlLgHyi2J>lE z;J&ZD%|$(t$uvilc~SAJZOiANQqH!k-&=1(?*O8C^+fVX1+5jEzh*e-9wLn0DX!3pZ)}w z3e+GgyIaB%fHVb>4t)auWcTbj0wIa)>CnTEd!pu6e-4fOlFVCrO|$OzlCe4VDe@&& z^&3N}a`ZL9al7nsGUe}TdS)8O3D=j2kf%o{m{{Ti5X7Thw0uZCBG5RBMTXTUF)Y2O z1br%2AI%0QrF(Ciu@m3lhuZe1R;=R4+U z8U5HtPTuR32z(Ylk)YR`kx#vhg8cNpw~utoM47Gc4NKG9zpd-Swv#rEFEwc5xPt^a zy=&l9ABGx0C+fa;62icZNbIy50KPQt>>s_Tj@b~!61?SU>$kXn1ddjT=iO+eZmMJA;Grm`J5ACV zWAF#AyB_;{Olm<2u9T+v(IM!K$W6aMk6Io}lG)3W*>S=~E-7+~E@7dXb973T*2@|) z-C-_mQ&*|sZ3phs--1edCv0pMXWRnAc|dBfr!B&6rJ0YHMTwj@rL5Q<(%gP-^ zCIERumiG?>VKTHdFp}8*seY`S@5(LB`|`+JsRgvxr!Ip=*AbYmR5kuE)gDZXfU+Gq zqpnJtd=a17I|CVl*PGAQ+$ODzO6jPKr*lttH0fCU)lPIi{FDhWVv$S&($eH~ARFVg`qj>*Pu8&>Xhf7Q z!Vw7;agBuvCGFeG;V*PYRz5iHZ3)~;phN$pBb=6jL+A?ea8XPNqsYFZG2f@r&+)Q7 zSg1sy3t*nmBiN&tJ~^L~Osom+l`UH4)8sM6!a{*$YraxxY5R#+$#jma5gr$06|4Us zdalrI*UzR=^ty9mLwX!ZTprkG&A#k^-g>UivW^`Z)$mf8E7XR|!mvKevst6-{ID7!7QP7tfy@qQ*?TV z|B7n)RFuLx`;Xs{ZA5pf4v{j{%Llb*g6qY!vE+Ky>;Qhfp-n}M!zSOTT@j-h1*eJ&P` zNX%aT&Yk=0aU`D$1PSIGGn?e~q8p6JgLQljCmsstsgI&Z-vrO9IF#mm1QhX+a~;;G zAut?ySNSR&Iw@XGVfbZ9qCSnWheUfBu6ur98lIkE0nIGNu5bAr-j( z-mi#LIbcE@50$fQYxIR0)D_n#M%{^28Sc3WM6l8cWR<@fcmJ4bck2Td8`T5VNO9^O ziS5Am2x_Tkht^7~cGt(G4WHUF<fSC647&Y_b^hEVYW?%4Qh+F@@n$Wu-r#@>e)8DOf6oV%x&T3Gx zW%QC_KpLH~&9~(osdVr#20wnOqeOP%pA!$J8Gz9uy;`(|>isZvb-w*qDH8RAf`Mk7 zm4c(&kCG2}0LphHWo6N3-ak*LA(a<9o^#1R&U^_3kQp|eKHV#r&yCmh@usXUeBsef zVQD*`@C4{a)-)(%wN<}0h}ti?0~gjN5}$;~-gBV&Ye5_$c{+ zLd0}`Q-4bH_3V-9FBC#>uV6}zXP97-7H&A>Bk?c5lI#+5jMi-ZBzEE-ewyW+B^T}%$~or~ zK(c2Fu-wyo0<3KlpkM+qhvS61RBJ?SGPmqNH zCo;S$OeeQhN|zQTx8-V%K&;8Ti=m6j#-DD*2SWD7;m64mKBi)IJfjGCbRIGU{anL@ zwel=|2#LYgJtM70mOjF8m{XYh1KW|-(i~R3f`{)X`L^mo zbD!Isdm?=Ev38{@k_|NIZW{gePU_Z`;*R+^u${(5p=?qh&^7X7aN5IGnelm?6M@Rr zxyaFgo26cAtj5I$53%Slz&?8QYfG9H(^FuK1QK=RmJDA-xkemhHO&!EfQdcGgL}7T zVUkqDesHN;V>|+28}2A-U*9ZhabaK`rO@4nT}iSM9A6pA;?MY$C{H)*I zFiYWl?^mM3wCloHqVHxZ*D0kd{f|n;N|Fd_v_F`SRp-$Mjk0Oj;U!tU18!#DZz7i0 z=k!LmWTtnqBn)yc92TD}j#ADz)|Q+lJbr_!;?^YIE9=I`=*5XL8fD;jF8?aD4&7;g034eLlGT3JJbD^b;Y_(l3oTa4R zK#s?;re};kJpu4#(k#AXnv#UVF%6T6!kpi8#On99QxpcT2D8sCJ`sH7ZGC!~uOvwb zVdv|)4W{r<^T?XndnDNW45K8@^Ru!_sOCluS9A`WTKC@U`fCK1F?~%`*{WuK`#ixV zQ|7(Ev(ZBN#R}1x7WRUChatyxM8!`ks-z+2F49LsUhjG`L=&x zdn6Cw%7;n}e=71K(ajgS_+X?*;kn5$)ERbFPX;~q5AVSfL&p3&$423@5m9k0nDs63 z$@Y^|{PtrBoGg@C671sf7)wDip8inlo1EJ6 zsVre%;4*KlLrouOb?WewQlVx8u`Hrd)>=AVxh;Vyb-&f7~c0znpr+^=8H5 zz3iU72xPUG++)yt3)}1%$V^oH?EgkGwq@U@DzEa2}2XLs;+IM^p$Tah~u zC#K%-&elex;G1(6*TzT;x3Hbuc2oNWFT10L$;iSfn1{OoR_GP@tcF^V2YgT+&WTBG zjZlN2*~Aa2(m>TwCkCHzDFJ=v)ep05KI?Il)gK17v|BR2YP=ir;!ow8XPwh8cbs+l zXe%h29%i{0a*wUILZM6@BGWoC{-gG{pce5 zTlww_0?_+rU$;f=w0$jWZiZ9OB~*aoEUJTe;`0Ne#;-~okJE{K71y^`3_~W3fBus~;a-TqY9pS7vTLi4v{>o? zWMM&4sf?rH)Mj^oxVK+nA3;}mABF&wmjAiR^MV%PJLYpv6(kLVxe=!BDkm=eHzTXU zE27dO{PPsv3t9=hay?z44E<*pqF^4sguM7$Z+b5d2SM*;Xr`v1dcOCZ9%eD_<$qc% zFC!ggem2=J|DU~rgT7q{>&8Z7{6!1k|F&4HuKs=-_t~Tg4IK2VMC;2!S~*IQ(|BJ7;Ggw&qWL6l@qJ+}@66=xA#*fTfe&{ovkigu%(lCZ)li z#_QWhKGyvi^M)#XSR#^`uNUS!srf4lqw(|au*MuEzP>SS)XBT43je=m5utBuk~v36 z@bGpykH!KF(!Wag|77rj#Cr=FCOmLo)Pzi;rz>Z4XZP zn@5YYv&uhA7M||UHIK+g7%JxxA`|K>Gb|-soG&DPjvbULGE7uGWi@=!2{TT%ii6I&OeP0+8a`0 z@%huAUo{pAhO4=LnJ=^RzXyt{-f3yfHn8}J)_UkL1m@2zzK*R*C(3g_+po`z2p!Ru zrj>B@;;etV;b1^OM3^z4hb-4MZRUxuW9oavQOK-l&(1e334L3pgo9dW0Y6mMrZ%+D z*j+GQ$=Dpcq00=y2EFE3k>DdQ3H>}hz&lie;h6rae* zLgZSkX%X;cwGPi@XuoTOhbCxzEe18Es|w$an=G~K56Up|gsYf`+D-1{K*_+Wcl| z$%9cmH`Og`lc2sp9GK(&k~Wat+a?Vx(?KHj;&XSecP3MbFYqlj!_*<;$i?2+-=DoXuXnSD)LIh`0OH2IxHeK zQK>(t&;;Ak_F8B1moSH;T-biN9IP&#ncM=qYnpf!=ufj24H~XlcRKb@^FE_iB3JS9 zF=nfx`!hHZrL5{0rIVU{DYd*zAPH3)z(b$;0B<4wOO(|f@pP?VF&IBmwAg4!ul2VB zFk0Cr{fhz-^nGT<%LzAnKpFW8bh`$n`4c=abcD>GrwqXeUWl6%YmRPY+v%q+2L5TV zZ4y`KYIjD>h#|aia48NtWbFW*{;MAS4{#oU1HK}{c7{%(qoWIZZ0PcFf5$G) zv6*>XdztB9Twj1YZGxZn@O_K>uGGvvGA;;yJ<4{{u3jujvc$==;0+JcR|IWlJT_Q0 z^{S~mnEM);n5+$HucG)n));>MvGPL=Er@8Wu!oKJ=sTT#sipiDXs^@6_^f3$tkBKX zEM0-PEaCE8_05&))jsxaOyr%rX%mY@sSSvD{(UnM&?d&lP_e5_)?7=5>IZoo1xYL$ z4M$ejP?SiDNmq%d1t1hxm&Ul%Ik$ogrCw((wJ|F%5Vo>^d;dA2*-GdZqc^eg)VYt{ zjA2ysm1#6lx?d~ufaZpPUnd2akY^jC3_y-b-yJS3J7u|hAGzwUxUMXZ*M@_wX^Q-- zZ87|LWZ zoh7%{<6i8)u&7!qEe3W!^s`#m3uVhJe`8ZQ(ZeB8xjjJtg-SpXYJWiuR)XfdUIMJ}^WD03Jjg#dN!@_IkLFdv+o3Qhn_AQ(f&rwC-nR?@;ZTxWp zLBs@0%roJenDZ!V3vJXjpR_A)((;sgs(P8t+lIEW6U}w@-(i=Nc&W1cglreEj%8cB zR)gET1APLfKlf$Ft7m&ICqZM{jC5WYHw+>0@qK^yTi;(P1F$e0%H@Kt`tT8s(u!P4_25& zjjGr^Szpp(T>J`cM-fXXDee4p#*sRXExsTu7(6Jg57XDHdZe>FMl0o{@CG=agyHeF z30dQEjxl=1aZBp1kSl%8VR>V}FW%=wgXJ&PqvNX88^T*XBzUE(?ZEOz1mrcX=*YkHrUoKD;RWRt{T)2(s!OU1kR z^EJO_Hhf~3FD_f#)hS_SZ-F@BZetB9K4lv>O`Xv%YqBDIP|0(LIW5iI6B1)8Ib-7( zWSYI_9mG{0LsFecTK2_Vu6)gsQ<%^vLNvG)$wdrARo5I)@UwgO%8&8Nytl;LzMyUJg^fYr=X2`VZe-MZLzwow5G%my0*;?9$?a%DJ zEgHsz(XC!gVoj+X zO)_QB1Y}O?3l>*ENlb6Q1tG7cgqgr9hN8nNtO1m0EvypQbLD{f!w!ixH`U!fq+QO1 zQv`CA(;Pal2(=CA8r*?(ut_psEe(>J3gl(BQEnlLayM$`_|ia#5^l2Vw#pU4>~In) zPigHl^_h8lJW_aFK((U88%*KmY;XgVen}rs@LGyWUeLC0i=f0)+UC>!v7OW+= zem>dJ=FV2u(wC-|rqsinF1SZy6pdDZAS@P~I@N*Bonh+XKOw2y;QgSZsLumz9%^9Q z;C&vP$L1d}Qry)l^GY@(uJ`Hv zY28bG6b5>3=^f4sg+;*h2!rR_Aku>wTDCw{uv{o{!2x0(U?^tdfuNKQUC2f zL*QB@HH_YW6%70r1mkAhFF<|v-%;|v{RfMjNW}g{XI=m5HW7~NXM|^T282=A|58CR zud}6|yFF_7uWq9vd!ebjp}=GpzeP+*HlhEmLBwflYSLjL75|3@!7GLAdj|*Ij#%0^ zG$%Knu}~~4Ed@*G%C$WED*lz4T26r$VS~)=m4)K?w)gq=nDKvJkvQBp>kaTgqsbQ1 z{E%STX0r}cQKH!3*;y<-g@FXh5y@L<@7`S`Uu_Fl5anaAZbH&nsrK<@QfH>t_i_igR1Nz45%zZYvFfg(JCXcjPF{SDyYbqv+XrHm!;gC-q{8 zGEQADMG!_loNa~Xhf!qJh`Q69o@r-q^U#IMw3{*;V>wvKMiuLQUF{keN~55#jMsd6!cl6i8GtuX%#R-ROIWq-XEd{L{K!SX108D&nBo{ThzJCa!ShM(@i^y7)&y39>Gj&%^ zM7%4|*r4mvK<@}V9E>hZ&NEDlJ2?$MF{ zq*a*A#Q1}gbpW^LooWNCJQ549Tfzi?+g+^j!^_XFseB(u!4-!hz=8K4Q+6UhX5aj z=X)XZUAvdA;G{~urM9~tbCKvh(}n6-rx2)%ouGqX_Lm&MqpuY7XGmE5uNkTwo+0fk`eVB89Nib0#eE{Yem4E=*dYxW+h|wj-M4t;E^pYpQcb zSdLuJ8#;6fdi|K`R6iiy<`yx%w4vN@G*@wY;RzvgMAR2*m;4S$wzh3;_qNT*UP<~h zHKs|gx!)Z$t5s6t-Wn~uY^ERLm^(R01W0SmPS$Gkb}Rth-xqg@bP3!9#KrztQG$Ma zd^PCrOsj#Bf~${JIJ*&>T?vxk^_OA>ygP`)Lk|Iy>f(@b&8}~2RtH9Wl7j`&2Fq&C zip%3e57q~Ok(O>64Yo&gr)Z1I$v?t?ES;-Re14#54ZTr^X_-G;ip)OCsCbY*@E*F? zU7RpC8hQF7WY+JeUK`i&R5UI*Z*YU7`<@HZoO@`sQ(2s6E&J{pNfNP(Cd4^X)KA{1 zwNk5drSCHtIc`j@cXEw1JXI*l0Lm0uv650)u!Xqr4c;>mwjHn`nJ+&*7$XCyF^auz z(pqjCD2*hLYw&Ov`Vr`abK{;Feyan~fS9~sEgnm=C7sI+^$Co~Pk&U}UqyBsOzz>? zM>`SdQz#zQ%+za@C(Fj1S2?*HTp z1)((}!~;~_)K;!4%1QIKw^LP*J1LB6>@oVxFiAc@nDXjW;S`g_ZAOe!^%cO~d@0Y#a)_E{x<_2m_O}RX7_d?Ts(DnE`<# zD>C$n^{x+$<;%b9BNPaIN0i)(K0Sm+H+>>~@%H@Hb9SH*`qe-;&KBH&Rr|$KfeOdU zI_jgZ$TB9*o78PN7>|B)phcK)Kg2ZUm1oFx^3mLUF%w8?fcU3dgjPZxapO^8KEn?d ztFP|>8aw}J@ijqkk5wx22^)NvU||VZu=R}m?|f2xHI2HB{#W<@D?LBw2)I}Oh}i-3 zY~#;{1dm{n`2VYOUo6iX;$B$%4{N{G-He++-n{AA$FJr+<*F|CyuXz;tm}Tdc-KC) z?!~~CiXZQ`Nh2;!z1#xMonw-k(27Cfq;mx!hnia$ILC-|F^$NH(@L1<(OOAiyq{1_ zI+e$d)5fLlWBw_?iSb2+VEAW|GTWW^>6g};{BqWY@+R|g#e}ao^WExsFK^vVxntuv zrZM!(aAM!>+oXgI$WweAjLC8V5VSNlTEf<3=0IZdU43<5dP+UJ<&b0KyF~Xf7giQ& zbtJ;^MMl|^05GO@mvo}$s(Er3i|MeFM@)pD-Zv+Eca zEM?;SH5R<0jlbC3x+QvYy?oHtcF@+EYfZ>7BmWt}oDRPcb^I2Yq?2-4eXhEm-6;#Q zb2VmocV0Tg(5vcD!Tf=+3SY&(D)iSE94JC4`5QT3Q^FD6R*`^=VBzm)WJ@K7i}234Wh=%3hxD6hn!)Ku+Ug<)V6xIjVB9#Ka zI2hG*bk>6i7fZGoiC}KPDj*v6eghu4IfXyL!+43|)nI>!Gl&H+PHT+*i9l$lFX|;GwC?$|1Xo~ywJ1gD)lP5Gm0Ol-`>!vw^OkK zh`)XpE`h;3-8CIsj5DcS2GncBt~wF z^*LWlD`0^U4+Ti`M|8Eh9YZI@etWFM#)_aBJ+-9x5^wt#Q@?__6F<@EI4`Y)-l3>S zZ*Cx=J@3l{RcC#U0;%Ch-uZ>J>1k+#W|_KrJ~C1BYmaRkG=% zXOkxX#7R>-Kng+3*gP7A@oy{qu#%!NCr`_-5knVt+L`HT>D+PZ|F|daT6$3zQcOOcwR8()lpqJ@+5gLz`O1MP87BLBUFk1n#$RRB#lF z`ehv5NrU8qmbO+rfptDQrG69b_n{g&9o~rw$Gv+*D5U z)W^i!ZagnZG}{)+&-s&@L~qvZXRNhbHW+taj#Gk-?LhkaE02x6Tg=!QRU_fyOdgQn zsS5VG^w{9ykw~V*eV4&ttklxEy5CI?GM3&Y%2pNaIn>SB$V1bmO{qfPQl&D&A(^rx zvLn@$dMy0e~DJp*G$ z{L}$r#AroW3iq0s%Zm3*TeKXwd1jf22`xE{nORA-difo>QTkmn^yN;N7}9*OcdRfq zu=s}|FxoTAMMd-Z6jo>!ErSk@6`uxr4tBd#qX!-IBV?D@&H7_m_1aDxXB$ZVcLg%X z#0F&tavXpLR(C$1O2*&CMj|70O4Me+*A$bR-jQ*4CJ0B?V9-3L;gU$cC9L$y-JJy zN;qEN#BT5KGXvPza^J&KYD=WV>xSwbmk)&;ta6EyDz}g#S1y|ap&Ez1R61))2jG5@ z8*vBt1aTlJbOOG<+57aUn4_{tLO*owB}{~vLS?q;;sv*rk9RCtv)mUU!g`IrE3?Db;3ZZif%gwF;vT2-MHauTJfd%9 zRKKis;o5~_Z19{;4fF&IWcsrWGBDQnnI&)%@z>d&t{v|a4f`glq&@sHRIb*yBT>%^ zuW=bL$d0RzUn(>>IlcyHk;H|&sEsJI$2ms{dFfdMRoK|Ly8LA=12S=c`Xf)dzBk|r zNqdhXnPyq!QPn9&_iD`LQjtl_hmSdKy_MZ(P$R?kz#!?1qoqW4$g--faza_0|l`HTu`w9GZqE!DTjP1}RQcJEZy z+fqb5qSV}&9{I4K(jMv18A7@Z+sj;9b?MecA zbzW~4c@g3@Ikc`7X^y)GS%u!K`X+;ZULU@*{W_uQqQy~nZZ)> zKzgx(h#WiF+mZcpM2c+-Z`oa=SLK_t=J!8Ae5gCblS&aLz$WDdn+Y8%Gf419)Yzh) ziJWVQ-ot`+A!4y&*pFHaolZ`bY*k5jBzN?u#rRtx$syF%e z+TdZ5*8Vp}1++m6)$VVDIxX+i39%gse`Nz6Plv|SW;R8#@1tVg9x5=$=Emy<9aFAB zR!h|xk4?!4Z5G9znN!CUN)&&{uFJX9i$|+#=$N4^YeUT{1#=P=sKIgaP+b|gFYm>u zN;d%})q1)MPVf|0P~+bk`4=)?V$;01T7{ z2I(|_duW&m+Fl@*C3QWkRx4xWp{}%HhE14rwN}^vL>%p0)#Hz)7TcZhd zX3qoJ_;raIxiGK9s*{{0c^<67mp1fpoC<{~(m`jv&6VwSBpjnL6`90;+i6Mbwn??< zVQa%@&354)#&d?c&62EvBGT0|tA$%VQ-#H8YVy|(5*&(bUUCV}fZQLqCie;)`-7rT z^K_H{jL=hWUIXM87R`$>_$5+(8-2n)u@(VhV;N)5<2!oujy^NQiOfFyB>NO<+_=b5 zNmo6ydIdaR4w~Ega)~OsDB}fi@s5adi~%Qwggs%{dQgsU?8G%u)@x7p%4eOJrTf=^ zQ%)-_Dg<0KVIBlvGA|(ZqT1S!!SYC;Pkh|VPuNyR@$Zr*aQral$ud)WBN(JR~(c#uRi;Fdx=3s5m6S;>J$wR>U@r{=h)ftDXz+f@wu@_iD z=5Ff8iqmAOjgi#SZ)S1tPc^xtO}a{t3Dx?Bb)Ty?O4IYKmx@-{b1Vd4(u5>d593yD zI;I1i6*!v@tWm&}vl~wUZJ~7-l3(TAI7ojic=3wh83Nr5)4fP>|5?p;I0|@Q@#@Q( zq5Q#S#24iG`ToTxDMI%5Fw_G|H@*t+pSQYF;(Gh_mmT$JYx_Qyvr%!)-Q0*R_Eu0% zYF7bgO{A>uq{NixNC^rSp>_$MAXReT#BaJrzwq<0i=>i`RR%vAEweqBGbRZ{7!uJX zALWC-<*HQG%8H7$yI}t16Z*~cHkUI!srI3vri>({HXN~#%5fycC{|#nz{M>YNL7!` z(S*ZrrG8jiP%M+}%~_5z=JwtK!Ec%&kgs}Lx0pII*#+F?glD_Izwj&8u5W6N4AErF z(WtMlEj2fO`$Y`|tB%%qp01IfzsR}@dCf%MgZ?;^LmPOta6MOFzn5OI$G5}b%gmQQe#%0>%x3+tb={P| zk<|C48nBm4mVFhssMUv996#u94=vwD8$NaDSvwo_jtjji(Pw5jA~UYFpRh}!KhS8% zlzl&&`AVx4VBP)`sv>^P*OcLVcOdXyJ(=>TKCRlGkb7s^O?}NAnHz!*RAGPuR{H50 z05kcTfLV*djlzwUq z2v0XCTBoOl>%s!puSA~w8s;fI+U3%G7G|aDhiD}rz_v;iN4`KdGakK}Sf%;HS-M7- z2uxRh-?b5!`)I9~KRCv+~5yToT;AG<-y+Lk-?WlWX#V?G&Va;B3RCZ6`nMRN=2O z%26xmAE%j%#M;9#h06v_pVMNmKX#|u^#G4c+fk|dHPYD)k0#+|FNbr1{Jh{^uMblH+#N-;16xFd1VAvdU-8aSf++mW`ut z?Jr~9G*}xsW9x6d80&#AkG!S*j=$s1=pv!>hX)~kz67*X#)_G7 zfu>*5>%dbE2e>c2>n>hCp8JbbWLl`OR~=xo{{L$4tfS&s)GZ$&5Foe(4;tJ;@Zj$5 z7Tn#PU;&cG-QC?aA$a5N5C|O{f;*XNa_+h3p1hfP^VY1Hw`N}ciV*0o?yma2y?=XG zphI7cRkuCeS_QcXN+u!iNWsFq?Y9jWMlFcEo=65gTi#ehCl2rAMtiG=pYqj!NuGpuS)wiw}juCqj{aVy@xK#&h4KJIoNS(Qd+0QO?bVHP@9) z)+6<(Dyb7sA6}1WUOSNx#zox(v5jIF$|Sl^zDLP7WjSg-d{IKcsqCxU%5G=a=}%DhL@H0!wYM@lI|qI z7w%WD-UCzZ6L_Kc$9_8*x*xnjI!%L%b*kuua=*Ugq+Vn5MfKG+?$~29z0`a+Ol!W; z`{56gF^38_mn>G?HMYNTpi*+KM|K$L%Q(>LY>v|_p*E|5=IbML2{XBg7eU2;p6>W=2>H@vYySz?i>13f z^^LjWHNv|vT0Fk8F9s)NPoqwW(|}=k}xaN%5xK9|p32PkUabz;BeDvfYs-Hvc z+<1SDNw<4#>-As?_AqXn)!dZY{%ZSK>sx2pO2^^yrJGUui1dqrDJzw&gPg+VE~4OP zDn+a5kOyCr3vdSZa|uKiP12z>kUs(N{Z6X$Fd}|L;~atCDbw8(!kJjWTfWUouI@mQ zzTTje-wpaX;0F%ZNwtH1?7jNP4fxCdip$PtEmPG9!Ne~U5aZ$|X_o3O4YqF|?oiHc zAGXEe621H`bc^of7FpdWl4q1k&pAagkvqw)wY9Ubzo3R$Hib1sP2;#KGlH1^rfqbH zX)EnAGzy?oY@JJy=HS$|QZQeBatjXjF5%?oOim}UCWL9zZhSsE9_wlWUTS9I^jVd4 zX<<~thC7ch*J0e-DtWeFvfrN#<06j*cb&UE=`pffk|xUfLgC9``(B5JQfYCauELlJ z>ueE|pISb?e!8ZJyt!KbD|$>#_5nP6{jzPV)S9;<$Fu|Qr~@Cz<}8;YXW_Et$X650 zv6c?Kd!OG7XqCxQs7BU*U#sL$={}Mn@dU>ws~#@Y7OvD(RGVga zb@`P#j{D2^b3oudPBeZh&0m=*cxyiB+pKAMA=%=RO`{XyrYrY&_kj|HJcCBi#euY@ z!i}}D9b;W36?dN2&R#5eQm)!Hc4O19bSV0uOswlrQ&UtDX@y){Kf|L9%~;~yk07K_ zGxKWFgUKAqdpVOZbN?ArZ(l7SXa0!zAm`R+iM-YDVi8*acvW@CG6x%?kjO|tG~zk@ z)OGOk`75%)U)FFHk-?+`WA4<5Wi=OJ&ddD+Xy0>&(LZGKUxyiu2BDWmew>cx59V#U zdC3{&lJOA-qUiJ4Du{10doi32i{%Zj)15p4=Fblh8P*pj1a<6W#gSNfSluf$L*ccm zW^oNlXdY;lMnOt8{*5wWO*ez*vITOB+6~;TEQyKJ(Q=T9H1xVIN6x$?tt32*m{4bh zqjoX4P968g(>bksF??L35K`Ar7oTD6*m$Fm49NYs%MSCQG>$&(-*~ywKr| zDNAoj9hrQ)#lsaq@BNi56?>Z$oZSOHeKDGt*A|H^6_6vQ`C^-SGW|0$+yhNMOsAHj zBxu=+Vy%=aBvbcs>~`hyW|(@Rmq-~N8p{!-W{S@NDG*D_w^7=ruO#iL>v}?F??_f> z*;#gw)2?)=J?!i(XW5;j%rWUk&WWoJD58W5@I})#`DgS`)B2$PY{OG={PkCd!rIQlRL<|U@Ok4y zzD@RfT{^pU8S6<;$(=6`Eagng-fbTZ#pNyr_vS~t0-_;3fCKEDT1O0cI~+Q6uCYa0 zW60YHQ7T7a)b-j3F7NXeE0t1dh_($;hRkBxr=nmzQCvXTeb^PhL10vK{qgAGON>gE zpX=JP{1W+5B3rDKc-SorKa-XplyC{oT8S7OlPLyW6x2u&Tb2<9M#<)lDn*yhQrP&X zNC_WPw=I>1EiZ~YQ@Rye1L>V)v6m;2KjJCR#Cb*rnxd%U@}(Y^LM2q`$b`}C^Wmi_ z%TZJSABMr%UL^6(fl1|Xrk$4j$ks{tGW>WI#jGxSxgIoy>{{G8HN`*U|1dsdxZdii z0He*!hyaa4Y#vuG?2ns>=3S(?aaEShu+ri>6gKIHJl&G)+G{S@}V- zYRWRMizE?JTe>+EWQEnAJg-$gN zz)bSbpviqCV}arU-n~{zNcMN)U^_84hxGs2llx2Xf>P%`c(KSp!8Og4%tA{`8zlG^ z3rahrqGg6kOvJo2@31Aw0{EPL)J%b<`g&EGIJQIJK=t81OipBdlSQz^3?kI}bkG&{ zZ&D3_-v{L#;s=bA85jNnOUQ#3=Z4ZYDQfG7{uD@oEpH;({`khgim6CN#dKyrDSX>^X^gR%Z!kp#1t2 z$Z0fLneJw9U#qLTnd@(U1_aa)1vva(d^O}M2DR{?0C7;qtcIOXvFoa6W&5&1 zU9Hppk#ah(c>^^@TW&}eQlsRqPu>ElW771fvBooYi(%|MN%fgB3q*vDVSOmafj zwD|A6bS2$)B~XTODbqc@$}9zB;-nt!A6a^JWLyO?O?Q> zZ=U|rxb?=&NW#bSK9G?mkv>1w4Wv0@_D*z-GRSC1LZ@|cUk*J7hFc2N@G>Rj8cID) z&FcF3(y4xr9lz+hlPX#Xh+Veo_zidW^T#%I)VMn=P3p*0tH*+4!XTsYQp2di87PZ@ zxQiEN#ts}-%h*o3AN{&YO_Jrjtikc-&@46u8oa}*!8mFQrZLHxD-puSG_r7B##dn;F?OWau zWNHbegWR#K%nRNS21Tw{+AQ4IEa|z=8tJ>e;sz;p)(FcKCv_QQ7JBSNMpM>#d$XYD8U@OYGbjPQbvwIBv!shfmZ-!V{!-_ zb}s&kNhsLhYkMV~=)1Tp&D;DVKB3$)^*Cwg>$44Xe5@+(cWz*}%Q3Sl|1EATWVNyU z+cEPn4|hu(92Ji61!_U-EgYQ;vb;J?$`nVAXz*J$*e*7Ijq{i!Hcup(J;y#m%rb)V zhpuOwwe0$MhD6OQV1Q95Z5GKk8aJ|WrMse=-DD8Ext~2;?#qA^OT1kt4t14&Ne5f!II#Zo1T{O>Z|QxQEPDvgpP2_-ZDeT0Cf+8Q z3|iK>FTr(6i?!l#FAp(6%(hDTp_iRH;57out=xR4XNp#?rsCiHi%PY+uL=TrqR*v~ zr&g!eIM$8bi&tQ-Sh4~bho8Npqx``2;>NguprXB|V&YfW?+8$`FqjIYj(DCS*FJ<^ zhFX8S=&AetTEYLmT~tm(qYKdW2Y6IS{(0=ZVxpq?*gJBbvYc)D>AeH#%mZXzuda)G zD=IKeq;B+3ZhkQiP1OHE#(~vA*sBv)NyXytafI>F$|e@V(O%k#q}Wskm}TEazYYz_JkBIQk{MoH{FL_QZoM^6!ZO~|sIM!$JSJ43S#dV=wjASC5pX*)Q6n7f4ks^oTCExQJXjBt&q@_u79;cSx zEQ7x;@4a~$)_ZPqerkQbN3XM>-sFCP`sFrEGcn%v8arlFDFoU9J9baDrR;X)={C2l4pO_AtF&{##G3l91lM z3z!I6?$0o^LnPz3X>Xe5t#Y8yYdM$GgF0=gh3&?$BzG-ME_vGpNpj^p1QGAIJoIT~n&lL}-~!eaue%)_hZtx|mV za3=xEX%Pt)g%3R<%tG@P{DH zD>@R33Bi{pMWg0k?n(ziY>UkW&5S10W$$E%op;#sdfqC39(5x>94}>`9@83)AD(YH zcwd6|px8BZ-__D$*Uux1fcq;Y#P{L2JR-#DG|8=r;d`No0mbvQ?N+N)1GP>KG{ggP z8uXrE%FabfafnmLeAMKJNuIhf`T&J}s%BlhMKxS<_$FO0*(z#PoR~yjs~EC1;o55J z;9jH#g}RG+{}COjr8Cr6Yz~@2BDf#1(?MFJ>BIAcggWg_(Xk6`As%?ijF;8Q@*uCJ z2%_hTbIo7>p!rcI7GN-&qu^D3NbXgIU(_iRS~8>=i1f4M+p=+X<-dpG{4LSMY4Wo z(YEl_hFo$tXHyJ|%LkEbLSstI+ZT!UlEkIgTMA(o0hl@c$08jc$zrx&({^-U1``c| z^Yg3l$NHNsBK(mT-`zN|ZA_3b4h1-@Lu6Tvv^^RRdtQy|ikuq>Y*ZxTWACc2v z>;b9?w@XbY;theSSb&4Ib(u1a^AAlwkc=^!R>A2R5!6EHmV%>W^9^IBnATn3yJQmvaz1!p&$%49j<^mCh30Eqtfl z=s7_fTLD77HSj{b$@JID4F0aH?xY~;Y{rD6e=GbfN|UrKD+1E@sw6tO5jQ1 zF11Y9ROYsItKd4!Lt_7>Tms@&doz8rqvFqYr&ugSj5>oRa&Zc}>0GRneD)N8SDDUI z_%JIpLGKsM+XfgY@f5bQ$z{p&K9EY)#&r9{g$xP3@$jlIV;`&Hw8Lag@p{9VIp2FXM! z;Ta5S;o=Y1aco~DOU50O5UBF#g7LWvJcQ~B(Uk*4BBa07HETfp>{v~(qe>Y3mx`gY zJMMk>djEcQ2iR*xLk5}1xt#bC{sB6%FjryelOmV{J(_vtp4=_;E*LAq?WI+q#Zco9oB zk7<)3ZM+~wEK(>5_OsIYsI3?zelZzRMNvTY?WMW99l^^bt_jJfVmgoC!yuspFW%cl z#Om*Hryu`h6^_8(w@VUR?=SYg@73fIkZMvmaB5LL7BWm&w3DYZ&b}#hkY1E3VExKe5w5?2aY=Ki z%z2?Y7c#s=*+OZ>+JrgoQ#JK%=QLJm9Ual-mK4pQH1~DK-BAuW>yepli~|98Ll>m) zNCI7$e`}LYg`CZVBhM_w>L#o&T7)wiB8*RopCQ4SYnCKR`GQF(CjS+9^|@;A#`~Up zf}I_hcU|C>j3q0pO0K;I-jL>UgerH8Yvk{=y?$C5otQDR{AgKp@pxddibA+Jc~D@V zhH;SHWP`8x7?r0}h*2$w4xh+%-{)`*n}jZ7 zDC|cdsPuDaNtdiO<*p`F(UIBvWC+==&dT6nb;Z>2bKt!W>r3$eT&|2+;tWXFuIP?x%@vbhXgOG7ewCtHkJ z88FGCE3Q)I^3jh=Ye=xmkHulq!nBUYztQ*>1q$fo5*~>&jJ&F#rk2^87qCz18j=?& zi{A>FknB|cR$n}+zx=Us0lgYR6JF6#t5$JM<#0F<+j&&vn@;bkJZqP-M;nBg?MHI!3(m|Bet>7({v{K?Gv%PgORzxPIg zD=j^#-zWIQ35rWV8px^v{(?LF?*g2qX&K_ECiL=Z2KU>QmwOW57@Dm9JWL9e#CGu> zN!fxTK75d-pU%imb@1rm35tGW7!Rjra;6fYr$;>)fANXv;yx42<*2kjCexP4bXnt@M-+@}Oa9g~@307x^WukTe#m1_o)6o_ufL%nXWY zJX2h`va~w}urm-JIg2C7Ho)6{E^;W* zBSr@%xQ2>P9h2GYh<3s4`xYS$j0`4eD$16L^9DA@MCF^bsZK*9uXnw1g!=E|zN2p4 z4X0~c*DL&r6H*;p8+D4m&p{YpSCF*+8oSk?lqQIjOYke=jIAkhgoU5{f>G>wuLq*^ zFfD~lcd1iPpH*tv2|Pwc-n&QgSkupL^^Wk@`OZ_-^L~Q6Zv3C*aP<9@Sy%B;BETfY zbo8M7pQ6=|%4>DfRCZvQ%UNlO^mP+;Qt&Qu=&9gf0U7^C>zh}3Jg~jyOj>9?SWLkS zUX_mNAC_*g$mm5mtsdbM*{9;yJvt4kSJAZ<<<65}Qb+$V!Ots9d`V1){spmUurjbv z1~Dx$Pq5$+BGZO5Z?}`a-JY0Ni@?P>Q??L`7ozY`=v!2mRL!!wn5}>om*qh_S-Hi7 z!exr)m9nC$$J;>;yM8ILKc9#T(Z^0qnXW;a6LYXbFR zKXXiZ5jXL~QcUrc;_;+t!!yyQoJ|jNJ3Zq_@^z0bj_!PQ9chEBN*U05j4^OME)n~p z=+xQ*EUzoQ^Ma7P=GVeZ4}#B1nm9HBo?Mo$PEMEKB^7NJ2)515+SdmZ1vrnK`8@Q+ zjd$MJdTQ^-geUMx+hWMG0`5TvZCx+J+Ki%eX_HeJ7R5kf``kKe3TgQ<$=a@@kCUK# zP^YEGt!xY0{H7zYO{f&oUeQ)9(F=Ezs}hUzDX+Qd3XPNv1kcodRPyINw(}1*VGqe} zJF^LB0Z{CSY+{wo3;IoIQx)RV+t;P*A+v<%^wj#aKwbz=RA?BUL*Zh-0tROT--DGl zCAr5&_~lOV8(1zo#G{G1RJo8=Ruphl0{2*?{nly^{s_M()=~nJMf5RQ#94hooinFR z{La+WmSC@q01?+hr&1BU4$x@ugw_a9@c%!=o&V2nI!=w2Ge4kO{u_VR8tD1hDdfR_ zuY3vR-X}n2{Nbohhy<>yt5Ynh4gG7Ak{{1H=mC->UK-H7LDfuX%!i+|T4V5^Nyi_LQhzlveL0#Gm?#F;4r4uR-RQl^ zsij0-Qca(2`nH7A=|Zrxz6WO`88yBEJ>$zP0>|s?vynV$-K+A7gUc$4gBdBq>r4D7 z%DTX3svT_lHiKF!6R(ZTV50r_i2z5Zn)**J+XgWH`%phQF>8q$n!DKY#47H=aS%Lc00jWc8vyHn|o1ex0>EU!)W8-jZKK z&B%!_w9;BN6J=YR<7(iO$rVpm`~>dw62s@ud<{r-bGw=MiORLSrd9u}0Ml-Zw6aRg zPqg%C%b_=P@n^N;t~>z&8*|Ao9dZ4cd4~c zamoo)P8Hx>qRbDWN_j)%Hbb4`s+0yxrTvr>1w(NcN5Q=TyP>zV{U7 z&ERRmSB}kx0!64_L?Qy-ik0Y)3P{SxJ%p0Mw)`nKx7VFd7n;4IZt@FAX55`gk;l)v zPNCbEI1MEzY9b81-pmS=7NLNn;AO3AoBD?4$&1zA$`Sj`#X3g-n~p(rI6e&s*;wY> zpz6J9i5attrx##t_gz~Oj}S)*4l?Z=o*q*xlFmY{Moegm5LB`}rNv)=0Ez4%Refl@ zX8as{_~t~6o?sq7lZVC#LLQ%;l^bxf=AK3J#kX?HdTYK)9N>rL81mWi9zL=L#*jXf z$y|vk+dozgqZU0V9Syu8#QfAK8pIK1#rnypz^yfOp%-A%6 z6{yt2pU8sQ8k_4#@cEkLK__Ny&EDroHA6zi2xA_QBQExq#?MvUiXe|$aL*iCgeG7> zaCb{L9^&P0d@jxo?DR3545sLC@9)Zeo*F>#@z$~VL7ps#p~&J5#cbFD>stl7r|Uqu z4OxoFt80QkJqOmHz3CJ<16O}2x@>-Ep3>0@#56zMI}X-bYK%2I7%GGsAPe|~lf$5f z9u4?x5%};=BBzYi^Ftgd>*bbt18Dw5IW?2|RUJa4Xw)AK^}ZW?^fCUnnCd|8jr`5t zjH1dX%vMS;u-c6~?PyG@yYgf>$ey`WpMvc*=~`SkHAvKtA0PTj(qJ`I1onn0&#{t$ z<6KfkaBoakdFQ{jH)RNYk3Q3UZhYMrQ+cflq%`ptn(s)&J|j2bqqu~mzW#7#7_3J` z$m?Q5ZLo8?AO6(H97}neLWfp^^89^(15R%f&Oxb!T7ZaP*mU9Iz^ZL`Hy3a`n*e`_ zjc77Ixbkidvg^2M>7pcT8=g2DJGaBcE7`U2-nMGf8e6Spo=Hc6{ONk&{b6*({#IhF zTYMftUt0R6G|adWsA|H(pR`25aeA@&Lc=AGAO(|q&8W7MpkE~X#DW=pMNX<{pds`$ z|GmWnEXZzTj6*4a0$0p#w&)7lOV#SN1KR>^j`b0}PKg9Itj9p6_91eMhL`b8ZCGEK zT6d1Nmp#B-kt*Qz1IJfeiZeNtCG8N_f)_Gngc3;z;~?|^95s|3)wHra{gz_+$zCyBpMf_Sk)3kFZ#*kz>e{>00#Q|e{?Cv2!7nX7y2Im=5M^I zROiQmercw}Z~7o*5Z+vi#GkE8SHO%5n2yy^E{wu(%c3+|Kdv$?OMEfOmBZzs@j$qQ?CI`kZ?x(&k%rPv zof@&kbYag~FXOCvj!%%W-ccf;4Tm_@G&>@un$M;WZ?7`5@OFFyBQteKI=*-EHI*x8 zTc85o8ab9Qv6pPsZ^^q9o|qp|<+0g;PZo+~vta)TJ&|69A<0B0kbN+0dqTMp7oBgQ z%4KN8HmrIT7&@aU@URfUGWd@166q+zQ?_*6*Vy3h^E(BC^`DeSG;P$#2xtz)hI^@r z)7j#vg%XcM2=L7P+HJUYM3+f*A_15wS{gG4V42(zp)8XP>Nm-nwTIt>=IV-~e8=87 z=-WAkKNwkfr35y#ONFh$di$#eiF>1ec1VwT+#t4-vT_v-V3}y;ea*BWrzW*Z$uI#F z9UMsOLMKr_J4i`dBf-z4-p|*LhHB6_;pr_;dS)Rt>=*5aYe<%4#yBoD%M{r^$6{h7 zl4xb!`RIItU7J^Pw$Hs*4C}Y8lYPCEjK`g+OVx|qC~>Lh$2uvOa&k!h zP*!^Icd2$dtXML=^BlNf<$8vT`d$ccliOwI3ERUU8zVuiRz=TUQXhJi-ejo)b%p8= zTPZTgRn%)-#H7RJ>tZis)i_%7XAWxdvp({Q0ddTb=Il@C3rm8^(gvsgCqfjUjn^lO z%~ozQ3mjORuTXHz%v>C)<}DA{8u3HXuc@vSfHPuDtyP{6j<@1J_j~ia_r43y=^+_FP61X>EAmJtu*|Z)$ zt5qBGp39`<`0r{?`SFM^WNPf+YIsHN6WRy5UvtMUH^*{%|Bey?p*TVtbR@7t zlk~AM{y+I8M;xkN;Lawn!B<0`P9(F)itxCO#&Q|}kz=Om43I6Dl|czc+|JJI`4R8q zGd!e1Fjw$YnvkU#;amd|;LYC7uwsFuUTOJ%_w%Euw2b|eA$s%a3ITU5fdO`|3sNK` zbc>(0Jc9={`t9TX1_^e zelj7`Kr5Bw-?g-q!m8K?M@PZHxIFh?$|Lw@i?~zI%Fe^&^rKY0tOiSU$2E@v+6&t~ zp00WYGPV1`qjhY=06{X6lL%@Zd}MdNTHM#7nO`~hZ9G{KB*d4LLBQc1_35gl%3saI zca5rdp@90^9Lgfyw1p*HcQaj&z}7~OsYMp`dY;1foIW>?q5U!cF{LjV+zx($@<&lN zN}@RQkhu?kU2{U;{91Dc)lfl%CeOweflP%WCqop3FuAd{UjScoDdQ8dy>Or_>Fe*~ zFu1~+TeiP-#^PWYXVXDTTk5h}?avA^{Q`+Qd3&=QXNC!Rxnvmn0HU5K-E$)~hXCM# zL_0O=VfH{)D=qxneN}YLEOd)_XSMgOE_#82eaN~dkKP3*#Mwn$g>39Q%=fx#EEgh- znb5q=O6?GlI#pKmzVCApxeIW4)upI+iE&kP%24}IZ9ChsCM>b*%lrhpqUL5b>rcAJ zj>T+Ol5v^;sCc>L=XkV>8okf@s6~qNgQviBYjwN5VX)OXEh0pQ&F%|94Yb~++UD;Y z#E>4~S$LHZ98^7@lm~GiNQXsBY*1D#ImG42mq((e##-AsTM8A9ZMpW@|3c9eXMSZb zJ$bT=oUcd`+<{%fwYc$f)Eh-)KH4IJn3>vzTJdK^2(n%mU#t}bI}eh6w`O5hFch_ z3voTwJ=s3uDe4P9IwY^!VFIj*IH5lSj`Lvcab3g~D`Iza)$w^_-^-rFa^F6*N+AbB zer#jcK8;Q@J`*6rxN5i&Pa3Rs&|a7ssVs0AZ@~&qVKsm=@VH##aP@CRU6tsH>s-Jo zh(sEvPXeBbrj7IC+=y&(HWK{F1lU-zEk_R6#bnPqj9)D>%d!PtCyLB;ZH{lXpV6v^ z-Xc>d0G|v~gt4zL9<|7Ex-ljvY(r~g#?ff)ff^Yaw!#@AhE4uaf$CjJPBvLLfWT|NFb9`D36$w_nICFa=Svj6f89RXbg@Rv<|@KmXM5LZ zzZIx(l*?Bz{?RZ~%>qic_L~jh1PW%Bw{5qV-aByMqmYtA@a#-8g!rBtvx}V6zYmp3 zYD4~(BkTpbzz$zFQJ85iP$k_UBSYUNB9qk*>p@Pf7nY@qG$4YFLX z=nnp4ZV8jG4f)r6)>LMdyx%sNhxE0f71D4ghhQg4YU@&pc5Qk}+}Sw}+?X^`{dfwI z9S&AEN5_c=RANFguh`FRO(Xa?ZOzA%Aw;+=huJ$u2C?OsY`IMuiED_a1_jdDfR(XW_Vzd3KkliW^n}Seb#Pn@GcuD)Ifu+&ab0l=_ux-KH zd%@dNYKBdn0h^3Uooc?6kKv%uBOPx5(Tdk$!bcy;yVxH`%BM9;b0T#}6W=@uYb^do6`S6Vqvx06~ykfMNjJx;f~ zVDdvBItRD;(k?}6vFel{BqiBKkjK7Y zi5JLjfj&PE3xv0===+FWxut(S@j&&dSaC30Hi00|xNsBi^W51vKrJkj2T57k0evu% z3vYfI6Rg1EF?TqTfRK{6eLI7Ua+;yNSk9}B)kJU(>6?_9ppgTRc#|r|-KP6(gJGC{`05WX&J+MG+XMU2zR(+Q(UI^cInRPg|z-<}J@z@OmBVFMDJ%=@qpjG*ktG}QM zbiFWq31y(F2Wh_@dAxz3Hi6n)Mv#foNlfc(;yU$wlsT1ILtW`WX6Bo(0zmRU_jiMlcUxQVRPA&A_J4{iJV8F(n&Z6tn>=3Eh z2wt^LZ{?s#FYvJBK`#qy&~Tkw(MK!eV)8B!6pA6n)n_c28l(B-(73Y}IFf~w_S$V8 zk$DbX0H;@;n>PeKz0skz)ulHVe+nbzbbp|3g(Wrigfm(aR|Q#az?)ahiji!4kF^ed zl9VjipcxwJDRg#Jg#fvVQ6ep9atUihqyKz;syD9=skxEg-nZRh{Y9^1u7g$kD{6*u zWOs5LPU0y8qq_8X#e@tE&hg}zv2wymluota1rss4G@ET$+9xXB#Js){*UNzmQA-JV;f zcF$zDhV8lH@05z<*%R6dbB_4oi*fV#W~OI!;&WucX+TD!!GwjdkM95Q>-J8FJHM`{|HgO^{T~nh zZecK%zII{yGn}C{8+4z+I3y9qDe0|vX?aMAY&B@ruU1VhteQ6cfL)_{&Y!-cYi}MRVTq$-RYl}u{ZKS~Y1?j76qyD23GZAGL-@Nv`qsv!Q z-73nk=Zc8oQNjJiZAg_Gn?Fo^rCb`Q2Wgfw$${Oi*_7S&7FGFIxMCcI9(G(LGggqP zuZwm9C=eyjt#k`USHji+4NGbC6kuN>aI;PzN~g3E9Qv0}zSpRtetA8hs#UfUAtjNC zZbEw^K;6}YkoV!%(Jp=>(!PN8M#Bh=*a(JtKd18f)2X-2s7(e~@Jnl9!X(`SNr?+R zk{D7Itb+>=(kRL(T6|aqIo|<~2{?+RpIPioB;B8ZJ(&(^*^GLyMzL2CeZ&OCVZT>A zH)jT;jXlT8a!AF8j6NT8*v+3OwEDCCnFZ#{Ug01uW5U zRT|1hhG4b0#n@b!h;g#rRJr=h63PcdThJEmfX{Ubr(|6SJQ+=1gS%wfttd1XeZ|Ft2+6u(Wy#?cFv>OMooTd%v<6fk1dRW z#X|FnkmhWREgc!9K-NxL%rQQLgS;5?lKJQC{H9xHGQCbaXuyYts40qji1ZH&p-N!J zlgMEqfZGg18YI^jNaJSQe)K*N2stO|;F>}kAUTG`ggGY_bq?4QDLyUx=y#T}(VRtD z3Pw@1aa%V~8FPhA81k(W2#Ow z$#M07lQ691IT5Gxv2V{Caed4Gj(-Dq_qsH{-J3eYAIa=B3b>+Z*g1stCj<%+s{(9^ zN>T1p#6f@G!b@n6K$6f~yS-5R&2Vgr_GX2Jnv>1IZEOBD@;im)E|v%V97odr{exVg z-Or2n82SmO8tP%Aeg{`e5uoLG)}@$;eK03Laj#7~3=z%L0A LS>bX){dfNjtdkE2 diff --git a/cleanurls/config.xml b/config.xml similarity index 100% rename from cleanurls/config.xml rename to config.xml diff --git a/cleanurls/empty_override/classes/Dispatcher.php b/empty_override/classes/Dispatcher.php similarity index 100% rename from cleanurls/empty_override/classes/Dispatcher.php rename to empty_override/classes/Dispatcher.php diff --git a/cleanurls/empty_override/classes/Link.php b/empty_override/classes/Link.php similarity index 100% rename from cleanurls/empty_override/classes/Link.php rename to empty_override/classes/Link.php diff --git a/cleanurls/empty_override/controllers/front/CategoryController.php b/empty_override/controllers/front/CategoryController.php similarity index 100% rename from cleanurls/empty_override/controllers/front/CategoryController.php rename to empty_override/controllers/front/CategoryController.php diff --git a/cleanurls/empty_override/controllers/front/CmsController.php b/empty_override/controllers/front/CmsController.php similarity index 100% rename from cleanurls/empty_override/controllers/front/CmsController.php rename to empty_override/controllers/front/CmsController.php diff --git a/cleanurls/empty_override/controllers/front/ManufacturerController.php b/empty_override/controllers/front/ManufacturerController.php similarity index 100% rename from cleanurls/empty_override/controllers/front/ManufacturerController.php rename to empty_override/controllers/front/ManufacturerController.php diff --git a/cleanurls/empty_override/controllers/front/ProductController.php b/empty_override/controllers/front/ProductController.php similarity index 100% rename from cleanurls/empty_override/controllers/front/ProductController.php rename to empty_override/controllers/front/ProductController.php diff --git a/cleanurls/empty_override/controllers/front/SupplierController.php b/empty_override/controllers/front/SupplierController.php similarity index 100% rename from cleanurls/empty_override/controllers/front/SupplierController.php rename to empty_override/controllers/front/SupplierController.php diff --git a/cleanurls/index.php b/index.php similarity index 100% rename from cleanurls/index.php rename to index.php diff --git a/cleanurls/logo.gif b/logo.gif similarity index 100% rename from cleanurls/logo.gif rename to logo.gif diff --git a/cleanurls/logo.png b/logo.png similarity index 100% rename from cleanurls/logo.png rename to logo.png diff --git a/cleanurls/override/classes/Dispatcher.php b/override/classes/Dispatcher.php similarity index 100% rename from cleanurls/override/classes/Dispatcher.php rename to override/classes/Dispatcher.php diff --git a/cleanurls/override/classes/Link.php b/override/classes/Link.php similarity index 100% rename from cleanurls/override/classes/Link.php rename to override/classes/Link.php diff --git a/cleanurls/override/classes/controller/FrontController.php b/override/classes/controller/FrontController.php similarity index 100% rename from cleanurls/override/classes/controller/FrontController.php rename to override/classes/controller/FrontController.php diff --git a/cleanurls/override/classes/index.php b/override/classes/index.php similarity index 100% rename from cleanurls/override/classes/index.php rename to override/classes/index.php diff --git a/cleanurls/override/controllers/front/CategoryController.php b/override/controllers/front/CategoryController.php similarity index 100% rename from cleanurls/override/controllers/front/CategoryController.php rename to override/controllers/front/CategoryController.php diff --git a/cleanurls/override/controllers/front/CmsController.php b/override/controllers/front/CmsController.php similarity index 100% rename from cleanurls/override/controllers/front/CmsController.php rename to override/controllers/front/CmsController.php diff --git a/cleanurls/override/controllers/front/ManufacturerController.php b/override/controllers/front/ManufacturerController.php similarity index 100% rename from cleanurls/override/controllers/front/ManufacturerController.php rename to override/controllers/front/ManufacturerController.php diff --git a/cleanurls/override/controllers/front/ProductController.php b/override/controllers/front/ProductController.php similarity index 100% rename from cleanurls/override/controllers/front/ProductController.php rename to override/controllers/front/ProductController.php diff --git a/cleanurls/override/controllers/front/SupplierController.php b/override/controllers/front/SupplierController.php similarity index 100% rename from cleanurls/override/controllers/front/SupplierController.php rename to override/controllers/front/SupplierController.php diff --git a/cleanurls/override/controllers/front/index.php b/override/controllers/front/index.php similarity index 100% rename from cleanurls/override/controllers/front/index.php rename to override/controllers/front/index.php diff --git a/cleanurls/override/controllers/index.php b/override/controllers/index.php similarity index 100% rename from cleanurls/override/controllers/index.php rename to override/controllers/index.php diff --git a/cleanurls/override/index.php b/override/index.php similarity index 100% rename from cleanurls/override/index.php rename to override/index.php From 9791c2146ae96d6f49fd568091d42a3082cf86f5 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 11 Mar 2015 17:28:20 +0100 Subject: [PATCH 047/174] just some code cleanup --- cleanurls.php | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/cleanurls.php b/cleanurls.php index 62c1387..fd94ae2 100644 --- a/cleanurls.php +++ b/cleanurls.php @@ -75,24 +75,31 @@ public function getContent() function checkWritable($directories) { - foreach ($directories as $dir) { - if (!file_exists(_PS_ROOT_DIR_ . '/' . $dir) && - strpos($dir, 'override/', 0) === 0 && - !copy(_PS_ROOT_DIR_ ."/modules/cleanurls/empty_".$dir, _PS_ROOT_DIR_ . "/" . $dir)) + foreach ($directories as $dir) { + if (!file_exists(_PS_ROOT_DIR_ . '/' . $dir) + && 0===strpos($dir, 'override/', 0) + && !copy(_PS_ROOT_DIR_ ."/modules/cleanurls/empty_".$dir, _PS_ROOT_DIR_ . "/" . $dir)) + return false; + if (!is_writable(_PS_ROOT_DIR_ . '/' . $dir)) return false; - if (!is_writable(_PS_ROOT_DIR_ . '/' . $dir)) - return false; } - return true; - } + return true; + } public function install() { - if (!$this->checkWritable(array("override/classes/Dispatcher.php", "override/classes/Link.php", - "override/controllers/front/CategoryController.php", "override/controllers/front/CmsController.php", "override/controllers/front/ManufacturerController.php","override/controllers/front/ProductController.php"),"override/controllers/front/SupplierController.php") - ) { - $this->_errors[] = $this->l('Files in /override folder are not writable, these files need to be writable: classes: Dispatcher.php, Link.php; controllers/front: CategoryController.php, CmsController.php, ManufacturerController.php, ProductController.php, SupplierController.php') -; + $overrides = array('override/classes/Dispatcher.php', + 'override/classes/Link.php', + 'override/controllers/front/CategoryController.php', + 'override/controllers/front/CmsController.php', + 'override/controllers/front/ManufacturerController.php', + 'override/controllers/front/ProductController.php', + 'override/controllers/front/SupplierController.php', + ); + if (!$this->checkWritable($overrides) + { + $this->_errors[] = $this->l('Files in /override folder are not writable, these files need to be writable:') + .'classes: Dispatcher.php, Link.php; controllers/front: CategoryController.php, CmsController.php, ManufacturerController.php, ProductController.php, SupplierController.php'); return false; } // add link_rewrite as index to improve search From 25b0b0124f99dd7c0dbe82a9e3b85b5f778d4a9e Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 11 Mar 2015 17:47:22 +0100 Subject: [PATCH 048/174] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 566f5c7..394ae1d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[ABOUT](https://github.com/ZiZuu-store/PrestaShop-modules-CleanURLs) +[ABOUT](https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs) =============================================================== It works on our 1.6.0.9. We are going to merge other users' contributions and ideas as soon as we note them and find the time to test. From 0b3830f9bd0613d42eba01c97eb8246ec51b3fa7 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 11 Mar 2015 17:48:21 +0100 Subject: [PATCH 049/174] Added security _PS_VERSION_ check --- cleanurls.php | 7 +++++-- logo.gif | Bin 1067 -> 0 bytes 2 files changed, 5 insertions(+), 2 deletions(-) delete mode 100644 logo.gif diff --git a/cleanurls.php b/cleanurls.php index fd94ae2..e8d1202 100644 --- a/cleanurls.php +++ b/cleanurls.php @@ -12,12 +12,15 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * -* @author Ha!*!*y +* @author ZiZuu.com * @copyright 2012-2013 Ha!*!*y * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* @code sorce: http://prestashop.com +* @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs */ +if (!defined('_PS_VERSION_')) + exit; + class cleanurls extends Module { public function __construct() diff --git a/logo.gif b/logo.gif deleted file mode 100644 index 9ea90ffbe20507136279458ce62a4c69b59bf33a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1067 zcmd7R`CFO=0KoCrXa2zQ*)y9xWv!W8&x)SWp2xO4rk0A5N9L^DVe`NPOvMXwX-xse z3mITc#gijE&;|&2j8_Ea3%+t+;x#;`PaDm&_4GU)Kh(4TqVHeu`Q`gb3MMiN8wdmf ztpE`6-LZEX5mAj1NQys_eBuJ-B#IJrxh)`~?RYdjFq#_iaZ3!E`6`APoWg!Hp))qK z=iK#P@ z%NR(`5rh5z{@z>1((gXE}bOmauWV8Y-%RiivtWNss?_kx;ipxC2)=z{Kj!`a5MywZYXZ|P5tKV>$QfJCl{#@U6HZ|!$PEOgxqMz%0qQH}tmSrAmA;wirB<)> z<*$x3=)iirB3o=uixsY*O;8b_NhZJ#Z>`=GLAriwgQM^iVlKoVI~$I#TW z4fPC|#$0agv{0K?DcxFfkB-WQTYGg)Lr~iw)X#D?-LrT0IG9`qYry%#fRod=#c4Jw z$+j{2`fSJM!k|t*pq(FlsAl*E`}P-xwn4tWgKy~gaj8wT#27QO#+O-QBl{;ahv#V( ztab`*Y>B5!YU!4HxJqyDq-R9po}V@=6kZ;<%9lB$QqMf-oD=N!j~>bXHE zH9ownh3QKkhSg0suCdG;_nhkkt7|-mhHtZsZkfckMah;`;Bt*@xF@`uigifoT^aus zo;lE}x1pKGu9*XuZbM{va^L*3#PV2X*_*OHm70E0ntTtOKBeQC{L!I$^GLn41ugFy z3_cs|vs<6qZ2M;WzQuW9aUZ(Z4_qtH4c_OP-QP7&{xAdogUM}DO0qxEHU!x-$y&=1wlipnvdM6IG-!%?Hl(4+d0S<7Ip}+pMZgm zzjh|FVo%Dy(9A5TtbL^vN?aaBoxaE-@07)#EJzXuXFL31&ik)}i8t(NeyqG&fRXB; z9BX;$;v32m9*jPn!kzpxQ-JLfV(7Ne&ncQ_*(qJADY8KOGB*sXCUeo)xSmU;NRj;< zg)Kmn78g@8^S9|AsIJ9VX+pLBkw`=l=QrMGq47=OXM(Yz!njZ0jYA*;kIn+*7C%2A F`aiBp`-A`h From 4e2ef94168a24afd205522c6dce9e2b6329f53f1 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 12 Mar 2015 19:39:16 +0100 Subject: [PATCH 050/174] Some coding standard --- cleanurls.php | 83 ++++++++++--------- config.xml | 4 +- empty_override/classes/Dispatcher.php | 4 - empty_override/classes/Link.php | 4 - .../controllers/front/CategoryController.php | 4 - .../controllers/front/CmsController.php | 4 - .../front/ManufacturerController.php | 4 - .../controllers/front/ProductController.php | 4 - .../controllers/front/SupplierController.php | 4 - index.php | 49 ++++++----- override/classes/Dispatcher.php | 2 +- override/classes/controller/index.php | 28 +++++++ override/classes/index.php | 29 ------- .../controllers/front/CategoryController.php | 17 ++-- .../controllers/front/ProductController.php | 28 ++----- override/controllers/front/index.php | 29 ------- override/controllers/index.php | 49 ++++++----- override/index.php | 49 ++++++----- 18 files changed, 157 insertions(+), 238 deletions(-) delete mode 100644 empty_override/classes/Dispatcher.php delete mode 100644 empty_override/classes/Link.php delete mode 100644 empty_override/controllers/front/CategoryController.php delete mode 100644 empty_override/controllers/front/CmsController.php delete mode 100644 empty_override/controllers/front/ManufacturerController.php delete mode 100644 empty_override/controllers/front/ProductController.php delete mode 100644 empty_override/controllers/front/SupplierController.php create mode 100644 override/classes/controller/index.php delete mode 100644 override/classes/index.php delete mode 100644 override/controllers/front/index.php diff --git a/cleanurls.php b/cleanurls.php index e8d1202..0b80dc8 100644 --- a/cleanurls.php +++ b/cleanurls.php @@ -1,77 +1,76 @@ -* @copyright 2012-2013 Ha!*!*y -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs -*/ + +/** + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * It is available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * + * DISCLAIMER + * This code is provided as is without any warranty. + * No promise of being safe or secure + * + * @author ZiZuu.com + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + */ if (!defined('_PS_VERSION_')) - exit; + exit; -class cleanurls extends Module +class CleanUrls extends Module { public function __construct() { $this->name = 'cleanurls'; $this->tab = 'seo'; - $this->version = '0.7'; - $this->need_instance = 0; + $this->version = '0.8'; $this->author = 'ZiZuu Store'; + $this->need_instance = 1; + $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); + $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('ZiZuu Clean URLs'); $this->description = $this->l('This override-Module allows you to remove URL ID\'s.'); + + $this->confirmUninstall = $this->l('Are you sure you want to uninstall "cleanurls"?'); } public function getContent() { $output = '
- On some versions you have to disable Cache save than open your shop home page than go back and enable it.
- Advanced Parameters > Performance > Clear Smarty cache

+ On some versions you have to disable Cache save than open your shop home page than go back and enable it.
+ Advanced Parameters > Performance > Clear Smarty cache

Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL off -> Save
Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL on -> Save

'; $sql = 'SELECT * FROM `'._DB_PREFIX_.'product_lang` - WHERE `link_rewrite` - IN (SELECT `link_rewrite` FROM `'._DB_PREFIX_.'product_lang` - GROUP BY `link_rewrite`, `id_lang` - HAVING count(`link_rewrite`) > 1)'; + WHERE `link_rewrite` + IN (SELECT `link_rewrite` FROM `'._DB_PREFIX_.'product_lang` + GROUP BY `link_rewrite`, `id_lang` + HAVING count(`link_rewrite`) > 1)'; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - { $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); - } if ($results = Db::getInstance()->ExecuteS($sql)) { - $output .= 'You need to fix duplicate URL entries
'; + $output .= 'You need to fix duplicate URL entries
'; foreach ($results AS $row) { $language_info = $this->context->language->getLanguage($row['id_lang']); - $output .= $row['name'].' ('.$row['id_product'] .') - '. $row['link_rewrite'].'
'; + $output .= $row['name'].' ('.$row['id_product'] .') - '. $row['link_rewrite'].'
'; $shop_info = $this->context->shop->getShop($language_info['id_shop']); - $output .= 'Language:'. $language_info['name'] . '
Shop:' . $shop_info['name'].'

'; + $output .= 'Language:'. $language_info['name'] . '
Shop:' . $shop_info['name'].'

'; } } else - { $output .= 'Nice you don\'t have any duplicate URL entries.'; - } return $output; } @@ -80,8 +79,8 @@ function checkWritable($directories) { foreach ($directories as $dir) { if (!file_exists(_PS_ROOT_DIR_ . '/' . $dir) - && 0===strpos($dir, 'override/', 0) - && !copy(_PS_ROOT_DIR_ ."/modules/cleanurls/empty_".$dir, _PS_ROOT_DIR_ . "/" . $dir)) + && 0 === strpos($dir, 'override/', 0) + && !copy(_PS_ROOT_DIR_ .'/modules/cleanurls/'.$dir, _PS_ROOT_DIR_ . '/' . $dir)) return false; if (!is_writable(_PS_ROOT_DIR_ . '/' . $dir)) return false; @@ -94,11 +93,12 @@ public function install() $overrides = array('override/classes/Dispatcher.php', 'override/classes/Link.php', 'override/controllers/front/CategoryController.php', - 'override/controllers/front/CmsController.php', - 'override/controllers/front/ManufacturerController.php', + 'override/controllers/front/CmsController.php', + 'override/controllers/front/ManufacturerController.php', 'override/controllers/front/ProductController.php', 'override/controllers/front/SupplierController.php', ); + if (!$this->checkWritable($overrides) { $this->_errors[] = $this->l('Files in /override folder are not writable, these files need to be writable:') @@ -109,18 +109,19 @@ public function install() $table_list = array('category_lang','cms_category_lang','cms_lang','product_lang'); foreach($table_list as $table) { - if(!Db::getInstance()->ExecuteS('SHOW INDEX FROM `'._DB_PREFIX_.$table.'` WHERE Key_name = \'link_rewrite\'')) + if (!Db::getInstance()->ExecuteS('SHOW INDEX FROM `'._DB_PREFIX_.$table.'` WHERE Key_name = \'link_rewrite\'')) Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_.$table.'` ADD INDEX ( `link_rewrite` )'); } if (!parent::install()) return false; + return true; } public function uninstall() { - copy(_PS_ROOT_DIR_ ."/modules/cleanurls/empty_override/classes/Dispatcher.php", _PS_ROOT_DIR_ . "/override/classes/Dispatcher.php"); + // TODO: restore previous override state if (!parent::uninstall()) return false; return true; diff --git a/config.xml b/config.xml index b1ad84e..73fb617 100644 --- a/config.xml +++ b/config.xml @@ -2,11 +2,11 @@ cleanurls - + 1 - 0 + 1 diff --git a/empty_override/classes/Dispatcher.php b/empty_override/classes/Dispatcher.php deleted file mode 100644 index 4cd11a4..0000000 --- a/empty_override/classes/Dispatcher.php +++ /dev/null @@ -1,4 +0,0 @@ - -* @copyright 2012-2013 Ha!*!*y -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* @code sorce: http://prestashop.com -*/ -header("Expires: Fri, 31 Dec 1999 23:59:59 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); +/** + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * It is available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * + * DISCLAIMER + * This code is provided as is without any warranty. + * No promise of being safe or secure + * + * @author ZiZuu.com + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + */ -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); +header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); -header("Location: ../"); -exit; \ No newline at end of file +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index ce77814..d72e500 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -58,7 +58,7 @@ class Dispatcher extends DispatcherCore ), 'product_rule' => array( 'controller' => 'product', - 'rule' => '{category:/}{rewrite}.html', + 'rule' => '{categories:/}{rewrite}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), 'rewrite' => array('regexp' => '[?_a-zA-Z0-9\pL\pS-]*', 'param' => 'product_rewrite'), diff --git a/override/classes/controller/index.php b/override/classes/controller/index.php new file mode 100644 index 0000000..ef6ab14 --- /dev/null +++ b/override/classes/controller/index.php @@ -0,0 +1,28 @@ + + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + */ + +header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/override/classes/index.php b/override/classes/index.php deleted file mode 100644 index 1f943d3..0000000 --- a/override/classes/index.php +++ /dev/null @@ -1,29 +0,0 @@ - -* @copyright 2012-2013 Ha!*!*y -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* @code sorce: http://prestashop.com -*/ - -header("Expires: Fri, 31 Dec 1999 23:59:59 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/override/controllers/front/CategoryController.php b/override/controllers/front/CategoryController.php index 1bb1f51..205a6e4 100644 --- a/override/controllers/front/CategoryController.php +++ b/override/controllers/front/CategoryController.php @@ -1,4 +1,8 @@ language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - { $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); - } $id_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - if($id_category > 0) - { + if ($id_category > 0) $_GET['id_category'] = $id_category; - } - else - { - //TODO: Do we need to send 404? - header('HTTP/1.1 404 Not Found'); - header('Status: 404 Not Found'); - } } parent::init(); diff --git a/override/controllers/front/ProductController.php b/override/controllers/front/ProductController.php index 17e4dea..9627789 100644 --- a/override/controllers/front/ProductController.php +++ b/override/controllers/front/ProductController.php @@ -1,4 +1,8 @@ language->id; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - { $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); - } $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - if($id_product > 0) + if ($id_product > 0) { $_GET['id_product'] = $id_product; } - else if(preg_match($url_id_pattern, $_SERVER['REQUEST_URI'], $url_split)) + elseif (preg_match($url_id_pattern, $_SERVER['REQUEST_URI'], $url_split)) { $url_id_product = $url_split[1]; @@ -41,21 +41,7 @@ public function init() $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if($id_product > 0) - { $_GET['id_product'] = $id_product; - } - else - { - //TODO: Do we need to send 404? - header('HTTP/1.1 404 Not Found'); - header('Status: 404 Not Found'); - } - } - else - { - //TODO: Do we need to send 404? - header('HTTP/1.1 404 Not Found'); - header('Status: 404 Not Found'); } } parent::init(); diff --git a/override/controllers/front/index.php b/override/controllers/front/index.php deleted file mode 100644 index 1f943d3..0000000 --- a/override/controllers/front/index.php +++ /dev/null @@ -1,29 +0,0 @@ - -* @copyright 2012-2013 Ha!*!*y -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* @code sorce: http://prestashop.com -*/ - -header("Expires: Fri, 31 Dec 1999 23:59:59 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/override/controllers/index.php b/override/controllers/index.php index 1f943d3..ef6ab14 100644 --- a/override/controllers/index.php +++ b/override/controllers/index.php @@ -1,29 +1,28 @@ -* @copyright 2012-2013 Ha!*!*y -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* @code sorce: http://prestashop.com -*/ -header("Expires: Fri, 31 Dec 1999 23:59:59 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); +/** + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * It is available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * + * DISCLAIMER + * This code is provided as is without any warranty. + * No promise of being safe or secure + * + * @author ZiZuu.com + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + */ -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); +header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); -header("Location: ../"); -exit; \ No newline at end of file +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/override/index.php b/override/index.php index 1f943d3..ef6ab14 100644 --- a/override/index.php +++ b/override/index.php @@ -1,29 +1,28 @@ -* @copyright 2012-2013 Ha!*!*y -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* @code sorce: http://prestashop.com -*/ -header("Expires: Fri, 31 Dec 1999 23:59:59 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); +/** + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * It is available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * + * DISCLAIMER + * This code is provided as is without any warranty. + * No promise of being safe or secure + * + * @author ZiZuu.com + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + */ -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); +header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); -header("Location: ../"); -exit; \ No newline at end of file +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; From cb6a7d3309188187c0c63010c0e07af859af5bef Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 12 Mar 2015 19:39:39 +0100 Subject: [PATCH 051/174] added index.php --- override/classes/index.php | 28 ++++++++++++++++++++++++++++ override/controllers/front/index.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 override/classes/index.php create mode 100644 override/controllers/front/index.php diff --git a/override/classes/index.php b/override/classes/index.php new file mode 100644 index 0000000..ef6ab14 --- /dev/null +++ b/override/classes/index.php @@ -0,0 +1,28 @@ + + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + */ + +header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/override/controllers/front/index.php b/override/controllers/front/index.php new file mode 100644 index 0000000..ef6ab14 --- /dev/null +++ b/override/controllers/front/index.php @@ -0,0 +1,28 @@ + + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + */ + +header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; From bdc890093071b2d98d2b927a30679aa6551c200c Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 13 Mar 2015 11:12:52 +0100 Subject: [PATCH 052/174] Cleaned git related giles --- .gitattributes | 22 ----- .gitignore | 217 +------------------------------------------------ 2 files changed, 3 insertions(+), 236 deletions(-) delete mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 412eeda..0000000 --- a/.gitattributes +++ /dev/null @@ -1,22 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto - -# Custom for Visual Studio -*.cs diff=csharp -*.sln merge=union -*.csproj merge=union -*.vbproj merge=union -*.fsproj merge=union -*.dbproj merge=union - -# Standard to msysgit -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index b9d6bd9..81a856e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,215 +1,4 @@ -################# -## Eclipse -################# - -*.pydevproject -.project -.metadata -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.classpath -.settings/ -.loadpath - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath - - -################# -## Visual Studio -################# - -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results - -[Dd]ebug/ -[Rr]elease/ -x64/ -build/ -[Bb]in/ -[Oo]bj/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -*_i.c -*_p.c -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.log -*.scc - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -*.ncrunch* -.*crunch*.local.xml - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.Publish.xml -*.pubxml - -# NuGet Packages Directory -## TODO: If you have NuGet Package Restore enabled, uncomment the next line -#packages/ - -# Windows Azure Build Output -csx -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -sql/ -*.Cache -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.[Pp]ublish.xml -*.pfx -*.publishsettings - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -App_Data/*.mdf -App_Data/*.ldf - -############# -## Windows detritus -############# - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Mac crap +.htaccess +.svn .DS_Store - - -############# -## Python -############# - -*.py[co] - -# Packages -*.egg -*.egg-info -dist/ -build/ -eggs/ -parts/ -var/ -sdist/ -develop-eggs/ -.installed.cfg - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -.coverage -.tox - -#Translations -*.mo - -#Mr Developer -.mr.developer.cfg +.*.swp From 399e334e027cf07e60cb2cf2d9994b246ecb11be Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 13 Mar 2015 12:19:09 +0100 Subject: [PATCH 053/174] - fixed parse error on cleanurls.php - fixed PS coding standards adeherence - security fix: use pSQL() to sanitize user values - some code cleanup --- cleanurls.php | 4 +- override/classes/Dispatcher.php | 18 ++++++ override/classes/Link.php | 18 ++++++ .../classes/controller/FrontController.php | 55 +++++++++--------- .../controllers/front/CategoryController.php | 26 ++++++--- override/controllers/front/CmsController.php | 56 ++++++++----------- .../front/ManufacturerController.php | 41 ++++++++------ .../controllers/front/ProductController.php | 33 ++++++----- .../controllers/front/SupplierController.php | 42 +++++++------- 9 files changed, 173 insertions(+), 120 deletions(-) diff --git a/cleanurls.php b/cleanurls.php index 0b80dc8..891c76d 100644 --- a/cleanurls.php +++ b/cleanurls.php @@ -99,9 +99,9 @@ public function install() 'override/controllers/front/SupplierController.php', ); - if (!$this->checkWritable($overrides) + if (!$this->checkWritable($overrides)) { - $this->_errors[] = $this->l('Files in /override folder are not writable, these files need to be writable:') + $this->_errors[] = $this->l('Files in /override folder are not writable, these files need to be writable:' .'classes: Dispatcher.php, Link.php; controllers/front: CategoryController.php, CmsController.php, ManufacturerController.php, ProductController.php, SupplierController.php'); return false; } diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index d72e500..673465d 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -1,4 +1,22 @@ + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + */ + class Dispatcher extends DispatcherCore { /** diff --git a/override/classes/Link.php b/override/classes/Link.php index cde8a24..0e6414a 100644 --- a/override/classes/Link.php +++ b/override/classes/Link.php @@ -1,4 +1,22 @@ + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + */ + class Link extends LinkCore { public function __construct($protocol_link = null, $protocol_content = null) diff --git a/override/classes/controller/FrontController.php b/override/classes/controller/FrontController.php index 897e5b4..eaecb7b 100644 --- a/override/classes/controller/FrontController.php +++ b/override/classes/controller/FrontController.php @@ -1,45 +1,44 @@ -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ + +/** + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * It is available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * + * DISCLAIMER + * This code is provided as is without any warranty. + * No promise of being safe or secure + * + * @author ZiZuu.com + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + */ class FrontController extends FrontControllerCore { - public function __construct() + public function __construct() { parent::__construct(); } protected function canonicalRedirection($canonical_url = '') { - $excluded_keys = array('product_rewrite', 'category_rewrite', 'manufacturer_rewrite', 'supplier_rewrite', - 'cms_rewrite', 'cms_category_rewrite'); + $excluded_keys = array( + 'product_rewrite', + 'category_rewrite', + 'manufacturer_rewrite', + 'supplier_rewrite', + 'cms_rewrite', + 'cms_category_rewrite', + ); + // hack original behavior on cananocalRedirection: remove *_rewrite from _GET $unfiltered_GET = $_GET; $_GET = array_diff_key($_GET, array_flip($excluded_keys)); parent::canonicalRedirection($canonical_url); $_GET = $unfiltered_GET; } } - diff --git a/override/controllers/front/CategoryController.php b/override/controllers/front/CategoryController.php index 205a6e4..b560d7d 100644 --- a/override/controllers/front/CategoryController.php +++ b/override/controllers/front/CategoryController.php @@ -1,25 +1,35 @@ + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs */ class CategoryController extends CategoryControllerCore { public function init() { - if (Tools::getValue('category_rewrite')) + if ($category_rewrite = Tools::getValue('category_rewrite')) { - $category_rewrite = Tools::getValue('category_rewrite'); - $sql = 'SELECT `id_category` FROM `'._DB_PREFIX_.'category_lang` - WHERE `link_rewrite` = \''.$category_rewrite.'\' AND `id_lang` = '. Context::getContext()->language->id; + WHERE `link_rewrite` = \''.pSQL($category_rewrite).'\' AND `id_lang` = '.Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); - - $id_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + $id_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_category > 0) $_GET['id_category'] = $id_category; } diff --git a/override/controllers/front/CmsController.php b/override/controllers/front/CmsController.php index 6061525..e6a1f13 100644 --- a/override/controllers/front/CmsController.php +++ b/override/controllers/front/CmsController.php @@ -1,62 +1,54 @@ + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + */ + class CmsController extends CmsControllerCore { public function init() { - if (Tools::getValue('cms_rewrite')) + if ($cms_rewrite = Tools::getValue('cms_rewrite')) { - $rewrite_url = Tools::getValue('cms_rewrite'); - $sql = 'SELECT l.`id_cms` FROM `'._DB_PREFIX_.'cms_lang` l LEFT JOIN `'._DB_PREFIX_.'cms_shop` s ON (l.`id_cms` = s.`id_cms`) - WHERE l.`link_rewrite` = \''.$rewrite_url.'\''; + WHERE l.`link_rewrite` = \''.pSQL($cms_rewrite).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); - } $id_cms = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - - if($id_cms > 0) - { + if ($id_cms > 0) $_GET['id_cms'] = $id_cms; - } - else - { - //TODO: Do we need to send 404? - header('HTTP/1.1 404 Not Found'); - header('Status: 404 Not Found'); - } } - else if (Tools::getValue('cms_category_rewrite')) + elseif ($cms_category_rewrite = Tools::getValue('cms_category_rewrite')) { - $rewrite_url = Tools::getValue('cms_category_rewrite'); - $sql = 'SELECT `id_cms_category` FROM `'._DB_PREFIX_.'cms_category_lang` - WHERE `link_rewrite` = \''.$rewrite_url.'\''; + WHERE `link_rewrite` = \''.pSQL($cms_category_rewrite).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); - } $id_cms_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - - if($id_cms_category > 0) - { + if ($id_cms_category > 0) $_GET['id_cms_category'] = $id_cms_category; - } - else - { - //TODO: Do we need to send 404? - header('HTTP/1.1 404 Not Found'); - header('Status: 404 Not Found'); - } } + parent::init(); } } diff --git a/override/controllers/front/ManufacturerController.php b/override/controllers/front/ManufacturerController.php index 0cde4fe..4ad9bf5 100644 --- a/override/controllers/front/ManufacturerController.php +++ b/override/controllers/front/ManufacturerController.php @@ -1,42 +1,49 @@ + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + */ + class ManufacturerController extends ManufacturerControllerCore { public function init() { if (Tools::getValue('manufacturer_rewrite')) { - $name_manufacturer = str_replace('-', '%', Tools::getValue('manufacturer_rewrite')); + $manufacturer_rewrite = str_replace('-', '%', Tools::getValue('manufacturer_rewrite')); - // - // TODO:: need to core update Prestashop code and - // DB for link_rewrite for manufacturers - // Should we use the Mysql FullText Index Search ?? - // + /* TODO: need to core update Prestashop code and DB for link_rewrite for manufacturers + * Should we use the Mysql FullText Index Search ?? + */ $sql = 'SELECT m.`id_manufacturer` FROM `'._DB_PREFIX_.'manufacturer` m LEFT JOIN `'._DB_PREFIX_.'manufacturer_shop` s ON (m.`id_manufacturer` = s.`id_manufacturer`) - WHERE m.`name` LIKE \''.$name_manufacturer.'\''; + WHERE m.`name` LIKE \''.pSQL($manufacturer_rewrite).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); - } $id_manufacturer = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - - if($id_manufacturer > 0) + if ($id_manufacturer > 0) { $_GET['id_manufacturer'] = $id_manufacturer; $_GET['noredirect'] = 1; } - else - { - //TODO: Do we need to send 404? - header('HTTP/1.1 404 Not Found'); - header('Status: 404 Not Found'); - } } + parent::init(); } } diff --git a/override/controllers/front/ProductController.php b/override/controllers/front/ProductController.php index 9627789..7ea9d8f 100644 --- a/override/controllers/front/ProductController.php +++ b/override/controllers/front/ProductController.php @@ -1,49 +1,54 @@ + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs */ class ProductController extends ProductControllerCore { public function init() { - if (Tools::getValue('product_rewrite')) + if ($product_rewrite = Tools::getValue('product_rewrite')) { $url_id_pattern = '/.*?([0-9]+)\-([a-zA-Z0-9-]*)(\.html)?/'; - $rewrite_url = Tools::getValue('product_rewrite'); $sql = 'SELECT `id_product` FROM `'._DB_PREFIX_.'product_lang` - WHERE `link_rewrite` = \''.$rewrite_url.'\' AND `id_lang` = '. Context::getContext()->language->id; + WHERE `link_rewrite` = \''.pSQL($product_rewrite).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - if ($id_product > 0) - { $_GET['id_product'] = $id_product; - } elseif (preg_match($url_id_pattern, $_SERVER['REQUEST_URI'], $url_split)) { - $url_id_product = $url_split[1]; - $sql = 'SELECT `id_product` FROM `'._DB_PREFIX_.'product_lang` - WHERE `id_product` = \''.$url_id_product.'\' AND `id_lang` = '. Context::getContext()->language->id; + WHERE `id_product` = \''.pSQL($url_split[1]).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - { $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); - } $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - if($id_product > 0) $_GET['id_product'] = $id_product; } } + parent::init(); } } diff --git a/override/controllers/front/SupplierController.php b/override/controllers/front/SupplierController.php index cfdfbaf..ec34b6c 100644 --- a/override/controllers/front/SupplierController.php +++ b/override/controllers/front/SupplierController.php @@ -1,40 +1,44 @@ + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + */ + class SupplierController extends SupplierControllerCore { public function init() { - if (Tools::getValue('supplier_rewrite')) + if ($supplier_rewrite = Tools::getValue('supplier_rewrite')) { - $name_supplier = str_replace('-', '%', Tools::getValue('supplier_rewrite')); + $supplier_rewrite = str_replace('-', '%', $supplier_rewrite); - // - // TODO:: need to core update Prestashop code and - // DB for link_rewrite for suppliers - // Should we use the Mysql FullText Index Search ?? - // + /* TODO: need to core update Prestashop code and DB for link_rewrite for suppliers + * Should we use the Mysql FullText Index Search ?? + */ $sql = 'SELECT sp.`id_supplier` FROM `'._DB_PREFIX_.'supplier` sp LEFT JOIN `'._DB_PREFIX_.'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`) - WHERE sp.`name` LIKE \''.$name_supplier.'\''; + WHERE sp.`name` LIKE \''.pSQL($supplier_rewrite).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); - } $id_supplier = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - if($id_supplier > 0) - { $_GET['id_supplier'] = $id_supplier; - } - else - { - //TODO: Do we need to send 404? - header('HTTP/1.1 404 Not Found'); - header('Status: 404 Not Found'); - } } parent::init(); From 02fe391180b7bf3a1e302d69256ec1bde51e342a Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 13 Mar 2015 12:31:21 +0100 Subject: [PATCH 054/174] - just minimal on README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 394ae1d..a22e8bc 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ This is __MANDATORY__ * manufacturers: manufactures/{rewrite} * suppliers: suppliers/{rewrite} * CMS page: info/{rewrite} -* CMS category: info/{rewrite}/ -* modules: modules/{module}{/:controller} +* CMS category: info/{rewrite}**/** +* modules: module/{module}{/:controller} You can replace "info" with whatever you want given that it does not conflicts with a category name From 35fd83922fad2eb72ebba67892d7acacbf3d9f60 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 13 Mar 2015 13:21:21 +0100 Subject: [PATCH 055/174] * Again security fixes over SQL injection * introduced _MODULE_NAME constant * again code cleanup --- cleanurls.php | 10 +++-- override/classes/Dispatcher.php | 68 ++++++++++++--------------------- override/classes/Link.php | 31 +++++++-------- 3 files changed, 47 insertions(+), 62 deletions(-) diff --git a/cleanurls.php b/cleanurls.php index 891c76d..1c0c0fb 100644 --- a/cleanurls.php +++ b/cleanurls.php @@ -22,9 +22,11 @@ class CleanUrls extends Module { + const _MODULE_NAME = 'cleanurls'; + public function __construct() { - $this->name = 'cleanurls'; + $this->name = _MODULE_NAME; $this->tab = 'seo'; $this->version = '0.8'; $this->author = 'ZiZuu Store'; @@ -37,7 +39,7 @@ public function __construct() $this->displayName = $this->l('ZiZuu Clean URLs'); $this->description = $this->l('This override-Module allows you to remove URL ID\'s.'); - $this->confirmUninstall = $this->l('Are you sure you want to uninstall "cleanurls"?'); + $this->confirmUninstall = $this->l('Are you sure you want to uninstall "'._MODULE_NAME.'"?'); } public function getContent() @@ -54,7 +56,6 @@ public function getContent() IN (SELECT `link_rewrite` FROM `'._DB_PREFIX_.'product_lang` GROUP BY `link_rewrite`, `id_lang` HAVING count(`link_rewrite`) > 1)'; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); @@ -75,12 +76,13 @@ public function getContent() return $output; } + // TODO: rewrite to have a robust install process function checkWritable($directories) { foreach ($directories as $dir) { if (!file_exists(_PS_ROOT_DIR_ . '/' . $dir) && 0 === strpos($dir, 'override/', 0) - && !copy(_PS_ROOT_DIR_ .'/modules/cleanurls/'.$dir, _PS_ROOT_DIR_ . '/' . $dir)) + && !copy(_PS_ROOT_DIR_ .'/modules/'._MODULE_NAME.'/'.$dir, _PS_ROOT_DIR_ . '/' . $dir)) return false; if (!is_writable(_PS_ROOT_DIR_ . '/' . $dir)) return false; diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index 673465d..b1f271a 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -113,7 +113,7 @@ class Dispatcher extends DispatcherCore 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9\pL-]*'), 'meta_title' => array('regexp' => '[_a-zA-Z0-9\pL-]*'), 'parent_categories' => array('regexp' => '[/_a-zA-Z0-9\pL-]*'), - ), + ), ), ); @@ -131,12 +131,9 @@ public static function isProductLink($short_link) $sql = 'SELECT `id_product` FROM `'._DB_PREFIX_.'product_lang` - WHERE `link_rewrite` = \''.$explode_product_link[$count-1].'\' AND `id_lang` = '. Context::getContext()->language->id; - + WHERE `link_rewrite` = \''.pSQL($explode_product_link[$count-1]).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - { $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); - } $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); @@ -155,12 +152,9 @@ public static function isCategoryLink($short_link) $categories = explode('/', $short_link); $sql = 'SELECT `id_category` FROM `'._DB_PREFIX_.'category_lang` - WHERE `link_rewrite` = \''.$categories[0].'\' AND `id_lang` = '. Context::getContext()->language->id; - + WHERE `link_rewrite` = \''.pSQL($categories[0]).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - { $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); - } $id_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); @@ -182,12 +176,9 @@ public static function isCmsLink($short_link) $sql = 'SELECT l.`id_cms` FROM `'._DB_PREFIX_.'cms_lang` l LEFT JOIN `'._DB_PREFIX_.'cms_shop` s ON (l.`id_cms` = s.`id_cms`) - WHERE l.`link_rewrite` = \''.$explode_cms_link[$count-1].'\''; - + WHERE l.`link_rewrite` = \''.pSQL($explode_cms_link[$count-1]).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); - } $id_cms = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); @@ -206,17 +197,14 @@ public static function isManufacturerLink($short_link) $explode_manufacturer_link = explode('/', $short_link); $count = count($explode_manufacturer_link); - $name_manufacturer = str_replace('-', '%', $explode_manufacturer_link[$count-1]); + $manufacturer = str_replace('-', '%', $explode_manufacturer_link[$count-1]); $sql = 'SELECT m.`id_manufacturer` FROM `'._DB_PREFIX_.'manufacturer` m LEFT JOIN `'._DB_PREFIX_.'manufacturer_shop` s ON (m.`id_manufacturer` = s.`id_manufacturer`) - WHERE m.`name` LIKE \''.$name_manufacturer.'\''; - + WHERE m.`name` LIKE \''.pSQL($manufacturer).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); - } $id_manufacturer = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); @@ -235,17 +223,14 @@ public static function isSupplierLink($short_link) $explode_supplier_link = explode('/', $short_link); $count = count($explode_supplier_link); - $name_supplier = str_replace('-', '%', $explode_supplier_link[$count-1]); + $supplier = str_replace('-', '%', $explode_supplier_link[$count-1]); $sql = 'SELECT sp.`id_supplier` FROM `'._DB_PREFIX_.'supplier` sp LEFT JOIN `'._DB_PREFIX_.'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`) - WHERE sp.`name` LIKE \''.$name_supplier.'\''; - + WHERE sp.`name` LIKE \''.pSQL($supplier).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); - } $id_supplier = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); @@ -260,14 +245,15 @@ public static function isSupplierLink($short_link) public function getController($id_shop = null) { if (defined('_PS_ADMIN_DIR_')) - $_GET['controllerUri'] = Tools::getvalue('controller'); + $_GET['controllerUri'] = Tools::getvalue('controller'); + if ($this->controller) { $_GET['controller'] = $this->controller; return $this->controller; } - if ($id_shop === null) + if (null === $id_shop) $id_shop = (int)Context::getContext()->shop->id; $controller = Tools::getValue('controller'); @@ -277,7 +263,7 @@ public function getController($id_shop = null) $controller = $m[1]; if (isset($_GET['controller'])) $_GET[$m[2]] = $m[3]; - else if (isset($_POST['controller'])) + elseif (isset($_POST['controller'])) $_POST[$m[2]] = $m[3]; } @@ -314,10 +300,8 @@ public function getController($id_shop = null) case 'supplier': case 'manufacturer': // these two can be processed in normal way and also as template - if(strpos($route['rule'], '{') !== false) - { + if (false !== strpos($route['rule'], '{')) $isTemplate = true; - } break; case 'cms': @@ -326,14 +310,12 @@ public function getController($id_shop = null) break; case 'category': // category can be processed in two ways - if(strpos($route['rule'], 'selected_filters') === false) - { + if (false === strpos($route['rule'], 'selected_filters')) $isTemplate = true; - } break; } - if($isTemplate == false) + if ($isTemplate == false) { $findRoute = $route; break; @@ -342,17 +324,16 @@ public function getController($id_shop = null) } // if route is not found, we have to find rewrite link in database - if(empty($findRoute)) + if (empty($findRoute)) { - $req_url = substr($this->request_uri, 1); // remove '/' from begining - $req_url = explode('?', $req_url); // remove all after '?' - $short_link = $req_url[0]; + // get the path from requested URI, and remove "/" at the beginning + $short_link = ltrim(parse_url($this->request_uri, PHP_URL_PATH), '/'); - if(!Dispatcher::isProductLink($short_link)) - if(!Dispatcher::isCategoryLink($short_link)) - if(!Dispatcher::isCmsLink($short_link)) - if(!Dispatcher::isManufacturerLink($short_link)) - if(!Dispatcher::isSupplierLink($short_link)) + if (!Dispatcher::isProductLink($short_link)) + if (!Dispatcher::isCategoryLink($short_link)) + if (!Dispatcher::isCmsLink($short_link)) + if (!Dispatcher::isManufacturerLink($short_link)) + if (!Dispatcher::isSupplierLink($short_link)) {} else $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['supplier_rule']; @@ -366,7 +347,7 @@ public function getController($id_shop = null) $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['product_rule']; } - if(!empty($findRoute)) + if (!empty($findRoute)) { if (preg_match($findRoute['regexp'], $this->request_uri, $m)) { @@ -405,6 +386,7 @@ public function getController($id_shop = null) $this->controller = str_replace('-', '', $this->controller); $_GET['controller'] = $this->controller; + return $this->controller; } } diff --git a/override/classes/Link.php b/override/classes/Link.php index 0e6414a..5bf3451 100644 --- a/override/classes/Link.php +++ b/override/classes/Link.php @@ -12,9 +12,9 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author ZiZuu.com - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @author ZiZuu.com + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs */ class Link extends LinkCore @@ -25,6 +25,7 @@ public function __construct($protocol_link = null, $protocol_content = null) /* TODO * add a configuration switch to hide or show the Home category + // Re-add Home category Link::$category_disable_rewrite = array_diff(Link::$category_disable_rewrite, array(Configuration::get('PS_HOME_CATEGORY'))); */ @@ -39,7 +40,7 @@ public function __construct($protocol_link = null, $protocol_content = null) * @param string $selected_filters Url parameter to autocheck filters of the module blocklayered * @return string */ - public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $selected_filters = NULL, $id_shop = NULL, $relative_protocol = false) + public function getCategoryLink($category, $alias = null, $id_lang = null, $selected_filters = null, $id_shop = null, $relative_protocol = false) { if (!$id_lang) $id_lang = Context::getContext()->language->id; @@ -51,10 +52,10 @@ public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $sele // Set available keywords $params = array(); - $params['id'] = $category->id; - $params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias; - $params['meta_keywords'] = Tools::str2url($category->getFieldByLang('meta_keywords')); - $params['meta_title'] = Tools::str2url($category->getFieldByLang('meta_title')); + $params['id'] = $category->id; + $params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias; + $params['meta_keywords'] = Tools::str2url($category->getFieldByLang('meta_keywords')); + $params['meta_title'] = Tools::str2url($category->getFieldByLang('meta_title')); // Selected filters is used by the module blocklayered $selected_filters = is_null($selected_filters) ? '' : $selected_filters; @@ -69,10 +70,10 @@ public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $sele $dispatcher = Dispatcher::getInstance(); - //XXX: replace 'category_rule' with $rule ? + // XXX: replace 'category_rule' with $rule ? if ($dispatcher->hasKeyword('category_rule', $id_lang, 'parent_categories')) { - //Retrieve all parent categories + // Retrieve all parent categories $cats = array(); foreach ($category->getParentsCategories($id_lang) as $cat) { @@ -83,7 +84,7 @@ public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $sele $cats[] = $cat['link_rewrite']; } } - // Add the URL slashes among categories, in reverse order + // add the URL slashes among categories, in reverse order $params['parent_categories'] = implode('/', array_reverse($cats)); } @@ -103,7 +104,7 @@ public function getCategoryLink($category, $alias = NULL, $id_lang = NULL, $sele */ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, $pagination = false, $array = false) { - // If no parameter $type, try to get it by using the controller name + // if no parameter $type, try to get it by using the controller name if (!$type && !$id_object) { $method_name = 'get'.Dispatcher::getInstance()->getController().'Link'; @@ -132,16 +133,16 @@ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, foreach ($_GET as $k => $value) { - // strip var like category_rewrite from url + // strip var of the form "*_rewrite" from url if ($k != 'id_'.$type && $k != $type.'_rewrite' && $k != 'controller') { if (Configuration::get('PS_REWRITING_SETTINGS') && ($k == 'isolang' || $k == 'id_lang')) continue; + $if_nb = (!$nb || ($nb && !in_array($k, $vars_nb))); $if_sort = (!$sort || ($sort && !in_array($k, $vars_sort))); $if_pagination = (!$pagination || ($pagination && !in_array($k, $vars_pagination))); if ($if_nb && $if_sort && $if_pagination) - { if (!is_array($value)) $vars[urlencode($k)] = $value; else @@ -152,7 +153,6 @@ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, $vars[urldecode($data[0])] = $data[1]; } } - } } } @@ -169,6 +169,7 @@ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, if (!$this->allow == 1) $vars['controller'] = Dispatcher::getInstance()->getController(); + return $vars; } } From 42a1ee6495e55ed71089454fa1392deedcbfac01 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 13 Mar 2015 16:01:08 +0100 Subject: [PATCH 056/174] * removed install stuff, parent already do the job --- cleanurls.php | 49 +++++---------------------------- override/classes/Dispatcher.php | 2 +- 2 files changed, 8 insertions(+), 43 deletions(-) diff --git a/cleanurls.php b/cleanurls.php index 1c0c0fb..cc89b14 100644 --- a/cleanurls.php +++ b/cleanurls.php @@ -44,12 +44,12 @@ public function __construct() public function getContent() { - $output = '
+ $output = '

On some versions you have to disable Cache save than open your shop home page than go back and enable it.
Advanced Parameters > Performance > Clear Smarty cache

Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL off -> Save
Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL on -> Save
-


'; +

'; $sql = 'SELECT * FROM `'._DB_PREFIX_.'product_lang` WHERE `link_rewrite` @@ -61,8 +61,8 @@ public function getContent() if ($results = Db::getInstance()->ExecuteS($sql)) { - $output .= 'You need to fix duplicate URL entries
'; - foreach ($results AS $row) + $this->adminDisplayWarning('You need to fix duplicate URL entries.'); + foreach ($results as $row) { $language_info = $this->context->language->getLanguage($row['id_lang']); $output .= $row['name'].' ('.$row['id_product'] .') - '. $row['link_rewrite'].'
'; @@ -71,42 +71,13 @@ public function getContent() } } else - $output .= 'Nice you don\'t have any duplicate URL entries.'; + $output .= 'Nice you don\'t have any duplicate URL entries.'; return $output; } - // TODO: rewrite to have a robust install process - function checkWritable($directories) - { - foreach ($directories as $dir) { - if (!file_exists(_PS_ROOT_DIR_ . '/' . $dir) - && 0 === strpos($dir, 'override/', 0) - && !copy(_PS_ROOT_DIR_ .'/modules/'._MODULE_NAME.'/'.$dir, _PS_ROOT_DIR_ . '/' . $dir)) - return false; - if (!is_writable(_PS_ROOT_DIR_ . '/' . $dir)) - return false; - } - return true; - } - public function install() { - $overrides = array('override/classes/Dispatcher.php', - 'override/classes/Link.php', - 'override/controllers/front/CategoryController.php', - 'override/controllers/front/CmsController.php', - 'override/controllers/front/ManufacturerController.php', - 'override/controllers/front/ProductController.php', - 'override/controllers/front/SupplierController.php', - ); - - if (!$this->checkWritable($overrides)) - { - $this->_errors[] = $this->l('Files in /override folder are not writable, these files need to be writable:' - .'classes: Dispatcher.php, Link.php; controllers/front: CategoryController.php, CmsController.php, ManufacturerController.php, ProductController.php, SupplierController.php'); - return false; - } // add link_rewrite as index to improve search $table_list = array('category_lang','cms_category_lang','cms_lang','product_lang'); foreach($table_list as $table) @@ -115,17 +86,11 @@ public function install() Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_.$table.'` ADD INDEX ( `link_rewrite` )'); } - if (!parent::install()) - return false; - - return true; + return parent::install(); } public function uninstall() { - // TODO: restore previous override state - if (!parent::uninstall()) - return false; - return true; + return parent::uninstall(); } } diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index b1f271a..e4d960b 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -315,7 +315,7 @@ public function getController($id_shop = null) break; } - if ($isTemplate == false) + if (!$isTemplate) { $findRoute = $route; break; From 86eab06e99e5368b1dffd8fe48219e257415e6a0 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 13 Mar 2015 16:57:32 +0100 Subject: [PATCH 057/174] * fix module name constant use --- cleanurls.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cleanurls.php b/cleanurls.php index cc89b14..e523899 100644 --- a/cleanurls.php +++ b/cleanurls.php @@ -26,7 +26,7 @@ class CleanUrls extends Module public function __construct() { - $this->name = _MODULE_NAME; + $this->name = self::_MODULE_NAME; $this->tab = 'seo'; $this->version = '0.8'; $this->author = 'ZiZuu Store'; @@ -39,7 +39,7 @@ public function __construct() $this->displayName = $this->l('ZiZuu Clean URLs'); $this->description = $this->l('This override-Module allows you to remove URL ID\'s.'); - $this->confirmUninstall = $this->l('Are you sure you want to uninstall "'._MODULE_NAME.'"?'); + $this->confirmUninstall = $this->l('Are you sure you want to uninstall "'.self::_MODULE_NAME.'"?'); } public function getContent() From 37b5946a83e2a035cb60f9dddc1860e8cbe67884 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 25 Mar 2015 12:54:23 +0100 Subject: [PATCH 058/174] * v0.8.1 --- cleanurls.php | 60 ++++++++++-------- config.xml | 2 +- logo.png | Bin 1282 -> 1152 bytes override/classes/Dispatcher.php | 47 +++++++------- override/classes/Link.php | 30 ++++----- .../classes/controller/FrontController.php | 1 + 6 files changed, 74 insertions(+), 66 deletions(-) diff --git a/cleanurls.php b/cleanurls.php index e523899..4c32cf3 100644 --- a/cleanurls.php +++ b/cleanurls.php @@ -22,13 +22,11 @@ class CleanUrls extends Module { - const _MODULE_NAME = 'cleanurls'; - public function __construct() { - $this->name = self::_MODULE_NAME; + $this->name = 'cleanurls'; $this->tab = 'seo'; - $this->version = '0.8'; + $this->version = '0.8.1'; $this->author = 'ZiZuu Store'; $this->need_instance = 1; $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); @@ -39,17 +37,19 @@ public function __construct() $this->displayName = $this->l('ZiZuu Clean URLs'); $this->description = $this->l('This override-Module allows you to remove URL ID\'s.'); - $this->confirmUninstall = $this->l('Are you sure you want to uninstall "'.self::_MODULE_NAME.'"?'); + $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); } public function getContent() { - $output = '

- On some versions you have to disable Cache save than open your shop home page than go back and enable it.
- Advanced Parameters > Performance > Clear Smarty cache

- Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL off -> Save
- Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL on -> Save
-

'; + $output = '

' + .nl2br($this->l('On some versions you could have to disable Cache, ' + .'save, open your shop home page, than go back and enable it: + + Advanced Parameters > Performance > Clear Smarty cache + Preferences -> SEO and URLs -> Set userfriendly URL off -> Save + Preferences -> SEO and URLs -> Set userfriendly URL on -> Save')) + .'

'; $sql = 'SELECT * FROM `'._DB_PREFIX_.'product_lang` WHERE `link_rewrite` @@ -59,38 +59,46 @@ public function getContent() if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); - if ($results = Db::getInstance()->ExecuteS($sql)) + if ($res = Db::getInstance()->ExecuteS($sql)) { - $this->adminDisplayWarning('You need to fix duplicate URL entries.'); - foreach ($results as $row) + $err = $this->l('You need to fix duplicate URL entries:').'
'; + foreach ($res as $row) { - $language_info = $this->context->language->getLanguage($row['id_lang']); - $output .= $row['name'].' ('.$row['id_product'] .') - '. $row['link_rewrite'].'
'; - $shop_info = $this->context->shop->getShop($language_info['id_shop']); - $output .= 'Language:'. $language_info['name'] . '
Shop:' . $shop_info['name'].'

'; + $lang = $this->context->language->getLanguage($row['id_lang']); + $err .= $row['name'].' ('.$row['id_product'].') - '.$row['link_rewrite'].'
'; + + $shop = $this->context->shop->getShop($lang['id_shop']); + $err .= $this->l('Language: ').$lang['name'].'
'.$this->l('Shop: ').$shop['name'].'

'; } + $output .= $this->displayError($err); } else - $output .= 'Nice you don\'t have any duplicate URL entries.'; + $output .= $this->displayConfirmation($this->l('Nice. You have no duplicate URL entry.')); - return $output; + return '
'.$output.'
'; } public function install() { // add link_rewrite as index to improve search - $table_list = array('category_lang','cms_category_lang','cms_lang','product_lang'); - foreach($table_list as $table) + $tables = array('category_lang','cms_category_lang','cms_lang','product_lang'); + foreach($tables as $tab) { - if (!Db::getInstance()->ExecuteS('SHOW INDEX FROM `'._DB_PREFIX_.$table.'` WHERE Key_name = \'link_rewrite\'')) - Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_.$table.'` ADD INDEX ( `link_rewrite` )'); + if (!Db::getInstance()->ExecuteS('SHOW INDEX FROM `'._DB_PREFIX_.$tab.'` WHERE Key_name = \'link_rewrite\'')) + Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_.$tab.'` ADD INDEX ( `link_rewrite` )'); } - return parent::install(); + if (!parent::install()) + return false; + + return true; } public function uninstall() { - return parent::uninstall(); + if (!parent::uninstall()) + return false; + + return true; } } diff --git a/config.xml b/config.xml index 73fb617..4efc23a 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ cleanurls - + diff --git a/logo.png b/logo.png index b0c35b59a32a35922e235ce13cfaea86fb337aa3..ec3991175b206bd2b36a208066607b626275dfb0 100644 GIT binary patch literal 1152 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+m{;p}MBd-Q6=HGCC57 zqGFs~++1ATAdI;9#Hi@lrslSSqSCVRs?_wXvWlww!jj6Wnu^Nm{)tmEGPC<8O!f~9 zPEJWrN={2jO)syiDX**!3OG&eN10Nvc$-rd^K-QL;L-r3vU)!Wh0 z)6v<}(be18-PhIA-_ zdCH_I(CkeFygMKX~f&+0$pvo;h>w%-Qp2 z&s{io;qt{xR~|fk{1Av9J$d=^)yr3}-o1VM?%mt>@87+D|Ng_rPoF=3{_^>Az4`G{ zU?c^U1o;IsFfcN)u(Gjp^6>Htiik-_%E&9K>lqjrn_F61+1fifyZMBN$HgZk0zq0v zW^PF(Fl?GzT3cJ&`X;a4xbMi>>rb9OfAQk=o40S@zW?}fonl)h(9CU~E{-7<{;d~N z!qH_ut7z+#P4u{HmK(Jn!|H>C(x6izT>| zEw*{TdvYQ{i|?LKgYcg3CH2*NR1A~Z<}A4TeKG6PNB?r9&aoV*Q}E_IIqO!Yk_5wE z{^K_T?@fBkrpRS+Fu{L`&W}L#)1@j*H`Z0ZZ$G?Iq>;TO_M6C}hUxz+OavC*WnTKc zXybgKzpoySsm`9abN!bjpE(Jqof$Ouzr0ct_Orou-lNTd7wq?bGYVXIo0G4t>C)Hd zA5U$5{a%*o&YZR3u3w*J&A0H}KbtA<+qK!d)-2t)Pvgu6>4t6dz4Wv%?peugbJzCH z+?=1kV)-5Rx6hvWHN3R(M4O5yV}I_Csca?tcb?mt?z;0tSNBXA@BQ+8Te9PhW#7tK zAj=TD|HZTZ&QrZ^LbtX$T-QIgbH}Q0C0pfK7s$WJek*aa_HJ|s(*=Jqcfn^1FLej* zl4oIAwfkqvuJsG$Sx!uhUOJuiUH%*P=7o=s`m}$@OSb3WxIF#aax1^}bvF&g67^@^ zy&3n?@LMxOp602HtRFY|nP$vfx_7pxy+neAqRGql2K)EiwpVMrADo$+2g=Kyu6{1- HoD!MsSsndzK~8L*2#j4^SD%*oAci5g?#Wu~LUZA9bT@Q0al=>@zk zP@tJ5g>mRc7hOwjX|}efH{b8{v;r%_I9+y<_oT^pPM`OCzvq3Q=kOwt2t3Ryg@4?5 zJYKT@m)F|XS&}XiT?~c8d7)qsBB3zQ0s3OgyG?s>Js5wGR3OO-@Y_329w;g(R99>( z2cOpuF1H)(4hKw6O~ahc25s*je-xjiA4CHD*7gq$$cl>8H8s^>7#;>{#tH%24?=+u zBvL8ZY&U?Sti2z9cxpGPL`pJuzJC~8t22PvYzEWB_^0MSubEV33^xzi|HRZ*bkulWF`-Tni+l0z&K}DJd&8LxIQb0=ZIos`1bf9bq_v?<3&V)s>*t8?X(h zVCMRC#~;7{rpNWW$w(kI6n_fAyz?Kh|9u8Uj9uyqLCF z;5vf$_5DPS#vYpkoJknM38&X;p|Gd`cGlIx=U<)%pU($dwmjLh9K1gYev93GBpDn4 zm&@srDCAkY>UMzoOcz|eIs&gBJqm;CC>>$r#0{Zy$SSc7O9`ni;hHeaF3CFTAkld1mLN)l{m|n5cNy3%)#ogsL`X9Di-Sa^=ULJsyvOSgmAw{l$X69Fx=p!V*_Ct_eT{Nk!&2aj#F8l$~uN@(YHTKtTVdTr_$0MGd@?Q0uibjaWbo^+PXa*JBmg4Ti)Dq z!YGmCfLNT(w3#2Bj)SNg+Njl3jcWp=61f<~2OAEb+(RG~ZY7)`u~t>%ngG*^7}*$k z7@6$xtXb8PkwA - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs - */ +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* It is available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* +* DISCLAIMER +* This code is provided as is without any warranty. +* No promise of being safe or secure +* +* @author ZiZuu.com +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs +*/ class Dispatcher extends DispatcherCore { @@ -28,7 +28,7 @@ class Dispatcher extends DispatcherCore 'rule' => 'supplier/{rewrite}/', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[?_a-zA-Z0-9\pL\pS-]*', 'param' => 'supplier_rewrite'), + '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-]*'), ), @@ -38,7 +38,7 @@ class Dispatcher extends DispatcherCore 'rule' => 'manufacturer/{rewrite}/', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[?_a-zA-Z0-9\pL\pS-]*', 'param' => 'manufacturer_rewrite'), + '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-]*'), ), @@ -48,7 +48,7 @@ class Dispatcher extends DispatcherCore 'rule' => 'info/{rewrite}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[?_a-zA-Z0-9\pL\pS-]*', 'param' => 'cms_rewrite'), + '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-]*'), ), @@ -58,7 +58,7 @@ class Dispatcher extends DispatcherCore 'rule' => 'info/{rewrite}/', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[?_a-zA-Z0-9\pL\pS-]*', 'param' => 'cms_category_rewrite'), + '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-]*'), ), @@ -79,7 +79,7 @@ class Dispatcher extends DispatcherCore 'rule' => '{categories:/}{rewrite}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[?_a-zA-Z0-9\pL\pS-]*', 'param' => 'product_rewrite'), + '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-]*'), @@ -99,7 +99,7 @@ class Dispatcher extends DispatcherCore 'id' => array('regexp' => '[0-9]+'), /* Selected filters is used by the module blocklayered */ 'selected_filters' => array('regexp' => '.*', 'param' => 'selected_filters'), - 'rewrite' => array('regexp' => '[?_a-zA-Z0-9-\pL]*', 'param' => 'category_rewrite'), + '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]*'), ), @@ -109,7 +109,7 @@ class Dispatcher extends DispatcherCore 'rule' => '{parent_categories:/}{rewrite}/', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - 'rewrite' => array('regexp' => '[?_a-zA-Z0-9\pL\pS-]*', 'param' => 'category_rewrite'), + '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_categories' => array('regexp' => '[/_a-zA-Z0-9\pL-]*'), @@ -380,8 +380,7 @@ public function getController($id_shop = null) $controller = $this->default_controller; $this->controller = $controller; } - // Default mode, take controller from url - else + else // Default mode, take controller from url $this->controller = $controller; $this->controller = str_replace('-', '', $this->controller); diff --git a/override/classes/Link.php b/override/classes/Link.php index 5bf3451..3263f8f 100644 --- a/override/classes/Link.php +++ b/override/classes/Link.php @@ -1,21 +1,21 @@ - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs - */ +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* It is available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* +* DISCLAIMER +* This code is provided as is without any warranty. +* No promise of being safe or secure +* +* @author ZiZuu.com +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs +*/ class Link extends LinkCore { diff --git a/override/classes/controller/FrontController.php b/override/classes/controller/FrontController.php index eaecb7b..bd48aba 100644 --- a/override/classes/controller/FrontController.php +++ b/override/classes/controller/FrontController.php @@ -19,6 +19,7 @@ class FrontController extends FrontControllerCore { + public function __construct() { parent::__construct(); From bd1b243aaebed7bb8d38bfb4489ded305388a4ae Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 25 Mar 2015 17:47:13 +0100 Subject: [PATCH 059/174] * Fixed routing issues. Now should work in PS >= 1.6.0.11 too --- override/classes/Dispatcher.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index 5e3e415..cac39af 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -284,6 +284,8 @@ public function getController($id_shop = null) if ($this->empty_route) $this->addRoute($this->empty_route['routeID'], $this->empty_route['rule'], $this->empty_route['controller'], Context::getContext()->language->id, array(), array(), $id_shop); + list($uri) = explode('?', $this->request_uri); + if (isset($this->routes[$id_shop][Context::getContext()->language->id])) { $findRoute = array(); @@ -291,7 +293,7 @@ public function getController($id_shop = null) // check, whether request_uri is template or not foreach ($this->routes[$id_shop][Context::getContext()->language->id] as $route) { - if (preg_match($route['regexp'], $this->request_uri, $m)) + if (preg_match($route['regexp'], $uri, $m)) { $isTemplate = false; @@ -327,7 +329,7 @@ public function getController($id_shop = null) if (empty($findRoute)) { // get the path from requested URI, and remove "/" at the beginning - $short_link = ltrim(parse_url($this->request_uri, PHP_URL_PATH), '/'); + $short_link = ltrim(parse_url($uri, PHP_URL_PATH), '/'); if (!Dispatcher::isProductLink($short_link)) if (!Dispatcher::isCategoryLink($short_link)) @@ -349,7 +351,7 @@ public function getController($id_shop = null) if (!empty($findRoute)) { - if (preg_match($findRoute['regexp'], $this->request_uri, $m)) + if (preg_match($findRoute['regexp'], $uri, $m)) { // Route found ! Now fill $_GET with parameters of uri foreach ($m as $k => $v) From e7f64d9a910f6654d48eafdcbf0111ee4b8b8a0b Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 25 Mar 2015 19:31:17 +0100 Subject: [PATCH 060/174] * reintroduced possibility of use ".html" extension --- override/classes/Dispatcher.php | 28 ++++--------------- override/controllers/front/CmsController.php | 3 +- .../controllers/front/ProductController.php | 7 +++-- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index cac39af..8b2b686 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -25,7 +25,7 @@ class Dispatcher extends DispatcherCore public $default_routes = array( 'supplier_rule' => array( 'controller' => 'supplier', - 'rule' => 'supplier/{rewrite}/', + 'rule' => 'supplier/{rewrite}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), 'rewrite' => array('regexp' => '[_a-zA-Z0-9\pL\pS-]*', 'param' => 'supplier_rewrite'), @@ -35,7 +35,7 @@ class Dispatcher extends DispatcherCore ), 'manufacturer_rule' => array( 'controller' => 'manufacturer', - 'rule' => 'manufacturer/{rewrite}/', + 'rule' => 'manufacturer/{rewrite}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), 'rewrite' => array('regexp' => '[_a-zA-Z0-9\pL\pS-]*', 'param' => 'manufacturer_rewrite'), @@ -125,13 +125,9 @@ class Dispatcher extends DispatcherCore */ public static function isProductLink($short_link) { - // check if any keyword - $explode_product_link = explode('/', $short_link); - $count = count($explode_product_link); - $sql = 'SELECT `id_product` FROM `'._DB_PREFIX_.'product_lang` - WHERE `link_rewrite` = \''.pSQL($explode_product_link[$count-1]).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; + WHERE `link_rewrite` = \''.pSQL(basename($short_link, '.html')).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); @@ -169,14 +165,10 @@ public static function isCategoryLink($short_link) */ public static function isCmsLink($short_link) { - // check if any keyword - $explode_cms_link = explode('/', $short_link); - $count = count($explode_cms_link); - $sql = 'SELECT l.`id_cms` FROM `'._DB_PREFIX_.'cms_lang` l LEFT JOIN `'._DB_PREFIX_.'cms_shop` s ON (l.`id_cms` = s.`id_cms`) - WHERE l.`link_rewrite` = \''.pSQL($explode_cms_link[$count-1]).'\''; + WHERE l.`link_rewrite` = \''.pSQL(basename($short_link, '.html')).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); @@ -193,11 +185,7 @@ public static function isCmsLink($short_link) */ public static function isManufacturerLink($short_link) { - // check if any keyword - $explode_manufacturer_link = explode('/', $short_link); - $count = count($explode_manufacturer_link); - - $manufacturer = str_replace('-', '%', $explode_manufacturer_link[$count-1]); + $manufacturer = str_replace('-', '%', basename($short_link)); $sql = 'SELECT m.`id_manufacturer` FROM `'._DB_PREFIX_.'manufacturer` m @@ -219,11 +207,7 @@ public static function isManufacturerLink($short_link) */ public static function isSupplierLink($short_link) { - // check if any keyword - $explode_supplier_link = explode('/', $short_link); - $count = count($explode_supplier_link); - - $supplier = str_replace('-', '%', $explode_supplier_link[$count-1]); + $supplier = str_replace('-', '%', basename($short_link)); $sql = 'SELECT sp.`id_supplier` FROM `'._DB_PREFIX_.'supplier` sp diff --git a/override/controllers/front/CmsController.php b/override/controllers/front/CmsController.php index e6a1f13..cfb7375 100644 --- a/override/controllers/front/CmsController.php +++ b/override/controllers/front/CmsController.php @@ -26,8 +26,7 @@ public function init() $sql = 'SELECT l.`id_cms` FROM `'._DB_PREFIX_.'cms_lang` l LEFT JOIN `'._DB_PREFIX_.'cms_shop` s ON (l.`id_cms` = s.`id_cms`) - WHERE l.`link_rewrite` = \''.pSQL($cms_rewrite).'\''; - + WHERE l.`link_rewrite` = \''.pSQL(str_replace('.html', '', $cms_rewrite)).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); diff --git a/override/controllers/front/ProductController.php b/override/controllers/front/ProductController.php index 7ea9d8f..f233344 100644 --- a/override/controllers/front/ProductController.php +++ b/override/controllers/front/ProductController.php @@ -24,21 +24,22 @@ public function init() if ($product_rewrite = Tools::getValue('product_rewrite')) { $url_id_pattern = '/.*?([0-9]+)\-([a-zA-Z0-9-]*)(\.html)?/'; + $lang_id = (int)Context::getContext()->language->id; $sql = 'SELECT `id_product` FROM `'._DB_PREFIX_.'product_lang` - WHERE `link_rewrite` = \''.pSQL($product_rewrite).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; + WHERE `link_rewrite` = \''.pSQL(str_replace('.html', '', $product_rewrite)).'\' AND `id_lang` = '.$lang_id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_product > 0) $_GET['id_product'] = $id_product; - elseif (preg_match($url_id_pattern, $_SERVER['REQUEST_URI'], $url_split)) + elseif (preg_match($url_id_pattern, $this->request_uri, $url_split)) { $sql = 'SELECT `id_product` FROM `'._DB_PREFIX_.'product_lang` - WHERE `id_product` = \''.pSQL($url_split[1]).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; + WHERE `id_product` = \''.pSQL($url_split[1]).'\' AND `id_lang` = '.$lang_id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); From 3395cb10fef81afada9d9fc73adec9c6a858b237 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 25 Mar 2015 19:36:37 +0100 Subject: [PATCH 061/174] Update README.md --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a22e8bc..f2aa0f2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [ABOUT](https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs) =============================================================== -It works on our 1.6.0.9. We are going to merge other users' contributions and ideas as soon as we note them and find the time to test. +It should work on our 1.6.0.14 . We are going to merge other users' contributions and ideas as soon as we note them and find the time to test. If you fork please make every change the way we can pull, don't reinvent the wheel .. make every custom changeon a private branch, so you can merge your own changes to the community mintained full branch every time a new release is out. @@ -11,18 +11,18 @@ Install the module from the Backoffice (administration panel), download the rele In the modules tab, click on **add a new module**. Click on Browse to open the dialogue box letting you search your computer, select the file then validate the dialogue box. Finally click on Upload this module. -###Make sure your seo and url settings are as follows: +###Make sure your SEO and URL settings are as follows: This is __MANDATORY__ -* products: {categories:/}{rewrite} (**NO .html** at the end) -* categories: {parent_categories:/}{rewrite}/ +* products: {categories:/}{rewrite} (** you can add .html** at the end) +* categories: {parent_categories:/}{rewrite}**/** * manufacturers: manufactures/{rewrite} * suppliers: suppliers/{rewrite} -* CMS page: info/{rewrite} +* CMS page: info/{rewrite} (** you can add .html** at the end) * CMS category: info/{rewrite}**/** * modules: module/{module}{/:controller} -You can replace "info" with whatever you want given that it does not conflicts with a category name +You can replace words such as "info", "module", etc with whatever you want given that it does not conflicts with a category name Keep in mind to * **clear the browser cache** @@ -31,7 +31,9 @@ Keep in mind to UNINSTALLATION -------- -Go to modules -> Find and uninstall "CleanURL". +Go to modules -> Find and uninstall "CleanURL". **It should suffice!** + +If something goes wrong do the following: Open folder /override/classes/ -> Remove "Link.php" From 13af5e47d0191fef42f11eedfef965d57c4a7df8 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 25 Mar 2015 19:36:52 +0100 Subject: [PATCH 062/174] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f2aa0f2..2b39f3d 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,11 @@ In the modules tab, click on **add a new module**. Click on Browse to open the d ###Make sure your SEO and URL settings are as follows: This is __MANDATORY__ -* products: {categories:/}{rewrite} (** you can add .html** at the end) +* products: {categories:/}{rewrite} (**you can add .html** at the end) * categories: {parent_categories:/}{rewrite}**/** * manufacturers: manufactures/{rewrite} * suppliers: suppliers/{rewrite} -* CMS page: info/{rewrite} (** you can add .html** at the end) +* CMS page: info/{rewrite} (**you can add .html** at the end) * CMS category: info/{rewrite}**/** * modules: module/{module}{/:controller} From 16a5650f9e1661f0dd3f5d3d0c8d16e664b0174e Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 26 Mar 2015 12:44:32 +0100 Subject: [PATCH 063/174] Update README.md --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2b39f3d..8178029 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ [ABOUT](https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs) =============================================================== -It should work on our 1.6.0.14 . We are going to merge other users' contributions and ideas as soon as we note them and find the time to test. +It has been tested on PS 1.6.0.9 - 1.6.0.14 +We are going to merge other users' contributions and ideas as soon as we note them and find the time to test. If you fork please make every change the way we can pull, don't reinvent the wheel .. make every custom changeon a private branch, so you can merge your own changes to the community mintained full branch every time a new release is out. @@ -14,11 +15,11 @@ In the modules tab, click on **add a new module**. Click on Browse to open the d ###Make sure your SEO and URL settings are as follows: This is __MANDATORY__ -* products: {categories:/}{rewrite} (**you can add .html** at the end) +* products: {categories:/}{rewrite} (you **can** add .html at the end) * categories: {parent_categories:/}{rewrite}**/** * manufacturers: manufactures/{rewrite} * suppliers: suppliers/{rewrite} -* CMS page: info/{rewrite} (**you can add .html** at the end) +* CMS page: info/{rewrite} (you **can** add .html at the end) * CMS category: info/{rewrite}**/** * modules: module/{module}{/:controller} From 8ddc3807dfd1af26b09add2a06a6be9239d833d0 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 26 Mar 2015 12:44:57 +0100 Subject: [PATCH 064/174] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8178029..0df65c1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ [ABOUT](https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs) =============================================================== + It has been tested on PS 1.6.0.9 - 1.6.0.14 + We are going to merge other users' contributions and ideas as soon as we note them and find the time to test. If you fork please make every change the way we can pull, don't reinvent the wheel .. make every custom changeon a private branch, so you can merge your own changes to the community mintained full branch every time a new release is out. From 4c5edb91ab4560667914f9e61ceb48c0ba957c7b Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 26 Mar 2015 13:10:41 +0100 Subject: [PATCH 065/174] Updated logo --- logo.png | Bin 1152 -> 726 bytes override/classes/Link.php | 41 +++++++++++++++++++------------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/logo.png b/logo.png index ec3991175b206bd2b36a208066607b626275dfb0..696efd1bad0b66e050bb7f1a4e9cef6bf17adaab 100644 GIT binary patch delta 702 zcmV;v0zv(N3DyOWB!9h7OjJdNwJiVt|A@9X{r>&|rQu7r>UyFkfW+%BvFI$g@(Qiz zgR&|+uHh=H;d-wCzuxrA<@aT~=<)ddsnYM2%I)R!{eG$`aF!?9?D&SYFJy`hsvN)oqc(YJa zq1w<{1`Di$;b6%$g~h;c-(oqL0v*5tmEMxI_+u!I^?I|fH1$id z_AhhT@Mv15X<08jN~lyC^QR|U2;q93^}_zq+HUkqo_~TcFocJR8CIx%=1KbqM2Hn8 zR;cwGOS%DY^c+fo30l$l-CRayh%Qbjl?s;vogdj@xh9`UAp(FBhhm`fX2v7(r6*ir z0A#}2Jo&xMc#@zGr1V@7VuS5s!NW%}2O|SWB7UR`93RjAgq|BQWNX?VqR*^R=XVl4 zBz6ozihtcHc{yU;fLX}twL}@p7$CqYrTx2E`RpFpW*idw{1JLsmk`=`Wi?@r^9b;W zUXG(r69~L;_}RSGA9?QFPe33<3drG<9o$diy)Ftp{~8%_+*YFIhWqNi{%Cox&zFJ% zRB_~-bbQ)g&)4hui_3)qgrjc{G5SpI>kCr1TsI0laS!PGxsgWmeQ_=x=(;p}MBd-Q6=HGCC57 zqGFs~++1ATAdI;9#Hi@lrslSSqSCVRs?_wXvWlww!jj6Wnu^Nm{)tmEGPC<8O!f~9 zPEJWrN={2jO)syiDX**!3OG&eN10Nvc$-rd^K-QL;L-r3vU)!Wh0 z)6v<}(be18-PhIA-_ zdCH_I(CkeFygMKX~f&+0$pvo;h>w%-Qp2 z&s{io;qt{xR~|fk{1Av9J$d=^)yr3}-o1VM?%mt>@87+D|Ng_rPoF=3{_^>Az4`G{ zU?c^U1o;IsFfcN)u(Gjp^6>Htiik-_%E&9K>lqjrn_F61+1fifyZMBN$HgZk0zq0v zW^PF(Fl?GzT3cJ&`X;a4xbMi>>rb9OfAQk=o40S@zW?}fonl)h(9CU~E{-7<{;d~N z!qH_ut7z+#P4u{HmK(Jn!|H>C(x6izT>| zEw*{TdvYQ{i|?LKgYcg3CH2*NR1A~Z<}A4TeKG6PNB?r9&aoV*Q}E_IIqO!Yk_5wE z{^K_T?@fBkrpRS+Fu{L`&W}L#)1@j*H`Z0ZZ$G?Iq>;TO_M6C}hUxz+OavC*WnTKc zXybgKzpoySsm`9abN!bjpE(Jqof$Ouzr0ct_Orou-lNTd7wq?bGYVXIo0G4t>C)Hd zA5U$5{a%*o&YZR3u3w*J&A0H}KbtA<+qK!d)-2t)Pvgu6>4t6dz4Wv%?peugbJzCH z+?=1kV)-5Rx6hvWHN3R(M4O5yV}I_Csca?tcb?mt?z;0tSNBXA@BQ+8Te9PhW#7tK zAj=TD|HZTZ&QrZ^LbtX$T-QIgbH}Q0C0pfK7s$WJek*aa_HJ|s(*=Jqcfn^1FLej* zl4oIAwfkqvuJsG$Sx!uhUOJuiUH%*P=7o=s`m}$@OSb3WxIF#aax1^}bvF&g67^@^ zy&3n?@LMxOp602HtRFY|nP$vfx_7pxy+neAqRGql2K)EiwpVMrADo$+2g=Kyu6{1- HoD!M -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs -*/ + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * It is available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * + * DISCLAIMER + * This code is provided as is without any warranty. + * No promise of being safe or secure + * + * @author ZiZuu.com + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + */ class Link extends LinkCore { @@ -70,22 +70,21 @@ public function getCategoryLink($category, $alias = null, $id_lang = null, $sele $dispatcher = Dispatcher::getInstance(); - // XXX: replace 'category_rule' with $rule ? if ($dispatcher->hasKeyword('category_rule', $id_lang, 'parent_categories')) { // Retrieve all parent categories - $cats = array(); - foreach ($category->getParentsCategories($id_lang) as $cat) + $p_cats = array(); + foreach ($category->getParentsCategories($id_lang) as $p_cat) { self::$category_disable_rewrite[] = $category->id; // remove root and current category from the URL - if (!in_array($cat['id_category'], self::$category_disable_rewrite)) { - $cats[] = $cat['link_rewrite']; + if (!in_array($p_cat['id_category'], self::$category_disable_rewrite)) { + $p_cats[] = $p_cat['link_rewrite']; } } // add the URL slashes among categories, in reverse order - $params['parent_categories'] = implode('/', array_reverse($cats)); + $params['parent_categories'] = implode('/', array_reverse($p_cats)); } return $url.$dispatcher->createUrl($rule, $id_lang, $params, $this->allow, '', $id_shop); From ba3f2ffd0805d13f4fd0068337fbf339cd9fc07c Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 26 Mar 2015 13:49:44 +0100 Subject: [PATCH 066/174] * release v0.9 --- cleanurls.php | 2 +- config.xml | 2 +- index.php | 6 ++-- override/classes/Dispatcher.php | 30 +++++++++---------- override/classes/Link.php | 12 -------- .../classes/controller/FrontController.php | 12 ++------ override/classes/controller/index.php | 6 ++-- override/classes/index.php | 6 ++-- override/controllers/front/CmsController.php | 6 ++-- .../front/ManufacturerController.php | 13 ++++---- .../controllers/front/ProductController.php | 11 ++++--- .../controllers/front/SupplierController.php | 9 ++---- override/controllers/front/index.php | 6 ++-- override/controllers/index.php | 6 ++-- override/index.php | 6 ++-- 15 files changed, 54 insertions(+), 79 deletions(-) diff --git a/cleanurls.php b/cleanurls.php index 4c32cf3..ad789eb 100644 --- a/cleanurls.php +++ b/cleanurls.php @@ -26,7 +26,7 @@ public function __construct() { $this->name = 'cleanurls'; $this->tab = 'seo'; - $this->version = '0.8.1'; + $this->version = '0.9'; $this->author = 'ZiZuu Store'; $this->need_instance = 1; $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); diff --git a/config.xml b/config.xml index 4efc23a..3f660a7 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ cleanurls - + diff --git a/index.php b/index.php index ef6ab14..16ac24f 100644 --- a/index.php +++ b/index.php @@ -12,9 +12,9 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author ZiZuu.com - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @author ZiZuu.com + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs */ header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index 8b2b686..2560e46 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -1,21 +1,21 @@ -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs -*/ + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * It is available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * + * DISCLAIMER + * This code is provided as is without any warranty. + * No promise of being safe or secure + * + * @author ZiZuu.com + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + */ class Dispatcher extends DispatcherCore { diff --git a/override/classes/Link.php b/override/classes/Link.php index fd1ca7b..7beef73 100644 --- a/override/classes/Link.php +++ b/override/classes/Link.php @@ -19,18 +19,6 @@ class Link extends LinkCore { - public function __construct($protocol_link = null, $protocol_content = null) - { - parent::__construct($protocol_link, $protocol_content); - - /* TODO - * add a configuration switch to hide or show the Home category - - // Re-add Home category - Link::$category_disable_rewrite = array_diff(Link::$category_disable_rewrite, array(Configuration::get('PS_HOME_CATEGORY'))); - */ - } - /** * Create a link to a category * diff --git a/override/classes/controller/FrontController.php b/override/classes/controller/FrontController.php index bd48aba..94c416e 100644 --- a/override/classes/controller/FrontController.php +++ b/override/classes/controller/FrontController.php @@ -12,19 +12,13 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author ZiZuu.com - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @author ZiZuu.com + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs */ class FrontController extends FrontControllerCore { - - public function __construct() - { - parent::__construct(); - } - protected function canonicalRedirection($canonical_url = '') { $excluded_keys = array( diff --git a/override/classes/controller/index.php b/override/classes/controller/index.php index ef6ab14..16ac24f 100644 --- a/override/classes/controller/index.php +++ b/override/classes/controller/index.php @@ -12,9 +12,9 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author ZiZuu.com - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @author ZiZuu.com + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs */ header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); diff --git a/override/classes/index.php b/override/classes/index.php index ef6ab14..16ac24f 100644 --- a/override/classes/index.php +++ b/override/classes/index.php @@ -12,9 +12,9 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author ZiZuu.com - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @author ZiZuu.com + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs */ header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); diff --git a/override/controllers/front/CmsController.php b/override/controllers/front/CmsController.php index cfb7375..a06e7d1 100644 --- a/override/controllers/front/CmsController.php +++ b/override/controllers/front/CmsController.php @@ -12,9 +12,9 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author ZiZuu.com - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @author ZiZuu.com + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs */ class CmsController extends CmsControllerCore diff --git a/override/controllers/front/ManufacturerController.php b/override/controllers/front/ManufacturerController.php index 4ad9bf5..750c93c 100644 --- a/override/controllers/front/ManufacturerController.php +++ b/override/controllers/front/ManufacturerController.php @@ -12,22 +12,19 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author ZiZuu.com - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @author ZiZuu.com + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs */ class ManufacturerController extends ManufacturerControllerCore { public function init() { - if (Tools::getValue('manufacturer_rewrite')) + if ($manufacturer_rewrite = Tools::getValue('manufacturer_rewrite')) { - $manufacturer_rewrite = str_replace('-', '%', Tools::getValue('manufacturer_rewrite')); + $manufacturer_rewrite = str_replace('-', '%', $manufacturer_rewrite); - /* TODO: need to core update Prestashop code and DB for link_rewrite for manufacturers - * Should we use the Mysql FullText Index Search ?? - */ $sql = 'SELECT m.`id_manufacturer` FROM `'._DB_PREFIX_.'manufacturer` m LEFT JOIN `'._DB_PREFIX_.'manufacturer_shop` s ON (m.`id_manufacturer` = s.`id_manufacturer`) diff --git a/override/controllers/front/ProductController.php b/override/controllers/front/ProductController.php index f233344..7786621 100644 --- a/override/controllers/front/ProductController.php +++ b/override/controllers/front/ProductController.php @@ -12,9 +12,9 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author ZiZuu.com - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @author ZiZuu.com + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs */ class ProductController extends ProductControllerCore @@ -35,12 +35,11 @@ public function init() $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_product > 0) $_GET['id_product'] = $id_product; - elseif (preg_match($url_id_pattern, $this->request_uri, $url_split)) + elseif (preg_match($url_id_pattern, $this->request_uri, $url_parts)) { $sql = 'SELECT `id_product` FROM `'._DB_PREFIX_.'product_lang` - WHERE `id_product` = \''.pSQL($url_split[1]).'\' AND `id_lang` = '.$lang_id; - + WHERE `id_product` = \''.pSQL($url_parts[1]).'\' AND `id_lang` = '.$lang_id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); diff --git a/override/controllers/front/SupplierController.php b/override/controllers/front/SupplierController.php index ec34b6c..40fc923 100644 --- a/override/controllers/front/SupplierController.php +++ b/override/controllers/front/SupplierController.php @@ -12,9 +12,9 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author ZiZuu.com - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @author ZiZuu.com + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs */ class SupplierController extends SupplierControllerCore @@ -25,9 +25,6 @@ public function init() { $supplier_rewrite = str_replace('-', '%', $supplier_rewrite); - /* TODO: need to core update Prestashop code and DB for link_rewrite for suppliers - * Should we use the Mysql FullText Index Search ?? - */ $sql = 'SELECT sp.`id_supplier` FROM `'._DB_PREFIX_.'supplier` sp LEFT JOIN `'._DB_PREFIX_.'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`) diff --git a/override/controllers/front/index.php b/override/controllers/front/index.php index ef6ab14..16ac24f 100644 --- a/override/controllers/front/index.php +++ b/override/controllers/front/index.php @@ -12,9 +12,9 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author ZiZuu.com - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @author ZiZuu.com + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs */ header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); diff --git a/override/controllers/index.php b/override/controllers/index.php index ef6ab14..16ac24f 100644 --- a/override/controllers/index.php +++ b/override/controllers/index.php @@ -12,9 +12,9 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author ZiZuu.com - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @author ZiZuu.com + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs */ header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); diff --git a/override/index.php b/override/index.php index ef6ab14..16ac24f 100644 --- a/override/index.php +++ b/override/index.php @@ -12,9 +12,9 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author ZiZuu.com - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @author ZiZuu.com + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs */ header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); From b68c68d207334dfccc027283b191385fae661c20 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 27 Mar 2015 12:08:10 +0100 Subject: [PATCH 067/174] * Renamed module to 'zzcleanurls', fixed config parameters --- config.xml | 6 +++--- cleanurls.php => zzcleanurls.php | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) rename cleanurls.php => zzcleanurls.php (96%) diff --git a/config.xml b/config.xml index 3f660a7..cc5cbd9 100644 --- a/config.xml +++ b/config.xml @@ -1,12 +1,12 @@ - cleanurls + zzcleanurls - 1 - 1 + 0 + 0 diff --git a/cleanurls.php b/zzcleanurls.php similarity index 96% rename from cleanurls.php rename to zzcleanurls.php index ad789eb..56902d5 100644 --- a/cleanurls.php +++ b/zzcleanurls.php @@ -20,15 +20,15 @@ if (!defined('_PS_VERSION_')) exit; -class CleanUrls extends Module +class zzCleanUrls extends Module { public function __construct() { - $this->name = 'cleanurls'; + $this->name = 'zzcleanurls'; $this->tab = 'seo'; $this->version = '0.9'; $this->author = 'ZiZuu Store'; - $this->need_instance = 1; + $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); $this->bootstrap = true; @@ -37,7 +37,7 @@ public function __construct() $this->displayName = $this->l('ZiZuu Clean URLs'); $this->description = $this->l('This override-Module allows you to remove URL ID\'s.'); - $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); + $this->confirmUninstall = $this->l('Are you sure you want to uninstall "ZiZuu Clean URLs"?'); } public function getContent() From 95994566499e57ae75f0d20a7cb8890918577bc3 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 27 Mar 2015 14:58:02 +0100 Subject: [PATCH 068/174] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0df65c1..adc48dd 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +# Prestashop module "ZiZuu CLean URLs" + [ABOUT](https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs) =============================================================== From 6afc75f5e8f084759d0088673901765386315539 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 27 Jul 2015 19:00:09 +0200 Subject: [PATCH 069/174] Add php-cs-fixer configuration --- .php_cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .php_cs diff --git a/.php_cs b/.php_cs new file mode 100644 index 0000000..fc9f7bb --- /dev/null +++ b/.php_cs @@ -0,0 +1,12 @@ +level(Symfony\CS\FixerInterface::PSR2_LEVEL) + ->setUsingCache(true) + ->finder( + Symfony\CS\Finder\DefaultFinder::create() + ->in(__DIR__) + ) +; + +// vim:ft=php From 0fa4893c1a9958c222b5927f19ed35e6c6323022 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 27 Jul 2015 19:15:25 +0200 Subject: [PATCH 070/174] added logo.gif as some modules still needs it --- logo.gif | Bin 0 -> 780 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 logo.gif diff --git a/logo.gif b/logo.gif new file mode 100644 index 0000000000000000000000000000000000000000..fef381d0e2c3c2b15bfc74477ff7c4472ecf3277 GIT binary patch literal 780 zcmV+n1M~bxNk%w1VITk?0QCU?hP5pJ|Nn@#H~s$p0j1$fx9WPLCV<52FR|z>xbh0E z=Yz5;JFej>tKoXD0KeY!%jNfFyXf)w{i)LLmCEhq^!svN)oqc(YJa zqmOrn4FOli?EoYV z1r)sa0|8wF1U1+l0jDBC0R|6n_1T00-$8EPlmK8+qCf-$5F|>N5OEU)0t^sfTnGS! z0tgsVgxpl2fVqgpP&QaugbDr#1QiBEm|3g=N&*M?R3MN*1;3sES`-L6VS>a51qw7^ zKp1q^r&VbUUkgiQx3@R<-{z>Ax>+!7GmBr1%vxDH4NP$31yu5l|Q0P%F}#sYW) zOi-}*0R=u79xJK|;u%yD5Eh*zfB^zxJ`b!8z@Wg#1{AvtuL!DGX9Kf+QeX%G;Uz8< zkrrgByIN6%qX#zepIDExM09S zT^4O2&*pT1ferUN;>!;oL&gR3bxFKf#7P2-6*I&zLx3?9XrK%T-bcg&2CU%1UbxiM zf(8g8sKJF8+BaT#3o9C6Kno=tKtTj0v~WQT Date: Fri, 31 Jul 2015 19:12:05 +0200 Subject: [PATCH 071/174] Should fix $category_disable_rewrite infinite grown --- override/classes/Link.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/override/classes/Link.php b/override/classes/Link.php index 7beef73..d9abd3f 100644 --- a/override/classes/Link.php +++ b/override/classes/Link.php @@ -64,10 +64,8 @@ public function getCategoryLink($category, $alias = null, $id_lang = null, $sele $p_cats = array(); foreach ($category->getParentsCategories($id_lang) as $p_cat) { - self::$category_disable_rewrite[] = $category->id; - // remove root and current category from the URL - if (!in_array($p_cat['id_category'], self::$category_disable_rewrite)) { + if (!in_array($p_cat['id_category'], self::$category_disable_rewrite + array($category->id))) { $p_cats[] = $p_cat['link_rewrite']; } } From 180840cb355d5ed9e4bed2fd8343b52768444704 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 3 Aug 2015 13:45:38 +0200 Subject: [PATCH 072/174] Added gif logo, fix $category_disable_rewrite --- logo.gif | Bin 780 -> 772 bytes override/classes/Link.php | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/logo.gif b/logo.gif index fef381d0e2c3c2b15bfc74477ff7c4472ecf3277..54b3a2cc421e969648af8c58ba4d0244ac5239cd 100644 GIT binary patch delta 51 zcmeBSYhmMY_jI!`PgGz~VED=~k>?tW+@_jI$cOjKY{VED>7k>{X@;!hR^5YPb;AYlf!e-m&1WBSK2`6lCEW^Jj2 I$v2s_0jc~DA^-pY diff --git a/override/classes/Link.php b/override/classes/Link.php index d9abd3f..9ded5ca 100644 --- a/override/classes/Link.php +++ b/override/classes/Link.php @@ -65,7 +65,7 @@ public function getCategoryLink($category, $alias = null, $id_lang = null, $sele foreach ($category->getParentsCategories($id_lang) as $p_cat) { // remove root and current category from the URL - if (!in_array($p_cat['id_category'], self::$category_disable_rewrite + array($category->id))) { + if (!in_array($p_cat['id_category'], array_merge(self::$category_disable_rewrite, array($category->id)))) { $p_cats[] = $p_cat['link_rewrite']; } } From 5b362bdf8c6b4c09df202ee598501d1e033705ba Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 25 Aug 2015 11:51:54 +0200 Subject: [PATCH 073/174] Fix category name from short_link --- override/classes/Dispatcher.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index 2560e46..0e95732 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -145,10 +145,10 @@ public static function isProductLink($short_link) public static function isCategoryLink($short_link) { // check if parent categories - $categories = explode('/', $short_link); + $category = basename($short_link); $sql = 'SELECT `id_category` FROM `'._DB_PREFIX_.'category_lang` - WHERE `link_rewrite` = \''.pSQL($categories[0]).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; + WHERE `link_rewrite` = \''.pSQL($category).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); From 6847244f3b2900f02e2ef5d1f2f07645b5ea42a0 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 25 Aug 2015 12:33:48 +0200 Subject: [PATCH 074/174] Update README.md --- README.md | 58 +++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index adc48dd..fd02ad5 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,11 @@ [ABOUT](https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs) =============================================================== -It has been tested on PS 1.6.0.9 - 1.6.0.14 +It has been reported to work on PS 1.5.6 - 1.6.1.x We are going to merge other users' contributions and ideas as soon as we note them and find the time to test. -If you fork please make every change the way we can pull, don't reinvent the wheel .. make every custom changeon a private branch, so you can merge your own changes to the community mintained full branch every time a new release is out. +If you fork please make every change the way we can pull, don't reinvent the wheel .. make every custom change on a private branch, so you can merge your own changes to the community mintained full branch every time a new release is out. INSTALLATION -------- @@ -19,42 +19,42 @@ In the modules tab, click on **add a new module**. Click on Browse to open the d ###Make sure your SEO and URL settings are as follows: This is __MANDATORY__ -* products: {categories:/}{rewrite} (you **can** add .html at the end) -* categories: {parent_categories:/}{rewrite}**/** -* manufacturers: manufactures/{rewrite} -* suppliers: suppliers/{rewrite} -* CMS page: info/{rewrite} (you **can** add .html at the end) -* CMS category: info/{rewrite}**/** -* modules: module/{module}{/:controller} + * products: {category:/}{rewrite} (you **can** add .html at the end) + * categories: {parent_categories:/}{rewrite}**/** + * manufacturers: manufactures/{rewrite} + * suppliers: suppliers/{rewrite} + * CMS page: info/{rewrite} (you **can** add .html at the end) + * CMS category: info/{rewrite}**/** + * modules: module/{module}{/:controller} -You can replace words such as "info", "module", etc with whatever you want given that it does not conflicts with a category name +You can replace words such as "info", "suppliers", etc with whatever you want given that it does not conflicts with a category name -Keep in mind to -* **clear the browser cache** -* **clear PS cache** (under smarty -> cache and smarty -> compile) +Remember to + * **clear the browser cache** + * **clear PS cache** (under smarty -> cache and smarty -> compile) UNINSTALLATION -------- -Go to modules -> Find and uninstall "CleanURL". **It should suffice!** +* Go to modules -> Find and uninstall "**zzcleanurl**" -If something goes wrong do the following: - -Open folder /override/classes/ --> Remove "Link.php" --> Remove "Dispatcher.php" +**It should suffice!** -Open folder /override/controllers/front/ --> Remove "CategoryController.php" --> Remove "CmsController.php" --> Remove "ManufacturerController.php" --> Remove "ProductController.php" --> Remove "SupplierController.php" -Open folder /cache/ --> Remove "class_index.php" +If something goes wrong do the following: +* Open folder /override/classes/ + * Remove "Link.php" + * Remove "Dispatcher.php" +* Open folder /override/controllers/front/ + * Remove "CategoryController.php" + * Remove "CmsController.php" + * Remove "ManufacturerController.php" + * Remove "ProductController.php" + * Remove "SupplierController.php" +* Open folder /cache/ + * Remove "class_index.php" +* Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL off -> Save +* Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL on -> Save -Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL off -> Save -Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL on -> Save If you got any other override modules, you should now go to you back office, uninstall them, and reinstall them again to work correctly. From b4eaf4676ae75c869f2fcd6ed4937e55b130d986 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 25 Aug 2015 12:34:48 +0200 Subject: [PATCH 075/174] Update zzcleanurls.php --- zzcleanurls.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zzcleanurls.php b/zzcleanurls.php index 56902d5..e1956a4 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -29,7 +29,7 @@ public function __construct() $this->version = '0.9'; $this->author = 'ZiZuu Store'; $this->need_instance = 0; - $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); + $this->ps_versions_compliancy = array('min' => '1.5', 'max' => _PS_VERSION_); $this->bootstrap = true; parent::__construct(); From c729b804143edc801193a98f27aeeea2d1d2cf07 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 25 Aug 2015 12:37:23 +0200 Subject: [PATCH 076/174] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fd02ad5..ee54189 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [ABOUT](https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs) =============================================================== -It has been reported to work on PS 1.5.6 - 1.6.1.x +It has been reported to work on **PS 1.5.6 - 1.6.1.x** We are going to merge other users' contributions and ideas as soon as we note them and find the time to test. @@ -12,7 +12,7 @@ If you fork please make every change the way we can pull, don't reinvent the whe INSTALLATION -------- -Install the module from the Backoffice (administration panel), download the release ZIP binary as it already contains the right folder name (cleanurls, not cleanurls-version_x.y.z !) +Install the module from the Backoffice (administration panel), download the release ZIP binary as it already contains the right folder name (zzcleanurls, **not** zzcleanurls-version_x.y.z !) In the modules tab, click on **add a new module**. Click on Browse to open the dialogue box letting you search your computer, select the file then validate the dialogue box. Finally click on Upload this module. @@ -36,7 +36,7 @@ Remember to UNINSTALLATION -------- -* Go to modules -> Find and uninstall "**zzcleanurl**" +* Go to modules -> Find and uninstall "**zzcleanurls**" **It should suffice!** From 8a9382af191f6f0e5cc0577f78d9014836644461 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 25 Aug 2015 15:46:33 +0200 Subject: [PATCH 077/174] PSR2 --- .gitignore | 1 + override/classes/Dispatcher.php | 660 +++++++++--------- override/classes/Link.php | 275 ++++---- .../classes/controller/FrontController.php | 32 +- .../controllers/front/CategoryController.php | 27 +- override/controllers/front/CmsController.php | 45 +- .../front/ManufacturerController.php | 33 +- .../controllers/front/ProductController.php | 51 +- .../controllers/front/SupplierController.php | 29 +- zzcleanurls.php | 165 ++--- 10 files changed, 666 insertions(+), 652 deletions(-) diff --git a/.gitignore b/.gitignore index 81a856e..2379fc7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .svn .DS_Store .*.swp +.php_cs.cache diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index 0e95732..1c2e1d1 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -19,359 +19,369 @@ class Dispatcher extends DispatcherCore { - /** - * @var array List of default routes - */ - public $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' => '{categories:/}{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}/filter/{selected_filters}', - 'keywords' => array( - 'id' => array('regexp' => '[0-9]+'), - /* Selected filters is used by the module blocklayered */ - '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' => '{parent_categories:/}{rewrite}/', - 'keywords' => array( - 'id' => array('regexp' => '[0-9]+'), - '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_categories' => array('regexp' => '[/_a-zA-Z0-9\pL-]*'), - ), - ), - ); - - /** - * Check if $short_link is a Product Link - * - * @param string $short_link: requested url without '?' part and without '/' on begining - * @return bool true: it's a link to product, false: it isn't - */ - public static function isProductLink($short_link) - { - $sql = 'SELECT `id_product` + /** + * @var array List of default routes + */ + public $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' => '{categories:/}{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}/filter/{selected_filters}', + 'keywords' => array( + 'id' => array('regexp' => '[0-9]+'), + /* Selected filters is used by the module blocklayered */ + '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' => '{parent_categories:/}{rewrite}/', + 'keywords' => array( + 'id' => array('regexp' => '[0-9]+'), + '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_categories' => array('regexp' => '[/_a-zA-Z0-9\pL-]*'), + ), + ), + ); + + /** + * Check if $short_link is a Product Link + * + * @param string $short_link: requested url without '?' part and without '/' on begining + * @return bool true: it's a link to product, false: it isn't + */ + public static function isProductLink($short_link) + { + $sql = 'SELECT `id_product` FROM `'._DB_PREFIX_.'product_lang` WHERE `link_rewrite` = \''.pSQL(basename($short_link, '.html')).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); + } - $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - - return ($id_product > 0); - } - - /** - * Check if $short_link is a Category Link - * - * @param string $short_link: requested url without '?' part and without '/' on begining - * @return bool true: it's a link to category, false: it isn't - */ - public static function isCategoryLink($short_link) - { - // check if parent categories - $category = basename($short_link); - - $sql = 'SELECT `id_category` FROM `'._DB_PREFIX_.'category_lang` + $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + + return ($id_product > 0); + } + + /** + * Check if $short_link is a Category Link + * + * @param string $short_link: requested url without '?' part and without '/' on begining + * @return bool true: it's a link to category, false: it isn't + */ + public static function isCategoryLink($short_link) + { + // check if parent categories + $category = basename($short_link); + + $sql = 'SELECT `id_category` FROM `'._DB_PREFIX_.'category_lang` WHERE `link_rewrite` = \''.pSQL($category).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); - - $id_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - - return ($id_category > 0); - } + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); + } + + $id_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + + return ($id_category > 0); + } - /** - * Check if $short_link is a Cms Link - * - * @param string $short_link: requested url without '?' part and without '/' on begining - * @return bool true: it's a link to cms page, false: it isn't - */ - public static function isCmsLink($short_link) - { - $sql = 'SELECT l.`id_cms` + /** + * Check if $short_link is a Cms Link + * + * @param string $short_link: requested url without '?' part and without '/' on begining + * @return bool true: it's a link to cms page, false: it isn't + */ + public static function isCmsLink($short_link) + { + $sql = 'SELECT l.`id_cms` FROM `'._DB_PREFIX_.'cms_lang` l LEFT JOIN `'._DB_PREFIX_.'cms_shop` s ON (l.`id_cms` = s.`id_cms`) WHERE l.`link_rewrite` = \''.pSQL(basename($short_link, '.html')).'\''; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + } - $id_cms = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - - return ($id_cms > 0); - } - - /** - * Check if $short_link is a Manufacturer Link - * - * @param string $short_link: requested url without '?' part and without '/' on begining - * @return bool true: it's a link to manufacturer, false: it isn't - */ - public static function isManufacturerLink($short_link) - { - $manufacturer = str_replace('-', '%', basename($short_link)); + $id_cms = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + + return ($id_cms > 0); + } + + /** + * Check if $short_link is a Manufacturer Link + * + * @param string $short_link: requested url without '?' part and without '/' on begining + * @return bool true: it's a link to manufacturer, false: it isn't + */ + public static function isManufacturerLink($short_link) + { + $manufacturer = str_replace('-', '%', basename($short_link)); - $sql = 'SELECT m.`id_manufacturer` + $sql = 'SELECT m.`id_manufacturer` FROM `'._DB_PREFIX_.'manufacturer` m LEFT JOIN `'._DB_PREFIX_.'manufacturer_shop` s ON (m.`id_manufacturer` = s.`id_manufacturer`) WHERE m.`name` LIKE \''.pSQL($manufacturer).'\''; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + } - $id_manufacturer = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - - return ($id_manufacturer > 0); - } + $id_manufacturer = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + + return ($id_manufacturer > 0); + } - /** - * Check if $short_link is a Supplier Link - * - * @param string $short_link: requested url without '?' part and without '/' on begining - * @return bool true: it's a link to supplier, false: it isn't - */ - public static function isSupplierLink($short_link) - { - $supplier = str_replace('-', '%', basename($short_link)); + /** + * Check if $short_link is a Supplier Link + * + * @param string $short_link: requested url without '?' part and without '/' on begining + * @return bool true: it's a link to supplier, false: it isn't + */ + public static function isSupplierLink($short_link) + { + $supplier = str_replace('-', '%', basename($short_link)); - $sql = 'SELECT sp.`id_supplier` + $sql = 'SELECT sp.`id_supplier` FROM `'._DB_PREFIX_.'supplier` sp LEFT JOIN `'._DB_PREFIX_.'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`) WHERE sp.`name` LIKE \''.pSQL($supplier).'\''; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + } - $id_supplier = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - - return ($id_supplier > 0); - } + $id_supplier = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + + return ($id_supplier > 0); + } - /** - * Retrieve the controller from url or request uri if routes are activated - * - * @return string - */ - public function getController($id_shop = null) - { - if (defined('_PS_ADMIN_DIR_')) - $_GET['controllerUri'] = Tools::getvalue('controller'); + /** + * Retrieve the controller from url or request uri if routes are activated + * + * @return string + */ + public function getController($id_shop = null) + { + if (defined('_PS_ADMIN_DIR_')) { + $_GET['controllerUri'] = Tools::getvalue('controller'); + } - if ($this->controller) - { - $_GET['controller'] = $this->controller; - return $this->controller; - } + if ($this->controller) { + $_GET['controller'] = $this->controller; + return $this->controller; + } - if (null === $id_shop) - $id_shop = (int)Context::getContext()->shop->id; + if (null === $id_shop) { + $id_shop = (int)Context::getContext()->shop->id; + } - $controller = Tools::getValue('controller'); - - if (isset($controller) && is_string($controller) && preg_match('/^([0-9a-z_-]+)\?(.*)=(.*)$/Ui', $controller, $m)) - { - $controller = $m[1]; - if (isset($_GET['controller'])) - $_GET[$m[2]] = $m[3]; - elseif (isset($_POST['controller'])) - $_POST[$m[2]] = $m[3]; - } + $controller = Tools::getValue('controller'); + + if (isset($controller) && is_string($controller) && preg_match('/^([0-9a-z_-]+)\?(.*)=(.*)$/Ui', $controller, $m)) { + $controller = $m[1]; + if (isset($_GET['controller'])) { + $_GET[$m[2]] = $m[3]; + } elseif (isset($_POST['controller'])) { + $_POST[$m[2]] = $m[3]; + } + } - if (!Validate::isControllerName($controller)) - $controller = false; - - // Use routes ? (for url rewriting) - if ($this->use_routes && !$controller && !defined('_PS_ADMIN_DIR_')) - { - if (!$this->request_uri) - return strtolower($this->controller_not_found); - $controller = $this->controller_not_found; - - // If the request_uri matches a static file, then there is no need to check the routes, we keep "controller_not_found" (a static file should not go through the dispatcher) - if (!preg_match('/\.(gif|jpe?g|png|css|js|ico)$/i', $this->request_uri)) - { - // Add empty route as last route to prevent this greedy regexp to match request uri before right time - if ($this->empty_route) - $this->addRoute($this->empty_route['routeID'], $this->empty_route['rule'], $this->empty_route['controller'], Context::getContext()->language->id, array(), array(), $id_shop); + if (!Validate::isControllerName($controller)) { + $controller = false; + } + + // Use routes ? (for url rewriting) + if ($this->use_routes && !$controller && !defined('_PS_ADMIN_DIR_')) { + if (!$this->request_uri) { + return strtolower($this->controller_not_found); + } + $controller = $this->controller_not_found; + + // If the request_uri matches a static file, then there is no need to check the routes, we keep "controller_not_found" (a static file should not go through the dispatcher) + if (!preg_match('/\.(gif|jpe?g|png|css|js|ico)$/i', $this->request_uri)) { + // Add empty route as last route to prevent this greedy regexp to match request uri before right time + if ($this->empty_route) { + $this->addRoute($this->empty_route['routeID'], $this->empty_route['rule'], $this->empty_route['controller'], Context::getContext()->language->id, array(), array(), $id_shop); + } - list($uri) = explode('?', $this->request_uri); + list($uri) = explode('?', $this->request_uri); - if (isset($this->routes[$id_shop][Context::getContext()->language->id])) - { - $findRoute = array(); - - // check, whether request_uri is template or not - foreach ($this->routes[$id_shop][Context::getContext()->language->id] as $route) - { - if (preg_match($route['regexp'], $uri, $m)) - { - $isTemplate = false; - - switch($route['controller']) - { - case 'supplier': - case 'manufacturer': - // these two can be processed in normal way and also as template - if (false !== strpos($route['rule'], '{')) - $isTemplate = true; - break; - - case 'cms': - case 'product': - $isTemplate = true; - break; - case 'category': - // category can be processed in two ways - if (false === strpos($route['rule'], 'selected_filters')) - $isTemplate = true; - break; - } - - if (!$isTemplate) - { - $findRoute = $route; - break; - } - } - } - - // if route is not found, we have to find rewrite link in database - if (empty($findRoute)) - { - // get the path from requested URI, and remove "/" at the beginning - $short_link = ltrim(parse_url($uri, PHP_URL_PATH), '/'); - - if (!Dispatcher::isProductLink($short_link)) - if (!Dispatcher::isCategoryLink($short_link)) - if (!Dispatcher::isCmsLink($short_link)) - if (!Dispatcher::isManufacturerLink($short_link)) - if (!Dispatcher::isSupplierLink($short_link)) - {} - else - $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['supplier_rule']; - else - $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['manufacturer_rule']; - else - $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['cms_rule']; - else - $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['category_rule']; - else - $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['product_rule']; - } + if (isset($this->routes[$id_shop][Context::getContext()->language->id])) { + $findRoute = array(); + + // check, whether request_uri is template or not + foreach ($this->routes[$id_shop][Context::getContext()->language->id] as $route) { + if (preg_match($route['regexp'], $uri, $m)) { + $isTemplate = false; + + switch ($route['controller']) { + case 'supplier': + case 'manufacturer': + // these two can be processed in normal way and also as template + if (false !== strpos($route['rule'], '{')) { + $isTemplate = true; + } + break; + + case 'cms': + case 'product': + $isTemplate = true; + break; + case 'category': + // category can be processed in two ways + if (false === strpos($route['rule'], 'selected_filters')) { + $isTemplate = true; + } + break; + } + + if (!$isTemplate) { + $findRoute = $route; + break; + } + } + } + + // if route is not found, we have to find rewrite link in database + if (empty($findRoute)) { + // get the path from requested URI, and remove "/" at the beginning + $short_link = ltrim(parse_url($uri, PHP_URL_PATH), '/'); + + if (!Dispatcher::isProductLink($short_link)) { + if (!Dispatcher::isCategoryLink($short_link)) { + if (!Dispatcher::isCmsLink($short_link)) { + if (!Dispatcher::isManufacturerLink($short_link)) { + if (!Dispatcher::isSupplierLink($short_link)) { + } else { + $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['supplier_rule']; + } + } else { + $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['manufacturer_rule']; + } + } else { + $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['cms_rule']; + } + } else { + $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['category_rule']; + } + } else { + $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['product_rule']; + } + } - if (!empty($findRoute)) - { - if (preg_match($findRoute['regexp'], $uri, $m)) - { - // Route found ! Now fill $_GET with parameters of uri - foreach ($m as $k => $v) - if (!is_numeric($k)) - $_GET[$k] = $v; - - $controller = $findRoute['controller'] ? $findRoute['controller'] : $_GET['controller']; - if (!empty($findRoute['params'])) - foreach ($findRoute['params'] as $k => $v) - $_GET[$k] = $v; - - // A patch for module friendly urls - if (preg_match('#module-([a-z0-9_-]+)-([a-z0-9]+)$#i', $controller, $m)) - { - $_GET['module'] = $m[1]; - $_GET['fc'] = 'module'; - $controller = $m[2]; - } - - if (isset($_GET['fc']) && $_GET['fc'] == 'module') - $this->front_controller = self::FC_MODULE; - } - } - } - } - - if ($controller == 'index' || $this->request_uri == '/index.php') - $controller = $this->default_controller; - $this->controller = $controller; - } - else // Default mode, take controller from url - $this->controller = $controller; + if (!empty($findRoute)) { + if (preg_match($findRoute['regexp'], $uri, $m)) { + // Route found ! Now fill $_GET with parameters of uri + foreach ($m as $k => $v) { + if (!is_numeric($k)) { + $_GET[$k] = $v; + } + } + + $controller = $findRoute['controller'] ? $findRoute['controller'] : $_GET['controller']; + if (!empty($findRoute['params'])) { + foreach ($findRoute['params'] as $k => $v) { + $_GET[$k] = $v; + } + } + + // A patch for module friendly urls + if (preg_match('#module-([a-z0-9_-]+)-([a-z0-9]+)$#i', $controller, $m)) { + $_GET['module'] = $m[1]; + $_GET['fc'] = 'module'; + $controller = $m[2]; + } + + if (isset($_GET['fc']) && $_GET['fc'] == 'module') { + $this->front_controller = self::FC_MODULE; + } + } + } + } + } + + if ($controller == 'index' || $this->request_uri == '/index.php') { + $controller = $this->default_controller; + } + $this->controller = $controller; + } else { // Default mode, take controller from url + $this->controller = $controller; + } - $this->controller = str_replace('-', '', $this->controller); - $_GET['controller'] = $this->controller; + $this->controller = str_replace('-', '', $this->controller); + $_GET['controller'] = $this->controller; - return $this->controller; - } + return $this->controller; + } } diff --git a/override/classes/Link.php b/override/classes/Link.php index 9ded5ca..5f35de3 100644 --- a/override/classes/Link.php +++ b/override/classes/Link.php @@ -19,142 +19,141 @@ class Link extends LinkCore { - /** - * Create a link to a category - * - * @param mixed $category Category object (can be an ID category, but deprecated) - * @param string $alias - * @param int $id_lang - * @param string $selected_filters Url parameter to autocheck filters of the module blocklayered - * @return string - */ - public function getCategoryLink($category, $alias = null, $id_lang = null, $selected_filters = null, $id_shop = null, $relative_protocol = false) - { - if (!$id_lang) - $id_lang = Context::getContext()->language->id; - - $url = $this->getBaseLink($id_shop, null, $relative_protocol).$this->getLangLink($id_lang, null, $id_shop); - - if (!is_object($category)) - $category = new Category($category, $id_lang); - - // Set available keywords - $params = array(); - $params['id'] = $category->id; - $params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias; - $params['meta_keywords'] = Tools::str2url($category->getFieldByLang('meta_keywords')); - $params['meta_title'] = Tools::str2url($category->getFieldByLang('meta_title')); - - // Selected filters is used by the module blocklayered - $selected_filters = is_null($selected_filters) ? '' : $selected_filters; - - if (empty($selected_filters)) - $rule = 'category_rule'; - else - { - $rule = 'layered_rule'; - $params['selected_filters'] = $selected_filters; - } - - $dispatcher = Dispatcher::getInstance(); - - if ($dispatcher->hasKeyword('category_rule', $id_lang, 'parent_categories')) - { - // Retrieve all parent categories - $p_cats = array(); - foreach ($category->getParentsCategories($id_lang) as $p_cat) - { - // remove root and current category from the URL - if (!in_array($p_cat['id_category'], array_merge(self::$category_disable_rewrite, array($category->id)))) { - $p_cats[] = $p_cat['link_rewrite']; - } - } - // add the URL slashes among categories, in reverse order - $params['parent_categories'] = implode('/', array_reverse($p_cats)); - } - - return $url.$dispatcher->createUrl($rule, $id_lang, $params, $this->allow, '', $id_shop); - } - - - /** - * Get pagination link - * - * @param string $type Controller name - * @param int $id_object - * @param boolean $nb Show nb element per page attribute - * @param boolean $sort Show sort attribute - * @param boolean $pagination Show page number attribute - * @param boolean $array If false return an url, if true return an array - */ - public function getPaginationLink($type, $id_object, $nb = false, $sort = false, $pagination = false, $array = false) - { - // if no parameter $type, try to get it by using the controller name - if (!$type && !$id_object) - { - $method_name = 'get'.Dispatcher::getInstance()->getController().'Link'; - if (method_exists($this, $method_name) && isset($_GET['id_'.Dispatcher::getInstance()->getController()])) - { - $type = Dispatcher::getInstance()->getController(); - $id_object = $_GET['id_'.$type]; - } - } - - if ($type && $id_object) - $url = $this->{'get'.$type.'Link'}($id_object, null); - else - { - if (isset(Context::getContext()->controller->php_self)) - $name = Context::getContext()->controller->php_self; - else - $name = Dispatcher::getInstance()->getController(); - $url = $this->getPageLink($name); - } - - $vars = array(); - $vars_nb = array('n', 'search_query'); - $vars_sort = array('orderby', 'orderway'); - $vars_pagination = array('p'); - - foreach ($_GET as $k => $value) - { - // strip var of the form "*_rewrite" from url - if ($k != 'id_'.$type && $k != $type.'_rewrite' && $k != 'controller') - { - if (Configuration::get('PS_REWRITING_SETTINGS') && ($k == 'isolang' || $k == 'id_lang')) - continue; - - $if_nb = (!$nb || ($nb && !in_array($k, $vars_nb))); - $if_sort = (!$sort || ($sort && !in_array($k, $vars_sort))); - $if_pagination = (!$pagination || ($pagination && !in_array($k, $vars_pagination))); - if ($if_nb && $if_sort && $if_pagination) - if (!is_array($value)) - $vars[urlencode($k)] = $value; - else - { - foreach (explode('&', http_build_query(array($k => $value), '', '&')) as $key => $val) - { - $data = explode('=', $val); - $vars[urldecode($data[0])] = $data[1]; - } - } - } - } - - if (!$array) - if (count($vars)) - return $url.(($this->allow == 1 || $url == $this->url) ? '?' : '&').http_build_query($vars, '', '&'); - else - return $url; - - $vars['requestUrl'] = $url; - - if ($type && $id_object) - $vars['id_'.$type] = (is_object($id_object) ? (int)$id_object->id : (int)$id_object); - - if (!$this->allow == 1) - $vars['controller'] = Dispatcher::getInstance()->getController(); - - return $vars; - } + /** + * Create a link to a category + * + * @param mixed $category Category object (can be an ID category, but deprecated) + * @param string $alias + * @param int $id_lang + * @param string $selected_filters Url parameter to autocheck filters of the module blocklayered + * @return string + */ + public function getCategoryLink($category, $alias = null, $id_lang = null, $selected_filters = null, $id_shop = null, $relative_protocol = false) + { + if (!$id_lang) { + $id_lang = Context::getContext()->language->id; + } + + $url = $this->getBaseLink($id_shop, null, $relative_protocol).$this->getLangLink($id_lang, null, $id_shop); + + if (!is_object($category)) { + $category = new Category($category, $id_lang); + } + + // Set available keywords + $params = array(); + $params['id'] = $category->id; + $params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias; + $params['meta_keywords'] = Tools::str2url($category->getFieldByLang('meta_keywords')); + $params['meta_title'] = Tools::str2url($category->getFieldByLang('meta_title')); + + // Selected filters is used by the module blocklayered + $selected_filters = is_null($selected_filters) ? '' : $selected_filters; + + if (empty($selected_filters)) { + $rule = 'category_rule'; + } else { + $rule = 'layered_rule'; + $params['selected_filters'] = $selected_filters; + } + + $dispatcher = Dispatcher::getInstance(); + + if ($dispatcher->hasKeyword('category_rule', $id_lang, 'parent_categories')) { + // Retrieve all parent categories + $p_cats = array(); + foreach ($category->getParentsCategories($id_lang) as $p_cat) { + // remove root and current category from the URL + if (!in_array($p_cat['id_category'], array_merge(self::$category_disable_rewrite, array($category->id)))) { + $p_cats[] = $p_cat['link_rewrite']; + } + } + // add the URL slashes among categories, in reverse order + $params['parent_categories'] = implode('/', array_reverse($p_cats)); + } + + return $url.$dispatcher->createUrl($rule, $id_lang, $params, $this->allow, '', $id_shop); + } + + + /** + * Get pagination link + * + * @param string $type Controller name + * @param int $id_object + * @param boolean $nb Show nb element per page attribute + * @param boolean $sort Show sort attribute + * @param boolean $pagination Show page number attribute + * @param boolean $array If false return an url, if true return an array + */ + public function getPaginationLink($type, $id_object, $nb = false, $sort = false, $pagination = false, $array = false) + { + // if no parameter $type, try to get it by using the controller name + if (!$type && !$id_object) { + $method_name = 'get'.Dispatcher::getInstance()->getController().'Link'; + if (method_exists($this, $method_name) && isset($_GET['id_'.Dispatcher::getInstance()->getController()])) { + $type = Dispatcher::getInstance()->getController(); + $id_object = $_GET['id_'.$type]; + } + } + + if ($type && $id_object) { + $url = $this->{'get'.$type.'Link'}($id_object, null); + } else { + if (isset(Context::getContext()->controller->php_self)) { + $name = Context::getContext()->controller->php_self; + } else { + $name = Dispatcher::getInstance()->getController(); + } + $url = $this->getPageLink($name); + } + + $vars = array(); + $vars_nb = array('n', 'search_query'); + $vars_sort = array('orderby', 'orderway'); + $vars_pagination = array('p'); + + foreach ($_GET as $k => $value) { + // strip var of the form "*_rewrite" from url + if ($k != 'id_'.$type && $k != $type.'_rewrite' && $k != 'controller') { + if (Configuration::get('PS_REWRITING_SETTINGS') && ($k == 'isolang' || $k == 'id_lang')) { + continue; + } + + $if_nb = (!$nb || ($nb && !in_array($k, $vars_nb))); + $if_sort = (!$sort || ($sort && !in_array($k, $vars_sort))); + $if_pagination = (!$pagination || ($pagination && !in_array($k, $vars_pagination))); + if ($if_nb && $if_sort && $if_pagination) { + if (!is_array($value)) { + $vars[urlencode($k)] = $value; + } else { + foreach (explode('&', http_build_query(array($k => $value), '', '&')) as $key => $val) { + $data = explode('=', $val); + $vars[urldecode($data[0])] = $data[1]; + } + } + } + } + } + + if (!$array) { + if (count($vars)) { + return $url.(($this->allow == 1 || $url == $this->url) ? '?' : '&').http_build_query($vars, '', '&'); + } else { + return $url; + } + } + + $vars['requestUrl'] = $url; + + if ($type && $id_object) { + $vars['id_'.$type] = (is_object($id_object) ? (int)$id_object->id : (int)$id_object); + } + + if (!$this->allow == 1) { + $vars['controller'] = Dispatcher::getInstance()->getController(); + } + + return $vars; + } } diff --git a/override/classes/controller/FrontController.php b/override/classes/controller/FrontController.php index 94c416e..d2edf2e 100644 --- a/override/classes/controller/FrontController.php +++ b/override/classes/controller/FrontController.php @@ -19,21 +19,21 @@ class FrontController extends FrontControllerCore { - protected function canonicalRedirection($canonical_url = '') - { - $excluded_keys = array( - 'product_rewrite', - 'category_rewrite', - 'manufacturer_rewrite', - 'supplier_rewrite', - 'cms_rewrite', - 'cms_category_rewrite', - ); + protected function canonicalRedirection($canonical_url = '') + { + $excluded_keys = array( + 'product_rewrite', + 'category_rewrite', + 'manufacturer_rewrite', + 'supplier_rewrite', + 'cms_rewrite', + 'cms_category_rewrite', + ); - // hack original behavior on cananocalRedirection: remove *_rewrite from _GET - $unfiltered_GET = $_GET; - $_GET = array_diff_key($_GET, array_flip($excluded_keys)); - parent::canonicalRedirection($canonical_url); - $_GET = $unfiltered_GET; - } + // hack original behavior on cananocalRedirection: remove *_rewrite from _GET + $unfiltered_GET = $_GET; + $_GET = array_diff_key($_GET, array_flip($excluded_keys)); + parent::canonicalRedirection($canonical_url); + $_GET = $unfiltered_GET; + } } diff --git a/override/controllers/front/CategoryController.php b/override/controllers/front/CategoryController.php index b560d7d..eca9a40 100644 --- a/override/controllers/front/CategoryController.php +++ b/override/controllers/front/CategoryController.php @@ -19,21 +19,22 @@ class CategoryController extends CategoryControllerCore { - public function init() - { - if ($category_rewrite = Tools::getValue('category_rewrite')) - { - $sql = 'SELECT `id_category` FROM `'._DB_PREFIX_.'category_lang` + public function init() + { + if ($category_rewrite = Tools::getValue('category_rewrite')) { + $sql = 'SELECT `id_category` FROM `'._DB_PREFIX_.'category_lang` WHERE `link_rewrite` = \''.pSQL($category_rewrite).'\' AND `id_lang` = '.Context::getContext()->language->id; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); + } - $id_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - if ($id_category > 0) - $_GET['id_category'] = $id_category; - } + $id_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + if ($id_category > 0) { + $_GET['id_category'] = $id_category; + } + } - parent::init(); - } + parent::init(); + } } diff --git a/override/controllers/front/CmsController.php b/override/controllers/front/CmsController.php index a06e7d1..6e5c88c 100644 --- a/override/controllers/front/CmsController.php +++ b/override/controllers/front/CmsController.php @@ -19,35 +19,36 @@ class CmsController extends CmsControllerCore { - public function init() - { - if ($cms_rewrite = Tools::getValue('cms_rewrite')) - { - $sql = 'SELECT l.`id_cms` + public function init() + { + if ($cms_rewrite = Tools::getValue('cms_rewrite')) { + $sql = 'SELECT l.`id_cms` FROM `'._DB_PREFIX_.'cms_lang` l LEFT JOIN `'._DB_PREFIX_.'cms_shop` s ON (l.`id_cms` = s.`id_cms`) WHERE l.`link_rewrite` = \''.pSQL(str_replace('.html', '', $cms_rewrite)).'\''; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + } - $id_cms = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - if ($id_cms > 0) - $_GET['id_cms'] = $id_cms; - } - elseif ($cms_category_rewrite = Tools::getValue('cms_category_rewrite')) - { - $sql = 'SELECT `id_cms_category` + $id_cms = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + if ($id_cms > 0) { + $_GET['id_cms'] = $id_cms; + } + } elseif ($cms_category_rewrite = Tools::getValue('cms_category_rewrite')) { + $sql = 'SELECT `id_cms_category` FROM `'._DB_PREFIX_.'cms_category_lang` WHERE `link_rewrite` = \''.pSQL($cms_category_rewrite).'\''; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + } - $id_cms_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - if ($id_cms_category > 0) - $_GET['id_cms_category'] = $id_cms_category; - } + $id_cms_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + if ($id_cms_category > 0) { + $_GET['id_cms_category'] = $id_cms_category; + } + } - parent::init(); - } + parent::init(); + } } diff --git a/override/controllers/front/ManufacturerController.php b/override/controllers/front/ManufacturerController.php index 750c93c..5cf2cda 100644 --- a/override/controllers/front/ManufacturerController.php +++ b/override/controllers/front/ManufacturerController.php @@ -19,28 +19,27 @@ class ManufacturerController extends ManufacturerControllerCore { - public function init() - { - if ($manufacturer_rewrite = Tools::getValue('manufacturer_rewrite')) - { - $manufacturer_rewrite = str_replace('-', '%', $manufacturer_rewrite); + public function init() + { + if ($manufacturer_rewrite = Tools::getValue('manufacturer_rewrite')) { + $manufacturer_rewrite = str_replace('-', '%', $manufacturer_rewrite); - $sql = 'SELECT m.`id_manufacturer` + $sql = 'SELECT m.`id_manufacturer` FROM `'._DB_PREFIX_.'manufacturer` m LEFT JOIN `'._DB_PREFIX_.'manufacturer_shop` s ON (m.`id_manufacturer` = s.`id_manufacturer`) WHERE m.`name` LIKE \''.pSQL($manufacturer_rewrite).'\''; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + } - $id_manufacturer = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - if ($id_manufacturer > 0) - { - $_GET['id_manufacturer'] = $id_manufacturer; - $_GET['noredirect'] = 1; - } - } + $id_manufacturer = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + if ($id_manufacturer > 0) { + $_GET['id_manufacturer'] = $id_manufacturer; + $_GET['noredirect'] = 1; + } + } - parent::init(); - } + parent::init(); + } } diff --git a/override/controllers/front/ProductController.php b/override/controllers/front/ProductController.php index 7786621..6b477b2 100644 --- a/override/controllers/front/ProductController.php +++ b/override/controllers/front/ProductController.php @@ -19,36 +19,37 @@ class ProductController extends ProductControllerCore { - public function init() - { - if ($product_rewrite = Tools::getValue('product_rewrite')) - { - $url_id_pattern = '/.*?([0-9]+)\-([a-zA-Z0-9-]*)(\.html)?/'; - $lang_id = (int)Context::getContext()->language->id; + public function init() + { + if ($product_rewrite = Tools::getValue('product_rewrite')) { + $url_id_pattern = '/.*?([0-9]+)\-([a-zA-Z0-9-]*)(\.html)?/'; + $lang_id = (int)Context::getContext()->language->id; - $sql = 'SELECT `id_product` + $sql = 'SELECT `id_product` FROM `'._DB_PREFIX_.'product_lang` WHERE `link_rewrite` = \''.pSQL(str_replace('.html', '', $product_rewrite)).'\' AND `id_lang` = '.$lang_id; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); + } - $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - if ($id_product > 0) - $_GET['id_product'] = $id_product; - elseif (preg_match($url_id_pattern, $this->request_uri, $url_parts)) - { - $sql = 'SELECT `id_product` + $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + if ($id_product > 0) { + $_GET['id_product'] = $id_product; + } elseif (preg_match($url_id_pattern, $this->request_uri, $url_parts)) { + $sql = 'SELECT `id_product` FROM `'._DB_PREFIX_.'product_lang` WHERE `id_product` = \''.pSQL($url_parts[1]).'\' AND `id_lang` = '.$lang_id; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); - - $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - if($id_product > 0) - $_GET['id_product'] = $id_product; - } - } + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); + } + + $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + if ($id_product > 0) { + $_GET['id_product'] = $id_product; + } + } + } - parent::init(); - } + parent::init(); + } } diff --git a/override/controllers/front/SupplierController.php b/override/controllers/front/SupplierController.php index 40fc923..cd399e9 100644 --- a/override/controllers/front/SupplierController.php +++ b/override/controllers/front/SupplierController.php @@ -19,25 +19,26 @@ class SupplierController extends SupplierControllerCore { - public function init() - { - if ($supplier_rewrite = Tools::getValue('supplier_rewrite')) - { - $supplier_rewrite = str_replace('-', '%', $supplier_rewrite); + public function init() + { + if ($supplier_rewrite = Tools::getValue('supplier_rewrite')) { + $supplier_rewrite = str_replace('-', '%', $supplier_rewrite); - $sql = 'SELECT sp.`id_supplier` + $sql = 'SELECT sp.`id_supplier` FROM `'._DB_PREFIX_.'supplier` sp LEFT JOIN `'._DB_PREFIX_.'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`) WHERE sp.`name` LIKE \''.pSQL($supplier_rewrite).'\''; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + } - $id_supplier = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - if($id_supplier > 0) - $_GET['id_supplier'] = $id_supplier; - } + $id_supplier = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + if ($id_supplier > 0) { + $_GET['id_supplier'] = $id_supplier; + } + } - parent::init(); - } + parent::init(); + } } diff --git a/zzcleanurls.php b/zzcleanurls.php index e1956a4..eb0492c 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -17,88 +17,89 @@ * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs */ -if (!defined('_PS_VERSION_')) - exit; +if (!defined('_PS_VERSION_')) { + exit; +} -class zzCleanUrls extends Module +class zzcleanurls extends Module { - public function __construct() - { - $this->name = 'zzcleanurls'; - $this->tab = 'seo'; - $this->version = '0.9'; - $this->author = 'ZiZuu Store'; - $this->need_instance = 0; - $this->ps_versions_compliancy = array('min' => '1.5', 'max' => _PS_VERSION_); - $this->bootstrap = true; - - parent::__construct(); - - $this->displayName = $this->l('ZiZuu Clean URLs'); - $this->description = $this->l('This override-Module allows you to remove URL ID\'s.'); - - $this->confirmUninstall = $this->l('Are you sure you want to uninstall "ZiZuu Clean URLs"?'); - } - - public function getContent() - { - $output = '

' - .nl2br($this->l('On some versions you could have to disable Cache, ' - .'save, open your shop home page, than go back and enable it: - - Advanced Parameters > Performance > Clear Smarty cache - Preferences -> SEO and URLs -> Set userfriendly URL off -> Save - Preferences -> SEO and URLs -> Set userfriendly URL on -> Save')) - .'

'; - - $sql = 'SELECT * FROM `'._DB_PREFIX_.'product_lang` - WHERE `link_rewrite` - IN (SELECT `link_rewrite` FROM `'._DB_PREFIX_.'product_lang` - GROUP BY `link_rewrite`, `id_lang` - HAVING count(`link_rewrite`) > 1)'; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) - $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); - - if ($res = Db::getInstance()->ExecuteS($sql)) - { - $err = $this->l('You need to fix duplicate URL entries:').'
'; - foreach ($res as $row) - { - $lang = $this->context->language->getLanguage($row['id_lang']); - $err .= $row['name'].' ('.$row['id_product'].') - '.$row['link_rewrite'].'
'; - - $shop = $this->context->shop->getShop($lang['id_shop']); - $err .= $this->l('Language: ').$lang['name'].'
'.$this->l('Shop: ').$shop['name'].'

'; - } - $output .= $this->displayError($err); - } - else - $output .= $this->displayConfirmation($this->l('Nice. You have no duplicate URL entry.')); - - return '
'.$output.'
'; - } - - public function install() - { - // add link_rewrite as index to improve search - $tables = array('category_lang','cms_category_lang','cms_lang','product_lang'); - foreach($tables as $tab) - { - if (!Db::getInstance()->ExecuteS('SHOW INDEX FROM `'._DB_PREFIX_.$tab.'` WHERE Key_name = \'link_rewrite\'')) - Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_.$tab.'` ADD INDEX ( `link_rewrite` )'); - } - - if (!parent::install()) - return false; - - return true; - } - - public function uninstall() - { - if (!parent::uninstall()) - return false; - - return true; - } + public function __construct() + { + $this->name = 'zzcleanurls'; + $this->tab = 'seo'; + $this->version = '0.9'; + $this->author = 'ZiZuu Store'; + $this->need_instance = 0; + $this->ps_versions_compliancy = array('min' => '1.5', 'max' => _PS_VERSION_); + $this->bootstrap = true; + + parent::__construct(); + + $this->displayName = $this->l('ZiZuu Clean URLs'); + $this->description = $this->l('This override-Module allows you to remove URL ID\'s.'); + + $this->confirmUninstall = $this->l('Are you sure you want to uninstall "ZiZuu Clean URLs"?'); + } + + public function getContent() + { + $output = '

' + .nl2br($this->l('On some versions you could have to disable Cache, ' + .'save, open your shop home page, than go back and enable it: + Advanced Parameters > Performance > Clear Smarty cache + Preferences -> SEO and URLs -> Set userfriendly URL off -> Save + Preferences -> SEO and URLs -> Set userfriendly URL on -> Save')) + .'

'; + + $sql = 'SELECT * FROM `'._DB_PREFIX_.'product_lang` + WHERE `link_rewrite` + IN (SELECT `link_rewrite` FROM `'._DB_PREFIX_.'product_lang` + GROUP BY `link_rewrite`, `id_lang` + HAVING count(`link_rewrite`) > 1)'; + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); + } + + if ($res = Db::getInstance()->ExecuteS($sql)) { + $err = $this->l('You need to fix duplicate URL entries:').'
'; + foreach ($res as $row) { + $lang = $this->context->language->getLanguage($row['id_lang']); + $err .= $row['name'].' ('.$row['id_product'].') - '.$row['link_rewrite'].'
'; + + $shop = $this->context->shop->getShop($lang['id_shop']); + $err .= $this->l('Language: ').$lang['name'].'
'.$this->l('Shop: ').$shop['name'].'

'; + } + $output .= $this->displayError($err); + } else { + $output .= $this->displayConfirmation($this->l('Nice. You have no duplicate URL entry.')); + } + + return '
'.$output.'
'; + } + + public function install() + { + // add link_rewrite as index to improve search + $tables = array('category_lang','cms_category_lang','cms_lang','product_lang'); + foreach ($tables as $tab) { + if (!Db::getInstance()->ExecuteS('SHOW INDEX FROM `'._DB_PREFIX_.$tab.'` WHERE Key_name = \'link_rewrite\'')) { + Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_.$tab.'` ADD INDEX ( `link_rewrite` )'); + } + } + + if (!parent::install()) { + return false; + } + + return true; + } + + public function uninstall() + { + if (!parent::uninstall()) { + return false; + } + + return true; + } } From 5ec816c21bdc222fb3d9c88db0dae3117600cbb2 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 25 Aug 2015 15:55:35 +0200 Subject: [PATCH 078/174] /\t/ / --- .php_cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.php_cs b/.php_cs index fc9f7bb..4a76aa9 100644 --- a/.php_cs +++ b/.php_cs @@ -6,7 +6,7 @@ return Symfony\CS\Config\Config::create() ->finder( Symfony\CS\Finder\DefaultFinder::create() ->in(__DIR__) - ) + ) ; // vim:ft=php From 72feb5bf484cc00352b9860dc0df8edd119b6c79 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 26 Aug 2015 09:54:26 +0200 Subject: [PATCH 079/174] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ee54189..71631b5 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ [ABOUT](https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs) =============================================================== -It has been reported to work on **PS 1.5.6 - 1.6.1.x** +It has been reported to work on **PS 1.5.6 - 1.6.1.x** but will install on PS >= 1.5 too. +**If you succesfully use this module on some older version please report** We are going to merge other users' contributions and ideas as soon as we note them and find the time to test. From b17c86cdb22188cfd2fc658e295471013bc993d7 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 26 Aug 2015 10:12:40 +0200 Subject: [PATCH 080/174] Update zzcleanurls.php --- zzcleanurls.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zzcleanurls.php b/zzcleanurls.php index eb0492c..ba1bc0d 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -27,7 +27,7 @@ public function __construct() { $this->name = 'zzcleanurls'; $this->tab = 'seo'; - $this->version = '0.9'; + $this->version = '0.10.0'; $this->author = 'ZiZuu Store'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.5', 'max' => _PS_VERSION_); From eb4b92177b128e415fdf43300a3aed74ed6ecb48 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 26 Aug 2015 10:12:58 +0200 Subject: [PATCH 081/174] Update config.xml --- config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.xml b/config.xml index cc5cbd9..b6f012b 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ zzcleanurls - + From 2e68643237af8fe99713b5f0a05f6ce94e182fd0 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 26 Aug 2015 10:28:15 +0200 Subject: [PATCH 082/174] Update README.md --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 71631b5..c31e334 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,23 @@ -# Prestashop module "ZiZuu CLean URLs" +[Prestashop module "ZiZuu CLean URLs"](https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs) +== -[ABOUT](https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs) -=============================================================== - -It has been reported to work on **PS 1.5.6 - 1.6.1.x** but will install on PS >= 1.5 too. -**If you succesfully use this module on some older version please report** +* For production use the **latest stable [release](https://github.com/ZiZuu-store/PrestaShop_module-zzCleanURLs/releases/)** +* For developing or Pull Request please use only the "**[dev](https://github.com/ZiZuu-store/PrestaShop_module-zzCleanURLs/tree/dev)**" branch We are going to merge other users' contributions and ideas as soon as we note them and find the time to test. If you fork please make every change the way we can pull, don't reinvent the wheel .. make every custom change on a private branch, so you can merge your own changes to the community mintained full branch every time a new release is out. -INSTALLATION --------- +It has been reported to work on **PS 1.5.6 - 1.6.1.x** but will install on PS >= 1.5 too. +**If you succesfully use this module on some older version please report** + +## INSTALLATION Install the module from the Backoffice (administration panel), download the release ZIP binary as it already contains the right folder name (zzcleanurls, **not** zzcleanurls-version_x.y.z !) In the modules tab, click on **add a new module**. Click on Browse to open the dialogue box letting you search your computer, select the file then validate the dialogue box. Finally click on Upload this module. -###Make sure your SEO and URL settings are as follows: +### Make sure your SEO and URL settings are as follows: This is __MANDATORY__ * products: {category:/}{rewrite} (you **can** add .html at the end) From b32bddfdcdab55b6109ac80d5773c8428fd86747 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 26 Aug 2015 10:52:09 +0200 Subject: [PATCH 083/174] Update README.md --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c31e334..0f408e2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[Prestashop module "ZiZuu CLean URLs"](https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs) +[Prestashop module "ZiZuu Clean URLs"](https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs) == * For production use the **latest stable [release](https://github.com/ZiZuu-store/PrestaShop_module-zzCleanURLs/releases/)** @@ -34,8 +34,7 @@ Remember to * **clear the browser cache** * **clear PS cache** (under smarty -> cache and smarty -> compile) -UNINSTALLATION --------- +## UNINSTALLATION * Go to modules -> Find and uninstall "**zzcleanurls**" From 6a6a887a7655dd97a577311b1043c7cd67f47876 Mon Sep 17 00:00:00 2001 From: The Gitter Badger Date: Fri, 28 Aug 2015 12:06:08 +0000 Subject: [PATCH 084/174] Added Gitter badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0f408e2..05c24ae 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ It has been reported to work on **PS 1.5.6 - 1.6.1.x** but will install on PS >= ## INSTALLATION +[![Join the chat at https://gitter.im/ZiZuu-store/PrestaShop_module-zzCleanURLs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ZiZuu-store/PrestaShop_module-zzCleanURLs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + Install the module from the Backoffice (administration panel), download the release ZIP binary as it already contains the right folder name (zzcleanurls, **not** zzcleanurls-version_x.y.z !) In the modules tab, click on **add a new module**. Click on Browse to open the dialogue box letting you search your computer, select the file then validate the dialogue box. Finally click on Upload this module. From 574b84defa4cc05abe22245aae4b447a1d7fb0ab Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 28 Aug 2015 14:09:39 +0200 Subject: [PATCH 085/174] move the gitter badge up --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 05c24ae..bef03f4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ [Prestashop module "ZiZuu Clean URLs"](https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs) == +[![Join the chat at https://gitter.im/ZiZuu-store/PrestaShop_module-zzCleanURLs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ZiZuu-store/PrestaShop_module-zzCleanURLs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + * For production use the **latest stable [release](https://github.com/ZiZuu-store/PrestaShop_module-zzCleanURLs/releases/)** * For developing or Pull Request please use only the "**[dev](https://github.com/ZiZuu-store/PrestaShop_module-zzCleanURLs/tree/dev)**" branch @@ -13,8 +15,6 @@ It has been reported to work on **PS 1.5.6 - 1.6.1.x** but will install on PS >= ## INSTALLATION -[![Join the chat at https://gitter.im/ZiZuu-store/PrestaShop_module-zzCleanURLs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ZiZuu-store/PrestaShop_module-zzCleanURLs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - Install the module from the Backoffice (administration panel), download the release ZIP binary as it already contains the right folder name (zzcleanurls, **not** zzcleanurls-version_x.y.z !) In the modules tab, click on **add a new module**. Click on Browse to open the dialogue box letting you search your computer, select the file then validate the dialogue box. Finally click on Upload this module. From 7e729e0206aaccc7b49555f0a1b22e339563d3be Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 1 Sep 2015 09:56:18 +0200 Subject: [PATCH 086/174] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bef03f4..23af093 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ [Prestashop module "ZiZuu Clean URLs"](https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs) == -[![Join the chat at https://gitter.im/ZiZuu-store/PrestaShop_module-zzCleanURLs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ZiZuu-store/PrestaShop_module-zzCleanURLs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Join the chat at https://gitter.im/ZiZuu-store/zzCleanURLs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ZiZuu-store/zzCleanURLs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -* For production use the **latest stable [release](https://github.com/ZiZuu-store/PrestaShop_module-zzCleanURLs/releases/)** -* For developing or Pull Request please use only the "**[dev](https://github.com/ZiZuu-store/PrestaShop_module-zzCleanURLs/tree/dev)**" branch +* For production use the **latest stable [release](https://github.com/ZiZuu-store/zzCleanURLs/releases/)** +* For developing or Pull Request please use only the "**[dev](https://github.com/ZiZuu-store/zzCleanURLs/tree/dev)**" branch We are going to merge other users' contributions and ideas as soon as we note them and find the time to test. @@ -15,7 +15,7 @@ It has been reported to work on **PS 1.5.6 - 1.6.1.x** but will install on PS >= ## INSTALLATION -Install the module from the Backoffice (administration panel), download the release ZIP binary as it already contains the right folder name (zzcleanurls, **not** zzcleanurls-version_x.y.z !) +Install the module from the Backoffice (administration panel), download the release ZIP file as it already contains the right folder name (zzcleanurls, **not** zzcleanurls-version_x.y.z !) In the modules tab, click on **add a new module**. Click on Browse to open the dialogue box letting you search your computer, select the file then validate the dialogue box. Finally click on Upload this module. From 2be04abf84c441e86258ce504192db645323e425 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 7 Sep 2015 19:06:42 +0200 Subject: [PATCH 087/174] Just spaces fix --- override/classes/Dispatcher.php | 70 +++++++++---------- override/classes/Link.php | 8 +-- override/classes/index.php | 2 +- .../controllers/front/CategoryController.php | 2 +- override/controllers/front/CmsController.php | 10 +-- .../front/ManufacturerController.php | 6 +- .../controllers/front/ProductController.php | 10 +-- .../controllers/front/SupplierController.php | 6 +- override/controllers/front/index.php | 2 +- override/controllers/index.php | 2 +- zzcleanurls.php | 2 +- 11 files changed, 60 insertions(+), 60 deletions(-) diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index 1c2e1d1..7015dd9 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -116,7 +116,7 @@ class Dispatcher extends DispatcherCore ), ), ); - + /** * Check if $short_link is a Product Link * @@ -126,17 +126,17 @@ class Dispatcher extends DispatcherCore public static function isProductLink($short_link) { $sql = 'SELECT `id_product` - FROM `'._DB_PREFIX_.'product_lang` - WHERE `link_rewrite` = \''.pSQL(basename($short_link, '.html')).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; + FROM `'._DB_PREFIX_.'product_lang` + WHERE `link_rewrite` = \''.pSQL(basename($short_link, '.html')).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); } $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - + return ($id_product > 0); } - + /** * Check if $short_link is a Category Link * @@ -147,15 +147,15 @@ public static function isCategoryLink($short_link) { // check if parent categories $category = basename($short_link); - + $sql = 'SELECT `id_category` FROM `'._DB_PREFIX_.'category_lang` - WHERE `link_rewrite` = \''.pSQL($category).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; + WHERE `link_rewrite` = \''.pSQL($category).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); } - + $id_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - + return ($id_category > 0); } @@ -168,18 +168,18 @@ public static function isCategoryLink($short_link) public static function isCmsLink($short_link) { $sql = 'SELECT l.`id_cms` - FROM `'._DB_PREFIX_.'cms_lang` l - LEFT JOIN `'._DB_PREFIX_.'cms_shop` s ON (l.`id_cms` = s.`id_cms`) - WHERE l.`link_rewrite` = \''.pSQL(basename($short_link, '.html')).'\''; + FROM `'._DB_PREFIX_.'cms_lang` l + LEFT JOIN `'._DB_PREFIX_.'cms_shop` s ON (l.`id_cms` = s.`id_cms`) + WHERE l.`link_rewrite` = \''.pSQL(basename($short_link, '.html')).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); } $id_cms = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - + return ($id_cms > 0); } - + /** * Check if $short_link is a Manufacturer Link * @@ -191,15 +191,15 @@ public static function isManufacturerLink($short_link) $manufacturer = str_replace('-', '%', basename($short_link)); $sql = 'SELECT m.`id_manufacturer` - FROM `'._DB_PREFIX_.'manufacturer` m - LEFT JOIN `'._DB_PREFIX_.'manufacturer_shop` s ON (m.`id_manufacturer` = s.`id_manufacturer`) - WHERE m.`name` LIKE \''.pSQL($manufacturer).'\''; + FROM `'._DB_PREFIX_.'manufacturer` m + LEFT JOIN `'._DB_PREFIX_.'manufacturer_shop` s ON (m.`id_manufacturer` = s.`id_manufacturer`) + WHERE m.`name` LIKE \''.pSQL($manufacturer).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); } $id_manufacturer = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - + return ($id_manufacturer > 0); } @@ -214,15 +214,15 @@ public static function isSupplierLink($short_link) $supplier = str_replace('-', '%', basename($short_link)); $sql = 'SELECT sp.`id_supplier` - FROM `'._DB_PREFIX_.'supplier` sp - LEFT JOIN `'._DB_PREFIX_.'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`) - WHERE sp.`name` LIKE \''.pSQL($supplier).'\''; + FROM `'._DB_PREFIX_.'supplier` sp + LEFT JOIN `'._DB_PREFIX_.'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`) + WHERE sp.`name` LIKE \''.pSQL($supplier).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); } $id_supplier = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - + return ($id_supplier > 0); } @@ -247,7 +247,7 @@ public function getController($id_shop = null) } $controller = Tools::getValue('controller'); - + if (isset($controller) && is_string($controller) && preg_match('/^([0-9a-z_-]+)\?(.*)=(.*)$/Ui', $controller, $m)) { $controller = $m[1]; if (isset($_GET['controller'])) { @@ -260,14 +260,14 @@ public function getController($id_shop = null) if (!Validate::isControllerName($controller)) { $controller = false; } - + // Use routes ? (for url rewriting) if ($this->use_routes && !$controller && !defined('_PS_ADMIN_DIR_')) { if (!$this->request_uri) { return strtolower($this->controller_not_found); } $controller = $this->controller_not_found; - + // If the request_uri matches a static file, then there is no need to check the routes, we keep "controller_not_found" (a static file should not go through the dispatcher) if (!preg_match('/\.(gif|jpe?g|png|css|js|ico)$/i', $this->request_uri)) { // Add empty route as last route to prevent this greedy regexp to match request uri before right time @@ -279,12 +279,12 @@ public function getController($id_shop = null) if (isset($this->routes[$id_shop][Context::getContext()->language->id])) { $findRoute = array(); - + // check, whether request_uri is template or not foreach ($this->routes[$id_shop][Context::getContext()->language->id] as $route) { if (preg_match($route['regexp'], $uri, $m)) { $isTemplate = false; - + switch ($route['controller']) { case 'supplier': case 'manufacturer': @@ -293,7 +293,7 @@ public function getController($id_shop = null) $isTemplate = true; } break; - + case 'cms': case 'product': $isTemplate = true; @@ -305,19 +305,19 @@ public function getController($id_shop = null) } break; } - + if (!$isTemplate) { $findRoute = $route; break; } } } - + // if route is not found, we have to find rewrite link in database if (empty($findRoute)) { // get the path from requested URI, and remove "/" at the beginning $short_link = ltrim(parse_url($uri, PHP_URL_PATH), '/'); - + if (!Dispatcher::isProductLink($short_link)) { if (!Dispatcher::isCategoryLink($short_link)) { if (!Dispatcher::isCmsLink($short_link)) { @@ -348,21 +348,21 @@ public function getController($id_shop = null) $_GET[$k] = $v; } } - + $controller = $findRoute['controller'] ? $findRoute['controller'] : $_GET['controller']; if (!empty($findRoute['params'])) { foreach ($findRoute['params'] as $k => $v) { $_GET[$k] = $v; } } - + // A patch for module friendly urls if (preg_match('#module-([a-z0-9_-]+)-([a-z0-9]+)$#i', $controller, $m)) { $_GET['module'] = $m[1]; $_GET['fc'] = 'module'; $controller = $m[2]; } - + if (isset($_GET['fc']) && $_GET['fc'] == 'module') { $this->front_controller = self::FC_MODULE; } @@ -370,7 +370,7 @@ public function getController($id_shop = null) } } } - + if ($controller == 'index' || $this->request_uri == '/index.php') { $controller = $this->default_controller; } diff --git a/override/classes/Link.php b/override/classes/Link.php index 5f35de3..4576e81 100644 --- a/override/classes/Link.php +++ b/override/classes/Link.php @@ -12,7 +12,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author ZiZuu.com + * @author ZiZuu.com * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs */ @@ -71,7 +71,7 @@ public function getCategoryLink($category, $alias = null, $id_lang = null, $sele // add the URL slashes among categories, in reverse order $params['parent_categories'] = implode('/', array_reverse($p_cats)); } - + return $url.$dispatcher->createUrl($rule, $id_lang, $params, $this->allow, '', $id_shop); } @@ -143,13 +143,13 @@ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, return $url; } } - + $vars['requestUrl'] = $url; if ($type && $id_object) { $vars['id_'.$type] = (is_object($id_object) ? (int)$id_object->id : (int)$id_object); } - + if (!$this->allow == 1) { $vars['controller'] = Dispatcher::getInstance()->getController(); } diff --git a/override/classes/index.php b/override/classes/index.php index 16ac24f..8c9e938 100644 --- a/override/classes/index.php +++ b/override/classes/index.php @@ -1,7 +1,7 @@ language->id; + WHERE `link_rewrite` = \''.pSQL($category_rewrite).'\' AND `id_lang` = '.Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); diff --git a/override/controllers/front/CmsController.php b/override/controllers/front/CmsController.php index 6e5c88c..2a94240 100644 --- a/override/controllers/front/CmsController.php +++ b/override/controllers/front/CmsController.php @@ -23,9 +23,9 @@ public function init() { if ($cms_rewrite = Tools::getValue('cms_rewrite')) { $sql = 'SELECT l.`id_cms` - FROM `'._DB_PREFIX_.'cms_lang` l - LEFT JOIN `'._DB_PREFIX_.'cms_shop` s ON (l.`id_cms` = s.`id_cms`) - WHERE l.`link_rewrite` = \''.pSQL(str_replace('.html', '', $cms_rewrite)).'\''; + FROM `'._DB_PREFIX_.'cms_lang` l + LEFT JOIN `'._DB_PREFIX_.'cms_shop` s ON (l.`id_cms` = s.`id_cms`) + WHERE l.`link_rewrite` = \''.pSQL(str_replace('.html', '', $cms_rewrite)).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); } @@ -36,8 +36,8 @@ public function init() } } elseif ($cms_category_rewrite = Tools::getValue('cms_category_rewrite')) { $sql = 'SELECT `id_cms_category` - FROM `'._DB_PREFIX_.'cms_category_lang` - WHERE `link_rewrite` = \''.pSQL($cms_category_rewrite).'\''; + FROM `'._DB_PREFIX_.'cms_category_lang` + WHERE `link_rewrite` = \''.pSQL($cms_category_rewrite).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); diff --git a/override/controllers/front/ManufacturerController.php b/override/controllers/front/ManufacturerController.php index 5cf2cda..0458103 100644 --- a/override/controllers/front/ManufacturerController.php +++ b/override/controllers/front/ManufacturerController.php @@ -25,9 +25,9 @@ public function init() $manufacturer_rewrite = str_replace('-', '%', $manufacturer_rewrite); $sql = 'SELECT m.`id_manufacturer` - FROM `'._DB_PREFIX_.'manufacturer` m - LEFT JOIN `'._DB_PREFIX_.'manufacturer_shop` s ON (m.`id_manufacturer` = s.`id_manufacturer`) - WHERE m.`name` LIKE \''.pSQL($manufacturer_rewrite).'\''; + FROM `'._DB_PREFIX_.'manufacturer` m + LEFT JOIN `'._DB_PREFIX_.'manufacturer_shop` s ON (m.`id_manufacturer` = s.`id_manufacturer`) + WHERE m.`name` LIKE \''.pSQL($manufacturer_rewrite).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); diff --git a/override/controllers/front/ProductController.php b/override/controllers/front/ProductController.php index 6b477b2..ff5f106 100644 --- a/override/controllers/front/ProductController.php +++ b/override/controllers/front/ProductController.php @@ -26,8 +26,8 @@ public function init() $lang_id = (int)Context::getContext()->language->id; $sql = 'SELECT `id_product` - FROM `'._DB_PREFIX_.'product_lang` - WHERE `link_rewrite` = \''.pSQL(str_replace('.html', '', $product_rewrite)).'\' AND `id_lang` = '.$lang_id; + FROM `'._DB_PREFIX_.'product_lang` + WHERE `link_rewrite` = \''.pSQL(str_replace('.html', '', $product_rewrite)).'\' AND `id_lang` = '.$lang_id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); } @@ -37,12 +37,12 @@ public function init() $_GET['id_product'] = $id_product; } elseif (preg_match($url_id_pattern, $this->request_uri, $url_parts)) { $sql = 'SELECT `id_product` - FROM `'._DB_PREFIX_.'product_lang` - WHERE `id_product` = \''.pSQL($url_parts[1]).'\' AND `id_lang` = '.$lang_id; + FROM `'._DB_PREFIX_.'product_lang` + WHERE `id_product` = \''.pSQL($url_parts[1]).'\' AND `id_lang` = '.$lang_id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); } - + $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_product > 0) { $_GET['id_product'] = $id_product; diff --git a/override/controllers/front/SupplierController.php b/override/controllers/front/SupplierController.php index cd399e9..ad1d251 100644 --- a/override/controllers/front/SupplierController.php +++ b/override/controllers/front/SupplierController.php @@ -25,9 +25,9 @@ public function init() $supplier_rewrite = str_replace('-', '%', $supplier_rewrite); $sql = 'SELECT sp.`id_supplier` - FROM `'._DB_PREFIX_.'supplier` sp - LEFT JOIN `'._DB_PREFIX_.'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`) - WHERE sp.`name` LIKE \''.pSQL($supplier_rewrite).'\''; + FROM `'._DB_PREFIX_.'supplier` sp + LEFT JOIN `'._DB_PREFIX_.'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`) + WHERE sp.`name` LIKE \''.pSQL($supplier_rewrite).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); diff --git a/override/controllers/front/index.php b/override/controllers/front/index.php index 16ac24f..8c9e938 100644 --- a/override/controllers/front/index.php +++ b/override/controllers/front/index.php @@ -1,7 +1,7 @@ Date: Wed, 9 Sep 2015 14:17:54 +0200 Subject: [PATCH 088/174] Fix license disclaimer --- index.php | 13 +++++-------- override/classes/Dispatcher.php | 13 +++++-------- override/classes/Link.php | 13 +++++-------- override/classes/controller/FrontController.php | 13 +++++-------- override/classes/controller/index.php | 13 +++++-------- override/classes/index.php | 13 +++++-------- override/controllers/front/CategoryController.php | 15 ++++++--------- override/controllers/front/CmsController.php | 13 +++++-------- .../controllers/front/ManufacturerController.php | 13 +++++-------- override/controllers/front/ProductController.php | 13 +++++-------- override/controllers/front/SupplierController.php | 13 +++++-------- override/controllers/front/index.php | 13 +++++-------- override/controllers/index.php | 13 +++++-------- override/index.php | 13 +++++-------- zzcleanurls.php | 15 ++++++--------- 15 files changed, 77 insertions(+), 122 deletions(-) diff --git a/index.php b/index.php index 16ac24f..e72b7ae 100644 --- a/index.php +++ b/index.php @@ -1,20 +1,17 @@ - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @source https://github.com/ZiZuu-store/zzCleanURLs */ header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index 7015dd9..f52b32c 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -1,20 +1,17 @@ - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @source https://github.com/ZiZuu-store/zzCleanURLs */ class Dispatcher extends DispatcherCore diff --git a/override/classes/Link.php b/override/classes/Link.php index 4576e81..8096120 100644 --- a/override/classes/Link.php +++ b/override/classes/Link.php @@ -1,20 +1,17 @@ - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @source https://github.com/ZiZuu-store/zzCleanURLs */ class Link extends LinkCore diff --git a/override/classes/controller/FrontController.php b/override/classes/controller/FrontController.php index d2edf2e..7b1932f 100644 --- a/override/classes/controller/FrontController.php +++ b/override/classes/controller/FrontController.php @@ -1,20 +1,17 @@ - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @source https://github.com/ZiZuu-store/zzCleanURLs */ class FrontController extends FrontControllerCore diff --git a/override/classes/controller/index.php b/override/classes/controller/index.php index 16ac24f..e72b7ae 100644 --- a/override/classes/controller/index.php +++ b/override/classes/controller/index.php @@ -1,20 +1,17 @@ - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @source https://github.com/ZiZuu-store/zzCleanURLs */ header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); diff --git a/override/classes/index.php b/override/classes/index.php index 8c9e938..e72b7ae 100644 --- a/override/classes/index.php +++ b/override/classes/index.php @@ -1,20 +1,17 @@ - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @source https://github.com/ZiZuu-store/zzCleanURLs */ header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); diff --git a/override/controllers/front/CategoryController.php b/override/controllers/front/CategoryController.php index 2667ae1..3464556 100644 --- a/override/controllers/front/CategoryController.php +++ b/override/controllers/front/CategoryController.php @@ -1,20 +1,17 @@ - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @author ZiZuu.com + * @source https://github.com/ZiZuu-store/zzCleanURLs */ class CategoryController extends CategoryControllerCore diff --git a/override/controllers/front/CmsController.php b/override/controllers/front/CmsController.php index 2a94240..b09f9fe 100644 --- a/override/controllers/front/CmsController.php +++ b/override/controllers/front/CmsController.php @@ -1,20 +1,17 @@ - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @source https://github.com/ZiZuu-store/zzCleanURLs */ class CmsController extends CmsControllerCore diff --git a/override/controllers/front/ManufacturerController.php b/override/controllers/front/ManufacturerController.php index 0458103..13f4ed4 100644 --- a/override/controllers/front/ManufacturerController.php +++ b/override/controllers/front/ManufacturerController.php @@ -1,20 +1,17 @@ - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @source https://github.com/ZiZuu-store/zzCleanURLs */ class ManufacturerController extends ManufacturerControllerCore diff --git a/override/controllers/front/ProductController.php b/override/controllers/front/ProductController.php index ff5f106..0f69195 100644 --- a/override/controllers/front/ProductController.php +++ b/override/controllers/front/ProductController.php @@ -1,20 +1,17 @@ - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @source https://github.com/ZiZuu-store/zzCleanURLs */ class ProductController extends ProductControllerCore diff --git a/override/controllers/front/SupplierController.php b/override/controllers/front/SupplierController.php index ad1d251..c06d90d 100644 --- a/override/controllers/front/SupplierController.php +++ b/override/controllers/front/SupplierController.php @@ -1,20 +1,17 @@ - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @source https://github.com/ZiZuu-store/zzCleanURLs */ class SupplierController extends SupplierControllerCore diff --git a/override/controllers/front/index.php b/override/controllers/front/index.php index 8c9e938..e72b7ae 100644 --- a/override/controllers/front/index.php +++ b/override/controllers/front/index.php @@ -1,20 +1,17 @@ - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @source https://github.com/ZiZuu-store/zzCleanURLs */ header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); diff --git a/override/controllers/index.php b/override/controllers/index.php index 8c9e938..e72b7ae 100644 --- a/override/controllers/index.php +++ b/override/controllers/index.php @@ -1,20 +1,17 @@ - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @source https://github.com/ZiZuu-store/zzCleanURLs */ header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); diff --git a/override/index.php b/override/index.php index 16ac24f..e72b7ae 100644 --- a/override/index.php +++ b/override/index.php @@ -1,20 +1,17 @@ - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @source https://github.com/ZiZuu-store/zzCleanURLs */ header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); diff --git a/zzcleanurls.php b/zzcleanurls.php index 22f5d03..053ef99 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -1,20 +1,17 @@ - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * @source https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs + * @author ZiZuu.com + * @source https://github.com/ZiZuu-store/zzCleanURLs */ if (!defined('_PS_VERSION_')) { From c49af5767a7fbba46aa87ce9147c6db7252354c1 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 9 Sep 2015 14:31:45 +0200 Subject: [PATCH 089/174] code cleanup on front controllers --- override/controllers/front/CategoryController.php | 1 - override/controllers/front/CmsController.php | 1 - override/controllers/front/ManufacturerController.php | 6 +----- override/controllers/front/SupplierController.php | 5 +---- 4 files changed, 2 insertions(+), 11 deletions(-) diff --git a/override/controllers/front/CategoryController.php b/override/controllers/front/CategoryController.php index 3464556..7cfac20 100644 --- a/override/controllers/front/CategoryController.php +++ b/override/controllers/front/CategoryController.php @@ -21,7 +21,6 @@ public function init() if ($category_rewrite = Tools::getValue('category_rewrite')) { $sql = 'SELECT `id_category` FROM `'._DB_PREFIX_.'category_lang` WHERE `link_rewrite` = \''.pSQL($category_rewrite).'\' AND `id_lang` = '.Context::getContext()->language->id; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); } diff --git a/override/controllers/front/CmsController.php b/override/controllers/front/CmsController.php index b09f9fe..5c5dfe7 100644 --- a/override/controllers/front/CmsController.php +++ b/override/controllers/front/CmsController.php @@ -35,7 +35,6 @@ public function init() $sql = 'SELECT `id_cms_category` FROM `'._DB_PREFIX_.'cms_category_lang` WHERE `link_rewrite` = \''.pSQL($cms_category_rewrite).'\''; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); } diff --git a/override/controllers/front/ManufacturerController.php b/override/controllers/front/ManufacturerController.php index 13f4ed4..5f95a7e 100644 --- a/override/controllers/front/ManufacturerController.php +++ b/override/controllers/front/ManufacturerController.php @@ -19,13 +19,10 @@ class ManufacturerController extends ManufacturerControllerCore public function init() { if ($manufacturer_rewrite = Tools::getValue('manufacturer_rewrite')) { - $manufacturer_rewrite = str_replace('-', '%', $manufacturer_rewrite); - $sql = 'SELECT m.`id_manufacturer` FROM `'._DB_PREFIX_.'manufacturer` m LEFT JOIN `'._DB_PREFIX_.'manufacturer_shop` s ON (m.`id_manufacturer` = s.`id_manufacturer`) - WHERE m.`name` LIKE \''.pSQL($manufacturer_rewrite).'\''; - + WHERE m.`name` LIKE \''.pSQL(str_replace('-', '%', $manufacturer_rewrite)).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); } @@ -33,7 +30,6 @@ public function init() $id_manufacturer = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_manufacturer > 0) { $_GET['id_manufacturer'] = $id_manufacturer; - $_GET['noredirect'] = 1; } } diff --git a/override/controllers/front/SupplierController.php b/override/controllers/front/SupplierController.php index c06d90d..2b22b57 100644 --- a/override/controllers/front/SupplierController.php +++ b/override/controllers/front/SupplierController.php @@ -19,13 +19,10 @@ class SupplierController extends SupplierControllerCore public function init() { if ($supplier_rewrite = Tools::getValue('supplier_rewrite')) { - $supplier_rewrite = str_replace('-', '%', $supplier_rewrite); - $sql = 'SELECT sp.`id_supplier` FROM `'._DB_PREFIX_.'supplier` sp LEFT JOIN `'._DB_PREFIX_.'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`) - WHERE sp.`name` LIKE \''.pSQL($supplier_rewrite).'\''; - + WHERE sp.`name` LIKE \''.pSQL(str_replace('-', '%', $supplier_rewrite)).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); } From 99abeb4e2dff174b20314621ec1c91a1eb8757e0 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 9 Sep 2015 14:34:35 +0200 Subject: [PATCH 090/174] better comment for hack --- override/classes/controller/FrontController.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/override/classes/controller/FrontController.php b/override/classes/controller/FrontController.php index 7b1932f..2ad7b0d 100644 --- a/override/classes/controller/FrontController.php +++ b/override/classes/controller/FrontController.php @@ -27,10 +27,9 @@ protected function canonicalRedirection($canonical_url = '') 'cms_category_rewrite', ); - // hack original behavior on cananocalRedirection: remove *_rewrite from _GET $unfiltered_GET = $_GET; - $_GET = array_diff_key($_GET, array_flip($excluded_keys)); + $_GET = array_diff_key($_GET, array_flip($excluded_keys)); // hack original behavior on cananocalRedirection: remove *_rewrite from _GET parent::canonicalRedirection($canonical_url); - $_GET = $unfiltered_GET; + $_GET = $unfiltered_GET; //restore original _GET } } From 3bddb203a13d51c1634e2b2520b438ce87522567 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 9 Sep 2015 16:31:02 +0200 Subject: [PATCH 091/174] better comments on FrontController.php --- override/classes/controller/FrontController.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/override/classes/controller/FrontController.php b/override/classes/controller/FrontController.php index 2ad7b0d..f7798ee 100644 --- a/override/classes/controller/FrontController.php +++ b/override/classes/controller/FrontController.php @@ -16,8 +16,18 @@ class FrontController extends FrontControllerCore { + /** + * Redirects to canonical URL + * + * Excludes "*_rewrite" URLs from being treated as non-canonical + * + * @param string $canonical_url + */ protected function canonicalRedirection($canonical_url = '') { + /* + * TODO: replace with a generic "*_rewrite" filter + */ $excluded_keys = array( 'product_rewrite', 'category_rewrite', From 7cd2e4b0c3088838d67abecd41dd8f5a138f1e86 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 9 Sep 2015 16:31:28 +0200 Subject: [PATCH 092/174] sync Link.php with its alter-ego in current PS --- override/classes/Link.php | 46 ++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/override/classes/Link.php b/override/classes/Link.php index 8096120..262fa94 100644 --- a/override/classes/Link.php +++ b/override/classes/Link.php @@ -72,20 +72,49 @@ public function getCategoryLink($category, $alias = null, $id_lang = null, $sele return $url.$dispatcher->createUrl($rule, $id_lang, $params, $this->allow, '', $id_shop); } + /** + * XXX TODO + * Create a link to a module + * + * @since 1.5.0 + * @param string $module Module name + * @param string $process Action name + * @param int $id_lang + * @return string + */ + public function getModuleLink($module, $controller = 'default', array $params = array(), $ssl = null, $id_lang = null, $id_shop = null, $relative_protocol = false) + { + if (!$id_lang) { + $id_lang = Context::getContext()->language->id; + } + + $url = $this->getBaseLink($id_shop, $ssl, $relative_protocol).$this->getLangLink($id_lang, null, $id_shop); + + // Set available keywords + $params['module'] = $module; + $params['controller'] = $controller ? $controller : 'default'; + + // If the module has its own route ... just use it ! + if (Dispatcher::getInstance()->hasRoute('module-'.$module.'-'.$controller, $id_lang, $id_shop)) { + return $this->getPageLink('module-'.$module.'-'.$controller, $ssl, $id_lang, $params); + } else { + return $url.Dispatcher::getInstance()->createUrl('module', $id_lang, $params, $this->allow, '', $id_shop); + } + } /** * Get pagination link * * @param string $type Controller name * @param int $id_object - * @param boolean $nb Show nb element per page attribute - * @param boolean $sort Show sort attribute - * @param boolean $pagination Show page number attribute - * @param boolean $array If false return an url, if true return an array + * @param bool $nb Show nb element per page attribute + * @param bool $sort Show sort attribute + * @param bool $pagination Show page number attribute + * @param bool $array If false return an url, if true return an array */ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, $pagination = false, $array = false) { - // if no parameter $type, try to get it by using the controller name + // If no parameter $type, try to get it by using the controller name if (!$type && !$id_object) { $method_name = 'get'.Dispatcher::getInstance()->getController().'Link'; if (method_exists($this, $method_name) && isset($_GET['id_'.Dispatcher::getInstance()->getController()])) { @@ -111,12 +140,10 @@ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, $vars_pagination = array('p'); foreach ($_GET as $k => $value) { - // strip var of the form "*_rewrite" from url - if ($k != 'id_'.$type && $k != $type.'_rewrite' && $k != 'controller') { + if ($k != 'id_'.$type && $k != 'controller' && $k != $type.'_rewrite') { /*XXX skip *_rewrite */ if (Configuration::get('PS_REWRITING_SETTINGS') && ($k == 'isolang' || $k == 'id_lang')) { continue; } - $if_nb = (!$nb || ($nb && !in_array($k, $vars_nb))); $if_sort = (!$sort || ($sort && !in_array($k, $vars_sort))); $if_pagination = (!$pagination || ($pagination && !in_array($k, $vars_pagination))); @@ -135,7 +162,7 @@ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, if (!$array) { if (count($vars)) { - return $url.(($this->allow == 1 || $url == $this->url) ? '?' : '&').http_build_query($vars, '', '&'); + return $url.(!strstr($url, '?') && ($this->allow == 1 || $url == $this->url) ? '?' : '&').http_build_query($vars, '', '&'); } else { return $url; } @@ -150,7 +177,6 @@ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, if (!$this->allow == 1) { $vars['controller'] = Dispatcher::getInstance()->getController(); } - return $vars; } } From 2b38cad5aafa77bdf990930f7ce9fdb35417a473 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 10 Sep 2015 14:08:13 +0200 Subject: [PATCH 093/174] added italian translation for the module config --- config_it.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 config_it.xml diff --git a/config_it.xml b/config_it.xml new file mode 100644 index 0000000..87b9eff --- /dev/null +++ b/config_it.xml @@ -0,0 +1,13 @@ + + + zzcleanurls + + + + + + + 1 + 0 + + From f510fad346ff21029a1b4fa2105e86d1a5aad997 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 17 Sep 2015 19:08:16 +0200 Subject: [PATCH 094/174] Make overrides to install/unistall cleanly --- override/classes/Dispatcher.php | 197 +++++++++--------- override/classes/Link.php | 14 -- .../classes/controller/FrontController.php | 14 -- .../controllers/front/CategoryController.php | 14 -- override/controllers/front/CmsController.php | 14 -- .../front/ManufacturerController.php | 14 -- .../controllers/front/ProductController.php | 14 -- .../controllers/front/SupplierController.php | 14 -- zzcleanurls.php | 2 +- 9 files changed, 95 insertions(+), 202 deletions(-) diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index f52b32c..4b244b1 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -1,118 +1,108 @@ - * @source https://github.com/ZiZuu-store/zzCleanURLs - */ - class Dispatcher extends DispatcherCore { - /** - * @var array List of default routes - */ - public $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-]*'), + public function __construct() + { + parent::__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-]*'), + ), ), - ), - '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-]*'), + '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_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-]*'), + '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-]*'), + ), ), - ), - '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'), + '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-]*'), + ), ), - 'params' => array( - 'fc' => 'module', + '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' => '{categories:/}{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-]*'), + 'product_rule' => array( + 'controller' => 'product', + 'rule' => '{categories:/}{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}/filter/{selected_filters}', - 'keywords' => array( - 'id' => array('regexp' => '[0-9]+'), - /* Selected filters is used by the module blocklayered */ - '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]*'), + 'layered_rule' => array( + 'controller' => 'category', + 'rule' => '{rewrite}/filter{selected_filters}', + 'keywords' => array( + 'id' => array('regexp' => '[0-9]+'), + /* Selected filters is used by the module blocklayered */ + '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' => '{parent_categories:/}{rewrite}/', - 'keywords' => array( - 'id' => array('regexp' => '[0-9]+'), - '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_categories' => array('regexp' => '[/_a-zA-Z0-9\pL-]*'), + 'category_rule' => array( + 'controller' => 'category', + 'rule' => '{categories:/}{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-]*'), + ), ), - ), - ); + ); + } /** * Check if $short_link is a Product Link @@ -226,6 +216,7 @@ public static function isSupplierLink($short_link) /** * Retrieve the controller from url or request uri if routes are activated * + * @param int $id_shop, defaults null * @return string */ public function getController($id_shop = null) diff --git a/override/classes/Link.php b/override/classes/Link.php index 262fa94..d1c231e 100644 --- a/override/classes/Link.php +++ b/override/classes/Link.php @@ -1,19 +1,5 @@ - * @source https://github.com/ZiZuu-store/zzCleanURLs - */ - class Link extends LinkCore { /** diff --git a/override/classes/controller/FrontController.php b/override/classes/controller/FrontController.php index f7798ee..9c5d1e6 100644 --- a/override/classes/controller/FrontController.php +++ b/override/classes/controller/FrontController.php @@ -1,19 +1,5 @@ - * @source https://github.com/ZiZuu-store/zzCleanURLs - */ - class FrontController extends FrontControllerCore { /** diff --git a/override/controllers/front/CategoryController.php b/override/controllers/front/CategoryController.php index 7cfac20..4bef4dc 100644 --- a/override/controllers/front/CategoryController.php +++ b/override/controllers/front/CategoryController.php @@ -1,19 +1,5 @@ - * @source https://github.com/ZiZuu-store/zzCleanURLs - */ - class CategoryController extends CategoryControllerCore { public function init() diff --git a/override/controllers/front/CmsController.php b/override/controllers/front/CmsController.php index 5c5dfe7..1d2968c 100644 --- a/override/controllers/front/CmsController.php +++ b/override/controllers/front/CmsController.php @@ -1,19 +1,5 @@ - * @source https://github.com/ZiZuu-store/zzCleanURLs - */ - class CmsController extends CmsControllerCore { public function init() diff --git a/override/controllers/front/ManufacturerController.php b/override/controllers/front/ManufacturerController.php index 5f95a7e..36b5772 100644 --- a/override/controllers/front/ManufacturerController.php +++ b/override/controllers/front/ManufacturerController.php @@ -1,19 +1,5 @@ - * @source https://github.com/ZiZuu-store/zzCleanURLs - */ - class ManufacturerController extends ManufacturerControllerCore { public function init() diff --git a/override/controllers/front/ProductController.php b/override/controllers/front/ProductController.php index 0f69195..2cc077c 100644 --- a/override/controllers/front/ProductController.php +++ b/override/controllers/front/ProductController.php @@ -1,19 +1,5 @@ - * @source https://github.com/ZiZuu-store/zzCleanURLs - */ - class ProductController extends ProductControllerCore { public function init() diff --git a/override/controllers/front/SupplierController.php b/override/controllers/front/SupplierController.php index 2b22b57..7dbe8fc 100644 --- a/override/controllers/front/SupplierController.php +++ b/override/controllers/front/SupplierController.php @@ -1,19 +1,5 @@ - * @source https://github.com/ZiZuu-store/zzCleanURLs - */ - class SupplierController extends SupplierControllerCore { public function init() diff --git a/zzcleanurls.php b/zzcleanurls.php index 053ef99..dbb0386 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -66,7 +66,7 @@ public function getContent() $shop = $this->context->shop->getShop($lang['id_shop']); $err .= $this->l('Language: ').$lang['name'].'
'.$this->l('Shop: ').$shop['name'].'

'; } - $output .= $this->displayError($err); + $output .= $this->displayWarning($err); } else { $output .= $this->displayConfirmation($this->l('Nice. You have no duplicate URL entry.')); } From 368a071bf1d71e39fb2a2eabbd69764dc7e49374 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 18 Sep 2015 13:51:41 +0200 Subject: [PATCH 095/174] fixed translations mechanism --- .gitignore | 1 + config_it.xml | 13 ------------- translations/it.php | 11 +++++++++++ 3 files changed, 12 insertions(+), 13 deletions(-) delete mode 100644 config_it.xml create mode 100644 translations/it.php diff --git a/.gitignore b/.gitignore index 2379fc7..e48dc1d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .DS_Store .*.swp .php_cs.cache +config_*.xml diff --git a/config_it.xml b/config_it.xml deleted file mode 100644 index 87b9eff..0000000 --- a/config_it.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - zzcleanurls - - - - - - - 1 - 0 - - diff --git a/translations/it.php b/translations/it.php new file mode 100644 index 0000000..b7b3f9c --- /dev/null +++ b/translations/it.php @@ -0,0 +1,11 @@ +zzcleanurls_66711d755755f94e8f48d9cb858290c8'] = 'ZiZuu Clean URLs'; +$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_4abf1025eb40d230f80b0470e5c60696'] = 'Questo modulo permette di rimuovere gli ID dalle URL. Utilizza gli \"override\".'; +$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_3c3419c3ec1896fbfd5c37549eda9144'] = 'Sicuro di voler rimuovere il modulo \"ZiZuu Clean URLs\"?'; +$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_851645568061b03aeeb2b4c2af435a5e'] = 'Dovresti eliminare queste URL duplicate:'; +$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_c961f5d807b8ae34a9a4a825606f953b'] = 'Lingua:'; +$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_63de125555fddc0e009f92ec0e9e64e4'] = 'Negozio:'; +$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_dae2931f3df26903e6ddbb123b751344'] = 'Perfetto. Non ci sono URL duplicate.'; From 2c4809cdb30cfa494d88268b1a04f5b96ad75031 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 18 Sep 2015 17:01:17 +0200 Subject: [PATCH 096/174] better translations --- translations/it.php | 9 +++++++++ zzcleanurls.php | 17 ++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/translations/it.php b/translations/it.php index b7b3f9c..d1c471d 100644 --- a/translations/it.php +++ b/translations/it.php @@ -5,6 +5,15 @@ $_MODULE['<{zzcleanurls}prestashop>zzcleanurls_66711d755755f94e8f48d9cb858290c8'] = 'ZiZuu Clean URLs'; $_MODULE['<{zzcleanurls}prestashop>zzcleanurls_4abf1025eb40d230f80b0470e5c60696'] = 'Questo modulo permette di rimuovere gli ID dalle URL. Utilizza gli \"override\".'; $_MODULE['<{zzcleanurls}prestashop>zzcleanurls_3c3419c3ec1896fbfd5c37549eda9144'] = 'Sicuro di voler rimuovere il modulo \"ZiZuu Clean URLs\"?'; +$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_8aa6176f15ae0b8ec0f7f7797bc129cb'] = 'In alcune versioni di Prestashop potrebbe essere necessario disabilitare la Cache, salvare, accedere al proprio negozio e riabilitare la cache di nuovo:'; +$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_c9d7eedc8be4380c02106619824b8449'] = 'Parametri avanzati'; +$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_9446a98ad14416153cc4d45ab8b531bf'] = 'Prestazioni'; +$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_341be761f9f11e9b06dac0071fb8a5ed'] = 'pulisci la Cache'; +$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_d0834fcec6337785ee749c8f5464f6f6'] = 'Impostazioni'; +$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_acc42ebe7b6b25f7d6ea8618f514f79b'] = 'SEO and URLs'; +$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_a3637ddc43eefbe21947f64210bae984'] = 'disattivare \"Friendly url\"'; +$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_c9cc8cce247e49bae79f15173ce97354'] = 'Salva'; +$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_7e497263357c140cc3d2396dbfa8b2eb'] = 'attivare \"Friendly url\"'; $_MODULE['<{zzcleanurls}prestashop>zzcleanurls_851645568061b03aeeb2b4c2af435a5e'] = 'Dovresti eliminare queste URL duplicate:'; $_MODULE['<{zzcleanurls}prestashop>zzcleanurls_c961f5d807b8ae34a9a4a825606f953b'] = 'Lingua:'; $_MODULE['<{zzcleanurls}prestashop>zzcleanurls_63de125555fddc0e009f92ec0e9e64e4'] = 'Negozio:'; diff --git a/zzcleanurls.php b/zzcleanurls.php index dbb0386..4ff3700 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -41,12 +41,11 @@ public function __construct() public function getContent() { $output = '

' - .nl2br($this->l('On some versions you could have to disable Cache, ' - .'save, open your shop home page, than go back and enable it: - Advanced Parameters > Performance > Clear Smarty cache - Preferences -> SEO and URLs -> Set userfriendly URL off -> Save - Preferences -> SEO and URLs -> Set userfriendly URL on -> Save')) - .'

'; + . $this->l('On some versions you could have to disable Cache, save, open your shop home page, than go back and enable it:').'

' + . sprintf('', $this->l('Advanced Parameters'), $this->l('Performance'), $this->l('Clear Smarty cache')).'
' + . sprintf('', $this->l('Preferences'), $this->l('SEO and URLs'), $this->l('Set userfriendly URL off'), $this->l('Save')).'
' + . sprintf('', $this->l('Preferences'), $this->l('SEO and URLs'), $this->l('Set userfriendly URL on'), $this->l('Save')).'
' + . '

'; $sql = 'SELECT * FROM `'._DB_PREFIX_.'product_lang` WHERE `link_rewrite` @@ -58,13 +57,13 @@ public function getContent() } if ($res = Db::getInstance()->ExecuteS($sql)) { - $err = $this->l('You need to fix duplicate URL entries:').'
'; + $err = $this->l('You need to fix duplicate URL entries:').'
'; foreach ($res as $row) { $lang = $this->context->language->getLanguage($row['id_lang']); - $err .= $row['name'].' ('.$row['id_product'].') - '.$row['link_rewrite'].'
'; + $err .= $row['name'].' ('.$row['id_product'].') - '.$row['link_rewrite'].'
'; $shop = $this->context->shop->getShop($lang['id_shop']); - $err .= $this->l('Language: ').$lang['name'].'
'.$this->l('Shop: ').$shop['name'].'

'; + $err .= $this->l('Language: ').$lang['name'].'
'.$this->l('Shop: ').$shop['name'].'

'; } $output .= $this->displayWarning($err); } else { From 6396927795b2b20ca9d69682f5f2b25692c892a3 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 18 Sep 2015 17:26:33 +0200 Subject: [PATCH 097/174] fixed missing format string for translation --- zzcleanurls.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zzcleanurls.php b/zzcleanurls.php index 4ff3700..339c711 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -42,9 +42,9 @@ public function getContent() { $output = '

' . $this->l('On some versions you could have to disable Cache, save, open your shop home page, than go back and enable it:').'

' - . sprintf('', $this->l('Advanced Parameters'), $this->l('Performance'), $this->l('Clear Smarty cache')).'
' - . sprintf('', $this->l('Preferences'), $this->l('SEO and URLs'), $this->l('Set userfriendly URL off'), $this->l('Save')).'
' - . sprintf('', $this->l('Preferences'), $this->l('SEO and URLs'), $this->l('Set userfriendly URL on'), $this->l('Save')).'
' + . sprintf('%s -> %s -> %s', $this->l('Advanced Parameters'), $this->l('Performance'), $this->l('Clear Smarty cache')).'
' + . sprintf('%s -> %s -> %s -> %s', $this->l('Preferences'), $this->l('SEO and URLs'), $this->l('Set userfriendly URL off'), $this->l('Save')).'
' + . sprintf('%s -> %s -> %s -> %s', $this->l('Preferences'), $this->l('SEO and URLs'), $this->l('Set userfriendly URL on'), $this->l('Save')).'
' . '

'; $sql = 'SELECT * FROM `'._DB_PREFIX_.'product_lang` From 00613a16153439031decd12e7b0ffcfca487d277 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 22 Sep 2015 14:51:37 +0200 Subject: [PATCH 098/174] fix categories, canonical redirection --- override/classes/Dispatcher.php | 8 +++---- override/classes/Link.php | 4 ++-- .../classes/controller/FrontController.php | 23 ++++++++----------- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index 4b244b1..96e8d11 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -62,7 +62,7 @@ public function __construct() ), 'product_rule' => array( 'controller' => 'product', - 'rule' => '{categories:/}{rewrite}', + 'rule' => '{category:/}{rewrite}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), 'rewrite' => array('regexp' => '[_a-zA-Z0-9\pL\pS-]*', 'param' => 'product_rewrite'), @@ -80,7 +80,7 @@ public function __construct() ), 'layered_rule' => array( 'controller' => 'category', - 'rule' => '{rewrite}/filter{selected_filters}', + 'rule' => '{rewrite}/f{/:selected_filters}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), /* Selected filters is used by the module blocklayered */ @@ -91,8 +91,8 @@ public function __construct() ), ), 'category_rule' => array( - 'controller' => 'category', - 'rule' => '{categories:/}{rewrite}/', + 'controller' => 'category', + 'rule' => '{rewrite}/', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), 'categories' => array('regexp' => '[/_a-zA-Z0-9\pL-]*'), diff --git a/override/classes/Link.php b/override/classes/Link.php index d1c231e..fdc6fe7 100644 --- a/override/classes/Link.php +++ b/override/classes/Link.php @@ -42,7 +42,7 @@ public function getCategoryLink($category, $alias = null, $id_lang = null, $sele $dispatcher = Dispatcher::getInstance(); - if ($dispatcher->hasKeyword('category_rule', $id_lang, 'parent_categories')) { + if ($dispatcher->hasKeyword('category_rule', $id_lang, 'categories')) { // Retrieve all parent categories $p_cats = array(); foreach ($category->getParentsCategories($id_lang) as $p_cat) { @@ -52,7 +52,7 @@ public function getCategoryLink($category, $alias = null, $id_lang = null, $sele } } // add the URL slashes among categories, in reverse order - $params['parent_categories'] = implode('/', array_reverse($p_cats)); + $params['categories'] = implode('/', array_reverse($p_cats)); } return $url.$dispatcher->createUrl($rule, $id_lang, $params, $this->allow, '', $id_shop); diff --git a/override/classes/controller/FrontController.php b/override/classes/controller/FrontController.php index 9c5d1e6..fd89db2 100644 --- a/override/classes/controller/FrontController.php +++ b/override/classes/controller/FrontController.php @@ -11,21 +11,16 @@ class FrontController extends FrontControllerCore */ protected function canonicalRedirection($canonical_url = '') { - /* - * TODO: replace with a generic "*_rewrite" filter - */ - $excluded_keys = array( - 'product_rewrite', - 'category_rewrite', - 'manufacturer_rewrite', - 'supplier_rewrite', - 'cms_rewrite', - 'cms_category_rewrite', - ); + $_unfiltered_GET = $_GET; + + // hack original behavior on cananocalRedirection: remove *_rewrite from _GET + $_GET = array_filter($_GET, function ($v) { + return '_rewrite' === substr($v, -8); + }); - $unfiltered_GET = $_GET; - $_GET = array_diff_key($_GET, array_flip($excluded_keys)); // hack original behavior on cananocalRedirection: remove *_rewrite from _GET parent::canonicalRedirection($canonical_url); - $_GET = $unfiltered_GET; //restore original _GET + + //restore original _GET + $_GET = $_unfiltered_GET; } } From 7c61268002334c2c47ebed0540a42a39167957df Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 23 Sep 2015 12:13:22 +0200 Subject: [PATCH 099/174] fix Dispatcher constructor --- override/classes/Dispatcher.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index 96e8d11..51287d9 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -4,7 +4,6 @@ class Dispatcher extends DispatcherCore { public function __construct() { - parent::__construct(); /** * @var array List of default routes */ @@ -83,7 +82,6 @@ public function __construct() 'rule' => '{rewrite}/f{/:selected_filters}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), - /* Selected filters is used by the module blocklayered */ '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]*'), @@ -102,6 +100,8 @@ public function __construct() ), ), ); + + parent::__construct(); } /** From 32140739aa11986ca317877aebf46a6d1405a054 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 23 Sep 2015 12:33:10 +0200 Subject: [PATCH 100/174] Release 0.11.0 --- config.xml | 2 +- zzcleanurls.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config.xml b/config.xml index b6f012b..55c8c7d 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ zzcleanurls - + diff --git a/zzcleanurls.php b/zzcleanurls.php index 339c711..4a7128a 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -24,7 +24,7 @@ public function __construct() { $this->name = 'zzcleanurls'; $this->tab = 'seo'; - $this->version = '0.10.0'; + $this->version = '0.11.0'; $this->author = 'ZiZuu Store'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.5', 'max' => _PS_VERSION_); From 1a0cc29d4b252bc7338da31a6948308a65429209 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 23 Sep 2015 16:19:33 +0200 Subject: [PATCH 101/174] Fixed modules' controllers. Release version 1.0.0 --- config.xml | 2 +- override/classes/Dispatcher.php | 6 +++--- zzcleanurls.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config.xml b/config.xml index 55c8c7d..777f085 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ zzcleanurls - + diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index 51287d9..cce2b5b 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -256,7 +256,7 @@ public function getController($id_shop = null) } $controller = $this->controller_not_found; - // If the request_uri matches a static file, then there is no need to check the routes, we keep "controller_not_found" (a static file should not go through the dispatcher) + // If the request_uri matches a static file, then there is no need to check the routes, we keep "controller_not_found" (a static file should not go through the dispatcher) if (!preg_match('/\.(gif|jpe?g|png|css|js|ico)$/i', $this->request_uri)) { // Add empty route as last route to prevent this greedy regexp to match request uri before right time if ($this->empty_route) { @@ -272,8 +272,8 @@ public function getController($id_shop = null) foreach ($this->routes[$id_shop][Context::getContext()->language->id] as $route) { if (preg_match($route['regexp'], $uri, $m)) { $isTemplate = false; - - switch ($route['controller']) { + $module = isset($route['params']['module']) ? $route['params']['module'] : ''; + switch ($route['controller'].$module) { // Avoid name collision between core and modules' controllers case 'supplier': case 'manufacturer': // these two can be processed in normal way and also as template diff --git a/zzcleanurls.php b/zzcleanurls.php index 4a7128a..0100844 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -24,7 +24,7 @@ public function __construct() { $this->name = 'zzcleanurls'; $this->tab = 'seo'; - $this->version = '0.11.0'; + $this->version = '1.0.0'; $this->author = 'ZiZuu Store'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.5', 'max' => _PS_VERSION_); From 240559d9a2e16fc8265614b0c0a396bea5846152 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 24 Sep 2015 10:40:08 +0200 Subject: [PATCH 102/174] Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 23af093..0896842 100644 --- a/README.md +++ b/README.md @@ -8,29 +8,29 @@ We are going to merge other users' contributions and ideas as soon as we note them and find the time to test. -If you fork please make every change the way we can pull, don't reinvent the wheel .. make every custom change on a private branch, so you can merge your own changes to the community mintained full branch every time a new release is out. +If you fork, please make every change the way we can pull, don't reinvent the wheel .. make every custom change on a private branch, so you can merge your own changes to the community mintained branch every time a new release is out. It has been reported to work on **PS 1.5.6 - 1.6.1.x** but will install on PS >= 1.5 too. **If you succesfully use this module on some older version please report** ## INSTALLATION -Install the module from the Backoffice (administration panel), download the release ZIP file as it already contains the right folder name (zzcleanurls, **not** zzcleanurls-version_x.y.z !) +Install the module from the Backoffice (administration panel), download the release ZIP file (***zzcleanurls.zip***) as it already contains the right folder name (`zzcleanurls`, **not** `zzcleanurls-version_x.y.z` !) -In the modules tab, click on **add a new module**. Click on Browse to open the dialogue box letting you search your computer, select the file then validate the dialogue box. Finally click on Upload this module. +In the modules tab, click on **add a new module**. Click on Browse to open the dialogue box letting you search your computer, select the ZIP file then validate the dialogue box. Finally click on Upload this module. ### Make sure your SEO and URL settings are as follows: This is __MANDATORY__ * products: {category:/}{rewrite} (you **can** add .html at the end) - * categories: {parent_categories:/}{rewrite}**/** + * categories: {categories:/}{rewrite}**/** * manufacturers: manufactures/{rewrite} * suppliers: suppliers/{rewrite} * CMS page: info/{rewrite} (you **can** add .html at the end) * CMS category: info/{rewrite}**/** - * modules: module/{module}{/:controller} + * modules: modules/{module}{/:controller} -You can replace words such as "info", "suppliers", etc with whatever you want given that it does not conflicts with a category name +You can replace words such as "info", "suppliers", etc with whatever you want, given that it does not conflicts with a category name Remember to * **clear the browser cache** From 32f0f04502abe04698484eb5c32b9a4354f81c5d Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 24 Sep 2015 12:45:55 +0200 Subject: [PATCH 103/174] Added Sensio Insight medal badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0896842..e11c023 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ [Prestashop module "ZiZuu Clean URLs"](https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs) == +[![SensioLabsInsight](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba/mini.png)](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba) [![Join the chat at https://gitter.im/ZiZuu-store/zzCleanURLs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ZiZuu-store/zzCleanURLs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) * For production use the **latest stable [release](https://github.com/ZiZuu-store/zzCleanURLs/releases/)** From 6bc2f18598274c4bca1f5efde1b013a8dc9f5aa0 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 24 Sep 2015 13:07:20 +0200 Subject: [PATCH 104/174] Fix insight's issues --- .gitignore | 1 - .php_cs | 1 + override/classes/Link.php | 32 +------------------------------- zzcleanurls.php | 2 +- 4 files changed, 3 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index e48dc1d..6b36e53 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ .htaccess .svn -.DS_Store .*.swp .php_cs.cache config_*.xml diff --git a/.php_cs b/.php_cs index 4a76aa9..3d8f0ca 100644 --- a/.php_cs +++ b/.php_cs @@ -1,6 +1,7 @@ fixers(array('-psr0')) ->level(Symfony\CS\FixerInterface::PSR2_LEVEL) ->setUsingCache(true) ->finder( diff --git a/override/classes/Link.php b/override/classes/Link.php index fdc6fe7..57bccf5 100644 --- a/override/classes/Link.php +++ b/override/classes/Link.php @@ -58,36 +58,6 @@ public function getCategoryLink($category, $alias = null, $id_lang = null, $sele return $url.$dispatcher->createUrl($rule, $id_lang, $params, $this->allow, '', $id_shop); } - /** - * XXX TODO - * Create a link to a module - * - * @since 1.5.0 - * @param string $module Module name - * @param string $process Action name - * @param int $id_lang - * @return string - */ - public function getModuleLink($module, $controller = 'default', array $params = array(), $ssl = null, $id_lang = null, $id_shop = null, $relative_protocol = false) - { - if (!$id_lang) { - $id_lang = Context::getContext()->language->id; - } - - $url = $this->getBaseLink($id_shop, $ssl, $relative_protocol).$this->getLangLink($id_lang, null, $id_shop); - - // Set available keywords - $params['module'] = $module; - $params['controller'] = $controller ? $controller : 'default'; - - // If the module has its own route ... just use it ! - if (Dispatcher::getInstance()->hasRoute('module-'.$module.'-'.$controller, $id_lang, $id_shop)) { - return $this->getPageLink('module-'.$module.'-'.$controller, $ssl, $id_lang, $params); - } else { - return $url.Dispatcher::getInstance()->createUrl('module', $id_lang, $params, $this->allow, '', $id_shop); - } - } - /** * Get pagination link * @@ -126,7 +96,7 @@ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, $vars_pagination = array('p'); foreach ($_GET as $k => $value) { - if ($k != 'id_'.$type && $k != 'controller' && $k != $type.'_rewrite') { /*XXX skip *_rewrite */ + if ($k != 'id_'.$type && $k != 'controller' && $k != $type.'_rewrite' /* skip *_rewrite */) { if (Configuration::get('PS_REWRITING_SETTINGS') && ($k == 'isolang' || $k == 'id_lang')) { continue; } diff --git a/zzcleanurls.php b/zzcleanurls.php index 0100844..1cf66e7 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -18,7 +18,7 @@ exit; } -class zzcleanurls extends Module +class zzCleanUrls extends Module { public function __construct() { From 4a00b471cdc3e315912589298e464f72495764b6 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 24 Sep 2015 15:45:17 +0200 Subject: [PATCH 105/174] Create .sensiolabs.yml --- .sensiolabs.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .sensiolabs.yml diff --git a/.sensiolabs.yml b/.sensiolabs.yml new file mode 100644 index 0000000..05ecacd --- /dev/null +++ b/.sensiolabs.yml @@ -0,0 +1,18 @@ +global_exclude_dirs: + - translations + - upgrade + +exclude_patterns: + - lib/debug.inc.php + - index.php + +rules: + php.absolute_path_present: + enabled: true + allowed_paths: [] + php.method_too_long: + enabled: true + max_length: 60 + threshold: 5 + php.psr1: + enabled: false From c7df96e05ccfcb06640f434a65e37e92105c3ad1 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 24 Sep 2015 15:45:41 +0200 Subject: [PATCH 106/174] Update zzcleanurls.php --- zzcleanurls.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zzcleanurls.php b/zzcleanurls.php index 1cf66e7..88d168c 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -15,7 +15,7 @@ */ if (!defined('_PS_VERSION_')) { - exit; + return; } class zzCleanUrls extends Module From 20b5246792aaee60ef2d41e32ba0b6a8f68f13fd Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 24 Sep 2015 17:52:38 +0200 Subject: [PATCH 107/174] Update .sensiolabs.yml --- .sensiolabs.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.sensiolabs.yml b/.sensiolabs.yml index 05ecacd..e06040c 100644 --- a/.sensiolabs.yml +++ b/.sensiolabs.yml @@ -3,7 +3,6 @@ global_exclude_dirs: - upgrade exclude_patterns: - - lib/debug.inc.php - index.php rules: @@ -12,7 +11,5 @@ rules: allowed_paths: [] php.method_too_long: enabled: true - max_length: 60 - threshold: 5 - php.psr1: - enabled: false + max_length: 50 + threshold: 15 From 7be64ff9883af3d26cf4b8c97260541bdd2c54e0 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 24 Sep 2015 18:22:40 +0200 Subject: [PATCH 108/174] Fix insight issues --- .sensiolabs.yml | 3 --- index.php | 2 +- override/classes/controller/index.php | 2 +- override/classes/index.php | 2 +- override/controllers/front/index.php | 2 +- override/controllers/index.php | 2 +- override/index.php | 2 +- 7 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.sensiolabs.yml b/.sensiolabs.yml index e06040c..5373da9 100644 --- a/.sensiolabs.yml +++ b/.sensiolabs.yml @@ -2,9 +2,6 @@ global_exclude_dirs: - translations - upgrade -exclude_patterns: - - index.php - rules: php.absolute_path_present: enabled: true diff --git a/index.php b/index.php index e72b7ae..ddc0813 100644 --- a/index.php +++ b/index.php @@ -22,4 +22,4 @@ header('Pragma: no-cache'); header('Location: ../'); -exit; +return; diff --git a/override/classes/controller/index.php b/override/classes/controller/index.php index e72b7ae..ddc0813 100644 --- a/override/classes/controller/index.php +++ b/override/classes/controller/index.php @@ -22,4 +22,4 @@ header('Pragma: no-cache'); header('Location: ../'); -exit; +return; diff --git a/override/classes/index.php b/override/classes/index.php index e72b7ae..ddc0813 100644 --- a/override/classes/index.php +++ b/override/classes/index.php @@ -22,4 +22,4 @@ header('Pragma: no-cache'); header('Location: ../'); -exit; +return; diff --git a/override/controllers/front/index.php b/override/controllers/front/index.php index e72b7ae..ddc0813 100644 --- a/override/controllers/front/index.php +++ b/override/controllers/front/index.php @@ -22,4 +22,4 @@ header('Pragma: no-cache'); header('Location: ../'); -exit; +return; diff --git a/override/controllers/index.php b/override/controllers/index.php index e72b7ae..ddc0813 100644 --- a/override/controllers/index.php +++ b/override/controllers/index.php @@ -22,4 +22,4 @@ header('Pragma: no-cache'); header('Location: ../'); -exit; +return; diff --git a/override/index.php b/override/index.php index e72b7ae..ddc0813 100644 --- a/override/index.php +++ b/override/index.php @@ -22,4 +22,4 @@ header('Pragma: no-cache'); header('Location: ../'); -exit; +return; From 947a0a03304bd682d948f3778a4e1706616bba82 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 24 Sep 2015 18:28:07 +0200 Subject: [PATCH 109/174] Update .sensiolabs.yml --- .sensiolabs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.sensiolabs.yml b/.sensiolabs.yml index 5373da9..11eabc8 100644 --- a/.sensiolabs.yml +++ b/.sensiolabs.yml @@ -10,3 +10,5 @@ rules: enabled: true max_length: 50 threshold: 15 + php.psr1: + enabled: false From 4b6da476e2e80a8068574884ba5786eb2955a921 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 25 Sep 2015 17:04:12 +0200 Subject: [PATCH 110/174] Create travis-ci-apache-vhost.conf --- travis-ci-apache-vhost.conf | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 travis-ci-apache-vhost.conf diff --git a/travis-ci-apache-vhost.conf b/travis-ci-apache-vhost.conf new file mode 100644 index 0000000..e661cff --- /dev/null +++ b/travis-ci-apache-vhost.conf @@ -0,0 +1,18 @@ + + + ServerName localhost + + AddHandler php5-fcgi .php + Action php5-fcgi /php5-fcgi + Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi + FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization + + DocumentRoot /var/www/ + + Options FollowSymLinks MultiViews ExecCGI + AllowOverride All + Order deny,allow + Allow from all + + + From fc029213c1a0deec9240d8b97a8f76a09fbdf3ba Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 25 Sep 2015 17:05:00 +0200 Subject: [PATCH 111/174] Delete travis-ci-apache-vhost.conf --- travis-ci-apache-vhost.conf | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 travis-ci-apache-vhost.conf diff --git a/travis-ci-apache-vhost.conf b/travis-ci-apache-vhost.conf deleted file mode 100644 index e661cff..0000000 --- a/travis-ci-apache-vhost.conf +++ /dev/null @@ -1,18 +0,0 @@ - - - ServerName localhost - - AddHandler php5-fcgi .php - Action php5-fcgi /php5-fcgi - Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi - FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization - - DocumentRoot /var/www/ - - Options FollowSymLinks MultiViews ExecCGI - AllowOverride All - Order deny,allow - Allow from all - - - From aa87ad1bc0360d49da924a220d195afa1bacfe61 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 12 Nov 2015 18:30:01 +0100 Subject: [PATCH 112/174] still not workig .. --- override/classes/Dispatcher.php | 57 ++++++++++++++------ override/controllers/front/CmsController.php | 19 ++++--- 2 files changed, 51 insertions(+), 25 deletions(-) diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index cce2b5b..18dcbdc 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -167,6 +167,27 @@ public static function isCmsLink($short_link) return ($id_cms > 0); } + /** + * Check if $short_link is a Cms Category Link + * + * @param string $short_link: requested url without '?' part and without '/' on begining + * @return bool true: it's a link to cms page, false: it isn't + */ + public static function isCmsCategoryLink($short_link) + { + $sql = 'SELECT l.`id_cms_category` + FROM `'._DB_PREFIX_.'cms_category_lang` l + LEFT JOIN `'._DB_PREFIX_.'cms_category_shop` s ON (l.`id_cms_category` = s.`id_cms_category`) + WHERE l.`link_rewrite` = \''.basename($short_link).'\''; + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + } + + $id_cms_cat = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + + return ($id_cms_cat > 0); + } + /** * Check if $short_link is a Manufacturer Link * @@ -234,7 +255,9 @@ public function getController($id_shop = null) $id_shop = (int)Context::getContext()->shop->id; } - $controller = Tools::getValue('controller'); + $controller = Tools::getValue('controller'); + + $curr_lang_id = Context::getContext()->language->id; if (isset($controller) && is_string($controller) && preg_match('/^([0-9a-z_-]+)\?(.*)=(.*)$/Ui', $controller, $m)) { $controller = $m[1]; @@ -260,16 +283,16 @@ public function getController($id_shop = null) if (!preg_match('/\.(gif|jpe?g|png|css|js|ico)$/i', $this->request_uri)) { // Add empty route as last route to prevent this greedy regexp to match request uri before right time if ($this->empty_route) { - $this->addRoute($this->empty_route['routeID'], $this->empty_route['rule'], $this->empty_route['controller'], Context::getContext()->language->id, array(), array(), $id_shop); + $this->addRoute($this->empty_route['routeID'], $this->empty_route['rule'], $this->empty_route['controller'], $curr_lang_id, array(), array(), $id_shop); } list($uri) = explode('?', $this->request_uri); - if (isset($this->routes[$id_shop][Context::getContext()->language->id])) { + if (isset($this->routes[$id_shop][$curr_lang_id])) { $findRoute = array(); // check, whether request_uri is template or not - foreach ($this->routes[$id_shop][Context::getContext()->language->id] as $route) { + foreach ($this->routes[$id_shop][$curr_lang_id] as $route) { if (preg_match($route['regexp'], $uri, $m)) { $isTemplate = false; $module = isset($route['params']['module']) ? $route['params']['module'] : ''; @@ -309,22 +332,26 @@ public function getController($id_shop = null) if (!Dispatcher::isProductLink($short_link)) { if (!Dispatcher::isCategoryLink($short_link)) { if (!Dispatcher::isCmsLink($short_link)) { - if (!Dispatcher::isManufacturerLink($short_link)) { - if (!Dispatcher::isSupplierLink($short_link)) { - } else { - $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['supplier_rule']; - } - } else { - $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['manufacturer_rule']; - } + if (!Dispatcher::isCmsCategoryLink($short_link)) { + if (!Dispatcher::isManufacturerLink($short_link)) { + if (!Dispatcher::isSupplierLink($short_link)) { + } else { + $findRoute = $this->routes[$id_shop][$curr_lang_id]['supplier_rule']; + } + } else { + $findRoute = $this->routes[$id_shop][$curr_lang_id]['manufacturer_rule']; + } + } else { + $findRoute = $this->routes[$id_shop][$curr_lang_id]['cms_category_rule']; + } } else { - $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['cms_rule']; + $findRoute = $this->routes[$id_shop][$curr_lang_id]['cms_rule']; } } else { - $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['category_rule']; + $findRoute = $this->routes[$id_shop][$curr_lang_id]['category_rule']; } } else { - $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['product_rule']; + $findRoute = $this->routes[$id_shop][$curr_lang_id]['product_rule']; } } diff --git a/override/controllers/front/CmsController.php b/override/controllers/front/CmsController.php index 1d2968c..4db06bb 100644 --- a/override/controllers/front/CmsController.php +++ b/override/controllers/front/CmsController.php @@ -4,15 +4,15 @@ class CmsController extends CmsControllerCore { public function init() { + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $shop_sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + } + if ($cms_rewrite = Tools::getValue('cms_rewrite')) { $sql = 'SELECT l.`id_cms` FROM `'._DB_PREFIX_.'cms_lang` l LEFT JOIN `'._DB_PREFIX_.'cms_shop` s ON (l.`id_cms` = s.`id_cms`) - WHERE l.`link_rewrite` = \''.pSQL(str_replace('.html', '', $cms_rewrite)).'\''; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); - } - + WHERE l.`link_rewrite` = \''.pSQL(str_replace('.html', '', $cms_rewrite)).'\''.$shop_sql; $id_cms = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_cms > 0) { $_GET['id_cms'] = $id_cms; @@ -20,12 +20,11 @@ public function init() } elseif ($cms_category_rewrite = Tools::getValue('cms_category_rewrite')) { $sql = 'SELECT `id_cms_category` FROM `'._DB_PREFIX_.'cms_category_lang` - WHERE `link_rewrite` = \''.pSQL($cms_category_rewrite).'\''; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); - } + LEFT JOIN `'._DB_PREFIX_.'cms_category_shop` s ON (l.`id_cms_category` = s.`id_cms_category`) + WHERE `link_rewrite` = \''.pSQL($cms_category_rewrite).'\''.$shop_sql; + $id_cms_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - $id_cms_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + var_dump($sql); if ($id_cms_category > 0) { $_GET['id_cms_category'] = $id_cms_category; } From 0482f1bc3089af252a5bc0f75c696a813afe0886 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 12 Nov 2015 18:50:26 +0100 Subject: [PATCH 113/174] Update Dispatcher.php --- override/classes/Dispatcher.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index 18dcbdc..488f2f0 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -332,18 +332,18 @@ public function getController($id_shop = null) if (!Dispatcher::isProductLink($short_link)) { if (!Dispatcher::isCategoryLink($short_link)) { if (!Dispatcher::isCmsLink($short_link)) { - if (!Dispatcher::isCmsCategoryLink($short_link)) { - if (!Dispatcher::isManufacturerLink($short_link)) { - if (!Dispatcher::isSupplierLink($short_link)) { - } else { - $findRoute = $this->routes[$id_shop][$curr_lang_id]['supplier_rule']; - } - } else { - $findRoute = $this->routes[$id_shop][$curr_lang_id]['manufacturer_rule']; - } - } else { - $findRoute = $this->routes[$id_shop][$curr_lang_id]['cms_category_rule']; - } + if (!Dispatcher::isCmsCategoryLink($short_link)) { + if (!Dispatcher::isManufacturerLink($short_link)) { + if (!Dispatcher::isSupplierLink($short_link)) { + } else { + $findRoute = $this->routes[$id_shop][$curr_lang_id]['supplier_rule']; + } + } else { + $findRoute = $this->routes[$id_shop][$curr_lang_id]['manufacturer_rule']; + } + } else { + $findRoute = $this->routes[$id_shop][$curr_lang_id]['cms_category_rule']; + } } else { $findRoute = $this->routes[$id_shop][$curr_lang_id]['cms_rule']; } From e4cdaceef6e973fb90a6936cacc3173add23c581 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 12 Nov 2015 18:54:49 +0100 Subject: [PATCH 114/174] Update Dispatcher.php --- override/classes/Dispatcher.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index 488f2f0..36b1ecd 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -332,18 +332,19 @@ public function getController($id_shop = null) if (!Dispatcher::isProductLink($short_link)) { if (!Dispatcher::isCategoryLink($short_link)) { if (!Dispatcher::isCmsLink($short_link)) { - if (!Dispatcher::isCmsCategoryLink($short_link)) { - if (!Dispatcher::isManufacturerLink($short_link)) { - if (!Dispatcher::isSupplierLink($short_link)) { - } else { - $findRoute = $this->routes[$id_shop][$curr_lang_id]['supplier_rule']; - } - } else { - $findRoute = $this->routes[$id_shop][$curr_lang_id]['manufacturer_rule']; - } - } else { - $findRoute = $this->routes[$id_shop][$curr_lang_id]['cms_category_rule']; - } + if (!Dispatcher::isCmsCategoryLink($short_link)) { + if (!Dispatcher::isManufacturerLink($short_link)) { + if (!Dispatcher::isSupplierLink($short_link)) { + // + } else { + $findRoute = $this->routes[$id_shop][$curr_lang_id]['supplier_rule']; + } + } else { + $findRoute = $this->routes[$id_shop][$curr_lang_id]['manufacturer_rule']; + } + } else { + $findRoute = $this->routes[$id_shop][$curr_lang_id]['cms_category_rule']; + } } else { $findRoute = $this->routes[$id_shop][$curr_lang_id]['cms_rule']; } From c2385ecd9ded83cd93ac433a98d47adb8050b2fc Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 12 Nov 2015 19:13:11 +0100 Subject: [PATCH 115/174] Update CmsController.php --- override/controllers/front/CmsController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/override/controllers/front/CmsController.php b/override/controllers/front/CmsController.php index 4db06bb..5a44e5c 100644 --- a/override/controllers/front/CmsController.php +++ b/override/controllers/front/CmsController.php @@ -4,9 +4,9 @@ class CmsController extends CmsControllerCore { public function init() { - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $shop_sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); - } + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $shop_sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + } if ($cms_rewrite = Tools::getValue('cms_rewrite')) { $sql = 'SELECT l.`id_cms` From 3d9c7dc453ffd03bd639df5d5698c1041bc113e7 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 12 Nov 2015 19:17:13 +0100 Subject: [PATCH 116/174] Update CmsController.php --- override/controllers/front/CmsController.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/override/controllers/front/CmsController.php b/override/controllers/front/CmsController.php index 5a44e5c..de5213c 100644 --- a/override/controllers/front/CmsController.php +++ b/override/controllers/front/CmsController.php @@ -21,10 +21,8 @@ public function init() $sql = 'SELECT `id_cms_category` FROM `'._DB_PREFIX_.'cms_category_lang` LEFT JOIN `'._DB_PREFIX_.'cms_category_shop` s ON (l.`id_cms_category` = s.`id_cms_category`) - WHERE `link_rewrite` = \''.pSQL($cms_category_rewrite).'\''.$shop_sql; + WHERE `link_rewrite` = \''.pSQL($cms_category_rewrite).'\''.$shop_sql; $id_cms_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - - var_dump($sql); if ($id_cms_category > 0) { $_GET['id_cms_category'] = $id_cms_category; } From 52bce0f77c3d4beed9214fa928a7c54ade49e110 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 13 Nov 2015 11:33:20 +0100 Subject: [PATCH 117/174] Fixed 404 on CMS category --- config.xml | 9 ++++--- override/classes/Dispatcher.php | 28 ++++++++++---------- override/controllers/front/CmsController.php | 8 +++--- zzcleanurls.php | 2 +- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/config.xml b/config.xml index 777f085..769ea75 100644 --- a/config.xml +++ b/config.xml @@ -2,11 +2,12 @@ zzcleanurls - - + + - 0 + + 1 0 - + \ No newline at end of file diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index 36b1ecd..cfd4358 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -181,7 +181,7 @@ public static function isCmsCategoryLink($short_link) WHERE l.`link_rewrite` = \''.basename($short_link).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); - } + } $id_cms_cat = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); @@ -255,9 +255,9 @@ public function getController($id_shop = null) $id_shop = (int)Context::getContext()->shop->id; } - $controller = Tools::getValue('controller'); + $controller = Tools::getValue('controller'); - $curr_lang_id = Context::getContext()->language->id; + $curr_lang_id = Context::getContext()->language->id; if (isset($controller) && is_string($controller) && preg_match('/^([0-9a-z_-]+)\?(.*)=(.*)$/Ui', $controller, $m)) { $controller = $m[1]; @@ -332,19 +332,19 @@ public function getController($id_shop = null) if (!Dispatcher::isProductLink($short_link)) { if (!Dispatcher::isCategoryLink($short_link)) { if (!Dispatcher::isCmsLink($short_link)) { - if (!Dispatcher::isCmsCategoryLink($short_link)) { - if (!Dispatcher::isManufacturerLink($short_link)) { - if (!Dispatcher::isSupplierLink($short_link)) { - // - } else { - $findRoute = $this->routes[$id_shop][$curr_lang_id]['supplier_rule']; - } + if (!Dispatcher::isCmsCategoryLink($short_link)) { + if (!Dispatcher::isManufacturerLink($short_link)) { + if (!Dispatcher::isSupplierLink($short_link)) { + // + } else { + $findRoute = $this->routes[$id_shop][$curr_lang_id]['supplier_rule']; + } + } else { + $findRoute = $this->routes[$id_shop][$curr_lang_id]['manufacturer_rule']; + } } else { - $findRoute = $this->routes[$id_shop][$curr_lang_id]['manufacturer_rule']; + $findRoute = $this->routes[$id_shop][$curr_lang_id]['cms_category_rule']; } - } else { - $findRoute = $this->routes[$id_shop][$curr_lang_id]['cms_category_rule']; - } } else { $findRoute = $this->routes[$id_shop][$curr_lang_id]['cms_rule']; } diff --git a/override/controllers/front/CmsController.php b/override/controllers/front/CmsController.php index de5213c..6de3087 100644 --- a/override/controllers/front/CmsController.php +++ b/override/controllers/front/CmsController.php @@ -13,16 +13,18 @@ public function init() FROM `'._DB_PREFIX_.'cms_lang` l LEFT JOIN `'._DB_PREFIX_.'cms_shop` s ON (l.`id_cms` = s.`id_cms`) WHERE l.`link_rewrite` = \''.pSQL(str_replace('.html', '', $cms_rewrite)).'\''.$shop_sql; + $id_cms = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_cms > 0) { $_GET['id_cms'] = $id_cms; } } elseif ($cms_category_rewrite = Tools::getValue('cms_category_rewrite')) { - $sql = 'SELECT `id_cms_category` - FROM `'._DB_PREFIX_.'cms_category_lang` + $sql = 'SELECT l.`id_cms_category` + FROM `'._DB_PREFIX_.'cms_category_lang` l LEFT JOIN `'._DB_PREFIX_.'cms_category_shop` s ON (l.`id_cms_category` = s.`id_cms_category`) WHERE `link_rewrite` = \''.pSQL($cms_category_rewrite).'\''.$shop_sql; - $id_cms_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + + $id_cms_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_cms_category > 0) { $_GET['id_cms_category'] = $id_cms_category; } diff --git a/zzcleanurls.php b/zzcleanurls.php index 88d168c..a8a044d 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -24,7 +24,7 @@ public function __construct() { $this->name = 'zzcleanurls'; $this->tab = 'seo'; - $this->version = '1.0.0'; + $this->version = '1.0.1'; $this->author = 'ZiZuu Store'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.5', 'max' => _PS_VERSION_); From a2d1dc373f05441b89385c2ab8eebaec3cb4c6fd Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 13 Nov 2015 13:35:37 +0100 Subject: [PATCH 118/174] Added some badges --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index e11c023..00e4ba8 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,11 @@ == [![SensioLabsInsight](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba/mini.png)](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba) +[![GitHub stars](https://img.shields.io/github/stars/ZiZuu-store/zzCleanURLs.svg?style=plastic)](https://github.com/ZiZuu-store/zzCleanURLs/stargazers) +[![GitHub issues](https://img.shields.io/github/issues/ZiZuu-store/zzCleanURLs.svg?style=plastic)](https://github.com/ZiZuu-store/zzCleanURLs/issues) + [![Join the chat at https://gitter.im/ZiZuu-store/zzCleanURLs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ZiZuu-store/zzCleanURLs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Twitter](https://img.shields.io/twitter/url/https/github.com/ZiZuu-store/zzCleanURLs.svg?style=social)](https://twitter.com/intent/tweet?text=Wow:&url=%5Bobject%20Object%5D) * For production use the **latest stable [release](https://github.com/ZiZuu-store/zzCleanURLs/releases/)** * For developing or Pull Request please use only the "**[dev](https://github.com/ZiZuu-store/zzCleanURLs/tree/dev)**" branch From 182a624da496aacb0e104c812c7b670bcb504b96 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 13 Nov 2015 13:40:50 +0100 Subject: [PATCH 119/174] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 00e4ba8..2bfa4d3 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![GitHub issues](https://img.shields.io/github/issues/ZiZuu-store/zzCleanURLs.svg?style=plastic)](https://github.com/ZiZuu-store/zzCleanURLs/issues) [![Join the chat at https://gitter.im/ZiZuu-store/zzCleanURLs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ZiZuu-store/zzCleanURLs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![Twitter](https://img.shields.io/twitter/url/https/github.com/ZiZuu-store/zzCleanURLs.svg?style=social)](https://twitter.com/intent/tweet?text=Wow:&url=%5Bobject%20Object%5D) +[![Twitter](https://img.shields.io/twitter/url/https/github.com/ZiZuu-store/zzCleanURLs.svg?style=social)](https://twitter.com/intent/tweet?text=Fantastic @PrestaShop module: "@ZiZuu Clean URLs"&url=https://github.com/ZiZuu-store/zzCleanURLs) * For production use the **latest stable [release](https://github.com/ZiZuu-store/zzCleanURLs/releases/)** * For developing or Pull Request please use only the "**[dev](https://github.com/ZiZuu-store/zzCleanURLs/tree/dev)**" branch From bc2c7cf944dd546e4f2798f1ee01e9c4952e56a9 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 13 Nov 2015 14:04:48 +0100 Subject: [PATCH 120/174] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2bfa4d3..7cff7fb 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![GitHub issues](https://img.shields.io/github/issues/ZiZuu-store/zzCleanURLs.svg?style=plastic)](https://github.com/ZiZuu-store/zzCleanURLs/issues) [![Join the chat at https://gitter.im/ZiZuu-store/zzCleanURLs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ZiZuu-store/zzCleanURLs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![Twitter](https://img.shields.io/twitter/url/https/github.com/ZiZuu-store/zzCleanURLs.svg?style=social)](https://twitter.com/intent/tweet?text=Fantastic @PrestaShop module: "@ZiZuu Clean URLs"&url=https://github.com/ZiZuu-store/zzCleanURLs) +[![Twitter](https://img.shields.io/twitter/url/https/github.com/ZiZuu-store/zzCleanURLs.svg?style=social)](https://twitter.com/intent/tweet?text=Fantastic @PrestaShop module by @ZiZuu_Store: "ZiZuu Clean URLs"&url=https://github.com/ZiZuu-store/zzCleanURLs) * For production use the **latest stable [release](https://github.com/ZiZuu-store/zzCleanURLs/releases/)** * For developing or Pull Request please use only the "**[dev](https://github.com/ZiZuu-store/zzCleanURLs/tree/dev)**" branch From 79f82f38d4e2cbad3dd7c95ed81d71b635daebcd Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 13 Nov 2015 16:32:01 +0100 Subject: [PATCH 121/174] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7cff7fb..3f45c0c 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![GitHub stars](https://img.shields.io/github/stars/ZiZuu-store/zzCleanURLs.svg?style=plastic)](https://github.com/ZiZuu-store/zzCleanURLs/stargazers) [![GitHub issues](https://img.shields.io/github/issues/ZiZuu-store/zzCleanURLs.svg?style=plastic)](https://github.com/ZiZuu-store/zzCleanURLs/issues) -[![Join the chat at https://gitter.im/ZiZuu-store/zzCleanURLs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ZiZuu-store/zzCleanURLs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Join the chat at https://gitter.im/ZiZuu-store/zzCleanURLs](https://img.shields.io/badge/Gitter-CHAT%20NOW-brightgreen.svg?style=plastic)](https://gitter.im/ZiZuu-store/zzCleanURLs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Twitter](https://img.shields.io/twitter/url/https/github.com/ZiZuu-store/zzCleanURLs.svg?style=social)](https://twitter.com/intent/tweet?text=Fantastic @PrestaShop module by @ZiZuu_Store: "ZiZuu Clean URLs"&url=https://github.com/ZiZuu-store/zzCleanURLs) * For production use the **latest stable [release](https://github.com/ZiZuu-store/zzCleanURLs/releases/)** From c690180dde48ac0ada4ebd2d868b4e0c1c4c221d Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 13 Nov 2015 16:44:05 +0100 Subject: [PATCH 122/174] Update README.md --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3f45c0c..75620b1 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,22 @@ [Prestashop module "ZiZuu Clean URLs"](https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs) -== +===== [![SensioLabsInsight](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba/mini.png)](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba) -[![GitHub stars](https://img.shields.io/github/stars/ZiZuu-store/zzCleanURLs.svg?style=plastic)](https://github.com/ZiZuu-store/zzCleanURLs/stargazers) -[![GitHub issues](https://img.shields.io/github/issues/ZiZuu-store/zzCleanURLs.svg?style=plastic)](https://github.com/ZiZuu-store/zzCleanURLs/issues) +[![GitHub stars](https://img.shields.io/github/stars/ZiZuu-store/zzCleanURLs.svg?style=social)](https://github.com/ZiZuu-store/zzCleanURLs/stargazers) +[![GitHub issues](https://img.shields.io/github/issues/ZiZuu-store/zzCleanURLs.svg?style=social)](https://github.com/ZiZuu-store/zzCleanURLs/issues) +[![Twitter](https://img.shields.io/twitter/url/https/github.com/ZiZuu-store/zzCleanURLs.svg?style=social)](https://twitter.com/intent/tweet?text=Fantastic @PrestaShop module by @ZiZuu_Store: "ZiZuu Clean URLs"&url=https://github.com/ZiZuu-store/zzCleanURLs) [![Join the chat at https://gitter.im/ZiZuu-store/zzCleanURLs](https://img.shields.io/badge/Gitter-CHAT%20NOW-brightgreen.svg?style=plastic)](https://gitter.im/ZiZuu-store/zzCleanURLs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![Twitter](https://img.shields.io/twitter/url/https/github.com/ZiZuu-store/zzCleanURLs.svg?style=social)](https://twitter.com/intent/tweet?text=Fantastic @PrestaShop module by @ZiZuu_Store: "ZiZuu Clean URLs"&url=https://github.com/ZiZuu-store/zzCleanURLs) -* For production use the **latest stable [release](https://github.com/ZiZuu-store/zzCleanURLs/releases/)** -* For developing or Pull Request please use only the "**[dev](https://github.com/ZiZuu-store/zzCleanURLs/tree/dev)**" branch +___ We are going to merge other users' contributions and ideas as soon as we note them and find the time to test. If you fork, please make every change the way we can pull, don't reinvent the wheel .. make every custom change on a private branch, so you can merge your own changes to the community mintained branch every time a new release is out. +* For production use the **latest stable [release](https://github.com/ZiZuu-store/zzCleanURLs/releases/)** +* For developing or Pull Request please use only the "**[dev](https://github.com/ZiZuu-store/zzCleanURLs/tree/dev)**" branch + It has been reported to work on **PS 1.5.6 - 1.6.1.x** but will install on PS >= 1.5 too. **If you succesfully use this module on some older version please report** From d70105eb30a7338c33fca63a0c6404b59a106b93 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 13 Nov 2015 16:44:59 +0100 Subject: [PATCH 123/174] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 75620b1..a901d65 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ ===== [![SensioLabsInsight](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba/mini.png)](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba) + [![GitHub stars](https://img.shields.io/github/stars/ZiZuu-store/zzCleanURLs.svg?style=social)](https://github.com/ZiZuu-store/zzCleanURLs/stargazers) [![GitHub issues](https://img.shields.io/github/issues/ZiZuu-store/zzCleanURLs.svg?style=social)](https://github.com/ZiZuu-store/zzCleanURLs/issues) [![Twitter](https://img.shields.io/twitter/url/https/github.com/ZiZuu-store/zzCleanURLs.svg?style=social)](https://twitter.com/intent/tweet?text=Fantastic @PrestaShop module by @ZiZuu_Store: "ZiZuu Clean URLs"&url=https://github.com/ZiZuu-store/zzCleanURLs) From ede448be323651a778002bcae0eb831f95e599ee Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 13 Nov 2015 18:05:19 +0100 Subject: [PATCH 124/174] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a901d65..cc695e0 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![SensioLabsInsight](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba/mini.png)](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba) +[![Github Releases](https://img.shields.io/github/downloads/atom/atom/latest/total.svg?style=plastic)](https://github.com/ZiZuu-store/zzCleanURLs) [![GitHub stars](https://img.shields.io/github/stars/ZiZuu-store/zzCleanURLs.svg?style=social)](https://github.com/ZiZuu-store/zzCleanURLs/stargazers) [![GitHub issues](https://img.shields.io/github/issues/ZiZuu-store/zzCleanURLs.svg?style=social)](https://github.com/ZiZuu-store/zzCleanURLs/issues) [![Twitter](https://img.shields.io/twitter/url/https/github.com/ZiZuu-store/zzCleanURLs.svg?style=social)](https://twitter.com/intent/tweet?text=Fantastic @PrestaShop module by @ZiZuu_Store: "ZiZuu Clean URLs"&url=https://github.com/ZiZuu-store/zzCleanURLs) From f9ab62e4b0a15fd75f5d00cf664d6f3502d8dace Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 13 Nov 2015 18:08:24 +0100 Subject: [PATCH 125/174] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc695e0..439d37b 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![SensioLabsInsight](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba/mini.png)](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba) -[![Github Releases](https://img.shields.io/github/downloads/atom/atom/latest/total.svg?style=plastic)](https://github.com/ZiZuu-store/zzCleanURLs) +[![Github Releases](https://img.shields.io/github/downloads/atom/atom/latest/total.svg?style=plastic)](https://github.com/ZiZuu-store/zzCleanURLs/releases) [![GitHub stars](https://img.shields.io/github/stars/ZiZuu-store/zzCleanURLs.svg?style=social)](https://github.com/ZiZuu-store/zzCleanURLs/stargazers) [![GitHub issues](https://img.shields.io/github/issues/ZiZuu-store/zzCleanURLs.svg?style=social)](https://github.com/ZiZuu-store/zzCleanURLs/issues) [![Twitter](https://img.shields.io/twitter/url/https/github.com/ZiZuu-store/zzCleanURLs.svg?style=social)](https://twitter.com/intent/tweet?text=Fantastic @PrestaShop module by @ZiZuu_Store: "ZiZuu Clean URLs"&url=https://github.com/ZiZuu-store/zzCleanURLs) From 32e273a11282b6f22b9d6142645689a1a646aa87 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 16 Nov 2015 10:48:33 +0100 Subject: [PATCH 126/174] Update README.md --- README.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 439d37b..420b4bd 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,20 @@ ===== [![SensioLabsInsight](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba/mini.png)](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba) +[![GitHub issues](https://img.shields.io/github/issues/ZiZuu-store/zzCleanURLs.svg?style=plastic)](https://github.com/ZiZuu-store/zzCleanURLs/issues) -[![Github Releases](https://img.shields.io/github/downloads/atom/atom/latest/total.svg?style=plastic)](https://github.com/ZiZuu-store/zzCleanURLs/releases) [![GitHub stars](https://img.shields.io/github/stars/ZiZuu-store/zzCleanURLs.svg?style=social)](https://github.com/ZiZuu-store/zzCleanURLs/stargazers) -[![GitHub issues](https://img.shields.io/github/issues/ZiZuu-store/zzCleanURLs.svg?style=social)](https://github.com/ZiZuu-store/zzCleanURLs/issues) +[![Twitter](https://img.shields.io/twitter/url/https/github.com/ZiZuu-store/zzCleanURLs.svg?style=social)](https://twitter.com/intent/tweet?text=Fantastic @PrestaShop module by @ZiZuu_Store: "ZiZuu Clean URLs"&url=https://github.com/ZiZuu-store/zzCleanURLs) + +[![Join the chat at https://gitter.im/ZiZuu-store/zzCleanURLs](https://img.shields.io/badge/Gitter-CHAT%20NOW-brightgreen.svg?style=plastic)](https://gitter.im/ZiZuu-store/zzCleanURLs) + + + + + +[![Github Releases](https://img.shields.io/github/downloads/atom/atom/latest/total.svg?style=plastic)](https://github.com/ZiZuu-store/zzCleanURLs/releases) +[![GitHub stars](https://img.shields.io/github/stars/badges/shields.svg?style=social&label=Star)](https://github.com/ZiZuu-store/zzCleanURLs/stargazers) + [![Twitter](https://img.shields.io/twitter/url/https/github.com/ZiZuu-store/zzCleanURLs.svg?style=social)](https://twitter.com/intent/tweet?text=Fantastic @PrestaShop module by @ZiZuu_Store: "ZiZuu Clean URLs"&url=https://github.com/ZiZuu-store/zzCleanURLs) [![Join the chat at https://gitter.im/ZiZuu-store/zzCleanURLs](https://img.shields.io/badge/Gitter-CHAT%20NOW-brightgreen.svg?style=plastic)](https://gitter.im/ZiZuu-store/zzCleanURLs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) From 2d435a785847559d8c01013d2bd6258c64237756 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 16 Nov 2015 10:48:54 +0100 Subject: [PATCH 127/174] Update README.md --- README.md | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/README.md b/README.md index 420b4bd..f075f26 100644 --- a/README.md +++ b/README.md @@ -9,17 +9,6 @@ [![Join the chat at https://gitter.im/ZiZuu-store/zzCleanURLs](https://img.shields.io/badge/Gitter-CHAT%20NOW-brightgreen.svg?style=plastic)](https://gitter.im/ZiZuu-store/zzCleanURLs) - - - - -[![Github Releases](https://img.shields.io/github/downloads/atom/atom/latest/total.svg?style=plastic)](https://github.com/ZiZuu-store/zzCleanURLs/releases) -[![GitHub stars](https://img.shields.io/github/stars/badges/shields.svg?style=social&label=Star)](https://github.com/ZiZuu-store/zzCleanURLs/stargazers) - -[![Twitter](https://img.shields.io/twitter/url/https/github.com/ZiZuu-store/zzCleanURLs.svg?style=social)](https://twitter.com/intent/tweet?text=Fantastic @PrestaShop module by @ZiZuu_Store: "ZiZuu Clean URLs"&url=https://github.com/ZiZuu-store/zzCleanURLs) - -[![Join the chat at https://gitter.im/ZiZuu-store/zzCleanURLs](https://img.shields.io/badge/Gitter-CHAT%20NOW-brightgreen.svg?style=plastic)](https://gitter.im/ZiZuu-store/zzCleanURLs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - ___ We are going to merge other users' contributions and ideas as soon as we note them and find the time to test. From 23cd3e0bc882fd6f5f1c8057cb1f0bdee80f1f31 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 30 Nov 2015 19:24:05 +0100 Subject: [PATCH 128/174] Fixed manufacturers and suppliers .. still have to fix their listing --- override/classes/Dispatcher.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index cfd4358..d0b4bf3 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -196,14 +196,14 @@ public static function isCmsCategoryLink($short_link) */ public static function isManufacturerLink($short_link) { - $manufacturer = str_replace('-', '%', basename($short_link)); + $manufacturer = str_replace('-', '_', basename($short_link)); $sql = 'SELECT m.`id_manufacturer` FROM `'._DB_PREFIX_.'manufacturer` m LEFT JOIN `'._DB_PREFIX_.'manufacturer_shop` s ON (m.`id_manufacturer` = s.`id_manufacturer`) - WHERE m.`name` LIKE \''.pSQL($manufacturer).'\''; + WHERE LOWER(m.`name`) = \''.pSQL($manufacturer).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + $sql .= ' AND s.`id_shop` LIKE '.(int)Shop::getContextShopID(); } $id_manufacturer = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); @@ -219,12 +219,12 @@ public static function isManufacturerLink($short_link) */ public static function isSupplierLink($short_link) { - $supplier = str_replace('-', '%', basename($short_link)); + $supplier = str_replace('-', '_', basename($short_link)); $sql = 'SELECT sp.`id_supplier` FROM `'._DB_PREFIX_.'supplier` sp LEFT JOIN `'._DB_PREFIX_.'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`) - WHERE sp.`name` LIKE \''.pSQL($supplier).'\''; + WHERE LOWER(sp.`name`) LIKE \''.pSQL($supplier).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); } From 5b7d02c6238cb5d7f6c848616da75bfa23a67931 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 1 Dec 2015 13:39:16 +0100 Subject: [PATCH 129/174] Fixed manufacturers/suppliers pages --- override/classes/Dispatcher.php | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index d0b4bf3..bccfcb2 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -194,16 +194,21 @@ public static function isCmsCategoryLink($short_link) * @param string $short_link: requested url without '?' part and without '/' on begining * @return bool true: it's a link to manufacturer, false: it isn't */ - public static function isManufacturerLink($short_link) + public static function isManufacturerLink($short_link, $route) { + if ($short_link == str_replace('{rewrite}', '', $route['rule'])) { + // manufacturers list + return true; + } + $manufacturer = str_replace('-', '_', basename($short_link)); $sql = 'SELECT m.`id_manufacturer` FROM `'._DB_PREFIX_.'manufacturer` m LEFT JOIN `'._DB_PREFIX_.'manufacturer_shop` s ON (m.`id_manufacturer` = s.`id_manufacturer`) - WHERE LOWER(m.`name`) = \''.pSQL($manufacturer).'\''; + WHERE LOWER(m.`name`) LIKE \''.pSQL($manufacturer).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND s.`id_shop` LIKE '.(int)Shop::getContextShopID(); + $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); } $id_manufacturer = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); @@ -217,8 +222,13 @@ public static function isManufacturerLink($short_link) * @param string $short_link: requested url without '?' part and without '/' on begining * @return bool true: it's a link to supplier, false: it isn't */ - public static function isSupplierLink($short_link) + public static function isSupplierLink($short_link, $route) { + if ($short_link == str_replace('{rewrite}', '', $route['rule'])) { + // suppliers list + return true; + } + $supplier = str_replace('-', '_', basename($short_link)); $sql = 'SELECT sp.`id_supplier` @@ -333,14 +343,16 @@ public function getController($id_shop = null) if (!Dispatcher::isCategoryLink($short_link)) { if (!Dispatcher::isCmsLink($short_link)) { if (!Dispatcher::isCmsCategoryLink($short_link)) { - if (!Dispatcher::isManufacturerLink($short_link)) { - if (!Dispatcher::isSupplierLink($short_link)) { - // + $_route = $this->routes[$id_shop][$curr_lang_id]['manufacturer_rule']; + if (!Dispatcher::isManufacturerLink($short_link, $_route)) { + $_route = $this->routes[$id_shop][$curr_lang_id]['supplier_rule']; + if (!Dispatcher::isSupplierLink($short_link, $_route)) { + // } else { - $findRoute = $this->routes[$id_shop][$curr_lang_id]['supplier_rule']; + $findRoute = $_route; } } else { - $findRoute = $this->routes[$id_shop][$curr_lang_id]['manufacturer_rule']; + $findRoute = $_route; } } else { $findRoute = $this->routes[$id_shop][$curr_lang_id]['cms_category_rule']; From 0f2febdfeb5c0c3d4c4c2dff61481eec53ee62c2 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 1 Dec 2015 13:47:51 +0100 Subject: [PATCH 130/174] Release 1.0.2 --- config.xml | 4 ++-- zzcleanurls.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config.xml b/config.xml index 769ea75..6c101e1 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ zzcleanurls - + @@ -10,4 +10,4 @@ 1 0 - \ No newline at end of file + diff --git a/zzcleanurls.php b/zzcleanurls.php index a8a044d..37513e8 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -24,7 +24,7 @@ public function __construct() { $this->name = 'zzcleanurls'; $this->tab = 'seo'; - $this->version = '1.0.1'; + $this->version = '1.0.2'; $this->author = 'ZiZuu Store'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.5', 'max' => _PS_VERSION_); From e340b7b267c113e7ca80ea88937dd85dfebac047 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 1 Dec 2015 16:50:13 +0100 Subject: [PATCH 131/174] Release 1.0.3 - support for '.html' extension on every URL (close issue #25) --- config.xml | 2 +- override/classes/Dispatcher.php | 6 ++++-- override/controllers/front/CategoryController.php | 2 +- override/controllers/front/CmsController.php | 2 +- override/controllers/front/ManufacturerController.php | 2 +- override/controllers/front/SupplierController.php | 2 +- zzcleanurls.php | 2 +- 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/config.xml b/config.xml index 6c101e1..90b0a26 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ zzcleanurls - + diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index bccfcb2..5dd27e1 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -136,7 +136,7 @@ public static function isCategoryLink($short_link) $category = basename($short_link); $sql = 'SELECT `id_category` FROM `'._DB_PREFIX_.'category_lang` - WHERE `link_rewrite` = \''.pSQL($category).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; + WHERE `link_rewrite` = \''.pSQL(basename($category, '.html')).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); } @@ -178,7 +178,7 @@ public static function isCmsCategoryLink($short_link) $sql = 'SELECT l.`id_cms_category` FROM `'._DB_PREFIX_.'cms_category_lang` l LEFT JOIN `'._DB_PREFIX_.'cms_category_shop` s ON (l.`id_cms_category` = s.`id_cms_category`) - WHERE l.`link_rewrite` = \''.basename($short_link).'\''; + WHERE l.`link_rewrite` = \''.basename($short_link, '.html').'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); } @@ -196,6 +196,7 @@ public static function isCmsCategoryLink($short_link) */ public static function isManufacturerLink($short_link, $route) { + $short_link = str_replace('.html', '', $short_link); if ($short_link == str_replace('{rewrite}', '', $route['rule'])) { // manufacturers list return true; @@ -224,6 +225,7 @@ public static function isManufacturerLink($short_link, $route) */ public static function isSupplierLink($short_link, $route) { + $short_link = str_replace('.html', '', $short_link); if ($short_link == str_replace('{rewrite}', '', $route['rule'])) { // suppliers list return true; diff --git a/override/controllers/front/CategoryController.php b/override/controllers/front/CategoryController.php index 4bef4dc..d13f0a7 100644 --- a/override/controllers/front/CategoryController.php +++ b/override/controllers/front/CategoryController.php @@ -6,7 +6,7 @@ public function init() { if ($category_rewrite = Tools::getValue('category_rewrite')) { $sql = 'SELECT `id_category` FROM `'._DB_PREFIX_.'category_lang` - WHERE `link_rewrite` = \''.pSQL($category_rewrite).'\' AND `id_lang` = '.Context::getContext()->language->id; + WHERE `link_rewrite` = \''.pSQL(str_replace('.html', '', $category_rewrite)).'\' AND `id_lang` = '.Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); } diff --git a/override/controllers/front/CmsController.php b/override/controllers/front/CmsController.php index 6de3087..e1124d0 100644 --- a/override/controllers/front/CmsController.php +++ b/override/controllers/front/CmsController.php @@ -22,7 +22,7 @@ public function init() $sql = 'SELECT l.`id_cms_category` FROM `'._DB_PREFIX_.'cms_category_lang` l LEFT JOIN `'._DB_PREFIX_.'cms_category_shop` s ON (l.`id_cms_category` = s.`id_cms_category`) - WHERE `link_rewrite` = \''.pSQL($cms_category_rewrite).'\''.$shop_sql; + WHERE `link_rewrite` = \''.pSQL(str_replace('.html', '', $cms_category_rewrite)).'\''.$shop_sql; $id_cms_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_cms_category > 0) { diff --git a/override/controllers/front/ManufacturerController.php b/override/controllers/front/ManufacturerController.php index 36b5772..7a5c2af 100644 --- a/override/controllers/front/ManufacturerController.php +++ b/override/controllers/front/ManufacturerController.php @@ -8,7 +8,7 @@ public function init() $sql = 'SELECT m.`id_manufacturer` FROM `'._DB_PREFIX_.'manufacturer` m LEFT JOIN `'._DB_PREFIX_.'manufacturer_shop` s ON (m.`id_manufacturer` = s.`id_manufacturer`) - WHERE m.`name` LIKE \''.pSQL(str_replace('-', '%', $manufacturer_rewrite)).'\''; + WHERE m.`name` LIKE \''.pSQL(str_replace('-', '_', $manufacturer_rewrite)).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); } diff --git a/override/controllers/front/SupplierController.php b/override/controllers/front/SupplierController.php index 7dbe8fc..1ab86bf 100644 --- a/override/controllers/front/SupplierController.php +++ b/override/controllers/front/SupplierController.php @@ -8,7 +8,7 @@ public function init() $sql = 'SELECT sp.`id_supplier` FROM `'._DB_PREFIX_.'supplier` sp LEFT JOIN `'._DB_PREFIX_.'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`) - WHERE sp.`name` LIKE \''.pSQL(str_replace('-', '%', $supplier_rewrite)).'\''; + WHERE sp.`name` LIKE \''.pSQL(str_replace('-', '_', $supplier_rewrite)).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); } diff --git a/zzcleanurls.php b/zzcleanurls.php index 37513e8..aa0ad46 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -24,7 +24,7 @@ public function __construct() { $this->name = 'zzcleanurls'; $this->tab = 'seo'; - $this->version = '1.0.2'; + $this->version = '1.0.3'; $this->author = 'ZiZuu Store'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.5', 'max' => _PS_VERSION_); From 0c80eb7cb43c61258acea48f32e7108f26fde906 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 2 Dec 2015 14:07:15 +0100 Subject: [PATCH 132/174] Added license and composer support --- .gitignore | 1 + LICENSE.md | 7 + composer.json | 27 +++ composer.lock | 499 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 534 insertions(+) create mode 100644 LICENSE.md create mode 100644 composer.json create mode 100644 composer.lock diff --git a/.gitignore b/.gitignore index 6b36e53..8ad6e70 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .htaccess .svn .*.swp +vendor .php_cs.cache config_*.xml diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..74ef0c8 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,7 @@ +# LICENSE +![Creative Commons BY-NC-SA License](https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png) + + +**[ZiZuu CleanURLs](../../)** by [ZiZuu Store](../../../) is licensed under a **Creative Commons [Attribution-NonCommercial-ShareAlike](http://creativecommons.org/licenses/by-nc-sa/4.0/) 4.0 International License**. + +Permissions beyond the scope of this license may be available at info@ZiZuu.com. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..20e40f4 --- /dev/null +++ b/composer.json @@ -0,0 +1,27 @@ +{ + "name": "zizuu-store/zzcleanurls", + "description": "Prestashop module \"ZiZuu Clean URLs\". It removes objects' IDs from URL", + "homepage": "https://github.com/ZiZuu-store/zzCleanURLs", + "license": "Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)", + "authors": [ + { + "name": "ZiZuu Store", + "email": "info@ZiZuu.com" + } + ], + "require": { + "php": ">=5.3.2" + }, + "config": { + "preferred-install": "dist" + }, + "type": "prestashop-module", + "require-dev": { + "fabpot/php-cs-fixer": "^1.11" + }, + "scripts": { + "do-csfix": [ + "php-cs-fixer -vv -n fix; echo" + ] + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..5fb4176 --- /dev/null +++ b/composer.lock @@ -0,0 +1,499 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "12c220940f7904c2c002cc580a0330d4", + "content-hash": "09ed8c62353e4c4778868c325243af0e", + "packages": [], + "packages-dev": [ + { + "name": "fabpot/php-cs-fixer", + "version": "v1.11", + "source": { + "type": "git", + "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", + "reference": "bd3ec2c2b774e0e127ac2c737ec646d9cf2f9eef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/bd3ec2c2b774e0e127ac2c737ec646d9cf2f9eef", + "reference": "bd3ec2c2b774e0e127ac2c737ec646d9cf2f9eef", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.6", + "sebastian/diff": "~1.1", + "symfony/console": "~2.3|~3.0", + "symfony/event-dispatcher": "~2.1|~3.0", + "symfony/filesystem": "~2.1|~3.0", + "symfony/finder": "~2.1|~3.0", + "symfony/process": "~2.3|~3.0", + "symfony/stopwatch": "~2.5|~3.0" + }, + "require-dev": { + "satooshi/php-coveralls": "0.7.*@dev" + }, + "bin": [ + "php-cs-fixer" + ], + "type": "application", + "autoload": { + "psr-4": { + "Symfony\\CS\\": "Symfony/CS/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Dariusz Rumiński", + "email": "dariusz.ruminski@gmail.com" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "A tool to automatically fix PHP code style", + "time": "2015-12-01 22:34:33" + }, + { + "name": "sebastian/diff", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "http://www.github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2015-02-22 15:13:53" + }, + { + "name": "symfony/console", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "175871ca8d1ef16ff8d8cac395a1c73afa8d0e63" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/175871ca8d1ef16ff8d8cac395a1c73afa8d0e63", + "reference": "175871ca8d1ef16ff8d8cac395a1c73afa8d0e63", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "symfony/polyfill-mbstring": "~1.0" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/event-dispatcher": "~2.8|~3.0", + "symfony/process": "~2.8|~3.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2015-11-30 12:36:17" + }, + { + "name": "symfony/event-dispatcher", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "d36355e026905fa5229e1ed7b4e9eda2e67adfcf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d36355e026905fa5229e1ed7b4e9eda2e67adfcf", + "reference": "d36355e026905fa5229e1ed7b4e9eda2e67adfcf", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.8|~3.0", + "symfony/dependency-injection": "~2.8|~3.0", + "symfony/expression-language": "~2.8|~3.0", + "symfony/stopwatch": "~2.8|~3.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "https://symfony.com", + "time": "2015-10-30 23:35:59" + }, + { + "name": "symfony/filesystem", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "692d98d813e4ef314b9c22775c86ddbeb0f44884" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/692d98d813e4ef314b9c22775c86ddbeb0f44884", + "reference": "692d98d813e4ef314b9c22775c86ddbeb0f44884", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "https://symfony.com", + "time": "2015-11-23 10:41:47" + }, + { + "name": "symfony/finder", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "3577eb98dba90721d1a0a3edfc6956ab8b1aecee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/3577eb98dba90721d1a0a3edfc6956ab8b1aecee", + "reference": "3577eb98dba90721d1a0a3edfc6956ab8b1aecee", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "https://symfony.com", + "time": "2015-10-30 23:35:59" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "0b6a8940385311a24e060ec1fe35680e17c74497" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0b6a8940385311a24e060ec1fe35680e17c74497", + "reference": "0b6a8940385311a24e060ec1fe35680e17c74497", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2015-11-04 20:28:58" + }, + { + "name": "symfony/process", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "01383ed02a1020759bc8ee5d975fcec04ba16fbf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/01383ed02a1020759bc8ee5d975fcec04ba16fbf", + "reference": "01383ed02a1020759bc8ee5d975fcec04ba16fbf", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Process Component", + "homepage": "https://symfony.com", + "time": "2015-11-30 12:36:17" + }, + { + "name": "symfony/stopwatch", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "6aeac8907e3e1340a0033b0a9ec075f8e6524800" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/6aeac8907e3e1340a0033b0a9ec075f8e6524800", + "reference": "6aeac8907e3e1340a0033b0a9ec075f8e6524800", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Stopwatch Component", + "homepage": "https://symfony.com", + "time": "2015-10-30 23:35:59" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=5.3.2" + }, + "platform-dev": [] +} From 0831f72e7ddeb59962006fc5438a0689d59ee257 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 2 Dec 2015 16:38:35 +0100 Subject: [PATCH 133/174] Update README.md --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f075f26..15b17e1 100644 --- a/README.md +++ b/README.md @@ -21,13 +21,13 @@ If you fork, please make every change the way we can pull, don't reinvent the wh It has been reported to work on **PS 1.5.6 - 1.6.1.x** but will install on PS >= 1.5 too. **If you succesfully use this module on some older version please report** -## INSTALLATION +# INSTALLATION Install the module from the Backoffice (administration panel), download the release ZIP file (***zzcleanurls.zip***) as it already contains the right folder name (`zzcleanurls`, **not** `zzcleanurls-version_x.y.z` !) In the modules tab, click on **add a new module**. Click on Browse to open the dialogue box letting you search your computer, select the ZIP file then validate the dialogue box. Finally click on Upload this module. -### Make sure your SEO and URL settings are as follows: +## Make sure your SEO and URL settings are as follows: This is __MANDATORY__ * products: {category:/}{rewrite} (you **can** add .html at the end) @@ -44,7 +44,7 @@ Remember to * **clear the browser cache** * **clear PS cache** (under smarty -> cache and smarty -> compile) -## UNINSTALLATION +# UNINSTALLATION * Go to modules -> Find and uninstall "**zzcleanurls**" @@ -68,3 +68,7 @@ If something goes wrong do the following: If you got any other override modules, you should now go to you back office, uninstall them, and reinstall them again to work correctly. + +# License + +[LICENSE.md](LICENSE.md) From cb85d1bd1c3aa3ccc0727487a536e3ad75d9b2a3 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 2 Dec 2015 17:58:52 +0100 Subject: [PATCH 134/174] Some badge adjustments --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 15b17e1..aa60a25 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,15 @@ [![SensioLabsInsight](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba/mini.png)](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba) [![GitHub issues](https://img.shields.io/github/issues/ZiZuu-store/zzCleanURLs.svg?style=plastic)](https://github.com/ZiZuu-store/zzCleanURLs/issues) +[![Packagist](https://img.shields.io/packagist/l/zizuu-store/zzcleanurls.svg?style=plastic)](https://creativecommons.org/licenses/by-nc-sa/4.0/) +[![GitHub release](https://img.shields.io/github/release/ZiZuu-store/zzCleanURLs.svg?style=plastic&label=latest)](https://github.com/ZiZuu-store/zzCleanURLs/releases/latest) + +[![Packagist](https://img.shields.io/packagist/dt/zizuu-store/zzcleanurls.svg?style=plastic)](https://packagist.org/packages/zizuu-store/zzcleanurls) [![GitHub stars](https://img.shields.io/github/stars/ZiZuu-store/zzCleanURLs.svg?style=social)](https://github.com/ZiZuu-store/zzCleanURLs/stargazers) -[![Twitter](https://img.shields.io/twitter/url/https/github.com/ZiZuu-store/zzCleanURLs.svg?style=social)](https://twitter.com/intent/tweet?text=Fantastic @PrestaShop module by @ZiZuu_Store: "ZiZuu Clean URLs"&url=https://github.com/ZiZuu-store/zzCleanURLs) +[![GitHub forks](https://img.shields.io/github/forks/ZiZuu-store/zzCleanURLs.svg?style=social&label=Forks)]() [![Join the chat at https://gitter.im/ZiZuu-store/zzCleanURLs](https://img.shields.io/badge/Gitter-CHAT%20NOW-brightgreen.svg?style=plastic)](https://gitter.im/ZiZuu-store/zzCleanURLs) +[![Twitter](https://img.shields.io/twitter/url/https/github.com/ZiZuu-store/zzCleanURLs.svg?style=social)](https://twitter.com/intent/tweet?text=Fantastic @PrestaShop module by @ZiZuu_Store: "ZiZuu Clean URLs"&url=https://github.com/ZiZuu-store/zzCleanURLs) ___ @@ -71,4 +76,4 @@ If you got any other override modules, you should now go to you back office, uni # License -[LICENSE.md](LICENSE.md) +See [LICENSE.md](LICENSE.md). From 1b30977ebda88fb5338d41dfcf803711e47d6a8a Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 2 Dec 2015 18:04:19 +0100 Subject: [PATCH 135/174] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 20e40f4..fa7e206 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "zizuu-store/zzcleanurls", "description": "Prestashop module \"ZiZuu Clean URLs\". It removes objects' IDs from URL", "homepage": "https://github.com/ZiZuu-store/zzCleanURLs", - "license": "Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)", + "license": "Attribution-NonCommercial-ShareAlike 4.0 International (CC-BY-NC-SA-4.0)", "authors": [ { "name": "ZiZuu Store", From 78025b0bdce9c9695f18d337f4019f41b34a96b3 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 2 Dec 2015 18:08:56 +0100 Subject: [PATCH 136/174] update license in composer --- composer.json | 2 +- composer.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index fa7e206..18c88ae 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "zizuu-store/zzcleanurls", "description": "Prestashop module \"ZiZuu Clean URLs\". It removes objects' IDs from URL", "homepage": "https://github.com/ZiZuu-store/zzCleanURLs", - "license": "Attribution-NonCommercial-ShareAlike 4.0 International (CC-BY-NC-SA-4.0)", + "license": "CC-BY-NC-SA-4.0", "authors": [ { "name": "ZiZuu Store", diff --git a/composer.lock b/composer.lock index 5fb4176..ff67e38 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "12c220940f7904c2c002cc580a0330d4", + "hash": "6dc01864686b5afbe26492b40ae88dc6", "content-hash": "09ed8c62353e4c4778868c325243af0e", "packages": [], "packages-dev": [ From 5b114554322c077b13e83222094dc3a28f681545 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 7 Dec 2015 10:15:58 +0100 Subject: [PATCH 137/174] Update README.md --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index aa60a25..6765792 100644 --- a/README.md +++ b/README.md @@ -76,4 +76,9 @@ If you got any other override modules, you should now go to you back office, uni # License -See [LICENSE.md](LICENSE.md). +![Creative Commons BY-NC-SA License](https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png) + + +**[ZiZuu CleanURLs](https://github.com/ZiZuu-store/zzCleanURLs)** by [ZiZuu Store](https://github.com/ZiZuu-store) is licensed under a **Creative Commons [Attribution-NonCommercial-ShareAlike](http://creativecommons.org/licenses/by-nc-sa/4.0/) 4.0 International License**. + +Permissions beyond the scope of this license may be available contacting us at info@ZiZuu.com. From a80cc6fb0c272e3bf501c4a365cb62ff4279726a Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 7 Dec 2015 10:16:21 +0100 Subject: [PATCH 138/174] Delete LICENSE.md --- LICENSE.md | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index 74ef0c8..0000000 --- a/LICENSE.md +++ /dev/null @@ -1,7 +0,0 @@ -# LICENSE -![Creative Commons BY-NC-SA License](https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png) - - -**[ZiZuu CleanURLs](../../)** by [ZiZuu Store](../../../) is licensed under a **Creative Commons [Attribution-NonCommercial-ShareAlike](http://creativecommons.org/licenses/by-nc-sa/4.0/) 4.0 International License**. - -Permissions beyond the scope of this license may be available at info@ZiZuu.com. From 63e142282ed505a9a8ada87a9fd7127075066479 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 15 Dec 2015 17:45:37 +0100 Subject: [PATCH 139/174] Added more powerful debugging capabilities --- composer.json | 6 +- composer.lock | 178 +++++++++++++++++++++++++++++++++++++++++++++--- zzcleanurls.php | 7 ++ 3 files changed, 179 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 18c88ae..9cb1205 100644 --- a/composer.json +++ b/composer.json @@ -17,10 +17,12 @@ }, "type": "prestashop-module", "require-dev": { - "fabpot/php-cs-fixer": "^1.11" + "fabpot/php-cs-fixer": "^1.11", + "symfony/var-dumper": "^3.0", + "symfony/debug": "^3.0" }, "scripts": { - "do-csfix": [ + "csfix": [ "php-cs-fixer -vv -n fix; echo" ] } diff --git a/composer.lock b/composer.lock index ff67e38..7b907c5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "6dc01864686b5afbe26492b40ae88dc6", - "content-hash": "09ed8c62353e4c4778868c325243af0e", + "hash": "7389c3ecbd36aa1c8c029f79f6fa3bd6", + "content-hash": "e75d0f065075e80ae00b227c4de640ae", "packages": [], "packages-dev": [ { @@ -62,30 +62,68 @@ "description": "A tool to automatically fix PHP code style", "time": "2015-12-01 22:34:33" }, + { + "name": "psr/log", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Psr\\Log\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2012-12-21 11:40:51" + }, { "name": "sebastian/diff", - "version": "1.3.0", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3" + "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3", - "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e", + "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "~4.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -108,11 +146,11 @@ } ], "description": "Diff implementation", - "homepage": "http://www.github.com/sebastianbergmann/diff", + "homepage": "https://github.com/sebastianbergmann/diff", "keywords": [ "diff" ], - "time": "2015-02-22 15:13:53" + "time": "2015-12-08 07:14:41" }, { "name": "symfony/console", @@ -174,6 +212,63 @@ "homepage": "https://symfony.com", "time": "2015-11-30 12:36:17" }, + { + "name": "symfony/debug", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/debug.git", + "reference": "0623b00095f0833412ee6f92f421e9adf4c7e113" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/debug/zipball/0623b00095f0833412ee6f92f421e9adf4c7e113", + "reference": "0623b00095f0833412ee6f92f421e9adf4c7e113", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "psr/log": "~1.0" + }, + "conflict": { + "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + }, + "require-dev": { + "symfony/class-loader": "~2.8|~3.0", + "symfony/http-kernel": "~2.8|~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Debug\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "https://symfony.com", + "time": "2015-11-27 05:46:53" + }, { "name": "symfony/event-dispatcher", "version": "v3.0.0", @@ -485,6 +580,69 @@ "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", "time": "2015-10-30 23:35:59" + }, + { + "name": "symfony/var-dumper", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/var-dumper.git", + "reference": "737e07704cca83f9dd0af926d45ce27eedc25657" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/737e07704cca83f9dd0af926d45ce27eedc25657", + "reference": "737e07704cca83f9dd0af926d45ce27eedc25657", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "symfony/polyfill-mbstring": "~1.0" + }, + "require-dev": { + "twig/twig": "~1.20|~2.0" + }, + "suggest": { + "ext-symfony_debug": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "files": [ + "Resources/functions/dump.php" + ], + "psr-4": { + "Symfony\\Component\\VarDumper\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony mechanism for exploring and dumping PHP variables", + "homepage": "https://symfony.com", + "keywords": [ + "debug", + "dump" + ], + "time": "2015-11-18 13:48:51" } ], "aliases": [], diff --git a/zzcleanurls.php b/zzcleanurls.php index aa0ad46..51b7080 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -14,10 +14,17 @@ * @source https://github.com/ZiZuu-store/zzCleanURLs */ +define('ZZ_DEBUG', true); + if (!defined('_PS_VERSION_')) { return; } +if (defined('ZZ_DEBUG') && ZZ_DEBUG) { + require(__DIR__.'/vendor/autoload.php'); + Symfony\Component\Debug\Debug::enable(); +} + class zzCleanUrls extends Module { public function __construct() From 4733b438f63ee1b4cffeb1d1a40cecea6cb36f9d Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 16 Dec 2015 15:47:57 +0100 Subject: [PATCH 140/174] moved category_rule on top as the original --- override/classes/Dispatcher.php | 36 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index 5dd27e1..d7b149d 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -8,6 +8,17 @@ public function __construct() * @var array List of default routes */ $this->default_routes = array( + 'category_rule' => array( + 'controller' => 'category', + 'rule' => '{rewrite}/', + 'keywords' => array( + 'id' => array('regexp' => '[0-9]+'), + 'categories' => array('regexp' => '[/_a-zA-Z0-9\pL\pS-]*'), + '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-]*'), + ), + ), 'supplier_rule' => array( 'controller' => 'supplier', 'rule' => 'supplier/{rewrite}', @@ -52,7 +63,7 @@ public function __construct() 'controller' => null, 'rule' => 'module/{module}{/:controller}', 'keywords' => array( - 'module' => array('regexp' => '[_a-zA-Z0-9-]+', 'param' => 'module'), + 'module' => array('regexp' => '[_a-zA-Z0-9-]+', 'param' => 'module'), 'controller' => array('regexp' => '[_a-zA-Z0-9-]+', 'param' => 'controller'), ), 'params' => array( @@ -83,20 +94,9 @@ public function __construct() '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-]*'), + '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-]*'), ), ), ); @@ -132,10 +132,8 @@ public static function isProductLink($short_link) */ public static function isCategoryLink($short_link) { - // check if parent categories - $category = basename($short_link); - - $sql = 'SELECT `id_category` FROM `'._DB_PREFIX_.'category_lang` + $sql = 'SELECT `id_category` + FROM `'._DB_PREFIX_.'category_lang` WHERE `link_rewrite` = \''.pSQL(basename($category, '.html')).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); From 16e757b5c7ee85ded621b78bc05d24655d3750f4 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 16 Dec 2015 16:19:27 +0100 Subject: [PATCH 141/174] adjust debugging stuff --- composer.json | 2 +- composer.lock | 2 +- zzcleanurls.php | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 9cb1205..61df739 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ }, "scripts": { "csfix": [ - "php-cs-fixer -vv -n fix; echo" + "php-cs-fixer -vvv -n fix; echo" ] } } diff --git a/composer.lock b/composer.lock index 7b907c5..a0d3c5d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "7389c3ecbd36aa1c8c029f79f6fa3bd6", + "hash": "91878ed48efbe4055fe29903173a35df", "content-hash": "e75d0f065075e80ae00b227c4de640ae", "packages": [], "packages-dev": [ diff --git a/zzcleanurls.php b/zzcleanurls.php index 51b7080..4984716 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -14,14 +14,15 @@ * @source https://github.com/ZiZuu-store/zzCleanURLs */ -define('ZZ_DEBUG', true); - if (!defined('_PS_VERSION_')) { return; } -if (defined('ZZ_DEBUG') && ZZ_DEBUG) { - require(__DIR__.'/vendor/autoload.php'); +// Set true to enable debugging +define('ZZ_DEBUG', false); + +if (defined('ZZ_DEBUG') && ZZ_DEBUG && is_readable(__DIR__.'/vendor/autoload.php')) { + require __DIR__.'/vendor/autoload.php'; Symfony\Component\Debug\Debug::enable(); } From a5c37dafc028ab866d01c59c939eafa47740ca6f Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 16 Dec 2015 17:45:23 +0100 Subject: [PATCH 142/174] Fix variable name in isCategoryLink() --- override/classes/Dispatcher.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index d7b149d..6687584 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -134,7 +134,7 @@ public static function isCategoryLink($short_link) { $sql = 'SELECT `id_category` FROM `'._DB_PREFIX_.'category_lang` - WHERE `link_rewrite` = \''.pSQL(basename($category, '.html')).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; + WHERE `link_rewrite` = \''.pSQL(basename($short_link, '.html')).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); } From 0acbf7a31dead26d7583ac7b395f4cceaa60ceb1 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Sat, 2 Jan 2016 10:24:56 +0100 Subject: [PATCH 143/174] Update zzcleanurls.php --- zzcleanurls.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zzcleanurls.php b/zzcleanurls.php index 4984716..ace3b90 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -18,8 +18,8 @@ return; } -// Set true to enable debugging -define('ZZ_DEBUG', false); +// Uncomment to enable debugging +// define('ZZ_DEBUG', true); if (defined('ZZ_DEBUG') && ZZ_DEBUG && is_readable(__DIR__.'/vendor/autoload.php')) { require __DIR__.'/vendor/autoload.php'; From f9b47441e6389e24beddb4c058b9ef2857b3192e Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Sun, 3 Jan 2016 11:12:20 +0100 Subject: [PATCH 144/174] fixed "forks" badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6765792..14fc2df 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ [![Packagist](https://img.shields.io/packagist/dt/zizuu-store/zzcleanurls.svg?style=plastic)](https://packagist.org/packages/zizuu-store/zzcleanurls) [![GitHub stars](https://img.shields.io/github/stars/ZiZuu-store/zzCleanURLs.svg?style=social)](https://github.com/ZiZuu-store/zzCleanURLs/stargazers) -[![GitHub forks](https://img.shields.io/github/forks/ZiZuu-store/zzCleanURLs.svg?style=social&label=Forks)]() +[![GitHub forks](https://img.shields.io/github/forks/ZiZuu-store/zzCleanURLs.svg?style=social&label=Forks)](https://github.com/ZiZuu-store/zzCleanURLs/network) [![Join the chat at https://gitter.im/ZiZuu-store/zzCleanURLs](https://img.shields.io/badge/Gitter-CHAT%20NOW-brightgreen.svg?style=plastic)](https://gitter.im/ZiZuu-store/zzCleanURLs) [![Twitter](https://img.shields.io/twitter/url/https/github.com/ZiZuu-store/zzCleanURLs.svg?style=social)](https://twitter.com/intent/tweet?text=Fantastic @PrestaShop module by @ZiZuu_Store: "ZiZuu Clean URLs"&url=https://github.com/ZiZuu-store/zzCleanURLs) From a890facbeda948508efaf6ef8e7fb60fcb9bc671 Mon Sep 17 00:00:00 2001 From: MJ-Aristote Date: Fri, 8 Jan 2016 14:27:30 +0100 Subject: [PATCH 145/174] Remove annoying warning Notice: Undefined variable: shop_sql in /override/controllers/front/CmsController.php on line 93 --- override/controllers/front/CmsController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/override/controllers/front/CmsController.php b/override/controllers/front/CmsController.php index e1124d0..09895da 100644 --- a/override/controllers/front/CmsController.php +++ b/override/controllers/front/CmsController.php @@ -4,6 +4,7 @@ class CmsController extends CmsControllerCore { public function init() { + $shop_sql = ""; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $shop_sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); } From 52ad1e451f95006338e93f6d0038bdb0caef7378 Mon Sep 17 00:00:00 2001 From: MJ-Aristote Date: Mon, 11 Jan 2016 08:52:19 +0100 Subject: [PATCH 146/174] remove concatenation on an empty string remove the .= operator on line 9 and substitute with simple --- override/controllers/front/CmsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/override/controllers/front/CmsController.php b/override/controllers/front/CmsController.php index 09895da..b6783ce 100644 --- a/override/controllers/front/CmsController.php +++ b/override/controllers/front/CmsController.php @@ -6,7 +6,7 @@ public function init() { $shop_sql = ""; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $shop_sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + $shop_sql = ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); } if ($cms_rewrite = Tools::getValue('cms_rewrite')) { From 5a694eca6c85b052889116a43c6b726e4b366183 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Sun, 17 Jan 2016 00:14:57 +0100 Subject: [PATCH 147/174] Update zzcleanurls.php remove commented out code --- zzcleanurls.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zzcleanurls.php b/zzcleanurls.php index ace3b90..4984716 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -18,8 +18,8 @@ return; } -// Uncomment to enable debugging -// define('ZZ_DEBUG', true); +// Set true to enable debugging +define('ZZ_DEBUG', false); if (defined('ZZ_DEBUG') && ZZ_DEBUG && is_readable(__DIR__.'/vendor/autoload.php')) { require __DIR__.'/vendor/autoload.php'; From 53cfd184fa9887d1ab93d5e42ccca73adc84a96e Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 9 Feb 2016 19:15:11 +0100 Subject: [PATCH 148/174] Try to avoid __construct, override loadRoutes() --- override/classes/Dispatcher.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index 6687584..4d20bbb 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -2,7 +2,7 @@ class Dispatcher extends DispatcherCore { - public function __construct() + protected function loadRoutes($id_shop = null) { /** * @var array List of default routes @@ -101,7 +101,7 @@ public function __construct() ), ); - parent::__construct(); + parent::loadRoutes($id_shop); } /** From f52749174755fbff4f7f36470d473698e4bd8c69 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 10 Feb 2016 10:20:33 +0100 Subject: [PATCH 149/174] no new line at EOF --- config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.xml b/config.xml index 90b0a26..9ef3c11 100644 --- a/config.xml +++ b/config.xml @@ -10,4 +10,4 @@ 1 0 - +
\ No newline at end of file From 559ef7edd62ad8cc2ed6eba3f0f3dabdf2e0bff4 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 10 Feb 2016 10:50:56 +0100 Subject: [PATCH 150/174] Update config.xml --- config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.xml b/config.xml index 9ef3c11..90b0a26 100644 --- a/config.xml +++ b/config.xml @@ -10,4 +10,4 @@ 1 0 -
\ No newline at end of file +
From 3571a58d3d71a07b994efe8a05c55110d7d27686 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 10 Feb 2016 10:51:48 +0100 Subject: [PATCH 151/174] Update .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8ad6e70..8a52790 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ .htaccess .svn -.*.swp vendor .php_cs.cache config_*.xml From 75a5d43990775b9e65b31d9b526899f163cba84e Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 10 Feb 2016 10:55:44 +0100 Subject: [PATCH 152/174] Release 1.0.4 --- config.xml | 2 +- zzcleanurls.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config.xml b/config.xml index 90b0a26..7527eaf 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ zzcleanurls - + diff --git a/zzcleanurls.php b/zzcleanurls.php index 4984716..4dfd23f 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -32,7 +32,7 @@ public function __construct() { $this->name = 'zzcleanurls'; $this->tab = 'seo'; - $this->version = '1.0.3'; + $this->version = '1.0.4'; $this->author = 'ZiZuu Store'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.5', 'max' => _PS_VERSION_); From 2c41d07c3965969335c57314553f36b6d54c2a70 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Wed, 10 Feb 2016 12:56:46 +0100 Subject: [PATCH 153/174] Update composer.json --- composer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 61df739..f302feb 100644 --- a/composer.json +++ b/composer.json @@ -3,27 +3,27 @@ "description": "Prestashop module \"ZiZuu Clean URLs\". It removes objects' IDs from URL", "homepage": "https://github.com/ZiZuu-store/zzCleanURLs", "license": "CC-BY-NC-SA-4.0", + "type": "prestashop-module", "authors": [ { "name": "ZiZuu Store", "email": "info@ZiZuu.com" } ], - "require": { - "php": ">=5.3.2" - }, "config": { "preferred-install": "dist" }, - "type": "prestashop-module", "require-dev": { "fabpot/php-cs-fixer": "^1.11", "symfony/var-dumper": "^3.0", "symfony/debug": "^3.0" }, + "require": { + "php": ">=5.3.2" + }, "scripts": { "csfix": [ - "php-cs-fixer -vvv -n fix; echo" + "php-cs-fixer -vvv fix" ] } } From 687dfdc412535aba3a454be75de11e2305370d58 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 15 Feb 2016 14:40:40 +0100 Subject: [PATCH 154/174] Closes #41 - allow id, ean13 and oter parameters - a bit of code simplification - fixed regex greediness and double preg_quote bug by overriding core method --- .gitignore | 1 + README.md | 4 +- composer.lock | 107 ++++---- config.xml | 2 +- override/classes/Dispatcher.php | 437 ++++++++++++++++++++------------ zzcleanurls.php | 12 +- 6 files changed, 337 insertions(+), 226 deletions(-) diff --git a/.gitignore b/.gitignore index 8a52790..fd264bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .htaccess .svn vendor +.cache .php_cs.cache config_*.xml diff --git a/README.md b/README.md index 14fc2df..f3214da 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Install the module from the Backoffice (administration panel), download the rele In the modules tab, click on **add a new module**. Click on Browse to open the dialogue box letting you search your computer, select the ZIP file then validate the dialogue box. Finally click on Upload this module. ## Make sure your SEO and URL settings are as follows: - + This is __MANDATORY__ * products: {category:/}{rewrite} (you **can** add .html at the end) * categories: {categories:/}{rewrite}**/** @@ -45,7 +45,7 @@ This is __MANDATORY__ You can replace words such as "info", "suppliers", etc with whatever you want, given that it does not conflicts with a category name -Remember to +Remember to * **clear the browser cache** * **clear PS cache** (under smarty -> cache and smarty -> compile) diff --git a/composer.lock b/composer.lock index a0d3c5d..88c8659 100644 --- a/composer.lock +++ b/composer.lock @@ -4,22 +4,22 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "91878ed48efbe4055fe29903173a35df", + "hash": "f8b52cd5284c103c5500a4f7970f8dd6", "content-hash": "e75d0f065075e80ae00b227c4de640ae", "packages": [], "packages-dev": [ { "name": "fabpot/php-cs-fixer", - "version": "v1.11", + "version": "v1.11.1", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "bd3ec2c2b774e0e127ac2c737ec646d9cf2f9eef" + "reference": "2c9f8298181f059c5077abda78019b9a0c9a7cc0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/bd3ec2c2b774e0e127ac2c737ec646d9cf2f9eef", - "reference": "bd3ec2c2b774e0e127ac2c737ec646d9cf2f9eef", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/2c9f8298181f059c5077abda78019b9a0c9a7cc0", + "reference": "2c9f8298181f059c5077abda78019b9a0c9a7cc0", "shasum": "" }, "require": { @@ -60,7 +60,7 @@ } ], "description": "A tool to automatically fix PHP code style", - "time": "2015-12-01 22:34:33" + "time": "2016-01-20 19:00:28" }, { "name": "psr/log", @@ -154,16 +154,16 @@ }, { "name": "symfony/console", - "version": "v3.0.0", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "175871ca8d1ef16ff8d8cac395a1c73afa8d0e63" + "reference": "5a02eaadaa285e2bb727eb6bbdfb8201fcd971b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/175871ca8d1ef16ff8d8cac395a1c73afa8d0e63", - "reference": "175871ca8d1ef16ff8d8cac395a1c73afa8d0e63", + "url": "https://api.github.com/repos/symfony/console/zipball/5a02eaadaa285e2bb727eb6bbdfb8201fcd971b0", + "reference": "5a02eaadaa285e2bb727eb6bbdfb8201fcd971b0", "shasum": "" }, "require": { @@ -210,20 +210,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2015-11-30 12:36:17" + "time": "2016-02-02 13:44:19" }, { "name": "symfony/debug", - "version": "v3.0.0", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "0623b00095f0833412ee6f92f421e9adf4c7e113" + "reference": "29606049ced1ec715475f88d1bbe587252a3476e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/0623b00095f0833412ee6f92f421e9adf4c7e113", - "reference": "0623b00095f0833412ee6f92f421e9adf4c7e113", + "url": "https://api.github.com/repos/symfony/debug/zipball/29606049ced1ec715475f88d1bbe587252a3476e", + "reference": "29606049ced1ec715475f88d1bbe587252a3476e", "shasum": "" }, "require": { @@ -267,20 +267,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2015-11-27 05:46:53" + "time": "2016-01-27 05:14:46" }, { "name": "symfony/event-dispatcher", - "version": "v3.0.0", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "d36355e026905fa5229e1ed7b4e9eda2e67adfcf" + "reference": "4dd5df31a28c0f82b41cb1e1599b74b5dcdbdafa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d36355e026905fa5229e1ed7b4e9eda2e67adfcf", - "reference": "d36355e026905fa5229e1ed7b4e9eda2e67adfcf", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/4dd5df31a28c0f82b41cb1e1599b74b5dcdbdafa", + "reference": "4dd5df31a28c0f82b41cb1e1599b74b5dcdbdafa", "shasum": "" }, "require": { @@ -327,20 +327,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2015-10-30 23:35:59" + "time": "2016-01-27 05:14:46" }, { "name": "symfony/filesystem", - "version": "v3.0.0", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "692d98d813e4ef314b9c22775c86ddbeb0f44884" + "reference": "064ac12afd2ceb8a2c1bfb7bed8e931c6dd1997f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/692d98d813e4ef314b9c22775c86ddbeb0f44884", - "reference": "692d98d813e4ef314b9c22775c86ddbeb0f44884", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/064ac12afd2ceb8a2c1bfb7bed8e931c6dd1997f", + "reference": "064ac12afd2ceb8a2c1bfb7bed8e931c6dd1997f", "shasum": "" }, "require": { @@ -376,20 +376,20 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2015-11-23 10:41:47" + "time": "2016-01-27 11:34:55" }, { "name": "symfony/finder", - "version": "v3.0.0", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "3577eb98dba90721d1a0a3edfc6956ab8b1aecee" + "reference": "623bda0abd9aa29e529c8e9c08b3b84171914723" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/3577eb98dba90721d1a0a3edfc6956ab8b1aecee", - "reference": "3577eb98dba90721d1a0a3edfc6956ab8b1aecee", + "url": "https://api.github.com/repos/symfony/finder/zipball/623bda0abd9aa29e529c8e9c08b3b84171914723", + "reference": "623bda0abd9aa29e529c8e9c08b3b84171914723", "shasum": "" }, "require": { @@ -425,29 +425,32 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2015-10-30 23:35:59" + "time": "2016-01-27 05:14:46" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.0.0", + "version": "v1.1.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "0b6a8940385311a24e060ec1fe35680e17c74497" + "reference": "1289d16209491b584839022f29257ad859b8532d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0b6a8940385311a24e060ec1fe35680e17c74497", - "reference": "0b6a8940385311a24e060ec1fe35680e17c74497", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/1289d16209491b584839022f29257ad859b8532d", + "reference": "1289d16209491b584839022f29257ad859b8532d", "shasum": "" }, "require": { "php": ">=5.3.3" }, + "suggest": { + "ext-mbstring": "For best performance" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.1-dev" } }, "autoload": { @@ -481,20 +484,20 @@ "portable", "shim" ], - "time": "2015-11-04 20:28:58" + "time": "2016-01-20 09:13:37" }, { "name": "symfony/process", - "version": "v3.0.0", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "01383ed02a1020759bc8ee5d975fcec04ba16fbf" + "reference": "dfecef47506179db2501430e732adbf3793099c8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/01383ed02a1020759bc8ee5d975fcec04ba16fbf", - "reference": "01383ed02a1020759bc8ee5d975fcec04ba16fbf", + "url": "https://api.github.com/repos/symfony/process/zipball/dfecef47506179db2501430e732adbf3793099c8", + "reference": "dfecef47506179db2501430e732adbf3793099c8", "shasum": "" }, "require": { @@ -530,20 +533,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2015-11-30 12:36:17" + "time": "2016-02-02 13:44:19" }, { "name": "symfony/stopwatch", - "version": "v3.0.0", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "6aeac8907e3e1340a0033b0a9ec075f8e6524800" + "reference": "4a204804952ff267ace88cf499e0b4bb302a475e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/6aeac8907e3e1340a0033b0a9ec075f8e6524800", - "reference": "6aeac8907e3e1340a0033b0a9ec075f8e6524800", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/4a204804952ff267ace88cf499e0b4bb302a475e", + "reference": "4a204804952ff267ace88cf499e0b4bb302a475e", "shasum": "" }, "require": { @@ -579,20 +582,20 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", - "time": "2015-10-30 23:35:59" + "time": "2016-01-03 15:35:16" }, { "name": "symfony/var-dumper", - "version": "v3.0.0", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "737e07704cca83f9dd0af926d45ce27eedc25657" + "reference": "24bb94807eff00db49374c37ebf56a0304e8aef3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/737e07704cca83f9dd0af926d45ce27eedc25657", - "reference": "737e07704cca83f9dd0af926d45ce27eedc25657", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/24bb94807eff00db49374c37ebf56a0304e8aef3", + "reference": "24bb94807eff00db49374c37ebf56a0304e8aef3", "shasum": "" }, "require": { @@ -642,7 +645,7 @@ "debug", "dump" ], - "time": "2015-11-18 13:48:51" + "time": "2016-01-07 13:38:51" } ], "aliases": [], diff --git a/config.xml b/config.xml index 7527eaf..eb396da 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ zzcleanurls - + diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index 4d20bbb..d7b8278 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -2,6 +2,9 @@ class Dispatcher extends DispatcherCore { + /** + * Load default routes group by languages + */ protected function loadRoutes($id_shop = null) { /** @@ -61,7 +64,7 @@ protected function loadRoutes($id_shop = null) ), 'module' => array( 'controller' => null, - 'rule' => 'module/{module}{/:controller}', + 'rule' => 'module/{module}/{controller}', 'keywords' => array( 'module' => array('regexp' => '[_a-zA-Z0-9-]+', 'param' => 'module'), 'controller' => array('regexp' => '[_a-zA-Z0-9-]+', 'param' => 'controller'), @@ -76,7 +79,7 @@ protected function loadRoutes($id_shop = null) '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]*'), + 'ean13' => array('regexp' => '[0-9]{8,17}'), 'category' => array('regexp' => '[_a-zA-Z0-9\pL-]*'), 'categories' => array('regexp' => '[/_a-zA-Z0-9\pL-]*'), 'reference' => array('regexp' => '[_a-zA-Z0-9\pL-]*'), @@ -90,7 +93,7 @@ protected function loadRoutes($id_shop = null) ), 'layered_rule' => array( 'controller' => 'category', - 'rule' => '{rewrite}/f{/:selected_filters}', + 'rule' => '{rewrite}/f/{selected_filters}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), 'selected_filters' => array('regexp' => '.*', 'param' => 'selected_filters'), @@ -105,143 +108,67 @@ protected function loadRoutes($id_shop = null) } /** - * Check if $short_link is a Product Link - * - * @param string $short_link: requested url without '?' part and without '/' on begining - * @return bool true: it's a link to product, false: it isn't - */ - public static function isProductLink($short_link) - { - $sql = 'SELECT `id_product` - FROM `'._DB_PREFIX_.'product_lang` - WHERE `link_rewrite` = \''.pSQL(basename($short_link, '.html')).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); - } - - $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - - return ($id_product > 0); - } - - /** - * Check if $short_link is a Category Link - * - * @param string $short_link: requested url without '?' part and without '/' on begining - * @return bool true: it's a link to category, false: it isn't - */ - public static function isCategoryLink($short_link) - { - $sql = 'SELECT `id_category` - FROM `'._DB_PREFIX_.'category_lang` - WHERE `link_rewrite` = \''.pSQL(basename($short_link, '.html')).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); - } - - $id_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - - return ($id_category > 0); - } - - /** - * Check if $short_link is a Cms Link * - * @param string $short_link: requested url without '?' part and without '/' on begining - * @return bool true: it's a link to cms page, false: it isn't + * @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 static function isCmsLink($short_link) + public function addRoute($route_id, $rule, $controller, $id_lang = null, array $keywords = array(), array $params = array(), $id_shop = null) { - $sql = 'SELECT l.`id_cms` - FROM `'._DB_PREFIX_.'cms_lang` l - LEFT JOIN `'._DB_PREFIX_.'cms_shop` s ON (l.`id_cms` = s.`id_cms`) - WHERE l.`link_rewrite` = \''.pSQL(basename($short_link, '.html')).'\''; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); - } - - $id_cms = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - - return ($id_cms > 0); - } - - /** - * Check if $short_link is a Cms Category Link - * - * @param string $short_link: requested url without '?' part and without '/' on begining - * @return bool true: it's a link to cms page, false: it isn't - */ - public static function isCmsCategoryLink($short_link) - { - $sql = 'SELECT l.`id_cms_category` - FROM `'._DB_PREFIX_.'cms_category_lang` l - LEFT JOIN `'._DB_PREFIX_.'cms_category_shop` s ON (l.`id_cms_category` = s.`id_cms_category`) - WHERE l.`link_rewrite` = \''.basename($short_link, '.html').'\''; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + if (isset(Context::getContext()->language) && $id_lang === null) { + $id_lang = (int)Context::getContext()->language->id; } - $id_cms_cat = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - - return ($id_cms_cat > 0); - } - - /** - * Check if $short_link is a Manufacturer Link - * - * @param string $short_link: requested url without '?' part and without '/' on begining - * @return bool true: it's a link to manufacturer, false: it isn't - */ - public static function isManufacturerLink($short_link, $route) - { - $short_link = str_replace('.html', '', $short_link); - if ($short_link == str_replace('{rewrite}', '', $route['rule'])) { - // manufacturers list - return true; + if (isset(Context::getContext()->shop) && $id_shop === null) { + $id_shop = (int)Context::getContext()->shop->id; } - $manufacturer = str_replace('-', '_', basename($short_link)); + $regexp = preg_quote($rule, '#'); + if ($keywords) { + $transform_keywords = array(); + preg_match_all('#\\\{(([^{}]*)\\\:)?('.implode('|', array_keys($keywords)).')(\\\:([^{}]*))?\\\}#', $regexp, $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 = '('.$prepend; + $append_regexp = $append.')??'; // fix greediness (step 1) + } - $sql = 'SELECT m.`id_manufacturer` - FROM `'._DB_PREFIX_.'manufacturer` m - LEFT JOIN `'._DB_PREFIX_.'manufacturer_shop` s ON (m.`id_manufacturer` = s.`id_manufacturer`) - WHERE LOWER(m.`name`) LIKE \''.pSQL($manufacturer).'\''; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + if (isset($keywords[$keyword]['param'])) { + $regexp = str_replace($m[0][$i], $prepend_regexp.'(?P<'.$keywords[$keyword]['param'].'>'.$keywords[$keyword]['regexp'].')'.$append_regexp, $regexp); + } else { + $regexp = str_replace($m[0][$i], $prepend_regexp.'('.$keywords[$keyword]['regexp'].')'.$append_regexp, $regexp); + } + } + $keywords = $transform_keywords; } - $id_manufacturer = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - - return ($id_manufacturer > 0); - } - - /** - * Check if $short_link is a Supplier Link - * - * @param string $short_link: requested url without '?' part and without '/' on begining - * @return bool true: it's a link to supplier, false: it isn't - */ - public static function isSupplierLink($short_link, $route) - { - $short_link = str_replace('.html', '', $short_link); - if ($short_link == str_replace('{rewrite}', '', $route['rule'])) { - // suppliers list - return true; + $regexp = '#^/'.$regexp.'$#uU'; // fix greediness (step 2) + if (!isset($this->routes[$id_shop])) { + $this->routes[$id_shop] = array(); } - - $supplier = str_replace('-', '_', basename($short_link)); - - $sql = 'SELECT sp.`id_supplier` - FROM `'._DB_PREFIX_.'supplier` sp - LEFT JOIN `'._DB_PREFIX_.'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`) - WHERE LOWER(sp.`name`) LIKE \''.pSQL($supplier).'\''; - if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + if (!isset($this->routes[$id_shop][$id_lang])) { + $this->routes[$id_shop][$id_lang] = array(); } - $id_supplier = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - - return ($id_supplier > 0); + $this->routes[$id_shop][$id_lang][$route_id] = array( + 'rule' => $rule, + 'regexp' => $regexp, + 'controller' => $controller, + 'keywords' => $keywords, + 'params' => $params, + ); } /** @@ -299,18 +226,18 @@ public function getController($id_shop = null) list($uri) = explode('?', $this->request_uri); if (isset($this->routes[$id_shop][$curr_lang_id])) { - $findRoute = array(); + $route = array(); // check, whether request_uri is template or not - foreach ($this->routes[$id_shop][$curr_lang_id] as $route) { - if (preg_match($route['regexp'], $uri, $m)) { + foreach ($this->routes[$id_shop][$curr_lang_id] as $k => $r) { + if (preg_match($r['regexp'], $uri, $m)) { $isTemplate = false; - $module = isset($route['params']['module']) ? $route['params']['module'] : ''; - switch ($route['controller'].$module) { // Avoid name collision between core and modules' controllers + $module = isset($r['params']['module']) ? $r['params']['module'] : ''; + switch ($r['controller'].$module) { // Avoid name collision between core and modules' controllers case 'supplier': case 'manufacturer': // these two can be processed in normal way and also as template - if (false !== strpos($route['rule'], '{')) { + if (false !== strpos($r['rule'], '{')) { $isTemplate = true; } break; @@ -321,65 +248,62 @@ public function getController($id_shop = null) break; case 'category': // category can be processed in two ways - if (false === strpos($route['rule'], 'selected_filters')) { + if (false === strpos($r['rule'], 'selected_filters')) { $isTemplate = true; } break; } if (!$isTemplate) { - $findRoute = $route; + $route = $r; break; } } } // if route is not found, we have to find rewrite link in database - if (empty($findRoute)) { + if (empty($route)) { // get the path from requested URI, and remove "/" at the beginning $short_link = ltrim(parse_url($uri, PHP_URL_PATH), '/'); - if (!Dispatcher::isProductLink($short_link)) { - if (!Dispatcher::isCategoryLink($short_link)) { - if (!Dispatcher::isCmsLink($short_link)) { - if (!Dispatcher::isCmsCategoryLink($short_link)) { - $_route = $this->routes[$id_shop][$curr_lang_id]['manufacturer_rule']; - if (!Dispatcher::isManufacturerLink($short_link, $_route)) { - $_route = $this->routes[$id_shop][$curr_lang_id]['supplier_rule']; - if (!Dispatcher::isSupplierLink($short_link, $_route)) { - // - } else { - $findRoute = $_route; + $route = $this->routes[$id_shop][$curr_lang_id]['product_rule']; + if (!Dispatcher::isProductLink($short_link, $route)) { + $route = $this->routes[$id_shop][$curr_lang_id]['category_rule']; + if (!Dispatcher::isCategoryLink($short_link, $route)) { + $route = $this->routes[$id_shop][$curr_lang_id]['cms_rule']; + if (!Dispatcher::isCmsLink($short_link, $route)) { + $route = $this->routes[$id_shop][$curr_lang_id]['cms_category_rule']; + if (!Dispatcher::isCmsCategoryLink($short_link, $route)) { + $route = $this->routes[$id_shop][$curr_lang_id]['manufacturer_rule']; + if (!Dispatcher::isManufacturerLink($short_link, $route)) { + $route = $this->routes[$id_shop][$curr_lang_id]['supplier_rule']; + if (!Dispatcher::isSupplierLink($short_link, $route)) { + // no route found + $route = array(); + $controller = $this->controller_not_found; } - } else { - $findRoute = $_route; } - } else { - $findRoute = $this->routes[$id_shop][$curr_lang_id]['cms_category_rule']; } - } else { - $findRoute = $this->routes[$id_shop][$curr_lang_id]['cms_rule']; } - } else { - $findRoute = $this->routes[$id_shop][$curr_lang_id]['category_rule']; } - } else { - $findRoute = $this->routes[$id_shop][$curr_lang_id]['product_rule']; + } + if (!empty($route['controller'])) { + $controller = $route['controller']; } } - if (!empty($findRoute)) { - if (preg_match($findRoute['regexp'], $uri, $m)) { - // Route found ! Now fill $_GET with parameters of uri + if (!empty($route)) { + if (preg_match($route['regexp'], $uri, $m)) { + // Route found! Now fill $_GET with parameters of uri foreach ($m as $k => $v) { if (!is_numeric($k)) { $_GET[$k] = $v; } } - $controller = $findRoute['controller'] ? $findRoute['controller'] : $_GET['controller']; - if (!empty($findRoute['params'])) { - foreach ($findRoute['params'] as $k => $v) { + $controller = $route['controller'] ? $route['controller'] : $_GET['controller']; + if (!empty($route['params'])) { + foreach ($route['params'] as $k => $v) { $_GET[$k] = $v; } } @@ -412,4 +336,191 @@ public function getController($id_shop = null) return $this->controller; } + + /** + * Check if $short_link is a Product Link + * + * @param string $short_link: requested url without '?' part and without '/' on begining + * @return bool true: it's a link to product, false: it isn't + */ + private static function isProductLink($short_link, $route) + { + $short_link = preg_replace('#\.html?$#', '', '/'.$short_link); + $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); + + preg_match($regexp, $short_link, $kw); + if (empty($kw['product_rewrite'])) { + return false; + } + + $sql = 'SELECT `id_product` + FROM `'._DB_PREFIX_.'product_lang` + WHERE `link_rewrite` = \''.pSQL($kw['product_rewrite']).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); + } + $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + + return ($id_product > 0); + } + + /** + * Check if $short_link is a Category Link + * + * @param string $short_link: requested url without '?' part and without '/' on begining + * @return bool true: it's a link to category, false: it isn't + */ + private static function isCategoryLink($short_link, $route) + { + $short_link = preg_replace('#\.html?$#', '', '/'.$short_link); + $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); + + preg_match($regexp, $short_link, $kw); + if (empty($kw['category_rewrite'])) { + return false; + } + + $sql = 'SELECT `id_category` + FROM `'._DB_PREFIX_.'category_lang` + WHERE `link_rewrite` = \''.pSQL($kw['category_rewrite']).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); + } + + $id_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + + return ($id_category > 0); + } + + /** + * Check if $short_link is a Cms Link + * + * @param string $short_link: requested url without '?' part and without '/' on begining + * @return bool true: it's a link to cms page, false: it isn't + */ + private static function isCmsLink($short_link, $route) + { + $short_link = preg_replace('#\.html?$#', '', '/'.$short_link); + $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); + + preg_match($regexp, $short_link, $kw); + if (empty($kw['cms_rewrite'])) { + return false; + } + + $sql = 'SELECT l.`id_cms` + FROM `'._DB_PREFIX_.'cms_lang` l + LEFT JOIN `'._DB_PREFIX_.'cms_shop` s ON (l.`id_cms` = s.`id_cms`) + WHERE l.`link_rewrite` = \''.pSQL($kw['cms_rewrite']).'\''; + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + } + + $id_cms = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + + return ($id_cms > 0); + } + + /** + * Check if $short_link is a Cms Category Link + * + * @param string $short_link: requested url without '?' part and without '/' on begining + * @return bool true: it's a link to cms page, false: it isn't + */ + private static function isCmsCategoryLink($short_link, $route) + { + $short_link = preg_replace('#\.html?$#', '', '/'.$short_link); + $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); + + preg_match($regexp, $short_link, $kw); + if (empty($kw['cms_category_rewrite'])) { + if (0 === strpos('/'.$route['rule'], $short_link)) { + //no link_rewrite, but uri starts with the link -> cms categories' list + return true; + } + return false; + } + + $sql = 'SELECT l.`id_cms_category` + FROM `'._DB_PREFIX_.'cms_category_lang` l + LEFT JOIN `'._DB_PREFIX_.'cms_category_shop` s ON (l.`id_cms_category` = s.`id_cms_category`) + WHERE l.`link_rewrite` = \''.$kw['cms_category_rewrite'].'\''; + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + } + + $id_cms_cat = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + + return ($id_cms_cat > 0); + } + + /** + * Check if $short_link is a Manufacturer Link + * + * @param string $short_link: requested url without '?' part and without '/' on begining + * @return bool true: it's a link to manufacturer, false: it isn't + */ + private static function isManufacturerLink($short_link, $route) + { + $short_link = preg_replace('#\.html?$#', '', '/'.$short_link); + $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); + + preg_match($regexp, $short_link, $kw); + if (empty($kw['manufacturer_rewrite'])) { + if (0 === strpos('/'.$route['rule'], $short_link)) { + //no link_rewrite, but uri starts with the link -> manufactures' list + return true; + } + return false; + } + + $manufacturer = str_replace('-', '_', $kw['manufacturer_rewrite']); + + $sql = 'SELECT m.`id_manufacturer` + FROM `'._DB_PREFIX_.'manufacturer` m + LEFT JOIN `'._DB_PREFIX_.'manufacturer_shop` s ON (m.`id_manufacturer` = s.`id_manufacturer`) + WHERE LOWER(m.`name`) LIKE \''.pSQL($manufacturer).'\''; + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + } + + $id_manufacturer = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + + return ($id_manufacturer > 0); + } + + /** + * Check if $short_link is a Supplier Link + * + * @param string $short_link: requested url without '?' part and without '/' on begining + * @return bool true: it's a link to supplier, false: it isn't + */ + private static function isSupplierLink($short_link, $route) + { + $short_link = preg_replace('#\.html?$#', '', '/'.$short_link); + $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); + + preg_match($regexp, $short_link, $kw); + if (empty($kw['supplier_rewrite'])) { + if (0 === strpos('/'.$route['rule'], $short_link)) { + //no link_rewrite, but uri starts with the link -> suppliers' list + return true; + } + return false; + } + + $supplier = str_replace('-', '_', $kw['supplier_rewrite']); + + $sql = 'SELECT sp.`id_supplier` + FROM `'._DB_PREFIX_.'supplier` sp + LEFT JOIN `'._DB_PREFIX_.'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`) + WHERE LOWER(sp.`name`) LIKE \''.pSQL($supplier).'\''; + if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { + $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + } + + $id_supplier = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + + return ($id_supplier > 0); + } } diff --git a/zzcleanurls.php b/zzcleanurls.php index 4dfd23f..a6c086a 100644 --- a/zzcleanurls.php +++ b/zzcleanurls.php @@ -18,11 +18,8 @@ return; } -// Set true to enable debugging -define('ZZ_DEBUG', false); - -if (defined('ZZ_DEBUG') && ZZ_DEBUG && is_readable(__DIR__.'/vendor/autoload.php')) { - require __DIR__.'/vendor/autoload.php'; +if (is_readable(__DIR__.'/vendor/autoload.php')) { + require_once __DIR__.'/vendor/autoload.php'; Symfony\Component\Debug\Debug::enable(); } @@ -32,7 +29,7 @@ public function __construct() { $this->name = 'zzcleanurls'; $this->tab = 'seo'; - $this->version = '1.0.4'; + $this->version = '1.0.5'; $this->author = 'ZiZuu Store'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.5', 'max' => _PS_VERSION_); @@ -84,8 +81,7 @@ public function getContent() public function install() { // add link_rewrite as index to improve search - $tables = array('category_lang','cms_category_lang','cms_lang','product_lang'); - foreach ($tables as $tab) { + foreach (array('category_lang', 'cms_category_lang', 'cms_lang', 'product_lang') as $tab) { if (!Db::getInstance()->ExecuteS('SHOW INDEX FROM `'._DB_PREFIX_.$tab.'` WHERE Key_name = \'link_rewrite\'')) { Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_.$tab.'` ADD INDEX ( `link_rewrite` )'); } From 04d96f5154c35dda20b23809b84dfab1a42ef607 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 15 Feb 2016 14:58:01 +0100 Subject: [PATCH 155/174] use self:: instead of class name --- override/classes/Dispatcher.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php index d7b8278..f0f5b8b 100644 --- a/override/classes/Dispatcher.php +++ b/override/classes/Dispatcher.php @@ -267,17 +267,17 @@ public function getController($id_shop = null) $short_link = ltrim(parse_url($uri, PHP_URL_PATH), '/'); $route = $this->routes[$id_shop][$curr_lang_id]['product_rule']; - if (!Dispatcher::isProductLink($short_link, $route)) { + if (!self::isProductLink($short_link, $route)) { $route = $this->routes[$id_shop][$curr_lang_id]['category_rule']; - if (!Dispatcher::isCategoryLink($short_link, $route)) { + if (!self::isCategoryLink($short_link, $route)) { $route = $this->routes[$id_shop][$curr_lang_id]['cms_rule']; - if (!Dispatcher::isCmsLink($short_link, $route)) { + if (!self::isCmsLink($short_link, $route)) { $route = $this->routes[$id_shop][$curr_lang_id]['cms_category_rule']; - if (!Dispatcher::isCmsCategoryLink($short_link, $route)) { + if (!self::isCmsCategoryLink($short_link, $route)) { $route = $this->routes[$id_shop][$curr_lang_id]['manufacturer_rule']; - if (!Dispatcher::isManufacturerLink($short_link, $route)) { + if (!self::isManufacturerLink($short_link, $route)) { $route = $this->routes[$id_shop][$curr_lang_id]['supplier_rule']; - if (!Dispatcher::isSupplierLink($short_link, $route)) { + if (!self::isSupplierLink($short_link, $route)) { // no route found $route = array(); $controller = $this->controller_not_found; From 64b420aedd895bcd4a36199ddbfaf6c2f286dc16 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Thu, 28 Apr 2016 12:47:36 +0200 Subject: [PATCH 156/174] Made a better install paragraph As per https://github.com/ZiZuu-store/zzCleanURLs/issues/51#issuecomment-214331878 . Thanks @dmitrymurashenkov --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f3214da..dd29519 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ We are going to merge other users' contributions and ideas as soon as we note th If you fork, please make every change the way we can pull, don't reinvent the wheel .. make every custom change on a private branch, so you can merge your own changes to the community mintained branch every time a new release is out. -* For production use the **latest stable [release](https://github.com/ZiZuu-store/zzCleanURLs/releases/)** +* For production use the **latest stable [release](https://github.com/ZiZuu-store/zzCleanURLs/releases/latest)** * For developing or Pull Request please use only the "**[dev](https://github.com/ZiZuu-store/zzCleanURLs/tree/dev)**" branch It has been reported to work on **PS 1.5.6 - 1.6.1.x** but will install on PS >= 1.5 too. @@ -28,9 +28,13 @@ It has been reported to work on **PS 1.5.6 - 1.6.1.x** but will install on PS >= # INSTALLATION -Install the module from the Backoffice (administration panel), download the release ZIP file (***zzcleanurls.zip***) as it already contains the right folder name (`zzcleanurls`, **not** `zzcleanurls-version_x.y.z` !) - -In the modules tab, click on **add a new module**. Click on Browse to open the dialogue box letting you search your computer, select the ZIP file then validate the dialogue box. Finally click on Upload this module. +Install the module from the Backoffice (administration panel): +- download the lastest [release](https://github.com/ZiZuu-store/zzCleanURLs/releases/latest) ***ZIP*** file (***`zzcleanurls.zip`***) as it already contains the right folder name (`zzcleanurls`, **not** `zzcleanurls-version_x.y.z` !) +- in the modules tab, click on **add a new module** +- click on "`Browse`" to open the dialogue box letting you search your computer +- select the ZIP file you downloaded and validate the dialogue box +- click on "`Upload this module`" +- once uploaded you could have to search the module among the others (tip: filter by author "`zizuu store`") and click on the `install` button ## Make sure your SEO and URL settings are as follows: From 781e4889a377ff8d065febdd8fb1988ff48a8152 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 6 Jun 2016 16:24:07 +0200 Subject: [PATCH 157/174] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f302feb..95f6afd 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "preferred-install": "dist" }, "require-dev": { - "fabpot/php-cs-fixer": "^1.11", + "friendsofphp/php-cs-fixer": "^1.11", "symfony/var-dumper": "^3.0", "symfony/debug": "^3.0" }, From 0c91c3aae5ed3f9638445c3f8b674e1c577028df Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 21 Oct 2016 14:33:52 +0200 Subject: [PATCH 158/174] Migrate the module to the new Faktiva maintainer --- .gitignore | 6 +- .php_cs | 31 +++- .sensiolabs.yml | 3 + README.md | 43 ++--- composer.json | 64 ++++--- composer.lock | 172 ++++++++++-------- config.xml => faktiva_clean_urls/config.xml | 10 +- .../faktiva_clean_urls.php | 35 ++-- faktiva_clean_urls/index.php | 29 +++ logo.gif => faktiva_clean_urls/logo.gif | Bin logo.png => faktiva_clean_urls/logo.png | Bin .../override}/classes/Dispatcher.php | 20 +- .../override}/classes/Link.php | 18 ++ .../classes/controller/FrontController.php | 18 ++ .../override/classes/controller/index.php | 29 +++ faktiva_clean_urls/override/classes/index.php | 29 +++ .../controllers/front/CategoryController.php | 18 ++ .../controllers/front/CmsController.php | 20 +- .../front/ManufacturerController.php | 18 ++ .../controllers/front/ProductController.php | 18 ++ .../controllers/front/SupplierController.php | 18 ++ .../override/controllers/front/index.php | 29 +++ .../override/controllers/index.php | 29 +++ faktiva_clean_urls/override/index.php | 29 +++ faktiva_clean_urls/tools/debug.php | 24 +++ .../translations}/it.php | 18 ++ faktiva_clean_urls/upgrade/index.php | 29 +++ faktiva_clean_urls/upgrade/install-1.1.0.php | 41 +++++ index.php | 25 --- override/classes/controller/index.php | 25 --- override/classes/index.php | 25 --- override/controllers/front/index.php | 25 --- override/controllers/index.php | 25 --- override/index.php | 25 --- 34 files changed, 642 insertions(+), 306 deletions(-) rename config.xml => faktiva_clean_urls/config.xml (61%) rename zzcleanurls.php => faktiva_clean_urls/faktiva_clean_urls.php (78%) create mode 100644 faktiva_clean_urls/index.php rename logo.gif => faktiva_clean_urls/logo.gif (100%) rename logo.png => faktiva_clean_urls/logo.png (100%) rename {override => faktiva_clean_urls/override}/classes/Dispatcher.php (97%) rename {override => faktiva_clean_urls/override}/classes/Link.php (90%) rename {override => faktiva_clean_urls/override}/classes/controller/FrontController.php (54%) create mode 100644 faktiva_clean_urls/override/classes/controller/index.php create mode 100644 faktiva_clean_urls/override/classes/index.php rename {override => faktiva_clean_urls/override}/controllers/front/CategoryController.php (59%) rename {override => faktiva_clean_urls/override}/controllers/front/CmsController.php (70%) rename {override => faktiva_clean_urls/override}/controllers/front/ManufacturerController.php (62%) rename {override => faktiva_clean_urls/override}/controllers/front/ProductController.php (74%) rename {override => faktiva_clean_urls/override}/controllers/front/SupplierController.php (60%) create mode 100644 faktiva_clean_urls/override/controllers/front/index.php create mode 100644 faktiva_clean_urls/override/controllers/index.php create mode 100644 faktiva_clean_urls/override/index.php create mode 100644 faktiva_clean_urls/tools/debug.php rename {translations => faktiva_clean_urls/translations}/it.php (77%) create mode 100644 faktiva_clean_urls/upgrade/index.php create mode 100644 faktiva_clean_urls/upgrade/install-1.1.0.php delete mode 100644 index.php delete mode 100644 override/classes/controller/index.php delete mode 100644 override/classes/index.php delete mode 100644 override/controllers/front/index.php delete mode 100644 override/controllers/index.php delete mode 100644 override/index.php diff --git a/.gitignore b/.gitignore index fd264bd..b79a0c0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ -.htaccess -.svn -vendor -.cache +vendor/ .php_cs.cache config_*.xml +*.zip diff --git a/.php_cs b/.php_cs index 3d8f0ca..1b35540 100644 --- a/.php_cs +++ b/.php_cs @@ -1,12 +1,37 @@ +@license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 +@source https://github.com/faktiva/prestashop-clean-urls +EOF; + +Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header); + return Symfony\CS\Config\Config::create() - ->fixers(array('-psr0')) - ->level(Symfony\CS\FixerInterface::PSR2_LEVEL) ->setUsingCache(true) + ->level(Symfony\CS\FixerInterface::PSR2_LEVEL) + ->fixers(array( + 'header_comment', + 'long_array_syntax', + 'single_quote', + 'pre_increment', + )) ->finder( Symfony\CS\Finder\DefaultFinder::create() - ->in(__DIR__) + ->in(__DIR__.'/faktiva_clean_urls') ) ; diff --git a/.sensiolabs.yml b/.sensiolabs.yml index 11eabc8..ec19085 100644 --- a/.sensiolabs.yml +++ b/.sensiolabs.yml @@ -2,6 +2,9 @@ global_exclude_dirs: - translations - upgrade +exclude_patterns: + - tools/debug.php + rules: php.absolute_path_present: enabled: true diff --git a/README.md b/README.md index dd29519..3cfa33c 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,24 @@ -[Prestashop module "ZiZuu Clean URLs"](https://github.com/ZiZuu-store/PrestaShop_module-CleanURLs) -===== +[PrestaShop module "Clean URLs"](https://github.com/faktiva/prestashop-seo-tk)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba/mini.png)](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba) [![License](https://img.shields.io/packagist/l/faktiva/prestashop-clan-urls.svg?style=flat)](https://creativecommons.org/licenses/by-sa/4.0/) +=== -[![SensioLabsInsight](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba/mini.png)](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba) -[![GitHub issues](https://img.shields.io/github/issues/ZiZuu-store/zzCleanURLs.svg?style=plastic)](https://github.com/ZiZuu-store/zzCleanURLs/issues) +[![GitHub release](https://img.shields.io/github/release/faktiva/prestashop-clean-urls.svg?style=plastic&label=latest)](https://github.com/faktiva/prestashop-clean-urls/releases/latest) +[![Project Status](http://opensource.box.com/badges/active.svg)](http://opensource.box.com/badges) +[![Percentage of issues still open](http://isitmaintained.com/badge/open/faktiva/prestashop-clean-urls.svg)](http://isitmaintained.com/project/faktiva/prestashop-clean-urls "Percentage of issues still open") +[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/faktiva/prestashop-clean-urls.svg)](http://isitmaintained.com/project/faktiva/prestashop-clean-urls "Average time to resolve an issue") +[![composer.lock](https://poser.pugx.org/faktiva/prestashop-clean-urls/composerlock)](https://packagist.org/packages/faktiva/prestashop-clean-urls) +[![Dependencies Status](https://img.shields.io/librariesio/github/faktiva/prestashop-clean-urls.svg?maxAge=3600)](https://libraries.io/github/faktiva/prestashop-clean-urls) -[![Packagist](https://img.shields.io/packagist/l/zizuu-store/zzcleanurls.svg?style=plastic)](https://creativecommons.org/licenses/by-nc-sa/4.0/) -[![GitHub release](https://img.shields.io/github/release/ZiZuu-store/zzCleanURLs.svg?style=plastic&label=latest)](https://github.com/ZiZuu-store/zzCleanURLs/releases/latest) - -[![Packagist](https://img.shields.io/packagist/dt/zizuu-store/zzcleanurls.svg?style=plastic)](https://packagist.org/packages/zizuu-store/zzcleanurls) -[![GitHub stars](https://img.shields.io/github/stars/ZiZuu-store/zzCleanURLs.svg?style=social)](https://github.com/ZiZuu-store/zzCleanURLs/stargazers) -[![GitHub forks](https://img.shields.io/github/forks/ZiZuu-store/zzCleanURLs.svg?style=social&label=Forks)](https://github.com/ZiZuu-store/zzCleanURLs/network) - -[![Join the chat at https://gitter.im/ZiZuu-store/zzCleanURLs](https://img.shields.io/badge/Gitter-CHAT%20NOW-brightgreen.svg?style=plastic)](https://gitter.im/ZiZuu-store/zzCleanURLs) -[![Twitter](https://img.shields.io/twitter/url/https/github.com/ZiZuu-store/zzCleanURLs.svg?style=social)](https://twitter.com/intent/tweet?text=Fantastic @PrestaShop module by @ZiZuu_Store: "ZiZuu Clean URLs"&url=https://github.com/ZiZuu-store/zzCleanURLs) +[![Join the chat at https://gitter.im/faktiva/prestashop-clean-urls](https://img.shields.io/badge/Gitter-CHAT%20NOW-brightgreen.svg?style=plastic)](https://gitter.im/faktiva/prestashop-clean-urls) +[![Twitter](https://img.shields.io/twitter/url/https/github.com/faktiva/prestashop-clean-urls.svg?style=social)](https://twitter.com/intent/tweet?text=Fantastic @PrestaShop module "#Faktiva Clean URLs"&url=https://github.com/faktiva/prestashop-clean-urls) ___ -We are going to merge other users' contributions and ideas as soon as we note them and find the time to test. +Makes possible to have URLs with no IDs in PrestaShop. -If you fork, please make every change the way we can pull, don't reinvent the wheel .. make every custom change on a private branch, so you can merge your own changes to the community mintained branch every time a new release is out. +If you fork, please make every change the way we can pull, don't reinvent the wheel .. make every custom change on a private branch, so you can merge your own changes to the community mantained branch every time a new release is out. -* For production use the **latest stable [release](https://github.com/ZiZuu-store/zzCleanURLs/releases/latest)** -* For developing or Pull Request please use only the "**[dev](https://github.com/ZiZuu-store/zzCleanURLs/tree/dev)**" branch +* For production use the **latest stable [release](https://github.com/faktiva/prestashop-clean-urls/releases/latest)** +* For developing or Pull Request please use only the "**[dev](https://github.com/faktiva/prestashop-clean-urls/tree/dev)**" branch It has been reported to work on **PS 1.5.6 - 1.6.1.x** but will install on PS >= 1.5 too. **If you succesfully use this module on some older version please report** @@ -29,12 +26,12 @@ It has been reported to work on **PS 1.5.6 - 1.6.1.x** but will install on PS >= # INSTALLATION Install the module from the Backoffice (administration panel): -- download the lastest [release](https://github.com/ZiZuu-store/zzCleanURLs/releases/latest) ***ZIP*** file (***`zzcleanurls.zip`***) as it already contains the right folder name (`zzcleanurls`, **not** `zzcleanurls-version_x.y.z` !) +- download the lastest [release](https://github.com/faktiva/prestashop-clean-urls/releases/latest) ***ZIP*** file (***`faktiva_clean_urls.zip`***) as it already contains the right folder name (`faktiva_clean_urls`, **not** `faktiva-prestashop-clean-urls-version_x.y.z` !) - in the modules tab, click on **add a new module** - click on "`Browse`" to open the dialogue box letting you search your computer - select the ZIP file you downloaded and validate the dialogue box - click on "`Upload this module`" -- once uploaded you could have to search the module among the others (tip: filter by author "`zizuu store`") and click on the `install` button +- once uploaded you could have to search the module among the others (tip: filter by author "`faktiva`") and click on the `install` button ## Make sure your SEO and URL settings are as follows: @@ -55,7 +52,7 @@ Remember to # UNINSTALLATION -* Go to modules -> Find and uninstall "**zzcleanurls**" +* Go to modules -> Find and uninstall "**faktiva_clean_urls**" **It should suffice!** @@ -80,9 +77,9 @@ If you got any other override modules, you should now go to you back office, uni # License -![Creative Commons BY-NC-SA License](https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png) +![Creative Commons BY-SA License](https://i.creativecommons.org/l/by-sa/4.0/88x31.png) -**[ZiZuu CleanURLs](https://github.com/ZiZuu-store/zzCleanURLs)** by [ZiZuu Store](https://github.com/ZiZuu-store) is licensed under a **Creative Commons [Attribution-NonCommercial-ShareAlike](http://creativecommons.org/licenses/by-nc-sa/4.0/) 4.0 International License**. +**[PrestaShop Clean URLs](https://github.com/faktiva/prestashop-clean-urls)** by [Faktiva](https://github.com/faktiva) is licensed under a **Creative Commons [Attribution-ShareAlike](http://creativecommons.org/licenses/by-sa/4.0/) 4.0 International License**. -Permissions beyond the scope of this license may be available contacting us at info@ZiZuu.com. +Permissions beyond the scope of this license may be available contacting us at info@faktiva.com. diff --git a/composer.json b/composer.json index 95f6afd..f368674 100644 --- a/composer.json +++ b/composer.json @@ -1,29 +1,41 @@ { - "name": "zizuu-store/zzcleanurls", - "description": "Prestashop module \"ZiZuu Clean URLs\". It removes objects' IDs from URL", - "homepage": "https://github.com/ZiZuu-store/zzCleanURLs", - "license": "CC-BY-NC-SA-4.0", - "type": "prestashop-module", - "authors": [ - { - "name": "ZiZuu Store", - "email": "info@ZiZuu.com" + "name": "faktiva/prestashop-clean-urls", + "description": "Prestashop\"Clean URLs\" module. It removes objects' IDs from URLs.", + "homepage": "https://github.com/faktiva/prestashop-clean-urls", + "license": "CC-BY-SA-4.0", + "type": "prestashop-module", + "authors": [ + { + "name": "AlberT", + "email": "albert@faktiva.com" + } + ], + + "minimum-stability": "stable", + "config": { + "github-protocols": ["https"], + "archive-format": "zip", + "preferred-install": "dist", + "optimize-autoloader": true + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~1.10", + "symfony/var-dumper": "~2.0|~3.0", + "symfony/debug": "~2.0|~3.0" + }, + "require": { + "php": ">=5.2" + }, + "scripts": { + "csfix": [ + "php-cs-fixer -vvv fix ; echo" + ], + "zip": [ + "@composer archive -vvv -f zip", + "php -r 'rename(@array_shift(glob(\"faktiva-prestashop-clean-urls-*.zip\")), \"faktiva_clean_urls.zip\");'" + ] + }, + "archive": { + "exclude": [".*", "/composer.*", "/vendor", "*.zip", "*.tar", "*.md", "/*.jpg" ] } - ], - "config": { - "preferred-install": "dist" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^1.11", - "symfony/var-dumper": "^3.0", - "symfony/debug": "^3.0" - }, - "require": { - "php": ">=5.3.2" - }, - "scripts": { - "csfix": [ - "php-cs-fixer -vvv fix" - ] - } } diff --git a/composer.lock b/composer.lock index 88c8659..5414967 100644 --- a/composer.lock +++ b/composer.lock @@ -4,37 +4,41 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "f8b52cd5284c103c5500a4f7970f8dd6", - "content-hash": "e75d0f065075e80ae00b227c4de640ae", + "hash": "8053fc7b2d3714db78dd2fc5593d0ec5", + "content-hash": "c74e65f1e131110b8380960ae40532f3", "packages": [], "packages-dev": [ { - "name": "fabpot/php-cs-fixer", - "version": "v1.11.1", + "name": "friendsofphp/php-cs-fixer", + "version": "v1.12.2", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "2c9f8298181f059c5077abda78019b9a0c9a7cc0" + "reference": "baa7112bef3b86c65fcfaae9a7a50436e3902b41" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/2c9f8298181f059c5077abda78019b9a0c9a7cc0", - "reference": "2c9f8298181f059c5077abda78019b9a0c9a7cc0", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/baa7112bef3b86c65fcfaae9a7a50436e3902b41", + "reference": "baa7112bef3b86c65fcfaae9a7a50436e3902b41", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.3.6", - "sebastian/diff": "~1.1", - "symfony/console": "~2.3|~3.0", - "symfony/event-dispatcher": "~2.1|~3.0", - "symfony/filesystem": "~2.1|~3.0", - "symfony/finder": "~2.1|~3.0", - "symfony/process": "~2.3|~3.0", - "symfony/stopwatch": "~2.5|~3.0" + "php": "^5.3.6 || >=7.0 <7.2", + "sebastian/diff": "^1.1", + "symfony/console": "^2.3 || ^3.0", + "symfony/event-dispatcher": "^2.1 || ^3.0", + "symfony/filesystem": "^2.1 || ^3.0", + "symfony/finder": "^2.1 || ^3.0", + "symfony/process": "^2.3 || ^3.0", + "symfony/stopwatch": "^2.5 || ^3.0" + }, + "conflict": { + "hhvm": "<3.9" }, "require-dev": { - "satooshi/php-coveralls": "0.7.*@dev" + "phpunit/phpunit": "^4.5|^5", + "satooshi/php-coveralls": "^1.0" }, "bin": [ "php-cs-fixer" @@ -60,26 +64,34 @@ } ], "description": "A tool to automatically fix PHP code style", - "time": "2016-01-20 19:00:28" + "time": "2016-09-27 07:57:59" }, { "name": "psr/log", - "version": "1.0.0", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", "shasum": "" }, + "require": { + "php": ">=5.3.0" + }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, "autoload": { - "psr-0": { - "Psr\\Log\\": "" + "psr-4": { + "Psr\\Log\\": "Psr/Log/" } }, "notification-url": "https://packagist.org/downloads/", @@ -93,12 +105,13 @@ } ], "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", "keywords": [ "log", "psr", "psr-3" ], - "time": "2012-12-21 11:40:51" + "time": "2016-10-10 12:19:37" }, { "name": "sebastian/diff", @@ -154,20 +167,21 @@ }, { "name": "symfony/console", - "version": "v3.0.2", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "5a02eaadaa285e2bb727eb6bbdfb8201fcd971b0" + "reference": "6cb0872fb57b38b3b09ff213c21ed693956b9eb0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/5a02eaadaa285e2bb727eb6bbdfb8201fcd971b0", - "reference": "5a02eaadaa285e2bb727eb6bbdfb8201fcd971b0", + "url": "https://api.github.com/repos/symfony/console/zipball/6cb0872fb57b38b3b09ff213c21ed693956b9eb0", + "reference": "6cb0872fb57b38b3b09ff213c21ed693956b9eb0", "shasum": "" }, "require": { "php": ">=5.5.9", + "symfony/debug": "~2.8|~3.0", "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { @@ -183,7 +197,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -210,20 +224,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2016-02-02 13:44:19" + "time": "2016-09-28 00:11:12" }, { "name": "symfony/debug", - "version": "v3.0.2", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "29606049ced1ec715475f88d1bbe587252a3476e" + "reference": "e2b3f74a67fc928adc3c1b9027f73e1bc01190a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/29606049ced1ec715475f88d1bbe587252a3476e", - "reference": "29606049ced1ec715475f88d1bbe587252a3476e", + "url": "https://api.github.com/repos/symfony/debug/zipball/e2b3f74a67fc928adc3c1b9027f73e1bc01190a8", + "reference": "e2b3f74a67fc928adc3c1b9027f73e1bc01190a8", "shasum": "" }, "require": { @@ -240,7 +254,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -267,20 +281,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2016-01-27 05:14:46" + "time": "2016-09-06 11:02:40" }, { "name": "symfony/event-dispatcher", - "version": "v3.0.2", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "4dd5df31a28c0f82b41cb1e1599b74b5dcdbdafa" + "reference": "c0c00c80b3a69132c4e55c3e7db32b4a387615e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/4dd5df31a28c0f82b41cb1e1599b74b5dcdbdafa", - "reference": "4dd5df31a28c0f82b41cb1e1599b74b5dcdbdafa", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/c0c00c80b3a69132c4e55c3e7db32b4a387615e5", + "reference": "c0c00c80b3a69132c4e55c3e7db32b4a387615e5", "shasum": "" }, "require": { @@ -300,7 +314,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -327,20 +341,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2016-01-27 05:14:46" + "time": "2016-07-19 10:45:57" }, { "name": "symfony/filesystem", - "version": "v3.0.2", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "064ac12afd2ceb8a2c1bfb7bed8e931c6dd1997f" + "reference": "682fd8fdb3135fdf05fc496a01579ccf6c85c0e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/064ac12afd2ceb8a2c1bfb7bed8e931c6dd1997f", - "reference": "064ac12afd2ceb8a2c1bfb7bed8e931c6dd1997f", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/682fd8fdb3135fdf05fc496a01579ccf6c85c0e5", + "reference": "682fd8fdb3135fdf05fc496a01579ccf6c85c0e5", "shasum": "" }, "require": { @@ -349,7 +363,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -376,20 +390,20 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2016-01-27 11:34:55" + "time": "2016-09-14 00:18:46" }, { "name": "symfony/finder", - "version": "v3.0.2", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "623bda0abd9aa29e529c8e9c08b3b84171914723" + "reference": "205b5ffbb518a98ba2ae60a52656c4a31ab00c6f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/623bda0abd9aa29e529c8e9c08b3b84171914723", - "reference": "623bda0abd9aa29e529c8e9c08b3b84171914723", + "url": "https://api.github.com/repos/symfony/finder/zipball/205b5ffbb518a98ba2ae60a52656c4a31ab00c6f", + "reference": "205b5ffbb518a98ba2ae60a52656c4a31ab00c6f", "shasum": "" }, "require": { @@ -398,7 +412,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -425,20 +439,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2016-01-27 05:14:46" + "time": "2016-09-28 00:11:12" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.1.0", + "version": "v1.2.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "1289d16209491b584839022f29257ad859b8532d" + "reference": "dff51f72b0706335131b00a7f49606168c582594" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/1289d16209491b584839022f29257ad859b8532d", - "reference": "1289d16209491b584839022f29257ad859b8532d", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/dff51f72b0706335131b00a7f49606168c582594", + "reference": "dff51f72b0706335131b00a7f49606168c582594", "shasum": "" }, "require": { @@ -450,7 +464,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "1.2-dev" } }, "autoload": { @@ -484,20 +498,20 @@ "portable", "shim" ], - "time": "2016-01-20 09:13:37" + "time": "2016-05-18 14:26:46" }, { "name": "symfony/process", - "version": "v3.0.2", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "dfecef47506179db2501430e732adbf3793099c8" + "reference": "66de154ae86b1a07001da9fbffd620206e4faf94" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/dfecef47506179db2501430e732adbf3793099c8", - "reference": "dfecef47506179db2501430e732adbf3793099c8", + "url": "https://api.github.com/repos/symfony/process/zipball/66de154ae86b1a07001da9fbffd620206e4faf94", + "reference": "66de154ae86b1a07001da9fbffd620206e4faf94", "shasum": "" }, "require": { @@ -506,7 +520,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -533,20 +547,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2016-02-02 13:44:19" + "time": "2016-09-29 14:13:09" }, { "name": "symfony/stopwatch", - "version": "v3.0.2", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "4a204804952ff267ace88cf499e0b4bb302a475e" + "reference": "bb42806b12c5f89db4ebf64af6741afe6d8457e1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/4a204804952ff267ace88cf499e0b4bb302a475e", - "reference": "4a204804952ff267ace88cf499e0b4bb302a475e", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/bb42806b12c5f89db4ebf64af6741afe6d8457e1", + "reference": "bb42806b12c5f89db4ebf64af6741afe6d8457e1", "shasum": "" }, "require": { @@ -555,7 +569,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -582,20 +596,20 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", - "time": "2016-01-03 15:35:16" + "time": "2016-06-29 05:41:56" }, { "name": "symfony/var-dumper", - "version": "v3.0.2", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "24bb94807eff00db49374c37ebf56a0304e8aef3" + "reference": "70bfe927b86ba9999aeebd829715b0bb2cd39a10" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/24bb94807eff00db49374c37ebf56a0304e8aef3", - "reference": "24bb94807eff00db49374c37ebf56a0304e8aef3", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/70bfe927b86ba9999aeebd829715b0bb2cd39a10", + "reference": "70bfe927b86ba9999aeebd829715b0bb2cd39a10", "shasum": "" }, "require": { @@ -611,7 +625,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -645,7 +659,7 @@ "debug", "dump" ], - "time": "2016-01-07 13:38:51" + "time": "2016-09-29 14:13:09" } ], "aliases": [], @@ -654,7 +668,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.3.2" + "php": ">=5.2" }, "platform-dev": [] } diff --git a/config.xml b/faktiva_clean_urls/config.xml similarity index 61% rename from config.xml rename to faktiva_clean_urls/config.xml index eb396da..e1f8459 100644 --- a/config.xml +++ b/faktiva_clean_urls/config.xml @@ -1,12 +1,12 @@ - zzcleanurls - - + faktiva_clean_urls + + - + - + 1 0 diff --git a/zzcleanurls.php b/faktiva_clean_urls/faktiva_clean_urls.php similarity index 78% rename from zzcleanurls.php rename to faktiva_clean_urls/faktiva_clean_urls.php index a6c086a..30daf5c 100644 --- a/zzcleanurls.php +++ b/faktiva_clean_urls/faktiva_clean_urls.php @@ -1,46 +1,53 @@ - * @source https://github.com/ZiZuu-store/zzCleanURLs + * @author AlberT + * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 + * @source https://github.com/faktiva/prestashop-clean-urls */ if (!defined('_PS_VERSION_')) { return; } -if (is_readable(__DIR__.'/vendor/autoload.php')) { - require_once __DIR__.'/vendor/autoload.php'; - Symfony\Component\Debug\Debug::enable(); +// Set true to enable debugging +define('FKV_DEBUG', false); + +if (version_compare(phpversion(), '5.3.0', '>=')) { // Namespaces support is required + include_once __DIR__.'/tools/debug.php'; } -class zzCleanUrls extends Module + +class faktiva_clean_urls extends Module { public function __construct() { - $this->name = 'zzcleanurls'; + $this->name = 'faktiva_clean_urls'; $this->tab = 'seo'; - $this->version = '1.0.5'; - $this->author = 'ZiZuu Store'; + $this->version = '1.1.0'; + $this->author = 'Faktiva'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.5', 'max' => _PS_VERSION_); $this->bootstrap = true; parent::__construct(); - $this->displayName = $this->l('ZiZuu Clean URLs'); + $this->displayName = $this->l('Faktiva Clean URLs'); $this->description = $this->l('This override-Module allows you to remove URL ID\'s.'); - $this->confirmUninstall = $this->l('Are you sure you want to uninstall "ZiZuu Clean URLs"?'); + $this->confirmUninstall = $this->l('Are you sure you want to uninstall "Faktiva Clean URLs" module?'); } public function getContent() diff --git a/faktiva_clean_urls/index.php b/faktiva_clean_urls/index.php new file mode 100644 index 0000000..fe444e7 --- /dev/null +++ b/faktiva_clean_urls/index.php @@ -0,0 +1,29 @@ + + * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 + * @source https://github.com/faktiva/prestashop-clean-urls + */ + +header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +return; diff --git a/logo.gif b/faktiva_clean_urls/logo.gif similarity index 100% rename from logo.gif rename to faktiva_clean_urls/logo.gif diff --git a/logo.png b/faktiva_clean_urls/logo.png similarity index 100% rename from logo.png rename to faktiva_clean_urls/logo.png diff --git a/override/classes/Dispatcher.php b/faktiva_clean_urls/override/classes/Dispatcher.php similarity index 97% rename from override/classes/Dispatcher.php rename to faktiva_clean_urls/override/classes/Dispatcher.php index f0f5b8b..bd12362 100644 --- a/override/classes/Dispatcher.php +++ b/faktiva_clean_urls/override/classes/Dispatcher.php @@ -1,5 +1,23 @@ + * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 + * @source https://github.com/faktiva/prestashop-clean-urls + */ + class Dispatcher extends DispatcherCore { /** @@ -129,7 +147,7 @@ public function addRoute($route_id, $rule, $controller, $id_lang = null, array $ if ($keywords) { $transform_keywords = array(); preg_match_all('#\\\{(([^{}]*)\\\:)?('.implode('|', array_keys($keywords)).')(\\\:([^{}]*))?\\\}#', $regexp, $m); - for ($i = 0, $total = count($m[0]); $i < $total; $i++) { + for ($i = 0, $total = count($m[0]); $i < $total; ++$i) { $prepend = $m[2][$i]; $keyword = $m[3][$i]; $append = $m[5][$i]; diff --git a/override/classes/Link.php b/faktiva_clean_urls/override/classes/Link.php similarity index 90% rename from override/classes/Link.php rename to faktiva_clean_urls/override/classes/Link.php index 57bccf5..f4a61f3 100644 --- a/override/classes/Link.php +++ b/faktiva_clean_urls/override/classes/Link.php @@ -1,5 +1,23 @@ + * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 + * @source https://github.com/faktiva/prestashop-clean-urls + */ + class Link extends LinkCore { /** diff --git a/override/classes/controller/FrontController.php b/faktiva_clean_urls/override/classes/controller/FrontController.php similarity index 54% rename from override/classes/controller/FrontController.php rename to faktiva_clean_urls/override/classes/controller/FrontController.php index fd89db2..921f8c4 100644 --- a/override/classes/controller/FrontController.php +++ b/faktiva_clean_urls/override/classes/controller/FrontController.php @@ -1,5 +1,23 @@ + * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 + * @source https://github.com/faktiva/prestashop-clean-urls + */ + class FrontController extends FrontControllerCore { /** diff --git a/faktiva_clean_urls/override/classes/controller/index.php b/faktiva_clean_urls/override/classes/controller/index.php new file mode 100644 index 0000000..fe444e7 --- /dev/null +++ b/faktiva_clean_urls/override/classes/controller/index.php @@ -0,0 +1,29 @@ + + * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 + * @source https://github.com/faktiva/prestashop-clean-urls + */ + +header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +return; diff --git a/faktiva_clean_urls/override/classes/index.php b/faktiva_clean_urls/override/classes/index.php new file mode 100644 index 0000000..fe444e7 --- /dev/null +++ b/faktiva_clean_urls/override/classes/index.php @@ -0,0 +1,29 @@ + + * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 + * @source https://github.com/faktiva/prestashop-clean-urls + */ + +header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +return; diff --git a/override/controllers/front/CategoryController.php b/faktiva_clean_urls/override/controllers/front/CategoryController.php similarity index 59% rename from override/controllers/front/CategoryController.php rename to faktiva_clean_urls/override/controllers/front/CategoryController.php index d13f0a7..7c2aed6 100644 --- a/override/controllers/front/CategoryController.php +++ b/faktiva_clean_urls/override/controllers/front/CategoryController.php @@ -1,5 +1,23 @@ + * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 + * @source https://github.com/faktiva/prestashop-clean-urls + */ + class CategoryController extends CategoryControllerCore { public function init() diff --git a/override/controllers/front/CmsController.php b/faktiva_clean_urls/override/controllers/front/CmsController.php similarity index 70% rename from override/controllers/front/CmsController.php rename to faktiva_clean_urls/override/controllers/front/CmsController.php index b6783ce..d0e8f0b 100644 --- a/override/controllers/front/CmsController.php +++ b/faktiva_clean_urls/override/controllers/front/CmsController.php @@ -1,10 +1,28 @@ + * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 + * @source https://github.com/faktiva/prestashop-clean-urls + */ + class CmsController extends CmsControllerCore { public function init() { - $shop_sql = ""; + $shop_sql = ''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $shop_sql = ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); } diff --git a/override/controllers/front/ManufacturerController.php b/faktiva_clean_urls/override/controllers/front/ManufacturerController.php similarity index 62% rename from override/controllers/front/ManufacturerController.php rename to faktiva_clean_urls/override/controllers/front/ManufacturerController.php index 7a5c2af..fd0115b 100644 --- a/override/controllers/front/ManufacturerController.php +++ b/faktiva_clean_urls/override/controllers/front/ManufacturerController.php @@ -1,5 +1,23 @@ + * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 + * @source https://github.com/faktiva/prestashop-clean-urls + */ + class ManufacturerController extends ManufacturerControllerCore { public function init() diff --git a/override/controllers/front/ProductController.php b/faktiva_clean_urls/override/controllers/front/ProductController.php similarity index 74% rename from override/controllers/front/ProductController.php rename to faktiva_clean_urls/override/controllers/front/ProductController.php index 2cc077c..c8e138f 100644 --- a/override/controllers/front/ProductController.php +++ b/faktiva_clean_urls/override/controllers/front/ProductController.php @@ -1,5 +1,23 @@ + * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 + * @source https://github.com/faktiva/prestashop-clean-urls + */ + class ProductController extends ProductControllerCore { public function init() diff --git a/override/controllers/front/SupplierController.php b/faktiva_clean_urls/override/controllers/front/SupplierController.php similarity index 60% rename from override/controllers/front/SupplierController.php rename to faktiva_clean_urls/override/controllers/front/SupplierController.php index 1ab86bf..440a9d9 100644 --- a/override/controllers/front/SupplierController.php +++ b/faktiva_clean_urls/override/controllers/front/SupplierController.php @@ -1,5 +1,23 @@ + * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 + * @source https://github.com/faktiva/prestashop-clean-urls + */ + class SupplierController extends SupplierControllerCore { public function init() diff --git a/faktiva_clean_urls/override/controllers/front/index.php b/faktiva_clean_urls/override/controllers/front/index.php new file mode 100644 index 0000000..fe444e7 --- /dev/null +++ b/faktiva_clean_urls/override/controllers/front/index.php @@ -0,0 +1,29 @@ + + * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 + * @source https://github.com/faktiva/prestashop-clean-urls + */ + +header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +return; diff --git a/faktiva_clean_urls/override/controllers/index.php b/faktiva_clean_urls/override/controllers/index.php new file mode 100644 index 0000000..fe444e7 --- /dev/null +++ b/faktiva_clean_urls/override/controllers/index.php @@ -0,0 +1,29 @@ + + * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 + * @source https://github.com/faktiva/prestashop-clean-urls + */ + +header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +return; diff --git a/faktiva_clean_urls/override/index.php b/faktiva_clean_urls/override/index.php new file mode 100644 index 0000000..fe444e7 --- /dev/null +++ b/faktiva_clean_urls/override/index.php @@ -0,0 +1,29 @@ + + * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 + * @source https://github.com/faktiva/prestashop-clean-urls + */ + +header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +return; diff --git a/faktiva_clean_urls/tools/debug.php b/faktiva_clean_urls/tools/debug.php new file mode 100644 index 0000000..a51e635 --- /dev/null +++ b/faktiva_clean_urls/tools/debug.php @@ -0,0 +1,24 @@ + + * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 + * @source https://github.com/faktiva/prestashop-clean-urls + */ + +if (defined('FKV_DEBUG') && FKV_DEBUG && is_readable(__DIR__.'/vendor/autoload.php')) { + require_once __DIR__.'/vendor/autoload.php'; + Symfony\Component\Debug\Debug::enable(); +} diff --git a/translations/it.php b/faktiva_clean_urls/translations/it.php similarity index 77% rename from translations/it.php rename to faktiva_clean_urls/translations/it.php index d1c471d..4947209 100644 --- a/translations/it.php +++ b/faktiva_clean_urls/translations/it.php @@ -1,5 +1,23 @@ + * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 + * @source https://github.com/faktiva/prestashop-clean-urls + */ + global $_MODULE; $_MODULE = array(); $_MODULE['<{zzcleanurls}prestashop>zzcleanurls_66711d755755f94e8f48d9cb858290c8'] = 'ZiZuu Clean URLs'; diff --git a/faktiva_clean_urls/upgrade/index.php b/faktiva_clean_urls/upgrade/index.php new file mode 100644 index 0000000..fe444e7 --- /dev/null +++ b/faktiva_clean_urls/upgrade/index.php @@ -0,0 +1,29 @@ + + * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 + * @source https://github.com/faktiva/prestashop-clean-urls + */ + +header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +return; diff --git a/faktiva_clean_urls/upgrade/install-1.1.0.php b/faktiva_clean_urls/upgrade/install-1.1.0.php new file mode 100644 index 0000000..2705be7 --- /dev/null +++ b/faktiva_clean_urls/upgrade/install-1.1.0.php @@ -0,0 +1,41 @@ + + * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 + * @source https://github.com/faktiva/prestashop-clean-urls + */ + +if (!defined('_PS_VERSION_')) { + return; +} + +function upgrade_module_1_1_0($module) +{ + $old_module = 'zzcleanurls'; + + if (Module::isInstalled($old_module)) { + Module::disableByName($this->name); + + die(Tools::displayError('You must first un-install module "ZiZuu Clean URLs"')); + } + + Db::getInstance()->delete('module', "`name` = '$old_module'", 1); + Db::getInstance()->delete('module_preference', "`module` = '$old_module'"); + Db::getInstance()->delete('configuration', "`name` LIKE '$old_module%'"); + Db::getInstance()->delete('quick_access', "`link` LIKE '%module_name=$old_module%'"); + + return true; +} diff --git a/index.php b/index.php deleted file mode 100644 index ddc0813..0000000 --- a/index.php +++ /dev/null @@ -1,25 +0,0 @@ - - * @source https://github.com/ZiZuu-store/zzCleanURLs - */ - -header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -return; diff --git a/override/classes/controller/index.php b/override/classes/controller/index.php deleted file mode 100644 index ddc0813..0000000 --- a/override/classes/controller/index.php +++ /dev/null @@ -1,25 +0,0 @@ - - * @source https://github.com/ZiZuu-store/zzCleanURLs - */ - -header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -return; diff --git a/override/classes/index.php b/override/classes/index.php deleted file mode 100644 index ddc0813..0000000 --- a/override/classes/index.php +++ /dev/null @@ -1,25 +0,0 @@ - - * @source https://github.com/ZiZuu-store/zzCleanURLs - */ - -header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -return; diff --git a/override/controllers/front/index.php b/override/controllers/front/index.php deleted file mode 100644 index ddc0813..0000000 --- a/override/controllers/front/index.php +++ /dev/null @@ -1,25 +0,0 @@ - - * @source https://github.com/ZiZuu-store/zzCleanURLs - */ - -header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -return; diff --git a/override/controllers/index.php b/override/controllers/index.php deleted file mode 100644 index ddc0813..0000000 --- a/override/controllers/index.php +++ /dev/null @@ -1,25 +0,0 @@ - - * @source https://github.com/ZiZuu-store/zzCleanURLs - */ - -header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -return; diff --git a/override/index.php b/override/index.php deleted file mode 100644 index ddc0813..0000000 --- a/override/index.php +++ /dev/null @@ -1,25 +0,0 @@ - - * @source https://github.com/ZiZuu-store/zzCleanURLs - */ - -header('Expires: Fri, 31 Dec 1999 23:59:59 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -return; From 13af27934d0bbaa4a8ddec440b50606a385d5c08 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 21 Oct 2016 14:43:42 +0200 Subject: [PATCH 159/174] Update composer.json --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index f368674..af90e2e 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,9 @@ "require": { "php": ">=5.2" }, + "replace": { + "zizuu-store/zzcleanurls": "*" + } "scripts": { "csfix": [ "php-cs-fixer -vvv fix ; echo" From eb0029cb5cdd6096977a0ee4414c4e6570c3acae Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 21 Oct 2016 18:05:08 +0200 Subject: [PATCH 160/174] upadte sensio insight badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3cfa33c..4e8851f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[PrestaShop module "Clean URLs"](https://github.com/faktiva/prestashop-seo-tk)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba/mini.png)](https://insight.sensiolabs.com/projects/0f609ac9-667f-4840-82d4-464e0f7c31ba) [![License](https://img.shields.io/packagist/l/faktiva/prestashop-clan-urls.svg?style=flat)](https://creativecommons.org/licenses/by-sa/4.0/) +[PrestaShop module "Clean URLs"](https://github.com/faktiva/prestashop-seo-tk)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/58d1de4f-45fc-4f63-aeb3-7ddc51d4a64e/mini.png)](https://insight.sensiolabs.com/projects/58d1de4f-45fc-4f63-aeb3-7ddc51d4a64e) [![License](https://img.shields.io/packagist/l/faktiva/prestashop-clan-urls.svg?style=flat)](https://creativecommons.org/licenses/by-sa/4.0/) === [![GitHub release](https://img.shields.io/github/release/faktiva/prestashop-clean-urls.svg?style=plastic&label=latest)](https://github.com/faktiva/prestashop-clean-urls/releases/latest) From 97a9cf44c1b9e819d92d44b5a9c9d785a1e12d7c Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 21 Oct 2016 18:11:43 +0200 Subject: [PATCH 161/174] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index af90e2e..06a9eb7 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ }, "replace": { "zizuu-store/zzcleanurls": "*" - } + }, "scripts": { "csfix": [ "php-cs-fixer -vvv fix ; echo" From cde70f132c49499b1f8ab017297870eb3fe214fc Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Fri, 21 Oct 2016 18:12:55 +0200 Subject: [PATCH 162/174] update composer --- composer.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.lock b/composer.lock index 5414967..9f78f0a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "8053fc7b2d3714db78dd2fc5593d0ec5", - "content-hash": "c74e65f1e131110b8380960ae40532f3", + "hash": "ad30b19d943a4bbf75f445eb0f67902e", + "content-hash": "972d8f96b75663155b38e4e406d9e997", "packages": [], "packages-dev": [ { From 3cfb93fb46e7fd5cb08d8927ee4e16910aa67655 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Sun, 23 Oct 2016 01:15:13 +0200 Subject: [PATCH 163/174] fix typo in license badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4e8851f..f08c941 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[PrestaShop module "Clean URLs"](https://github.com/faktiva/prestashop-seo-tk)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/58d1de4f-45fc-4f63-aeb3-7ddc51d4a64e/mini.png)](https://insight.sensiolabs.com/projects/58d1de4f-45fc-4f63-aeb3-7ddc51d4a64e) [![License](https://img.shields.io/packagist/l/faktiva/prestashop-clan-urls.svg?style=flat)](https://creativecommons.org/licenses/by-sa/4.0/) +[PrestaShop module "Clean URLs"](https://github.com/faktiva/prestashop-seo-tk)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/58d1de4f-45fc-4f63-aeb3-7ddc51d4a64e/mini.png)](https://insight.sensiolabs.com/projects/58d1de4f-45fc-4f63-aeb3-7ddc51d4a64e) [![License](https://img.shields.io/packagist/l/faktiva/prestashop-clean-urls.svg?style=flat)](https://creativecommons.org/licenses/by-sa/4.0/) === [![GitHub release](https://img.shields.io/github/release/faktiva/prestashop-clean-urls.svg?style=plastic&label=latest)](https://github.com/faktiva/prestashop-clean-urls/releases/latest) From c7417788b51cc15d868c5f244b0a82970efdd11e Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 24 Oct 2016 11:00:09 +0200 Subject: [PATCH 164/174] Update composer dependencies Close #63 --- composer.json | 4 ++-- composer.lock | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 06a9eb7..a195cac 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "optimize-autoloader": true }, "require-dev": { - "friendsofphp/php-cs-fixer": "~1.10", + "friendsofphp/php-cs-fixer": "^1.12", "symfony/var-dumper": "~2.0|~3.0", "symfony/debug": "~2.0|~3.0" }, @@ -30,7 +30,7 @@ "zizuu-store/zzcleanurls": "*" }, "scripts": { - "csfix": [ + "fix-cs": [ "php-cs-fixer -vvv fix ; echo" ], "zip": [ diff --git a/composer.lock b/composer.lock index 9f78f0a..406dba7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "ad30b19d943a4bbf75f445eb0f67902e", - "content-hash": "972d8f96b75663155b38e4e406d9e997", + "hash": "9d224f87715c2bd53923bf264924e934", + "content-hash": "a38c1366173223af2cb1969ced550ff9", "packages": [], "packages-dev": [ { From 26258021be9b064b81d6dfe21725f30053336161 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 24 Oct 2016 11:09:30 +0200 Subject: [PATCH 165/174] Add .editorconfig [Close #61] --- .editorconfig | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ba7a233 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +; top-most EditorConfig file +root = true + +[*] +end_of_line = LF +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 4 From b9a988ef8104215c440df19f521c50e90d54ea63 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 24 Oct 2016 16:57:49 +0200 Subject: [PATCH 166/174] Fix PHP-CS-FIXER to work on version >= 1.12 --- .php_cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.php_cs b/.php_cs index 1b35540..5579f56 100644 --- a/.php_cs +++ b/.php_cs @@ -20,6 +20,9 @@ EOF; Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header); +$finder = Symfony\CS\Finder::create() + ->in(__DIR__.'/faktiva_clean_urls'); + return Symfony\CS\Config\Config::create() ->setUsingCache(true) ->level(Symfony\CS\FixerInterface::PSR2_LEVEL) @@ -29,10 +32,7 @@ return Symfony\CS\Config\Config::create() 'single_quote', 'pre_increment', )) - ->finder( - Symfony\CS\Finder\DefaultFinder::create() - ->in(__DIR__.'/faktiva_clean_urls') - ) + ->finder($finder) ; // vim:ft=php From dde918f3c7a14fd57f3225e2a9a4576b603e176b Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 24 Oct 2016 17:09:51 +0200 Subject: [PATCH 167/174] Added sensiolabs/security-checker - required sensiolabs/security-checker - created some useful composer script stanzas - updated versions - changed bin-dir to "bin" --- .gitignore | 1 + composer.json | 18 +++++++++++++++--- composer.lock | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 62 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index b79a0c0..fe98dfa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ vendor/ +bin/ .php_cs.cache config_*.xml *.zip diff --git a/composer.json b/composer.json index a195cac..a92ee85 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ "minimum-stability": "stable", "config": { + "bin-dir": "bin", "github-protocols": ["https"], "archive-format": "zip", "preferred-install": "dist", @@ -20,8 +21,9 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^1.12", - "symfony/var-dumper": "~2.0|~3.0", - "symfony/debug": "~2.0|~3.0" + "symfony/var-dumper": "^2.8||^3.0", + "symfony/debug": "^2.8||^3.0", + "sensiolabs/security-checker": "^4.0" }, "require": { "php": ">=5.2" @@ -30,8 +32,18 @@ "zizuu-store/zzcleanurls": "*" }, "scripts": { + "chk-cs": [ + "php-cs-fixer -vvv fix --dry-run" + ], + "chk-sec": [ + "php bin/security-checker -vv security:check" + ], + "check": [ + "@chk-cs", + "@chk-sec" + ], "fix-cs": [ - "php-cs-fixer -vvv fix ; echo" + "php-cs-fixer -vvv fix ; exit 0" ], "zip": [ "@composer archive -vvv -f zip", diff --git a/composer.lock b/composer.lock index 406dba7..286ac60 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "9d224f87715c2bd53923bf264924e934", - "content-hash": "a38c1366173223af2cb1969ced550ff9", + "hash": "1b802d7b0d5a0eb4106ef15c86c5d046", + "content-hash": "07bff411abf84b026b6f0fb44b00a343", "packages": [], "packages-dev": [ { @@ -165,6 +165,50 @@ ], "time": "2015-12-08 07:14:41" }, + { + "name": "sensiolabs/security-checker", + "version": "v4.0.0", + "source": { + "type": "git", + "url": "https://github.com/sensiolabs/security-checker.git", + "reference": "116027b57b568ed61b7b1c80eeb4f6ee9e8c599c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sensiolabs/security-checker/zipball/116027b57b568ed61b7b1c80eeb4f6ee9e8c599c", + "reference": "116027b57b568ed61b7b1c80eeb4f6ee9e8c599c", + "shasum": "" + }, + "require": { + "symfony/console": "~2.7|~3.0" + }, + "bin": [ + "security-checker" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "psr-0": { + "SensioLabs\\Security": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien.potencier@gmail.com" + } + ], + "description": "A security checker for your composer.lock", + "time": "2016-09-23 18:09:57" + }, { "name": "symfony/console", "version": "v3.1.5", From 11cffb0e6adddb9e4954f2e5ab2792088ad469d4 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 24 Oct 2016 17:38:54 +0200 Subject: [PATCH 168/174] Enforced better Coding Style --- .php_cs | 9 +- faktiva_clean_urls/faktiva_clean_urls.php | 25 ++- faktiva_clean_urls/index.php | 1 + .../override/classes/Dispatcher.php | 146 ++++++++++-------- faktiva_clean_urls/override/classes/Link.php | 48 +++--- .../classes/controller/FrontController.php | 2 +- .../override/classes/controller/index.php | 1 + faktiva_clean_urls/override/classes/index.php | 1 + .../controllers/front/CategoryController.php | 4 +- .../controllers/front/CmsController.php | 6 +- .../front/ManufacturerController.php | 4 +- .../controllers/front/ProductController.php | 10 +- .../controllers/front/SupplierController.php | 4 +- .../override/controllers/front/index.php | 1 + .../override/controllers/index.php | 1 + faktiva_clean_urls/override/index.php | 1 + faktiva_clean_urls/translations/it.php | 2 +- faktiva_clean_urls/upgrade/index.php | 1 + 18 files changed, 144 insertions(+), 123 deletions(-) diff --git a/.php_cs b/.php_cs index 5579f56..aabbbe7 100644 --- a/.php_cs +++ b/.php_cs @@ -25,12 +25,15 @@ $finder = Symfony\CS\Finder::create() return Symfony\CS\Config\Config::create() ->setUsingCache(true) - ->level(Symfony\CS\FixerInterface::PSR2_LEVEL) + ->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL) ->fixers(array( + 'align_double_arrow', + 'align_equals', 'header_comment', + 'empty_return', 'long_array_syntax', - 'single_quote', - 'pre_increment', + 'newline_after_open_tag', + 'short_echo_tag', )) ->finder($finder) ; diff --git a/faktiva_clean_urls/faktiva_clean_urls.php b/faktiva_clean_urls/faktiva_clean_urls.php index 30daf5c..ea628c2 100644 --- a/faktiva_clean_urls/faktiva_clean_urls.php +++ b/faktiva_clean_urls/faktiva_clean_urls.php @@ -29,18 +29,17 @@ include_once __DIR__.'/tools/debug.php'; } - class faktiva_clean_urls extends Module { public function __construct() { - $this->name = 'faktiva_clean_urls'; - $this->tab = 'seo'; - $this->version = '1.1.0'; - $this->author = 'Faktiva'; - $this->need_instance = 0; + $this->name = 'faktiva_clean_urls'; + $this->tab = 'seo'; + $this->version = '1.1.0'; + $this->author = 'Faktiva'; + $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.5', 'max' => _PS_VERSION_); - $this->bootstrap = true; + $this->bootstrap = true; parent::__construct(); @@ -53,11 +52,11 @@ public function __construct() public function getContent() { $output = '

' - . $this->l('On some versions you could have to disable Cache, save, open your shop home page, than go back and enable it:').'

' - . sprintf('%s -> %s -> %s', $this->l('Advanced Parameters'), $this->l('Performance'), $this->l('Clear Smarty cache')).'
' - . sprintf('%s -> %s -> %s -> %s', $this->l('Preferences'), $this->l('SEO and URLs'), $this->l('Set userfriendly URL off'), $this->l('Save')).'
' - . sprintf('%s -> %s -> %s -> %s', $this->l('Preferences'), $this->l('SEO and URLs'), $this->l('Set userfriendly URL on'), $this->l('Save')).'
' - . '

'; + .$this->l('On some versions you could have to disable Cache, save, open your shop home page, than go back and enable it:').'

' + .sprintf('%s -> %s -> %s', $this->l('Advanced Parameters'), $this->l('Performance'), $this->l('Clear Smarty cache')).'
' + .sprintf('%s -> %s -> %s -> %s', $this->l('Preferences'), $this->l('SEO and URLs'), $this->l('Set userfriendly URL off'), $this->l('Save')).'
' + .sprintf('%s -> %s -> %s -> %s', $this->l('Preferences'), $this->l('SEO and URLs'), $this->l('Set userfriendly URL on'), $this->l('Save')).'
' + .'

'; $sql = 'SELECT * FROM `'._DB_PREFIX_.'product_lang` WHERE `link_rewrite` @@ -65,7 +64,7 @@ public function getContent() GROUP BY `link_rewrite`, `id_lang` HAVING count(`link_rewrite`) > 1)'; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); + $sql .= ' AND `id_shop` = '.(int) Shop::getContextShopID(); } if ($res = Db::getInstance()->ExecuteS($sql)) { diff --git a/faktiva_clean_urls/index.php b/faktiva_clean_urls/index.php index fe444e7..baee4b5 100644 --- a/faktiva_clean_urls/index.php +++ b/faktiva_clean_urls/index.php @@ -26,4 +26,5 @@ header('Pragma: no-cache'); header('Location: ../'); + return; diff --git a/faktiva_clean_urls/override/classes/Dispatcher.php b/faktiva_clean_urls/override/classes/Dispatcher.php index bd12362..5ba88bd 100644 --- a/faktiva_clean_urls/override/classes/Dispatcher.php +++ b/faktiva_clean_urls/override/classes/Dispatcher.php @@ -21,11 +21,11 @@ class Dispatcher extends DispatcherCore { /** - * Load default routes group by languages + * Load default routes group by languages. */ protected function loadRoutes($id_shop = null) { - /** + /* * @var array List of default routes */ $this->default_routes = array( @@ -51,7 +51,7 @@ protected function loadRoutes($id_shop = null) ), ), 'manufacturer_rule' => array( - 'controller' => 'manufacturer', + 'controller' => 'manufacturer', 'rule' => 'manufacturer/{rewrite}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), @@ -61,8 +61,8 @@ protected function loadRoutes($id_shop = null) ), ), 'cms_rule' => array( - 'controller' => 'cms', - 'rule' => 'info/{rewrite}', + 'controller' => 'cms', + 'rule' => 'info/{rewrite}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), 'rewrite' => array('regexp' => '[_a-zA-Z0-9\pL\pS-]*', 'param' => 'cms_rewrite'), @@ -71,8 +71,8 @@ protected function loadRoutes($id_shop = null) ), ), 'cms_category_rule' => array( - 'controller' => 'cms', - 'rule' => 'info/{rewrite}/', + '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'), @@ -81,18 +81,18 @@ protected function loadRoutes($id_shop = null) ), ), 'module' => array( - 'controller' => null, - 'rule' => 'module/{module}/{controller}', + '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( + 'params' => array( 'fc' => 'module', ), ), 'product_rule' => array( - 'controller' => 'product', + 'controller' => 'product', 'rule' => '{category:/}{rewrite}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), @@ -110,7 +110,7 @@ protected function loadRoutes($id_shop = null) ), ), 'layered_rule' => array( - 'controller' => 'category', + 'controller' => 'category', 'rule' => '{rewrite}/f/{selected_filters}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), @@ -126,21 +126,20 @@ protected function loadRoutes($id_shop = null) } /** - * - * @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 $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 + * @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) { if (isset(Context::getContext()->language) && $id_lang === null) { - $id_lang = (int)Context::getContext()->language->id; + $id_lang = (int) Context::getContext()->language->id; } if (isset(Context::getContext()->shop) && $id_shop === null) { - $id_shop = (int)Context::getContext()->shop->id; + $id_shop = (int) Context::getContext()->shop->id; } $regexp = preg_quote($rule, '#'); @@ -148,19 +147,19 @@ public function addRoute($route_id, $rule, $controller, $id_lang = null, array $ $transform_keywords = array(); preg_match_all('#\\\{(([^{}]*)\\\:)?('.implode('|', array_keys($keywords)).')(\\\:([^{}]*))?\\\}#', $regexp, $m); for ($i = 0, $total = count($m[0]); $i < $total; ++$i) { - $prepend = $m[2][$i]; - $keyword = $m[3][$i]; - $append = $m[5][$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' => stripslashes($prepend), + 'append' => stripslashes($append), ); $prepend_regexp = $append_regexp = ''; if ($prepend || $append) { $prepend_regexp = '('.$prepend; - $append_regexp = $append.')??'; // fix greediness (step 1) + $append_regexp = $append.')??'; // fix greediness (step 1) } if (isset($keywords[$keyword]['param'])) { @@ -181,18 +180,19 @@ public function addRoute($route_id, $rule, $controller, $id_lang = null, array $ } $this->routes[$id_shop][$id_lang][$route_id] = array( - 'rule' => $rule, - 'regexp' => $regexp, + 'rule' => $rule, + 'regexp' => $regexp, 'controller' => $controller, - 'keywords' => $keywords, - 'params' => $params, + 'keywords' => $keywords, + 'params' => $params, ); } /** - * Retrieve the controller from url or request uri if routes are activated + * Retrieve the controller from url or request uri if routes are activated. * * @param int $id_shop, defaults null + * * @return string */ public function getController($id_shop = null) @@ -203,11 +203,12 @@ public function getController($id_shop = null) if ($this->controller) { $_GET['controller'] = $this->controller; + return $this->controller; } if (null === $id_shop) { - $id_shop = (int)Context::getContext()->shop->id; + $id_shop = (int) Context::getContext()->shop->id; } $controller = Tools::getValue('controller'); @@ -250,7 +251,7 @@ public function getController($id_shop = null) foreach ($this->routes[$id_shop][$curr_lang_id] as $k => $r) { if (preg_match($r['regexp'], $uri, $m)) { $isTemplate = false; - $module = isset($r['params']['module']) ? $r['params']['module'] : ''; + $module = isset($r['params']['module']) ? $r['params']['module'] : ''; switch ($r['controller'].$module) { // Avoid name collision between core and modules' controllers case 'supplier': case 'manufacturer': @@ -297,7 +298,7 @@ public function getController($id_shop = null) $route = $this->routes[$id_shop][$curr_lang_id]['supplier_rule']; if (!self::isSupplierLink($short_link, $route)) { // no route found - $route = array(); + $route = array(); $controller = $this->controller_not_found; } } @@ -329,8 +330,8 @@ public function getController($id_shop = null) // A patch for module friendly urls if (preg_match('#module-([a-z0-9_-]+)-([a-z0-9]+)$#i', $controller, $m)) { $_GET['module'] = $m[1]; - $_GET['fc'] = 'module'; - $controller = $m[2]; + $_GET['fc'] = 'module'; + $controller = $m[2]; } if (isset($_GET['fc']) && $_GET['fc'] == 'module') { @@ -349,22 +350,23 @@ public function getController($id_shop = null) $this->controller = $controller; } - $this->controller = str_replace('-', '', $this->controller); + $this->controller = str_replace('-', '', $this->controller); $_GET['controller'] = $this->controller; return $this->controller; } /** - * Check if $short_link is a Product Link + * Check if $short_link is a Product Link. * * @param string $short_link: requested url without '?' part and without '/' on begining + * * @return bool true: it's a link to product, false: it isn't */ private static function isProductLink($short_link, $route) { $short_link = preg_replace('#\.html?$#', '', '/'.$short_link); - $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); + $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); preg_match($regexp, $short_link, $kw); if (empty($kw['product_rewrite'])) { @@ -373,25 +375,26 @@ private static function isProductLink($short_link, $route) $sql = 'SELECT `id_product` FROM `'._DB_PREFIX_.'product_lang` - WHERE `link_rewrite` = \''.pSQL($kw['product_rewrite']).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; + WHERE `link_rewrite` = \''.pSQL($kw['product_rewrite']).'\' AND `id_lang` = '.(int) Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); + $sql .= ' AND `id_shop` = '.(int) Shop::getContextShopID(); } - $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + $id_product = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - return ($id_product > 0); + return $id_product > 0; } /** - * Check if $short_link is a Category Link + * Check if $short_link is a Category Link. * * @param string $short_link: requested url without '?' part and without '/' on begining + * * @return bool true: it's a link to category, false: it isn't */ private static function isCategoryLink($short_link, $route) { $short_link = preg_replace('#\.html?$#', '', '/'.$short_link); - $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); + $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); preg_match($regexp, $short_link, $kw); if (empty($kw['category_rewrite'])) { @@ -400,26 +403,27 @@ private static function isCategoryLink($short_link, $route) $sql = 'SELECT `id_category` FROM `'._DB_PREFIX_.'category_lang` - WHERE `link_rewrite` = \''.pSQL($kw['category_rewrite']).'\' AND `id_lang` = '.(int)Context::getContext()->language->id; + WHERE `link_rewrite` = \''.pSQL($kw['category_rewrite']).'\' AND `id_lang` = '.(int) Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); + $sql .= ' AND `id_shop` = '.(int) Shop::getContextShopID(); } - $id_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + $id_category = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - return ($id_category > 0); + return $id_category > 0; } /** - * Check if $short_link is a Cms Link + * Check if $short_link is a Cms Link. * * @param string $short_link: requested url without '?' part and without '/' on begining + * * @return bool true: it's a link to cms page, false: it isn't */ private static function isCmsLink($short_link, $route) { $short_link = preg_replace('#\.html?$#', '', '/'.$short_link); - $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); + $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); preg_match($regexp, $short_link, $kw); if (empty($kw['cms_rewrite'])) { @@ -431,24 +435,25 @@ private static function isCmsLink($short_link, $route) LEFT JOIN `'._DB_PREFIX_.'cms_shop` s ON (l.`id_cms` = s.`id_cms`) WHERE l.`link_rewrite` = \''.pSQL($kw['cms_rewrite']).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + $sql .= ' AND s.`id_shop` = '.(int) Shop::getContextShopID(); } - $id_cms = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + $id_cms = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - return ($id_cms > 0); + return $id_cms > 0; } /** - * Check if $short_link is a Cms Category Link + * Check if $short_link is a Cms Category Link. * * @param string $short_link: requested url without '?' part and without '/' on begining + * * @return bool true: it's a link to cms page, false: it isn't */ private static function isCmsCategoryLink($short_link, $route) { $short_link = preg_replace('#\.html?$#', '', '/'.$short_link); - $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); + $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); preg_match($regexp, $short_link, $kw); if (empty($kw['cms_category_rewrite'])) { @@ -456,6 +461,7 @@ private static function isCmsCategoryLink($short_link, $route) //no link_rewrite, but uri starts with the link -> cms categories' list return true; } + return false; } @@ -464,24 +470,25 @@ private static function isCmsCategoryLink($short_link, $route) LEFT JOIN `'._DB_PREFIX_.'cms_category_shop` s ON (l.`id_cms_category` = s.`id_cms_category`) WHERE l.`link_rewrite` = \''.$kw['cms_category_rewrite'].'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + $sql .= ' AND s.`id_shop` = '.(int) Shop::getContextShopID(); } - $id_cms_cat = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + $id_cms_cat = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - return ($id_cms_cat > 0); + return $id_cms_cat > 0; } /** - * Check if $short_link is a Manufacturer Link + * Check if $short_link is a Manufacturer Link. * * @param string $short_link: requested url without '?' part and without '/' on begining + * * @return bool true: it's a link to manufacturer, false: it isn't */ private static function isManufacturerLink($short_link, $route) { $short_link = preg_replace('#\.html?$#', '', '/'.$short_link); - $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); + $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); preg_match($regexp, $short_link, $kw); if (empty($kw['manufacturer_rewrite'])) { @@ -489,6 +496,7 @@ private static function isManufacturerLink($short_link, $route) //no link_rewrite, but uri starts with the link -> manufactures' list return true; } + return false; } @@ -499,24 +507,25 @@ private static function isManufacturerLink($short_link, $route) LEFT JOIN `'._DB_PREFIX_.'manufacturer_shop` s ON (m.`id_manufacturer` = s.`id_manufacturer`) WHERE LOWER(m.`name`) LIKE \''.pSQL($manufacturer).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + $sql .= ' AND s.`id_shop` = '.(int) Shop::getContextShopID(); } - $id_manufacturer = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + $id_manufacturer = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - return ($id_manufacturer > 0); + return $id_manufacturer > 0; } /** - * Check if $short_link is a Supplier Link + * Check if $short_link is a Supplier Link. * * @param string $short_link: requested url without '?' part and without '/' on begining + * * @return bool true: it's a link to supplier, false: it isn't */ private static function isSupplierLink($short_link, $route) { $short_link = preg_replace('#\.html?$#', '', '/'.$short_link); - $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); + $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); preg_match($regexp, $short_link, $kw); if (empty($kw['supplier_rewrite'])) { @@ -524,6 +533,7 @@ private static function isSupplierLink($short_link, $route) //no link_rewrite, but uri starts with the link -> suppliers' list return true; } + return false; } @@ -534,11 +544,11 @@ private static function isSupplierLink($short_link, $route) LEFT JOIN `'._DB_PREFIX_.'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`) WHERE LOWER(sp.`name`) LIKE \''.pSQL($supplier).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + $sql .= ' AND s.`id_shop` = '.(int) Shop::getContextShopID(); } - $id_supplier = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + $id_supplier = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); - return ($id_supplier > 0); + return $id_supplier > 0; } } diff --git a/faktiva_clean_urls/override/classes/Link.php b/faktiva_clean_urls/override/classes/Link.php index f4a61f3..1b7202b 100644 --- a/faktiva_clean_urls/override/classes/Link.php +++ b/faktiva_clean_urls/override/classes/Link.php @@ -21,12 +21,13 @@ class Link extends LinkCore { /** - * Create a link to a category + * Create a link to a category. * - * @param mixed $category Category object (can be an ID category, but deprecated) + * @param mixed $category Category object (can be an ID category, but deprecated) * @param string $alias - * @param int $id_lang + * @param int $id_lang * @param string $selected_filters Url parameter to autocheck filters of the module blocklayered + * * @return string */ public function getCategoryLink($category, $alias = null, $id_lang = null, $selected_filters = null, $id_shop = null, $relative_protocol = false) @@ -42,11 +43,11 @@ public function getCategoryLink($category, $alias = null, $id_lang = null, $sele } // Set available keywords - $params = array(); - $params['id'] = $category->id; - $params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias; + $params = array(); + $params['id'] = $category->id; + $params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias; $params['meta_keywords'] = Tools::str2url($category->getFieldByLang('meta_keywords')); - $params['meta_title'] = Tools::str2url($category->getFieldByLang('meta_title')); + $params['meta_title'] = Tools::str2url($category->getFieldByLang('meta_title')); // Selected filters is used by the module blocklayered $selected_filters = is_null($selected_filters) ? '' : $selected_filters; @@ -54,7 +55,7 @@ public function getCategoryLink($category, $alias = null, $id_lang = null, $sele if (empty($selected_filters)) { $rule = 'category_rule'; } else { - $rule = 'layered_rule'; + $rule = 'layered_rule'; $params['selected_filters'] = $selected_filters; } @@ -77,14 +78,14 @@ public function getCategoryLink($category, $alias = null, $id_lang = null, $sele } /** - * Get pagination link + * Get pagination link. * - * @param string $type Controller name - * @param int $id_object - * @param bool $nb Show nb element per page attribute - * @param bool $sort Show sort attribute - * @param bool $pagination Show page number attribute - * @param bool $array If false return an url, if true return an array + * @param string $type Controller name + * @param int $id_object + * @param bool $nb Show nb element per page attribute + * @param bool $sort Show sort attribute + * @param bool $pagination Show page number attribute + * @param bool $array If false return an url, if true return an array */ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, $pagination = false, $array = false) { @@ -92,7 +93,7 @@ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, if (!$type && !$id_object) { $method_name = 'get'.Dispatcher::getInstance()->getController().'Link'; if (method_exists($this, $method_name) && isset($_GET['id_'.Dispatcher::getInstance()->getController()])) { - $type = Dispatcher::getInstance()->getController(); + $type = Dispatcher::getInstance()->getController(); $id_object = $_GET['id_'.$type]; } } @@ -108,9 +109,9 @@ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, $url = $this->getPageLink($name); } - $vars = array(); - $vars_nb = array('n', 'search_query'); - $vars_sort = array('orderby', 'orderway'); + $vars = array(); + $vars_nb = array('n', 'search_query'); + $vars_sort = array('orderby', 'orderway'); $vars_pagination = array('p'); foreach ($_GET as $k => $value) { @@ -118,15 +119,15 @@ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, if (Configuration::get('PS_REWRITING_SETTINGS') && ($k == 'isolang' || $k == 'id_lang')) { continue; } - $if_nb = (!$nb || ($nb && !in_array($k, $vars_nb))); - $if_sort = (!$sort || ($sort && !in_array($k, $vars_sort))); + $if_nb = (!$nb || ($nb && !in_array($k, $vars_nb))); + $if_sort = (!$sort || ($sort && !in_array($k, $vars_sort))); $if_pagination = (!$pagination || ($pagination && !in_array($k, $vars_pagination))); if ($if_nb && $if_sort && $if_pagination) { if (!is_array($value)) { $vars[urlencode($k)] = $value; } else { foreach (explode('&', http_build_query(array($k => $value), '', '&')) as $key => $val) { - $data = explode('=', $val); + $data = explode('=', $val); $vars[urldecode($data[0])] = $data[1]; } } @@ -145,12 +146,13 @@ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, $vars['requestUrl'] = $url; if ($type && $id_object) { - $vars['id_'.$type] = (is_object($id_object) ? (int)$id_object->id : (int)$id_object); + $vars['id_'.$type] = (is_object($id_object) ? (int) $id_object->id : (int) $id_object); } if (!$this->allow == 1) { $vars['controller'] = Dispatcher::getInstance()->getController(); } + return $vars; } } diff --git a/faktiva_clean_urls/override/classes/controller/FrontController.php b/faktiva_clean_urls/override/classes/controller/FrontController.php index 921f8c4..0371ba7 100644 --- a/faktiva_clean_urls/override/classes/controller/FrontController.php +++ b/faktiva_clean_urls/override/classes/controller/FrontController.php @@ -21,7 +21,7 @@ class FrontController extends FrontControllerCore { /** - * Redirects to canonical URL + * Redirects to canonical URL. * * Excludes "*_rewrite" URLs from being treated as non-canonical * diff --git a/faktiva_clean_urls/override/classes/controller/index.php b/faktiva_clean_urls/override/classes/controller/index.php index fe444e7..baee4b5 100644 --- a/faktiva_clean_urls/override/classes/controller/index.php +++ b/faktiva_clean_urls/override/classes/controller/index.php @@ -26,4 +26,5 @@ header('Pragma: no-cache'); header('Location: ../'); + return; diff --git a/faktiva_clean_urls/override/classes/index.php b/faktiva_clean_urls/override/classes/index.php index fe444e7..baee4b5 100644 --- a/faktiva_clean_urls/override/classes/index.php +++ b/faktiva_clean_urls/override/classes/index.php @@ -26,4 +26,5 @@ header('Pragma: no-cache'); header('Location: ../'); + return; diff --git a/faktiva_clean_urls/override/controllers/front/CategoryController.php b/faktiva_clean_urls/override/controllers/front/CategoryController.php index 7c2aed6..9d00a4f 100644 --- a/faktiva_clean_urls/override/controllers/front/CategoryController.php +++ b/faktiva_clean_urls/override/controllers/front/CategoryController.php @@ -26,10 +26,10 @@ public function init() $sql = 'SELECT `id_category` FROM `'._DB_PREFIX_.'category_lang` WHERE `link_rewrite` = \''.pSQL(str_replace('.html', '', $category_rewrite)).'\' AND `id_lang` = '.Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); + $sql .= ' AND `id_shop` = '.(int) Shop::getContextShopID(); } - $id_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + $id_category = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_category > 0) { $_GET['id_category'] = $id_category; } diff --git a/faktiva_clean_urls/override/controllers/front/CmsController.php b/faktiva_clean_urls/override/controllers/front/CmsController.php index d0e8f0b..f63fedb 100644 --- a/faktiva_clean_urls/override/controllers/front/CmsController.php +++ b/faktiva_clean_urls/override/controllers/front/CmsController.php @@ -24,7 +24,7 @@ public function init() { $shop_sql = ''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $shop_sql = ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + $shop_sql = ' AND s.`id_shop` = '.(int) Shop::getContextShopID(); } if ($cms_rewrite = Tools::getValue('cms_rewrite')) { @@ -33,7 +33,7 @@ public function init() LEFT JOIN `'._DB_PREFIX_.'cms_shop` s ON (l.`id_cms` = s.`id_cms`) WHERE l.`link_rewrite` = \''.pSQL(str_replace('.html', '', $cms_rewrite)).'\''.$shop_sql; - $id_cms = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + $id_cms = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_cms > 0) { $_GET['id_cms'] = $id_cms; } @@ -43,7 +43,7 @@ public function init() LEFT JOIN `'._DB_PREFIX_.'cms_category_shop` s ON (l.`id_cms_category` = s.`id_cms_category`) WHERE `link_rewrite` = \''.pSQL(str_replace('.html', '', $cms_category_rewrite)).'\''.$shop_sql; - $id_cms_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + $id_cms_category = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_cms_category > 0) { $_GET['id_cms_category'] = $id_cms_category; } diff --git a/faktiva_clean_urls/override/controllers/front/ManufacturerController.php b/faktiva_clean_urls/override/controllers/front/ManufacturerController.php index fd0115b..56711d4 100644 --- a/faktiva_clean_urls/override/controllers/front/ManufacturerController.php +++ b/faktiva_clean_urls/override/controllers/front/ManufacturerController.php @@ -28,10 +28,10 @@ public function init() LEFT JOIN `'._DB_PREFIX_.'manufacturer_shop` s ON (m.`id_manufacturer` = s.`id_manufacturer`) WHERE m.`name` LIKE \''.pSQL(str_replace('-', '_', $manufacturer_rewrite)).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + $sql .= ' AND s.`id_shop` = '.(int) Shop::getContextShopID(); } - $id_manufacturer = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + $id_manufacturer = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_manufacturer > 0) { $_GET['id_manufacturer'] = $id_manufacturer; } diff --git a/faktiva_clean_urls/override/controllers/front/ProductController.php b/faktiva_clean_urls/override/controllers/front/ProductController.php index c8e138f..0f1959c 100644 --- a/faktiva_clean_urls/override/controllers/front/ProductController.php +++ b/faktiva_clean_urls/override/controllers/front/ProductController.php @@ -24,16 +24,16 @@ public function init() { if ($product_rewrite = Tools::getValue('product_rewrite')) { $url_id_pattern = '/.*?([0-9]+)\-([a-zA-Z0-9-]*)(\.html)?/'; - $lang_id = (int)Context::getContext()->language->id; + $lang_id = (int) Context::getContext()->language->id; $sql = 'SELECT `id_product` FROM `'._DB_PREFIX_.'product_lang` WHERE `link_rewrite` = \''.pSQL(str_replace('.html', '', $product_rewrite)).'\' AND `id_lang` = '.$lang_id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); + $sql .= ' AND `id_shop` = '.(int) Shop::getContextShopID(); } - $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + $id_product = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_product > 0) { $_GET['id_product'] = $id_product; } elseif (preg_match($url_id_pattern, $this->request_uri, $url_parts)) { @@ -41,10 +41,10 @@ public function init() FROM `'._DB_PREFIX_.'product_lang` WHERE `id_product` = \''.pSQL($url_parts[1]).'\' AND `id_lang` = '.$lang_id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); + $sql .= ' AND `id_shop` = '.(int) Shop::getContextShopID(); } - $id_product = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + $id_product = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_product > 0) { $_GET['id_product'] = $id_product; } diff --git a/faktiva_clean_urls/override/controllers/front/SupplierController.php b/faktiva_clean_urls/override/controllers/front/SupplierController.php index 440a9d9..cf0cd68 100644 --- a/faktiva_clean_urls/override/controllers/front/SupplierController.php +++ b/faktiva_clean_urls/override/controllers/front/SupplierController.php @@ -28,10 +28,10 @@ public function init() LEFT JOIN `'._DB_PREFIX_.'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`) WHERE sp.`name` LIKE \''.pSQL(str_replace('-', '_', $supplier_rewrite)).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + $sql .= ' AND s.`id_shop` = '.(int) Shop::getContextShopID(); } - $id_supplier = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + $id_supplier = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_supplier > 0) { $_GET['id_supplier'] = $id_supplier; } diff --git a/faktiva_clean_urls/override/controllers/front/index.php b/faktiva_clean_urls/override/controllers/front/index.php index fe444e7..baee4b5 100644 --- a/faktiva_clean_urls/override/controllers/front/index.php +++ b/faktiva_clean_urls/override/controllers/front/index.php @@ -26,4 +26,5 @@ header('Pragma: no-cache'); header('Location: ../'); + return; diff --git a/faktiva_clean_urls/override/controllers/index.php b/faktiva_clean_urls/override/controllers/index.php index fe444e7..baee4b5 100644 --- a/faktiva_clean_urls/override/controllers/index.php +++ b/faktiva_clean_urls/override/controllers/index.php @@ -26,4 +26,5 @@ header('Pragma: no-cache'); header('Location: ../'); + return; diff --git a/faktiva_clean_urls/override/index.php b/faktiva_clean_urls/override/index.php index fe444e7..baee4b5 100644 --- a/faktiva_clean_urls/override/index.php +++ b/faktiva_clean_urls/override/index.php @@ -26,4 +26,5 @@ header('Pragma: no-cache'); header('Location: ../'); + return; diff --git a/faktiva_clean_urls/translations/it.php b/faktiva_clean_urls/translations/it.php index 4947209..649d3f0 100644 --- a/faktiva_clean_urls/translations/it.php +++ b/faktiva_clean_urls/translations/it.php @@ -19,7 +19,7 @@ */ global $_MODULE; -$_MODULE = array(); +$_MODULE = array(); $_MODULE['<{zzcleanurls}prestashop>zzcleanurls_66711d755755f94e8f48d9cb858290c8'] = 'ZiZuu Clean URLs'; $_MODULE['<{zzcleanurls}prestashop>zzcleanurls_4abf1025eb40d230f80b0470e5c60696'] = 'Questo modulo permette di rimuovere gli ID dalle URL. Utilizza gli \"override\".'; $_MODULE['<{zzcleanurls}prestashop>zzcleanurls_3c3419c3ec1896fbfd5c37549eda9144'] = 'Sicuro di voler rimuovere il modulo \"ZiZuu Clean URLs\"?'; diff --git a/faktiva_clean_urls/upgrade/index.php b/faktiva_clean_urls/upgrade/index.php index fe444e7..baee4b5 100644 --- a/faktiva_clean_urls/upgrade/index.php +++ b/faktiva_clean_urls/upgrade/index.php @@ -26,4 +26,5 @@ header('Pragma: no-cache'); header('Location: ../'); + return; From 75bc9b7c7841c7b36f1a759a7863e53cfbed0488 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 24 Oct 2016 18:17:19 +0200 Subject: [PATCH 169/174] better README --- README.md | 88 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index f08c941..45bab53 100644 --- a/README.md +++ b/README.md @@ -11,44 +11,49 @@ [![Join the chat at https://gitter.im/faktiva/prestashop-clean-urls](https://img.shields.io/badge/Gitter-CHAT%20NOW-brightgreen.svg?style=plastic)](https://gitter.im/faktiva/prestashop-clean-urls) [![Twitter](https://img.shields.io/twitter/url/https/github.com/faktiva/prestashop-clean-urls.svg?style=social)](https://twitter.com/intent/tweet?text=Fantastic @PrestaShop module "#Faktiva Clean URLs"&url=https://github.com/faktiva/prestashop-clean-urls) -___ +____ -Makes possible to have URLs with no IDs in PrestaShop. +**Makes possible to have URLs with no IDs in PrestaShop.** -If you fork, please make every change the way we can pull, don't reinvent the wheel .. make every custom change on a private branch, so you can merge your own changes to the community mantained branch every time a new release is out. +> If you fork, please make every change the way we can pull, don't reinvent the wheel .. make every custom change on a private branch, so you can merge your own changes to the community mantained branch every time a new release is out. +> +> - For production use the **latest stable [release](https://github.com/faktiva/prestashop-clean-urls/releases/latest)** +> - For developing or Pull Request please use only the "**[dev](https://github.com/faktiva/prestashop-clean-urls/tree/dev)**" branch +> +> It has been reported to work on **PS 1.5.6 - 1.6.1.x** but will install on PS >= 1.5 too. +> **If you succesfully use this module on some older version please report** -* For production use the **latest stable [release](https://github.com/faktiva/prestashop-clean-urls/releases/latest)** -* For developing or Pull Request please use only the "**[dev](https://github.com/faktiva/prestashop-clean-urls/tree/dev)**" branch - -It has been reported to work on **PS 1.5.6 - 1.6.1.x** but will install on PS >= 1.5 too. -**If you succesfully use this module on some older version please report** # INSTALLATION -Install the module from the Backoffice (administration panel): -- download the lastest [release](https://github.com/faktiva/prestashop-clean-urls/releases/latest) ***ZIP*** file (***`faktiva_clean_urls.zip`***) as it already contains the right folder name (`faktiva_clean_urls`, **not** `faktiva-prestashop-clean-urls-version_x.y.z` !) -- in the modules tab, click on **add a new module** -- click on "`Browse`" to open the dialogue box letting you search your computer -- select the ZIP file you downloaded and validate the dialogue box -- click on "`Upload this module`" -- once uploaded you could have to search the module among the others (tip: filter by author "`faktiva`") and click on the `install` button +## from _PS administration panel_ + +Go in the back office of your shop and follow these steps: + - download the [lastest release](https://github.com/faktiva/prestashop-clean-urls/releases/latest) **_ZIP_ file** (**_`faktiva_clean_urls.zip`_**) as it already contains the right folder name (`faktiva_clean_urls`, **not** `faktiva-prestashop-clean-urls-version_x.y.z` !) + - in the modules tab, click on **`add a new module`** + - click on **"`Browse`"** to open the dialogue box letting you search your computer + - select the ZIP file you downloaded and validate the dialogue box + - click on "**`Upload this module`**" + - once uploaded, you could have to search the module among the others (_tip: filter by author "**`faktiva`**"_) and click on the **`install`** button -## Make sure your SEO and URL settings are as follows: +# Configuration & Checks -This is __MANDATORY__ - * products: {category:/}{rewrite} (you **can** add .html at the end) - * categories: {categories:/}{rewrite}**/** - * manufacturers: manufactures/{rewrite} - * suppliers: suppliers/{rewrite} - * CMS page: info/{rewrite} (you **can** add .html at the end) - * CMS category: info/{rewrite}**/** - * modules: modules/{module}{/:controller} +**Make sure your _`SEO and URL`_ settings are as follows:** -You can replace words such as "info", "suppliers", etc with whatever you want, given that it does not conflicts with a category name +This is **MANDATORY** + - products: {category:/}{rewrite} (you **can** add .html at the end) + - categories: {categories:/}{rewrite}**/** + - manufacturers: manufactures/{rewrite} + - suppliers: suppliers/{rewrite} + - CMS page: info/{rewrite} (you **can** add .html at the end) + - CMS category: info/{rewrite}**/** + - modules: modules/{module}{/:controller} -Remember to - * **clear the browser cache** - * **clear PS cache** (under smarty -> cache and smarty -> compile) +_You can replace words such as "info", "suppliers", etc with whatever you want, given that it does not conflicts with a category name_ + +**Remember to** + - clear the **browser cache** + - clear **PS cache** (under smarty -> cache and smarty -> compile) # UNINSTALLATION @@ -58,19 +63,19 @@ Remember to If something goes wrong do the following: -* Open folder /override/classes/ - * Remove "Link.php" - * Remove "Dispatcher.php" -* Open folder /override/controllers/front/ - * Remove "CategoryController.php" - * Remove "CmsController.php" - * Remove "ManufacturerController.php" - * Remove "ProductController.php" - * Remove "SupplierController.php" -* Open folder /cache/ - * Remove "class_index.php" -* Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL off -> Save -* Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL on -> Save + - Open folder **`/override/classes/`** + - Remove **`Link.php`** + - Remove **`Dispatcher.php`** + - Open folder **`/override/controllers/front/`** + - Remove **`CategoryController.php`** + - Remove **`CmsController.php`** + - Remove **`ManufacturerController.php`** + - Remove **`ProductController.php`** + - Remove **`SupplierController.php`** + - Open folder **`/cache/`** + - Remove **`class_index.php`** + - Go to **`back office`** -> **`Preferences`** -> **`SEO and URLs`** -> Set **`userfriendly URL`** off -> **`Save`** + - Go to **`back office`** -> **`Preferences`** -> **`SEO and URLs`** -> Set **`userfriendly URL`** on -> **`Save`** If you got any other override modules, you should now go to you back office, uninstall them, and reinstall them again to work correctly. @@ -83,3 +88,4 @@ If you got any other override modules, you should now go to you back office, uni **[PrestaShop Clean URLs](https://github.com/faktiva/prestashop-clean-urls)** by [Faktiva](https://github.com/faktiva) is licensed under a **Creative Commons [Attribution-ShareAlike](http://creativecommons.org/licenses/by-sa/4.0/) 4.0 International License**. Permissions beyond the scope of this license may be available contacting us at info@faktiva.com. + From 526cd1f45223999b4ff41f0fd049df477db0393a Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 24 Oct 2016 18:17:39 +0200 Subject: [PATCH 170/174] Release 1.1.1 - closes #61 - closes #62 - closes #63 --- faktiva_clean_urls/config.xml | 2 +- faktiva_clean_urls/faktiva_clean_urls.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/faktiva_clean_urls/config.xml b/faktiva_clean_urls/config.xml index e1f8459..8ea9912 100644 --- a/faktiva_clean_urls/config.xml +++ b/faktiva_clean_urls/config.xml @@ -2,7 +2,7 @@ faktiva_clean_urls - + diff --git a/faktiva_clean_urls/faktiva_clean_urls.php b/faktiva_clean_urls/faktiva_clean_urls.php index ea628c2..9d094af 100644 --- a/faktiva_clean_urls/faktiva_clean_urls.php +++ b/faktiva_clean_urls/faktiva_clean_urls.php @@ -35,7 +35,7 @@ public function __construct() { $this->name = 'faktiva_clean_urls'; $this->tab = 'seo'; - $this->version = '1.1.0'; + $this->version = '1.1.1'; $this->author = 'Faktiva'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.5', 'max' => _PS_VERSION_); From 2c30131bf39c2cdc91774f968ae18244bcaf8066 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Mon, 24 Oct 2016 18:22:02 +0200 Subject: [PATCH 171/174] Change @author in header comment --- .php_cs | 2 +- faktiva_clean_urls/faktiva_clean_urls.php | 2 +- faktiva_clean_urls/index.php | 2 +- faktiva_clean_urls/override/classes/Dispatcher.php | 2 +- faktiva_clean_urls/override/classes/Link.php | 2 +- .../override/classes/controller/FrontController.php | 2 +- faktiva_clean_urls/override/classes/controller/index.php | 2 +- faktiva_clean_urls/override/classes/index.php | 2 +- .../override/controllers/front/CategoryController.php | 2 +- faktiva_clean_urls/override/controllers/front/CmsController.php | 2 +- .../override/controllers/front/ManufacturerController.php | 2 +- .../override/controllers/front/ProductController.php | 2 +- .../override/controllers/front/SupplierController.php | 2 +- faktiva_clean_urls/override/controllers/front/index.php | 2 +- faktiva_clean_urls/override/controllers/index.php | 2 +- faktiva_clean_urls/override/index.php | 2 +- faktiva_clean_urls/tools/debug.php | 2 +- faktiva_clean_urls/translations/it.php | 2 +- faktiva_clean_urls/upgrade/index.php | 2 +- faktiva_clean_urls/upgrade/install-1.1.0.php | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.php_cs b/.php_cs index aabbbe7..a34ac72 100644 --- a/.php_cs +++ b/.php_cs @@ -13,7 +13,7 @@ DISCLAIMER This code is provided as is without any warranty. No promise of being safe or secure -@author AlberT +@author Emiliano 'AlberT' Gabrielli @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 @source https://github.com/faktiva/prestashop-clean-urls EOF; diff --git a/faktiva_clean_urls/faktiva_clean_urls.php b/faktiva_clean_urls/faktiva_clean_urls.php index 9d094af..3de821b 100644 --- a/faktiva_clean_urls/faktiva_clean_urls.php +++ b/faktiva_clean_urls/faktiva_clean_urls.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ diff --git a/faktiva_clean_urls/index.php b/faktiva_clean_urls/index.php index baee4b5..5bbd579 100644 --- a/faktiva_clean_urls/index.php +++ b/faktiva_clean_urls/index.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ diff --git a/faktiva_clean_urls/override/classes/Dispatcher.php b/faktiva_clean_urls/override/classes/Dispatcher.php index 5ba88bd..2a9d76b 100644 --- a/faktiva_clean_urls/override/classes/Dispatcher.php +++ b/faktiva_clean_urls/override/classes/Dispatcher.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ diff --git a/faktiva_clean_urls/override/classes/Link.php b/faktiva_clean_urls/override/classes/Link.php index 1b7202b..e319ba1 100644 --- a/faktiva_clean_urls/override/classes/Link.php +++ b/faktiva_clean_urls/override/classes/Link.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ diff --git a/faktiva_clean_urls/override/classes/controller/FrontController.php b/faktiva_clean_urls/override/classes/controller/FrontController.php index 0371ba7..5c029c5 100644 --- a/faktiva_clean_urls/override/classes/controller/FrontController.php +++ b/faktiva_clean_urls/override/classes/controller/FrontController.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ diff --git a/faktiva_clean_urls/override/classes/controller/index.php b/faktiva_clean_urls/override/classes/controller/index.php index baee4b5..5bbd579 100644 --- a/faktiva_clean_urls/override/classes/controller/index.php +++ b/faktiva_clean_urls/override/classes/controller/index.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ diff --git a/faktiva_clean_urls/override/classes/index.php b/faktiva_clean_urls/override/classes/index.php index baee4b5..5bbd579 100644 --- a/faktiva_clean_urls/override/classes/index.php +++ b/faktiva_clean_urls/override/classes/index.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ diff --git a/faktiva_clean_urls/override/controllers/front/CategoryController.php b/faktiva_clean_urls/override/controllers/front/CategoryController.php index 9d00a4f..39e7d4d 100644 --- a/faktiva_clean_urls/override/controllers/front/CategoryController.php +++ b/faktiva_clean_urls/override/controllers/front/CategoryController.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ diff --git a/faktiva_clean_urls/override/controllers/front/CmsController.php b/faktiva_clean_urls/override/controllers/front/CmsController.php index f63fedb..a650b9d 100644 --- a/faktiva_clean_urls/override/controllers/front/CmsController.php +++ b/faktiva_clean_urls/override/controllers/front/CmsController.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ diff --git a/faktiva_clean_urls/override/controllers/front/ManufacturerController.php b/faktiva_clean_urls/override/controllers/front/ManufacturerController.php index 56711d4..fece097 100644 --- a/faktiva_clean_urls/override/controllers/front/ManufacturerController.php +++ b/faktiva_clean_urls/override/controllers/front/ManufacturerController.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ diff --git a/faktiva_clean_urls/override/controllers/front/ProductController.php b/faktiva_clean_urls/override/controllers/front/ProductController.php index 0f1959c..7c1fd66 100644 --- a/faktiva_clean_urls/override/controllers/front/ProductController.php +++ b/faktiva_clean_urls/override/controllers/front/ProductController.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ diff --git a/faktiva_clean_urls/override/controllers/front/SupplierController.php b/faktiva_clean_urls/override/controllers/front/SupplierController.php index cf0cd68..40dab3c 100644 --- a/faktiva_clean_urls/override/controllers/front/SupplierController.php +++ b/faktiva_clean_urls/override/controllers/front/SupplierController.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ diff --git a/faktiva_clean_urls/override/controllers/front/index.php b/faktiva_clean_urls/override/controllers/front/index.php index baee4b5..5bbd579 100644 --- a/faktiva_clean_urls/override/controllers/front/index.php +++ b/faktiva_clean_urls/override/controllers/front/index.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ diff --git a/faktiva_clean_urls/override/controllers/index.php b/faktiva_clean_urls/override/controllers/index.php index baee4b5..5bbd579 100644 --- a/faktiva_clean_urls/override/controllers/index.php +++ b/faktiva_clean_urls/override/controllers/index.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ diff --git a/faktiva_clean_urls/override/index.php b/faktiva_clean_urls/override/index.php index baee4b5..5bbd579 100644 --- a/faktiva_clean_urls/override/index.php +++ b/faktiva_clean_urls/override/index.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ diff --git a/faktiva_clean_urls/tools/debug.php b/faktiva_clean_urls/tools/debug.php index a51e635..b3337c0 100644 --- a/faktiva_clean_urls/tools/debug.php +++ b/faktiva_clean_urls/tools/debug.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ diff --git a/faktiva_clean_urls/translations/it.php b/faktiva_clean_urls/translations/it.php index 649d3f0..45b3c8f 100644 --- a/faktiva_clean_urls/translations/it.php +++ b/faktiva_clean_urls/translations/it.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ diff --git a/faktiva_clean_urls/upgrade/index.php b/faktiva_clean_urls/upgrade/index.php index baee4b5..5bbd579 100644 --- a/faktiva_clean_urls/upgrade/index.php +++ b/faktiva_clean_urls/upgrade/index.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ diff --git a/faktiva_clean_urls/upgrade/install-1.1.0.php b/faktiva_clean_urls/upgrade/install-1.1.0.php index 2705be7..d8b086d 100644 --- a/faktiva_clean_urls/upgrade/install-1.1.0.php +++ b/faktiva_clean_urls/upgrade/install-1.1.0.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ From 0a1f2276f24d2c4a35060fae48f262e99f3b51ed Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Sun, 23 Oct 2016 01:19:24 +0200 Subject: [PATCH 172/174] Backport release 1.1.0 into dev * Migrate the module to the new Faktiva maintainer * minor changes --- .../override/classes/Dispatcher.php | 6 ++-- .../controllers/front/CategoryController.php | 6 ++-- .../controllers/front/SupplierController.php | 6 ++-- faktiva_clean_urls/translations/it.php | 34 +++++++++---------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/faktiva_clean_urls/override/classes/Dispatcher.php b/faktiva_clean_urls/override/classes/Dispatcher.php index 2a9d76b..3b1d008 100644 --- a/faktiva_clean_urls/override/classes/Dispatcher.php +++ b/faktiva_clean_urls/override/classes/Dispatcher.php @@ -147,9 +147,9 @@ public function addRoute($route_id, $rule, $controller, $id_lang = null, array $ $transform_keywords = array(); preg_match_all('#\\\{(([^{}]*)\\\:)?('.implode('|', array_keys($keywords)).')(\\\:([^{}]*))?\\\}#', $regexp, $m); for ($i = 0, $total = count($m[0]); $i < $total; ++$i) { - $prepend = $m[2][$i]; - $keyword = $m[3][$i]; - $append = $m[5][$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), diff --git a/faktiva_clean_urls/override/controllers/front/CategoryController.php b/faktiva_clean_urls/override/controllers/front/CategoryController.php index 39e7d4d..7c2aed6 100644 --- a/faktiva_clean_urls/override/controllers/front/CategoryController.php +++ b/faktiva_clean_urls/override/controllers/front/CategoryController.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author Emiliano 'AlberT' Gabrielli + * @author AlberT * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ @@ -26,10 +26,10 @@ public function init() $sql = 'SELECT `id_category` FROM `'._DB_PREFIX_.'category_lang` WHERE `link_rewrite` = \''.pSQL(str_replace('.html', '', $category_rewrite)).'\' AND `id_lang` = '.Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND `id_shop` = '.(int) Shop::getContextShopID(); + $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); } - $id_category = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + $id_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_category > 0) { $_GET['id_category'] = $id_category; } diff --git a/faktiva_clean_urls/override/controllers/front/SupplierController.php b/faktiva_clean_urls/override/controllers/front/SupplierController.php index 40dab3c..440a9d9 100644 --- a/faktiva_clean_urls/override/controllers/front/SupplierController.php +++ b/faktiva_clean_urls/override/controllers/front/SupplierController.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author Emiliano 'AlberT' Gabrielli + * @author AlberT * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ @@ -28,10 +28,10 @@ public function init() LEFT JOIN `'._DB_PREFIX_.'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`) WHERE sp.`name` LIKE \''.pSQL(str_replace('-', '_', $supplier_rewrite)).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND s.`id_shop` = '.(int) Shop::getContextShopID(); + $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); } - $id_supplier = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + $id_supplier = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_supplier > 0) { $_GET['id_supplier'] = $id_supplier; } diff --git a/faktiva_clean_urls/translations/it.php b/faktiva_clean_urls/translations/it.php index 45b3c8f..9f9866c 100644 --- a/faktiva_clean_urls/translations/it.php +++ b/faktiva_clean_urls/translations/it.php @@ -19,20 +19,20 @@ */ global $_MODULE; -$_MODULE = array(); -$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_66711d755755f94e8f48d9cb858290c8'] = 'ZiZuu Clean URLs'; -$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_4abf1025eb40d230f80b0470e5c60696'] = 'Questo modulo permette di rimuovere gli ID dalle URL. Utilizza gli \"override\".'; -$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_3c3419c3ec1896fbfd5c37549eda9144'] = 'Sicuro di voler rimuovere il modulo \"ZiZuu Clean URLs\"?'; -$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_8aa6176f15ae0b8ec0f7f7797bc129cb'] = 'In alcune versioni di Prestashop potrebbe essere necessario disabilitare la Cache, salvare, accedere al proprio negozio e riabilitare la cache di nuovo:'; -$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_c9d7eedc8be4380c02106619824b8449'] = 'Parametri avanzati'; -$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_9446a98ad14416153cc4d45ab8b531bf'] = 'Prestazioni'; -$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_341be761f9f11e9b06dac0071fb8a5ed'] = 'pulisci la Cache'; -$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_d0834fcec6337785ee749c8f5464f6f6'] = 'Impostazioni'; -$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_acc42ebe7b6b25f7d6ea8618f514f79b'] = 'SEO and URLs'; -$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_a3637ddc43eefbe21947f64210bae984'] = 'disattivare \"Friendly url\"'; -$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_c9cc8cce247e49bae79f15173ce97354'] = 'Salva'; -$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_7e497263357c140cc3d2396dbfa8b2eb'] = 'attivare \"Friendly url\"'; -$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_851645568061b03aeeb2b4c2af435a5e'] = 'Dovresti eliminare queste URL duplicate:'; -$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_c961f5d807b8ae34a9a4a825606f953b'] = 'Lingua:'; -$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_63de125555fddc0e009f92ec0e9e64e4'] = 'Negozio:'; -$_MODULE['<{zzcleanurls}prestashop>zzcleanurls_dae2931f3df26903e6ddbb123b751344'] = 'Perfetto. Non ci sono URL duplicate.'; +$_MODULE = array(); +$_MODULE['<{faktiva_clean_urls}prestashop>faktiva_clean_urls_66711d755755f94e8f48d9cb858290c8'] = 'Faktiva Clean URLs'; +$_MODULE['<{faktiva_clean_urls}prestashop>faktiva_clean_urls_4abf1025eb40d230f80b0470e5c60696'] = 'Questo modulo permette di rimuovere gli ID dalle URL. Utilizza gli \"override\".'; +$_MODULE['<{faktiva_clean_urls}prestashop>faktiva_clean_urls_3c3419c3ec1896fbfd5c37549eda9144'] = 'Sicuro di voler rimuovere il modulo \"Faktiva Clean URLs\"?'; +$_MODULE['<{faktiva_clean_urls}prestashop>faktiva_clean_urls_8aa6176f15ae0b8ec0f7f7797bc129cb'] = 'In alcune versioni di Prestashop potrebbe essere necessario disabilitare la Cache, salvare, accedere al proprio negozio e riabilitare la cache di nuovo:'; +$_MODULE['<{faktiva_clean_urls}prestashop>faktiva_clean_urls_c9d7eedc8be4380c02106619824b8449'] = 'Parametri avanzati'; +$_MODULE['<{faktiva_clean_urls}prestashop>faktiva_clean_urls_9446a98ad14416153cc4d45ab8b531bf'] = 'Prestazioni'; +$_MODULE['<{faktiva_clean_urls}prestashop>faktiva_clean_urls_341be761f9f11e9b06dac0071fb8a5ed'] = 'pulisci la Cache'; +$_MODULE['<{faktiva_clean_urls}prestashop>faktiva_clean_urls_d0834fcec6337785ee749c8f5464f6f6'] = 'Impostazioni'; +$_MODULE['<{faktiva_clean_urls}prestashop>faktiva_clean_urls_acc42ebe7b6b25f7d6ea8618f514f79b'] = 'SEO and URLs'; +$_MODULE['<{faktiva_clean_urls}prestashop>faktiva_clean_urls_a3637ddc43eefbe21947f64210bae984'] = 'disattivare \"Friendly url\"'; +$_MODULE['<{faktiva_clean_urls}prestashop>faktiva_clean_urls_c9cc8cce247e49bae79f15173ce97354'] = 'Salva'; +$_MODULE['<{faktiva_clean_urls}prestashop>faktiva_clean_urls_7e497263357c140cc3d2396dbfa8b2eb'] = 'attivare \"Friendly url\"'; +$_MODULE['<{faktiva_clean_urls}prestashop>faktiva_clean_urls_851645568061b03aeeb2b4c2af435a5e'] = 'Dovresti eliminare queste URL duplicate:'; +$_MODULE['<{faktiva_clean_urls}prestashop>faktiva_clean_urls_c961f5d807b8ae34a9a4a825606f953b'] = 'Lingua:'; +$_MODULE['<{faktiva_clean_urls}prestashop>faktiva_clean_urls_63de125555fddc0e009f92ec0e9e64e4'] = 'Negozio:'; +$_MODULE['<{faktiva_clean_urls}prestashop>faktiva_clean_urls_dae2931f3df26903e6ddbb123b751344'] = 'Perfetto. Non ci sono URL duplicate.'; From c4c232c0ae3a0db657c900b5ee25adb06f06a2f1 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 25 Oct 2016 13:23:14 +0200 Subject: [PATCH 173/174] Stil Coding Style adjustments --- .php_cs | 2 - faktiva_clean_urls/faktiva_clean_urls.php | 12 +- .../override/classes/Dispatcher.php | 134 +++++++++--------- faktiva_clean_urls/override/classes/Link.php | 24 ++-- .../controllers/front/CategoryController.php | 6 +- .../controllers/front/ProductController.php | 2 +- .../controllers/front/SupplierController.php | 6 +- 7 files changed, 92 insertions(+), 94 deletions(-) diff --git a/.php_cs b/.php_cs index a34ac72..e1764dc 100644 --- a/.php_cs +++ b/.php_cs @@ -27,8 +27,6 @@ return Symfony\CS\Config\Config::create() ->setUsingCache(true) ->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL) ->fixers(array( - 'align_double_arrow', - 'align_equals', 'header_comment', 'empty_return', 'long_array_syntax', diff --git a/faktiva_clean_urls/faktiva_clean_urls.php b/faktiva_clean_urls/faktiva_clean_urls.php index 3de821b..95d6b04 100644 --- a/faktiva_clean_urls/faktiva_clean_urls.php +++ b/faktiva_clean_urls/faktiva_clean_urls.php @@ -33,13 +33,13 @@ class faktiva_clean_urls extends Module { public function __construct() { - $this->name = 'faktiva_clean_urls'; - $this->tab = 'seo'; - $this->version = '1.1.1'; - $this->author = 'Faktiva'; - $this->need_instance = 0; + $this->name = 'faktiva_clean_urls'; + $this->tab = 'seo'; + $this->version = '1.1.1'; + $this->author = 'Faktiva'; + $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.5', 'max' => _PS_VERSION_); - $this->bootstrap = true; + $this->bootstrap = true; parent::__construct(); diff --git a/faktiva_clean_urls/override/classes/Dispatcher.php b/faktiva_clean_urls/override/classes/Dispatcher.php index 3b1d008..ab08f95 100644 --- a/faktiva_clean_urls/override/classes/Dispatcher.php +++ b/faktiva_clean_urls/override/classes/Dispatcher.php @@ -31,60 +31,60 @@ protected function loadRoutes($id_shop = null) $this->default_routes = array( 'category_rule' => array( 'controller' => 'category', - 'rule' => '{rewrite}/', - 'keywords' => array( - 'id' => array('regexp' => '[0-9]+'), - 'categories' => array('regexp' => '[/_a-zA-Z0-9\pL\pS-]*'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9\pL\pS-]*', 'param' => 'category_rewrite'), + 'rule' => '{rewrite}/', + 'keywords' => array( + 'id' => array('regexp' => '[0-9]+'), + 'categories' => array('regexp' => '[/_a-zA-Z0-9\pL\pS-]*'), + '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-]*'), + 'meta_title' => array('regexp' => '[_a-zA-Z0-9\pL-]*'), ), ), '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'), + '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-]*'), + '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'), + '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-]*'), + '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'), + '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-]*'), + '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'), + '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-]*'), + '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'), + '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( @@ -93,31 +93,31 @@ protected function loadRoutes($id_shop = null) ), '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]{8,17}'), - 'category' => array('regexp' => '[_a-zA-Z0-9\pL-]*'), - 'categories' => array('regexp' => '[/_a-zA-Z0-9\pL-]*'), - 'reference' => array('regexp' => '[_a-zA-Z0-9\pL-]*'), + '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]{8,17}'), + '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-]*'), + '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]+'), + '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-]*'), + '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-]*'), ), ), ); @@ -149,17 +149,17 @@ public function addRoute($route_id, $rule, $controller, $id_lang = null, array $ for ($i = 0, $total = count($m[0]); $i < $total; ++$i) { $prepend = $m[2][$i]; $keyword = $m[3][$i]; - $append = $m[5][$i]; + $append = $m[5][$i]; $transform_keywords[$keyword] = array( 'required' => isset($keywords[$keyword]['param']), - 'prepend' => stripslashes($prepend), - 'append' => stripslashes($append), + 'prepend' => stripslashes($prepend), + 'append' => stripslashes($append), ); $prepend_regexp = $append_regexp = ''; if ($prepend || $append) { $prepend_regexp = '('.$prepend; - $append_regexp = $append.')??'; // fix greediness (step 1) + $append_regexp = $append.')??'; // fix greediness (step 1) } if (isset($keywords[$keyword]['param'])) { @@ -180,11 +180,11 @@ public function addRoute($route_id, $rule, $controller, $id_lang = null, array $ } $this->routes[$id_shop][$id_lang][$route_id] = array( - 'rule' => $rule, - 'regexp' => $regexp, + 'rule' => $rule, + 'regexp' => $regexp, 'controller' => $controller, - 'keywords' => $keywords, - 'params' => $params, + 'keywords' => $keywords, + 'params' => $params, ); } @@ -251,7 +251,7 @@ public function getController($id_shop = null) foreach ($this->routes[$id_shop][$curr_lang_id] as $k => $r) { if (preg_match($r['regexp'], $uri, $m)) { $isTemplate = false; - $module = isset($r['params']['module']) ? $r['params']['module'] : ''; + $module = isset($r['params']['module']) ? $r['params']['module'] : ''; switch ($r['controller'].$module) { // Avoid name collision between core and modules' controllers case 'supplier': case 'manufacturer': @@ -298,7 +298,7 @@ public function getController($id_shop = null) $route = $this->routes[$id_shop][$curr_lang_id]['supplier_rule']; if (!self::isSupplierLink($short_link, $route)) { // no route found - $route = array(); + $route = array(); $controller = $this->controller_not_found; } } @@ -330,8 +330,8 @@ public function getController($id_shop = null) // A patch for module friendly urls if (preg_match('#module-([a-z0-9_-]+)-([a-z0-9]+)$#i', $controller, $m)) { $_GET['module'] = $m[1]; - $_GET['fc'] = 'module'; - $controller = $m[2]; + $_GET['fc'] = 'module'; + $controller = $m[2]; } if (isset($_GET['fc']) && $_GET['fc'] == 'module') { @@ -350,7 +350,7 @@ public function getController($id_shop = null) $this->controller = $controller; } - $this->controller = str_replace('-', '', $this->controller); + $this->controller = str_replace('-', '', $this->controller); $_GET['controller'] = $this->controller; return $this->controller; @@ -366,7 +366,7 @@ public function getController($id_shop = null) private static function isProductLink($short_link, $route) { $short_link = preg_replace('#\.html?$#', '', '/'.$short_link); - $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); + $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); preg_match($regexp, $short_link, $kw); if (empty($kw['product_rewrite'])) { @@ -394,7 +394,7 @@ private static function isProductLink($short_link, $route) private static function isCategoryLink($short_link, $route) { $short_link = preg_replace('#\.html?$#', '', '/'.$short_link); - $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); + $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); preg_match($regexp, $short_link, $kw); if (empty($kw['category_rewrite'])) { @@ -423,7 +423,7 @@ private static function isCategoryLink($short_link, $route) private static function isCmsLink($short_link, $route) { $short_link = preg_replace('#\.html?$#', '', '/'.$short_link); - $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); + $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); preg_match($regexp, $short_link, $kw); if (empty($kw['cms_rewrite'])) { @@ -453,7 +453,7 @@ private static function isCmsLink($short_link, $route) private static function isCmsCategoryLink($short_link, $route) { $short_link = preg_replace('#\.html?$#', '', '/'.$short_link); - $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); + $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); preg_match($regexp, $short_link, $kw); if (empty($kw['cms_category_rewrite'])) { @@ -488,7 +488,7 @@ private static function isCmsCategoryLink($short_link, $route) private static function isManufacturerLink($short_link, $route) { $short_link = preg_replace('#\.html?$#', '', '/'.$short_link); - $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); + $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); preg_match($regexp, $short_link, $kw); if (empty($kw['manufacturer_rewrite'])) { @@ -525,7 +525,7 @@ private static function isManufacturerLink($short_link, $route) private static function isSupplierLink($short_link, $route) { $short_link = preg_replace('#\.html?$#', '', '/'.$short_link); - $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); + $regexp = preg_replace('!\\\.html?\\$#!', '$#', $route['regexp']); preg_match($regexp, $short_link, $kw); if (empty($kw['supplier_rewrite'])) { diff --git a/faktiva_clean_urls/override/classes/Link.php b/faktiva_clean_urls/override/classes/Link.php index e319ba1..d2196bb 100644 --- a/faktiva_clean_urls/override/classes/Link.php +++ b/faktiva_clean_urls/override/classes/Link.php @@ -43,11 +43,11 @@ public function getCategoryLink($category, $alias = null, $id_lang = null, $sele } // Set available keywords - $params = array(); - $params['id'] = $category->id; - $params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias; + $params = array(); + $params['id'] = $category->id; + $params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias; $params['meta_keywords'] = Tools::str2url($category->getFieldByLang('meta_keywords')); - $params['meta_title'] = Tools::str2url($category->getFieldByLang('meta_title')); + $params['meta_title'] = Tools::str2url($category->getFieldByLang('meta_title')); // Selected filters is used by the module blocklayered $selected_filters = is_null($selected_filters) ? '' : $selected_filters; @@ -55,7 +55,7 @@ public function getCategoryLink($category, $alias = null, $id_lang = null, $sele if (empty($selected_filters)) { $rule = 'category_rule'; } else { - $rule = 'layered_rule'; + $rule = 'layered_rule'; $params['selected_filters'] = $selected_filters; } @@ -93,7 +93,7 @@ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, if (!$type && !$id_object) { $method_name = 'get'.Dispatcher::getInstance()->getController().'Link'; if (method_exists($this, $method_name) && isset($_GET['id_'.Dispatcher::getInstance()->getController()])) { - $type = Dispatcher::getInstance()->getController(); + $type = Dispatcher::getInstance()->getController(); $id_object = $_GET['id_'.$type]; } } @@ -109,9 +109,9 @@ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, $url = $this->getPageLink($name); } - $vars = array(); - $vars_nb = array('n', 'search_query'); - $vars_sort = array('orderby', 'orderway'); + $vars = array(); + $vars_nb = array('n', 'search_query'); + $vars_sort = array('orderby', 'orderway'); $vars_pagination = array('p'); foreach ($_GET as $k => $value) { @@ -119,15 +119,15 @@ public function getPaginationLink($type, $id_object, $nb = false, $sort = false, if (Configuration::get('PS_REWRITING_SETTINGS') && ($k == 'isolang' || $k == 'id_lang')) { continue; } - $if_nb = (!$nb || ($nb && !in_array($k, $vars_nb))); - $if_sort = (!$sort || ($sort && !in_array($k, $vars_sort))); + $if_nb = (!$nb || ($nb && !in_array($k, $vars_nb))); + $if_sort = (!$sort || ($sort && !in_array($k, $vars_sort))); $if_pagination = (!$pagination || ($pagination && !in_array($k, $vars_pagination))); if ($if_nb && $if_sort && $if_pagination) { if (!is_array($value)) { $vars[urlencode($k)] = $value; } else { foreach (explode('&', http_build_query(array($k => $value), '', '&')) as $key => $val) { - $data = explode('=', $val); + $data = explode('=', $val); $vars[urldecode($data[0])] = $data[1]; } } diff --git a/faktiva_clean_urls/override/controllers/front/CategoryController.php b/faktiva_clean_urls/override/controllers/front/CategoryController.php index 7c2aed6..39e7d4d 100644 --- a/faktiva_clean_urls/override/controllers/front/CategoryController.php +++ b/faktiva_clean_urls/override/controllers/front/CategoryController.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ @@ -26,10 +26,10 @@ public function init() $sql = 'SELECT `id_category` FROM `'._DB_PREFIX_.'category_lang` WHERE `link_rewrite` = \''.pSQL(str_replace('.html', '', $category_rewrite)).'\' AND `id_lang` = '.Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND `id_shop` = '.(int)Shop::getContextShopID(); + $sql .= ' AND `id_shop` = '.(int) Shop::getContextShopID(); } - $id_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + $id_category = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_category > 0) { $_GET['id_category'] = $id_category; } diff --git a/faktiva_clean_urls/override/controllers/front/ProductController.php b/faktiva_clean_urls/override/controllers/front/ProductController.php index 7c1fd66..2c9f34c 100644 --- a/faktiva_clean_urls/override/controllers/front/ProductController.php +++ b/faktiva_clean_urls/override/controllers/front/ProductController.php @@ -24,7 +24,7 @@ public function init() { if ($product_rewrite = Tools::getValue('product_rewrite')) { $url_id_pattern = '/.*?([0-9]+)\-([a-zA-Z0-9-]*)(\.html)?/'; - $lang_id = (int) Context::getContext()->language->id; + $lang_id = (int) Context::getContext()->language->id; $sql = 'SELECT `id_product` FROM `'._DB_PREFIX_.'product_lang` diff --git a/faktiva_clean_urls/override/controllers/front/SupplierController.php b/faktiva_clean_urls/override/controllers/front/SupplierController.php index 440a9d9..40dab3c 100644 --- a/faktiva_clean_urls/override/controllers/front/SupplierController.php +++ b/faktiva_clean_urls/override/controllers/front/SupplierController.php @@ -13,7 +13,7 @@ * This code is provided as is without any warranty. * No promise of being safe or secure * - * @author AlberT + * @author Emiliano 'AlberT' Gabrielli * @license https://creativecommons.org/licenses/by-sa/4.0/ CC-BY-SA-4.0 * @source https://github.com/faktiva/prestashop-clean-urls */ @@ -28,10 +28,10 @@ public function init() LEFT JOIN `'._DB_PREFIX_.'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`) WHERE sp.`name` LIKE \''.pSQL(str_replace('-', '_', $supplier_rewrite)).'\''; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { - $sql .= ' AND s.`id_shop` = '.(int)Shop::getContextShopID(); + $sql .= ' AND s.`id_shop` = '.(int) Shop::getContextShopID(); } - $id_supplier = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + $id_supplier = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_supplier > 0) { $_GET['id_supplier'] = $id_supplier; } From 72a2da46c681ea7468f7c56e99bacc872c2273c4 Mon Sep 17 00:00:00 2001 From: Emiliano 'AlberT' Gabrielli Date: Tue, 25 Oct 2016 13:31:45 +0200 Subject: [PATCH 174/174] Another update to the SL badge --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 45bab53..0fee7d4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -[PrestaShop module "Clean URLs"](https://github.com/faktiva/prestashop-seo-tk)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/58d1de4f-45fc-4f63-aeb3-7ddc51d4a64e/mini.png)](https://insight.sensiolabs.com/projects/58d1de4f-45fc-4f63-aeb3-7ddc51d4a64e) [![License](https://img.shields.io/packagist/l/faktiva/prestashop-clean-urls.svg?style=flat)](https://creativecommons.org/licenses/by-sa/4.0/) +[![SensioLabsInsight](https://insight.sensiolabs.com/projects/58d1de4f-45fc-4f63-aeb3-7ddc51d4a64e/small.png)](https://insight.sensiolabs.com/projects/58d1de4f-45fc-4f63-aeb3-7ddc51d4a64e) +[PrestaShop module "Clean URLs"](https://github.com/faktiva/prestashop-seo-tk) === [![GitHub release](https://img.shields.io/github/release/faktiva/prestashop-clean-urls.svg?style=plastic&label=latest)](https://github.com/faktiva/prestashop-clean-urls/releases/latest) @@ -7,6 +8,7 @@ [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/faktiva/prestashop-clean-urls.svg)](http://isitmaintained.com/project/faktiva/prestashop-clean-urls "Average time to resolve an issue") [![composer.lock](https://poser.pugx.org/faktiva/prestashop-clean-urls/composerlock)](https://packagist.org/packages/faktiva/prestashop-clean-urls) [![Dependencies Status](https://img.shields.io/librariesio/github/faktiva/prestashop-clean-urls.svg?maxAge=3600)](https://libraries.io/github/faktiva/prestashop-clean-urls) +[![License](https://img.shields.io/packagist/l/faktiva/prestashop-clean-urls.svg?style=flat)](https://creativecommons.org/licenses/by-sa/4.0/) [![Join the chat at https://gitter.im/faktiva/prestashop-clean-urls](https://img.shields.io/badge/Gitter-CHAT%20NOW-brightgreen.svg?style=plastic)](https://gitter.im/faktiva/prestashop-clean-urls) [![Twitter](https://img.shields.io/twitter/url/https/github.com/faktiva/prestashop-clean-urls.svg?style=social)](https://twitter.com/intent/tweet?text=Fantastic @PrestaShop module "#Faktiva Clean URLs"&url=https://github.com/faktiva/prestashop-clean-urls)