From 66eab15a18378063419d2c0f19d9e6cf4e30ca1a Mon Sep 17 00:00:00 2001 From: rMalie Date: Mon, 1 Aug 2011 13:28:02 +0000 Subject: [PATCH] // Routes for dispatcher (part 4) + some fix --- admin-dev/functions.php | 1 - admin-dev/init.php | 3 +- admin-dev/login.php | 6 +- admin-dev/tabs/AdminLanguages.php | 16 +- admin-dev/tabs/AdminPreferences.php | 3 +- admin-dev/tabs/AdminShopUrl.php | 64 ++++--- classes/Cart.php | 2 +- classes/Cookie.php | 2 +- classes/Dispatcher.php | 89 +++++++--- classes/FrontController.php | 4 +- classes/Language.php | 11 ++ classes/Link.php | 39 ++-- classes/Product.php | 2 +- classes/Shop.php | 43 ++--- classes/ShopUrl.php | 27 ++- classes/Tools.php | 205 +++++++++------------- config/config.inc.php | 11 +- install-dev/sql/db.sql | 25 +-- install-dev/sql/upgrade/1.5.0.0.sql | 5 +- modules/blocklanguages/blocklanguages.tpl | 2 +- modules/ganalytics/ganalytics.php | 2 +- 21 files changed, 298 insertions(+), 264 deletions(-) diff --git a/admin-dev/functions.php b/admin-dev/functions.php index a68793d76..a8ccfa83a 100644 --- a/admin-dev/functions.php +++ b/admin-dev/functions.php @@ -75,7 +75,6 @@ function includeDatepicker($id, $time = false) function rewriteSettingsFile($baseUrls = NULL, $theme = NULL, $arrayDB = NULL) { $defines = array(); - $defines['_PS_DIRECTORY_'] = ($baseUrls AND $baseUrls['_PS_DIRECTORY_']) ? $baseUrls['_PS_DIRECTORY_'] : _PS_DIRECTORY_; $defines['_MEDIA_SERVER_1_'] = ($baseUrls AND isset($baseUrls['_MEDIA_SERVER_1_'])) ? $baseUrls['_MEDIA_SERVER_1_'] : _MEDIA_SERVER_1_; $defines['_MEDIA_SERVER_2_'] = ($baseUrls AND isset($baseUrls['_MEDIA_SERVER_2_'])) ? $baseUrls['_MEDIA_SERVER_2_'] : _MEDIA_SERVER_2_; $defines['_MEDIA_SERVER_3_'] = ($baseUrls AND isset($baseUrls['_MEDIA_SERVER_3_'])) ? $baseUrls['_MEDIA_SERVER_3_'] : _MEDIA_SERVER_3_; diff --git a/admin-dev/init.php b/admin-dev/init.php index a2a479631..63e58134f 100644 --- a/admin-dev/init.php +++ b/admin-dev/init.php @@ -34,8 +34,7 @@ if (isset($_GET['logout'])) if (!$cookie->isLoggedBack()) { - $destination = substr($_SERVER['REQUEST_URI'], strlen(dirname($_SERVER['SCRIPT_NAME'])) + 1); - Tools::redirectAdmin('login.php'.(empty($destination) || ($destination == 'index.php?logout') ? '' : '?redirect='.$destination)); + Tools::redirectAdmin('login.php?redirect='.$_SERVER['REQUEST_URI']); } // Set current index diff --git a/admin-dev/login.php b/admin-dev/login.php index e2ff575f5..34550de3b 100644 --- a/admin-dev/login.php +++ b/admin-dev/login.php @@ -51,10 +51,8 @@ if ((empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) == 'off') .'

