// Refactoring of shop class with new context Part 2

This commit is contained in:
rMalie
2011-07-13 12:52:09 +00:00
parent 375607f8a5
commit 8981b6aaee
21 changed files with 189 additions and 193 deletions
+56 -57
View File
@@ -38,62 +38,61 @@ if (!$cookie->isLoggedBack())
$destination = substr($_SERVER['REQUEST_URI'], strlen(dirname($_SERVER['SCRIPT_NAME'])) + 1); $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'.(empty($destination) || ($destination == 'index.php?logout') ? '' : '?redirect='.$destination));
} }
else
$currentIndex = $_SERVER['SCRIPT_NAME'].(($tab = Tools::getValue('tab')) ? '?tab='.$tab : '');
if ($back = Tools::getValue('back'))
$currentIndex .= '&back='.urlencode($back);
/* Server Params */
$protocol_link = (Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
$protocol_content = (isset($useSSL) AND $useSSL AND Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
$link = new Link($protocol_link, $protocol_content);
define('_PS_BASE_URL_', Tools::getShopDomain(true));
define('_PS_BASE_URL_SSL_', Tools::getShopDomainSsl(true));
$employee = new Employee((int)$cookie->id_employee);
$cookie->id_lang = (int)$employee->id_lang;
$language = new Language($cookie->id_lang ? $cookie->id_lang : Configuration::get('PS_LANG_DEFAULT'));
$iso = $language->iso_code;
include(_PS_TRANSLATIONS_DIR_.$iso.'/errors.php');
include(_PS_TRANSLATIONS_DIR_.$iso.'/fields.php');
include(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php');
/* attribute id_lang is often needed, so we create a constant for performance reasons */
define('_USER_ID_LANG_', (int)$cookie->id_lang);
$path = dirname(__FILE__).'/themes/';
if (empty($employee->bo_theme) OR !file_exists($path.$employee->bo_theme.'/admin.css'))
{ {
$currentIndex = $_SERVER['SCRIPT_NAME'].(($tab = Tools::getValue('tab')) ? '?tab='.$tab : ''); if (file_exists($path.'oldschool/admin.css'))
if ($back = Tools::getValue('back')) $employee->bo_theme = 'oldschool';
$currentIndex .= '&back='.urlencode($back); elseif (file_exists($path.'origins/admin.css'))
$employee->bo_theme = 'origins';
/* Server Params */ else
$protocol_link = (Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://'; foreach (scandir($path) as $theme)
$protocol_content = (isset($useSSL) AND $useSSL AND Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://'; if ($theme[0] != '.' AND file_exists($path.$theme.'/admin.css'))
$link = new Link($protocol_link, $protocol_content); {
define('_PS_BASE_URL_', Tools::getShopDomain(true)); $employee->bo_theme = $theme;
define('_PS_BASE_URL_SSL_', Tools::getShopDomainSsl(true)); break;
}
$employee = new Employee((int)$cookie->id_employee); $employee->update();
$cookie->id_lang = (int)$employee->id_lang;
$language = new Language($cookie->id_lang ? $cookie->id_lang : Configuration::get('PS_LANG_DEFAULT'));
$iso = $language->iso_code;
include(_PS_TRANSLATIONS_DIR_.$iso.'/errors.php');
include(_PS_TRANSLATIONS_DIR_.$iso.'/fields.php');
include(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php');
/* attribute id_lang is often needed, so we create a constant for performance reasons */
define('_USER_ID_LANG_', (int)$cookie->id_lang);
$path = dirname(__FILE__).'/themes/';
if (empty($employee->bo_theme) OR !file_exists($path.$employee->bo_theme.'/admin.css'))
{
if (file_exists($path.'oldschool/admin.css'))
$employee->bo_theme = 'oldschool';
elseif (file_exists($path.'origins/admin.css'))
$employee->bo_theme = 'origins';
else
foreach (scandir($path) as $theme)
if ($theme[0] != '.' AND file_exists($path.$theme.'/admin.css'))
{
$employee->bo_theme = $theme;
break;
}
$employee->update();
}
// Change shop context ?
if (Tools::isMultiShopActivated() && Tools::getValue('setShopContext') !== false)
{
$cookie->shopContext = Tools::getValue('setShopContext');
$url = parse_url($_SERVER['REQUEST_URI']);
$query = (isset($url['query'])) ? $url['query'] : '';
parse_str($query, $parseQuery);
unset($parseQuery['setShopContext']);
Tools::redirectAdmin($url['path'] . '?' . http_build_query($parseQuery));
}
$context = Context::getContext();
$context->employee = $employee;
$context->cookie = $cookie;
$context->link = $link;
$context->language = $language;
$context->country = new Country(Configuration::get('PS_COUNTRY_DEFAULT'));
} }
// Change shop context ?
if (Tools::isMultiShopActivated() && Tools::getValue('setShopContext') !== false)
{
$cookie->shopContext = Tools::getValue('setShopContext');
$url = parse_url($_SERVER['REQUEST_URI']);
$query = (isset($url['query'])) ? $url['query'] : '';
parse_str($query, $parseQuery);
unset($parseQuery['setShopContext']);
Tools::redirectAdmin($url['path'] . '?' . http_build_query($parseQuery));
}
$context = Context::getContext();
$context->employee = $employee;
$context->cookie = $cookie;
$context->link = $link;
$context->language = $language;
$context->country = new Country(Configuration::get('PS_COUNTRY_DEFAULT'));
$context->shop = new Shop(Shop::getContext('shop', true));
+1 -1
View File
@@ -133,7 +133,7 @@ class AdminMeta extends AdminTab
foreach ($this->_languages as $language) foreach ($this->_languages as $language)
echo ' echo '
<div id="url_rewrite_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;"> <div id="url_rewrite_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
<input style="width:300px" type="text" name="url_rewrite_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($meta, 'url_rewrite', (int)($language['id_lang']), (int)$cookie->id_current_shop), ENT_COMPAT, 'UTF-8').'" /> <input style="width:300px" type="text" name="url_rewrite_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($meta, 'url_rewrite', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span> <span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
<p class="clear" style="width:300px">'.$this->l('Example : "contacts" for http://mysite.com/shop/contacts to redirect to http://mysite.com/shop/contact-form.php').'</p> <p class="clear" style="width:300px">'.$this->l('Example : "contacts" for http://mysite.com/shop/contacts to redirect to http://mysite.com/shop/contact-form.php').'</p>
</div>'; </div>';
+21 -26
View File
@@ -31,8 +31,6 @@ class AdminModulesPositions extends AdminTab
public function postProcess() public function postProcess()
{ {
global $currentIndex;
// Getting key value for display // Getting key value for display
if (Tools::getValue('show_modules') AND strval(Tools::getValue('show_modules')) != 'all') if (Tools::getValue('show_modules') AND strval(Tools::getValue('show_modules')) != 'all')
$this->displayKey = (int)(Tools::getValue('show_modules')); $this->displayKey = (int)(Tools::getValue('show_modules'));
@@ -48,7 +46,7 @@ class AdminModulesPositions extends AdminTab
if (Validate::isLoadedObject($module)) if (Validate::isLoadedObject($module))
{ {
$module->updatePosition($id_hook, (int)(Tools::getValue('direction'))); $module->updatePosition($id_hook, (int)(Tools::getValue('direction')));
Tools::redirectAdmin($currentIndex.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token); Tools::redirectAdmin($this->currentIndex.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
} }
else else
$this->_errors[] = Tools::displayError('module cannot be loaded'); $this->_errors[] = Tools::displayError('module cannot be loaded');
@@ -89,7 +87,7 @@ class AdminModulesPositions extends AdminTab
elseif (!$module->registerExceptions($id_hook, $excepts, Shop::getListFromContext())) elseif (!$module->registerExceptions($id_hook, $excepts, Shop::getListFromContext()))
$this->_errors[] = Tools::displayError('An error occurred while transplanting module to hook.'); $this->_errors[] = Tools::displayError('An error occurred while transplanting module to hook.');
else else
Tools::redirectAdmin($currentIndex.'&conf=16'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token); Tools::redirectAdmin($this->currentIndex.'&conf=16'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
} }
} }
else else
@@ -131,7 +129,7 @@ class AdminModulesPositions extends AdminTab
} }
if (!$this->_errors) if (!$this->_errors)
Tools::redirectAdmin($currentIndex.'&conf=16'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token); Tools::redirectAdmin($this->currentIndex.'&conf=16'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
} }
else else
{ {
@@ -146,7 +144,7 @@ class AdminModulesPositions extends AdminTab
if (!$module->editExceptions($id_hook, $exceptions, Shop::getListFromContext())) if (!$module->editExceptions($id_hook, $exceptions, Shop::getListFromContext()))
$this->_errors[] = Tools::displayError('An error occurred while transplanting module to hook.'); $this->_errors[] = Tools::displayError('An error occurred while transplanting module to hook.');
else else
Tools::redirectAdmin($currentIndex.'&conf=16'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token); Tools::redirectAdmin($this->currentIndex.'&conf=16'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
} }
} }
} }
@@ -172,7 +170,7 @@ class AdminModulesPositions extends AdminTab
if (!$module->unregisterHook($id_hook, Shop::getListFromContext()) OR !$module->unregisterExceptions($id_hook, Shop::getListFromContext())) if (!$module->unregisterHook($id_hook, Shop::getListFromContext()) OR !$module->unregisterExceptions($id_hook, Shop::getListFromContext()))
$this->_errors[] = Tools::displayError('An error occurred while deleting module from hook.'); $this->_errors[] = Tools::displayError('An error occurred while deleting module from hook.');
else else
Tools::redirectAdmin($currentIndex.'&conf=17'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token); Tools::redirectAdmin($this->currentIndex.'&conf=17'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
} }
} }
else else
@@ -202,7 +200,7 @@ class AdminModulesPositions extends AdminTab
} }
} }
if (!sizeof($this->_errors)) if (!sizeof($this->_errors))
Tools::redirectAdmin($currentIndex.'&conf=17'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token); Tools::redirectAdmin($this->currentIndex.'&conf=17'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
} }
} }
} }
@@ -217,9 +215,7 @@ class AdminModulesPositions extends AdminTab
public function displayList() public function displayList()
{ {
global $currentIndex; $context = Context::getContext();
$link = new Link();
$admin_dir = dirname($_SERVER['PHP_SELF']); $admin_dir = dirname($_SERVER['PHP_SELF']);
$admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1); $admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1);
@@ -231,13 +227,13 @@ class AdminModulesPositions extends AdminTab
</script> </script>
<script type="text/javascript" src="../js/admin-dnd.js"></script> <script type="text/javascript" src="../js/admin-dnd.js"></script>
'; ';
echo '<a href="'.$currentIndex.'&addToHook'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token.'"><img src="../img/admin/add.gif" border="0" /> <b>'.$this->l('Transplant a module').'</b></a><br /><br />'; echo '<a href="'.$this->currentIndex.'&addToHook'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token.'"><img src="../img/admin/add.gif" border="0" /> <b>'.$this->l('Transplant a module').'</b></a><br /><br />';
// Print select list // Print select list
echo ' echo '
<form> <form>
'.$this->l('Show').' : '.$this->l('Show').' :
<select id="show_modules" onChange="autoUrl(\'show_modules\', \''.$currentIndex.'&token='.$this->token.'&show_modules=\')"> <select id="show_modules" onChange="autoUrl(\'show_modules\', \''.$this->currentIndex.'&token='.$this->token.'&show_modules=\')">
<option value="all">'.$this->l('All modules').'&nbsp;</option> <option value="all">'.$this->l('All modules').'&nbsp;</option>
<option>---------------</option>'; <option>---------------</option>';
$modules = Module::getModulesInstalled(); $modules = Module::getModulesInstalled();
@@ -253,26 +249,26 @@ class AdminModulesPositions extends AdminTab
echo ' echo '
</select> </select>
<br /><br /> <br /><br />
<input type="checkbox" id="hook_position" onclick="autoUrlNoList(\'hook_position\', \''.$currentIndex.'&token='.$this->token.'&show_modules='.(int)(Tools::getValue('show_modules')).'&hook_position=\')" '.(Tools::getValue('hook_position') ? 'checked="checked" ' : '').' />&nbsp;<label class="t" for="hook_position">'.$this->l('Display non-positionable hook').'</label> <input type="checkbox" id="hook_position" onclick="autoUrlNoList(\'hook_position\', \''.$this->currentIndex.'&token='.$this->token.'&show_modules='.(int)(Tools::getValue('show_modules')).'&hook_position=\')" '.(Tools::getValue('hook_position') ? 'checked="checked" ' : '').' />&nbsp;<label class="t" for="hook_position">'.$this->l('Display non-positionable hook').'</label>
</form> </form>
<fieldset style="width:250px;float:right"><legend>'.$this->l('Live edit').'</legend>'; <fieldset style="width:250px;float:right"><legend>'.$this->l('Live edit').'</legend>';
if (Tools::isMultiShopActivated() && Shop::getContextType() != Shop::CONTEXT_SHOP) if (Tools::isMultiShopActivated() && $context->shop->getContextType() != Shop::CONTEXT_SHOP)
echo '<p>'.$this->l('You have to select a shop to use live edit').'</p>'; echo '<p>'.$this->l('You have to select a shop to use live edit').'</p>';
else else
echo '<p>'.$this->l('By clicking here you will be redirected to the front office of your shop to move and delete modules directly.').'</p> echo '<p>'.$this->l('By clicking here you will be redirected to the front office of your shop to move and delete modules directly.').'</p>
<br> <br>
<a href="'.$link->getPageLink('index').'&live_edit&ad='.$admin_dir.'&liveToken='.sha1($admin_dir._COOKIE_KEY_).((Tools::isMultiShopActivated()) ? '&id_shop='.Context::getContext()->shop->getID() : '').'" target="_blank" class="button">'.$this->l('Run LiveEdit').'</a>'; <a href="'.$context->link->getPageLink('index').'&live_edit&ad='.$admin_dir.'&liveToken='.sha1($admin_dir._COOKIE_KEY_).((Tools::isMultiShopActivated()) ? '&id_shop='.Context::getContext()->shop->getID() : '').'" target="_blank" class="button">'.$this->l('Run LiveEdit').'</a>';
echo '</fieldset>'; echo '</fieldset>';
// Print hook list // Print hook list
echo '<form method="post" action="'.$currentIndex.'&token='.$this->token.'">'; echo '<form method="post" action="'.$this->currentIndex.'&token='.$this->token.'">';
$irow = 0; $irow = 0;
$hooks = Hook::getHooks(!(int)(Tools::getValue('hook_position'))); $hooks = Hook::getHooks(!(int)(Tools::getValue('hook_position')));
echo '<div id="unhook_button_position_top"><input class="button floatr" type="submit" name="unhookform" value="'.$this->l('Unhook the selection').'"/></div>'; echo '<div id="unhook_button_position_top"><input class="button floatr" type="submit" name="unhookform" value="'.$this->l('Unhook the selection').'"/></div>';
$canMove = (Tools::isMultiShopActivated() && Shop::getContextType() != Shop::CONTEXT_SHOP) ? false : true; $canMove = (Tools::isMultiShopActivated() && $context->shop->getContextType() != Shop::CONTEXT_SHOP) ? false : true;
if (!$canMove) if (!$canMove)
echo '<br /><div><b>'.$this->l('If you want to order / move following data, please go in shop context (select a shop in shop list)').'</b></div>'; echo '<br /><div><b>'.$this->l('If you want to order / move following data, please go in shop context (select a shop in shop list)').'</b></div>';
foreach ($hooks AS $hook) foreach ($hooks AS $hook)
@@ -307,8 +303,8 @@ class AdminModulesPositions extends AdminTab
echo ' echo '
<td class="positions" width="40">'.(int)($position).'</td> <td class="positions" width="40">'.(int)($position).'</td>
<td'.(($canMove && $nbModules >= 2) ? ' class="dragHandle"' : '').' id="td_'.$hook['id_hook'].'_'.$instance->id.'" width="40"> <td'.(($canMove && $nbModules >= 2) ? ' class="dragHandle"' : '').' id="td_'.$hook['id_hook'].'_'.$instance->id.'" width="40">
'.(($canMove) ? '<a'.($position == 1 ? ' style="display: none;"' : '' ).' href="'.$currentIndex.'&id_module='.$instance->id.'&id_hook='.$hook['id_hook'].'&direction=0&token='.$this->token.'&changePosition='.rand().'#'.$hook['name'].'"><img src="../img/admin/up.gif" alt="'.$this->l('Up').'" title="'.$this->l('Up').'" /></a><br /> '.(($canMove) ? '<a'.($position == 1 ? ' style="display: none;"' : '' ).' href="'.$this->currentIndex.'&id_module='.$instance->id.'&id_hook='.$hook['id_hook'].'&direction=0&token='.$this->token.'&changePosition='.rand().'#'.$hook['name'].'"><img src="../img/admin/up.gif" alt="'.$this->l('Up').'" title="'.$this->l('Up').'" /></a><br />
<a '.($position == count($instances) ? ' style="display: none;"' : '').'href="'.$currentIndex.'&id_module='.$instance->id.'&id_hook='.$hook['id_hook'].'&direction=1&token='.$this->token.'&changePosition='.rand().'#'.$hook['name'].'"><img src="../img/admin/down.gif" alt="'.$this->l('Down').'" title="'.$this->l('Down').'" /></a>' : '').' <a '.($position == count($instances) ? ' style="display: none;"' : '').'href="'.$this->currentIndex.'&id_module='.$instance->id.'&id_hook='.$hook['id_hook'].'&direction=1&token='.$this->token.'&changePosition='.rand().'#'.$hook['name'].'"><img src="../img/admin/down.gif" alt="'.$this->l('Down').'" title="'.$this->l('Down').'" /></a>' : '').'
</td> </td>
<td style="padding-left: 10px;"><label class="lab_modules_positions" for="mod'.$hook['id_hook'].'_'.$instance->id.'"> <td style="padding-left: 10px;"><label class="lab_modules_positions" for="mod'.$hook['id_hook'].'_'.$instance->id.'">
'; ';
@@ -321,8 +317,8 @@ class AdminModulesPositions extends AdminTab
</label></td> </label></td>
<td width="60">'; <td width="60">';
echo ' echo '
<a href="'.$currentIndex.'&id_module='.$instance->id.'&id_hook='.$hook['id_hook'].'&editGraft'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token.'"><img src="../img/admin/edit.gif" border="0" alt="'.$this->l('Edit').'" title="'.$this->l('Edit').'" /></a> <a href="'.$this->currentIndex.'&id_module='.$instance->id.'&id_hook='.$hook['id_hook'].'&editGraft'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token.'"><img src="../img/admin/edit.gif" border="0" alt="'.$this->l('Edit').'" title="'.$this->l('Edit').'" /></a>
<a href="'.$currentIndex.'&id_module='.$instance->id.'&id_hook='.$hook['id_hook'].'&deleteGraft'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token.'"><img src="../img/admin/delete.gif" border="0" alt="'.$this->l('Delete').'" title="'.$this->l('Delete').'" /></a> <a href="'.$this->currentIndex.'&id_module='.$instance->id.'&id_hook='.$hook['id_hook'].'&deleteGraft'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token.'"><img src="../img/admin/delete.gif" border="0" alt="'.$this->l('Delete').'" title="'.$this->l('Delete').'" /></a>
<input type="checkbox" id="mod'.$hook['id_hook'].'_'.$instance->id.'" class="hook'.$hook['id_hook'].'" onclick="hookCheckboxes('.$hook['id_hook'].', 1, this)" name="unhooks[]" value="'.$hook['id_hook'].'_'.$instance->id.'"/>'; <input type="checkbox" id="mod'.$hook['id_hook'].'_'.$instance->id.'" class="hook'.$hook['id_hook'].'" onclick="hookCheckboxes('.$hook['id_hook'].', 1, this)" name="unhooks[]" value="'.$hook['id_hook'].'_'.$instance->id.'"/>';
echo ' echo '
</td> </td>
@@ -337,7 +333,6 @@ class AdminModulesPositions extends AdminTab
public function displayForm($isMainTab = true) public function displayForm($isMainTab = true)
{ {
global $currentIndex;
parent::displayForm(); parent::displayForm();
$id_module = (int)(Tools::getValue('id_module')); $id_module = (int)(Tools::getValue('id_module'));
@@ -346,7 +341,7 @@ class AdminModulesPositions extends AdminTab
{ {
// Check auth for this page // Check auth for this page
if (!$id_module || !$id_hook) if (!$id_module || !$id_hook)
Tools::redirectAdmin($currentIndex . '&token='.$this->token); Tools::redirectAdmin($this->currentIndex . '&token='.$this->token);
$sql = 'SELECT id_module $sql = 'SELECT id_module
FROM '._DB_PREFIX_.'hook_module FROM '._DB_PREFIX_.'hook_module
@@ -354,7 +349,7 @@ class AdminModulesPositions extends AdminTab
AND id_hook = '.$id_hook.' AND id_hook = '.$id_hook.'
AND id_shop IN('.implode(', ', ShopCore::getListFromContext()).')'; AND id_shop IN('.implode(', ', ShopCore::getListFromContext()).')';
if (!Db::getInstance()->getValue($sql)) if (!Db::getInstance()->getValue($sql))
Tools::redirectAdmin($currentIndex . '&token='.$this->token); Tools::redirectAdmin($this->currentIndex . '&token='.$this->token);
$slModule = Module::getInstanceById($id_module); $slModule = Module::getInstanceById($id_module);
$exceptsList = $slModule->getExceptions($id_hook, true); $exceptsList = $slModule->getExceptions($id_hook, true);
@@ -386,7 +381,7 @@ class AdminModulesPositions extends AdminTab
$modules = $instances; $modules = $instances;
$hooks = Hook::getHooks(0); $hooks = Hook::getHooks(0);
echo ' echo '
<form action="'.$currentIndex.'&token='.$this->token.'" method="post">'; <form action="'.$this->currentIndex.'&token='.$this->token.'" method="post">';
if ($this->displayKey) if ($this->displayKey)
echo '<input type="hidden" name="show_modules" value="'.$this->displayKey.'" />'; echo '<input type="hidden" name="show_modules" value="'.$this->displayKey.'" />';
echo '<fieldset style="width:700px"><legend><img src="../img/t/AdminModulesPositions.gif" />'.$this->l('Transplant a module').'</legend> echo '<fieldset style="width:700px"><legend><img src="../img/t/AdminModulesPositions.gif" />'.$this->l('Transplant a module').'</legend>
+9 -17
View File
@@ -29,14 +29,13 @@ class AdminPreferences extends AdminTab
{ {
public function __construct() public function __construct()
{ {
global $cookie; $context = Context::getContext();
$this->className = 'Configuration'; $this->className = 'Configuration';
$this->table = 'configuration'; $this->table = 'configuration';
$timezones = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT name FROM '._DB_PREFIX_.'timezone'); $timezones = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT name FROM '._DB_PREFIX_.'timezone');
$taxes[] = array('id' => 0, 'name' => $this->l('None')); $taxes[] = array('id' => 0, 'name' => $this->l('None'));
foreach (Tax::getTaxes((int)($cookie->id_lang)) as $tax) foreach (Tax::getTaxes($context->language->id) as $tax)
$taxes[] = array('id' => $tax['id_tax'], 'name' => $tax['name']); $taxes[] = array('id' => $tax['id_tax'], 'name' => $tax['name']);
$order_process_type = array( $order_process_type = array(
@@ -71,7 +70,7 @@ class AdminPreferences extends AdminTab
'name' => $this->l('None') 'name' => $this->l('None')
) )
); );
foreach (CMS::listCms($cookie->id_lang) as $cms_file) foreach (CMS::listCms($context->language->id) as $cms_file)
$cms_tab[] = array('id' => $cms_file['id_cms'], 'name' => $cms_file['meta_title']); $cms_tab[] = array('id' => $cms_file['id_cms'], 'name' => $cms_file['meta_title']);
$this->_fieldsGeneral = array( $this->_fieldsGeneral = array(
@@ -117,8 +116,6 @@ class AdminPreferences extends AdminTab
public function postProcess() public function postProcess()
{ {
global $currentIndex;
if (isset($_POST['submitGeneral'.$this->table])) if (isset($_POST['submitGeneral'.$this->table]))
{ {
Module::hookExec('categoryUpdate'); // We call this hook, for regenerate cache of categories Module::hookExec('categoryUpdate'); // We call this hook, for regenerate cache of categories
@@ -152,7 +149,7 @@ class AdminPreferences extends AdminTab
if ($val = Tools::getValue('PS_THEME')) if ($val = Tools::getValue('PS_THEME'))
{ {
if (rewriteSettingsFile(NULL, $val, NULL)) if (rewriteSettingsFile(NULL, $val, NULL))
Tools::redirectAdmin($currentIndex.'&conf=6'.'&token='.$this->token); Tools::redirectAdmin($this->currentIndex.'&conf=6'.'&token='.$this->token);
else else
$this->_errors[] = Tools::displayError('Cannot access settings file.'); $this->_errors[] = Tools::displayError('Cannot access settings file.');
} }
@@ -169,12 +166,10 @@ class AdminPreferences extends AdminTab
* Update settings in database and configuration files * Update settings in database and configuration files
* *
* @params array $fields Fields settings * @params array $fields Fields settings
*
* @global string $currentIndex Current URL in order to keep current Tab
*/ */
protected function _postConfig($fields) protected function _postConfig($fields)
{ {
global $currentIndex, $smarty; global $smarty;
$languages = Language::getLanguages(false); $languages = Language::getLanguages(false);
if (!Configuration::get('PS_FORCE_SMARTY_2')) if (!Configuration::get('PS_FORCE_SMARTY_2'))
@@ -282,7 +277,7 @@ class AdminPreferences extends AdminTab
if (!sizeof($this->_errors)) if (!sizeof($this->_errors))
{ {
$this->submitConfiguration($fields); $this->submitConfiguration($fields);
Tools::redirectAdmin($currentIndex.'&conf=6'.'&token='.$this->token); Tools::redirectAdmin($this->currentIndex.'&conf=6'.'&token='.$this->token);
} }
} }
} }
@@ -330,13 +325,10 @@ class AdminPreferences extends AdminTab
* *
* @params string $name Form name * @params string $name Form name
* @params array $fields Fields settings * @params array $fields Fields settings
*
* @global string $currentIndex Current URL in order to keep current Tab
*/ */
protected function _displayForm($name, $fields, $tabname, $size, $icon) protected function _displayForm($name, $fields, $tabname, $size, $icon)
{ {
global $currentIndex; $context = Context::getContext();
$defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT')); $defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT'));
$languages = Language::getLanguages(false); $languages = Language::getLanguages(false);
$confValues = $this->getConf($fields, $languages); $confValues = $this->getConf($fields, $languages);
@@ -355,7 +347,7 @@ class AdminPreferences extends AdminTab
$(\'input[name=PS_MAINTENANCE_IP]\').attr(\'value\',\''.Tools::getRemoteAddr().'\'); $(\'input[name=PS_MAINTENANCE_IP]\').attr(\'value\',\''.Tools::getRemoteAddr().'\');
} }
</script> </script>
<form action="'.$currentIndex.'&submit'.$name.$this->table.'=1&token='.$this->token.'" method="post" enctype="multipart/form-data"> <form action="'.$this->currentIndex.'&submit'.$name.$this->table.'=1&token='.$this->token.'" method="post" enctype="multipart/form-data">
<fieldset><legend><img src="../img/admin/'.strval($icon).'.gif" />'.$tabname.'</legend>'; <fieldset><legend><img src="../img/admin/'.strval($icon).'.gif" />'.$tabname.'</legend>';
foreach ($fields AS $key => $field) foreach ($fields AS $key => $field)
{ {
@@ -376,7 +368,7 @@ class AdminPreferences extends AdminTab
echo '<div class="margin-form" style="padding-top:5px;">'; echo '<div class="margin-form" style="padding-top:5px;">';
} }
$isDisabled = (isset($field['visibility']) && $field['visibility'] > Shop::getContextType()) ? true : false; $isDisabled = (isset($field['visibility']) && $field['visibility'] > $context->shop->getContextType()) ? true : false;
/* Display the appropriate input type for each field */ /* Display the appropriate input type for each field */
switch ($field['type']) switch ($field['type'])
+22 -21
View File
@@ -141,6 +141,8 @@ abstract class AdminTabCore
/** @var string specificConfirmDelete */ /** @var string specificConfirmDelete */
public $specificConfirmDelete = NULL; public $specificConfirmDelete = NULL;
public $currentIndex = '';
protected $identifiersDnd = array('id_product' => 'id_product', 'id_category' => 'id_category_to_move','id_cms_category' => 'id_cms_category_to_move', 'id_cms' => 'id_cms'); protected $identifiersDnd = array('id_product' => 'id_product', 'id_category' => 'id_category_to_move','id_cms_category' => 'id_cms_category_to_move', 'id_cms' => 'id_cms');
/** @var bool Redirect or not ater a creation */ /** @var bool Redirect or not ater a creation */
@@ -1692,21 +1694,22 @@ abstract class AdminTabCore
*/ */
public function displayOptionsList() public function displayOptionsList()
{ {
global $currentIndex, $cookie, $tab; global $tab;
$context = Context::getContext();
if (!isset($this->_fieldsOptions) OR !sizeof($this->_fieldsOptions)) if (!isset($this->_fieldsOptions) OR !sizeof($this->_fieldsOptions))
return false; return false;
$defaultLanguage = (int)Configuration::get('PS_LANG_DEFAULT'); $defaultLanguage = (int)Configuration::get('PS_LANG_DEFAULT');
$this->_languages = Language::getLanguages(false); $this->_languages = Language::getLanguages(false);
$tab = Tab::getTab((int)$cookie->id_lang, Tab::getIdFromClassName($tab)); $tab = Tab::getTab($context->language->id, Tab::getIdFromClassName($tab));
echo '<br /><br />'; echo '<br /><br />';
echo (isset($this->optionTitle) ? '<h2>'.$this->optionTitle.'</h2>' : ''); echo (isset($this->optionTitle) ? '<h2>'.$this->optionTitle.'</h2>' : '');
echo ' echo '
<script type="text/javascript"> <script type="text/javascript">
id_language = Number('.$defaultLanguage.'); id_language = Number('.$defaultLanguage.');
</script> </script>
<form action="'.$currentIndex.'" id="'.$tab['name'].'" name="'.$tab['name'].'" method="post"> <form action="'.$this->currentIndex.'" id="'.$tab['name'].'" name="'.$tab['name'].'" method="post">
<fieldset>'; <fieldset>';
echo (isset($this->optionTitle) ? '<legend> echo (isset($this->optionTitle) ? '<legend>
<img src="'.(!empty($tab['module']) && file_exists($_SERVER['DOCUMENT_ROOT']._MODULE_DIR_.$tab['module'].'/'.$tab['class_name'].'.gif') ? _MODULE_DIR_.$tab['module'].'/' : '../img/t/').$tab['class_name'].'.gif" />' <img src="'.(!empty($tab['module']) && file_exists($_SERVER['DOCUMENT_ROOT']._MODULE_DIR_.$tab['module'].'/'.$tab['class_name'].'.gif') ? _MODULE_DIR_.$tab['module'].'/' : '../img/t/').$tab['class_name'].'.gif" />'
@@ -1719,7 +1722,7 @@ abstract class AdminTabCore
if (!Validate::isCleanHtml($val)) if (!Validate::isCleanHtml($val))
$val = Configuration::get($key); $val = Configuration::get($key);
$isDisabled = (isset($field['visibility']) && $field['visibility'] > Shop::getContextType()) ? true : false; $isDisabled = (isset($field['visibility']) && $field['visibility'] > $context->shop->getContextType()) ? true : false;
echo $this->getHtmlDefaultConfigurationValue($key, $this->_languages); echo $this->getHtmlDefaultConfigurationValue($key, $this->_languages);
echo '<label>'.$field['title'].' </label> echo '<label>'.$field['title'].' </label>
@@ -2002,8 +2005,6 @@ abstract class AdminTabCore
protected function warnDomainName() protected function warnDomainName()
{ {
global $currentIndex;
if ($_SERVER['HTTP_HOST'] != Configuration::get('PS_SHOP_DOMAIN') AND $_SERVER['HTTP_HOST'] != Configuration::get('PS_SHOP_DOMAIN_SSL')) if ($_SERVER['HTTP_HOST'] != Configuration::get('PS_SHOP_DOMAIN') AND $_SERVER['HTTP_HOST'] != Configuration::get('PS_SHOP_DOMAIN_SSL'))
$this->displayWarning($this->l('Your are currently connected with the following domain name:').' <span style="color: #CC0000;">'.$_SERVER['HTTP_HOST'].'</span><br />'. $this->displayWarning($this->l('Your are currently connected with the following domain name:').' <span style="color: #CC0000;">'.$_SERVER['HTTP_HOST'].'</span><br />'.
$this->l('This one is different from the main shop domain name set in "Preferences > SEO & URLs":').' <span style="color: #CC0000;">'.Configuration::get('PS_SHOP_DOMAIN').'</span><br /> $this->l('This one is different from the main shop domain name set in "Preferences > SEO & URLs":').' <span style="color: #CC0000;">'.Configuration::get('PS_SHOP_DOMAIN').'</span><br />
@@ -2013,15 +2014,15 @@ abstract class AdminTabCore
protected function displayAssoShop($field_name = 'name') protected function displayAssoShop($field_name = 'name')
{ {
global $currentIndex, $cookie; $context = Context::getContext();
if (!Tools::isMultiShopActivated() || (!$this->_object && Shop::getContextType() != Shop::CONTEXT_ALL)) if (!Tools::isMultiShopActivated() || (!$this->_object && $context->shop->getContextType() != Shop::CONTEXT_ALL))
return; return;
$shops = Shop::getShops(); $shops = Shop::getShops();
$objects = Db::getInstance()->ExecuteS('SELECT DISTINCT a.`'.pSQL($this->identifier).'`, '.(($this->lang AND isset($this->fieldsDisplay[$field_name]['filter_key']) AND $this->fieldsDisplay[$field_name]['filter_key'] == 'b!'.$field_name) ? 'b' : 'a').'.`'.pSQL($field_name).'` $objects = Db::getInstance()->ExecuteS('SELECT DISTINCT a.`'.pSQL($this->identifier).'`, '.(($this->lang AND isset($this->fieldsDisplay[$field_name]['filter_key']) AND $this->fieldsDisplay[$field_name]['filter_key'] == 'b!'.$field_name) ? 'b' : 'a').'.`'.pSQL($field_name).'`
FROM `'._DB_PREFIX_.pSQL($this->table).'`a '. FROM `'._DB_PREFIX_.pSQL($this->table).'`a '.
(($this->lang AND isset($this->fieldsDisplay[$field_name]['filter_key']) AND $this->fieldsDisplay[$field_name]['filter_key'] == 'b!'.$field_name) ? ' LEFT JOIN `'._DB_PREFIX_.pSQL($this->table).'_lang` b ON (a.`'.pSQL($this->identifier).'`=b.`'.pSQL($this->identifier).'`)' : ''). (($this->lang AND isset($this->fieldsDisplay[$field_name]['filter_key']) AND $this->fieldsDisplay[$field_name]['filter_key'] == 'b!'.$field_name) ? ' LEFT JOIN `'._DB_PREFIX_.pSQL($this->table).'_lang` b ON (a.`'.pSQL($this->identifier).'`=b.`'.pSQL($this->identifier).'`)' : '').
' WHERE 1'.(($this->lang AND isset($this->fieldsDisplay[$field_name]['filter_key']) AND $this->fieldsDisplay[$field_name]['filter_key'] == 'b!'.$field_name) ? ' AND b.id_lang='.(int)$cookie->id_lang : '').($this->_object ? ' AND a.`'.pSQL($this->identifier).'`='.(int)$this->_object->id : '')); ' WHERE 1'.(($this->lang AND isset($this->fieldsDisplay[$field_name]['filter_key']) AND $this->fieldsDisplay[$field_name]['filter_key'] == 'b!'.$field_name) ? ' AND b.id_lang='.(int)$context->language->id : '').($this->_object ? ' AND a.`'.pSQL($this->identifier).'`='.(int)$this->_object->id : ''));
$assos = array(); $assos = array();
$res = Db::getInstance()->ExecuteS('SELECT id_shop, `'.pSQL($this->identifier).'` $res = Db::getInstance()->ExecuteS('SELECT id_shop, `'.pSQL($this->identifier).'`
FROM `'._DB_PREFIX_.pSQL($this->table).'_shop`'); FROM `'._DB_PREFIX_.pSQL($this->table).'_shop`');
@@ -2032,7 +2033,7 @@ abstract class AdminTabCore
{ {
$html = ' $html = '
<table cellpadding="0" cellspacing="0" class="table"> <table cellpadding="0" cellspacing="0" class="table">
<form name="updateAssoShop" action="'.$currentIndex.'&submitFields'.$this->table.'=1&token='.$this->token.'" method="post"> <form name="updateAssoShop" action="'.$this->currentIndex.'&submitFields'.$this->table.'=1&token='.$this->token.'" method="post">
<input type="hidden" name="assoShopClass" value="'.$this->className.'" /> <input type="hidden" name="assoShopClass" value="'.$this->className.'" />
<tr> <tr>
<th style="width: 200px">'.$this->l('Shop association').'</th>'; <th style="width: 200px">'.$this->l('Shop association').'</th>';
@@ -2074,15 +2075,14 @@ abstract class AdminTabCore
protected function displayAssoGroupShop($field_name = 'name') protected function displayAssoGroupShop($field_name = 'name')
{ {
global $currentIndex, $cookie; $context = Context::getContext();
if (!Tools::isMultiShopActivated() || (!$this->_object && $context->shop->getContextType() != Shop::CONTEXT_ALL))
if (!Tools::isMultiShopActivated() || (!$this->_object && Shop::getContextType() != Shop::CONTEXT_ALL))
return; return;
$objects = Db::getInstance()->ExecuteS('SELECT DISTINCT a.`'.pSQL($this->identifier).'`, '.(($this->lang AND isset($this->fieldsDisplay[$field_name]['filter_key']) AND $this->fieldsDisplay[$field_name]['filter_key'] == 'b!'.$field_name) ? 'b' : 'a').'.`'.pSQL($field_name).'` $objects = Db::getInstance()->ExecuteS('SELECT DISTINCT a.`'.pSQL($this->identifier).'`, '.(($this->lang AND isset($this->fieldsDisplay[$field_name]['filter_key']) AND $this->fieldsDisplay[$field_name]['filter_key'] == 'b!'.$field_name) ? 'b' : 'a').'.`'.pSQL($field_name).'`
FROM `'._DB_PREFIX_.pSQL($this->table).'` a'. FROM `'._DB_PREFIX_.pSQL($this->table).'` a'.
(($this->lang AND isset($this->fieldsDisplay[$field_name]['filter_key']) AND $this->fieldsDisplay[$field_name]['filter_key'] == 'b!'.$field_name) ? ' LEFT JOIN `'._DB_PREFIX_.pSQL($this->table).'_lang` b ON (a.`'.pSQL($this->identifier).'`=b.`'.pSQL($this->identifier).'`)' : ''). (($this->lang AND isset($this->fieldsDisplay[$field_name]['filter_key']) AND $this->fieldsDisplay[$field_name]['filter_key'] == 'b!'.$field_name) ? ' LEFT JOIN `'._DB_PREFIX_.pSQL($this->table).'_lang` b ON (a.`'.pSQL($this->identifier).'`=b.`'.pSQL($this->identifier).'`)' : '').
' WHERE 1'.(($this->lang AND isset($this->fieldsDisplay[$field_name]['filter_key']) AND $this->fieldsDisplay[$field_name]['filter_key'] == 'b!'.$field_name) ? ' AND b.id_lang='.(int)$cookie->id_lang : '').($this->_object ? ' AND a.`'.pSQL($this->identifier).'`='.(int)$this->_object->id : '')); ' WHERE 1'.(($this->lang AND isset($this->fieldsDisplay[$field_name]['filter_key']) AND $this->fieldsDisplay[$field_name]['filter_key'] == 'b!'.$field_name) ? ' AND b.id_lang='.(int)$context->language->id : '').($this->_object ? ' AND a.`'.pSQL($this->identifier).'`='.(int)$this->_object->id : ''));
$groups_shop = GroupShop::getGroupShops(); $groups_shop = GroupShop::getGroupShops();
$assos = array(); $assos = array();
$res = Db::getInstance()->ExecuteS('SELECT id_group_shop, `'.pSQL($this->identifier).'` $res = Db::getInstance()->ExecuteS('SELECT id_group_shop, `'.pSQL($this->identifier).'`
@@ -2091,7 +2091,7 @@ abstract class AdminTabCore
$assos[$row['id_group_shop']][] = $row[$this->identifier]; $assos[$row['id_group_shop']][] = $row[$this->identifier];
if (!$this->_object) if (!$this->_object)
{ {
$html = '<form name="updateAssoGroupShop" action="'.$currentIndex.'&submitFields'.$this->table.'=1&token='.$this->token.'" method="post"> $html = '<form name="updateAssoGroupShop" action="'.$this->currentIndex.'&submitFields'.$this->table.'=1&token='.$this->token.'" method="post">
<input type="hidden" name="assoGroupShopClass" value="'.$this->className.'" /> <input type="hidden" name="assoGroupShopClass" value="'.$this->className.'" />
<table cellpadding="0" cellspacing="0" class="table"> <table cellpadding="0" cellspacing="0" class="table">
<tr> <tr>
@@ -2157,21 +2157,22 @@ abstract class AdminTabCore
*/ */
protected function getHtmlDefaultConfigurationValue($key, $languages) protected function getHtmlDefaultConfigurationValue($key, $languages)
{ {
$context = Context::getContext();
if (Configuration::isLangKey($key)) if (Configuration::isLangKey($key))
{ {
$testContext = false; $testContext = false;
foreach ($languages as $lang) foreach ($languages as $lang)
if ((Shop::getContextType() == Shop::CONTEXT_SHOP && Configuration::hasContext($key, $lang['id_lang'], Shop::CONTEXT_SHOP)) if (($context->shop->getContextType() == Shop::CONTEXT_SHOP && Configuration::hasContext($key, $lang['id_lang'], Shop::CONTEXT_SHOP))
|| (Shop::getContextType() == Shop::CONTEXT_GROUP && Configuration::hasContext($key, $lang['id_lang'], Shop::CONTEXT_GROUP))) || ($context->shop->getContextType() == Shop::CONTEXT_GROUP && Configuration::hasContext($key, $lang['id_lang'], Shop::CONTEXT_GROUP)))
$testContext = true; $testContext = true;
} }
else else
{ {
$testContext = ((Shop::getContextType() == Shop::CONTEXT_SHOP && Configuration::hasContext($key, null, Shop::CONTEXT_SHOP)) $testContext = (($context->shop->getContextType() == Shop::CONTEXT_SHOP && Configuration::hasContext($key, null, Shop::CONTEXT_SHOP))
|| (Shop::getContextType() == Shop::CONTEXT_GROUP && Configuration::hasContext($key, null, Shop::CONTEXT_GROUP))) ? true : false; || ($context->shop->getContextType() == Shop::CONTEXT_GROUP && Configuration::hasContext($key, null, Shop::CONTEXT_GROUP))) ? true : false;
} }
if (Tools::isMultiShopActivated() && Shop::getContextType() != Shop::CONTEXT_ALL && $testContext) if (Tools::isMultiShopActivated() && $context->shop->getContextType() != Shop::CONTEXT_ALL && $testContext)
{ {
echo '<div class="multishop_config">'; echo '<div class="multishop_config">';
echo '<a href="#" title="'.$this->l('Click here to use default value for this field').'"><img src="../img/admin/multishop_config.png" /></a>'; echo '<a href="#" title="'.$this->l('Click here to use default value for this field').'"><img src="../img/admin/multishop_config.png" /></a>';
@@ -2192,7 +2193,7 @@ abstract class AdminTabCore
$languages = Language::getLanguages(false); $languages = Language::getLanguages(false);
foreach ($fields as $key => $options) foreach ($fields as $key => $options)
{ {
if (isset($options['visibility']) && $options['visibility'] > Shop::getContextType()) if (isset($options['visibility']) && $options['visibility'] > Context::getContext()->shop->getContextType())
continue; continue;
if (Tools::isMultiShopActivated() && isset($_POST['configUseDefault'][$key])) if (Tools::isMultiShopActivated() && isset($_POST['configUseDefault'][$key]))
+1 -2
View File
@@ -579,9 +579,8 @@ class CategoryCore extends ObjectModel
if (!$id_shop) if (!$id_shop)
$id_shop = Configuration::get('PS_SHOP_DEFAULT'); $id_shop = Configuration::get('PS_SHOP_DEFAULT');
$shop = new Shop((int)$id_shop); $shop = new Shop((int)$id_shop);
$id_category = $shop->getRootCategory();
return new Category ((int)$id_category, is_null($id_lang) ? (int)_USER_ID_LANG_ : (int)($id_lang)); return new Category ((int)$shop->id_category, is_null($id_lang) ? (int)_USER_ID_LANG_ : (int)($id_lang));
} }
/** /**
+3 -3
View File
@@ -372,7 +372,7 @@ class ConfigurationCore extends ObjectModel
*/ */
public static function deleteFromContext($key) public static function deleteFromContext($key)
{ {
list($shopID, $shopGroupID) = Shop::retrieveContext(); list($shopID, $shopGroupID) = Shop::getContext();
if (!$shopID && !$shopGroupID) if (!$shopID && !$shopGroupID)
return; return;
@@ -395,7 +395,7 @@ class ConfigurationCore extends ObjectModel
*/ */
public static function hasContext($key, $langID, $context) public static function hasContext($key, $langID, $context)
{ {
list($shopID, $shopGroupID) = Shop::retrieveContext(); list($shopID, $shopGroupID) = Shop::getContext();
if ($context == Shop::CONTEXT_SHOP && Configuration::hasKey($key, $langID, null, $shopID)) if ($context == Shop::CONTEXT_SHOP && Configuration::hasKey($key, $langID, null, $shopID))
return true; return true;
else if ($context == Shop::CONTEXT_GROUP && Configuration::hasKey($key, $langID, $shopGroupID)) else if ($context == Shop::CONTEXT_GROUP && Configuration::hasKey($key, $langID, $shopGroupID))
@@ -424,7 +424,7 @@ class ConfigurationCore extends ObjectModel
*/ */
protected static function getShopFromContext(&$id_group_shop, &$id_shop) protected static function getShopFromContext(&$id_group_shop, &$id_shop)
{ {
list($shopID, $shopGroupID) = Shop::retrieveContext(); list($shopID, $shopGroupID) = Shop::getContext();
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = $shopID; $id_shop = $shopID;
if (is_null($id_group_shop)) if (is_null($id_group_shop))
+2 -2
View File
@@ -188,7 +188,7 @@ class FrontControllerCore
$cart->id_currency = (int)($cookie->id_currency); $cart->id_currency = (int)($cookie->id_currency);
$cart->id_guest = (int)($cookie->id_guest); $cart->id_guest = (int)($cookie->id_guest);
$cart->id_group_shop = (int)$this->id_current_group_shop; $cart->id_group_shop = (int)$this->id_current_group_shop;
$cart->id_shop = (int)$this->id_current_shop; $cart->id_shop = $this->id_current_shop;
if ($cookie->id_customer) if ($cookie->id_customer)
{ {
$cart->id_customer = (int)($cookie->id_customer); $cart->id_customer = (int)($cookie->id_customer);
@@ -276,7 +276,7 @@ class FrontControllerCore
'vat_management' => (int)Configuration::get('VATNUMBER_MANAGEMENT'), 'vat_management' => (int)Configuration::get('VATNUMBER_MANAGEMENT'),
'opc' => (bool)Configuration::get('PS_ORDER_PROCESS_TYPE'), 'opc' => (bool)Configuration::get('PS_ORDER_PROCESS_TYPE'),
'PS_CATALOG_MODE' => (bool)Configuration::get('PS_CATALOG_MODE'), 'PS_CATALOG_MODE' => (bool)Configuration::get('PS_CATALOG_MODE'),
'id_current_shop' => (int)$this->id_current_shop, 'id_current_shop' => $this->id_current_shop,
'id_current_group_shop' => (int)$this->id_current_group_shop 'id_current_group_shop' => (int)$this->id_current_group_shop
)); ));
+1 -1
View File
@@ -105,7 +105,7 @@ abstract class ModuleCore
public function __construct($name = null) public function __construct($name = null)
{ {
// Search the module shop context // Search the module shop context
list($shopID, $shopGroupID) = Shop::retrieveContext(); list($shopID, $shopGroupID) = Shop::getContext();
$this->setShopID($shopID); $this->setShopID($shopID);
$this->setShopGroupID($shopGroupID); $this->setShopGroupID($shopGroupID);
+3 -2
View File
@@ -124,12 +124,13 @@ abstract class ObjectModelCore
/* Connect to database and check SQL table/identifier */ /* Connect to database and check SQL table/identifier */
if (!Validate::isTableOrIdentifier($this->identifier) OR !Validate::isTableOrIdentifier($this->table)) if (!Validate::isTableOrIdentifier($this->identifier) OR !Validate::isTableOrIdentifier($this->table))
die(Tools::displayError()); die(Tools::displayError());
$db = Db::getInstance();
$this->identifier = pSQL($this->identifier); $this->identifier = pSQL($this->identifier);
/* Load object from database if object id is present */ /* Load object from database if object id is present */
if ($id) if ($id)
{ {
if (!isset(self::$_cache[$this->table][(int)$id][(int)$id_shop][(int)$id_lang])) if (!isset(self::$_cache[$this->table][(int)$id][(int)$id_shop][(int)$id_lang]))
self::$_cache[$this->table][(int)($id)][(int)$id_shop][(int)$id_lang] = Db::getInstance()->getRow(' self::$_cache[$this->table][(int)($id)][(int)$id_shop][(int)$id_lang] = $db->getRow('
SELECT * SELECT *
FROM `'._DB_PREFIX_.$this->table.'` a '. FROM `'._DB_PREFIX_.$this->table.'` a '.
($id_lang ? ('LEFT JOIN `'.pSQL(_DB_PREFIX_.$this->table).'_lang` b ON (a.`'.$this->identifier.'` = b.`'.$this->identifier).'` AND `id_lang` = '.(int)($id_lang).')' : '') ($id_lang ? ('LEFT JOIN `'.pSQL(_DB_PREFIX_.$this->table).'_lang` b ON (a.`'.$this->identifier.'` = b.`'.$this->identifier).'` AND `id_lang` = '.(int)($id_lang).')' : '')
@@ -145,7 +146,7 @@ abstract class ObjectModelCore
if (!$id_lang AND method_exists($this, 'getTranslationsFieldsChild')) if (!$id_lang AND method_exists($this, 'getTranslationsFieldsChild'))
{ {
$result = Db::getInstance()->ExecuteS('SELECT * FROM `'.pSQL(_DB_PREFIX_.$this->table).'_lang` $result = $db->ExecuteS('SELECT * FROM `'.pSQL(_DB_PREFIX_.$this->table).'_lang`
WHERE `'.$this->identifier.'` = '.(int)$id WHERE `'.$this->identifier.'` = '.(int)$id
.(($this->langMultiShop AND $id_shop) ? ' AND `id_shop`='.(int)$id_shop : '')); .(($this->langMultiShop AND $id_shop) ? ' AND `id_shop`='.(int)$id_shop : ''));
if ($result) if ($result)
+20 -12
View File
@@ -2079,17 +2079,22 @@ class ProductCore extends ObjectModel
* *
* @since 1.5.0 * @since 1.5.0
* @param int $quantity * @param int $quantity
* @param int $id_product_attribute
* @param bool $update
* @param Context $context
*/ */
public function setStock($quantity, $id_product_attribute = 0, $update = false) public function setStock($quantity, $id_product_attribute = 0, $update = false, $context = null)
{ {
if (!$this->id) if (!$this->id)
return ; return ;
$shop = Context::getContext()->shop->getID(); if (!$context)
$context = Context::getContext();
$shop = $context->shop;
// For retrocompatibility // For retrocompatibility
$id_product_attribute = (int)$id_product_attribute; $id_product_attribute = (int)$id_product_attribute;
$quantity = (int)$quantity; $quantity = (int)$quantity;
if (Shop::getInstance($shop)->isDefaultShop()) if ($shop->isDefaultShop())
{ {
if ($id_product_attribute) if ($id_product_attribute)
{ {
@@ -2111,7 +2116,7 @@ class ProductCore extends ObjectModel
// Change stock quantity on product attribute // Change stock quantity on product attribute
if ($id_product_attribute) if ($id_product_attribute)
{ {
if ($id_stock = Stock::getStockId($this->id, $id_product_attribute, $shop)) if ($id_stock = Stock::getStockId($this->id, $id_product_attribute, $shop->getID()))
{ {
$sql = 'UPDATE '._DB_PREFIX_.'stock $sql = 'UPDATE '._DB_PREFIX_.'stock
SET quantity = '.(($update) ? 'quantity + '. $quantity : $quantity).' SET quantity = '.(($update) ? 'quantity + '. $quantity : $quantity).'
@@ -2122,14 +2127,14 @@ class ProductCore extends ObjectModel
Db::getInstance()->autoExecute(_DB_PREFIX_.'stock', array( Db::getInstance()->autoExecute(_DB_PREFIX_.'stock', array(
'id_product' => $this->id, 'id_product' => $this->id,
'id_product_attribute' => $id_product_attribute, 'id_product_attribute' => $id_product_attribute,
'id_shop' => $shop, 'id_shop' => $shop->getID(),
'id_group_shop' => Shop::getGroupFromShop($shop), 'id_group_shop' => $shop->getGroupID(),
'quantity' => $quantity, 'quantity' => $quantity,
), 'INSERT'); ), 'INSERT');
} }
// Change stock quantity on product // Change stock quantity on product
if ($id_stock = Stock::getStockId($this->id, $id_product_attribute, $shop)) if ($id_stock = Stock::getStockId($this->id, $id_product_attribute, $shop->getID()))
{ {
$sql = 'UPDATE '._DB_PREFIX_.'stock $sql = 'UPDATE '._DB_PREFIX_.'stock
SET quantity = '.(($update) ? 'quantity + '. $quantity : $quantity).' SET quantity = '.(($update) ? 'quantity + '. $quantity : $quantity).'
@@ -2140,8 +2145,8 @@ class ProductCore extends ObjectModel
Db::getInstance()->autoExecute(_DB_PREFIX_.'stock', array( Db::getInstance()->autoExecute(_DB_PREFIX_.'stock', array(
'id_product' => $this->id, 'id_product' => $this->id,
'id_product_attribute' => 0, 'id_product_attribute' => 0,
'id_shop' => $shop, 'id_shop' => $shop->getID(),
'id_group_shop' => Shop::getGroupFromShop($shop), 'id_group_shop' => $shop->getGroupID(),
'quantity' => $quantity, 'quantity' => $quantity,
), 'INSERT'); ), 'INSERT');
} }
@@ -2150,19 +2155,22 @@ class ProductCore extends ObjectModel
* Get the stock quantity of current product * Get the stock quantity of current product
* *
* @since 1.5.0 * @since 1.5.0
* @param int $id_product_attribute
* @param Context $context
* @return int * @return int
*/ */
public function getStock($id_product_attribute = 0) public function getStock($id_product_attribute = 0, $context = null)
{ {
if (!$this->id) if (!$this->id)
return 0; return 0;
if (!$context)
$context = Context::getContext();
$shop = Context::getContext()->shop->getID();
$sql = 'SELECT quantity $sql = 'SELECT quantity
FROM '._DB_PREFIX_.'stock FROM '._DB_PREFIX_.'stock
WHERE id_product = '.$this->id.' WHERE id_product = '.$this->id.'
AND id_product_attribute = '.(int)$id_product_attribute AND id_product_attribute = '.(int)$id_product_attribute
.Shop::sqlSharedStock('', $shop); .Shop::sqlSharedStock();
return (int)Db::getInstance()->getValue($sql); return (int)Db::getInstance()->getValue($sql);
} }
+31 -30
View File
@@ -45,12 +45,6 @@ class ShopCore extends ObjectModel
*/ */
protected $group; protected $group;
//private static $current_base_uri;
//private static $current_theme_name;
private static $id_current_shop;
private static $id_current_group_shop;
private static $id_current_root_category;
protected $fieldsSize = array('name' => 64); protected $fieldsSize = array('name' => 64);
protected $fieldsValidate = array( protected $fieldsValidate = array(
'active' => 'isBool', 'active' => 'isBool',
@@ -220,7 +214,7 @@ class ShopCore extends ObjectModel
return false; return false;
$this->theme_name = $row['name']; $this->theme_name = $row['name'];
$this->base_uri = $row['uri']; $this->base_uri = ($row['uri']) ? $row['uri'].'/' : '';
return true; return true;
} }
@@ -316,6 +310,16 @@ class ShopCore extends ObjectModel
return ($this->id == Configuration::get('PS_SHOP_DEFAULT')); return ($this->id == Configuration::get('PS_SHOP_DEFAULT'));
} }
/**
* Get list of associated tables to shop
*
* @return array
*/
public static function getAssoTables()
{
return self::$assoTables;
}
/** /**
* Load list of groups and shops, and cache it * Load list of groups and shops, and cache it
* *
@@ -358,16 +362,6 @@ class ShopCore extends ObjectModel
} }
} }
/**
* Get list of associated tables to shop
*
* @return array
*/
public static function getAssoTables()
{
return self::$assoTables;
}
/** /**
* Get shops list * Get shops list
* *
@@ -449,23 +443,24 @@ class ShopCore extends ObjectModel
* Retrieve the current shop context in FO or BO * Retrieve the current shop context in FO or BO
* *
* @param string null|shop|group * @param string null|shop|group
* @param bool If true, this method will return default shop ID if no shop was found in context (for BO)
* @return array(id_shop, id_group_shop)|int * @return array(id_shop, id_group_shop)|int
*/ */
public static function retrieveContext($type = null) public static function getContext($type = null, $useDefault = false)
{ {
static $executed = false, $shopID = 0, $shopGroupID = 0; static $executed = false, $shopID = 0, $shopGroupID = 0;
if (!$executed) if (!$executed)
{ {
$context = Context::getContext();
if (defined('PS_ADMIN_DIR')) if (defined('PS_ADMIN_DIR'))
{ {
global $cookie;
// While cookie is not instancied in admin, we wait ... // While cookie is not instancied in admin, we wait ...
if (!$cookie) if (!isset($context->cookie))
return ($type == 'shop' || $type == 'group') ? '' : array('', ''); return ($type == 'shop' || $type == 'group') ? '' : array('', '');
// Parse shopContext cookie value (E.g. s-2, g-4) // Parse shopContext cookie value (E.g. s-2, g-4)
$split = explode('-', $cookie->shopContext); $split = explode('-', Context::getContext()->cookie);
$shopID = $shopGroupID = ''; $shopID = $shopGroupID = '';
if (count($split) == 2) if (count($split) == 2)
{ {
@@ -480,11 +475,17 @@ class ShopCore extends ObjectModel
} }
else else
{ {
$shopID = (int)self::$id_current_shop; $shopID = $context->shop->getID();
$shopGroupID = (int)self::$id_current_group_shop; $shopGroupID = $context->shop->getGroupID();
} }
$executed = true; $executed = true;
} }
if ($useDefault && !$shopID)
$shopID = Configuration::get('PS_SHOP_DEFAULT');
if ($useDefault && !$shopGroupID)
$shopID = Shop::getGroupFromShop(Configuration::get('PS_SHOP_DEFAULT'));
if ($type == 'shop') if ($type == 'shop')
return $shopID; return $shopID;
else if ($type == 'group') else if ($type == 'group')
@@ -519,7 +520,7 @@ class ShopCore extends ObjectModel
*/ */
public static function getListFromContext() public static function getListFromContext()
{ {
list($shopID, $shopGroupID) = Shop::retrieveContext(); list($shopID, $shopGroupID) = Shop::getContext();
return Shop::getListOfID($shopID, $shopGroupID); return Shop::getListOfID($shopID, $shopGroupID);
} }
@@ -528,9 +529,9 @@ class ShopCore extends ObjectModel
* *
* @return int * @return int
*/ */
public static function getContextType() public function getContextType()
{ {
list($shopID, $shopGroupID) = Shop::retrieveContext(); list($shopID, $shopGroupID) = Shop::getContext();
if ($shopID) if ($shopID)
return Shop::CONTEXT_SHOP; return Shop::CONTEXT_SHOP;
else if ($shopGroupID) else if ($shopGroupID)
@@ -548,9 +549,9 @@ class ShopCore extends ObjectModel
$restriction = ''; $restriction = '';
if (is_null($shopID)) if (is_null($shopID))
$shopID = Shop::retrieveContext('shop'); $shopID = Shop::getContext('shop');
if (is_null($shopGroupID)) if (is_null($shopGroupID))
$shopGroupID = Shop::retrieveContext('group'); $shopGroupID = Shop::getContext('group');
if ($type == 'group_shop') if ($type == 'group_shop')
{ {
@@ -607,7 +608,7 @@ class ShopCore extends ObjectModel
$tree = Shop::getTree(); $tree = Shop::getTree();
// Get default value // Get default value
list($shopID, $shopGroupID) = Shop::retrieveContext(); list($shopID, $shopGroupID) = Shop::getContext();
if ($shopID) if ($shopID)
$value = 's-'.$shopID; $value = 's-'.$shopID;
else if ($shopGroupID) else if ($shopGroupID)
+1 -1
View File
@@ -132,7 +132,7 @@ class AuthControllerCore extends FrontController
$this->errors[] = Tools::displayError('Invalid date of birth'); $this->errors[] = Tools::displayError('Invalid date of birth');
if (!sizeof($this->errors)) if (!sizeof($this->errors))
{ {
if (Customer::customerExists(Tools::getValue('email'), false, true, (int)$this->id_current_group_shop, (int)$this->id_current_shop)) if (Customer::customerExists(Tools::getValue('email')))
$this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.'); $this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.');
if (Tools::isSubmit('newsletter')) if (Tools::isSubmit('newsletter'))
{ {
+1 -1
View File
@@ -60,7 +60,7 @@ class CmsControllerCore extends FrontController
parent::preProcess(); parent::preProcess();
/* assignCase (1 = CMS page, 2 = CMS category) */ /* assignCase (1 = CMS page, 2 = CMS category) */
if (Validate::isLoadedObject($this->cms) AND ($this->cms->isAssociatedToShop((int)$this->id_current_shop) AND $this->cms->active OR (Tools::getValue('adtoken') == Tools::encrypt('PreviewCMS'.$this->cms->id) AND file_exists(dirname(__FILE__).'/../'.Tools::getValue('ad').'/ajax.php')))) if (Validate::isLoadedObject($this->cms) AND ($this->cms->isAssociatedToShop() AND $this->cms->active OR (Tools::getValue('adtoken') == Tools::encrypt('PreviewCMS'.$this->cms->id) AND file_exists(dirname(__FILE__).'/../'.Tools::getValue('ad').'/ajax.php'))))
$this->assignCase = 1; $this->assignCase = 1;
elseif (Validate::isLoadedObject($this->cms_category)) elseif (Validate::isLoadedObject($this->cms_category))
$this->assignCase = 2; $this->assignCase = 2;
+1 -1
View File
@@ -105,7 +105,7 @@ class CartControllerCore extends FrontController
$this->errors[] = Tools::displayError('Product not found'); $this->errors[] = Tools::displayError('Product not found');
else else
{ {
$producToAdd = new Product((int)($idProduct), true, (int)self::$cookie->id_lang, (int)$this->id_current_shop); $producToAdd = new Product((int)($idProduct), true, (int)self::$cookie->id_lang);
if ((!$producToAdd->id OR !$producToAdd->active) AND !$delete) if ((!$producToAdd->id OR !$producToAdd->active) AND !$delete)
if (Tools::getValue('ajax') == 'true') if (Tools::getValue('ajax') == 'true')
die('{"hasError" : true, "errors" : ["'.Tools::displayError('Product is no longer available.', false).'"]}'); die('{"hasError" : true, "errors" : ["'.Tools::displayError('Product is no longer available.', false).'"]}');
+1 -1
View File
@@ -51,7 +51,7 @@ class CategoryControllerCore extends FrontController
public function preProcess() public function preProcess()
{ {
if ($id_category = (int)Tools::getValue('id_category')) if ($id_category = (int)Tools::getValue('id_category'))
$this->category = new Category($id_category, self::$cookie->id_lang, (int)$this->id_current_shop); $this->category = new Category($id_category, self::$cookie->id_lang);
if (!Validate::isLoadedObject($this->category)) if (!Validate::isLoadedObject($this->category))
{ {
header('HTTP/1.1 404 Not Found'); header('HTTP/1.1 404 Not Found');
+3 -3
View File
@@ -58,14 +58,14 @@ class CompareControllerCore extends FrontController
foreach ($ids AS $k => &$id) foreach ($ids AS $k => &$id)
{ {
$curProduct = new Product((int)$id, true, (int)self::$cookie->id_lang,(int)$this->id_current_shop); $curProduct = new Product((int)$id, true, (int)self::$cookie->id_lang);
if (!$curProduct->active OR !$curProduct->isAssociatedToShop((int)$this->id_current_shop)) if (!$curProduct->active OR !$curProduct->isAssociatedToShop())
{ {
unset($ids[$k]); unset($ids[$k]);
continue; continue;
} }
if (!$curProduct->active OR !$curProduct->isAssociatedToShop((int)$this->id_current_shop)) if (!$curProduct->active OR !$curProduct->isAssociatedToShop())
{ {
unset($ids[$k]); unset($ids[$k]);
continue; continue;
+1 -1
View File
@@ -103,7 +103,7 @@ class ContactControllerCore extends FrontController
else else
{ {
$customer = new Customer(); $customer = new Customer();
$customer->getByEmail($from, NULL, (int)$this->id_current_group_shop, (int)$this->id_current_shop); $customer->getByEmail($from);
} }
$contact = new Contact($id_contact, self::$cookie->id_lang); $contact = new Contact($id_contact, self::$cookie->id_lang);
+1 -1
View File
@@ -40,7 +40,7 @@ class ManufacturerControllerCore extends FrontController
if ($id_manufacturer = Tools::getValue('id_manufacturer')) if ($id_manufacturer = Tools::getValue('id_manufacturer'))
{ {
$this->manufacturer = new Manufacturer((int)$id_manufacturer, self::$cookie->id_lang); $this->manufacturer = new Manufacturer((int)$id_manufacturer, self::$cookie->id_lang);
if (Validate::isLoadedObject($this->manufacturer) AND $this->manufacturer->active AND $this->manufacturer->isAssociatedToGroupShop((int)$this->id_current_shop)) if (Validate::isLoadedObject($this->manufacturer) AND $this->manufacturer->active AND $this->manufacturer->isAssociatedToGroupShop())
{ {
$nbProducts = $this->manufacturer->getProducts($id_manufacturer, NULL, NULL, NULL, $this->orderBy, $this->orderWay, true); $nbProducts = $this->manufacturer->getProducts($id_manufacturer, NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
$this->pagination((int)$nbProducts); $this->pagination((int)$nbProducts);
+4 -4
View File
@@ -102,7 +102,7 @@ class ProductControllerCore extends FrontController
$this->errors[] = Tools::displayError('Product not found'); $this->errors[] = Tools::displayError('Product not found');
else else
{ {
if (!Validate::isLoadedObject($this->product) OR !$this->product->isAssociatedToShop((int)$this->id_current_shop) if (!Validate::isLoadedObject($this->product) OR !$this->product->isAssociatedToShop()
OR (!$this->product->active AND (Tools::getValue('adtoken') != Tools::encrypt('PreviewProduct'.$this->product->id)) OR (!$this->product->active AND (Tools::getValue('adtoken') != Tools::encrypt('PreviewProduct'.$this->product->id))
|| !file_exists(dirname(__FILE__).'/../'.Tools::getValue('ad').'/ajax.php'))) || !file_exists(dirname(__FILE__).'/../'.Tools::getValue('ad').'/ajax.php')))
{ {
@@ -160,16 +160,16 @@ class ProductControllerCore extends FrontController
if (isset($regs[2]) AND is_numeric($regs[2])) if (isset($regs[2]) AND is_numeric($regs[2]))
{ {
if (Product::idIsOnCategoryId((int)($this->product->id), array('0' => array('id_category' => (int)($regs[2]))))) if (Product::idIsOnCategoryId((int)($this->product->id), array('0' => array('id_category' => (int)($regs[2])))))
$category = new Category((int)($regs[2]), (int)self::$cookie->id_lang, (int)$this->id_current_shop); $category = new Category((int)($regs[2]), (int)self::$cookie->id_lang);
} }
elseif (isset($regs[5]) AND is_numeric($regs[5])) elseif (isset($regs[5]) AND is_numeric($regs[5]))
{ {
if (Product::idIsOnCategoryId((int)($this->product->id), array('0' => array('id_category' => (int)($regs[5]))))) if (Product::idIsOnCategoryId((int)($this->product->id), array('0' => array('id_category' => (int)($regs[5])))))
$category = new Category((int)($regs[5]), (int)self::$cookie->id_lang, (int)$this->id_current_shop); $category = new Category((int)($regs[5]), (int)self::$cookie->id_lang);
} }
} }
if (!$category) if (!$category)
$category = new Category($this->product->id_category_default, (int)self::$cookie->id_lang, (int)$this->id_current_shop); $category = new Category($this->product->id_category_default, (int)self::$cookie->id_lang);
if (isset($category) AND Validate::isLoadedObject($category)) if (isset($category) AND Validate::isLoadedObject($category))
{ {
+1 -1
View File
@@ -40,7 +40,7 @@ class SupplierControllerCore extends FrontController
if ($id_supplier = Tools::getValue('id_supplier')) if ($id_supplier = Tools::getValue('id_supplier'))
{ {
$this->supplier = new Supplier((int)$id_supplier, self::$cookie->id_lang); $this->supplier = new Supplier((int)$id_supplier, self::$cookie->id_lang);
if (Validate::isLoadedObject($this->supplier) AND $this->supplier->active AND $this->supplier->isAssociatedToGroupShop((int)$this->id_current_shop)) if (Validate::isLoadedObject($this->supplier) AND $this->supplier->active AND $this->supplier->isAssociatedToGroupShop())
{ {
$nbProducts = $this->supplier->getProducts($id_supplier, NULL, NULL, NULL, $this->orderBy, $this->orderWay, true); $nbProducts = $this->supplier->getProducts($id_supplier, NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
$this->pagination((int)$nbProducts); $this->pagination((int)$nbProducts);