https://'.Tools::getServerName().$_SERVER['REQUEST_URI'].''; } -$cookie = new Cookie('psAdmin', substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__), -10)); -if (!isset($cookie->id_lang)) - $cookie->id_lang = Configuration::get('PS_LANG_DEFAULT'); -$iso = strtolower(Language::getIsoById((int)($cookie->id_lang))); +$cookie = Context::getContext()->cookie; +$iso = strtolower(Language::getIsoById(Context::getContext()->language->id)); include(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php'); include(_PS_TRANSLATIONS_DIR_.$iso.'/errors.php'); diff --git a/admin-dev/tabs/AdminLanguages.php b/admin-dev/tabs/AdminLanguages.php index 0030353f9..636d5c42d 100644 --- a/admin-dev/tabs/AdminLanguages.php +++ b/admin-dev/tabs/AdminLanguages.php @@ -38,17 +38,19 @@ class AdminLanguages extends AdminTab $this->fieldImageSettings = array(array('name' => 'flag', 'dir' => 'l'), array('name' => 'no-picture', 'dir' => 'p')); $this->fieldsDisplay = array( - 'id_lang' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), - 'flag' => array('title' => $this->l('Logo'), 'align' => 'center', 'image' => 'l', 'orderby' => false, 'search' => false), - 'name' => array('title' => $this->l('Name'), 'width' => 120), - 'iso_code' => array('title' => $this->l('ISO code'), 'width' => 70, 'align' => 'center'), - 'language_code' => array('title' => $this->l('Language code'), 'width' => 70, 'align' => 'center'), - 'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool')); + 'id_lang' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), + 'flag' => array('title' => $this->l('Logo'), 'align' => 'center', 'image' => 'l', 'orderby' => false, 'search' => false), + 'name' => array('title' => $this->l('Name'), 'width' => 120), + 'iso_code' => array('title' => $this->l('ISO code'), 'width' => 70, 'align' => 'center'), + 'language_code' => array('title' => $this->l('Language code'), 'width' => 70, 'align' => 'center'), + 'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool'), + ); $this->optionTitle = $this->l('Languages options'); $this->_fieldsOptions = array( - 'PS_LANG_DEFAULT' => array('title' => $this->l('Default language:'), 'desc' => $this->l('The default language used in shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_lang', 'list' => Language::getlanguages(false)), + 'PS_LANG_DEFAULT' => array('title' => $this->l('Default language:'), 'desc' => $this->l('The default language used in shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_lang', 'list' => Language::getlanguages(false)), ); + $this->_group = 'GROUP BY a.id_lang'; parent::__construct(); } diff --git a/admin-dev/tabs/AdminPreferences.php b/admin-dev/tabs/AdminPreferences.php index c81d3d183..87d169947 100644 --- a/admin-dev/tabs/AdminPreferences.php +++ b/admin-dev/tabs/AdminPreferences.php @@ -172,7 +172,7 @@ class AdminPreferences extends AdminTab { $languages = Language::getLanguages(false); - Tools::clearCache($smarty); + Tools::clearCache($this->context->smarty); /* Check required fields */ foreach ($fields AS $field => $values) @@ -289,7 +289,6 @@ class AdminPreferences extends AdminTab else $tab[$key] = Tools::getValue($key, Configuration::get($key)); } - $tab['_PS_DIRECTORY_'] = _PS_DIRECTORY_; $tab['_MEDIA_SERVER_1_'] = _MEDIA_SERVER_1_; $tab['_MEDIA_SERVER_2_'] = _MEDIA_SERVER_2_; $tab['_MEDIA_SERVER_3_'] = _MEDIA_SERVER_3_; diff --git a/admin-dev/tabs/AdminShopUrl.php b/admin-dev/tabs/AdminShopUrl.php index f69ef3744..4349af5aa 100755 --- a/admin-dev/tabs/AdminShopUrl.php +++ b/admin-dev/tabs/AdminShopUrl.php @@ -34,19 +34,19 @@ class AdminShopUrl extends AdminTab $this->className = 'ShopUrl'; $this->edit = true; $this->delete = true; - $this->_select = 's.name shop_name'; + $this->_select = 's.name AS shop_name, CONCAT(a.physical_uri, a.virtual_uri) AS uri'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'shop` s ON (s.id_shop = a.id_shop)'; $this->_listSkipDelete = array(1); $this->fieldsDisplay = array( - 'id_shop_url' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), - 'domain' => array('title' => $this->l('Domain'), 'width' => 130, 'filter_key' => 'domain'), - 'domain_ssl' => array('title' => $this->l('Domain SSL'), 'width' => 130, 'filter_key' => 'domain'), - 'uri' => array('title' => $this->l('Uri'), 'width' => 130, 'filter_key' => 'uri'), - 'shop_name' => array('title' => $this->l('Shop name'), 'width' => 70), - 'main' => array('title' => $this->l('Main URL'), 'align' => 'center', 'activeVisu' => 'main', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'main'), - 'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'active')); - $this->_fieldsOptions = array('_PS_DIRECTORY_' => array('title' => $this->l('PS directory'), 'desc' => $this->l('Name of the PrestaShop directory on your Web server, bracketed by forward slashes (e.g., /shop/)'), 'validation' => 'isUrl', 'type' => 'text', 'size' => 20, 'default' => _PS_DIRECTORY_, 'visibility' => Shop::CONTEXT_ALL)); + 'id_shop_url' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), + 'domain' => array('title' => $this->l('Domain'), 'width' => 130, 'filter_key' => 'domain'), + 'domain_ssl' => array('title' => $this->l('Domain SSL'), 'width' => 130, 'filter_key' => 'domain'), + 'uri' => array('title' => $this->l('Uri'), 'width' => 130, 'filter_key' => 'uri'), + 'shop_name' => array('title' => $this->l('Shop name'), 'width' => 70), + 'main' => array('title' => $this->l('Main URL'), 'align' => 'center', 'activeVisu' => 'main', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'main'), + 'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'active'), + ); parent::__construct(); } @@ -66,15 +66,6 @@ class AdminShopUrl extends AdminTab Tools::generateHtaccess(dirname(__FILE__).'/../../.htaccess', Configuration::get('PS_REWRITING_SETTINGS'), Configuration::get('PS_HTACCESS_CACHE_CONTROL'), Configuration::get('PS_HTACCESS_SPECIFIC')); } - - if (Tools::isSubmit('submitOptions'.$this->table)) - { - $baseUrls = array(); - if ($_PS_DIRECTORY_ = Tools::getValue('_PS_DIRECTORY_')) - $baseUrls['_PS_DIRECTORY_'] = $_PS_DIRECTORY_; - rewriteSettingsFile($baseUrls, NULL, NULL); - unset($this->_fieldsGeneral['_PS_DIRECTORY_']); - } return parent::postProcess(); } @@ -90,6 +81,30 @@ class AdminShopUrl extends AdminTab if (!($obj = $this->loadObject(true))) return; + + echo << + // + +EOF; echo '
@@ -103,11 +118,20 @@ class AdminShopUrl extends AdminTab
- +
- +

'.$this->l('Folder of your store ex: ipods for http://yourshopname.com/ipods/, leave empty if no folder.').'
'.$this->l('URL Rewrite must be activated to use this feature.').'

+ +
+ +

'.$this->l('Folder of your store ex: ipods for http://yourshopname.com/ipods/, leave empty if no folder.').'
'.$this->l('URL Rewrite must be activated to use this feature.').'

+
+ +
+ +