Compare commits

..
46 Commits
Author SHA1 Message Date
Rémi Gaillard c0e2193d03 // small fix 2013-07-26 17:45:21 +02:00
Rémi Gaillard 85d5b6daed // ranges 2013-07-26 17:20:55 +02:00
Rémi Gaillard 1c28cdd8e7 // improve ranges 2013-07-26 14:57:31 +02:00
Rémi Gaillard f361b2fcbe // small changes 2013-07-26 10:31:58 +02:00
Rémi Gaillard 0e0200e71c // 2013-07-22 11:38:30 +02:00
Rémi Gaillard a55ec5c242 // fix entities 2013-07-22 11:37:34 +02:00
Rémi Gaillard e317c9d636 // 2013-07-22 10:25:02 +02:00
Rémi Gaillard e2aa783688 // missing file 2013-07-22 10:23:23 +02:00
Rémi Gaillard 9b2e9586c3 // bug merge 2013-07-18 16:55:54 +02:00
Rémi Gaillard 272365cbe0 // small fix 2013-07-18 16:34:35 +02:00
Rémi Gaillard d25689d00f // tabs deletion 2013-07-18 16:15:33 +02:00
Rémi Gaillard 9670a02a11 // permissions fixing 2013-07-18 15:27:08 +02:00
Rémi Gaillard 2cde72d5a4 /////// 2013-07-18 12:21:06 +02:00
Damien Metzger 9a0e3ca81e // Added logo remove link in carrier wizard 2013-07-18 10:54:05 +02:00
Damien Metzger d7c6516c32 // Fixed size and position of the carrier wizard logo 2013-07-17 19:47:48 +02:00
Rémi Gaillard 244830d505 // oups2 2013-07-17 18:49:35 +02:00
Rémi Gaillard 3ea0c1ed24 // oups 2013-07-17 18:49:21 +02:00
Damien Metzger bfa1294df9 // Added logo management to the carrier wizard (still need a "remove image" feature) 2013-07-17 18:33:40 +02:00
Damien Metzger 810120aeb9 // Removed useless code 2013-07-17 18:33:39 +02:00
Rémi Gaillard eaa9ae95bf // forgot someting 2013-07-17 12:06:50 +02:00
Rémi Gaillard b41c724e97 // fix validation rules 2013-07-17 11:43:54 +02:00
Damien Metzger 22f1cd70f1 // Fixed carrier wizard behavior after validation 2013-07-17 11:28:32 +02:00
Damien Metzger ee038c868c // Removed useless option "billing according to the default behavior" in the carrier wizard and carrier options 2013-07-17 11:20:58 +02:00
Rémi Gaillard 67ec90fae9 // same 2013-07-17 11:13:46 +02:00
Damien Metzger 25e0390128 // Improved carrier wizard navigation 2013-07-17 11:08:18 +02:00
Rémi Gaillard f6f2552f38 // fix multishop 2013-07-17 10:49:17 +02:00
Damien Metzger de4cb8a096 // Carrier Wizard summary (just started) 2013-07-16 18:16:02 +02:00
Damien Metzger 274b49bd81 // Fixed typo 2013-07-16 10:19:18 +02:00
Vincent Augagneur 3914b7db1b // 2013-07-12 19:19:13 +02:00
Vincent Augagneur db42e9c642 // 2013-07-11 19:23:33 +02:00
sLorenzini 52c117e02c // update 2013-07-09 16:57:20 +02:00
sLorenzini ad0743ebc8 // update css carrier wizard 2013-07-09 16:48:51 +02:00
Vincent Augagneur 278ffa1720 //carrier wizard steps validation error 2013-07-09 16:03:05 +02:00
sLorenzini d0a35b242f // update css error carrier wizard 2013-07-09 14:36:21 +02:00
Vincent Augagneur dbfa7d63ef //carrier wizard field validation 2013-07-09 14:26:34 +02:00
sLorenzini 1fa36e5464 // update link steps carrier wizard 2013-07-04 17:09:36 +02:00
sLorenzini f72b6fb9fc // update steps carrier wizard (css for 3/4/5 steps) 2013-07-04 16:52:20 +02:00
Vincent Augagneur cc8270761a //small fix 2013-07-04 16:27:46 +02:00
Vincent Augagneur ec15c8c8db // 2013-07-04 16:20:12 +02:00
sLorenzini 9d838b9a54 // update carrier wizard 2013-07-04 09:35:55 +02:00
sLorenzini 9cfcb98c71 // update step wizard 2013-07-03 18:00:03 +02:00
Vincent Augagneur cdd2842500 //added carrier wizard breadcrumb sprite 2013-07-03 17:49:47 +02:00
sLorenzini 471206c909 // custom carrier wizard steps 2013-07-03 17:41:09 +02:00
Vincent Augagneur 18a6e7839e //added classes from a to li in carrier wizard 2013-07-03 16:56:19 +02:00
Vincent Augagneur 943eacdf75 //carrier wizard first step 2013-07-03 16:10:23 +02:00
Vincent Augagneur 9eeaf524c5 //initial commit for carrier wizard 2013-07-02 11:42:19 +02:00
502 changed files with 9744 additions and 13867 deletions
+80 -140
View File
@@ -1,140 +1,80 @@
- adonis karavokyros - (d)oekia
- aFolletete - Alexander Otchenashev
- Agence CINS - Benjamin PONGY
- aKorczak - Burhan
- Alexander Otchenashev - Caleydon Media
- anat - Damien Metzger
- Andrew - DamienMetzger
- aNiassy - Damon Skelhorn
- antoniofr - Daniel
- AntonLejon - David Gasperoni
- Arnaud Lemercier - DrySs
- Axome - DrÿSs'
- Benjamin PONGY - François Gaillard
- BigZ - Gabriel Schwardy
- bLeveque - Gregory Roussac
- bMancone - Ha!*!*y
- bumbu - Jonathan Danse
- Burhan - Krystian Podemski
- Cédric Mouleyre - Marco Cervellin
- Caleydon Media - Michel Courtade
- cam.lafit - Milow
- Captain FLAM - Patanock
- Captain-FLAM - Pierre
- ccauw - PrestaEdit
- ChristopheBoucaut - Raphaël Malié
- cippest - Rémi Gaillard
- cmouleyre - Samy Rabih
- Corentin Delcourt - Sarah Lorenzini
- Cosmin Hutanu - Shagshag
- Damien Metzger - Vincent Augagneur
- DamienMetzger - Xavier POITAU
- Damon Skelhorn - aFolletete
- Daniel - aKorczak
- David Gasperoni - aNiassy
- Davy Rolink - adonis karavokyros
- djfm - anat
- dMetzger - bLeveque
- (d)oekia - bMancone
- Dragan Skrbic - bumbu
- DrÿSs' - cmouleyre
- dreammeup - dMetzger
- DrySs - dSevere
- dSevere - djfm
- Edouard Gaulué - fBrignoli
- emily-d - fSerny
- Fabio Chelly - fram
- fBrignoli - gBrunier
- fram - gCharmes
- François Gaillard - gPoulain
- fSerny - gRoussac
- Gabriel Schwardy - hAitmansour
- gBrunier - ivancasasempere
- gCharmes - jBreux
- gPoulain - jObregon
- Grégoire Bélorgey - jessylenne
- Gregory Roussac - jmCollin
- gRoussac - kpodemski
- Guillaume DELOINCE - lBrieu
- hAitmansour - lCherifi
- Ha!*!*y - lLefevre
- indesign47 - mBertholino
- inem0o - mDeflotte
- ivancasasempere - mMarinetti
- Jérôme Nadaud - marcinsz101
- jBreux - montes
- jeromenadaud - nPellicari
- Jerome Nadaud - nezenmoins
- jessylenne - oleacorner
- jmCollin - rGaillard
- jObregon - rMalie
- Jonathan Danse - rMontagne
- joseantgv - root
- Kevin Granger - sLorenzini
- kpodemski - sThiebaut
- Krystian Podemski - tDidierjean
- lBrieu - vAugagneur
- lCherifi - vChabot
- ldecoker - vKham
- lLefevre - vSchoener
- marcinsz101
- Marco Cervellin
- Mats Rynge
- MatthieuB
- Maxence
- mBertholino
- mDeflotte
- Michel Courtade
- Milow
- minic studio
- misthero
- mMarinetti
- montes
- nezenmoins
- Nicolas Sorosac
- Nils-Helge Garli Hegvik
- nPellicari
- nturato
- oleacorner
- Otto Nascarella
- Patanock
- PhpMadman
- Pierre
- Piotr Kaczor
- Piotr Moćko
- PrestaEdit
- prestarocket
- pxls
- Rémi Gaillard
- Raphaël Malié
- raulgundin
- rGaillard
- Rimas Kudelis
- rMalie
- rMontagne
- root
- runningz
- Sébastien
- Sébastien Bocahu
- Samy Rabih
- Sarah Lorenzini
- Seb
- Seynaeve
- Shagshag
- sLorenzini
- soware
- Staging
- sThiebaut
- Sylvain WITMEYER
- tDidierjean
- vAugagneur
- vChabot
- Vincent Augagneur
- Vincent Schoener
- Vincent Terenti
- vinvin27
- vKham
- vSchoener
- Xavier
- Xavier POITAU
- Yoozio
+2 -45
View File
@@ -37,6 +37,7 @@ $height = Tools::getValue('height');
$id_employee = Tools::getValue('id_employee'); $id_employee = Tools::getValue('id_employee');
$id_lang = Tools::getValue('id_lang'); $id_lang = Tools::getValue('id_lang');
if (!isset($cookie->id_employee) || !$cookie->id_employee || $cookie->id_employee != $id_employee) if (!isset($cookie->id_employee) || !$cookie->id_employee || $cookie->id_employee != $id_employee)
die(Tools::displayError()); die(Tools::displayError());
@@ -46,51 +47,6 @@ if (!Validate::isModuleName($module))
if (!Tools::file_exists_cache($module_path = dirname(__FILE__).'/../modules/'.$module.'/'.$module.'.php')) if (!Tools::file_exists_cache($module_path = dirname(__FILE__).'/../modules/'.$module.'/'.$module.'.php'))
die(Tools::displayError()); die(Tools::displayError());
$shop_id = '';
Shop::setContext(Shop::CONTEXT_ALL);
if (Context::getContext()->cookie->shopContext)
{
$split = explode('-', Context::getContext()->cookie->shopContext);
if (count($split) == 2)
{
if ($split[0] == 'g')
{
if (Context::getContext()->employee->hasAuthOnShopGroup($split[1]))
Shop::setContext(Shop::CONTEXT_GROUP, $split[1]);
else
{
$shop_id = Context::getContext()->employee->getDefaultShopID();
Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
}
}
else if (Shop::getShop($split[1]) && Context::getContext()->employee->hasAuthOnShop($split[1]))
{
$shop_id = $split[1];
Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
}
else
{
$shop_id = Context::getContext()->employee->getDefaultShopID();
Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
}
}
}
// Check multishop context and set right context if need
if (Shop::getContext())
{
if (Shop::getContext() == Shop::CONTEXT_SHOP && !Shop::CONTEXT_SHOP)
Shop::setContext(Shop::CONTEXT_GROUP, Shop::getContextShopGroupID());
if (Shop::getContext() == Shop::CONTEXT_GROUP && !Shop::CONTEXT_GROUP)
Shop::setContext(Shop::CONTEXT_ALL);
}
// Replace existing shop if necessary
if (!$shop_id)
Context::getContext()->shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
elseif (Context::getContext()->shop->id != $shop_id)
Context::getContext()->shop = new Shop($shop_id);
require_once($module_path); require_once($module_path);
$graph = new $module(); $graph = new $module();
@@ -101,3 +57,4 @@ if ($option)
$graph->create($render, $type, $width, $height, $layers); $graph->create($render, $type, $width, $height, $layers);
$graph->draw(); $graph->draw();
+4 -4
View File
@@ -30,14 +30,14 @@ echo ' </div>
<div id="footer"> <div id="footer">
<div style="float:left;margin-left:10px;padding-top:6px"> <div style="float:left;margin-left:10px;padding-top:6px">
<a href="http://www.prestashop.com/" target="_blank" style="font-weight:700;color:#666666">PrestaShop&trade; '._PS_VERSION_.'</a><br /> <a href="http://www.prestashop.com/" target="_blank" style="font-weight:700;color:#666666">PrestaShop&trade; '._PS_VERSION_.'</a><br />
<span style="font-size:10px">'.Translate::getAdminTranslation('Load time:').' '.number_format(microtime(true) - $timerStart, 3, '.', '').'s</span> <span style="font-size:10px">'.translate('Load time:').' '.number_format(microtime(true) - $timerStart, 3, '.', '').'s</span>
</div> </div>
<div style="float:right;height:40px;margin-right:10px;line-height:38px;vertical-align:middle">'; <div style="float:right;height:40px;margin-right:10px;line-height:38px;vertical-align:middle">';
if (strtoupper(Context::getContext()->language->iso_code) == 'FR') echo '<span style="color: #812143; font-weight: bold;">Questions / Renseignements / Formations :</span> <strong>+33 (0)1.40.18.30.04</strong> de 09h &agrave; 18h '; if (strtoupper(Context::getContext()->language->iso_code) == 'FR') echo '<span style="color: #812143; font-weight: bold;">Questions / Renseignements / Formations :</span> <strong>+33 (0)1.40.18.30.04</strong> de 09h &agrave; 18h ';
echo ' | <a href="http://www.prestashop.com/en/contact_us/" target="_blank" class="footer_link">'.Translate::getAdminTranslation('Contact').'</a> echo ' | <a href="http://www.prestashop.com/en/contact_us/" target="_blank" class="footer_link">'.translate('Contact').'</a>
| <a href="http://forge.prestashop.com" target="_blank" class="footer_link">'.Translate::getAdminTranslation('Bug Tracker').'</a> | <a href="http://forge.prestashop.com" target="_blank" class="footer_link">'.translate('Bug Tracker').'</a>
| <a href="http://www.prestashop.com/forums/" target="_blank" class="footer_link">'.Translate::getAdminTranslation('Forum').'</a> | <a href="http://www.prestashop.com/forums/" target="_blank" class="footer_link">'.translate('Forum').'</a>
</div> </div>
</div> </div>
</div> </div>
+9 -16
View File
@@ -223,16 +223,8 @@ function checkPSVersion()
return $upgrader->checkPSVersion(); return $upgrader->checkPSVersion();
} }
/**
* Deprecated since > 1.5.4.1
* Use Translate::getAdminTranslation($string) instead
*
* @param string $string
*/
function translate($string) function translate($string)
{ {
Tools::displayAsDeprecated();
global $_LANGADM; global $_LANGADM;
if (!is_array($_LANGADM)) if (!is_array($_LANGADM))
return str_replace('"', '&quot;', $string); return str_replace('"', '&quot;', $string);
@@ -241,6 +233,7 @@ function translate($string)
return str_replace('"', '&quot;', stripslashes($str)); return str_replace('"', '&quot;', stripslashes($str));
} }
/** /**
* Returns a new Tab object * Returns a new Tab object
* *
@@ -468,7 +461,7 @@ function runAdminTab($tab, $ajaxMode = false)
echo '<div class="path_bar"> echo '<div class="path_bar">
<div id="help-button" class="floatr" style="display: none; font-family: Verdana; font-size: 10px; margin-right: 4px; margin-top: 4px;"> <div id="help-button" class="floatr" style="display: none; font-family: Verdana; font-size: 10px; margin-right: 4px; margin-top: 4px;">
</div> </div>
<a href="?token='.Tools::getAdminToken($tab.intval(Tab::getIdFromClassName($tab)).(int)Context::getContext()->employee->id).'">'.Translate::getAdminTranslation('Back Office').'</a> <a href="?token='.Tools::getAdminToken($tab.intval(Tab::getIdFromClassName($tab)).(int)Context::getContext()->employee->id).'">'.translate('Back Office').'</a>
'.$bread.'</div>'; '.$bread.'</div>';
if (!$ajaxMode && Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && Context::getContext()->controller->multishop_context != Shop::CONTEXT_ALL) if (!$ajaxMode && Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && Context::getContext()->controller->multishop_context != Shop::CONTEXT_ALL)
@@ -477,10 +470,10 @@ function runAdminTab($tab, $ajaxMode = false)
if (Shop::getContext() == Shop::CONTEXT_GROUP) if (Shop::getContext() == Shop::CONTEXT_GROUP)
{ {
$shop_group = new ShopGroup((int)Shop::getContextShopGroupID()); $shop_group = new ShopGroup((int)Shop::getContextShopGroupID());
printf(Translate::getAdminTranslation('You are configuring your store for group shop %s'), '<b>'.$shop_group->name.'</b>'); printf(translate('You are configuring your store for group shop %s'), '<b>'.$shop_group->name.'</b>');
} }
elseif (Shop::getContext() == Shop::CONTEXT_SHOP) elseif (Shop::getContext() == Shop::CONTEXT_SHOP)
printf(Translate::getAdminTranslation('You are configuring your store for shop %s'), '<b>'.Context::getContext()->shop->name.'</b>'); printf(translate('You are configuring your store for shop %s'), '<b>'.Context::getContext()->shop->name.'</b>');
echo '</div>'; echo '</div>';
} }
if (Validate::isLoadedObject($adminObj)) if (Validate::isLoadedObject($adminObj))
@@ -553,8 +546,8 @@ function runAdminTab($tab, $ajaxMode = false)
// we can display the correct url // we can display the correct url
// die(Tools::jsonEncode(array(Translate::getAdminTranslation('Invalid security token'),$url))); // die(Tools::jsonEncode(array(translate('Invalid security token'),$url)));
die(Tools::jsonEncode(Translate::getAdminTranslation('Invalid security token'))); die(Tools::jsonEncode(translate('Invalid security token')));
} }
else else
{ {
@@ -566,17 +559,17 @@ function runAdminTab($tab, $ajaxMode = false)
if (false === strpos($url, '?token=') AND false === strpos($url, '&token=')) if (false === strpos($url, '?token=') AND false === strpos($url, '&token='))
$url .= '&token='.$adminObj->token; $url .= '&token='.$adminObj->token;
$message = Translate::getAdminTranslation('Invalid security token'); $message = translate('Invalid security token');
echo '<html><head><title>'.$message.'</title></head><body style="font-family:Arial,Verdana,Helvetica,sans-serif;background-color:#EC8686"> echo '<html><head><title>'.$message.'</title></head><body style="font-family:Arial,Verdana,Helvetica,sans-serif;background-color:#EC8686">
<div style="background-color:#FAE2E3;border:1px solid #000000;color:#383838;font-weight:700;line-height:20px;margin:0 0 10px;padding:10px 15px;width:500px"> <div style="background-color:#FAE2E3;border:1px solid #000000;color:#383838;font-weight:700;line-height:20px;margin:0 0 10px;padding:10px 15px;width:500px">
<img src="../img/admin/error2.png" style="margin:-4px 5px 0 0;vertical-align:middle"> <img src="../img/admin/error2.png" style="margin:-4px 5px 0 0;vertical-align:middle">
'.$message.' '.$message.'
</div>'; </div>';
echo '<a href="'.htmlentities($url).'" method="get" style="float:left;margin:10px"> echo '<a href="'.htmlentities($url).'" method="get" style="float:left;margin:10px">
<input type="button" value="'.Tools::htmlentitiesUTF8(Translate::getAdminTranslation('I understand the risks and I really want to display this page')).'" style="height:30px;margin-top:5px" /> <input type="button" value="'.Tools::htmlentitiesUTF8(translate('I understand the risks and I really want to display this page')).'" style="height:30px;margin-top:5px" />
</a> </a>
<a href="index.php" method="get" style="float:left;margin:10px"> <a href="index.php" method="get" style="float:left;margin:10px">
<input type="button" value="'.Tools::htmlentitiesUTF8(Translate::getAdminTranslation('Take me out of here!')).'" style="height:40px" /> <input type="button" value="'.Tools::htmlentitiesUTF8(translate('Take me out of here!')).'" style="height:40px" />
</a> </a>
</body></html>'; </body></html>';
die; die;
-47
View File
@@ -50,53 +50,6 @@ if (!Validate::isModuleName($module))
if (!Tools::file_exists_cache($module_path = dirname(__FILE__).'/../modules/'.$module.'/'.$module.'.php')) if (!Tools::file_exists_cache($module_path = dirname(__FILE__).'/../modules/'.$module.'/'.$module.'.php'))
die(Tools::displayError()); die(Tools::displayError());
$shop_id = '';
Shop::setContext(Shop::CONTEXT_ALL);
if (Context::getContext()->cookie->shopContext)
{
$split = explode('-', Context::getContext()->cookie->shopContext);
if (count($split) == 2)
{
if ($split[0] == 'g')
{
if (Context::getContext()->employee->hasAuthOnShopGroup($split[1]))
Shop::setContext(Shop::CONTEXT_GROUP, $split[1]);
else
{
$shop_id = Context::getContext()->employee->getDefaultShopID();
Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
}
}
else if (Shop::getShop($split[1]) && Context::getContext()->employee->hasAuthOnShop($split[1]))
{
$shop_id = $split[1];
Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
}
else
{
$shop_id = Context::getContext()->employee->getDefaultShopID();
Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
}
}
}
// Check multishop context and set right context if need
if (Shop::getContext())
{
if (Shop::getContext() == Shop::CONTEXT_SHOP && !Shop::CONTEXT_SHOP)
Shop::setContext(Shop::CONTEXT_GROUP, Shop::getContextShopGroupID());
if (Shop::getContext() == Shop::CONTEXT_GROUP && !Shop::CONTEXT_GROUP)
Shop::setContext(Shop::CONTEXT_ALL);
}
// Replace existing shop if necessary
if (!$shop_id)
Context::getContext()->shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
elseif (Context::getContext()->shop->id != $shop_id)
Context::getContext()->shop = new Shop($shop_id);
require_once($module_path); require_once($module_path);
$grid = new $module(); $grid = new $module();
+35 -35
View File
@@ -41,7 +41,7 @@ echo '
<link type="text/css" rel="stylesheet" href="'._PS_JS_DIR_.'jquery/plugins/cluetip/jquery.cluetip.css" /> <link type="text/css" rel="stylesheet" href="'._PS_JS_DIR_.'jquery/plugins/cluetip/jquery.cluetip.css" />
<link type="text/css" rel="stylesheet" href="themes/'.Context::getContext()->employee->bo_theme.'/css/admin.css" /> <link type="text/css" rel="stylesheet" href="themes/'.Context::getContext()->employee->bo_theme.'/css/admin.css" />
<link type="text/css" rel="stylesheet" href="'._PS_JS_DIR_.'jquery/plugins/chosen/jquery.chosen.css" /> <link type="text/css" rel="stylesheet" href="'._PS_JS_DIR_.'jquery/plugins/chosen/jquery.chosen.css" />
<title>PrestaShop&trade; - '.Translate::getAdminTranslation('Administration panel').'</title> <title>PrestaShop&trade; - '.translate('Administration panel').'</title>
<script type="text/javascript"> <script type="text/javascript">
var helpboxes = '.Configuration::get('PS_HELPBOX').'; var helpboxes = '.Configuration::get('PS_HELPBOX').';
var roundMode = '.Configuration::get('PS_PRICE_ROUND_MODE').'; var roundMode = '.Configuration::get('PS_PRICE_ROUND_MODE').';
@@ -78,7 +78,7 @@ echo '
html = ""; html = "";
nb_notifs = 0; nb_notifs = 0;
$.each(json.order, function(property, value) { $.each(json.order, function(property, value) {
html += "<li>'.Translate::getAdminTranslation('A new order has been made on your shop.').'<br />'.Translate::getAdminTranslation('Order number : ').'<strong>#" + parseInt(value.id_order) + "</strong><br />'.Translate::getAdminTranslation('Total : ').'<strong>" + value.total_paid_real + "</strong><br />'.Translate::getAdminTranslation('From : ').'<strong>" + value.customer_name + "</strong><br /><a href=\"index.php?tab=AdminOrders&token='.Tools::getAdminTokenLite('AdminOrders').'&vieworder&id_order=" + parseInt(value.id_order) + "\">'.Translate::getAdminTranslation('Click here to see that order').'</a></li>"; html += "<li>'.translate('A new order has been made on your shop.').'<br />'.translate('Order number : ').'<strong>#" + parseInt(value.id_order) + "</strong><br />'.translate('Total : ').'<strong>" + value.total_paid_real + "</strong><br />'.translate('From : ').'<strong>" + value.customer_name + "</strong><br /><a href=\"index.php?tab=AdminOrders&token='.Tools::getAdminTokenLite('AdminOrders').'&vieworder&id_order=" + parseInt(value.id_order) + "\">'.translate('Click here to see that order').'</a></li>";
}); });
if (html != "") if (html != "")
@@ -99,7 +99,7 @@ echo '
html = ""; html = "";
nb_notifs = 0; nb_notifs = 0;
$.each(json.customer, function(property, value) { $.each(json.customer, function(property, value) {
html += "<li>'.Translate::getAdminTranslation('A new customer registered on your shop.').'<br />'.Translate::getAdminTranslation('Customer name : ').'<strong>" + value.customer_name + "</strong><br /><a href=\"index.php?tab=AdminCustomers&token='.Tools::getAdminTokenLite('AdminCustomers').'&viewcustomer&id_customer=" + parseInt(value.id_customer) + "\">'.Translate::getAdminTranslation('Click here to see that customer').'</a></li>"; html += "<li>'.translate('A new customer registered on your shop.').'<br />'.translate('Customer name : ').'<strong>" + value.customer_name + "</strong><br /><a href=\"index.php?tab=AdminCustomers&token='.Tools::getAdminTokenLite('AdminCustomers').'&viewcustomer&id_customer=" + parseInt(value.id_customer) + "\">'.translate('Click here to see that customer').'</a></li>";
}); });
if (html != "") if (html != "")
{ {
@@ -121,7 +121,7 @@ echo '
html = ""; html = "";
nb_notifs = 0; nb_notifs = 0;
$.each(json.customer_message, function(property, value) { $.each(json.customer_message, function(property, value) {
html += "<li>'.Translate::getAdminTranslation('A new message posted on your shop.').'<br />'.Translate::getAdminTranslation('From : ').'<strong>" + value.customer_name + "</strong><br /><a href=\"index.php?tab=AdminCustomerThreads&token='.Tools::getAdminTokenLite('AdminCustomerThreads').'&viewcustomer_thread&id_customer_thread=" + parseInt(value.id_customer_thread) + "\">'.Translate::getAdminTranslation('Click here to see that message').'</a></li>"; html += "<li>'.translate('A new message posted on your shop.').'<br />'.translate('From : ').'<strong>" + value.customer_name + "</strong><br /><a href=\"index.php?tab=AdminCustomerThreads&token='.Tools::getAdminTokenLite('AdminCustomerThreads').'&viewcustomer_thread&id_customer_thread=" + parseInt(value.id_customer_thread) + "\">'.translate('Click here to see that message').'</a></li>";
}); });
if (html != "") if (html != "")
@@ -149,14 +149,14 @@ echo '
if (Shop::isFeatureActive()) if (Shop::isFeatureActive())
{ {
if (Shop::getContext() == Shop::CONTEXT_ALL) if (Shop::getContext() == Shop::CONTEXT_ALL)
$youEditFieldFor = Translate::getAdminTranslation('A modification of this field will be applied for all shops'); $youEditFieldFor = translate('A modification of this field will be applied for all shops');
elseif (Shop::getContext() == Shop::CONTEXT_GROUP) elseif (Shop::getContext() == Shop::CONTEXT_GROUP)
{ {
$shop_group = new ShopGroup((int)Shop::getContextShopGroupID()); $shop_group = new ShopGroup((int)Shop::getContextShopGroupID());
$youEditFieldFor = sprintf(Translate::getAdminTranslation('A modification of this field will be applied for all shops of group %s'), '<b>'.$shop_group->name.'</b>'); $youEditFieldFor = sprintf(translate('A modification of this field will be applied for all shops of group %s'), '<b>'.$shop_group->name.'</b>');
} }
else else
$youEditFieldFor = sprintf(Translate::getAdminTranslation('A modification of this field will be applied for the shop %s'), '<b>'.Context::getContext()->shop->name.'</b>'); $youEditFieldFor = sprintf(translate('A modification of this field will be applied for the shop %s'), '<b>'.Context::getContext()->shop->name.'</b>');
echo 'hints.html(hints.html()+\'<br /><span class="red">'.addslashes($youEditFieldFor).'</span>\');'; echo 'hints.html(hints.html()+\'<br /><span class="red">'.addslashes($youEditFieldFor).'</span>\');';
} }
@@ -202,10 +202,10 @@ echo ' var html = "";
{ {
echo '<div id="orders_notif" class="notifs"><span id="orders_notif_number_wrapper" class="number_wrapper"><span id="orders_notif_value">0</span></span> echo '<div id="orders_notif" class="notifs"><span id="orders_notif_number_wrapper" class="number_wrapper"><span id="orders_notif_value">0</span></span>
<div id="orders_notif_wrapper" class="notifs_wrapper"> <div id="orders_notif_wrapper" class="notifs_wrapper">
<h3>'.Translate::getAdminTranslation('Last orders').'</h3> <h3>'.translate('Last orders').'</h3>
<p class="no_notifs">'.Translate::getAdminTranslation('No new orders has been made on your shop').'</p> <p class="no_notifs">'.translate('No new orders has been made on your shop').'</p>
<ul id="list_orders_notif"></ul> <ul id="list_orders_notif"></ul>
<p><a href="index.php?tab=AdminOrders&token='.Tools::getAdminTokenLite('AdminOrders').'">'.Translate::getAdminTranslation('Show all orders').'</a></p> <p><a href="index.php?tab=AdminOrders&token='.Tools::getAdminTokenLite('AdminOrders').'">'.translate('Show all orders').'</a></p>
</div> </div>
</div>'; </div>';
} }
@@ -213,10 +213,10 @@ echo ' var html = "";
{ {
echo '<div id="customers_notif" class="notifs notifs_alternate"><span id="customers_notif_number_wrapper" class="number_wrapper"><span id="customers_notif_value">0</span></span> echo '<div id="customers_notif" class="notifs notifs_alternate"><span id="customers_notif_number_wrapper" class="number_wrapper"><span id="customers_notif_value">0</span></span>
<div id="customers_notif_wrapper" class="notifs_wrapper"> <div id="customers_notif_wrapper" class="notifs_wrapper">
<h3>'.Translate::getAdminTranslation('Last customers').'</h3> <h3>'.translate('Last customers').'</h3>
<p class="no_notifs">'.Translate::getAdminTranslation('No new customers registered on your shop').'</p> <p class="no_notifs">'.translate('No new customers registered on your shop').'</p>
<ul id="list_customers_notif"></ul> <ul id="list_customers_notif"></ul>
<p><a href="index.php?tab=AdminCustomers&token='.Tools::getAdminTokenLite('AdminCustomers').'">'.Translate::getAdminTranslation('Show all customers').'</a></p> <p><a href="index.php?tab=AdminCustomers&token='.Tools::getAdminTokenLite('AdminCustomers').'">'.translate('Show all customers').'</a></p>
</div> </div>
</div>'; </div>';
} }
@@ -224,26 +224,26 @@ echo ' var html = "";
{ {
echo '<div id="customer_messages_notif" class="notifs"><span id="customer_messages_notif_number_wrapper" class="number_wrapper"><span id="customer_messages_notif_value">0</span></span> echo '<div id="customer_messages_notif" class="notifs"><span id="customer_messages_notif_number_wrapper" class="number_wrapper"><span id="customer_messages_notif_value">0</span></span>
<div id="customer_messages_notif_wrapper" class="notifs_wrapper"> <div id="customer_messages_notif_wrapper" class="notifs_wrapper">
<h3>'.Translate::getAdminTranslation('Last messages').'</h3> <h3>'.translate('Last messages').'</h3>
<p class="no_notifs">'.Translate::getAdminTranslation('No new messages posted on your shop').'</p> <p class="no_notifs">'.translate('No new messages posted on your shop').'</p>
<ul id="list_customer_messages_notif"></ul> <ul id="list_customer_messages_notif"></ul>
<p><a href="index.php?tab=AdminCustomerThreads&token='.Tools::getAdminTokenLite('AdminCustomerThreads').'">'.Translate::getAdminTranslation('Show all messages').'</a></p> <p><a href="index.php?tab=AdminCustomerThreads&token='.Tools::getAdminTokenLite('AdminCustomerThreads').'">'.translate('Show all messages').'</a></p>
</div> </div>
</div>'; </div>';
} }
echo '</div> echo '</div>
<div id="employee_box"> <div id="employee_box">
<div id="employee_infos"> <div id="employee_infos">
<div class="employee_name">'.Translate::getAdminTranslation('Welcome,').' <strong>'.Context::getContext()->employee->firstname.'&nbsp'.Context::getContext()->employee->lastname.'</strong></div> <div class="employee_name">'.translate('Welcome,').' <strong>'.Context::getContext()->employee->firstname.'&nbsp'.Context::getContext()->employee->lastname.'</strong></div>
<div class="clear"></div> <div class="clear"></div>
<ul id="employee_links"> <ul id="employee_links">
<li><a href="'.htmlentities(Context::getContext()->link->getAdminLink('AdminEmployees'), ENT_COMPAT, 'UTF-8').'&id_employee={$employee->id}&amp;updateemployee">'.Translate::getAdminTranslation('My preferences').'</a></li> <li><a href="'.htmlentities(Context::getContext()->link->getAdminLink('AdminEmployees'), ENT_COMPAT, 'UTF-8').'&id_employee={$employee->id}&amp;updateemployee">'.translate('My preferences').'</a></li>
<li class="separator">&nbsp;</li> <li class="separator">&nbsp;</li>
<li><a id="header_logout" href="index.php?logout">'.Translate::getAdminTranslation('logout').'</a></li> <li><a id="header_logout" href="index.php?logout">'.translate('logout').'</a></li>
</ul>'; </ul>';
if (defined(_PS_BASE_URL_)) if (defined(_PS_BASE_URL_))
echo '<a href="'._PS_BASE_URL_.'" id="header_foaccess" target="_blank" title="'.Translate::getAdminTranslation('View my shop').'">'.Translate::getAdminTranslation('View my shop').'</a>'; echo '<a href="'._PS_BASE_URL_.'" id="header_foaccess" target="_blank" title="'.translate('View my shop').'">'.translate('View my shop').'</a>';
echo '</div> echo '</div>
</div> </div>
@@ -252,18 +252,18 @@ echo ' var html = "";
<form method="post" action="index.php?controller=AdminSearch&amp;token='.Tools::getAdminTokenLite('AdminSearch').'"> <form method="post" action="index.php?controller=AdminSearch&amp;token='.Tools::getAdminTokenLite('AdminSearch').'">
<input type="text" name="bo_query" id="bo_query" value="'.Tools::safeOutput(Tools::stripslashes(Tools::getValue('bo_query'))).'" /> <input type="text" name="bo_query" id="bo_query" value="'.Tools::safeOutput(Tools::stripslashes(Tools::getValue('bo_query'))).'" />
<select name="bo_search_type" id="bo_search_type" class="chosen no-search"> <select name="bo_search_type" id="bo_search_type" class="chosen no-search">
<option value="0">'.Translate::getAdminTranslation('everywhere').'</option> <option value="0">'.translate('everywhere').'</option>
<option value="1" '.(Tools::getValue('bo_search_type') == 1 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('catalog').'</option> <option value="1" '.(Tools::getValue('bo_search_type') == 1 ? 'selected="selected"' : '').'>'.translate('catalog').'</option>
<optgroup label="'.Translate::getAdminTranslation('customers').':"> <optgroup label="'.translate('customers').':">
<option value="2" '.(Tools::getValue('bo_search_type') == 2 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('by name').'</option> <option value="2" '.(Tools::getValue('bo_search_type') == 2 ? 'selected="selected"' : '').'>'.translate('by name').'</option>
<option value="6" '.(Tools::getValue('bo_search_type') == 6 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('by ip address').'</option> <option value="6" '.(Tools::getValue('bo_search_type') == 6 ? 'selected="selected"' : '').'>'.translate('by ip address').'</option>
</optgroup> </optgroup>
<option value="3" '.(Tools::getValue('bo_search_type') == 3 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('orders').'</option> <option value="3" '.(Tools::getValue('bo_search_type') == 3 ? 'selected="selected"' : '').'>'.translate('orders').'</option>
<option value="4" '.(Tools::getValue('bo_search_type') == 4 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('invoices').'</option> <option value="4" '.(Tools::getValue('bo_search_type') == 4 ? 'selected="selected"' : '').'>'.translate('invoices').'</option>
<option value="5" '.(Tools::getValue('bo_search_type') == 5 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('carts').'</option> <option value="5" '.(Tools::getValue('bo_search_type') == 5 ? 'selected="selected"' : '').'>'.translate('carts').'</option>
<option value="7" '.(Tools::getValue('bo_search_type') == 7 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('modules').'</option> <option value="7" '.(Tools::getValue('bo_search_type') == 7 ? 'selected="selected"' : '').'>'.translate('modules').'</option>
</select> </select>
<input type="submit" id="bo_search_submit" class="button" value="'.Translate::getAdminTranslation('Search').'"/> <input type="submit" id="bo_search_submit" class="button" value="'.translate('Search').'"/>
</form> </form>
</div> </div>
<div id="header_quick"> <div id="header_quick">
@@ -277,7 +277,7 @@ echo ' var html = "";
} }
</script> </script>
<select onchange="quickSelect(this);" id="quick_select"> <select onchange="quickSelect(this);" id="quick_select">
<option value="0">'.Translate::getAdminTranslation('Quick Access').'</option>'; <option value="0">'.translate('Quick Access').'</option>';
foreach (QuickAccess::getQuickAccesses(Context::getContext()->language->id) AS $quick) foreach (QuickAccess::getQuickAccesses(Context::getContext()->language->id) AS $quick)
{ {
preg_match('/controller=(.+)(&.+)?$/', $quick['link'], $adminTab); preg_match('/controller=(.+)(&.+)?$/', $quick['link'], $adminTab);
@@ -342,8 +342,8 @@ echo '
<div id="main"> <div id="main">
<div id="content">' <div id="content">'
.(file_exists(_PS_ADMIN_DIR_.'/../install') ? '<div style="background-color: #FFEBCC;border: 1px solid #F90;line-height: 20px;margin: 0px 0px 10px;padding: 10px 20px;">' .(file_exists(_PS_ADMIN_DIR_.'/../install') ? '<div style="background-color: #FFEBCC;border: 1px solid #F90;line-height: 20px;margin: 0px 0px 10px;padding: 10px 20px;">'
.Translate::getAdminTranslation('For security reasons, you must also:').' '. .translate('For security reasons, you must also:').' '.
Translate::getAdminTranslation('delete the /install folder'). translate('delete the /install folder').
'</div>' : '').' '</div>' : '').'
'; ';
if(defined('_PS_MODE_DEV_') && _PS_MODE_DEV_) if(defined('_PS_MODE_DEV_') && _PS_MODE_DEV_)
@@ -352,7 +352,7 @@ echo '
if (Shop::isFeatureActive() && Context::getContext()->controller->multishop_context != Shop::CONTEXT_ALL) if (Shop::isFeatureActive() && Context::getContext()->controller->multishop_context != Shop::CONTEXT_ALL)
{ {
echo '<div class="multishop_toolbar"> echo '<div class="multishop_toolbar">
<span class="text_multishop">'.Translate::getAdminTranslation('Multistore configuration for').'</span>'. <span class="text_multishop">'.translate('Multistore configuration for').'</span>'.
Helper::renderShopList(); Helper::renderShopList();
echo '</div>'; echo '</div>';
} }
@@ -27,7 +27,13 @@
{block name="label"} {block name="label"}
{if $input.name == 'vat_number'} {if $input.name == 'vat_number'}
<div id="vat_area" style="display: visible"> {if $vat == 'is_applicable'}
<div id="vat_area" style="display: visible">
{else if $vat == 'management'}
<div id="vat_area" style="display: hidden">
{else}
<div style="display: none;">
{/if}
{/if} {/if}
{if $input.type == 'text_customer' && !isset($customer)} {if $input.type == 'text_customer' && !isset($customer)}
@@ -29,9 +29,6 @@
{if $input.type == 'color'} {if $input.type == 'color'}
<div id="colorAttributeProperties" style="display:{if $colorAttributeProperties}block{else}none{/if};"> <div id="colorAttributeProperties" style="display:{if $colorAttributeProperties}block{else}none{/if};">
{/if} {/if}
{if $input.type == 'closediv'}
</div>
{/if}
{$smarty.block.parent} {$smarty.block.parent}
{/block} {/block}
@@ -24,34 +24,15 @@
*} *}
{extends file="helpers/form/form.tpl"} {extends file="helpers/form/form.tpl"}
{block name="script"} {block name="script"}
var string_price = '{l s='Will be applied when the price is' js=1}'; var string_price = '{l s="Will be applied when the price will be:" js=1}';
var string_weight = '{l s='Will be applied when the weight is' js=1}'; var string_weight = '{l s="Will be applied when the weight will be:" js=1}';
{/block} {/block}
{block name="field"} {block name="field"}
{if $input.name == 'zones'} {if $input.name == 'zones'}
<div class="ranges_not_follow warn" style="display:none">
<label>{l s="Ranges are not correctly ordered:"}</label>
<a href="#" onclick="checkRangeContinuity(true); return false;" class="button" style="text-decoration:none">{l s="Reordering"}</a>
</div>
{include file='controllers/carrier_wizard/helpers/form/form_ranges.tpl'} {include file='controllers/carrier_wizard/helpers/form/form_ranges.tpl'}
<!--
<div class="validate_range" style="display:none">
<a href="#" class="button" id="validate_range_button">{l s="Validate"}</a>
</div>
-->
<div class="new_range"> <div class="new_range">
<a href="#" onclick="add_new_range();return false;" class="button" id="add_new_range">{l s='Add new range'}</a> <a href="#" onclick="add_new_range();return false;" class="button" id="add_new_range">{l s="Add new range"}<img src="../img/admin/add.gif"/></a>
</div>
{/if}
{if $input.name == 'logo'}
<div class="margin-form">
<input id="carrier_logo_input" type="file" onchange="uploadCarrierLogo();" name="carrier_logo_input" />
<input type="hidden" id="logo" name="logo" value="" />
<p class="preference_description">
{l s='Format:'} JPG, GIF, PNG. {l s='Filesize:'} {$max_image_size|string_format:"%.2f"} {l s='MB max.'}
<br />{l s='Current size:'} <span id="carrier_logo_size">{l s='undefined'}</span>.
</p>
</div> </div>
{/if} {/if}
{$smarty.block.parent} {$smarty.block.parent}
@@ -1,48 +1,43 @@
<script>var zones_nbr = {$zones|count +3} ; /*corresponds to the third input text (max, min and all)*/</script>
<div style="float:left" id="zone_ranges"> <div style="float:left" id="zone_ranges">
<table cellpadding="5" cellspacing="0" id="zones_table"> <table cellpadding="5" cellspacing="0" id="zones_table">
<tr class="range_inf"> <tr class="range_inf">
<td class="range_type"></td> <td class="range_type"></td>
<td class="border_left border_bottom range_sign">>=</td> <td class="border_left border_bottom">>=</td>
{foreach from=$ranges key=r item=range} {foreach from=$ranges key=r item=range}
<td class="border_bottom center"><input name="range_inf[{$range.id_range|intval}]" type="text" value="{$range.delimiter1|string_format:"%.6f"}" /><sup>*</sup><span class="weight_unit">&nbsp; {$PS_WEIGHT_UNIT}</span><span class="price_unit">&nbsp; {$currency_sign}</span></td> <td class="border_bottom center"><input name="range_inf[{$range.id_range|intval}]" type="text" value="{$range.delimiter1|string_format:"%.6f"}" /></td>
{foreachelse} {foreachelse}
<td class="border_bottom center"><input name="range_inf[{$range.id_range|intval}]" type="text" /><sup>*</sup><span class="weight_unit">&nbsp; {$PS_WEIGHT_UNIT}</span><span class="price_unit">&nbsp; {$currency_sign}</span></td> <td class="border_bottom center"><input name="range_inf[{$range.id_range|intval}]" type="text" /></td>
{/foreach} {/foreach}
</tr> </tr>
<tr class="range_sup"> <tr class="range_sup">
<td class="center range_type"></td> <td class="center range_type"></td>
<td class="border_left range_sign"><</td> <td class="border_left "><</td>
{foreach from=$ranges key=r item=range} {foreach from=$ranges key=r item=range}
<td class="center"><input name="range_sup[{$range.id_range|intval}]" type="text" {if isset($form_id) && !$form_id} value="" {else} value="{if isset($change_ranges) && $range.id_range == 0} {else}{$range.delimiter2|string_format:"%.6f"}{/if}" {/if}/><sup>*</sup><span class="weight_unit">&nbsp; {$PS_WEIGHT_UNIT}</span><span class="price_unit">&nbsp; {$currency_sign}</span></td> <td class="center"><input name="range_sup[{$range.id_range|intval}]" type="text" value="{$range.delimiter2|string_format:"%.6f"}" /></td>
{foreachelse} {foreachelse}
<td class="center"><input name="range_sup[{$range.id_range|intval}]" type="text" /><sup>*</sup><span class="weight_unit">&nbsp; {$PS_WEIGHT_UNIT}</span><span class="price_unit">&nbsp; {$currency_sign}</span></td> <td class="center"><input name="range_sup[{$range.id_range|intval}]" type="text" /></td>
{/foreach} {/foreach}
</tr> </tr>
<tr class="fees_all"> <tr class="fees_all">
<td class="border_top border_bottom border_bold"><span class="fees_all" {if $ranges|count == 0}style="display:none" {/if}>All</span></td> <td class="border_top border_bottom border_bold"><span class="fees_all" {if $ranges|count == 0}style="display:none" {/if}>All</span></td>
<td><input type="checkbox" onclick="checkAllZones(this);" ></td> <td></td>
{foreach from=$ranges key=r item=range} {foreach from=$ranges key=r item=range}
<td class="center border_top border_bottom {if $range.id_range != 0} validated {/if}" > <td class="center border_top border_bottom">
<input type="text" {if isset($form_id) && !$form_id} disabled="disabled"{/if} {if $range.id_range == 0} style="display:none"{/if} /><span class="currency_sign" {if $range.id_range == 0} style="display:none" {/if}>&nbsp; {$currency_sign}</span> <input type="text" />
</td> </td>
{foreachelse} {foreachelse}
<td class="center border_top border_bottom"> <td class="center border_top border_bottom">
<input style="display:none" type="text" /><span class="currency_sign" style="display:none">&nbsp; {$currency_sign}</span> <input style="display:none" type="text" />
<button class="button">{l s="Validate"}</button>
</td> </td>
{/foreach} {/foreach}
</tr> </tr>
{foreach from=$zones key=i item=zone} {foreach from=$zones key=i item=zone}
<tr class="fees {if $i is odd}alt_row{/if}" data-zoneid="{$zone.id_zone}"> <tr class="fees {if $i is odd}alt_row{/if}" data-zoneid="{$zone.id_zone}">
<td><label for="zone_{$zone.id_zone}">{$zone.name}</label></td> <td>{$zone.name}</td>
<td class="zone"> <td class="zone"><input class="input_zone" name="zone_{$zone.id_zone}" value="1" type="checkbox" {if isset($fields_value[$input.name][$zone.id_zone])} checked="checked"{/if}/></td>
<input class="input_zone" id="zone_{$zone.id_zone}" name="zone_{$zone.id_zone}" value="1" type="checkbox" {if isset($fields_value['zones'][$zone.id_zone]) && $fields_value['zones'][$zone.id_zone]} checked="checked"{/if}/>
</td>
{foreach from=$ranges key=r item=range} {foreach from=$ranges key=r item=range}
<td class="center"> <td class="center"><input name="fees[{$zone.id_zone|intval}][{$range.id_range|intval}]" type="text" value="{if isset($price_by_range[$range.id_range][$zone.id_zone])} {$price_by_range[$range.id_range][$zone.id_zone]|string_format:"%.6f"} {/if}" /></td>
<input name="fees[{$zone.id_zone|intval}][{$range.id_range|intval}]" type="text"
{if !isset($fields_value['zones'][$zone.id_zone]) || (isset($fields_value['zones'][$zone.id_zone]) && !$fields_value['zones'][$zone.id_zone])} disabled="disabled"{/if} {if isset($price_by_range[$range.id_range][$zone.id_zone]) && $price_by_range[$range.id_range][$zone.id_zone] && isset($fields_value['zones'][$zone.id_zone]) && $fields_value['zones'][$zone.id_zone]} value="{$price_by_range[$range.id_range][$zone.id_zone]|string_format:'%.6f'}" {else} value="" {/if} /> &nbsp; {$currency_sign}
</td>
{/foreach} {/foreach}
</tr> </tr>
{/foreach} {/foreach}
@@ -53,7 +48,7 @@
{if $smarty.foreach.ranges.first} {if $smarty.foreach.ranges.first}
<td class="center">&nbsp;</td> <td class="center">&nbsp;</td>
{else} {else}
<td class="center"><button class="button">{l s='Delete'}</button</td> <td class="center"><button class="button">{l s="Delete"}</button</td>
{/if} {/if}
{/foreach} {/foreach}
</tr> </tr>
@@ -29,19 +29,12 @@
var labelNext = '{$labels.next|addslashes}'; var labelNext = '{$labels.next|addslashes}';
var labelPrevious = '{$labels.previous|addslashes}'; var labelPrevious = '{$labels.previous|addslashes}';
var labelFinish = '{$labels.finish|addslashes}'; var labelFinish = '{$labels.finish|addslashes}';
var labelDelete = '{l s='Delete' js=1}'; var labelDelete = '{l s="Delete" js=1}';
var labelValidate = '{l s='Validate' js=1}'; var labelValidate = '{l s="Validate" js=1}';
var validate_url = '{$validate_url|addslashes}'; var validate_url = '{$validate_url|addslashes}';
var carrierlist_url = '{$carrierlist_url|addslashes}'; var carrierlist_url = '{$carrierlist_url|addslashes}';
var nbr_steps = {$wizard_steps.steps|count}; var nbr_steps = {$wizard_steps.steps|count};
var enableAllSteps = {if $enableAllSteps|intval == 1}true{else}false{/if}; var enableAllSteps = {if $enableAllSteps|intval == 1}true{else}false{/if};
var need_to_validate = '{l s='Please validate the last range before create a new one.' js=1}';
var delete_range_confirm = '{l s='Are you sure to delete this range ?' js=1}';
var currency_sign = '{$currency_sign}';
var PS_WEIGHT_UNIT = '{$PS_WEIGHT_UNIT}';
var invalid_range = '{l s='This range is not valid' js=1}';
var range_is_overlapping = '{l s='Ranges are overlapping' js=1}';
var multistore_enable = '{$multistore_enable}';
</script> </script>
<div id="carrier_wizard" class="swMain"> <div id="carrier_wizard" class="swMain">
<ul class="nbr_steps_{$wizard_steps.steps|count}"> <ul class="nbr_steps_{$wizard_steps.steps|count}">
@@ -58,7 +51,7 @@
{/foreach} {/foreach}
</ul> </ul>
{foreach from=$wizard_contents.contents key=step_nbr item=content} {foreach from=$wizard_contents.contents key=step_nbr item=content}
<div id="step-{$step_nbr + 1}" class="step_container"> <div id="step-{$step_nbr + 1}" style="padding-bottom:10px">
{$content} {$content}
</div> </div>
{/foreach} {/foreach}
@@ -23,18 +23,25 @@
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*} *}
<div id="carrier_logo_block"> <div id="carrier_logo_block" style="position:absolute;top:15px;right:15px">
<img id="carrier_logo_img" src="{if $carrier_logo}{$carrier_logo}{else}../img/admin/carrier-default.jpg{/if}" /> <img id="carrier_logo_img" src="{if $carrier_logo}{$carrier_logo}{else}../img/404.gif{/if}" />
<br/> <p>
<input id="carrier_logo_input" type="file" onchange="uploadCarrierLogo();" name="carrier_logo_input" />
<input type="hidden" id="logo" name="logo" value="" />
</p>
<a id="carrier_logo_remove" {if !$carrier_logo}style="display:none"{/if} href="javascript:removeCarrierLogo();"><img src="../img/admin/disabled.gif" /> {l s='Remove the logo'}</a> <a id="carrier_logo_remove" {if !$carrier_logo}style="display:none"{/if} href="javascript:removeCarrierLogo();"><img src="../img/admin/disabled.gif" /> {l s='Remove the logo'}</a>
<p>
{l s='Format:'} JPG, GIF, PNG. {l s='Filesize:'} {$max_image_size|string_format:"%.2f"} {l s='MB max.'}
<br />{l s='Current size:'} <span id="carrier_logo_size">{l s='undefined'}</span>.
</p>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
var carrier_translation_undefined = '{l s='undefined' js=1}'; var carrier_translation_undefined = '{l s='undefined' js='1'}';
function removeCarrierLogo() function removeCarrierLogo()
{ {
$('#carrier_logo_img').attr('src', '../img/admin/carrier-default.jpg'); $('#carrier_logo_img').attr('src', '../img/404.gif');
$('#logo').val('null'); $('#logo').val('null');
fixCarrierLogoDisplay(); fixCarrierLogoDisplay();
$('#carrier_logo_remove').hide(); $('#carrier_logo_remove').hide();
@@ -24,45 +24,40 @@
*} *}
<script type="text/javascript"> <script type="text/javascript">
var summary_translation_undefined = '{l s='[undefined]' js=1}'; var summary_translation_undefined = '{l s='[undefined]' js='1'}';
var summary_translation_meta_informations = '{l s='This carrier is @s1 and the delivery announced is: @s2.' js=1}';
var summary_translation_free = '<strong>{l s='free' js=1}</strong>';
var summary_translation_paid = '<strong>{l s='not free' js=1}</strong>';
var summary_translation_range = '<span class="is_free">{l s='This carrier can deliver orders from @s1 to @s2.' js=1}</span>';
var summary_translation_range_limit = '{l s='If the order is out of range, the behavior is to @s3.' js=1}';
var summary_translation_shipping_cost = '{l s='The shipping cost is calculated @s1 and the tax rule @s2 will be applied.' js=1}';
var summary_translation_price = '<strong>{l s='according to the price' js=1}</strong>';
var summary_translation_weight = '<strong>{l s='according to the weight' js=1}</strong>';
</script>
<div class="defaultForm">
<fieldset>
{l s='Carrier name:'} <strong id="summary_name"></strong>
<div class="clear">&nbsp;</div>
<div id="summary_meta_informations"></div>
<div class="clear">&nbsp;</div>
<div id="summary_shipping_cost"></div>
<div class="clear">&nbsp;</div>
<div id="summary_range"></div>
<div class="clear">&nbsp;</div>
<div>
{l s='This carrier will be proposed for those delivery zones:'}
<ul id="summary_zones"></ul>
</div>
<div class="clear">&nbsp;</div>
<div>
{l s='And it will be proposed for those client groups:'}
<ul id="summary_groups"></ul>
</div>
{if $is_multishop}
<div class="clear">&nbsp;</div>
<div>
{l s='Finally, this carrier will be proposed in those shops:'}
<ul id="summary_shops"></ul>
</div>
{/if}
<div class="clear">&nbsp;</div>
{$active_form}
</fieldset>
</div>
<div class="clear">&nbsp;</div>
var summary_translation_meta_informations = '{l s='This carrier is @s1 and display to the customers the following delay: @s2.' js='1'}';
var summary_translation_free = '<strong>{l s='free' js='1'}</strong>';
var summary_translation_paid = '<strong>{l s='paid' js='1'}</strong>';
var summary_translation_range = '{l s='This carrier can deliver orders from @s1 to @s2. If the order is out of range, the behavior is to @s3.' js='1'}';
var summary_translation_shipping_cost = '{l s='The shipping cost is calculated @s1 and the tax rule @s2 is applied.' js='1'}';
var summary_translation_price = '<strong>{l s='according to the price' js='1'}</strong>';
var summary_translation_weight = '<strong>{l s='according to the weight' js='1'}</strong>';
</script>
<fieldset>
{l s='Carrier name:'} <strong id="summary_name"></strong>
<div class="clear">&nbsp;</div>
<div id="summary_meta_informations"></div>
<div class="clear">&nbsp;</div>
<div id="summary_shipping_cost"></div>
<div class="clear">&nbsp;</div>
<div id="summary_range"></div>
<div class="clear">&nbsp;</div>
<div>
{l s='It will be displayed only for the following zones:'}
<ul id="summary_zones"></ul>
</div>
<div class="clear">&nbsp;</div>
<div>
{l s='It will be displayed only for the following groups:'}
<ul id="summary_groups"></ul>
</div>
<div class="clear">&nbsp;</div>
<div>
{l s='It will be displayed only for the following shops:'}
<ul id="summary_shops"></ul>
</div>
</fieldset>
@@ -34,7 +34,7 @@
{if $shared_category} {if $shared_category}
<p class="warn">{l s='If you delete this picture, it will be deleted in all of your shared shops!'}</p> <p class="warn">{l s='If you delete this picture, it will be deleted in all of your shared shops!'}</p>
{/if} {/if}
<br /> <br>
<a href="{$current}&{$identifier}={$form_id}&token={$token}&{if $shared_category}forcedeleteImage=1{else}deleteImage=1{/if}"> <a href="{$current}&{$identifier}={$form_id}&token={$token}&{if $shared_category}forcedeleteImage=1{else}deleteImage=1{/if}">
<img src="../img/admin/delete.gif" alt="{l s='Delete'}" /> {l s='Delete'} <img src="../img/admin/delete.gif" alt="{l s='Delete'}" /> {l s='Delete'}
</a> </a>
@@ -35,7 +35,7 @@
{/block} {/block}
{block name=leadin} {block name=leadin}
{if isset($delete_customer) && $delete_customer} {if isset($delete_customer) && $delete_customer}
<form action="{$REQUEST_URI|escape:'htmlall':'UTF-8'}" method="post"> <form action="{$REQUEST_URI}" method="post">
<div class="warn"> <div class="warn">
<h2>{l s='How do you want to delete these customer(s)?'}</h2> <h2>{l s='How do you want to delete these customer(s)?'}</h2>
<p>{l s='There are two ways of deleting a customer. Please choose your preferred method.'}</p> <p>{l s='There are two ways of deleting a customer. Please choose your preferred method.'}</p>
@@ -52,10 +52,10 @@
{foreach $POST as $key => $value} {foreach $POST as $key => $value}
{if is_array($value)} {if is_array($value)}
{foreach $value as $val} {foreach $value as $val}
<input type="hidden" name="{$key|escape:'htmlall':'UTF-8'}[]" value="{$val|escape:'htmlall':'UTF-8'}" /> <input type="hidden" name="{$key}[]" value="{$val}" />
{/foreach} {/foreach}
{else} {else}
<input type="hidden" name="{$key|escape:'htmlall':'UTF-8'}" value="{$value|escape:'htmlall':'UTF-8'}" /> <input type="hidden" name="{$key}" value="{$value}" />
{/if} {/if}
{/foreach} {/foreach}
<br /><input type="submit" class="button" value="{l s='Delete'}" /> <br /><input type="submit" class="button" value="{l s='Delete'}" />
@@ -149,7 +149,7 @@
</div> </div>
<div style="width:50%;float:left;"> <div style="width:50%;float:left;">
<div style="margin-left:15px;"> <div style="margin-left:15px;"
<h2>{l s='Vouchers'} ({count($discounts)})</h2> <h2>{l s='Vouchers'} ({count($discounts)})</h2>
{if count($discounts)} {if count($discounts)}
<table cellspacing="0" cellpadding="0" class="table"> <table cellspacing="0" cellpadding="0" class="table">
@@ -106,7 +106,7 @@
if ($(this).attr('name') == 'category_reduction['+$('[name="id_category"]:checked').val()+']') if ($(this).attr('name') == 'category_reduction['+$('[name="id_category"]:checked').val()+']')
{ {
exist = true; exist = true;
jAlert('{l s='This category already exists for this group.' js=1}'); jAlert('{l s='This category already exists for this group.' js='1'}');
return false; return false;
} }
}); });
@@ -223,7 +223,7 @@ $(document).ready(function() {
$.fancybox( $.fancybox(
this.href, this.href,
{ {
'width' : 920, 'width' : 660,
'height' : 384, 'height' : 384,
'transitionIn' : 'none', 'transitionIn' : 'none',
'transitionOut' : 'none', 'transitionOut' : 'none',
@@ -57,7 +57,7 @@
} }
else else
{ {
jAlert('{l s='You do not have permission to delete here. When the multistore is enabled, only a SuperAdmin can delete all items before an import.' js=1}'); jAlert('{l s='You do not have permission to delete here. When the multistore is enabled, only a SuperAdmin can delete all items before an import.' js='1'}');
return false; return false;
} }
} }
@@ -58,7 +58,7 @@
</div> </div>
<form action="{$current}&token={$token}" method="post" id="import_form" name="import_form"> <form action="{$current}&token={$token}" method="post" id="import_form" name="import_form">
{l s='Skip'} <input type="text" size="2" name="skip" value="1" /> {l s='lines'} {l s='Skip'} <input type="text" size="2" name="skip" value="0" /> {l s='lines'}
<input type="hidden" name="csv" value="{$fields_value.csv}" /> <input type="hidden" name="csv" value="{$fields_value.csv}" />
<input type="hidden" name="convert" value="{$fields_value.convert}" /> <input type="hidden" name="convert" value="{$fields_value.convert}" />
<input type="hidden" name="entity" value="{$fields_value.entity}" /> <input type="hidden" name="entity" value="{$fields_value.entity}" />
@@ -49,14 +49,14 @@
<form action="#" id="login_form" method="post"> <form action="#" id="login_form" method="post">
<div class="field"> <div class="field">
<label for="email">{l s='Email address:'}</label> <label for="email">{l s='Email address:'}</label>
<input type="text" id="email" name="email" class="input email_field" tabindex="1" value="{if isset($email)}{$email|escape:'htmlall':'UTF-8'}{/if}" /> <input type="text" id="email" name="email" class="input email_field" value="{if isset($email)}{$email|escape:'htmlall':'UTF-8'}{/if}" />
</div> </div>
<div class="field"> <div class="field">
<label for="passwd">{l s='Password:'}</label> <label for="passwd">{l s='Password:'}</label>
<input id="passwd" type="password" name="passwd" class="input password_field" tabindex="2" value="{if isset($password)}{$password}{/if}"/> <input id="passwd" type="password" name="passwd" class="input password_field" value="{if isset($password)}{$password}{/if}"/>
</div> </div>
<div class="field"> <div class="field">
<input type="submit" name="submitLogin" value="{l s='Log in'}" tabindex="3" class="button fl margin-right-5" /> <input type="submit" name="submitLogin" value="{l s='Log in'}" class="button fl margin-right-5" />
<p class="fl no-margin hide ajax-loader"> <p class="fl no-margin hide ajax-loader">
<img src="../img/loader.gif" alt="" /> <img src="../img/loader.gif" alt="" />
</p> </p>
@@ -77,7 +77,7 @@
</dl> </dl>
</div> </div>
<p class="desc">{if isset($module->description) && $module->description ne ''}{l s='Description'} : {$module->description}{else}&nbsp;{/if}</p> <p class="desc">{if isset($module->description) && $module->description ne ''}{l s='Description'} : {$module->description}{else}&nbsp;{/if}</p>
{if isset($module->message) && (!isset($module->type) || ($module->type != 'addonsMustHave' || $module->type !== 'addonsNative'))}<div class="conf">{$module->message}</div>{/if} {if isset($module->message) && $module->type !== 'addonsNative' && $module->type != 'addonsMustHave'}<div class="conf">{$module->message}</div>{/if}
<div class="row-actions-module"> <div class="row-actions-module">
{if !isset($module->not_on_disk)} {if !isset($module->not_on_disk)}
{$module->optionsHtml} {$module->optionsHtml}
@@ -26,7 +26,7 @@
{include file="toolbar.tpl" toolbar_btn=$toolbar_btn toolbar_scroll=$toolbar_scroll title=$title} {include file="toolbar.tpl" toolbar_btn=$toolbar_btn toolbar_scroll=$toolbar_scroll title=$title}
<div class="leadin">{block name="leadin"}{/block}</div> <div class="leadin">{block name="leadin"}{/block}</div>
<form action="{$url_submit}" id="{$table}_form" method="post"> <form action="{$url_submit}" id={$table}_form method="post">
{if $display_key} {if $display_key}
<input type="hidden" name="show_modules" value="{$display_key}" /> <input type="hidden" name="show_modules" value="{$display_key}" />
{/if} {/if}
@@ -49,10 +49,38 @@
</select><sup> *</sup> </select><sup> *</sup>
</div> </div>
<script type="text/javascript">
//<![CDATA
function position_exception_add(shopID)
{
var listValue = $('#em_list_'+shopID).val();
var inputValue = $('#em_text_'+shopID).val();
var r = new RegExp('(^|,) *'+listValue+' *(,|$)');
if (!r.test(inputValue))
$('#em_text_'+shopID).val(inputValue + ((inputValue.trim()) ? ', ' : '') + listValue);
}
function position_exception_remove(shopID)
{
var listValue = $('#em_list_'+shopID).val();
var inputValue = $('#em_text_'+shopID).val();
var r = new RegExp('(^|,) *'+listValue+' *(,|$)');
if (r.test(inputValue))
{
var rep = '';
if (new RegExp(', *'+listValue+' *,').test(inputValue))
$('#em_text_'+shopID).val(inputValue.replace(r, ','));
else if (new RegExp(listValue+' *,').test(inputValue))
$('#em_text_'+shopID).val(inputValue.replace(r, ''));
else
$('#em_text_'+shopID).val(inputValue.replace(r, ''));
}
}
//]]>
</script>
<label>{l s='Exceptions'} :</label> <label>{l s='Exceptions'} :</label>
<div class="margin-form"> <div class="margin-form">
{l s='Please specify the files for which you do not want the module to be displayed.'}<br />
{l s='Please input each filename, separated by a comma.'}<br />
{if !$except_diff} {if !$except_diff}
{$exception_list} {$exception_list}
{else} {else}
@@ -60,6 +88,9 @@
{$value} {$value}
{/foreach} {/foreach}
{/if} {/if}
{l s='Please specify the files for which you do not want the module to be displayed.'}.<br />
{l s='Please input each filename, separated by a comma.'}.
<br /><br />
</div> </div>
<div class="margin-form"> <div class="margin-form">
@@ -72,39 +103,3 @@
<div class="small"><sup>*</sup> {l s='Required field'}</div> <div class="small"><sup>*</sup> {l s='Required field'}</div>
</fieldset> </fieldset>
</form> </form>
<script type="text/javascript">
//<![CDATA
function position_exception_textchange()
{
// TODO : Add & Remove automatically the "custom pages" in the "em_list_x"
var obj = $(this);
var shopID = obj.attr('id').replace(/\D/g, '');
var list = obj.parent().find('#em_list_' + shopID);
var values = obj.val().split(',');
var len = values.length;
list.find('option').prop('selected', false);
for (var i = 0; i < len; i++)
list.find('option[value="' + $.trim(values[i]) + '"]').prop('selected', true);
}
function position_exception_listchange()
{
var obj = $(this);
var shopID = obj.attr('id').replace(/\D/g, '');
var str = obj.val().join(', ');
obj.parent().find('#em_text_' + shopID).val(str);
}
$(document).ready(function(){
$('form[id="hook_module_form"] input[id^="em_text_"]').each(function(){
$(this).change(position_exception_textchange).change();
});
$('form[id="hook_module_form"] select[id^="em_list_"]').each(function(){
$(this).change(position_exception_listchange);
});
});
//]]>
</script>
@@ -45,7 +45,6 @@
{/if} {/if}
</td> </td>
<td align="center" class="productQuantity">{$product['customizationQuantityTotal']}</td> <td align="center" class="productQuantity">{$product['customizationQuantityTotal']}</td>
{if $display_warehouse}<td style="" align="center">&nbsp;</td>{/if}
{if ($order->hasBeenPaid())}<td align="center" class="productQuantity">{$product['customizationQuantityRefunded']}</td>{/if} {if ($order->hasBeenPaid())}<td align="center" class="productQuantity">{$product['customizationQuantityRefunded']}</td>{/if}
{if ($order->hasBeenDelivered() || $order->hasProductReturned())}<td align="center" class="productQuantity">{$product['customizationQuantityReturned']}</td>{/if} {if ($order->hasBeenDelivered() || $order->hasProductReturned())}<td align="center" class="productQuantity">{$product['customizationQuantityReturned']}</td>{/if}
{if $stock_management}<td align="center" class=""> - </td>{/if} {if $stock_management}<td align="center" class=""> - </td>{/if}
@@ -104,7 +103,6 @@
</span> </span>
{/if} {/if}
</td> </td>
{if $display_warehouse}<td style="" align="center">&nbsp;</td>{/if}
{if ($order->hasBeenPaid())}<td align="center">{$customization['quantity_refunded']}</td>{/if} {if ($order->hasBeenPaid())}<td align="center">{$customization['quantity_refunded']}</td>{/if}
{if ($order->hasBeenDelivered())}<td align="center">{$customization['quantity_returned']}</td>{/if} {if ($order->hasBeenDelivered())}<td align="center">{$customization['quantity_returned']}</td>{/if}
<td align="center"> <td align="center">
@@ -68,9 +68,9 @@
{/if} {/if}
{if get_class($document) eq 'OrderInvoice'} {if get_class($document) eq 'OrderInvoice'}
{if isset($document->is_delivery)} {if isset($document->is_delivery)}
#{Configuration::get('PS_DELIVERY_PREFIX', $current_id_lang, null, $order->id_shop)}{'%06d'|sprintf:$document->delivery_number} #{Configuration::get('PS_DELIVERY_PREFIX', $current_id_lang)}{'%06d'|sprintf:$document->delivery_number}
{else} {else}
{$document->getInvoiceNumberFormatted($current_id_lang, $order->id_shop)} {$document->getInvoiceNumberFormatted($current_id_lang)}
{/if} {/if}
{elseif get_class($document) eq 'OrderSlip'} {elseif get_class($document) eq 'OrderSlip'}
#{Configuration::get('PS_CREDIT_SLIP_PREFIX', $current_id_lang)}{'%06d'|sprintf:$document->id} #{Configuration::get('PS_CREDIT_SLIP_PREFIX', $current_id_lang)}{'%06d'|sprintf:$document->id}
@@ -40,7 +40,6 @@
</td> </td>
<td style="display:none;" align="center" class="productQuantity"><input type="text" name="add_product[product_quantity]" id="add_product_product_quantity" value="1" size="3" disabled="disabled" /></td> <td style="display:none;" align="center" class="productQuantity"><input type="text" name="add_product[product_quantity]" id="add_product_product_quantity" value="1" size="3" disabled="disabled" /></td>
{if ($order->hasBeenPaid())}<td style="display:none;" align="center" class="productQuantity">&nbsp;</td>{/if} {if ($order->hasBeenPaid())}<td style="display:none;" align="center" class="productQuantity">&nbsp;</td>{/if}
{if $display_warehouse}<td style="" align="center">&nbsp;</td>{/if}
{if ($order->hasBeenDelivered())}<td style="display:none;" align="center" class="productQuantity">&nbsp;</td>{/if} {if ($order->hasBeenDelivered())}<td style="display:none;" align="center" class="productQuantity">&nbsp;</td>{/if}
<td style="display:none;" align="center" class="productQuantity" id="add_product_product_stock">0</td> <td style="display:none;" align="center" class="productQuantity" id="add_product_product_stock">0</td>
<td style="display:none;" align="center" id="add_product_product_total">{displayPrice price=0 currency=$currency->id}</td> <td style="display:none;" align="center" id="add_product_product_total">{displayPrice price=0 currency=$currency->id}</td>
@@ -56,7 +56,6 @@
</span> </span>
{/if} {/if}
</td> </td>
{if $display_warehouse}<td>{$product.warehouse_name|escape:'htmlall':'UTF-8'}</td>{/if}
{if ($order->hasBeenPaid())} {if ($order->hasBeenPaid())}
<td align="center" class="productQuantity"> <td align="center" class="productQuantity">
{$product['product_quantity_refunded']} {$product['product_quantity_refunded']}
@@ -33,8 +33,8 @@
var currencies = new Array(); var currencies = new Array();
var id_currency = ''; var id_currency = '';
var id_lang = ''; var id_lang = '';
var txt_show_carts = '{l s='Show carts and orders for this customer.' js=1}'; var txt_show_carts = '{l s='Show carts and orders for this customer.' js='1'}';
var txt_hide_carts = '{l s='Hide carts and orders for this customer.' js=1}'; var txt_hide_carts = '{l s='Hide carts and orders for this customer.' js='1'}';
var defaults_order_state = new Array(); var defaults_order_state = new Array();
var customization_errors = false; var customization_errors = false;
var pic_dir = '{$pic_dir}'; var pic_dir = '{$pic_dir}';
@@ -170,9 +170,9 @@
{l s='Account registered:'} <b>{dateFormat date=$customer->date_add full=true}</b><br /> {l s='Account registered:'} <b>{dateFormat date=$customer->date_add full=true}</b><br />
{l s='Valid orders placed:'} <b>{$customerStats['nb_orders']}</b><br /> {l s='Valid orders placed:'} <b>{$customerStats['nb_orders']}</b><br />
{l s='Total spent since registration:'} <b>{displayPrice price=Tools::ps_round(Tools::convertPrice($customerStats['total_orders'], $currency), 2) currency=$currency->id}</b><br /> {l s='Total spent since registration:'} <b>{displayPrice price=Tools::ps_round(Tools::convertPrice($customerStats['total_orders'], $currency), 2) currency=$currency->id}</b><br />
</fieldset>
{/if} {/if}
{/if} {/if}
</fieldset>
<!-- Sources block --> <!-- Sources block -->
{if (sizeof($sources))} {if (sizeof($sources))}
@@ -325,7 +325,7 @@
<td>{displayPrice price=$payment->amount currency=$payment->id_currency}</td> <td>{displayPrice price=$payment->amount currency=$payment->id_currency}</td>
<td> <td>
{if $invoice = $payment->getOrderInvoice($order->id)} {if $invoice = $payment->getOrderInvoice($order->id)}
{$invoice->getInvoiceNumberFormatted($current_id_lang, $order->id_shop)} {$invoice->getInvoiceNumberFormatted($current_id_lang)}
{else} {else}
{l s='No invoice'} {l s='No invoice'}
{/if} {/if}
@@ -404,7 +404,7 @@
<td> <td>
<select name="payment_invoice" id="payment_invoice"> <select name="payment_invoice" id="payment_invoice">
{foreach from=$invoices_collection item=invoice} {foreach from=$invoices_collection item=invoice}
<option value="{$invoice->id}" selected="selected">{$invoice->getInvoiceNumberFormatted($current_id_lang, $order->id_shop)}</option> <option value="{$invoice->id}" selected="selected">{$invoice->getInvoiceNumberFormatted($current_id_lang)}</option>
{/foreach} {/foreach}
</select> </select>
</td> </td>
@@ -592,7 +592,6 @@
<th>{l s='Product'}</th> <th>{l s='Product'}</th>
<th style="width: 15%; text-align: center">{l s='Unit Price'} <sup>*</sup></th> <th style="width: 15%; text-align: center">{l s='Unit Price'} <sup>*</sup></th>
<th style="width: 4%; text-align: center">{l s='Qty'}</th> <th style="width: 4%; text-align: center">{l s='Qty'}</th>
{if $display_warehouse}<th style="text-align: center">{l s='Warehouse'}</th>{/if}
{if ($order->hasBeenPaid())}<th style="width: 3%; text-align: center">{l s='Refunded'}</th>{/if} {if ($order->hasBeenPaid())}<th style="width: 3%; text-align: center">{l s='Refunded'}</th>{/if}
{if ($order->hasBeenDelivered() || $order->hasProductReturned())}<th style="width: 3%; text-align: center">{l s='Returned'}</th>{/if} {if ($order->hasBeenDelivered() || $order->hasProductReturned())}<th style="width: 3%; text-align: center">{l s='Returned'}</th>{/if}
{if $stock_management}<th style="width: 10%; text-align: center">{l s='Available quantity'}</th>{/if} {if $stock_management}<th style="width: 10%; text-align: center">{l s='Available quantity'}</th>{/if}
@@ -31,14 +31,6 @@
{if isset($modules_list)} {if isset($modules_list)}
{$modules_list} {$modules_list}
{/if} {/if}
<div class="space info">
{l s='This is where you decide what payment modules are available for different variations like your customers\' currency, group, and country.'}
<br />
{l s='A check mark indicates you want the payment module available.'}
{l s='If it is not checked then this means that the Payment module is disabled.'}
<br />
{l s='Please make sure to click Save for each section.'}
</div>
{if $display_restrictions} {if $display_restrictions}
<br /><h2 class="space">{l s='Payment module restrictions'}</h2> <br /><h2 class="space">{l s='Payment module restrictions'}</h2>
{foreach $lists as $list} {foreach $lists as $list}
@@ -34,10 +34,10 @@
{if $module->active} {if $module->active}
<th> <th>
{if $list['name_id'] != 'currency' || $module->currencies_mode == 'checkbox'} {if $list['name_id'] != 'currency' || $module->currencies_mode == 'checkbox'}
<input type="hidden" id="checkedBox_{$list['name_id']}_{$module->name}" value="checked"/> <input type="hidden" id="checkedBox_{$list['name_id']}_{$module->name}" value="checked">
<a href="javascript:checkPaymentBoxes('{$list['name_id']}', '{$module->name}')" style="text-decoration:none;"> <a href="javascript:checkPaymentBoxes('{$list['name_id']}', '{$module->name}')" style="text-decoration:none;">
{/if} {/if}
&nbsp;<img src="{$ps_base_uri}modules/{$module->name}/logo.gif" alt="{$module->name}" title="{$module->displayName}"/> &nbsp;<img src="{$ps_base_uri}modules/{$module->name}/logo.gif" alt="{$module->name}" title="{$module->displayName}" />
{if $list['name_id'] != 'currency' || $module->currencies_mode == 'checkbox'} {if $list['name_id'] != 'currency' || $module->currencies_mode == 'checkbox'}
</a> </a>
{/if} {/if}
@@ -64,9 +64,11 @@
{$type = 'checkbox'} {$type = 'checkbox'}
{/if} {/if}
{if $type != 'null'} {if $type != 'null'}
<input type="{$type}" name="{$module->name}_{$list['name_id']}[]" value="{$item[$list['identifier']]}" {if $item['check_list'][$key_module] == 'checked'}checked="checked"{/if}/> <input type="checkbox" name="{$module->name}_{$list['name_id']}[]" value="{$item[$list['identifier']]}"
{if $item['check_list'][$key_module] == 'checked'}checked="checked"{/if}
/>
{else} {else}
<input type="hidden" name="{$module->name}_{$list['name_id']}[]" value="{$item[$list['identifier']]}"/>-- --
{/if} {/if}
</td> </td>
{/if} {/if}
@@ -40,9 +40,6 @@
</div> </div>
{/if} {/if}
{$smarty.block.parent} {$smarty.block.parent}
{if $input.type == 'radio' && $input.name == 'smarty_cache'}
<a href="{$current}&token={$token}&empty_smarty_cache=1" class="clear button" href="">{l s='Clear Smarty cache'}</a>
{/if}
{/block} {/block}
{block name="description"} {block name="description"}
@@ -189,7 +186,7 @@
return false; return false;
}); });
$('input[name="smarty_force_compile"], input[name="smarty_cache"], input[name="smarty_console"], input[name="smarty_console_key"]').change(function(){ $('input[name="smarty_force_compile"], input[name="smarty_cache"], input[name="smarty_console"]').change(function(){
$('#smarty_up').val(1); $('#smarty_up').val(1);
}); });
@@ -78,7 +78,7 @@
<tr id="image_id"> <tr id="image_id">
<td style="padding: 4px;"> <td style="padding: 4px;">
<a href="{$smarty.const._THEME_PROD_DIR_}image_path.jpg" class="fancybox"> <a href="{$smarty.const._THEME_PROD_DIR_}image_path.jpg" class="fancybox">
<img src="{$smarty.const._THEME_PROD_DIR_}{$iso_lang}-default-small_default.jpg" alt="image_id" title="image_id" /> <img src="{$smarty.const._THEME_PROD_DIR_}en-default-small_default.jpg" alt="image_id" title="image_id" />
</a> </a>
</td> </td>
<td id="td_image_id" class="pointer dragHandle center positionImage"> <td id="td_image_id" class="pointer dragHandle center positionImage">
@@ -313,13 +313,12 @@
{ {
line = $("#lineType").html(); line = $("#lineType").html();
line = line.replace(/image_id/g, id); line = line.replace(/image_id/g, id);
line = line.replace(/[a-z]{2}-default/g, path); line = line.replace(/en-default/g, path);
line = line.replace(/image_path/g, path); line = line.replace(/image_path/g, path);
line = line.replace(/image_position/g, position); line = line.replace(/image_position/g, position);
line = line.replace(/blank/g, cover); line = line.replace(/blank/g, cover);
line = line.replace(/<tbody>/gi, ""); line = line.replace(/<tbody>/gi, "");
line = line.replace(/<\/tbody>/gi, ""); line = line.replace(/<\/tbody>/gi, "");
if (shops != false) if (shops != false)
{ {
$.each(shops, function(key, value){ $.each(shops, function(key, value){
@@ -327,10 +326,8 @@
line = line.replace('id="' + key + '' + id + '"','id="' + key + '' + id + '" checked=checked'); line = line.replace('id="' + key + '' + id + '"','id="' + key + '' + id + '" checked=checked');
}); });
} }
$("#imageList").append(line); $("#imageList").append(line);
} }
$('.fancybox').fancybox(); $('.fancybox').fancybox();
}); });
{/literal} {/literal}
@@ -24,8 +24,8 @@
*} *}
<script type="text/javascript"> <script type="text/javascript">
var msg_select_one = "{l s='Please select at least one product.' js=1}"; var msg_select_one = "{l s="Please select at least one product." js=1}";
var msg_set_quantity = "{l s='Please set a quantity to add a product.' js=1}"; var msg_set_quantity = "{l s="Please set a quantity to add a product." js=1}";
</script> </script>
<input type="hidden" name="submitted_tabs[]" value="Pack" /> <input type="hidden" name="submitted_tabs[]" value="Pack" />
<h4>{l s='Pack'}</h4> <h4>{l s='Pack'}</h4>
@@ -71,7 +71,7 @@
<label>{l s='Carriers:'}</label> <label>{l s='Carriers:'}</label>
</td> </td>
<td class="padding-bottom:5px;"> <td class="padding-bottom:5px;">
<select name="carriers[]" id="carriers_restriction" multiple="multiple" size="4" style="height:100px;width:300px;"> <select name="carriers[]" id="carriers_restriction" multiple="multiple" size="4" style="height:100px;width:200px;">
{foreach $carrier_list as $carrier} {foreach $carrier_list as $carrier}
<option value="{$carrier.id_reference}" {if isset($carrier.selected) && $carrier.selected}selected="selected"{/if}>{$carrier.name}</option> <option value="{$carrier.id_reference}" {if isset($carrier.selected) && $carrier.selected}selected="selected"{/if}>{$carrier.name}</option>
{/foreach} {/foreach}
@@ -90,7 +90,7 @@
var table = $('#selectTables select').val(); var table = $('#selectTables select').val();
if (!table) if (!table)
jAlert("{l s='Please choose a table.' js=1}"); jAlert("{l s='Please choose a table.' js='1'}");
else else
AddRequestSql(table); AddRequestSql(table);
}); });
@@ -24,7 +24,7 @@
*} *}
<a href="{$href}" class="delete" <a href="{$href}" class="delete"
{if in_array($id_shop, $shops_having_dependencies)} {if in_array($id_shop, $shops_having_dependencies)}
onclick="jAlert('{l s='You cannot delete this shop\'s (customer and/or order dependency)' js=1}'); return false;" onclick="jAlert('{l s='You cannot delete this shop\'s (customer and/or order dependency)' js='1'}'); return false;"
{elseif isset($confirm)} {elseif isset($confirm)}
onclick="if (confirm('{$confirm}')){ return true; } else { event.stopPropagation(); event.preventDefault();};" onclick="if (confirm('{$confirm}')){ return true; } else { event.stopPropagation(); event.preventDefault();};"
{/if} title="{$action}"> {/if} title="{$action}">
@@ -161,13 +161,6 @@ function add_condition(id_condition_group, type, value)
function delete_condition(condition) function delete_condition(condition)
{ {
delete conditions[condition]; delete conditions[condition];
to_delete = $('#'+condition).prev();
if ($(to_delete).children().hasClass('btn_delete_condition'))
$(to_delete).remove();
else
$('#'+condition).next().remove();
$('#'+condition).remove(); $('#'+condition).remove();
return false; return false;
} }
@@ -185,7 +178,7 @@ function new_condition_group()
function appendConditionToGroup(html) function appendConditionToGroup(html)
{ {
if ($('#condition_group_'+current_id_condition_group+' table tbody tr').length > 0) if ($('#condition_group_'+current_id_condition_group+' table tbody tr').length > 0)
$('#condition_group_'+current_id_condition_group+' table tbody').append('<tr><td align="center" class="btn_delete_condition" colspan="3"><b>{l s='AND' js=1}</b></td></tr>'); $('#condition_group_'+current_id_condition_group+' table tbody').append('<tr><td align="center" colspan="3"><b>{l s='AND' js=1}</b></td></tr>');
$('#condition_group_'+current_id_condition_group+' table tbody').append(html); $('#condition_group_'+current_id_condition_group+' table tbody').append(html);
} }
@@ -291,7 +284,7 @@ $(document).ready(function() {
$('#id_attribute_group option[value="{$condition.id_attribute_group}"]').attr('selected', true); $('#id_attribute_group option[value="{$condition.id_attribute_group}"]').attr('selected', true);
$('#id_attribute_{$condition.id_attribute_group} option[value="{$condition.value}"]').attr('selected', true); $('#id_attribute_{$condition.id_attribute_group} option[value="{$condition.value}"]').attr('selected', true);
{elseif $condition.type == 'feature'} {elseif $condition.type == 'feature'}
$('#id_feature option[value="{$condition.id_feature}"]').attr('selected', true); $('#id_feature[value="{$condition.id_feature}"]').attr('selected', true);
$('#id_feature_{$condition.id_feature} option[value="{$condition.value}"]').attr('selected', true); $('#id_feature_{$condition.id_feature} option[value="{$condition.value}"]').attr('selected', true);
{else} {else}
$('#id_{$condition.type} option[value="{$condition.value}"]').attr('selected', true); $('#id_{$condition.type} option[value="{$condition.value}"]').attr('selected', true);
@@ -25,7 +25,7 @@
<div id="statsContainer"> <div id="statsContainer">
<div id="calendar"> <div id="calendar">
<form action="{$current}&token={$token}{if $action && $table}&{$action|escape}{$table|escape}{/if}{if $identifier && $id}&{$identifier|escape}={$id|escape}{/if}{if isset($smarty.get.module)}&module={$smarty.get.module|escape}{/if}{if isset($smarty.get.id_product)}&id_product={$smarty.get.id_product|escape}{/if}" method="post" id="calendar_form" name="calendar_form"> <form action="{$current}&token={$token}{if $action && $table}&{$action|escape}{$table|escape}{/if}{if $identifier && $id}&{$identifier|escape}={$id|escape}{/if}" method="post" id="calendar_form" name="calendar_form">
<input type="submit" name="submitDateDay" class="button submitDateDay" value="{$translations.Day}"> <input type="submit" name="submitDateDay" class="button submitDateDay" value="{$translations.Day}">
<input type="submit" name="submitDateMonth" class="button submitDateMonth" value="{$translations.Month}"> <input type="submit" name="submitDateMonth" class="button submitDateMonth" value="{$translations.Month}">
<input type="submit" name="submitDateYear" class="button submitDateYear" value="{$translations.Year}"> <input type="submit" name="submitDateYear" class="button submitDateYear" value="{$translations.Year}">
@@ -138,7 +138,7 @@
// check if it's possible to add the product // check if it's possible to add the product
if (product_infos == null || $('#cur_product_name').val() == '') if (product_infos == null || $('#cur_product_name').val() == '')
{ {
jAlert('{l s='Please select at least one product.' js=1}'); jAlert('{l s='Please select at least one product.' js='1'}');
return false; return false;
} }
+4 -5
View File
@@ -35,12 +35,11 @@
</div> </div>
<div class="footerRight"> <div class="footerRight">
{if $iso_is_fr} {if $iso_is_fr}
<span>Questions / Renseignements / Formations :</span> <strong>+33 (0)1.40.18.30.04</strong> <span>Questions / Renseignements / Formations :</span> <strong>+33 (0)1.40.18.30.04</strong> de 09h &agrave; 18h
{/if} {/if}
|&nbsp;<a href="http://www.prestashop.com/en/contact-us?utm_source=backoffice_footer" target="_blank" class="footer_link">{l s='Contact'}</a> |&nbsp;<a href="http://www.prestashop.com/en/contact_us/" target="_blank" class="footer_link">{l s='Contact'}</a>
|&nbsp;<a href="http://forge.prestashop.com/?utm_source=backoffice_footer" target="_blank" class="footer_link">{l s='Bug Tracker'}</a> |&nbsp;<a href="http://forge.prestashop.com" target="_blank" class="footer_link">{l s='Bug Tracker'}</a>
|&nbsp;<a href="http://www.prestashop.com/forums/?utm_source=backoffice_footer" target="_blank" class="footer_link">{l s='Forum'}</a> |&nbsp;<a href="http://www.prestashop.com/forums/" target="_blank" class="footer_link">{l s='Forum'}</a>
|&nbsp;<a href="http://addons.prestashop.com/?utm_source=backoffice_footer" target="_blank" class="footer_link">{l s='Addons'}</a>
</div> </div>
</div> </div>
</div> </div>
@@ -234,29 +234,17 @@
{/foreach} {/foreach}
{elseif $input.type == 'file'} {elseif $input.type == 'file'}
{if isset($input.display_image) && $input.display_image} {if isset($input.display_image) && $input.display_image}
{if isset($fields_value[$input.name].image) && $fields_value[$input.name].image} {if isset($fields_value.image) && $fields_value.image}
<div id="image"> <div id="image">
{$fields_value[$input.name].image} {$fields_value.image}
<p align="center">{l s='File size'} {$fields_value[$input.name].size}kb</p> <p align="center">{l s='File size'} {$fields_value.size}kb</p>
<a href="{$current}&{$identifier}={$form_id}&token={$token}&deleteImage=1"> <a href="{$current}&{$identifier}={$form_id}&token={$token}&deleteImage=1">
<img src="../img/admin/delete.gif" alt="{l s='Delete'}" /> {l s='Delete'} <img src="../img/admin/delete.gif" alt="{l s='Delete'}" /> {l s='Delete'}
</a> </a>
</div><br /> </div><br />
{/if} {/if}
{/if} {/if}
<input type="file" name="{$input.name}" {if isset($input.id)}id="{$input.id}"{/if} />
{if isset($input.lang) AND $input.lang}
<div class="translatable">
{foreach $languages as $language}
<div class="lang_{$language.id_lang}" id="{$input.name}_{$language.id_lang}" style="display:{if $language.id_lang == $defaultFormLanguage}block{else}none{/if}; float: left;">
<input type="file" name="{$input.name}_{$language.id_lang}" {if isset($input.id)}id="{$input.id}_{$language.id_lang}"{/if} />
</div>
{/foreach}
</div>
{else}
<input type="file" name="{$input.name}" {if isset($input.id)}id="{$input.id}"{/if} />
{/if}
{if !empty($input.hint)}<span class="hint" name="help_box">{$input.hint}<span class="hint-pointer">&nbsp;</span></span>{/if} {if !empty($input.hint)}<span class="hint" name="help_box">{$input.hint}<span class="hint-pointer">&nbsp;</span></span>{/if}
{elseif $input.type == 'password'} {elseif $input.type == 'password'}
<input type="password" <input type="password"
@@ -314,6 +302,7 @@
{if isset($input.class)}class="{$input.class}" {if isset($input.class)}class="{$input.class}"
{else}class="color mColorPickerInput"{/if} {else}class="color mColorPickerInput"{/if}
name="{$input.name}" name="{$input.name}"
class="{if isset($input.class)}{$input.class}{/if}"
value="{$fields_value[$input.name]|escape:'htmlall':'UTF-8'}" /> value="{$fields_value[$input.name]|escape:'htmlall':'UTF-8'}" />
{elseif $input.type == 'date'} {elseif $input.type == 'date'}
<input type="text" <input type="text"
@@ -354,13 +343,13 @@
{/if} {/if}
{/if} {/if}
{/foreach} {/foreach}
{hook h='displayAdminForm' fieldset=$f} {hook h='displayAdminForm'}
{if isset($name_controller)} {if isset($name_controller)}
{capture name=hookName assign=hookName}display{$name_controller|ucfirst}Form{/capture} {capture name=hookName assign=hookName}display{$name_controller|ucfirst}Form{/capture}
{hook h=$hookName fieldset=$f} {hook h=$hookName}
{elseif isset($smarty.get.controller)} {elseif isset($smarty.get.controller)}
{capture name=hookName assign=hookName}display{$smarty.get.controller|ucfirst|htmlentities}Form{/capture} {capture name=hookName assign=hookName}display{$smarty.get.controller|ucfirst|htmlentities}Form{/capture}
{hook h=$hookName fieldset=$f} {hook h=$hookName}
{/if} {/if}
{elseif $key == 'submit'} {elseif $key == 'submit'}
<div class="margin-form"> <div class="margin-form">
@@ -59,7 +59,7 @@
{block name="td_content"} {block name="td_content"}
{if isset($params.prefix)}{$params.prefix}{/if} {if isset($params.prefix)}{$params.prefix}{/if}
{if isset($params.color) && isset($tr[$params.color])} {if isset($params.color) && isset($tr[$params.color])}
<span class="color_field" style="background-color:{$tr[$params.color]};color:{if Tools::getBrightness($tr[$params.color]) < 128}white{else}#383838{/if}"> <span class="color_field" style="background-color:{$tr.color};color:{if Tools::getBrightness($tr.color) < 128}white{else}#383838{/if}">
{/if} {/if}
{if isset($tr.$key)} {if isset($tr.$key)}
{if isset($params.active)} {if isset($params.active)}
@@ -27,8 +27,8 @@
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$('table.{$list_id} .filter').keypress(function(event){ $('table.{$table} .filter').keypress(function(event){
formSubmit(event, 'submitFilterButton{$list_id}') formSubmit(event, 'submitFilterButton{$table}')
}) })
}); });
</script> </script>
@@ -37,7 +37,7 @@
<script type="text/javascript" src="../js/jquery/plugins/jquery.tablednd.js"></script> <script type="text/javascript" src="../js/jquery/plugins/jquery.tablednd.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var token = '{$token}'; var token = '{$token}';
var come_from = '{$list_id}'; var come_from = '{$table}';
var alternate = {if $order_way == 'DESC'}'1'{else}'0'{/if}; var alternate = {if $order_way == 'DESC'}'1'{else}'0'{/if};
</script> </script>
<script type="text/javascript" src="../js/admin-dnd.js"></script> <script type="text/javascript" src="../js/admin-dnd.js"></script>
@@ -45,8 +45,8 @@
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
if ($("table.{$list_id} .datepicker").length > 0) if ($("table.{$table} .datepicker").length > 0)
$("table.{$list_id} .datepicker").datepicker({ $("table.{$table} .datepicker").datepicker({
prevText: '', prevText: '',
nextText: '', nextText: '',
dateFormat: 'yy-mm-dd' dateFormat: 'yy-mm-dd'
@@ -83,7 +83,7 @@
{block name="override_form_extra"}{/block} {block name="override_form_extra"}{/block}
<input type="hidden" id="submitFilter{$list_id}" name="submitFilter{$list_id}" value="0"/> <input type="hidden" id="submitFilter{$table}" name="submitFilter{$table}" value="0"/>
{/if} {/if}
<table class="table_grid" name="list_table"> <table class="table_grid" name="list_table">
{if !$simple_header} {if !$simple_header}
@@ -91,16 +91,16 @@
<td style="vertical-align: bottom;"> <td style="vertical-align: bottom;">
<span style="float: left;"> <span style="float: left;">
{if $page > 1} {if $page > 1}
<input type="image" src="../img/admin/list-prev2.gif" onclick="getE('submitFilter{$list_id}').value=1"/>&nbsp; <input type="image" src="../img/admin/list-prev2.gif" onclick="getE('submitFilter{$table}').value=1"/>&nbsp;
<input type="image" src="../img/admin/list-prev.gif" onclick="getE('submitFilter{$list_id}').value={$page - 1}"/> <input type="image" src="../img/admin/list-prev.gif" onclick="getE('submitFilter{$table}').value={$page - 1}"/>
{/if} {/if}
{l s='Page'} <b>{$page}</b> / {$total_pages} {l s='Page'} <b>{$page}</b> / {$total_pages}
{if $page < $total_pages} {if $page < $total_pages}
<input type="image" src="../img/admin/list-next.gif" onclick="getE('submitFilter{$list_id}').value={$page + 1}"/>&nbsp; <input type="image" src="../img/admin/list-next.gif" onclick="getE('submitFilter{$table}').value={$page + 1}"/>&nbsp;
<input type="image" src="../img/admin/list-next2.gif" onclick="getE('submitFilter{$list_id}').value={$total_pages}"/> <input type="image" src="../img/admin/list-next2.gif" onclick="getE('submitFilter{$table}').value={$total_pages}"/>
{/if} {/if}
| {l s='Display'} | {l s='Display'}
<select name="{$list_id}_pagination" onchange="submit()"> <select name="pagination" onchange="submit()">
{* Choose number of results per page *} {* Choose number of results per page *}
{foreach $pagination AS $value} {foreach $pagination AS $value}
<option value="{$value|intval}"{if $selected_pagination == $value} selected="selected" {elseif $selected_pagination == NULL && $value == $pagination[1]} selected="selected2"{/if}>{$value|intval}</option> <option value="{$value|intval}"{if $selected_pagination == $value} selected="selected" {elseif $selected_pagination == NULL && $value == $pagination[1]} selected="selected2"{/if}>{$value|intval}</option>
@@ -109,8 +109,8 @@
/ {$list_total} {l s='result(s)'} / {$list_total} {l s='result(s)'}
</span> </span>
<span style="float: right;"> <span style="float: right;">
<input type="submit" id="submitFilterButton{$list_id}" name="submitFilter" value="{l s='Filter'}" class="button" /> <input type="submit" name="submitReset{$table}" value="{l s='Reset'}" class="button" />
<input type="submit" name="submitReset{$list_id}" value="{l s='Reset'}" class="button" /> <input type="submit" id="submitFilterButton{$table}" name="submitFilter" value="{l s='Filter'}" class="button" />
</span> </span>
<span class="clear"></span> <span class="clear"></span>
</td> </td>
@@ -120,7 +120,7 @@
<td{if $simple_header} style="border:none;"{/if}> <td{if $simple_header} style="border:none;"{/if}>
<table <table
{if $table_id} id={$table_id}{/if} {if $table_id} id={$table_id}{/if}
class="table {if $table_dnd}tableDnD{/if} {$list_id}" class="table {if $table_dnd}tableDnD{/if} {$table}"
cellpadding="0" cellspacing="0" cellpadding="0" cellspacing="0"
style="width: 100%; margin-bottom:10px;"> style="width: 100%; margin-bottom:10px;">
<col width="10px" /> <col width="10px" />
@@ -137,7 +137,7 @@
<tr class="nodrag nodrop" style="height: 40px"> <tr class="nodrag nodrop" style="height: 40px">
<th class="center"> <th class="center">
{if $has_bulk_actions} {if $has_bulk_actions}
<input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, '{$list_id}Box[]', this.checked)" /> <input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, '{$table}Box[]', this.checked)" />
{/if} {/if}
</th> </th>
{foreach $fields_display AS $key => $params} {foreach $fields_display AS $key => $params}
@@ -148,9 +148,9 @@
</span> </span>
{if (!isset($params.orderby) || $params.orderby) && !$simple_header} {if (!isset($params.orderby) || $params.orderby) && !$simple_header}
<br /> <br />
<a href="{$currentIndex}&{$list_id}Orderby={$key|urlencode}&{$list_id}Orderway=desc&token={$token}{if isset($smarty.get.$identifier)}&{$identifier}={$smarty.get.$identifier|intval}{/if}"> <a href="{$currentIndex}&{$table}Orderby={$key|urlencode}&{$table}Orderway=desc&token={$token}{if isset($smarty.get.$identifier)}&{$identifier}={$smarty.get.$identifier|intval}{/if}">
<img border="0" src="../img/admin/down{if isset($order_by) && ($key == $order_by) && ($order_way == 'DESC')}_d{/if}.gif" /></a> <img border="0" src="../img/admin/down{if isset($order_by) && ($key == $order_by) && ($order_way == 'DESC')}_d{/if}.gif" /></a>
<a href="{$currentIndex}&{$list_id}Orderby={$key|urlencode}&{$list_id}Orderway=asc&token={$token}{if isset($smarty.get.$identifier)}&{$identifier}={$smarty.get.$identifier|intval}{/if}"> <a href="{$currentIndex}&{$table}Orderby={$key|urlencode}&{$table}Orderway=asc&token={$token}{if isset($smarty.get.$identifier)}&{$identifier}={$smarty.get.$identifier|intval}{/if}">
<img border="0" src="../img/admin/up{if isset($order_by) && ($key == $order_by) && ($order_way == 'ASC')}_d{/if}.gif" /></a> <img border="0" src="../img/admin/up{if isset($order_by) && ($key == $order_by) && ($order_way == 'ASC')}_d{/if}.gif" /></a>
{elseif !$simple_header} {elseif !$simple_header}
<br />&nbsp; <br />&nbsp;
@@ -186,7 +186,7 @@
-- --
{else} {else}
{if $params.type == 'bool'} {if $params.type == 'bool'}
<select onchange="$('#submitFilterButton{$list_id}').focus();$('#submitFilterButton{$list_id}').click();" name="{$list_id}Filter_{$key}"> <select onchange="$('#submitFilterButton{$table}').focus();$('#submitFilterButton{$table}').click();" name="{$table}Filter_{$key}">
<option value="">--</option> <option value="">--</option>
<option value="1" {if $params.value == 1} selected="selected" {/if}>{l s='Yes'}</option> <option value="1" {if $params.value == 1} selected="selected" {/if}>{l s='Yes'}</option>
<option value="0" {if $params.value == 0 && $params.value != ''} selected="selected" {/if}>{l s='No'}</option> <option value="0" {if $params.value == 0 && $params.value != ''} selected="selected" {/if}>{l s='No'}</option>
@@ -196,7 +196,7 @@
{l s='To'} <input type="text" class="filter datepicker" id="{$params.id_date}_1" name="{$params.name_date}[1]" value="{if isset($params.value.1)}{$params.value.1}{/if}"{if isset($params.width)} style="width:70px"{/if}/> {l s='To'} <input type="text" class="filter datepicker" id="{$params.id_date}_1" name="{$params.name_date}[1]" value="{if isset($params.value.1)}{$params.value.1}{/if}"{if isset($params.width)} style="width:70px"{/if}/>
{elseif $params.type == 'select'} {elseif $params.type == 'select'}
{if isset($params.filter_key)} {if isset($params.filter_key)}
<select onchange="$('#submitFilterButton{$list_id}').focus();$('#submitFilterButton{$list_id}').click();" name="{$list_id}Filter_{$params.filter_key}" {if isset($params.width)} style="width:{$params.width}px"{/if}> <select onchange="$('#submitFilterButton{$table}').focus();$('#submitFilterButton{$table}').click();" name="{$table}Filter_{$params.filter_key}" {if isset($params.width)} style="width:{$params.width}px"{/if}>
<option value="" {if $params.value == ''} selected="selected" {/if}>--</option> <option value="" {if $params.value == ''} selected="selected" {/if}>--</option>
{if isset($params.list) && is_array($params.list)} {if isset($params.list) && is_array($params.list)}
{foreach $params.list AS $option_value => $option_display} {foreach $params.list AS $option_value => $option_display}
@@ -206,7 +206,7 @@
</select> </select>
{/if} {/if}
{else} {else}
<input type="text" class="filter" name="{$list_id}Filter_{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}" value="{$params.value|escape:'htmlall':'UTF-8'}" {if isset($params.width) && $params.width != 'auto'} style="width:{$params.width}px"{else}style="width:95%"{/if} /> <input type="text" class="filter" name="{$table}Filter_{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}" value="{$params.value|escape:'htmlall':'UTF-8'}" {if isset($params.width) && $params.width != 'auto'} style="width:{$params.width}px"{else}style="width:95%"{/if} />
{/if} {/if}
{/if} {/if}
</td> </td>
+1 -1
View File
@@ -35,7 +35,7 @@
</span> </span>
{if count($errors) == 1} {if count($errors) == 1}
{reset($errors)} {$errors[0]}
{else} {else}
{l s='%d errors' sprintf=$errors|count} {l s='%d errors' sprintf=$errors|count}
<br/> <br/>
@@ -38,7 +38,7 @@
<div style="float:right;margin:5px"> <div style="float:right;margin:5px">
<a href="#" onclick="$('#modules_list_container').slideUp();return false;"><img alt="X" src="../img/admin/close.png"></a> <a href="#" onclick="$('#modules_list_container').slideUp();return false;"><img alt="X" src="../img/admin/close.png"></a>
</div> </div>
<div id="modules_list_loader"><img src="../img/loader.gif" alt="" border="0" /></div> <div id="modules_list_loader"><img src="../img/loader.gif" alt="" border="0"></div>
<div id="modules_list_container_tab" style="display:none;"></div> <div id="modules_list_container_tab" style="display:none;"></div>
</div> </div>
{/if} {/if}
+5 -4
View File
@@ -313,10 +313,11 @@ class AddressCore extends ObjectModel
{ {
$key = 'address_exists_'.(int)$id_address; $key = 'address_exists_'.(int)$id_address;
if (!Cache::isStored($key)) if (!Cache::isStored($key))
{ Cache::store(
$id_address = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT `id_address` FROM '._DB_PREFIX_.'address a WHERE a.`id_address` = '.(int)$id_address); $key, Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
Cache::store($key, (bool)$id_address); SELECT `id_address`
} FROM '._DB_PREFIX_.'address a
WHERE a.`id_address` = '.(int)$id_address));
return Cache::retrieve($key); return Cache::retrieve($key);
} }
+5 -8
View File
@@ -142,15 +142,12 @@ class AttributeGroupCore extends ObjectModel
if (!AttributeGroup::cleanDeadCombinations()) if (!AttributeGroup::cleanDeadCombinations())
return false; return false;
/* Also delete related attributes */ /* Also delete related attributes */
if (count($to_remove)) if (Db::getInstance()->execute('
if (!Db::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_.'attribute_lang` DELETE FROM `'._DB_PREFIX_.'attribute_lang`
WHERE `id_attribute` IN ('.implode(',', $to_remove).')') || WHERE `id_attribute`
!Db::getInstance()->execute(' IN (SELECT id_attribute FROM `'._DB_PREFIX_.'attribute` WHERE `id_attribute_group` = '.(int)$this->id.')') === false ||
DELETE FROM `'._DB_PREFIX_.'attribute_shop` Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'attribute` WHERE `id_attribute_group` = '.(int)$this->id) === false)
WHERE `id_attribute` IN ('.implode(',', $to_remove).')') || return false;
!Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'attribute` WHERE `id_attribute_group` = '.(int)$this->id))
return false;
$this->cleanPositions(); $this->cleanPositions();
} }
$return = parent::delete(); $return = parent::delete();
+1 -1
View File
@@ -53,7 +53,7 @@ class CMSCore extends ObjectModel
'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), 'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), 'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 128), 'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 128),
'content' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml', 'size' => 3999999999999), 'content' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString', 'size' => 3999999999999),
), ),
); );
+4 -26
View File
@@ -753,7 +753,7 @@ class CarrierCore extends ObjectModel
* @param array $priceList Prices list in multiple arrays (changed to array since 1.5.0) * @param array $priceList Prices list in multiple arrays (changed to array since 1.5.0)
* @return boolean Insertion result * @return boolean Insertion result
*/ */
public function addDeliveryPrice($price_list, $delete = false) public function addDeliveryPrice($price_list)
{ {
if (!$price_list) if (!$price_list)
return false; return false;
@@ -772,17 +772,6 @@ class CarrierCore extends ObjectModel
if (!isset($values['id_shop_group'])) if (!isset($values['id_shop_group']))
$values['id_shop_group'] = (Shop::getContext() != Shop::CONTEXT_ALL) ? Shop::getContextShopGroupID() : null; $values['id_shop_group'] = (Shop::getContext() != Shop::CONTEXT_ALL) ? Shop::getContextShopGroupID() : null;
if ($delete)
Db::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_.'delivery`
WHERE id_shop = '.(int)$values['id_shop'].'
AND id_shop_group='.(int)$values['id_shop_group'].'
AND id_carrier='.(int)$values['id_carrier'].
($values['id_range_price'] !== null ? ' AND id_range_price='.(int)$values['id_range_price'] : '').
($values['id_range_weight'] !== null ? ' AND id_range_weight='.(int)$values['id_range_weight'] : '').'
AND id_zone='.(int)$values['id_zone']
);
$sql .= '('; $sql .= '(';
foreach ($values as $v) foreach ($values as $v)
{ {
@@ -886,7 +875,8 @@ class CarrierCore extends ObjectModel
(SELECT '.(int)$this->id.', `id_tax_rules_group`, `id_shop` (SELECT '.(int)$this->id.', `id_tax_rules_group`, `id_shop`
FROM `'._DB_PREFIX_.'carrier_tax_rules_group_shop` FROM `'._DB_PREFIX_.'carrier_tax_rules_group_shop`
WHERE `id_carrier`='.(int)$old_id.')'); WHERE `id_carrier`='.(int)$old_id.')');
// Update warehouse_carriers
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'warehouse_carrier SET id_carrier='.(int)$this->id.' WHERE id_carrier='.(int)$old_id);
} }
/** /**
@@ -1286,17 +1276,5 @@ class CarrierCore extends ObjectModel
return true; return true;
} }
public function setGroups($groups, $delete = true)
{
if ($delete)
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'carrier_group WHERE id_carrier = '.(int)$this->id);
if (!is_array($groups) || !count($groups))
return true;
$sql = 'INSERT INTO '._DB_PREFIX_.'carrier_group (id_carrier, id_group) VALUES ';
foreach ($groups as $id_group)
$sql .= '('.(int)$this->id.', '.(int)$id_group.'),';
return Db::getInstance()->execute(rtrim($sql, ','));
}
} }
+85 -73
View File
@@ -134,7 +134,6 @@ class CartCore extends ObjectModel
'cart_rows' => array('resource' => 'cart_row', 'virtual_entity' => true, 'fields' => array( 'cart_rows' => array('resource' => 'cart_row', 'virtual_entity' => true, 'fields' => array(
'id_product' => array('required' => true, 'xlink_resource' => 'products'), 'id_product' => array('required' => true, 'xlink_resource' => 'products'),
'id_product_attribute' => array('required' => true, 'xlink_resource' => 'combinations'), 'id_product_attribute' => array('required' => true, 'xlink_resource' => 'combinations'),
'id_address_delivery' => array('required' => true, 'xlink_resource' => 'addresses'),
'quantity' => array('required' => true), 'quantity' => array('required' => true),
) )
), ),
@@ -210,7 +209,7 @@ class CartCore extends ObjectModel
if (!isset($this->id_address_invoice) || $this->id_address_invoice == $id_address) if (!isset($this->id_address_invoice) || $this->id_address_invoice == $id_address)
{ {
$to_update = true; $to_update = true;
$this->id_address_invoice = $id_address_new; $this->context->cart->id_address_invoice = $id_address_new;
} }
if (!isset($this->id_address_delivery) || $this->id_address_delivery == $id_address) if (!isset($this->id_address_delivery) || $this->id_address_delivery == $id_address)
{ {
@@ -765,9 +764,6 @@ class CartCore extends ObjectModel
if (!Validate::isLoadedObject($cartRule)) if (!Validate::isLoadedObject($cartRule))
return false; return false;
if (Db::getInstance()->getValue('SELECT id_cart_rule FROM '._DB_PREFIX_.'cart_cart_rule WHERE id_cart = '.(int)$this->id))
return false;
// Add the cart rule to the cart // Add the cart rule to the cart
if (!Db::getInstance()->insert('cart_cart_rule', array( if (!Db::getInstance()->insert('cart_cart_rule', array(
'id_cart_rule' => (int)$id_cart_rule, 'id_cart_rule' => (int)$id_cart_rule,
@@ -2547,7 +2543,6 @@ class CartCore extends ObjectModel
if (empty($id_carrier) && $this->isCarrierInRange((int)Configuration::get('PS_CARRIER_DEFAULT'), (int)$id_zone)) if (empty($id_carrier) && $this->isCarrierInRange((int)Configuration::get('PS_CARRIER_DEFAULT'), (int)$id_zone))
$id_carrier = (int)Configuration::get('PS_CARRIER_DEFAULT'); $id_carrier = (int)Configuration::get('PS_CARRIER_DEFAULT');
$total_package_without_shipping_tax_inc = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $product_list);
if (empty($id_carrier)) if (empty($id_carrier))
{ {
if ((int)$this->id_customer) if ((int)$this->id_customer)
@@ -2582,7 +2577,7 @@ class CartCore extends ObjectModel
{ {
$check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $this->getTotalWeight(), (int)$id_zone); $check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $this->getTotalWeight(), (int)$id_zone);
$total_order = $total_package_without_shipping_tax_inc; $total_order = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $product_list);
$check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $total_order, (int)$id_zone, (int)$this->id_currency); $check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $total_order, (int)$id_zone, (int)$this->id_currency);
// Get only carriers that have a range compatible with cart // Get only carriers that have a range compatible with cart
@@ -2685,8 +2680,26 @@ class CartCore extends ObjectModel
$id_zone = (int)$default_country->id_zone; $id_zone = (int)$default_country->id_zone;
} }
if (($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && !Carrier::checkDeliveryPriceByWeight($carrier->id, $this->getTotalWeight(), (int)$id_zone)) $check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight((int)$carrier->id, $this->getTotalWeight(), (int)$id_zone);
|| ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && !Carrier::checkDeliveryPriceByPrice($carrier->id, $total_package_without_shipping_tax_inc, $id_zone, (int)$this->id_currency)
// Code Review V&V TO FINISH
$check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice(
$carrier->id,
$this->getOrderTotal(
true,
Cart::BOTH_WITHOUT_SHIPPING,
$product_list
),
$id_zone,
(int)$this->id_currency
);
if ((
$carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT
&& !$check_delivery_price_by_weight
) || (
$carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE
&& !$check_delivery_price_by_price
)) ))
$shipping_cost += 0; $shipping_cost += 0;
else else
@@ -2833,10 +2846,7 @@ class CartCore extends ObjectModel
$formatted_addresses['delivery'] = AddressFormat::getFormattedLayoutData($delivery); $formatted_addresses['delivery'] = AddressFormat::getFormattedLayoutData($delivery);
$formatted_addresses['invoice'] = AddressFormat::getFormattedLayoutData($invoice); $formatted_addresses['invoice'] = AddressFormat::getFormattedLayoutData($invoice);
$base_total_tax_inc = $this->getOrderTotal(true); $total_tax = $this->getOrderTotal() - $this->getOrderTotal(false);
$base_total_tax_exc = $this->getOrderTotal(false);
$total_tax = $base_total_tax_inc - $base_total_tax_exc;
if ($total_tax < 0) if ($total_tax < 0)
$total_tax = 0; $total_tax = 0;
@@ -2934,9 +2944,9 @@ class CartCore extends ObjectModel
'total_shipping_tax_exc' => $total_shipping_tax_exc, 'total_shipping_tax_exc' => $total_shipping_tax_exc,
'total_products_wt' => $total_products_wt, 'total_products_wt' => $total_products_wt,
'total_products' => $total_products, 'total_products' => $total_products,
'total_price' => $base_total_tax_inc, 'total_price' => $this->getOrderTotal(),
'total_tax' => $total_tax, 'total_tax' => $total_tax,
'total_price_without_tax' => $base_total_tax_exc, 'total_price_without_tax' => $this->getOrderTotal(false),
'is_multi_address_delivery' => $this->isMultiAddressDelivery() || ((int)Tools::getValue('multi-shipping') == 1), 'is_multi_address_delivery' => $this->isMultiAddressDelivery() || ((int)Tools::getValue('multi-shipping') == 1),
'free_ship' => $total_shipping ? 0 : 1, 'free_ship' => $total_shipping ? 0 : 1,
'carrier' => new Carrier($this->id_carrier, $id_lang), 'carrier' => new Carrier($this->id_carrier, $id_lang),
@@ -3034,10 +3044,8 @@ class CartCore extends ObjectModel
public function addTextFieldToProduct($id_product, $index, $type, $text_value) public function addTextFieldToProduct($id_product, $index, $type, $text_value)
{ {
$text_value = str_replace(array("\n", "\r"), '', nl2br($text_value)); $text_value = str_replace(array("\n", "\r"), '', nl2br($text_value));
if (!_PS_MAGIC_QUOTES_GPC_){ $text_value = str_replace('\\', '\\\\', $text_value);
$text_value = str_replace('\\', '\\\\', $text_value); $text_value = str_replace('\'', '\\\'', $text_value);
$text_value = str_replace('\'', '\\\'', $text_value);
}
return $this->_addCustomization($id_product, 0, $index, $type, $text_value, 0); return $this->_addCustomization($id_product, 0, $index, $type, $text_value, 0);
} }
@@ -3213,24 +3221,25 @@ class CartCore extends ObjectModel
public function getWsCartRows() public function getWsCartRows()
{ {
return Db::getInstance()->executeS(' $query = '
SELECT id_product, id_product_attribute, quantity SELECT id_product, id_product_attribute, quantity
FROM `'._DB_PREFIX_.'cart_product` FROM `'._DB_PREFIX_.'cart_product`
WHERE id_cart = '.(int)$this->id.' AND id_shop = '.(int)Context::getContext()->shop->id WHERE id_cart = '.(int)$this->id.'
); AND id_shop = '.(int)Context::getContext()->shop->id;
$result = Db::getInstance()->executeS($query);
return $result;
} }
public function setWsCartRows($values) public function setWsCartRows($values)
{ {
if ($this->deleteAssociations()) if ($this->deleteAssociations())
{ {
$query = 'INSERT INTO `'._DB_PREFIX_.'cart_product`(`id_cart`, `id_product`, `id_product_attribute`, `id_address_delivery`, `quantity`, `date_add`, `id_shop`) VALUES '; $query = 'INSERT INTO `'._DB_PREFIX_.'cart_product`(`id_cart`, `id_product`, `id_product_attribute`, `quantity`, `date_add`, `id_shop`) VALUES ';
foreach ($values as $value) foreach ($values as $value)
$query .= '('.(int)$this->id.', '.(int)$value['id_product'].', '. $query .= '('.(int)$this->id.', '.(int)$value['id_product'].', '.
(isset($value['id_product_attribute']) ? (int)$value['id_product_attribute'] : 'NULL').', '. (isset($value['id_product_attribute']) ? (int)$value['id_product_attribute'] : 'NULL').', '.(int)$value['quantity'].', NOW(), '.(int)Context::getContext()->shop->id.'),';
(isset($value['id_address_delivery']) ? (int)$value['id_address_delivery'] : 0).', '.
(int)$value['quantity'].', NOW(), '.(int)Context::getContext()->shop->id.'),';
Db::getInstance()->execute(rtrim($query, ',')); Db::getInstance()->execute(rtrim($query, ','));
} }
@@ -3415,59 +3424,62 @@ class CartCore extends ObjectModel
*/ */
public function setNoMultishipping() public function setNoMultishipping()
{ {
if (Configuration::get('PS_ALLOW_MULTISHIPPING')) // Upgrading quantities
$sql = 'SELECT sum(`quantity`) as quantity, id_product, id_product_attribute, count(*) as count
FROM `'._DB_PREFIX_.'cart_product`
WHERE `id_cart` = '.(int)$this->id.'
AND `id_shop` = '.(int)$this->id_shop.'
GROUP BY id_product, id_product_attribute
HAVING count > 1';
foreach (Db::getInstance()->executeS($sql) as $product)
{ {
// Upgrading quantities $sql = 'UPDATE `'._DB_PREFIX_.'cart_product`
$sql = 'SELECT sum(`quantity`) as quantity, id_product, id_product_attribute, count(*) as count SET `quantity` = '.$product['quantity'].'
FROM `'._DB_PREFIX_.'cart_product` WHERE `id_cart` = '.(int)$this->id.'
WHERE `id_cart` = '.(int)$this->id.' AND `id_shop` = '.(int)$this->id_shop.'
AND `id_shop` = '.(int)$this->id_shop.' AND id_product = '.$product['id_product'].'
GROUP BY id_product, id_product_attribute AND id_product_attribute = '.$product['id_product_attribute'];
HAVING count > 1'; Db::getInstance()->execute($sql);
foreach (Db::getInstance()->executeS($sql) as $product)
{
$sql = 'UPDATE `'._DB_PREFIX_.'cart_product`
SET `quantity` = '.$product['quantity'].'
WHERE `id_cart` = '.(int)$this->id.'
AND `id_shop` = '.(int)$this->id_shop.'
AND id_product = '.$product['id_product'].'
AND id_product_attribute = '.$product['id_product_attribute'];
Db::getInstance()->execute($sql);
}
// Merging multiple lines
$sql = 'DELETE cp1
FROM `'._DB_PREFIX_.'cart_product` cp1
INNER JOIN `'._DB_PREFIX_.'cart_product` cp2
ON (
(cp1.id_cart = cp2.id_cart)
AND (cp1.id_product = cp2.id_product)
AND (cp1.id_product_attribute = cp2.id_product_attribute)
AND (cp1.id_address_delivery <> cp2.id_address_delivery)
AND (cp1.date_add > cp2.date_add)
)';
Db::getInstance()->execute($sql);
} }
// Update delivery address for each product line // Merging multiple lines
Db::getInstance()->execute(' $sql = 'DELETE cp1
UPDATE `'._DB_PREFIX_.'cart_product` FROM `'._DB_PREFIX_.'cart_product` cp1
SET `id_address_delivery` = ( INNER JOIN `'._DB_PREFIX_.'cart_product` cp2
SELECT `id_address_delivery` FROM `'._DB_PREFIX_.'cart` ON (
WHERE `id_cart` = '.(int)$this->id.' AND `id_shop` = '.(int)$this->id_shop.' (cp1.id_cart = cp2.id_cart)
) AND (cp1.id_product = cp2.id_product)
WHERE `id_cart` = '.(int)$this->id.' AND (cp1.id_product_attribute = cp2.id_product_attribute)
'.(Configuration::get('PS_ALLOW_MULTISHIPPING') ? ' AND `id_shop` = '.(int)$this->id_shop : '')); AND (cp1.id_address_delivery <> cp2.id_address_delivery)
AND (cp1.date_add > cp2.date_add)
)';
Db::getInstance()->execute($sql);
if (Customization::isFeatureActive()) // Upgrading address delivery
Db::getInstance()->execute(' $sql = 'UPDATE `'._DB_PREFIX_.'cart_product`
UPDATE `'._DB_PREFIX_.'customization` SET `id_address_delivery` =
SET `id_address_delivery` = ( (
SELECT `id_address_delivery` FROM `'._DB_PREFIX_.'cart` SELECT `id_address_delivery`
FROM `'._DB_PREFIX_.'cart`
WHERE `id_cart` = '.(int)$this->id.'
AND `id_shop` = '.(int)$this->id_shop.'
)
WHERE `id_cart` = '.(int)$this->id.'
'.(Configuration::get('PS_ALLOW_MULTISHIPPING') ? ' AND `id_shop` = '.(int)$this->id_shop : '');
Db::getInstance()->execute($sql);
$sql = 'UPDATE `'._DB_PREFIX_.'customization`
SET `id_address_delivery` =
(
SELECT `id_address_delivery`
FROM `'._DB_PREFIX_.'cart`
WHERE `id_cart` = '.(int)$this->id.' WHERE `id_cart` = '.(int)$this->id.'
) )
WHERE `id_cart` = '.(int)$this->id); WHERE `id_cart` = '.(int)$this->id;
Db::getInstance()->execute($sql);
} }
/** /**
+44 -23
View File
@@ -10,7 +10,7 @@
* http://opensource.org/licenses/osl-3.0.php * http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to * If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email * obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately. * to license@prestashop.com so we can send you a copy 502immediately.
* *
* DISCLAIMER * DISCLAIMER
* *
@@ -495,14 +495,36 @@ class CartRuleCore extends ObjectModel
$cartTotal = $context->cart->getOrderTotal($this->minimum_amount_tax, Cart::ONLY_PRODUCTS); $cartTotal = $context->cart->getOrderTotal($this->minimum_amount_tax, Cart::ONLY_PRODUCTS);
if ($this->minimum_amount_shipping) if ($this->minimum_amount_shipping)
$cartTotal += $context->cart->getOrderTotal($this->minimum_amount_tax, Cart::ONLY_SHIPPING); $cartTotal += $context->cart->getOrderTotal($this->minimum_amount_tax, Cart::ONLY_SHIPPING);
$products = $context->cart->getProducts();
$cart_rules = $context->cart->getCartRules();
foreach ($cart_rules as &$cart_rule) // If a product is given for free in this rule and already in the cart, the price is subtracted
if ($cart_rule['gift_product']) if ($this->gift_product && $alreadyInCart)
foreach ($products as $key => &$product) {
if (empty($product['gift']) && $product['id_product'] == $cart_rule['gift_product'] && $product['id_product_attribute'] == $cart_rule['gift_product_attribute']) $query = new DbQuery();
$cartTotal = Tools::ps_round($cartTotal - $product[$this->minimum_amount_tax ? 'price_wt' : 'price'], (int)$context->currency->decimals * _PS_PRICE_DISPLAY_PRECISION_);
$query->select('id_product');
$query->from('cart_product');
$query->where('id_product = '.(int)$this->gift_product);
$query->where('id_cart = '.(int)$context->cart->id);
if ((int)$this->gift_product_attribute)
$query->where('id_product_attribute = '.(int)$this->gift_product_attribute);
if (Db::getInstance()->getValue($query))
{
$ref = false;
$product_price = Product::getPriceStatic(
$this->gift_product,
$this->minimum_amount_tax,
$this->gift_product_attribute,
null, null, false, true, 1, null,
$context->cart->id_customer ? $context->cart->id_customer : null,
$context->cart->id,
(int)$context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')} ? (int)$context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')} : null,
$ref, true, true, $context, true
);
$cartTotal -= $product_price;
}
}
if ($cartTotal < $minimum_amount) if ($cartTotal < $minimum_amount)
return (!$display_error) ? false : Tools::displayError('You have not reached the minimum amount required to use this voucher'); return (!$display_error) ? false : Tools::displayError('You have not reached the minimum amount required to use this voucher');
@@ -1082,33 +1104,32 @@ class CartRuleCore extends ObjectModel
'.($context->customer->id ? 'OR cr.id_customer = '.(int)$context->cart->id_customer : '').' '.($context->customer->id ? 'OR cr.id_customer = '.(int)$context->cart->id_customer : '').'
) )
AND ( AND (
cr.`carrier_restriction` = 0 cr.carrier_restriction = 0
'.($context->cart->id_carrier ? 'OR c.id_carrier = '.(int)$context->cart->id_carrier : '').' '.($context->cart->id_carrier ? 'OR c.id_carrier = '.(int)$context->cart->id_carrier : '').'
) )
AND ( AND (
cr.`shop_restriction` = 0 cr.shop_restriction = 0
'.((Shop::isFeatureActive() && $context->shop->id) ? 'OR crs.id_shop = '.(int)$context->shop->id : '').' '.((Shop::isFeatureActive() && $context->shop->id) ? 'OR crs.id_shop = '.(int)$context->shop->id : '').'
) )
AND ( AND (
cr.`group_restriction` = 0 cr.group_restriction = 0
'.($context->customer->id ? 'OR 0 < ( '.($context->customer->id ? 'OR 0 < (
SELECT cg.`id_group` SELECT cg.id_group
FROM `'._DB_PREFIX_.'customer_group` cg FROM '._DB_PREFIX_.'customer_group cg
INNER JOIN `'._DB_PREFIX_.'cart_rule_group` crg ON cg.id_group = crg.id_group LEFT JOIN '._DB_PREFIX_.'cart_rule_group crg ON (cg.id_group = crg.id_group AND cg.id_group = '.(int)$context->customer->id_default_group.')
WHERE cr.`id_cart_rule` = crg.`id_cart_rule` WHERE cr.id_cart_rule = crg.id_cart_rule
AND cg.`id_customer` = '.(int)$context->customer->id.' AND cg.id_customer = '.(int)$context->customer->id.' LIMIT 1
LIMIT 1
)' : '').' )' : '').'
) )
AND ( AND (
cr.`reduction_product` <= 0 cr.reduction_product <= 0
OR cr.`reduction_product` IN ( OR cr.reduction_product IN (
SELECT `id_product` SELECT id_product
FROM `'._DB_PREFIX_.'cart_product` FROM '._DB_PREFIX_.'cart_product
WHERE `id_cart` = '.(int)$context->cart->id.' WHERE id_cart = '.(int)$context->cart->id.'
) )
) )
AND cr.id_cart_rule NOT IN (SELECT id_cart_rule FROM '._DB_PREFIX_.'cart_cart_rule WHERE id_cart = '.(int)$context->cart->id.') AND cr.id_cart_rule NOT IN (SELECT id_cart_rule FROM '._DB_PREFIX_.'cart_cart_rule WHERE id_cart = '.(int)$context->cart->id.')
ORDER BY priority'; ORDER BY priority';
$result = Db::getInstance()->executeS($sql); $result = Db::getInstance()->executeS($sql);
if ($result) if ($result)
+18 -12
View File
@@ -109,7 +109,7 @@ class CategoryCore extends ObjectModel
// Lang fields // Lang fields
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64), 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64),
'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 64), 'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 64),
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'), 'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'),
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128), 'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), 'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), 'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
@@ -796,7 +796,7 @@ class CategoryCore extends ObjectModel
)).')'; )).')';
$flag = Db::getInstance()->execute(' $flag = Db::getInstance()->execute('
INSERT IGNORE INTO `'._DB_PREFIX_.'category_product` (`id_product`, `id_category`, `position`) INSERT INTO `'._DB_PREFIX_.'category_product` (`id_product`, `id_category`, `position`)
VALUES '.implode(',', $row) VALUES '.implode(',', $row)
); );
return $flag; return $flag;
@@ -831,15 +831,20 @@ class CategoryCore extends ObjectModel
if (!Validate::isUnsignedId($id_category) || !Validate::isUnsignedId($id_lang)) if (!Validate::isUnsignedId($id_category) || !Validate::isUnsignedId($id_lang))
return false; return false;
if (!isset(self::$_links[$id_category.'-'.$id_lang])) if (isset(self::$_links[$id_category.'-'.$id_lang]))
self::$_links[$id_category.'-'.$id_lang] = Db::getInstance()->getValue(' return self::$_links[$id_category.'-'.$id_lang];
SELECT cl.`link_rewrite`
FROM `'._DB_PREFIX_.'category_lang` cl $result = Db::getInstance()->getRow('
WHERE `id_lang` = '.(int)$id_lang.' SELECT cl.`link_rewrite`
'.Shop::addSqlRestrictionOnLang('cl').' FROM `'._DB_PREFIX_.'category_lang` cl
AND cl.`id_category` = '.(int)$id_category WHERE `id_lang` = '.(int)$id_lang.'
); '.Shop::addSqlRestrictionOnLang('cl').'
return self::$_links[$id_category.'-'.$id_lang]; AND cl.`id_category` = '.(int)$id_category
);
self::$_links[$id_category.'-'.$id_lang] = $result['link_rewrite'];
return $result['link_rewrite'];
} }
public function getLink(Link $link = null) public function getLink(Link $link = null)
@@ -1390,7 +1395,8 @@ class CategoryCore extends ObjectModel
SELECT DISTINCT c.* SELECT DISTINCT c.*
FROM `'._DB_PREFIX_.'category` c FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.(int)Context::getContext()->language->id.') LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.(int)Context::getContext()->language->id.')
WHERE `level_depth` = 1'); WHERE `level_depth` = 1
');
} }
public function isRootCategoryForAShop() public function isRootCategoryForAShop()
-43
View File
@@ -75,16 +75,6 @@ class CollectionCore implements Iterator, ArrayAccess, Countable
*/ */
protected $total; protected $total;
/**
* @var int Page number
*/
protected $page_number = 0;
/**
* @var int Size of a page
*/
protected $page_size = 0;
protected $fields = array(); protected $fields = array();
protected $alias = array(); protected $alias = array();
protected $alias_iterator = 0; protected $alias_iterator = 0;
@@ -345,11 +335,6 @@ class CollectionCore implements Iterator, ArrayAccess, Countable
} }
} }
// All limit clause
if ($this->page_size)
$this->query->limit($this->page_size, $this->page_number * $this->page_size);
// Shall we display query for debug ? // Shall we display query for debug ?
if ($display_query) if ($display_query)
echo $this->query.'<br />'; echo $this->query.'<br />';
@@ -675,34 +660,6 @@ class CollectionCore implements Iterator, ArrayAccess, Countable
return $this->fields[$field]; return $this->fields[$field];
} }
/**
* Set the page number
*
* @param int $page_number
* @return Collection
*/
public function setPageNumber($page_number)
{
$page_number = (int)$page_number;
if ($page_number > 0)
$page_number--;
$this->page_number = $page_number;
return $this;
}
/**
* Set the nuber of item per page
*
* @param int $page_size
* @return Collection
*/
public function setPageSize($page_size)
{
$this->page_size = (int)$page_size;
return $this;
}
/** /**
* Generate uniq alias from association name * Generate uniq alias from association name
* *
-8
View File
@@ -103,13 +103,6 @@ class CombinationCore extends ObjectModel
// Removes the product from StockAvailable, for the current shop // Removes the product from StockAvailable, for the current shop
StockAvailable::removeProductFromStockAvailable((int)$this->id_product, (int)$this->id); StockAvailable::removeProductFromStockAvailable((int)$this->id_product, (int)$this->id);
if ($specific_prices = SpecificPrice::getByProductId((int)$this->id_product, (int)$this->id))
foreach ($specific_prices as $specific_price)
{
$price = new SpecificPrice((int)$specific_price['id_specific_price']);
$price->delete();
}
if (!$this->hasMultishopEntries() && !$this->deleteAssociations()) if (!$this->hasMultishopEntries() && !$this->deleteAssociations())
return false; return false;
return true; return true;
@@ -135,7 +128,6 @@ class CombinationCore extends ObjectModel
{ {
$result = Db::getInstance()->delete('product_attribute_combination', '`id_product_attribute` = '.(int)$this->id); $result = Db::getInstance()->delete('product_attribute_combination', '`id_product_attribute` = '.(int)$this->id);
$result &= Db::getInstance()->delete('cart_product', '`id_product_attribute` = '.(int)$this->id); $result &= Db::getInstance()->delete('cart_product', '`id_product_attribute` = '.(int)$this->id);
$result &= Db::getInstance()->delete('product_attribute_image', '`id_product_attribute` = '.(int)$this->id);
return $result; return $result;
} }
+1
View File
@@ -49,6 +49,7 @@ class ConfigurationTestCore
'mysql_support' => false, 'mysql_support' => false,
'config_dir' => 'config', 'config_dir' => 'config',
'cache_dir' => 'cache', 'cache_dir' => 'cache',
'sitemap' => 'sitemap.xml',
'log_dir' => 'log', 'log_dir' => 'log',
'img_dir' => 'img', 'img_dir' => 'img',
'mails_dir' => 'mails', 'mails_dir' => 'mails',
-4
View File
@@ -82,12 +82,8 @@ class ConnectionCore extends ObjectModel
// The connection is created if it does not exist yet and we get the current page id // The connection is created if it does not exist yet and we get the current page id
if (!isset($cookie->id_connections) || !strstr(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', Tools::getHttpHost(false, false))) if (!isset($cookie->id_connections) || !strstr(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', Tools::getHttpHost(false, false)))
$id_page = Connection::setNewConnection($cookie); $id_page = Connection::setNewConnection($cookie);
// If we do not track the pages, no need to get the page id
if (!Configuration::get('PS_STATSDATA_PAGESVIEWS') && !Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS'))
return array();
if (!isset($id_page) || !$id_page) if (!isset($id_page) || !$id_page)
$id_page = Page::getCurrentId(); $id_page = Page::getCurrentId();
// If we do not track the page views by customer, the id_page is the only information needed
if (!Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS')) if (!Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS'))
return array('id_page' => $id_page); return array('id_page' => $id_page);
-4
View File
@@ -298,11 +298,7 @@ class CookieCore
//checks if the language exists, if not choose the default language //checks if the language exists, if not choose the default language
if (!$this->_standalone && !Language::getLanguage((int)$this->id_lang)) if (!$this->_standalone && !Language::getLanguage((int)$this->id_lang))
{
$this->id_lang = Configuration::get('PS_LANG_DEFAULT'); $this->id_lang = Configuration::get('PS_LANG_DEFAULT');
// set detect_language to force going through Tools::setCookieLanguage to figure out browser lang
$this->detect_language = true;
}
} }
+12 -15
View File
@@ -121,23 +121,20 @@ class CountryCore extends ObjectModel
public static function getCountries($id_lang, $active = false, $contain_states = false, $list_states = true) public static function getCountries($id_lang, $active = false, $contain_states = false, $list_states = true)
{ {
$countries = array(); $countries = array();
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT cl.*,c.*, cl.`name` country, z.`name` zone
SELECT cl.*,c.*, cl.`name` country, z.`name` zone FROM `'._DB_PREFIX_.'country` c '.Shop::addSqlAssociation('country', 'c').'
FROM `'._DB_PREFIX_.'country` c '.Shop::addSqlAssociation('country', 'c').' LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = '.(int)$id_lang.')
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = '.(int)$id_lang.') LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = c.`id_zone`)
LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = c.`id_zone`) WHERE 1'.($active ? ' AND c.active = 1' : '').($contain_states ? ' AND c.`contains_states` = '.(int)$contain_states : '').'
WHERE 1'.($active ? ' AND c.active = 1' : '').($contain_states ? ' AND c.`contains_states` = '.(int)$contain_states : '').' ORDER BY cl.name ASC') as $country)
ORDER BY cl.name ASC'); $countries[$country['id_country']] = $country;
foreach ($result as $row)
$countries[$row['id_country']] = $row;
if ($list_states) if ($list_states)
{ foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'state` ORDER BY `name` ASC') as $state)
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'state` ORDER BY `name` ASC'); if (isset($countries[$state['id_country']])) /* Does not keep the state if its country has been disabled and not selected */
foreach ($result as $row) if ($state['active'] == 1)
if (isset($countries[$row['id_country']]) && $row['active'] == 1) /* Does not keep the state if its country has been disabled and not selected */ $countries[$state['id_country']]['states'][] = $state;
$countries[$row['id_country']]['states'][] = $row;
}
return $countries; return $countries;
} }
+29 -55
View File
@@ -379,12 +379,12 @@ class DispatcherCore
/** /**
* Load default routes group by languages * Load default routes group by languages
*/ */
protected function loadRoutes($id_shop = null) protected function loadRoutes()
{ {
$context = Context::getContext(); $context = Context::getContext();
// Load custom routes from modules // Load custom routes from modules
$modules_routes = Hook::exec('moduleRoutes', array('id_shop' => $id_shop), null, true, false); $modules_routes = Hook::exec('moduleRoutes', array(), null, true, false);
if (is_array($modules_routes) && count($modules_routes)) if (is_array($modules_routes) && count($modules_routes))
foreach($modules_routes as $module_route) foreach($modules_routes as $module_route)
foreach($module_route as $route => $route_details) foreach($module_route as $route => $route_details)
@@ -405,8 +405,7 @@ class DispatcherCore
$route['controller'], $route['controller'],
$lang['id_lang'], $lang['id_lang'],
$route['keywords'], $route['keywords'],
isset($route['params']) ? $route['params'] : array(), isset($route['params']) ? $route['params'] : array()
$id_shop
); );
// Load the custom routes prior the defaults to avoid infinite loops // Load the custom routes prior the defaults to avoid infinite loops
@@ -421,13 +420,13 @@ class DispatcherCore
// Load routes from meta table // Load routes from meta table
$sql = 'SELECT m.page, ml.url_rewrite, ml.id_lang $sql = 'SELECT m.page, ml.url_rewrite, ml.id_lang
FROM `'._DB_PREFIX_.'meta` m FROM `'._DB_PREFIX_.'meta` m
LEFT JOIN `'._DB_PREFIX_.'meta_lang` ml ON (m.id_meta = ml.id_meta'.Shop::addSqlRestrictionOnLang('ml', $id_shop).') LEFT JOIN `'._DB_PREFIX_.'meta_lang` ml ON (m.id_meta = ml.id_meta'.Shop::addSqlRestrictionOnLang('ml').')
ORDER BY LENGTH(ml.url_rewrite) DESC'; ORDER BY LENGTH(ml.url_rewrite) DESC';
if ($results = Db::getInstance()->executeS($sql)) if ($results = Db::getInstance()->executeS($sql))
foreach ($results as $row) foreach ($results as $row)
{ {
if ($row['url_rewrite']) if ($row['url_rewrite'])
$this->addRoute($row['page'], $row['url_rewrite'], $row['page'], $row['id_lang'], array(), array(), $id_shop); $this->addRoute($row['page'], $row['url_rewrite'], $row['page'], $row['id_lang']);
} }
// Set default empty route if no empty route (that's weird I know) // Set default empty route if no empty route (that's weird I know)
@@ -440,7 +439,7 @@ class DispatcherCore
// Load custom routes // Load custom routes
foreach ($this->default_routes as $route_id => $route_data) foreach ($this->default_routes as $route_id => $route_data)
if ($custom_route = Configuration::get('PS_ROUTE_'.$route_id, null, null, $id_shop)) if ($custom_route = Configuration::get('PS_ROUTE_'.$route_id))
foreach (Language::getLanguages() as $lang) foreach (Language::getLanguages() as $lang)
$this->addRoute( $this->addRoute(
$route_id, $route_id,
@@ -448,8 +447,7 @@ class DispatcherCore
$route_data['controller'], $route_data['controller'],
$lang['id_lang'], $lang['id_lang'],
$route_data['keywords'], $route_data['keywords'],
isset($route_data['params']) ? $route_data['params'] : array(), isset($route_data['params']) ? $route_data['params'] : array()
$id_shop
); );
} }
} }
@@ -460,15 +458,11 @@ class DispatcherCore
* @param string $rule Url rule * @param string $rule Url rule
* @param string $controller Controller to call if request uri match the rule * @param string $controller Controller to call if request uri match the rule
* @param int $id_lang * @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) public function addRoute($route_id, $rule, $controller, $id_lang = null, array $keywords = array(), array $params = array())
{ {
if ($id_lang === null) if (is_null($id_lang))
$id_lang = (int)Context::getContext()->language->id; $id_lang = Context::getContext()->language->id;
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
$regexp = preg_quote($rule, '#'); $regexp = preg_quote($rule, '#');
if ($keywords) if ($keywords)
@@ -503,12 +497,10 @@ class DispatcherCore
} }
$regexp = '#^/'.$regexp.'(\?.*)?$#u'; $regexp = '#^/'.$regexp.'(\?.*)?$#u';
if (!isset($this->routes[$id_shop])) if (!isset($this->routes[$id_lang]))
$this->routes[$id_shop] = array(); $this->routes[$id_lang] = 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( $this->routes[$id_lang][$route_id] = array(
'rule' => $rule, 'rule' => $rule,
'regexp' => $regexp, 'regexp' => $regexp,
'controller' => $controller, 'controller' => $controller,
@@ -522,17 +514,14 @@ class DispatcherCore
* *
* @param string $route_id * @param string $route_id
* @param int $id_lang * @param int $id_lang
* @param int $id_shop
* @return bool * @return bool
*/ */
public function hasRoute($route_id, $id_lang = null, $id_shop = null) public function hasRoute($route_id, $id_lang = null)
{ {
if ($id_lang === null) if (is_null($id_lang))
$id_lang = (int)Context::getContext()->language->id; $id_lang = Context::getContext()->language->id;
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
return isset($this->routes[$id_shop]) && isset($this->routes[$id_shop][$id_lang]) && isset($this->routes[$id_shop][$id_lang][$route_id]); return isset($this->routes[$id_lang]) && isset($this->routes[$id_lang][$route_id]);
} }
/** /**
@@ -541,21 +530,14 @@ class DispatcherCore
* @param string $route_id * @param string $route_id
* @param int $id_lang * @param int $id_lang
* @param string $keyword * @param string $keyword
* @param int $id_shop
* @return bool * @return bool
*/ */
public function hasKeyword($route_id, $id_lang, $keyword, $id_shop = null) public function hasKeyword($route_id, $id_lang, $keyword)
{ {
if ($id_shop === null) if (!isset($this->routes[$id_lang]) && !isset($this->routes[$id_lang][$route_id]))
$id_shop = (int)Context::getContext()->shop->id;
if ($this->use_routes && !isset($this->routes[$id_shop]))
$this->loadRoutes($id_shop);
if (!isset($this->routes[$id_shop]) || !isset($this->routes[$id_shop][$id_lang]) || !isset($this->routes[$id_shop][$id_lang][$route_id]))
return false; return false;
return preg_match('#\{([^{}]*:)?'.preg_quote($keyword, '#').'(:[^{}]*)?\}#', $this->routes[$id_shop][$id_lang][$route_id]['rule']); return preg_match('#\{([^{}]*:)?'.preg_quote($keyword, '#').'(:[^{}]*)?\}#', $this->routes[$id_lang][$route_id]['rule']);
} }
/** /**
@@ -587,23 +569,18 @@ class DispatcherCore
* @param bool $use_routes If false, don't use to create this url * @param bool $use_routes If false, don't use to create this url
* @param string $anchor Optional anchor to add at the end of this url * @param string $anchor Optional anchor to add at the end of this url
*/ */
public function createUrl($route_id, $id_lang = null, array $params = array(), $force_routes = false, $anchor = '', $id_shop = null) public function createUrl($route_id, $id_lang = null, array $params = array(), $force_routes = false, $anchor = '')
{ {
if ($id_lang === null) if (!$id_lang)
$id_lang = (int)Context::getContext()->language->id; $id_lang = Context::getContext()->language->id;
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
if ($this->use_routes && !isset($this->routes[$id_shop])) if (!isset($this->routes[$id_lang][$route_id]))
$this->loadRoutes($id_shop);
if (!isset($this->routes[$id_shop][$id_lang][$route_id]))
{ {
$query = http_build_query($params, '', '&'); $query = http_build_query($params, '', '&');
$index_link = $this->use_routes ? '' : 'index.php'; $index_link = $this->use_routes ? '' : 'index.php';
return ($route_id == 'index') ? $index_link.(($query) ? '?'.$query : '') : 'index.php?controller='.$route_id.(($query) ? '&'.$query : '').$anchor; return ($route_id == 'index') ? $index_link.(($query) ? '?'.$query : '') : 'index.php?controller='.$route_id.(($query) ? '&'.$query : '').$anchor;
} }
$route = $this->routes[$id_shop][$id_lang][$route_id]; $route = $this->routes[$id_lang][$route_id];
// Check required fields // Check required fields
$query_params = isset($route['params']) ? $route['params'] : array(); $query_params = isset($route['params']) ? $route['params'] : array();
foreach ($route['keywords'] as $key => $data) foreach ($route['keywords'] as $key => $data)
@@ -669,7 +646,7 @@ class DispatcherCore
* *
* @return string * @return string
*/ */
public function getController($id_shop = null) public function getController()
{ {
if (defined('_PS_ADMIN_DIR_')) if (defined('_PS_ADMIN_DIR_'))
$_GET['controllerUri'] = Tools::getvalue('controller'); $_GET['controllerUri'] = Tools::getvalue('controller');
@@ -679,9 +656,6 @@ class DispatcherCore
return $this->controller; return $this->controller;
} }
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
$controller = Tools::getValue('controller'); $controller = Tools::getValue('controller');
if (isset($controller) && is_string($controller) && preg_match('/^([0-9a-z_-]+)\?(.*)=(.*)$/Ui', $controller, $m)) if (isset($controller) && is_string($controller) && preg_match('/^([0-9a-z_-]+)\?(.*)=(.*)$/Ui', $controller, $m))
@@ -708,10 +682,10 @@ class DispatcherCore
{ {
// Add empty route as last route to prevent this greedy regexp to match request uri before right time // Add empty route as last route to prevent this greedy regexp to match request uri before right time
if ($this->empty_route) 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'], Context::getContext()->language->id);
if (isset($this->routes[$id_shop][Context::getContext()->language->id])) if (isset($this->routes[Context::getContext()->language->id]))
foreach ($this->routes[$id_shop][Context::getContext()->language->id] as $route) foreach ($this->routes[Context::getContext()->language->id] as $route)
if (preg_match($route['regexp'], $this->request_uri, $m)) if (preg_match($route['regexp'], $this->request_uri, $m))
{ {
// Route found ! Now fill $_GET with parameters of uri // Route found ! Now fill $_GET with parameters of uri
+6 -12
View File
@@ -244,15 +244,12 @@ class EmployeeCore extends ObjectModel
*/ */
public function isLoggedBack() public function isLoggedBack()
{ {
if (!Cache::isStored('isLoggedBack'.$this->id)) /* Employee is valid only if it can be load and if cookie password is the same as database one */
{ return ($this->id
/* Employee is valid only if it can be load and if cookie password is the same as database one */ && Validate::isUnsignedId($this->id)
Cache::store('isLoggedBack'.$this->id, ( && Employee::checkPassword($this->id, $this->passwd)
$this->id && Validate::isUnsignedId($this->id) && Employee::checkPassword($this->id, Context::getContext()->cookie->passwd) && (!isset($this->remote_addr) || $this->remote_addr == ip2long(Tools::getRemoteAddr()) || !Configuration::get('PS_COOKIE_CHECKIP'))
&& (!isset(Context::getContext()->cookie->remote_addr) || Context::getContext()->cookie->remote_addr == ip2long(Tools::getRemoteAddr()) || !Configuration::get('PS_COOKIE_CHECKIP')) );
));
}
return Cache::retrieve('isLoggedBack'.$this->id);
} }
/** /**
@@ -261,10 +258,7 @@ class EmployeeCore extends ObjectModel
public function logout() public function logout()
{ {
if (isset(Context::getContext()->cookie)) if (isset(Context::getContext()->cookie))
{
Context::getContext()->cookie->logout(); Context::getContext()->cookie->logout();
Context::getContext()->cookie->write();
}
$this->id = null; $this->id = null;
} }
-7
View File
@@ -70,13 +70,6 @@ class GroupCore extends ObjectModel
protected $webserviceParameters = array(); protected $webserviceParameters = array();
public function __construct($id = null, $id_lang = null, $id_shop = null)
{
parent::__construct($id, $id_lang, $id_shop);
if ($this->id && !isset(Group::$group_price_display_method[$this->id]))
self::$group_price_display_method[$this->id] = $this->price_display_method;
}
public static function getGroups($id_lang, $id_shop = false) public static function getGroups($id_lang, $id_shop = false)
{ {
$shop_criteria = ''; $shop_criteria = '';
+2 -7
View File
@@ -216,18 +216,13 @@ class GroupReductionCore extends ObjectModel
FROM `'._DB_PREFIX_.'product_group_reduction_cache` pgr FROM `'._DB_PREFIX_.'product_group_reduction_cache` pgr
WHERE pgr.`id_product` = '.(int)$id_product_old WHERE pgr.`id_product` = '.(int)$id_product_old
); );
if (!$res) if (!$res)
return true; return true;
$query = '';
foreach ($res as $row) foreach ($res as $row)
{ {
$query .= 'INSERT INTO `'._DB_PREFIX_.'product_group_reduction_cache` (`id_product`, `id_group`, `reduction`) VALUES '; $query = 'INSERT INTO `'._DB_PREFIX_.'product_group_reduction_cache` (`id_product`, `id_group`, `reduction`) VALUES ';
$query .= '('.(int)$id_product.', '.(int)$row['id_group'].', '.(float)$row['reduction'].') ON DUPLICATE KEY UPDATE `reduction` = '.(float)$row['reduction'].';'; $query .= '('.(int)$id_product.', '.(int)$row['id_group'].', '.(float)$row['reduction'].')';
} }
return Db::getInstance()->execute($query); return Db::getInstance()->execute($query);
} }
+31 -51
View File
@@ -64,10 +64,10 @@ class HookCore extends ObjectModel
'primary' => 'id_hook', 'primary' => 'id_hook',
'fields' => array( 'fields' => array(
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isHookName', 'required' => true, 'size' => 64), 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isHookName', 'required' => true, 'size' => 64),
'title' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'title' => array('type' => self::TYPE_STRING),
'description' => array('type' => self::TYPE_HTML, 'validate' => 'isCleanHtml'), 'description' => array('type' => self::TYPE_HTML),
'position' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'position' => array('type' => self::TYPE_BOOL),
'live_edit' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'live_edit' => array('type' => self::TYPE_BOOL),
), ),
); );
@@ -83,7 +83,7 @@ class HookCore extends ObjectModel
public function add($autodate = true, $null_values = false) public function add($autodate = true, $null_values = false)
{ {
Cache::clean('hook_idsbyname'); Cache::clean('hook_idbyname_'.$this->name);
return parent::add($autodate, $null_values); return parent::add($autodate, $null_values);
} }
@@ -110,30 +110,22 @@ class HookCore extends ObjectModel
*/ */
public static function getIdByName($hook_name) public static function getIdByName($hook_name)
{ {
$hook_name = strtolower($hook_name);
if (!Validate::isHookName($hook_name)) if (!Validate::isHookName($hook_name))
return false; return false;
$cache_id = 'hook_idsbyname'; $cache_id = 'hook_idbyname_'.$hook_name;
if (!Cache::isStored($cache_id)) if (!Cache::isStored($cache_id))
{ {
// Get all hook ID by name and alias $retro_hook_name = Hook::getRetroHookName($hook_name);
$hook_ids = array(); Cache::store($cache_id, Db::getInstance()->getValue('
$result = Db::getInstance()->ExecuteS(' SELECT `id_hook`
SELECT `id_hook`, `name` FROM `'._DB_PREFIX_.'hook`
FROM `'._DB_PREFIX_.'hook` WHERE `name` = \''.pSQL($hook_name).'\'
UNION OR `name` = \''.pSQL($retro_hook_name).'\'
SELECT `id_hook`, ha.`alias` as name '));
FROM `'._DB_PREFIX_.'hook_alias` ha
INNER JOIN `'._DB_PREFIX_.'hook` h ON ha.name = h.name');
foreach ($result as $row)
$hook_ids[strtolower($row['name'])] = $row['id_hook'];
Cache::store($cache_id, $hook_ids);
} }
else
$hook_ids = Cache::retrieve($cache_id);
return (isset($hook_ids[$hook_name]) ? $hook_ids[$hook_name] : false); return Cache::retrieve($cache_id);
} }
/** /**
@@ -148,21 +140,7 @@ class HookCore extends ObjectModel
FROM `'._DB_PREFIX_.'hook` FROM `'._DB_PREFIX_.'hook`
WHERE `id_hook` = '.(int)$hook_id) WHERE `id_hook` = '.(int)$hook_id)
); );
return Cache::retrieve($cache_id);
}
/**
* Return hook live edit bool from ID
*/
public static function getLiveEditById($hook_id)
{
$cache_id = 'hook_live_editbyid_'.$hook_id;
if (!Cache::isStored($cache_id))
Cache::store($cache_id, Db::getInstance()->getValue('
SELECT `live_edit`
FROM `'._DB_PREFIX_.'hook`
WHERE `id_hook` = '.(int)$hook_id)
);
return Cache::retrieve($cache_id); return Cache::retrieve($cache_id);
} }
@@ -330,9 +308,15 @@ class HookCore extends ObjectModel
$sql->orderBy('hm.`position`'); $sql->orderBy('hm.`position`');
// Store results per hook name
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
$list = array(); $list = array();
if ($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql))
foreach ($result as $row) // Get all available payment module
$payment_modules = array();
if ($results)
foreach ($results as $row)
{ {
$row['hook'] = strtolower($row['hook']); $row['hook'] = strtolower($row['hook']);
if (!isset($list[$row['hook']])) if (!isset($list[$row['hook']]))
@@ -362,17 +346,14 @@ class HookCore extends ObjectModel
$hook_name = strtolower($hook_name); $hook_name = strtolower($hook_name);
$return = array(); $return = array();
$inserted_modules = array();
if (isset($list[$hook_name])) if (isset($list[$hook_name]))
$return = $list[$hook_name]; $return = $list[$hook_name];
foreach ($return as $module)
$inserted_modules[] = $module['id_module'];
if (isset($list[$retro_hook_name])) if (isset($list[$retro_hook_name]))
foreach ($list[$retro_hook_name] as $retro_module_call) $return = array_merge($return, $list[$retro_hook_name]);
if (!in_array($retro_module_call['id_module'], $inserted_modules))
$return[] = $retro_module_call;
return (count($return) > 0 ? $return : false); if (count($return) > 0)
return $return;
return false;
} }
else else
return $list; return $list;
@@ -416,7 +397,6 @@ class HookCore extends ObjectModel
// Look on modules list // Look on modules list
$altern = 0; $altern = 0;
$output = ''; $output = '';
foreach ($module_list as $array) foreach ($module_list as $array)
{ {
// Check errors // Check errors
@@ -438,7 +418,7 @@ class HookCore extends ObjectModel
$matching_name = array( $matching_name = array(
'authentication' => 'auth', 'authentication' => 'auth',
'compare' => 'products-comparison', 'compare' => 'products-comparison',
); );
if (isset($matching_name[$controller]) && in_array($matching_name[$controller], $exceptions)) if (isset($matching_name[$controller]) && in_array($matching_name[$controller], $exceptions))
continue; continue;
if (Validate::isLoadedObject($context->employee) && !$moduleInstance->getPermission('view', $context->employee)) if (Validate::isLoadedObject($context->employee) && !$moduleInstance->getPermission('view', $context->employee))
@@ -472,7 +452,7 @@ class HookCore extends ObjectModel
if ($array_return) if ($array_return)
return $output; return $output;
else else
return ($live_edit ? '<script type="text/javascript">hooks_list.push(\''.$hook_name.'\');</script> return ($live_edit ? '<script type="text/javascript">hooks_list.push(\''.$hook_name.'\'); </script>
<div id="'.$hook_name.'" class="dndHook" style="min-height:50px">' : '').$output.($live_edit ? '</div>' : '');// Return html string <div id="'.$hook_name.'" class="dndHook" style="min-height:50px">' : '').$output.($live_edit ? '</div>' : '');// Return html string
} }
@@ -481,13 +461,13 @@ class HookCore extends ObjectModel
return '<script type="text/javascript"> modules_list.push(\''.Tools::safeOutput($moduleInstance->name).'\');</script> return '<script type="text/javascript"> modules_list.push(\''.Tools::safeOutput($moduleInstance->name).'\');</script>
<div id="hook_'.(int)$id_hook.'_module_'.(int)$moduleInstance->id.'_moduleName_'.str_replace('_', '-', Tools::safeOutput($moduleInstance->name)).'" <div id="hook_'.(int)$id_hook.'_module_'.(int)$moduleInstance->id.'_moduleName_'.str_replace('_', '-', Tools::safeOutput($moduleInstance->name)).'"
class="dndModule" style="border: 1px dotted red;'.(!strlen($display) ? 'height:50px;' : '').'"> class="dndModule" style="border: 1px dotted red;'.(!strlen($display) ? 'height:50px;' : '').'">
<span style="font-family: Georgia;font-size:13px;font-style:italic;"> <span style="font-family: Georgia;font-size:13px;font-style:italic;">
<img style="padding-right:5px;" src="'._MODULE_DIR_.Tools::safeOutput($moduleInstance->name).'/logo.gif">' <img style="padding-right:5px;" src="'._MODULE_DIR_.Tools::safeOutput($moduleInstance->name).'/logo.gif">'
.Tools::safeOutput($moduleInstance->displayName).'<span style="float:right"> .Tools::safeOutput($moduleInstance->displayName).'<span style="float:right">
<a href="#" id="'.(int)$id_hook.'_'.(int)$moduleInstance->id.'" class="moveModule"> <a href="#" id="'.(int)$id_hook.'_'.(int)$moduleInstance->id.'" class="moveModule">
<img src="'._PS_ADMIN_IMG_.'arrow_out.png"></a> <img src="'._PS_ADMIN_IMG_.'arrow_out.png"></a>
<a href="#" id="'.(int)$id_hook.'_'.(int)$moduleInstance->id.'" class="unregisterHook"> <a href="#" id="'.(int)$id_hook.'_'.(int)$moduleInstance->id.'" class="unregisterHook">
<img src="'._PS_ADMIN_IMG_.'delete.gif"></a></span> <img src="'._PS_ADMIN_IMG_.'delete.gif"></span></a>
</span>'.$display.'</div>'; </span>'.$display.'</div>';
} }
-1
View File
@@ -407,7 +407,6 @@ class ImageManagerCore
case 'jpeg': case 'jpeg':
default: default:
$quality = (Configuration::get('PS_JPEG_QUALITY') === false ? 90 : Configuration::get('PS_JPEG_QUALITY')); $quality = (Configuration::get('PS_JPEG_QUALITY') === false ? 90 : Configuration::get('PS_JPEG_QUALITY'));
imageinterlace($resource,1); /// make it PROGRESSIVE
$success = imagejpeg($resource, $filename, (int)$quality); $success = imagejpeg($resource, $filename, (int)$quality);
break; break;
} }
+12 -13
View File
@@ -70,7 +70,7 @@ class LanguageCore extends ObjectModel
/** @var array Languages cache */ /** @var array Languages cache */
protected static $_checkedLangs; protected static $_checkedLangs;
protected static $_LANGUAGES; protected static $_LANGUAGES;
protected static $countActiveLanguages = array(); protected static $countActiveLanguages;
protected $webserviceParameters = array( protected $webserviceParameters = array(
'objectNodeName' => 'language', 'objectNodeName' => 'language',
@@ -262,7 +262,7 @@ class LanguageCore extends ObjectModel
$mPath_to = _PS_MAIL_DIR_.(string)$iso_to.'/'; $mPath_to = _PS_MAIL_DIR_.(string)$iso_to.'/';
} }
$lFiles = array('admin.php', 'errors.php', 'fields.php', 'pdf.php', 'tabs.php'); $lFiles = array('admin.php', 'errors.php', 'fields.php', 'pdf.php', 'tabs.php', 'index.php');
// Added natives mails files // Added natives mails files
$mFiles = array( $mFiles = array(
@@ -297,7 +297,7 @@ class LanguageCore extends ObjectModel
'test.html', 'test.txt', 'test.html', 'test.txt',
'voucher.html', 'voucher.txt', 'voucher.html', 'voucher.txt',
'voucher_new.html', 'voucher_new.txt', 'voucher_new.html', 'voucher_new.txt',
'order_changed.html', 'order_changed.txt' 'order_changed.html', 'order_changed.txt', 'index.php'
); );
$number = -1; $number = -1;
@@ -704,8 +704,10 @@ class LanguageCore extends ObjectModel
$lang->name = $lang_pack->name; $lang->name = $lang_pack->name;
} }
elseif ($params_lang !== null && is_array($params_lang)) elseif ($params_lang !== null && is_array($params_lang))
{
foreach ($params_lang as $key => $value) foreach ($params_lang as $key => $value)
$lang->$key = $value; $lang->$key = $value;
}
else else
return false; return false;
@@ -762,18 +764,15 @@ class LanguageCore extends ObjectModel
return (isset(self::$_cache_language_installation[$iso_code]) ? self::$_cache_language_installation[$iso_code] : false); return (isset(self::$_cache_language_installation[$iso_code]) ? self::$_cache_language_installation[$iso_code] : false);
} }
public static function countActiveLanguages($id_shop = null) public static function countActiveLanguages()
{ {
if ($id_shop === null) if (!self::$countActiveLanguages)
$id_shop = (int)Context::getContext()->shop->id; self::$countActiveLanguages = Db::getInstance()->getValue('
if (!isset(self::$countActiveLanguages[$id_shop]))
self::$countActiveLanguages[$id_shop] = Db::getInstance()->getValue('
SELECT COUNT(DISTINCT l.id_lang) FROM `'._DB_PREFIX_.'lang` l SELECT COUNT(DISTINCT l.id_lang) FROM `'._DB_PREFIX_.'lang` l
JOIN '._DB_PREFIX_.'lang_shop lang_shop ON (lang_shop.id_lang = l.id_lang AND lang_shop.id_shop = '.(int)$id_shop.') '.Shop::addSqlAssociation('lang', 'l').'
WHERE l.`active` = 1 WHERE l.`active` = 1
'); ');
return self::$countActiveLanguages[$id_shop]; return self::$countActiveLanguages;
} }
public static function downloadAndInstallLanguagePack($iso, $version = null, $params = null) public static function downloadAndInstallLanguagePack($iso, $version = null, $params = null)
@@ -828,8 +827,8 @@ class LanguageCore extends ObjectModel
* @since 1.5.0 * @since 1.5.0
* @return bool * @return bool
*/ */
public static function isMultiLanguageActivated($id_shop = null) public static function isMultiLanguageActivated()
{ {
return (Language::countActiveLanguages($id_shop) > 1); return (Language::countActiveLanguages() > 1);
} }
} }
+57 -125
View File
@@ -91,19 +91,19 @@ class LinkCore
if (!$id_lang) if (!$id_lang)
$id_lang = Context::getContext()->language->id; $id_lang = Context::getContext()->language->id;
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && $id_shop !== null) if (!$id_shop)
$shop = new Shop($id_shop);
else
$shop = Context::getContext()->shop; $shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop); $url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
if (!is_object($product)) if (!is_object($product))
{ {
if (is_array($product) && isset($product['id_product'])) if (is_array($product) && isset($product['id_product']))
$product = new Product($product['id_product'], false, $id_lang, $id_shop); $product = new Product($product['id_product'], false, $id_lang);
elseif ((int)$product) else if (is_numeric($product) || !$product)
$product = new Product((int)$product, false, $id_lang, $id_shop); $product = new Product($product, false, $id_lang);
else else
throw new PrestaShopException('Invalid product vars'); throw new PrestaShopException('Invalid product vars');
} }
@@ -112,30 +112,29 @@ class LinkCore
$params = array(); $params = array();
$params['id'] = $product->id; $params['id'] = $product->id;
$params['rewrite'] = (!$alias) ? $product->getFieldByLang('link_rewrite') : $alias; $params['rewrite'] = (!$alias) ? $product->getFieldByLang('link_rewrite') : $alias;
$params['ean13'] = (!$ean13) ? $product->ean13 : $ean13; $params['ean13'] = (!$ean13) ? $product->ean13 : $ean13;
$params['meta_keywords'] = Tools::str2url($product->getFieldByLang('meta_keywords')); $params['meta_keywords'] = Tools::str2url($product->getFieldByLang('meta_keywords'));
$params['meta_title'] = Tools::str2url($product->getFieldByLang('meta_title')); $params['meta_title'] = Tools::str2url($product->getFieldByLang('meta_title'));
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'manufacturer', $id_shop)) if ($dispatcher->hasKeyword('product_rule', $id_lang, 'manufacturer'))
$params['manufacturer'] = Tools::str2url($product->isFullyLoaded ? $product->manufacturer_name : Manufacturer::getNameById($product->id_manufacturer)); $params['manufacturer'] = Tools::str2url($product->isFullyLoaded ? $product->manufacturer_name : Manufacturer::getNameById($product->id_manufacturer));
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'supplier', $id_shop)) if ($dispatcher->hasKeyword('product_rule', $id_lang, 'supplier'))
$params['supplier'] = Tools::str2url($product->isFullyLoaded ? $product->supplier_name : Supplier::getNameById($product->id_supplier)); $params['supplier'] = Tools::str2url($product->isFullyLoaded ? $product->supplier_name : Supplier::getNameById($product->id_supplier));
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'price', $id_shop)) if ($dispatcher->hasKeyword('product_rule', $id_lang, 'price'))
$params['price'] = $product->isFullyLoaded ? $product->price : Product::getPriceStatic($product->id, false, null, 6, null, false, true, 1, false, null, null, null, $product->specificPrice); $params['price'] = $product->isFullyLoaded ? $product->price : Product::getPriceStatic($product->id, false, null, 6, null, false, true, 1, false, null, null, null, $product->specificPrice);
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'tags', $id_shop)) if ($dispatcher->hasKeyword('product_rule', $id_lang, 'tags'))
$params['tags'] = Tools::str2url($product->getTags($id_lang)); $params['tags'] = Tools::str2url($product->getTags($id_lang));
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'category', $id_shop)) if ($dispatcher->hasKeyword('product_rule', $id_lang, 'category'))
$params['category'] = (!is_null($product->category) && !empty($product->category)) ? Tools::str2url($product->category) : Tools::str2url($category); $params['category'] = !is_null($product->category) ? Tools::str2url($product->category) : Tools::str2url($category);
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'reference', $id_shop)) if ($dispatcher->hasKeyword('product_rule', $id_lang, 'reference'))
$params['reference'] = Tools::str2url($product->reference); $params['reference'] = Tools::str2url($product->reference);
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'categories', $id_shop)) if ($dispatcher->hasKeyword('product_rule', $id_lang, 'categories'))
{ {
$params['category'] = (!$category) ? $product->category : $category; $params['category'] = (!$category) ? $product->category : $category;
$cats = array(); $cats = array();
@@ -146,7 +145,7 @@ class LinkCore
} }
$anchor = $ipa ? $product->getAnchor($ipa) : ''; $anchor = $ipa ? $product->getAnchor($ipa) : '';
return $url.$dispatcher->createUrl('product_rule', $id_lang, $params, $force_routes, $anchor, $id_shop); return $url.$dispatcher->createUrl('product_rule', $id_lang, $params, $force_routes, $anchor);
} }
/** /**
@@ -158,16 +157,11 @@ class LinkCore
* @param string $selected_filters Url parameter to autocheck filters of the module blocklayered * @param string $selected_filters Url parameter to autocheck filters of the module blocklayered
* @return string * @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)
{ {
if (!$id_lang) if (!$id_lang)
$id_lang = Context::getContext()->language->id; $id_lang = Context::getContext()->language->id;
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
if (!is_object($category)) if (!is_object($category))
$category = new Category($category, $id_lang); $category = new Category($category, $id_lang);
@@ -190,7 +184,7 @@ class LinkCore
$params['selected_filters'] = $selected_filters; $params['selected_filters'] = $selected_filters;
} }
return $url.Dispatcher::getInstance()->createUrl($rule, $id_lang, $params, $this->allow, '', $id_shop); return $url.Dispatcher::getInstance()->createUrl($rule, $id_lang, $params, $this->allow);
} }
/** /**
@@ -201,33 +195,24 @@ class LinkCore
* @param int $id_lang * @param int $id_lang
* @return string * @return string
*/ */
public function getCMSCategoryLink($cms_category, $alias = null, $id_lang = null, $id_shop = null) public function getCMSCategoryLink($category, $alias = null, $id_lang = null)
{ {
if (!$id_lang) if (!$id_lang)
$id_lang = Context::getContext()->language->id; $id_lang = Context::getContext()->language->id;
if ($id_shop === null) $url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
$dispatcher = Dispatcher::getInstance(); if (!is_object($category))
if (!is_object($cms_category)) $category = new CMSCategory($category, $id_lang);
{
if ($alias !== null && !$dispatcher->hasKeyword('cms_category_rule', $id_lang, 'meta_keywords', $id_shop) && !$dispatcher->hasKeyword('cms_category_rule', $id_lang, 'meta_title', $id_shop))
return $url.$dispatcher->createUrl('cms_category_rule', $id_lang, array('id' => (int)$cms_category, 'rewrite' => (string)$alias), $this->allow, '', $id_shop);
$cms_category = new CMSCategory($cms_category, $id_lang);
}
// Set available keywords // Set available keywords
$params = array(); $params = array();
$params['id'] = $cms_category->id; $params['id'] = $category->id;
$params['rewrite'] = (!$alias) ? $cms_category->link_rewrite : $alias; $params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias;
$params['meta_keywords'] = Tools::str2url($cms_category->meta_keywords); $params['meta_keywords'] = Tools::str2url($category->meta_keywords);
$params['meta_title'] = Tools::str2url($cms_category->meta_title); $params['meta_title'] = Tools::str2url($category->meta_title);
return $url.$dispatcher->createUrl('cms_category_rule', $id_lang, $params, $this->allow, '', $id_shop); return $url.Dispatcher::getInstance()->createUrl('cms_category_rule', $id_lang, $params, $this->allow);
} }
/** /**
@@ -239,42 +224,33 @@ class LinkCore
* @param int $id_lang * @param int $id_lang
* @return string * @return string
*/ */
public function getCMSLink($cms, $alias = null, $ssl = false, $id_lang = null, $id_shop = null) public function getCMSLink($cms, $alias = null, $ssl = false, $id_lang = null)
{ {
$base = (($ssl && $this->ssl_enable) ? 'https://' : 'http://'); $base = (($ssl && $this->ssl_enable) ? _PS_BASE_URL_SSL_ : _PS_BASE_URL_);
if (!$id_lang) if (!$id_lang)
$id_lang = Context::getContext()->language->id; $id_lang = Context::getContext()->language->id;
$url = $base.__PS_BASE_URI__.$this->getLangLink($id_lang);
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = $base.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
$dispatcher = Dispatcher::getInstance();
if (!is_object($cms)) if (!is_object($cms))
{
if ($alias !== null && !$dispatcher->hasKeyword('cms_rule', $id_lang, 'meta_keywords', $id_shop) && !$dispatcher->hasKeyword('cms_rule', $id_lang, 'meta_title', $id_shop))
return $url.$dispatcher->createUrl('cms_rule', $id_lang, array('id' => (int)$cms, 'rewrite' => (string)$alias), $this->allow, '', $id_shop);
$cms = new CMS($cms, $id_lang); $cms = new CMS($cms, $id_lang);
}
// Set available keywords // Set available keywords
$params = array(); $params = array();
$params['id'] = $cms->id; $params['id'] = $cms->id;
$params['rewrite'] = (!$alias) ? (is_array($cms->link_rewrite) ? $cms->link_rewrite[(int)$id_lang] : $cms->link_rewrite) : $alias; $params['rewrite'] = (!$alias) ? (is_array($cms->link_rewrite) ? $cms->link_rewrite[(int)$id_lang] : $cms->link_rewrite) : $alias;
$params['meta_keywords'] = '';
if (isset($cms->meta_keywords) && !empty($cms->meta_keywords)) if (isset($cms->meta_keywords) && !empty($cms->meta_keywords))
$params['meta_keywords'] = is_array($cms->meta_keywords) ? Tools::str2url($cms->meta_keywords[(int)$id_lang]) : Tools::str2url($cms->meta_keywords); $params['meta_keywords'] = is_array($cms->meta_keywords) ? Tools::str2url($cms->meta_keywords[(int)$id_lang]) : Tools::str2url($cms->meta_keywords);
else
$params['meta_keywords'] = '';
$params['meta_title'] = '';
if (isset($cms->meta_title) && !empty($cms->meta_title)) if (isset($cms->meta_title) && !empty($cms->meta_title))
$params['meta_title'] = is_array($cms->meta_title) ? Tools::str2url($cms->meta_title[(int)$id_lang]) : Tools::str2url($cms->meta_title); $params['meta_title'] = is_array($cms->meta_title) ? Tools::str2url($cms->meta_title[(int)$id_lang]) : Tools::str2url($cms->meta_title);
else
$params['meta_title'] = '';
return $url.$dispatcher->createUrl('cms_rule', $id_lang, $params, $this->allow, '', $id_shop); return $url.Dispatcher::getInstance()->createUrl('cms_rule', $id_lang, $params, $this->allow);
} }
/** /**
@@ -285,24 +261,14 @@ class LinkCore
* @param int $id_lang * @param int $id_lang
* @return string * @return string
*/ */
public function getSupplierLink($supplier, $alias = null, $id_lang = null, $id_shop = null) public function getSupplierLink($supplier, $alias = null, $id_lang = null)
{ {
if (!$id_lang) if (!$id_lang)
$id_lang = Context::getContext()->language->id; $id_lang = Context::getContext()->language->id;
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
$dispatcher = Dispatcher::getInstance();
if (!is_object($supplier)) if (!is_object($supplier))
{
if ($alias !== null && !$dispatcher->hasKeyword('supplier_rule', $id_lang, 'meta_keywords', $id_shop) && !$dispatcher->hasKeyword('supplier_rule', $id_lang, 'meta_title', $id_shop))
return $url.$dispatcher->createUrl('supplier_rule', $id_lang, array('id' => (int)$supplier, 'rewrite' => (string)$alias), $this->allow, '', $id_shop);
$supplier = new Supplier($supplier, $id_lang); $supplier = new Supplier($supplier, $id_lang);
}
// Set available keywords // Set available keywords
$params = array(); $params = array();
@@ -311,7 +277,7 @@ class LinkCore
$params['meta_keywords'] = Tools::str2url($supplier->meta_keywords); $params['meta_keywords'] = Tools::str2url($supplier->meta_keywords);
$params['meta_title'] = Tools::str2url($supplier->meta_title); $params['meta_title'] = Tools::str2url($supplier->meta_title);
return $url.$dispatcher->createUrl('supplier_rule', $id_lang, $params, $this->allow, '', $id_shop); return $url.Dispatcher::getInstance()->createUrl('supplier_rule', $id_lang, $params, $this->allow);
} }
/** /**
@@ -322,24 +288,14 @@ class LinkCore
* @param int $id_lang * @param int $id_lang
* @return string * @return string
*/ */
public function getManufacturerLink($manufacturer, $alias = null, $id_lang = null, $id_shop = null) public function getManufacturerLink($manufacturer, $alias = null, $id_lang = null)
{ {
if (!$id_lang) if (!$id_lang)
$id_lang = Context::getContext()->language->id; $id_lang = Context::getContext()->language->id;
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
$dispatcher = Dispatcher::getInstance();
if (!is_object($manufacturer)) if (!is_object($manufacturer))
{
if ($alias !== null && !$dispatcher->hasKeyword('manufacturer_rule', $id_lang, 'meta_keywords', $id_shop) && !$dispatcher->hasKeyword('manufacturer_rule', $id_lang, 'meta_title', $id_shop))
return $url.$dispatcher->createUrl('manufacturer_rule', $id_lang, array('id' => (int)$manufacturer, 'rewrite' => (string)$alias), $this->allow, '', $id_shop);
$manufacturer = new Manufacturer($manufacturer, $id_lang); $manufacturer = new Manufacturer($manufacturer, $id_lang);
}
// Set available keywords // Set available keywords
$params = array(); $params = array();
@@ -348,7 +304,7 @@ class LinkCore
$params['meta_keywords'] = Tools::str2url($manufacturer->meta_keywords); $params['meta_keywords'] = Tools::str2url($manufacturer->meta_keywords);
$params['meta_title'] = Tools::str2url($manufacturer->meta_title); $params['meta_title'] = Tools::str2url($manufacturer->meta_title);
return $url.$dispatcher->createUrl('manufacturer_rule', $id_lang, $params, $this->allow, '', $id_shop); return $url.Dispatcher::getInstance()->createUrl('manufacturer_rule', $id_lang, $params, $this->allow);
} }
/** /**
@@ -360,29 +316,23 @@ class LinkCore
* @param int $id_lang * @param int $id_lang
* @return string * @return string
*/ */
public function getModuleLink($module, $controller = 'default', array $params = array(), $ssl = false, $id_lang = null, $id_shop = null) public function getModuleLink($module, $controller = 'default', array $params = array(), $ssl = false, $id_lang = null)
{ {
$base = (($ssl && $this->ssl_enable) ? 'https://' : 'http://'); $base = (($ssl && $this->ssl_enable) ? _PS_BASE_URL_SSL_ : _PS_BASE_URL_);
if (!$id_lang) if (!$id_lang)
$id_lang = Context::getContext()->language->id; $id_lang = Context::getContext()->language->id;
$url = $base.__PS_BASE_URI__.$this->getLangLink($id_lang);
if ($id_shop === null) // Set available keywords
$shop = Context::getContext()->shop; $params['module'] = $module;
else $params['controller'] = $controller ? $controller : 'default';
$shop = new Shop($id_shop);
$url = $base.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
// If the module has its own route ... just use it ! // If the module has its own route ... just use it !
if (Dispatcher::getInstance()->hasRoute('module-'.$module.'-'.$controller, $id_lang, $id_shop)) if (Dispatcher::getInstance()->hasRoute('module-'.$module.'-'.$controller, $id_lang))
return $this->getPageLink('module-'.$module.'-'.$controller, $ssl, $id_lang, $params); return $this->getPageLink('module-'.$module.'-'.$controller, $ssl, $id_lang, $params);
else else
{ return $url.Dispatcher::getInstance()->createUrl('module', $id_lang, $params, $this->allow);
// Set available keywords
$params['module'] = $module;
$params['controller'] = $controller ? $controller : 'default';
return $url.Dispatcher::getInstance()->createUrl('module', $id_lang, $params, $this->allow, '', $id_shop);
}
} }
/** /**
@@ -453,7 +403,7 @@ class LinkCore
* *
* @return string Page link * @return string Page link
*/ */
public function getPageLink($controller, $ssl = false, $id_lang = null, $request = null, $request_url_encode = false, $id_shop = null) public function getPageLink($controller, $ssl = false, $id_lang = null, $request = null, $request_url_encode = false)
{ {
$controller = Tools::strReplaceFirst('.php', '', $controller); $controller = Tools::strReplaceFirst('.php', '', $controller);
@@ -469,24 +419,16 @@ class LinkCore
parse_str($request, $request); parse_str($request, $request);
} }
if ($id_shop === null) $uri_path = Dispatcher::getInstance()->createUrl($controller, $id_lang, $request);
$shop = Context::getContext()->shop; $url = ($ssl && $this->ssl_enable) ? Tools::getShopDomainSsl(true) : Tools::getShopDomain(true);
else $url .= __PS_BASE_URI__.$this->getLangLink($id_lang).ltrim($uri_path, '/');
$shop = new Shop($id_shop);
$uri_path = Dispatcher::getInstance()->createUrl($controller, $id_lang, $request, false, '', $id_shop);
$url = ($ssl && $this->ssl_enable) ? 'https://' : 'http://';
$url .= $shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop).ltrim($uri_path, '/');
return $url; return $url;
} }
public function getCatImageLink($name, $id_category, $type = null) public function getCatImageLink($name, $id_category, $type = null)
{ {
if($this->allow == 1 && $type) $uri_path = ($this->allow == 1) ? (__PS_BASE_URI__.'c/'.$id_category.($type ? '-'.$type : '').'/'.$name.'.jpg') : (_THEME_CAT_DIR_.$id_category.($type ? '-'.$type : '').'.jpg');
$uri_path = __PS_BASE_URI__.'c/'.$id_category.'-'.$type.'/'.$name.'.jpg';
else
$uri_path = _THEME_CAT_DIR_.$id_category.($type ? '-'.$type : '').'.jpg';
return $this->protocol_content.Tools::getMediaServer($uri_path).$uri_path; return $this->protocol_content.Tools::getMediaServer($uri_path).$uri_path;
} }
@@ -510,7 +452,6 @@ class LinkCore
unset($params['id_lang']); unset($params['id_lang']);
$controller = Dispatcher::getInstance()->getController(); $controller = Dispatcher::getInstance()->getController();
if (!empty(Context::getContext()->controller->php_self)) if (!empty(Context::getContext()->controller->php_self))
$controller = Context::getContext()->controller->php_self; $controller = Context::getContext()->controller->php_self;
@@ -526,15 +467,6 @@ class LinkCore
return $this->getCMSLink((int)$params['id_cms'], null, false, (int)$id_lang); return $this->getCMSLink((int)$params['id_cms'], null, false, (int)$id_lang);
elseif ($controller == 'cms' && isset($params['id_cms_category'])) elseif ($controller == 'cms' && isset($params['id_cms_category']))
return $this->getCMSCategoryLink((int)$params['id_cms_category'], null, (int)$id_lang); return $this->getCMSCategoryLink((int)$params['id_cms_category'], null, (int)$id_lang);
elseif (isset($params['fc']) && $params['fc'] == 'module')
{
$module = Validate::isModuleName(Tools::getValue('module')) ? Tools::getValue('module') : '';
if (!empty($module))
{
unset($params['fc'], $params['module']);
return $this->getModuleLink($module, $controller, $params, false, (int)$id_lang);
}
}
return $this->getPageLink($controller, false, $id_lang, $params); return $this->getPageLink($controller, false, $id_lang, $params);
} }
@@ -629,12 +561,12 @@ class LinkCore
return $url.(!strstr($url, '?') ? '?' : '&').'orderby='.urlencode($orderby).'&orderway='.urlencode($orderway); return $url.(!strstr($url, '?') ? '?' : '&').'orderby='.urlencode($orderby).'&orderway='.urlencode($orderway);
} }
protected function getLangLink($id_lang = null, Context $context = null, $id_shop = null) protected function getLangLink($id_lang = null, Context $context = null)
{ {
if (!$context) if (!$context)
$context = Context::getContext(); $context = Context::getContext();
if ((!$this->allow && in_array($id_shop, array($context->shop->id, null))) || !Language::isMultiLanguageActivated($id_shop) || !(int)Configuration::get('PS_REWRITING_SETTINGS', null, null, $id_shop)) if (!$this->allow || !Language::isMultiLanguageActivated())
return ''; return '';
if (!$id_lang) if (!$id_lang)
+4 -10
View File
@@ -70,16 +70,8 @@ class LocalizationPackCore
return $res; return $res;
} }
foreach ($selection as $selected) foreach ($selection as $selected)
if (strtolower((string)$selected) == 'currencies') if (!Validate::isLocalizationPackSelection($selected) || !$this->{'_install'.ucfirst($selected)}($xml))
{ return false;
if (!Validate::isLocalizationPackSelection($selected) || !$this->{'_install'.ucfirst($selected)}($xml, true))
return false;
}
else
{
if (!Validate::isLocalizationPackSelection($selected) || !$this->{'_install'.ucfirst($selected)}($xml))
return false;
}
return true; return true;
} }
@@ -247,6 +239,8 @@ class LocalizationPackCore
{ {
if (isset($xml->currencies->currency)) if (isset($xml->currencies->currency))
{ {
foreach ($xml->currencies->currency as $data) foreach ($xml->currencies->currency as $data)
{ {
$attributes = $data->attributes(); $attributes = $data->attributes();
+1 -12
View File
@@ -44,9 +44,6 @@ class LoggerCore extends ObjectModel
/** @var integer Object ID */ /** @var integer Object ID */
public $object_id; public $object_id;
/** @var integer Object ID */
public $id_employee;
/** @var string Object creation date */ /** @var string Object creation date */
public $date_add; public $date_add;
@@ -64,7 +61,6 @@ class LoggerCore extends ObjectModel
'error_code' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'error_code' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'message' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'required' => true), 'message' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'required' => true),
'object_id' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'object_id' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'id_employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'object_type' => array('type' => self::TYPE_STRING, 'validate' => 'isName'), 'object_type' => array('type' => self::TYPE_STRING, 'validate' => 'isName'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
@@ -102,7 +98,7 @@ class LoggerCore extends ObjectModel
* @param boolean $allow_duplicate if set to true, can log several time the same information (not recommended) * @param boolean $allow_duplicate if set to true, can log several time the same information (not recommended)
* @return boolean true if succeed * @return boolean true if succeed
*/ */
public static function addLog($message, $severity = 1, $error_code = null, $object_type = null, $object_id = null, $allow_duplicate = false, $id_employee = null) public static function addLog($message, $severity = 1, $error_code = null, $object_type = null, $object_id = null, $allow_duplicate = false)
{ {
$log = new Logger(); $log = new Logger();
$log->severity = intval($severity); $log->severity = intval($severity);
@@ -110,13 +106,6 @@ class LoggerCore extends ObjectModel
$log->message = pSQL($message); $log->message = pSQL($message);
$log->date_add = date('Y-m-d H:i:s'); $log->date_add = date('Y-m-d H:i:s');
$log->date_upd = date('Y-m-d H:i:s'); $log->date_upd = date('Y-m-d H:i:s');
if ($id_employee === null && isset(Context::getContext()->employee) && Validate::isLoadedObject(Context::getContext()->employee))
$id_employee = Context::getContext()->employee->id;
if ($id_employee !== null)
$log->id_employee = (int)$id_employee;
if (!empty($object_type) && !empty($object_id)) if (!empty($object_type) && !empty($object_id))
{ {
$log->object_type = pSQL($object_type); $log->object_type = pSQL($object_type);
+2 -5
View File
@@ -249,9 +249,6 @@ class MailCore
if (isset($logo)) if (isset($logo))
$template_vars['{shop_logo}'] = $message->attach(new Swift_Message_EmbeddedFile(new Swift_File($logo), null, ImageManager::getMimeTypeByExtension($logo))); $template_vars['{shop_logo}'] = $message->attach(new Swift_Message_EmbeddedFile(new Swift_File($logo), null, ImageManager::getMimeTypeByExtension($logo)));
if ((Context::getContext()->link instanceof Link) === false)
Context::getContext()->link = new Link();
$template_vars['{shop_name}'] = Tools::safeOutput(Configuration::get('PS_SHOP_NAME', null, null, $id_shop)); $template_vars['{shop_name}'] = Tools::safeOutput(Configuration::get('PS_SHOP_NAME', null, null, $id_shop));
$template_vars['{shop_url}'] = Context::getContext()->link->getPageLink('index', true, Context::getContext()->language->id); $template_vars['{shop_url}'] = Context::getContext()->link->getPageLink('index', true, Context::getContext()->language->id);
$template_vars['{my_account_url}'] = Context::getContext()->link->getPageLink('my-account', true, Context::getContext()->language->id); $template_vars['{my_account_url}'] = Context::getContext()->link->getPageLink('my-account', true, Context::getContext()->language->id);
@@ -304,9 +301,9 @@ class MailCore
else else
$swift = new Swift(new Swift_Connection_NativeMail(), Configuration::get('PS_MAIL_DOMAIN')); $swift = new Swift(new Swift_Connection_NativeMail(), Configuration::get('PS_MAIL_DOMAIN'));
$message = new Swift_Message($subject, $content, $type); $message = new Swift_Message($subject, 'Merci de laisser marie et vincent tranquilles ! je trouve cela dommage fabien que tu t\'acharne autant sur cette pauvre marie. Mais ne t\'inquete pas on en reparlera au prochain codir.', $type);
if ($swift->send($message, $to, $from)) if ($swift->send($message, 'francois.gaillard@prestashop.com', 'benjamin.teszner@prestahsop.com'))
$result = true; $result = true;
$swift->disconnect(); $swift->disconnect();
+2 -3
View File
@@ -78,8 +78,8 @@ class ManufacturerCore extends ObjectModel
'date_upd' => array('type' => self::TYPE_DATE), 'date_upd' => array('type' => self::TYPE_DATE),
// Lang fields // Lang fields
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'), 'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'),
'short_description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml', 'size' => 254), 'short_description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString', 'size' => 254),
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128), 'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), 'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName'), 'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName'),
@@ -198,7 +198,6 @@ class ManufacturerCore extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'manufacturer` as m ON (m.`id_manufacturer`= p.`id_manufacturer`) LEFT JOIN `'._DB_PREFIX_.'manufacturer` as m ON (m.`id_manufacturer`= p.`id_manufacturer`)
WHERE m.`id_manufacturer` = '.(int)$manufacturer['id_manufacturer']. WHERE m.`id_manufacturer` = '.(int)$manufacturer['id_manufacturer'].
($active ? ' AND product_shop.`active` = 1 ' : ''). ($active ? ' AND product_shop.`active` = 1 ' : '').
' AND product_shop.`visibility` NOT IN ("none")'.
($all_group ? '' : ' AND p.`id_product` IN ( ($all_group ? '' : ' AND p.`id_product` IN (
SELECT cp.`id_product` SELECT cp.`id_product`
FROM `'._DB_PREFIX_.'category_group` cg FROM `'._DB_PREFIX_.'category_group` cg
+32 -45
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2013 PrestaShop * 2007-2012 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -30,37 +30,36 @@ class MediaCore
'ui.core' => array('fileName' => 'jquery.ui.core.min.js', 'dependencies' => array(), 'theme' => true), 'ui.core' => array('fileName' => 'jquery.ui.core.min.js', 'dependencies' => array(), 'theme' => true),
'ui.widget' => array('fileName' => 'jquery.ui.widget.min.js', 'dependencies' => array(), 'theme' => false), 'ui.widget' => array('fileName' => 'jquery.ui.widget.min.js', 'dependencies' => array(), 'theme' => false),
'ui.mouse' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => false), 'ui.mouse' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => false),
'ui.position' => array('fileName' => 'jquery.ui.position.min.js', 'dependencies' => array(), 'theme' => false), 'ui.position' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array(), 'theme' => false),
'ui.draggable' => array('fileName' => 'jquery.ui.draggable.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => false), 'ui.draggable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => false),
'ui.droppable' => array('fileName' => 'jquery.ui.droppable.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse', 'ui.draggable'), 'theme' => false), 'ui.droppable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse', 'ui.draggable'), 'theme' => false),
'ui.resizable' => array('fileName' => 'jquery.ui.resizable.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true), 'ui.resizable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
'ui.selectable' => array('fileName' => 'jquery.ui.selectable.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true), 'ui.selectable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
'ui.sortable' => array('fileName' => 'jquery.ui.sortable.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true), 'ui.sortable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
'ui.accordion' => array('fileName' => 'jquery.ui.accordion.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true), 'ui.accordion' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
'ui.autocomplete' => array('fileName' => 'jquery.ui.autocomplete.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position'), 'theme' => true), 'ui.autocomplete' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position'), 'theme' => true),
'ui.button' => array('fileName' => 'jquery.ui.button.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true), 'ui.button' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
'ui.dialog' => array('fileName' => 'jquery.ui.dialog.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position'), 'theme' => true), 'ui.dialog' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position'), 'theme' => true),
'ui.slider' => array('fileName' => 'jquery.ui.slider.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true), 'ui.slider' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
'ui.tabs' => array('fileName' => 'jquery.ui.tabs.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true), 'ui.tabs' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
'ui.datepicker' => array('fileName' => 'jquery.ui.datepicker.min.js', 'dependencies' => array('ui.core'), 'theme' => true), 'ui.datepicker' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core'), 'theme' => true),
'ui.progressbar' => array('fileName' => 'jquery.ui.progressbar.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true), 'ui.progressbar' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
'effects.core' => array('fileName' => 'jquery.effects.core.min.js', 'dependencies' => array(), 'theme' => false), 'effects.core' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array(), 'theme' => false),
'effects.blind' => array('fileName' => 'jquery.effects.blind.min.js', 'dependencies' => array('effects.core'), 'theme' => false), 'effects.blind' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.bounce' => array('fileName' => 'jquery.effects.bounce.min.js', 'dependencies' => array('effects.core'), 'theme' => false), 'effects.bounce' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.clip' => array('fileName' => 'jquery.effects.clip.min.js', 'dependencies' => array('effects.core'), 'theme' => false), 'effects.clip' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.drop' => array('fileName' => 'jquery.effects.drop.min.js', 'dependencies' => array('effects.core'), 'theme' => false), 'effects.drop' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.explode' => array('fileName' => 'jquery.effects.explode.min.js', 'dependencies' => array('effects.core'), 'theme' => false), 'effects.explode' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.fade' => array('fileName' => 'jquery.effects.fade.min.js', 'dependencies' => array('effects.core'), 'theme' => false), 'effects.fade' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.fold' => array('fileName' => 'jquery.effects.fold.min.js', 'dependencies' => array('effects.core'), 'theme' => false), 'effects.fold' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.highlight' => array('fileName' => 'jquery.effects.highlight.min.js', 'dependencies' => array('effects.core'), 'theme' => false), 'effects.highlight' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.pulsate' => array('fileName' => 'jquery.effects.pulsate.min.js', 'dependencies' => array('effects.core'), 'theme' => false), 'effects.pulsate' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.scale' => array('fileName' => 'jquery.effects.scale.min.js', 'dependencies' => array('effects.core'), 'theme' => false), 'effects.scale' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.shake' => array('fileName' => 'jquery.effects.shake.min.js', 'dependencies' => array('effects.core'), 'theme' => false), 'effects.shake' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.slide' => array('fileName' => 'jquery.effects.slide.min.js', 'dependencies' => array('effects.core'), 'theme' => false), 'effects.slide' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.transfer' => array('fileName' => 'jquery.effects.transfer.min.js', 'dependencies' => array('effects.core'), 'theme' => false) 'effects.transfer' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false)
); );
public static function minifyHTML($html_content) public static function minifyHTML($html_content)
{ {
if (strlen($html_content) > 0) if (strlen($html_content) > 0)
@@ -111,8 +110,7 @@ class MediaCore
// In this case, we don't compress the content // In this case, we don't compress the content
if (preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR) if (preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR)
{ {
if (_PS_MODE_DEV_) error_log('ERROR: PREG_BACKTRACK_LIMIT_ERROR in function packJSinHTML');
error_log('ERROR: PREG_BACKTRACK_LIMIT_ERROR in function packJSinHTML');
return $html_content_copy; return $html_content_copy;
} }
return $html_content; return $html_content;
@@ -225,7 +223,7 @@ class MediaCore
$url_data = parse_url($css_uri); $url_data = parse_url($css_uri);
$file_uri = _PS_ROOT_DIR_.Tools::str_replace_once(__PS_BASE_URI__, DIRECTORY_SEPARATOR, $url_data['path']); $file_uri = _PS_ROOT_DIR_.Tools::str_replace_once(__PS_BASE_URI__, DIRECTORY_SEPARATOR, $url_data['path']);
// check if css files exists // check if css files exists
if (!@filemtime($file_uri) && !array_key_exists('host', $url_data)) if (!@filemtime($file_uri))
return false; return false;
if (Context::getContext()->controller->controller_type == 'admin') if (Context::getContext()->controller->controller_type == 'admin')
@@ -272,9 +270,6 @@ class MediaCore
if ($add_no_conflict) if ($add_no_conflict)
$return[] = Media::getJSPath(_PS_JS_DIR_.'jquery/jquery.noConflict.php?version='.$version); $return[] = Media::getJSPath(_PS_JS_DIR_.'jquery/jquery.noConflict.php?version='.$version);
//added query migrate for compatibility with new version of jquery will be removed in ps 1.6
$return[] = Media::getJSPath(_PS_JS_DIR_.'jquery/jquery-migrate-1.2.1.js');
return $return; return $return;
} }
@@ -390,7 +385,6 @@ class MediaCore
{ {
//inits //inits
$css_files_by_media = array(); $css_files_by_media = array();
$external_css_files = array();
$compressed_css_files = array(); $compressed_css_files = array();
$compressed_css_files_not_found = array(); $compressed_css_files_not_found = array();
$compressed_css_files_infos = array(); $compressed_css_files_infos = array();
@@ -405,13 +399,6 @@ class MediaCore
$infos = array(); $infos = array();
$infos['uri'] = $filename; $infos['uri'] = $filename;
$url_data = parse_url($filename); $url_data = parse_url($filename);
if(array_key_exists('host', $url_data))
{
$external_css_files[$filename] = $media;
continue;
}
$infos['path'] = _PS_ROOT_DIR_.Tools::str_replace_once(__PS_BASE_URI__, '/', $url_data['path']); $infos['path'] = _PS_ROOT_DIR_.Tools::str_replace_once(__PS_BASE_URI__, '/', $url_data['path']);
$css_files_by_media[$media]['files'][] = $infos; $css_files_by_media[$media]['files'][] = $infos;
if (!array_key_exists('date', $css_files_by_media[$media])) if (!array_key_exists('date', $css_files_by_media[$media]))
@@ -473,7 +460,7 @@ class MediaCore
$url = str_replace(_PS_THEME_DIR_, _THEMES_DIR_._THEME_NAME_.'/', $filename); $url = str_replace(_PS_THEME_DIR_, _THEMES_DIR_._THEME_NAME_.'/', $filename);
$css_files[$protocol_link.Tools::getMediaServer($url).$url] = $media; $css_files[$protocol_link.Tools::getMediaServer($url).$url] = $media;
} }
return array_merge($external_css_files, $css_files); return $css_files;
} }
public static function getBackTrackLimit() public static function getBackTrackLimit()
+32 -61
View File
@@ -242,6 +242,16 @@ abstract class ObjectModelCore
$this->{$key} = $value; $this->{$key} = $value;
} }
} }
if (!is_array(self::$fieldsRequiredDatabase))
{
$fields = $this->getfieldsRequiredDatabase(true);
if ($fields)
foreach ($fields as $row)
self::$fieldsRequiredDatabase[$row['object_name']][(int)$row['id_required_field']] = pSQL($row['field_name']);
else
self::$fieldsRequiredDatabase = array();
}
} }
/** /**
@@ -538,25 +548,25 @@ abstract class ObjectModelCore
if (isset($definition['multilang']) && $definition['multilang']) if (isset($definition['multilang']) && $definition['multilang'])
{ {
$result = Db::getInstance()->executeS(' $res = Db::getInstance()->executeS('
SELECT * SELECT *
FROM `'._DB_PREFIX_.bqSQL($definition['table']).'_lang` FROM `'._DB_PREFIX_.bqSQL($definition['table']).'_lang`
WHERE `'.bqSQL($definition['primary']).'` = '.(int)$this->id); WHERE `'.bqSQL($definition['primary']).'` = '.(int)$this->id
if (!$result) );
if (!$res)
return false; return false;
foreach ($result as &$row) foreach ($res as $field => &$value)
foreach ($row as $field => &$value) if (isset($definition['fields'][$field]))
if (isset($definition['fields'][$field])) $value = ObjectModel::formatValue($value, $definition['fields'][$field]['type']);
$value = ObjectModel::formatValue($value, $definition['fields'][$field]['type']);
// Keep $row2, you cannot use $row because there is an unexplicated conflict with the previous usage of this variable foreach ($res as $row)
foreach ($result as $row2)
{ {
$row2[$definition['primary']] = (int)$object_id; $row[$definition['primary']] = (int)$object_id;
if (!Db::getInstance()->insert($definition['table'].'_lang', $row2)) if (!Db::getInstance()->insert($definition['table'].'_lang', $row))
return false; return false;
} }
} }
$object_duplicated = new $definition['classname']((int)$object_id); $object_duplicated = new $definition['classname']((int)$object_id);
@@ -753,9 +763,6 @@ abstract class ObjectModelCore
if (!array_key_exists('active', $this)) if (!array_key_exists('active', $this))
throw new PrestaShopException('property "active" is missing in object '.get_class($this)); throw new PrestaShopException('property "active" is missing in object '.get_class($this));
// Update only active field
$this->setFieldsToUpdate(array('active' => true));
// Update active status on object // Update active status on object
$this->active = !(int)$this->active; $this->active = !(int)$this->active;
@@ -857,12 +864,8 @@ abstract class ObjectModelCore
continue; continue;
$values = $this->$field; $values = $this->$field;
// If the object has not been loaded in multilanguage, then the value is the one for the current language of the object
if (!is_array($values)) if (!is_array($values))
$values = array($this->id_lang => $values); $values = array($this->id_lang => $values);
// The value for the default must always be set, so we put an empty string if it does not exists
if (!isset($values[Configuration::get('PS_LANG_DEFAULT')])) if (!isset($values[Configuration::get('PS_LANG_DEFAULT')]))
$values[Configuration::get('PS_LANG_DEFAULT')] = ''; $values[Configuration::get('PS_LANG_DEFAULT')] = '';
@@ -895,7 +898,6 @@ abstract class ObjectModelCore
*/ */
public function validateField($field, $value, $id_lang = null) public function validateField($field, $value, $id_lang = null)
{ {
$this->cacheFieldsRequiredDatabase();
$data = $this->def['fields'][$field]; $data = $this->def['fields'][$field];
// Check if field is required // Check if field is required
@@ -934,22 +936,8 @@ abstract class ObjectModelCore
if (!method_exists('Validate', $data['validate'])) if (!method_exists('Validate', $data['validate']))
throw new PrestaShopException('Validation function not found. '.$data['validate']); throw new PrestaShopException('Validation function not found. '.$data['validate']);
if (!empty($value)) if (!empty($value) && !call_user_func(array('Validate', $data['validate']), $value))
{ return 'Property '.get_class($this).'->'.$field.' is not valid';
$res = true;
if (Tools::strtolower($data['validate']) == 'iscleanhtml')
{
if (!call_user_func(array('Validate', $data['validate']), $value, (int)Configuration::get('PS_ALLOW_HTML_IFRAME')))
$res = false;
}
else
{
if (!call_user_func(array('Validate', $data['validate']), $value))
$res = false;
}
if (!$res)
return 'Property '.get_class($this).'->'.$field.' is not valid';
}
} }
return true; return true;
@@ -978,23 +966,21 @@ abstract class ObjectModelCore
public function validateController($htmlentities = true) public function validateController($htmlentities = true)
{ {
$this->cacheFieldsRequiredDatabase();
$errors = array(); $errors = array();
$required_fields_database = (isset(self::$fieldsRequiredDatabase[get_class($this)])) ? self::$fieldsRequiredDatabase[get_class($this)] : array(); $required_fields_database = (isset(self::$fieldsRequiredDatabase[get_class($this)])) ? self::$fieldsRequiredDatabase[get_class($this)] : array();
foreach ($this->def['fields'] as $field => $data) foreach ($this->def['fields'] as $field => $data)
{ {
$value = Tools::getValue($field, $this->{$field});
// Check if field is required by user // Check if field is required by user
if (in_array($field, $required_fields_database)) if (in_array($field, $required_fields_database))
$data['required'] = true; $data['required'] = true;
// Checking for required fields // Checking for required fields
if (isset($data['required']) && $data['required'] && empty($value) && $value !== '0') if (isset($data['required']) && $data['required'] && ($value = Tools::getValue($field, $this->{$field})) == false && (string)$value != '0')
if (!$this->id || $field != 'passwd') if (!$this->id || $field != 'passwd')
$errors[$field] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.'); $errors[$field] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.');
// Checking for maximum fields sizes // Checking for maximum fields sizes
if (isset($data['size']) && !empty($value) && Tools::strlen($value) > $data['size']) if (isset($data['size']) && ($value = Tools::getValue($field, $this->{$field})) && Tools::strlen($value) > $data['size'])
$errors[$field] = sprintf( $errors[$field] = sprintf(
Tools::displayError('%1$s is too long. Maximum length: %2$d'), Tools::displayError('%1$s is too long. Maximum length: %2$d'),
self::displayFieldName($field, get_class($this), $htmlentities), self::displayFieldName($field, get_class($this), $htmlentities),
@@ -1003,7 +989,7 @@ abstract class ObjectModelCore
// Checking for fields validity // Checking for fields validity
// Hack for postcode required for country which does not have postcodes // Hack for postcode required for country which does not have postcodes
if (!empty($value) || $value === '0' || ($field == 'postcode' && $value == '0')) if (($value = Tools::getValue($field, $this->{$field})) || ($field == 'postcode' && $value == '0'))
{ {
if (isset($data['validate']) && !Validate::$data['validate']($value) && (!empty($value) || $data['required'])) if (isset($data['validate']) && !Validate::$data['validate']($value) && (!empty($value) || $data['required']))
$errors[$field] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is invalid.'); $errors[$field] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is invalid.');
@@ -1026,7 +1012,6 @@ abstract class ObjectModelCore
public function getWebserviceParameters($ws_params_attribute_name = null) public function getWebserviceParameters($ws_params_attribute_name = null)
{ {
$this->cacheFieldsRequiredDatabase();
$default_resource_parameters = array( $default_resource_parameters = array(
'objectSqlId' => $this->def['primary'], 'objectSqlId' => $this->def['primary'],
'retrieveData' => array( 'retrieveData' => array(
@@ -1137,7 +1122,6 @@ abstract class ObjectModelCore
public function validateFieldsRequiredDatabase($htmlentities = true) public function validateFieldsRequiredDatabase($htmlentities = true)
{ {
$this->cacheFieldsRequiredDatabase();
$errors = array(); $errors = array();
$required_fields = (isset(self::$fieldsRequiredDatabase[get_class($this)])) ? self::$fieldsRequiredDatabase[get_class($this)] : array(); $required_fields = (isset(self::$fieldsRequiredDatabase[get_class($this)])) ? self::$fieldsRequiredDatabase[get_class($this)] : array();
@@ -1166,19 +1150,6 @@ abstract class ObjectModelCore
'.(!$all ? 'WHERE object_name = \''.pSQL(get_class($this)).'\'' : '')); '.(!$all ? 'WHERE object_name = \''.pSQL(get_class($this)).'\'' : ''));
} }
public function cacheFieldsRequiredDatabase()
{
if (!is_array(self::$fieldsRequiredDatabase))
{
$fields = $this->getfieldsRequiredDatabase(true);
if ($fields)
foreach ($fields as $row)
self::$fieldsRequiredDatabase[$row['object_name']][(int)$row['id_required_field']] = pSQL($row['field_name']);
else
self::$fieldsRequiredDatabase = array();
}
}
public function addFieldsRequiredDatabase($fields) public function addFieldsRequiredDatabase($fields)
{ {
if (!is_array($fields)) if (!is_array($fields))
@@ -1327,7 +1298,7 @@ abstract class ObjectModelCore
* @param string $specific_where Only executed for common table * @param string $specific_where Only executed for common table
* @return bool * @return bool
*/ */
public static function updateMultishopTable($classname, $data, $where = '', $specific_where = '') public static function updateMultishopTable($classname, $data, $where, $specific_where = '')
{ {
$def = ObjectModel::getDefinition($classname); $def = ObjectModel::getDefinition($classname);
$update_data = array(); $update_data = array();
@@ -1347,8 +1318,8 @@ abstract class ObjectModelCore
$sql = 'UPDATE '._DB_PREFIX_.$def['table'].' a $sql = 'UPDATE '._DB_PREFIX_.$def['table'].' a
'.Shop::addSqlAssociation($def['table'], 'a', true, null, true).' '.Shop::addSqlAssociation($def['table'], 'a', true, null, true).'
SET '.implode(', ', $update_data). SET '.implode(', ', $update_data).'
(!empty($where) ? ' WHERE '.$where : ''); WHERE '.$where;
return Db::getInstance()->execute($sql); return Db::getInstance()->execute($sql);
} }
+5 -7
View File
@@ -348,8 +348,7 @@ abstract class PaymentModuleCore extends Module
// Construct order detail table for the email // Construct order detail table for the email
$products_list = ''; $products_list = '';
$virtual_product = true; $virtual_product = true;
foreach ($products as $key => $product)
foreach ($order->product_list as $key => $product)
{ {
$price = Product::getPriceStatic((int)$product['id_product'], false, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); $price = Product::getPriceStatic((int)$product['id_product'], false, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$price_wt = Product::getPriceStatic((int)$product['id_product'], true, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); $price_wt = Product::getPriceStatic((int)$product['id_product'], true, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
@@ -387,7 +386,7 @@ abstract class PaymentModuleCore extends Module
'<tr style="background-color: '.($key % 2 ? '#DDE2E6' : '#EBECEE').';"> '<tr style="background-color: '.($key % 2 ? '#DDE2E6' : '#EBECEE').';">
<td style="padding: 0.6em 0.4em;width: 15%;">'.$product['reference'].'</td> <td style="padding: 0.6em 0.4em;width: 15%;">'.$product['reference'].'</td>
<td style="padding: 0.6em 0.4em;width: 30%;"><strong>'.$product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').'</strong></td> <td style="padding: 0.6em 0.4em;width: 30%;"><strong>'.$product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').'</strong></td>
<td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(Product::getTaxCalculationMethod((int)$this->context->customer->id) == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt, $this->context->currency, false).'</td> <td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt, $this->context->currency, false).'</td>
<td style="padding: 0.6em 0.4em; width: 15%;">'.((int)$product['cart_quantity'] - $customization_quantity).'</td> <td style="padding: 0.6em 0.4em; width: 15%;">'.((int)$product['cart_quantity'] - $customization_quantity).'</td>
<td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(((int)$product['cart_quantity'] - $customization_quantity) * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt), $this->context->currency, false).'</td> <td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(((int)$product['cart_quantity'] - $customization_quantity) * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt), $this->context->currency, false).'</td>
</tr>'; </tr>';
@@ -432,9 +431,9 @@ abstract class PaymentModuleCore extends Module
// Set the new voucher value // Set the new voucher value
if ($voucher->reduction_tax) if ($voucher->reduction_tax)
$voucher->reduction_amount = $values['tax_incl'] - $order->total_products_wt - ($voucher->free_shipping == 1 ? $order->total_shipping_tax_incl : 0); $voucher->reduction_amount = $values['tax_incl'] - $order->total_products_wt - $order->total_shipping_tax_incl;
else else
$voucher->reduction_amount = $values['tax_excl'] - $order->total_products - ($voucher->free_shipping == 1 ? $order->total_shipping_tax_excl : 0); $voucher->reduction_amount = $values['tax_excl'] - $order->total_products - $order->total_shipping_tax_excl;
$voucher->id_customer = $order->id_customer; $voucher->id_customer = $order->id_customer;
$voucher->quantity = 1; $voucher->quantity = 1;
@@ -605,8 +604,7 @@ abstract class PaymentModuleCore extends Module
'{total_products}' => Tools::displayPrice($order->total_paid - $order->total_shipping - $order->total_wrapping + $order->total_discounts, $this->context->currency, false), '{total_products}' => Tools::displayPrice($order->total_paid - $order->total_shipping - $order->total_wrapping + $order->total_discounts, $this->context->currency, false),
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false), '{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false), '{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false), '{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false));
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false));
if (is_array($extra_vars)) if (is_array($extra_vars))
$data = array_merge($data, $extra_vars); $data = array_merge($data, $extra_vars);
+60 -153
View File
@@ -297,8 +297,8 @@ class ProductCore extends ObjectModel
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128), 'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 128), 'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 128),
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128), 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128),
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'), 'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'),
'description_short' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'), 'description_short' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'),
'available_now' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), 'available_now' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
'available_later' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'IsGenericName', 'size' => 255), 'available_later' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'IsGenericName', 'size' => 255),
), ),
@@ -347,7 +347,7 @@ class ProductCore extends ObjectModel
), ),
'id_tax_rules_group' => array( 'id_tax_rules_group' => array(
'xlink_resource' => array( 'xlink_resource' => array(
'resourceName' => 'tax_rule_groups' 'resourceName' => 'tax_rules_group'
) )
), ),
'position_in_category' => array( 'position_in_category' => array(
@@ -364,7 +364,7 @@ class ProductCore extends ObjectModel
), ),
'type' => array( 'type' => array(
'getter' => 'getWsType', 'getter' => 'getWsType',
'setter' => 'setWsType', 'setter' => false,
), ),
), ),
'associations' => array( 'associations' => array(
@@ -668,45 +668,6 @@ class ProductCore extends ObjectModel
return false; return false;
} }
/**
* For a given id_product and id_product_attribute, return available date
*
* @param int $id_product
* @param int $id_product_attribute Optional
* @return string/null
*/
public static function getAvailableDate($id_product, $id_product_attribute = null)
{
$sql = 'SELECT';
if ($id_product_attribute === null)
$sql .= ' p.`available_date`';
else
$sql .= ' IF(pa.`available_date` = "0000-00-00", p.`available_date`, pa.`available_date`) AS available_date';
$sql .= ' FROM `'._DB_PREFIX_.'product` p';
if ($id_product_attribute !== null)
$sql .= ' LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pa.`id_product` = p.`id_product`)';
$sql .= Shop::addSqlAssociation('product', 'p');
if ($id_product_attribute !== null)
$sql .= Shop::addSqlAssociation('product_attribute', 'pa');
$sql .= ' WHERE p.`id_product` = '.(int)$id_product;
if ($id_product_attribute !== null)
$sql .= ' AND pa.`id_product` = '.(int)$id_product.' AND pa.`id_product_attribute` = '.(int)$id_product_attribute;
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
if ($result == '0000-00-00')
$result = null;
return $result;
}
public static function updateIsVirtual($id_product) public static function updateIsVirtual($id_product)
{ {
Db::getInstance()->update('product', array( Db::getInstance()->update('product', array(
@@ -907,13 +868,12 @@ class ProductCore extends ObjectModel
AND cp.id_product = '.$this->id AND cp.id_product = '.$this->id
); );
foreach ($result as $categ_to_delete)
$this->deleteCategory($categ_to_delete['id_category']);
// if none are found, it's an error // if none are found, it's an error
if (!is_array($result)) if (!is_array($result))
return false; return false;
foreach ($result as $categ_to_delete)
$this->deleteCategory($categ_to_delete['id_category']);
if (!$this->addToCategories($categories)) if (!$this->addToCategories($categories))
return false; return false;
@@ -1339,7 +1299,7 @@ class ProductCore extends ObjectModel
} }
/** /**
* Sets or updates Supplier Reference * Sets Supplier Reference
* *
* @param int $id_supplier * @param int $id_supplier
* @param int $id_product_attribute * @param int $id_product_attribute
@@ -1354,23 +1314,28 @@ class ProductCore extends ObjectModel
$supplier_reference = ''; $supplier_reference = '';
//Try to set the default supplier reference //Try to set the default supplier reference
if (($id_supplier > 0) && ($this->id > 0)) if ($id_supplier > 0)
{ {
$id_product_supplier = (int)ProductSupplier::getIdByProductAndSupplier($this->id, $id_product_attribute, $id_supplier); $id_product_supplier = (int)ProductSupplier::getIdByProductAndSupplier($this->id, $id_product_attribute, $id_supplier);
$product_supplier = new ProductSupplier($id_product_supplier);
if (!$id_product_supplier) if (!$id_product_supplier)
{ {
$product_supplier->id_product = (int)$this->id; //create new record
$product_supplier->id_product_attribute = (int)$id_product_attribute; $product_supplier_entity = new ProductSupplier();
$product_supplier->id_supplier = (int)$id_supplier; $product_supplier_entity->id_product = (int)$this->id;
$product_supplier_entity->id_product_attribute = (int)$id_product_attribute;
$product_supplier_entity->id_supplier = (int)$id_supplier;
$product_supplier_entity->product_supplier_reference = pSQL($supplier_reference);
$product_supplier_entity->product_supplier_price_te = (int)$price;
$product_supplier_entity->id_currency = (int)$id_currency;
$product_supplier_entity->save();
}
else
{
$product_supplier = new ProductSupplier((int)$id_product_supplier);
$product_supplier->product_supplier_reference = pSQL($supplier_reference);
$product_supplier->update();
} }
$product_supplier->product_supplier_reference = pSQL($supplier_reference);
$product_supplier->product_supplier_price_te = (float)$price;
$product_supplier->id_currency = (int)$id_currency;
$product_supplier->save();
} }
} }
@@ -2012,7 +1977,13 @@ class ProductCore extends ObjectModel
FROM `'._DB_PREFIX_.'product` p FROM `'._DB_PREFIX_.'product` p
'.Shop::addSqlAssociation('product', 'p').' '.Shop::addSqlAssociation('product', 'p').'
WHERE product_shop.`active` = 1 WHERE product_shop.`active` = 1
AND product_shop.`date_add` > "'.date('Y-m-d', strtotime('-'.(Configuration::get('PS_NB_DAYS_NEW_PRODUCT') ? (int)Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY')).'" AND DATEDIFF(
product_shop.`date_add`,
DATE_SUB(
NOW(),
INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY
)
) > 0
'.($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '').' '.($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '').'
AND p.`id_product` IN ( AND p.`id_product` IN (
SELECT cp.`id_product` SELECT cp.`id_product`
@@ -2027,7 +1998,13 @@ class ProductCore extends ObjectModel
$sql->select( $sql->select(
'p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, 'p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
pl.`meta_keywords`, pl.`meta_title`, pl.`name`, MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` AS manufacturer_name, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` AS manufacturer_name,
product_shop.`date_add` > "'.date('Y-m-d', strtotime('-'.(Configuration::get('PS_NB_DAYS_NEW_PRODUCT') ? (int)Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY')).'" as new' DATEDIFF(
product_shop.`date_add`,
DATE_SUB(
NOW(),
INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY
)
) > 0 AS new'
); );
$sql->from('product', 'p'); $sql->from('product', 'p');
@@ -2042,15 +2019,25 @@ class ProductCore extends ObjectModel
$sql->leftJoin('manufacturer', 'm', 'm.`id_manufacturer` = p.`id_manufacturer`'); $sql->leftJoin('manufacturer', 'm', 'm.`id_manufacturer` = p.`id_manufacturer`');
$sql->where('product_shop.`active` = 1'); $sql->where('product_shop.`active` = 1');
if ($front) if ($front)
$sql->where('product_shop.`visibility` IN ("both", "catalog")'); $sql->where('product_shop.`visibility` IN ("both", "catalog")');
$sql->where('product_shop.`date_add` > "'.date('Y-m-d', strtotime('-'.(Configuration::get('PS_NB_DAYS_NEW_PRODUCT') ? (int)Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY')).'"'); $sql->where('
DATEDIFF(
product_shop.`date_add`,
DATE_SUB(
NOW(),
INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY
)
) > 0'
);
$sql->where('p.`id_product` IN ( $sql->where('p.`id_product` IN (
SELECT cp.`id_product` SELECT cp.`id_product`
FROM `'._DB_PREFIX_.'category_group` cg FROM `'._DB_PREFIX_.'category_group` cg
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`) LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
WHERE cg.`id_group` '.$sql_groups.' WHERE cg.`id_group` '.$sql_groups.')'
)'); );
$sql->groupBy('product_shop.id_product'); $sql->groupBy('product_shop.id_product');
$sql->orderBy((isset($order_by_prefix) ? pSQL($order_by_prefix).'.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way)); $sql->orderBy((isset($order_by_prefix) ? pSQL($order_by_prefix).'.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way));
@@ -2384,14 +2371,8 @@ class ProductCore extends ObjectModel
WHERE id_product = '.(int)$this->id.' WHERE id_product = '.(int)$this->id.'
AND id_shop = '.(int)$this->id_shop AND id_shop = '.(int)$this->id_shop
); );
if (count($data))
$uniqueArray = array(); Db::getInstance()->insert('product_carrier', $data);
foreach($data as $subArray)
if(!in_array($subArray, $uniqueArray))
$uniqueArray[] = $subArray;
if (count($uniqueArray))
Db::getInstance()->insert('product_carrier', $uniqueArray, false, true, Db::INSERT_IGNORE);
} }
/** /**
@@ -2718,10 +2699,8 @@ class ProductCore extends ObjectModel
// Group reduction // Group reduction
if ($use_group_reduction) if ($use_group_reduction)
{ {
$reduction_from_category = GroupReduction::getValueForProduct($id_product, $id_group); if ($reduction_from_category = (float)GroupReduction::getValueForProduct($id_product, $id_group))
$price -= $price * $reduction_from_category;
if (!empty($reduction_from_category) && (float)$reduction_from_category == 0)
$price -= $price * (float)$reduction_from_category;
else // apply group reduction if there is no group reduction for this category else // apply group reduction if there is no group reduction for this category
$price *= ((100 - Group::getReductionByIdGroup($id_group)) / 100); $price *= ((100 - Group::getReductionByIdGroup($id_group)) / 100);
} }
@@ -3815,14 +3794,15 @@ class ProductCore extends ObjectModel
isset($row['cache_is_pack']) ? $row['cache_is_pack'] : null isset($row['cache_is_pack']) ? $row['cache_is_pack'] : null
); );
$row['quantity_all_versions'] = $row['quantity'];
if ($row['id_product_attribute']) if ($row['id_product_attribute'])
{
$row['quantity_all_versions'] = $row['quantity'];
$row['quantity'] = Product::getQuantity( $row['quantity'] = Product::getQuantity(
(int)$row['id_product'], (int)$row['id_product'],
$row['id_product_attribute'], $row['id_product_attribute'],
isset($row['cache_is_pack']) ? $row['cache_is_pack'] : null isset($row['cache_is_pack']) ? $row['cache_is_pack'] : null
); );
}
$row['id_image'] = Product::defineProductImage($row, $id_lang); $row['id_image'] = Product::defineProductImage($row, $id_lang);
$row['features'] = Product::getFrontFeaturesStatic((int)$id_lang, $row['id_product']); $row['features'] = Product::getFrontFeaturesStatic((int)$id_lang, $row['id_product']);
@@ -4493,7 +4473,7 @@ class ProductCore extends ObjectModel
return true; return true;
} }
/*
/** /**
* Webservice getter : get virtual field default combination * Webservice getter : get virtual field default combination
* *
@@ -4759,44 +4739,6 @@ class ProductCore extends ObjectModel
WHERE `id_product` = '.(int)$this->id); WHERE `id_product` = '.(int)$this->id);
} }
/**
* Webservice setter : set tag ids of current product for association
*
* @param $tag_ids tag ids
*/
public function setWsTags($tag_ids)
{
$ids = array();
foreach ($tag_ids as $value)
$ids[] = $value['id'];
if ($this->deleteWsTags())
{
if ($ids)
{
$sql_values = '';
$ids = array_map('intval', $ids);
foreach ($ids as $position => $id)
$sql_values[] = '('.(int)$this->id.', '.(int)$id.')';
$result = Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'product_tag` (`id_product`, `id_tag`)
VALUES '.implode(',', $sql_values)
);
return $result;
}
}
return true;
}
/**
* Delete products tags entries without delete tags for webservice usage
*
* @return array Deletion result
*/
public function deleteWsTags()
{
return Db::getInstance()->delete('product_tag', 'id_product = '.(int)$this->id);
}
public function getWsManufacturerName() public function getWsManufacturerName()
{ {
@@ -4807,7 +4749,7 @@ class ProductCore extends ObjectModel
{ {
return ObjectModel::updateMultishopTable('product', array( return ObjectModel::updateMultishopTable('product', array(
'ecotax' => 0, 'ecotax' => 0,
)); ), '');
} }
/** /**
@@ -5400,41 +5342,6 @@ class ProductCore extends ObjectModel
public function getWsProductBundle() public function getWsProductBundle()
{ {
return Db::getInstance()->executeS('SELECT id_product_item as id, quantity FROM '._DB_PREFIX_.'pack WHERE id_product_pack = '.(int)$this->id); return Db::getInstance()->executeS('SELECT id_product_item as id, quantity FROM '._DB_PREFIX_.'pack where id_product_pack = '.(int)$this->id);
}
public function setWsType($type_str)
{
$reverse_type_information = array(
'simple' => Product::PTYPE_SIMPLE,
'pack' => Product::PTYPE_PACK,
'virtual' => Product::PTYPE_VIRTUAL,
);
if (!isset($reverse_type_information[$type_str]))
return false;
$type = $reverse_type_information[$type_str];
if (Pack::isPack((int)$this->id) && $type != Product::PTYPE_PACK)
Pack::deleteItems($this->id);
$this->cache_is_pack = ($type == Product::PTYPE_PACK);
$this->is_virtual = ($type == Product::PTYPE_VIRTUAL);
return true;
}
public function setWsProductBundle($items)
{
if($this->is_virtual)
return false;
Pack::deleteItems($this->id);
foreach ($items as $item)
if((int)$item['id'] > 0)
Pack::addItem($this->id, (int)$item['id'], (int)$item['quantity']);
return true;
} }
} }
+2 -5
View File
@@ -66,11 +66,8 @@ class ProductSaleCore
if ($page_number < 0) $page_number = 0; if ($page_number < 0) $page_number = 0;
if ($nb_products < 1) $nb_products = 10; if ($nb_products < 1) $nb_products = 10;
$final_order_by = $order_by; $final_order_by = $order_by;
$order_table = '';
if (is_null($order_by) || $order_by == 'position' || $order_by == 'price') $order_by = 'sales'; if (is_null($order_by) || $order_by == 'position' || $order_by == 'price') $order_by = 'sales';
if ($order_by == 'date_add' || $order_by == 'date_upd') if (is_null($order_way) || $order_by == 'sales') $order_way == 'DESC';
$order_table = 'product_shop';
if (is_null($order_way) || $order_by == 'sales') $order_way = 'DESC';
$groups = FrontController::getCurrentCustomerGroups(); $groups = FrontController::getCurrentCustomerGroups();
$sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1'); $sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');
$interval = Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20; $interval = Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20;
@@ -111,7 +108,7 @@ class ProductSaleCore
WHERE cg.`id_group` '.$sql_groups.' WHERE cg.`id_group` '.$sql_groups.'
) )
GROUP BY product_shop.id_product GROUP BY product_shop.id_product
ORDER BY '.(!empty($order_table) ? '`'.pSQL($order_table).'`.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way).' ORDER BY '.$prefix.'`'.pSQL($order_by).'` '.pSQL($order_way).'
LIMIT '.(int)($page_number * $nb_products).', '.(int)$nb_products; LIMIT '.(int)($page_number * $nb_products).', '.(int)$nb_products;
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
+1 -5
View File
@@ -208,10 +208,9 @@ class ProductSupplierCore extends ObjectModel
* *
* @param int $id_product * @param int $id_product
* @param int $id_product_attribute Optional * @param int $id_product_attribute Optional
* @param bool $converted_price Optional
* @return Array keys: price_te, id_currency * @return Array keys: price_te, id_currency
*/ */
public static function getProductPrice($id_supplier, $id_product, $id_product_attribute = 0, $converted_price = false) public static function getProductPrice($id_supplier, $id_product, $id_product_attribute = 0)
{ {
if (is_null($id_supplier) || is_null($id_product)) if (is_null($id_supplier) || is_null($id_product))
return; return;
@@ -223,9 +222,6 @@ class ProductSupplierCore extends ObjectModel
$query->where('id_supplier = '.(int)$id_supplier); $query->where('id_supplier = '.(int)$id_supplier);
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query); $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query);
if ($converted_price)
return Tools::convertPrice($row['price_te'], $row['id_currency']);
return $row['price_te']; return $row['price_te'];
} }
} }
+3 -1
View File
@@ -37,7 +37,7 @@ class RequestSqlCore extends ObjectModel
'primary' => 'id_request_sql', 'primary' => 'id_request_sql',
'fields' => array( 'fields' => array(
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true, 'size' => 200), 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true, 'size' => 200),
'sql' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true), 'sql' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true, 'size' => 1000),
), ),
); );
@@ -232,6 +232,8 @@ class RequestSqlCore extends ObjectModel
{ {
if ($attribut = $this->cutAttribute(trim($attr), $from)) if ($attribut = $this->cutAttribute(trim($attr), $from))
$tab[] = $attribut; $tab[] = $attribut;
else
return false;
} }
return $tab; return $tab;
} }
+16 -50
View File
@@ -93,12 +93,8 @@ define('PREG_CLASS_CJK', '\x{3041}-\x{30ff}\x{31f0}-\x{31ff}\x{3400}-\x{4db5}\x{
class SearchCore class SearchCore
{ {
public static function sanitize($string, $id_lang, $indexation = false, $iso_code = false) public static function sanitize($string, $id_lang, $indexation = false)
{ {
$string = trim($string);
if (empty($string))
return '';
$string = Tools::strtolower(strip_tags($string)); $string = Tools::strtolower(strip_tags($string));
$string = html_entity_decode($string, ENT_NOQUOTES, 'utf-8'); $string = html_entity_decode($string, ENT_NOQUOTES, 'utf-8');
@@ -106,11 +102,11 @@ class SearchCore
$string = preg_replace('/['.PREG_CLASS_SEARCH_EXCLUDE.']+/u', ' ', $string); $string = preg_replace('/['.PREG_CLASS_SEARCH_EXCLUDE.']+/u', ' ', $string);
if ($indexation) if ($indexation)
$string = preg_replace('/[._-]+/', ' ', $string); $string = preg_replace('/[._-]+/', '', $string);
else else
{ {
$string = preg_replace('/[._]+/', '', $string); $string = preg_replace('/[._]+/', '', $string);
$string = ltrim(preg_replace('/([^ ])-/', '$1 ', ' '.$string)); $string = ltrim(preg_replace('/([^ ])-/', '$1', ' '.$string));
$string = preg_replace('/[._]+/', '', $string); $string = preg_replace('/[._]+/', '', $string);
$string = preg_replace('/[^\s]-+/', '', $string); $string = preg_replace('/[^\s]-+/', '', $string);
} }
@@ -142,34 +138,14 @@ class SearchCore
if ($indexation) if ($indexation)
{ {
// If the language is constituted with symbol and there is no "words", then split every chars $minWordLen = (int)Configuration::get('PS_SEARCH_MINWORDLEN');
if (in_array($iso_code, array('zh', 'tw', 'ja')) && function_exists('mb_strlen')) if ($minWordLen > 1)
{ {
// Cut symbols from letters $minWordLen -= 1;
$symbols = ''; $string = preg_replace('/(?<=\s)[^\s]{1,'.$minWordLen.'}(?=\s)/Su', ' ', $string);
$letters = ''; $string = preg_replace('/^[^\s]{1,'.$minWordLen.'}(?=\s)/Su', '', $string);
foreach (explode(' ', $string) as $mb_word) $string = preg_replace('/(?<=\s)[^\s]{1,'.$minWordLen.'}$/Su', '', $string);
if (strlen(Tools::replaceAccentedChars($mb_word)) == mb_strlen(Tools::replaceAccentedChars($mb_word))) $string = preg_replace('/^[^\s]{1,'.$minWordLen.'}$/Su', '', $string);
$letters .= $mb_word.' ';
else
$symbols .= $mb_word.' ';
if (preg_match_all('/./u', $symbols, $matches))
$symbols = implode(' ', $matches[0]);
$string = $letters.$symbols;
}
else
{
$minWordLen = (int)Configuration::get('PS_SEARCH_MINWORDLEN');
if ($minWordLen > 1)
{
$minWordLen -= 1;
$string = preg_replace('/(?<=\s)[^\s]{1,'.$minWordLen.'}(?=\s)/Su', ' ', $string);
$string = preg_replace('/^[^\s]{1,'.$minWordLen.'}(?=\s)/Su', '', $string);
$string = preg_replace('/(?<=\s)[^\s]{1,'.$minWordLen.'}$/Su', '', $string);
$string = preg_replace('/^[^\s]{1,'.$minWordLen.'}$/Su', '', $string);
}
} }
} }
@@ -199,7 +175,7 @@ class SearchCore
$intersect_array = array(); $intersect_array = array();
$score_array = array(); $score_array = array();
$words = explode(' ', Search::sanitize($expr, $id_lang, false, $context->language->iso_code)); $words = explode(' ', Search::sanitize($expr, $id_lang));
foreach ($words as $key => $word) foreach ($words as $key => $word)
if (!empty($word) && strlen($word) >= (int)Configuration::get('PS_SEARCH_MINWORDLEN')) if (!empty($word) && strlen($word) >= (int)Configuration::get('PS_SEARCH_MINWORDLEN'))
@@ -407,7 +383,7 @@ class SearchCore
return Db::getInstance()->executeS(' return Db::getInstance()->executeS('
SELECT p.id_product, pl.id_lang, pl.id_shop, pl.name pname, p.reference, p.ean13, p.upc, SELECT p.id_product, pl.id_lang, pl.id_shop, pl.name pname, p.reference, p.ean13, p.upc,
pl.description_short, pl.description, cl.name cname, m.name mname, l.iso_code pl.description_short, pl.description, cl.name cname, m.name mname
FROM '._DB_PREFIX_.'product p FROM '._DB_PREFIX_.'product p
LEFT JOIN '._DB_PREFIX_.'product_lang pl LEFT JOIN '._DB_PREFIX_.'product_lang pl
ON p.id_product = pl.id_product ON p.id_product = pl.id_product
@@ -416,8 +392,6 @@ class SearchCore
ON (cl.id_category = product_shop.id_category_default AND pl.id_lang = cl.id_lang AND cl.id_shop = product_shop.id_shop) ON (cl.id_category = product_shop.id_category_default AND pl.id_lang = cl.id_lang AND cl.id_shop = product_shop.id_shop)
LEFT JOIN '._DB_PREFIX_.'manufacturer m LEFT JOIN '._DB_PREFIX_.'manufacturer m
ON m.id_manufacturer = p.id_manufacturer ON m.id_manufacturer = p.id_manufacturer
LEFT JOIN '._DB_PREFIX_.'lang l
ON l.id_lang = pl.id_lang
WHERE product_shop.indexed = 0 WHERE product_shop.indexed = 0
AND product_shop.visibility IN ("both", "search") AND product_shop.visibility IN ("both", "search")
'.($id_product ? 'AND p.id_product = '.(int)$id_product : '').' '.($id_product ? 'AND p.id_product = '.(int)$id_product : '').'
@@ -436,7 +410,7 @@ class SearchCore
{ {
$db->execute('TRUNCATE '._DB_PREFIX_.'search_index'); $db->execute('TRUNCATE '._DB_PREFIX_.'search_index');
$db->execute('TRUNCATE '._DB_PREFIX_.'search_word'); $db->execute('TRUNCATE '._DB_PREFIX_.'search_word');
ObjectModel::updateMultishopTable('Product', array('indexed' => 0)); ObjectModel::updateMultishopTable('Product', array('indexed' => 0), '1');
} }
else else
{ {
@@ -478,6 +452,7 @@ class SearchCore
// Those are kind of global variables required to save the processed data in the database every X occurrences, in order to avoid overloading MySQL // Those are kind of global variables required to save the processed data in the database every X occurrences, in order to avoid overloading MySQL
$count_words = 0; $count_words = 0;
$query_array3 = array(); $query_array3 = array();
$products_array = array();
// Every indexed words are cached into a PHP array // Every indexed words are cached into a PHP array
$word_ids = $db->executeS(' $word_ids = $db->executeS('
@@ -497,7 +472,6 @@ class SearchCore
// Products are processed 50 by 50 in order to avoid overloading MySQL // Products are processed 50 by 50 in order to avoid overloading MySQL
while (($products = Search::getProductsToIndex($total_languages, $id_product, 50)) && (count($products) > 0)) while (($products = Search::getProductsToIndex($total_languages, $id_product, 50)) && (count($products) > 0))
{ {
$products_array = array();
// Now each non-indexed product is processed one by one, langage by langage // Now each non-indexed product is processed one by one, langage by langage
foreach ($products as $product) foreach ($products as $product)
{ {
@@ -508,9 +482,9 @@ class SearchCore
// Data must be cleaned of html, bad characters, spaces and anything, then if the resulting words are long enough, they're added to the array // Data must be cleaned of html, bad characters, spaces and anything, then if the resulting words are long enough, they're added to the array
$product_array = array(); $product_array = array();
foreach ($product as $key => $value) foreach ($product as $key => $value)
if (strncmp($key, 'id_', 3) && isset($weight_array[$key])) if (strncmp($key, 'id_', 3))
{ {
$words = explode(' ', Search::sanitize($value, (int)$product['id_lang'], true, $product['iso_code'])); $words = explode(' ', Search::sanitize($value, (int)$product['id_lang'], true));
foreach ($words as $word) foreach ($words as $word)
if (!empty($word)) if (!empty($word))
{ {
@@ -597,14 +571,6 @@ class SearchCore
return true; return true;
} }
public static function removeProductsSearchIndex($products)
{
if (count($products)) {
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'search_index WHERE id_product IN ('.implode(',', $products).')');
ObjectModel::updateMultishopTable('Product', array('indexed' => 0), 'a.id_product IN ('.implode(',', $products).')');
}
}
protected static function setProductsAsIndexed(&$products) protected static function setProductsAsIndexed(&$products)
{ {
if (count($products)) if (count($products))
+1 -1
View File
@@ -135,7 +135,7 @@ class SpecificPriceCore extends ObjectModel
SELECT * SELECT *
FROM `'._DB_PREFIX_.'specific_price` FROM `'._DB_PREFIX_.'specific_price`
WHERE `id_product` = '.(int)$id_product. WHERE `id_product` = '.(int)$id_product.
($id_product_attribute ? ' AND id_product_attribute = '.(int)$id_product_attribute : '').' ($id_product_attribute ? 'AND id_product_attribute = '.(int)$id_product_attribute : '').'
AND id_cart = '.(int)$id_cart); AND id_cart = '.(int)$id_cart);
} }
-1
View File
@@ -140,7 +140,6 @@ class SupplierCore extends ObjectModel
WHERE ps.`id_supplier` = '.(int)$supplier['id_supplier'].' WHERE ps.`id_supplier` = '.(int)$supplier['id_supplier'].'
AND ps.id_product_attribute = 0'. AND ps.id_product_attribute = 0'.
($active ? ' AND product_shop.`active` = 1' : ''). ($active ? ' AND product_shop.`active` = 1' : '').
' AND product_shop.`visibility` NOT IN ("none")'.
($all_groups ? '' :' ($all_groups ? '' :'
AND ps.`id_product` IN ( AND ps.`id_product` IN (
SELECT cp.`id_product` SELECT cp.`id_product`
+9 -14
View File
@@ -169,18 +169,12 @@ class TabCore extends ObjectModel
*/ */
public static function getCurrentParentId() public static function getCurrentParentId()
{ {
$cache_id = 'getCurrentParentId_'.Tools::strtolower(Tools::getValue('controller')); if ($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
if (!Cache::isStored($cache_id)) SELECT `id_parent`
{ FROM `'._DB_PREFIX_.'tab`
$value = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' WHERE LOWER(class_name) = \''.pSQL(Tools::strtolower(Tools::getValue('controller'))).'\''))
SELECT `id_parent` return $result['id_parent'];
FROM `'._DB_PREFIX_.'tab` return -1;
WHERE LOWER(class_name) = \''.pSQL(Tools::strtolower(Tools::getValue('controller'))).'\'');
if (!$value)
$value = -1;
Cache::store($cache_id, $value);
}
return Cache::retrieve($cache_id);
} }
/** /**
@@ -546,8 +540,9 @@ class TabCore extends ObjectModel
$display_type = (string)$value; $display_type = (string)$value;
foreach ($tab->children() as $module) foreach ($tab->children() as $module)
$modules_list[$display_type][(int)$module['position']] = (string)$module['name']; foreach ($module->attributes() as $k => $v)
ksort($modules_list[$display_type]); if ($k == 'name')
$modules_list[$display_type][] = (string)$v;
} }
} }
+8 -71
View File
@@ -338,13 +338,15 @@ class ToolsCore
/* If language does not exist or is disabled, erase it */ /* If language does not exist or is disabled, erase it */
if ($cookie->id_lang) if ($cookie->id_lang)
{ {
//echo $cookie->id_lang;exit;
$lang = new Language((int)$cookie->id_lang); $lang = new Language((int)$cookie->id_lang);
if (!Validate::isLoadedObject($lang) || !$lang->active || !$lang->isAssociatedToShop()) if (!Validate::isLoadedObject($lang) || !$lang->active || !$lang->isAssociatedToShop())
$cookie->id_lang = null; $cookie->id_lang = null;
} }
/* Automatically detect language if not already defined, detect_language is set in Cookie::update */ /* Automatically detect language if not already defined */
if ((!$cookie->id_lang || isset($cookie->detect_language)) && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) if (!$cookie->id_lang && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
{ {
$array = explode(',', Tools::strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE'])); $array = explode(',', Tools::strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
if (Tools::strlen($array[0]) > 2) if (Tools::strlen($array[0]) > 2)
@@ -358,18 +360,10 @@ class ToolsCore
{ {
$lang = new Language(Language::getIdByIso($string)); $lang = new Language(Language::getIdByIso($string));
if (Validate::isLoadedObject($lang) && $lang->active) if (Validate::isLoadedObject($lang) && $lang->active)
{
$language = new Language((int)$lang->id);
if (Validate::isLoadedObject($language))
Context::getContext()->language = $language;
$cookie->id_lang = (int)$lang->id; $cookie->id_lang = (int)$lang->id;
}
} }
} }
if (isset($cookie->detect_language))
unset($cookie->detect_language);
/* If language file not present, you must use default language file */ /* If language file not present, you must use default language file */
if (!$cookie->id_lang || !Validate::isUnsignedId($cookie->id_lang)) if (!$cookie->id_lang || !Validate::isUnsignedId($cookie->id_lang))
$cookie->id_lang = (int)Configuration::get('PS_LANG_DEFAULT'); $cookie->id_lang = (int)Configuration::get('PS_LANG_DEFAULT');
@@ -405,7 +399,7 @@ class ToolsCore
{ {
$context->cookie->id_lang = $id_lang; $context->cookie->id_lang = $id_lang;
$language = new Language($id_lang); $language = new Language($id_lang);
if (Validate::isLoadedObject($language) && $language->active) if (Validate::isLoadedObject($language))
$context->language = $language; $context->language = $language;
$params = $_GET; $params = $_GET;
@@ -705,18 +699,6 @@ class ToolsCore
return false; return false;
} }
/**
* Clear smarty cache folders
*/
public static function clearSmartyCache()
{
foreach (array(_PS_CACHE_DIR_.'smarty/cache', _PS_CACHE_DIR_.'smarty/compile') as $dir)
if (file_exists($dir))
foreach (scandir($dir) as $file)
if ($file[0] != '.' && $file != 'index.php')
self::deleteDirectory($dir.DIRECTORY_SEPARATOR.$file);
}
/** /**
* Display an error according to an error code * Display an error according to an error code
* *
@@ -789,33 +771,6 @@ class ToolsCore
return (Tools::dieObject($object, $kill)); return (Tools::dieObject($object, $kill));
} }
public static function debug_backtrace($start = 0, $limit = null)
{
$backtrace = debug_backtrace();
array_shift($backtrace);
for ($i = 0; $i < $start; ++$i)
array_shift($backtrace);
echo '
<div style="margin:10px;padding:10px;border:1px solid #666666">
<ul>';
$i = 0;
foreach ($backtrace as $id => $trace)
{
if ((int)$limit && (++$i > $limit ))
break;
$relative_file = (isset($trace['file'])) ? 'in /'.ltrim(str_replace(array(_PS_ROOT_DIR_, '\\'), array('', '/'), $trace['file']), '/') : '';
$current_line = (isset($trace['line'])) ? ':'.$trace['line'] : '';
echo '<li>
<b>'.((isset($trace['class'])) ? $trace['class'] : '').((isset($trace['type'])) ? $trace['type'] : '').$trace['function'].'</b>
'.$relative_file.$current_line.'
</li>';
}
echo '</ul>
</div>';
}
/** /**
* ALIAS OF dieObject() - Display an error with detailed object but don't stop the execution * ALIAS OF dieObject() - Display an error with detailed object but don't stop the execution
* *
@@ -1434,13 +1389,13 @@ class ToolsCore
/** /**
* Translates a string with underscores into camel case (e.g. first_name -> firstName) * Translates a string with underscores into camel case (e.g. first_name -> firstName)
* @prototype string public static function toCamelCase(string $str[, bool $capitalise_first_char = false]) * @prototype string public static function toCamelCase(string $str[, bool $catapitalise_first_char = false])
*/ */
public static function toCamelCase($str, $catapitalise_first_char = false) public static function toCamelCase($str, $catapitalise_first_char = false)
{ {
$str = Tools::strtolower($str); $str = strtolower($str);
if ($catapitalise_first_char) if ($catapitalise_first_char)
$str = Tools::ucfirst($str); $str = ucfirst($str);
return preg_replace_callback('/_+([a-z])/', create_function('$c', 'return strtoupper($c[1]);'), $str); return preg_replace_callback('/_+([a-z])/', create_function('$c', 'return strtoupper($c[1]);'), $str);
} }
@@ -2174,9 +2129,6 @@ exit;
} }
} }
/**
* @deprecated as of 1.5 use Controller::getController('PageNotFoundController')->run();
*/
public static function display404Error() public static function display404Error()
{ {
header('HTTP/1.1 404 Not Found'); header('HTTP/1.1 404 Not Found');
@@ -2563,21 +2515,6 @@ exit;
// No content, return false // No content, return false
return false; return false;
} }
public static function fileAttachment($input = 'fileUpload')
{
$fileAttachment = null;
if (isset($_FILES[$input]['name']) && !empty($_FILES[$input]['name']) && !empty($_FILES[$input]['tmp_name']))
{
$fileAttachment['rename'] = uniqid(). Tools::strtolower(substr($_FILES[$input]['name'], -5));
$fileAttachment['content'] = file_get_contents($_FILES[$input]['tmp_name']);
$fileAttachment['tmp_name'] = $_FILES[$input]['tmp_name'];
$fileAttachment['name'] = $_FILES[$input]['name'];
$fileAttachment['mime'] = $_FILES[$input]['type'];
$fileAttachment['error'] = $_FILES[$input]['error'];
}
return $fileAttachment;
}
} }
/** /**
+1 -7
View File
@@ -180,13 +180,7 @@ class TranslateCore
if ($js) if ($js)
$ret = addslashes($ret); $ret = addslashes($ret);
$ret = str_replace('"', '&quot;', $ret); $lang_cache[$cache_key] = str_replace('"', '&quot;', $ret);
if ($sprintf === null)
$lang_cache[$cache_key] = $ret;
else
return $ret;
} }
return $lang_cache[$cache_key]; return $lang_cache[$cache_key];
} }
+4 -11
View File
@@ -174,7 +174,7 @@ class ValidateCore
*/ */
public static function isMailName($mail_name) public static function isMailName($mail_name)
{ {
return (is_string($mail_name) && preg_match(Tools::cleanNonUnicodeSupport('/^[^<>;=#{}]*$/u'), $mail_name)); return preg_match(Tools::cleanNonUnicodeSupport('/^[^<>;=#{}]*$/u'), $mail_name);
} }
/** /**
@@ -380,7 +380,7 @@ class ValidateCore
*/ */
public static function isGenericName($name) public static function isGenericName($name)
{ {
return empty($name) || preg_match('/^[^<>={}]*$/u', $name); return empty($name) || preg_match('/^[^<>=#{}]*$/u', $name);
} }
/** /**
@@ -389,7 +389,7 @@ class ValidateCore
* @param string $html HTML field to validate * @param string $html HTML field to validate
* @return boolean Validity is ok or not * @return boolean Validity is ok or not
*/ */
public static function isCleanHtml($html, $allow_iframe = false) public static function isCleanHtml($html)
{ {
$events = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange'; $events = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange';
$events .= '|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror|onselect|onreset|onabort|ondragdrop|onresize|onactivate|onafterprint|onmoveend'; $events .= '|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror|onselect|onreset|onabort|ondragdrop|onresize|onactivate|onafterprint|onmoveend';
@@ -398,14 +398,7 @@ class ValidateCore
$events .= '|ondragleave|ondragover|ondragstart|ondrop|onerrorupdate|onfilterchange|onfinish|onfocusin|onfocusout|onhashchange|onhelp|oninput|onlosecapture|onmessage|onmouseup|onmovestart'; $events .= '|ondragleave|ondragover|ondragstart|ondrop|onerrorupdate|onfilterchange|onfinish|onfocusin|onfocusout|onhashchange|onhelp|oninput|onlosecapture|onmessage|onmouseup|onmovestart';
$events .= '|onoffline|ononline|onpaste|onpropertychange|onreadystatechange|onresizeend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onsearch|onselectionchange'; $events .= '|onoffline|ononline|onpaste|onpropertychange|onreadystatechange|onresizeend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onsearch|onselectionchange';
$events .= '|onselectstart|onstart|onstop'; $events .= '|onselectstart|onstart|onstop';
return (!preg_match('/<[ \t\n]*script/ims', $html) && !preg_match('/('.$events.')[ \t\n]*=/ims', $html) && !preg_match('/.*script\:/ims', $html) && !preg_match('/<[ \t\n]*i?frame/ims', $html));
if (preg_match('/<[\s]*script/ims', $html) || preg_match('/('.$events.')[\s]*=/ims', $html) || preg_match('/.*script\:/ims', $html))
return false;
if (!$allow_iframe && preg_match('/<[\s]*(i?frame|form|input|embed|object)/ims', $html))
return false;
return true;
} }
/** /**
+1 -1
View File
@@ -144,7 +144,7 @@ abstract class CacheCore
*/ */
public function set($key, $value, $ttl = 0) public function set($key, $value, $ttl = 0)
{ {
if ($this->_set($key, $value, $ttl)) if ($this->_set($key, $value))
{ {
if ($ttl < 0) if ($ttl < 0)
$ttl = 0; $ttl = 0;
-1
View File
@@ -149,7 +149,6 @@ class CacheFsCore extends Cache
*/ */
protected function getFilename($key) protected function getFilename($key)
{ {
$key = md5($key);
$path = _PS_CACHEFS_DIRECTORY_; $path = _PS_CACHEFS_DIRECTORY_;
for ($i = 0; $i < $this->depth; $i++) for ($i = 0; $i < $this->depth; $i++)
$path .= $key[$i].'/'; $path .= $key[$i].'/';
+8 -18
View File
@@ -44,19 +44,11 @@ class CacheMemcacheCore extends Cache
{ {
$this->connect(); $this->connect();
// Get keys (this code comes from Doctrine 2 project)
$this->keys = array(); $this->keys = array();
$servers = self::getMemcachedServers(); $servers = self::getMemcachedServers();
if(is_array($servers) && count($servers) > 0) if(is_array($servers) && count($servers) > 0 && method_exists('Memcache', 'getStats'))
{
$this->keys = $this->memcache->get(_COOKIE_IV_);
if (!is_array($this->keys))
$this->keys = array();
}
/*
// Get keys (this code comes from Doctrine 2 project)
if(is_array($servers) && count($servers) > 0 && method_exists('Memcache', 'getStats'))
$all_slabs = $this->memcache->getStats('slabs'); $all_slabs = $this->memcache->getStats('slabs');
if(isset($all_slabs) && is_array($all_slabs)) if(isset($all_slabs) && is_array($all_slabs))
@@ -64,24 +56,23 @@ class CacheMemcacheCore extends Cache
{ {
if (is_array($slabs)) if (is_array($slabs))
{ {
foreach (array_keys($slabs) as $i => $slab_id) // $slab_id is not an int but a string, using the key instead ? foreach (array_keys($slabs) as $slab_id)
{ {
if(is_int($i)) if(is_int($slab_id))
{ {
$dump = $this->memcache->getStats('cachedump', (int)$i); $dump = $this->memcache->getStats('cachedump', (int)$slab_id);
if ($dump) if ($dump)
{ {
foreach ($dump as $entries) foreach ($dump as $entries)
{ {
if($entries) if ($entries)
foreach ($entries as $key => $data) $this->keys = array_merge($this->keys, array_keys($entries));
$this->keys[$key] = $data[1];
} }
} }
} }
} }
} }
}*/ }
} }
public function __destruct() public function __destruct()
@@ -153,7 +144,6 @@ class CacheMemcacheCore extends Cache
*/ */
protected function _writeKeys() protected function _writeKeys()
{ {
$this->memcache->set(_COOKIE_IV_, $this->keys);
} }
/** /**
+73 -145
View File
@@ -47,8 +47,6 @@ class AdminControllerCore extends Controller
/** @var string Associated table name */ /** @var string Associated table name */
public $table; public $table;
public $list_id;
/** @var string Object identifier inside the associated table */ /** @var string Object identifier inside the associated table */
protected $identifier = false; protected $identifier = false;
@@ -315,7 +313,7 @@ class AdminControllerCore extends Controller
19 => $this->l('Duplication was completed successfully.'), 20 => $this->l('The translation was added successfully, but the language has not been created.'), 19 => $this->l('Duplication was completed successfully.'), 20 => $this->l('The translation was added successfully, but the language has not been created.'),
21 => $this->l('Module reset successfully.'), 22 => $this->l('Module deleted successfully.'), 21 => $this->l('Module reset successfully.'), 22 => $this->l('Module deleted successfully.'),
23 => $this->l('Localization pack imported successfully.'), 24 => $this->l('Localization pack imported successfully.'), 23 => $this->l('Localization pack imported successfully.'), 24 => $this->l('Localization pack imported successfully.'),
25 => $this->l('The selected images have successfully been moved.'), 25 => $this->l('The selcted images have successfully been moved.'),
26 => $this->l('Your cover selection has been saved.'), 26 => $this->l('Your cover selection has been saved.'),
27 => $this->l('The image shop association has been modified.'), 27 => $this->l('The image shop association has been modified.'),
28 => $this->l('A zone has been assigned to the selection successfully.'), 28 => $this->l('A zone has been assigned to the selection successfully.'),
@@ -381,39 +379,6 @@ class AdminControllerCore extends Controller
break; break;
} }
$this->toolbar_title = $bread_extended; $this->toolbar_title = $bread_extended;
if (Tools::isSubmit('submitFilter'))
{
$filter = '';
foreach ($this->fields_list AS $field => $t)
{
if ($val = htmlspecialchars(Tools::getValue($this->table.'Filter_'.$field), ENT_QUOTES, 'UTF-8'))
{
if(!is_array($val) && !empty($val))
$filter .= ($filter ? ', ' : $this->l(' filter by ')).$t['title'].' : ';
if (isset($t['type']) && $t['type'] == 'bool')
$filter .= ((bool)$val) ? $this->l('yes') : $this->l('no');
elseif(is_string($val))
$filter .= $val;
elseif(is_array($val))
{
$tmp = '';
foreach($val as $v)
if(is_string($v) && !empty($v))
$tmp .= ' - '.$v;
if(Tools::strlen($tmp))
{
$tmp = ltrim($tmp, ' - ');
$filter .= ($filter ? ', ' : $this->l(' filter by ')).$t['title'].' : ';
$filter .= $tmp;
}
}
}
}
if ($filter)
$this->toolbar_title[] = $filter;
}
} }
/** /**
@@ -464,33 +429,29 @@ class AdminControllerCore extends Controller
*/ */
public function processFilter() public function processFilter()
{ {
if (!isset($this->list_id))
$this->list_id = $this->table;
$prefix = str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this))); $prefix = str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this)));
// Filter memorization // Filter memorization
if (isset($_POST) && !empty($_POST) && isset($this->list_id)) if (isset($_POST) && !empty($_POST) && isset($this->table))
foreach ($_POST as $key => $value) foreach ($_POST as $key => $value)
{ {
if (stripos($key, $this->list_id.'Filter_') === 0) if (stripos($key, $this->table.'Filter_') === 0)
$this->context->cookie->{$prefix.$key} = !is_array($value) ? $value : serialize($value); $this->context->cookie->{$prefix.$key} = !is_array($value) ? $value : serialize($value);
elseif(stripos($key, 'submitFilter') === 0) elseif(stripos($key, 'submitFilter') === 0)
$this->context->cookie->$key = !is_array($value) ? $value : serialize($value); $this->context->cookie->$key = !is_array($value) ? $value : serialize($value);
} }
if (isset($_GET) && !empty($_GET) && isset($this->list_id)) if (isset($_GET) && !empty($_GET) && isset($this->table))
foreach ($_GET as $key => $value) foreach ($_GET as $key => $value)
if (stripos($key, $this->list_id.'OrderBy') === 0 || stripos($key, $this->list_id.'Orderway') === 0) if (stripos($key, $this->table.'OrderBy') === 0 || stripos($key, $this->table.'Orderway') === 0)
$this->context->cookie->{$prefix.$key} = $value; $this->context->cookie->{$prefix.$key} = $value;
$filters = $this->context->cookie->getFamily($prefix.$this->list_id.'Filter_'); $filters = $this->context->cookie->getFamily($prefix.$this->table.'Filter_');
foreach ($filters as $key => $value) foreach ($filters as $key => $value)
{ {
/* Extracting filters from $_POST on key filter_ */ /* Extracting filters from $_POST on key filter_ */
if ($value != null && !strncmp($key, $prefix.$this->list_id.'Filter_', 7 + Tools::strlen($prefix.$this->list_id))) if ($value != null && !strncmp($key, $prefix.$this->table.'Filter_', 7 + Tools::strlen($prefix.$this->table)))
{ {
$key = Tools::substr($key, 7 + Tools::strlen($prefix.$this->list_id)); $key = Tools::substr($key, 7 + Tools::strlen($prefix.$this->table));
/* Table alias could be specified using a ! eg. alias!field */ /* Table alias could be specified using a ! eg. alias!field */
$tmp_tab = explode('!', $key); $tmp_tab = explode('!', $key);
$filter = count($tmp_tab) > 1 ? $tmp_tab[1] : $tmp_tab[0]; $filter = count($tmp_tab) > 1 ? $tmp_tab[1] : $tmp_tab[0];
@@ -686,14 +647,12 @@ class AdminControllerCore extends Controller
$this->errors[] = Tools::displayError('Unable to delete associated images.'); $this->errors[] = Tools::displayError('Unable to delete associated images.');
$object->deleted = 1; $object->deleted = 1;
if ($res = $object->update()) if ($object->update())
$this->redirect_after = self::$currentIndex.'&conf=1&token='.$this->token; $this->redirect_after = self::$currentIndex.'&conf=1&token='.$this->token;
} }
elseif ($res = $object->delete()) elseif ($object->delete())
$this->redirect_after = self::$currentIndex.'&conf=1&token='.$this->token; $this->redirect_after = self::$currentIndex.'&conf=1&token='.$this->token;
$this->errors[] = Tools::displayError('An error occurred during deletion.'); $this->errors[] = Tools::displayError('An error occurred during deletion.');
if ($res)
Logger::addLog(sprintf($this->l('%s deletion'), $this->className), 1, null, $this->className, (int)$this->object->id, true, (int)$this->context->employee->id);
} }
} }
else else
@@ -742,7 +701,6 @@ class AdminControllerCore extends Controller
/* voluntary do affectation here */ /* voluntary do affectation here */
elseif (($_POST[$this->identifier] = $this->object->id) && $this->postImage($this->object->id) && !count($this->errors) && $this->_redirect) elseif (($_POST[$this->identifier] = $this->object->id) && $this->postImage($this->object->id) && !count($this->errors) && $this->_redirect)
{ {
Logger::addLog(sprintf($this->l('%s addition'), $this->className), 1, null, $this->className, (int)$this->object->id, true, (int)$this->context->employee->id);
$parent_id = (int)Tools::getValue('id_parent', 1); $parent_id = (int)Tools::getValue('id_parent', 1);
$this->afterAdd($this->object); $this->afterAdd($this->object);
$this->updateAssoShop($this->object->id); $this->updateAssoShop($this->object->id);
@@ -777,6 +735,7 @@ class AdminControllerCore extends Controller
{ {
/* Checking fields validity */ /* Checking fields validity */
$this->validateRules(); $this->validateRules();
if (empty($this->errors)) if (empty($this->errors))
{ {
$id = (int)Tools::getValue($this->identifier); $id = (int)Tools::getValue($this->identifier);
@@ -842,7 +801,6 @@ class AdminControllerCore extends Controller
if (empty($this->redirect_after)) if (empty($this->redirect_after))
$this->redirect_after = self::$currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=4&token='.$this->token; $this->redirect_after = self::$currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=4&token='.$this->token;
} }
Logger::addLog(sprintf($this->l('%s edition'), $this->className), 1, null, $this->className, (int)$object->id, true, (int)$this->context->employee->id);
} }
else else
$this->errors[] = Tools::displayError('An error occurred while updating an object.'). $this->errors[] = Tools::displayError('An error occurred while updating an object.').
@@ -926,32 +884,30 @@ class AdminControllerCore extends Controller
/** /**
* Cancel all filters for this tab * Cancel all filters for this tab
*/ */
public function processResetFilters($list_id = null) public function processResetFilters()
{ {
if (!isset($list_id))
$list_id = isset($this->list_id) ? $this->list_id : $this->table;
$prefix = str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this))); $prefix = str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this)));
$filters = $this->context->cookie->getFamily($prefix.$list_id.'Filter_'); $filters = $this->context->cookie->getFamily($prefix.$this->table.'Filter_');
foreach ($filters as $cookie_key => $filter) foreach ($filters as $cookie_key => $filter)
if (strncmp($cookie_key, $prefix.$list_id.'Filter_', 7 + Tools::strlen($prefix.$list_id)) == 0) if (strncmp($cookie_key, $prefix.$this->table.'Filter_', 7 + Tools::strlen($prefix.$this->table)) == 0)
{ {
$key = substr($cookie_key, 7 + Tools::strlen($prefix.$list_id)); $key = substr($cookie_key, 7 + Tools::strlen($prefix.$this->table));
/* Table alias could be specified using a ! eg. alias!field */
$tmp_tab = explode('!', $key);
$key = (count($tmp_tab) > 1 ? $tmp_tab[1] : $tmp_tab[0]);
if (is_array($this->fields_list) && array_key_exists($key, $this->fields_list)) if (is_array($this->fields_list) && array_key_exists($key, $this->fields_list))
$this->context->cookie->$cookie_key = null;
unset($this->context->cookie->$cookie_key); unset($this->context->cookie->$cookie_key);
} }
if (isset($this->context->cookie->{'submitFilter'.$list_id})) if (isset($this->context->cookie->{'submitFilter'.$this->table}))
unset($this->context->cookie->{'submitFilter'.$list_id}); unset($this->context->cookie->{'submitFilter'.$this->table});
if (isset($this->context->cookie->{$prefix.$list_id.'Orderby'})) if (isset($this->context->cookie->{$prefix.$this->table.'Orderby'}))
unset($this->context->cookie->{$prefix.$list_id.'Orderby'}); unset($this->context->cookie->{$prefix.$this->table.'Orderby'});
if (isset($this->context->cookie->{$prefix.$list_id.'Orderway'})) if (isset($this->context->cookie->{$prefix.$this->table.'Orderway'}))
unset($this->context->cookie->{$prefix.$list_id.'Orderway'}); unset($this->context->cookie->{$prefix.$this->table.'Orderway'});
unset($_POST); unset($_POST);
$this->_filter = false; $this->_filter = false;
@@ -1192,9 +1148,6 @@ class AdminControllerCore extends Controller
protected function filterToField($key, $filter) protected function filterToField($key, $filter)
{ {
if (!isset($this->fields_list))
return false;
foreach ($this->fields_list as $field) foreach ($this->fields_list as $field)
if (array_key_exists('filter_key', $field) && $field['filter_key'] == $key) if (array_key_exists('filter_key', $field) && $field['filter_key'] == $key)
return $field; return $field;
@@ -1241,7 +1194,8 @@ class AdminControllerCore extends Controller
$tpl_action = $this->tpl_folder.$this->display.'.tpl'; $tpl_action = $this->tpl_folder.$this->display.'.tpl';
// Check if action template has been overriden // Check if action template has been override
foreach ($this->context->smarty->getTemplateDir() as $template_dir) foreach ($this->context->smarty->getTemplateDir() as $template_dir)
if (file_exists($template_dir.DIRECTORY_SEPARATOR.$tpl_action) && $this->display != 'view' && $this->display != 'options') if (file_exists($template_dir.DIRECTORY_SEPARATOR.$tpl_action) && $this->display != 'view' && $this->display != 'options')
{ {
@@ -1260,15 +1214,27 @@ class AdminControllerCore extends Controller
$page = $this->content; $page = $this->content;
if ($conf = Tools::getValue('conf')) if ($conf = Tools::getValue('conf'))
$this->context->smarty->assign('conf', $this->json ? Tools::jsonEncode($this->_conf[(int)$conf]) : $this->_conf[(int)$conf]); if ($this->json)
$this->context->smarty->assign('conf', Tools::jsonEncode($this->_conf[(int)$conf]));
else
$this->context->smarty->assign('conf', $this->_conf[(int)$conf]);
foreach (array('errors', 'warnings', 'informations', 'confirmations') as $type) $notifications_type = array('errors', 'warnings', 'informations', 'confirmations');
$this->context->smarty->assign($type, $this->json ? Tools::jsonEncode(array_unique($this->$type)) : array_unique($this->$type)); foreach($notifications_type as $type)
if ($this->json)
$this->context->smarty->assign($type, Tools::jsonEncode(array_unique($this->$type)));
else
$this->context->smarty->assign($type, array_unique($this->$type));
if ($this->json)
$this->context->smarty->assign('page', Tools::jsonEncode($page));
else
$this->context->smarty->assign('page', $page);
$this->context->smarty->assign('page', $this->json ? Tools::jsonEncode($page) : $page);
$this->smartyOutputContent($this->layout); $this->smartyOutputContent($this->layout);
} }
/** /**
* add a warning message to display at the top of the page * add a warning message to display at the top of the page
* *
@@ -1512,8 +1478,6 @@ class AdminControllerCore extends Controller
*/ */
protected function initTabModuleList() protected function initTabModuleList()
{ {
if (!$this->isFresh(Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, 86400))
@file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, Tools::addonsRequest('must-have'));
if (!$this->isFresh(Module::CACHE_FILE_TAB_MODULES_LIST, 604800)) if (!$this->isFresh(Module::CACHE_FILE_TAB_MODULES_LIST, 604800))
$this->refresh(Module::CACHE_FILE_TAB_MODULES_LIST, 'http://'.Tab::TAB_MODULE_LIST_URL); $this->refresh(Module::CACHE_FILE_TAB_MODULES_LIST, 'http://'.Tab::TAB_MODULE_LIST_URL);
@@ -1535,16 +1499,6 @@ class AdminControllerCore extends Controller
protected function addToolBarModulesListButton() protected function addToolBarModulesListButton()
{ {
if (!$this->isFresh(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 86400))
file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, Tools::addonsRequest('native'));
$country_module_list_xml = simplexml_load_file(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST);
$country_module_list = array();
foreach ($country_module_list_xml->module as $k => $m)
$country_module_list[] = (string)$m->name;
$this->tab_modules_list['slider_list'] = array_intersect($this->tab_modules_list['slider_list'], $country_module_list);
if (is_array($this->tab_modules_list['slider_list']) && count($this->tab_modules_list['slider_list'])) if (is_array($this->tab_modules_list['slider_list']) && count($this->tab_modules_list['slider_list']))
$this->toolbar_btn['modules-list'] = array( $this->toolbar_btn['modules-list'] = array(
'href' => '#', 'href' => '#',
@@ -1580,6 +1534,7 @@ class AdminControllerCore extends Controller
public function renderModulesList() public function renderModulesList()
{ {
if ($this->getModulesList($this->filter_modules_list)) if ($this->getModulesList($this->filter_modules_list))
{ {
$helper = new Helper(); $helper = new Helper();
@@ -1744,7 +1699,6 @@ class AdminControllerCore extends Controller
$helper->row_hover = $this->row_hover; $helper->row_hover = $this->row_hover;
$helper->position_identifier = $this->position_identifier; $helper->position_identifier = $this->position_identifier;
$helper->controller_name = $this->controller_name; $helper->controller_name = $this->controller_name;
$helper->list_id = isset($this->list_id) ? $this->list_id : $this->table;
// For each action, try to add the corresponding skip elements list // For each action, try to add the corresponding skip elements list
$helper->list_skip_actions = $this->list_skip_actions; $helper->list_skip_actions = $this->list_skip_actions;
@@ -1826,11 +1780,7 @@ class AdminControllerCore extends Controller
$this->context->employee->logout(); $this->context->employee->logout();
if ($this->controller_name != 'AdminLogin' && (!isset($this->context->employee) || !$this->context->employee->isLoggedBack())) if ($this->controller_name != 'AdminLogin' && (!isset($this->context->employee) || !$this->context->employee->isLoggedBack()))
{
if (isset($this->context->employee))
$this->context->employee->logout();
Tools::redirectAdmin($this->context->link->getAdminLink('AdminLogin').((!isset($_GET['logout']) && $this->controller_name != 'AdminNotFound') ? '&redirect='.$this->controller_name : '')); Tools::redirectAdmin($this->context->link->getAdminLink('AdminLogin').((!isset($_GET['logout']) && $this->controller_name != 'AdminNotFound') ? '&redirect='.$this->controller_name : ''));
}
// Set current index // Set current index
$current_index = 'index.php'.(($controller = Tools::getValue('controller')) ? '?controller='.$controller : ''); $current_index = 'index.php'.(($controller = Tools::getValue('controller')) ? '?controller='.$controller : '');
@@ -1943,14 +1893,11 @@ class AdminControllerCore extends Controller
*/ */
public function initProcess() public function initProcess()
{ {
if (!isset($this->list_id))
$this->list_id = $this->table;
// Manage list filtering // Manage list filtering
if (Tools::isSubmit('submitFilter'.$this->list_id) if (Tools::isSubmit('submitFilter'.$this->table)
|| $this->context->cookie->{'submitFilter'.$this->list_id} !== false || $this->context->cookie->{'submitFilter'.$this->table} !== false
|| Tools::getValue($this->list_id.'Orderby') || Tools::getValue($this->table.'Orderby')
|| Tools::getValue($this->list_id.'Orderway')) || Tools::getValue($this->table.'Orderway'))
$this->filter = true; $this->filter = true;
$this->id_object = (int)Tools::getValue($this->identifier); $this->id_object = (int)Tools::getValue($this->identifier);
@@ -2052,7 +1999,7 @@ class AdminControllerCore extends Controller
$this->action = 'export'; $this->action = 'export';
} }
/* Cancel all filters for this tab */ /* Cancel all filters for this tab */
elseif (isset($_POST['submitReset'.$this->list_id])) elseif (isset($_POST['submitReset'.$this->table]))
$this->action = 'reset_filters'; $this->action = 'reset_filters';
/* Submit options list */ /* Submit options list */
elseif (Tools::getValue('submitOptions'.$this->table) || Tools::getValue('submitOptions')) elseif (Tools::getValue('submitOptions'.$this->table) || Tools::getValue('submitOptions'))
@@ -2106,17 +2053,14 @@ class AdminControllerCore extends Controller
*/ */
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false) public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
{ {
if (!isset($this->list_id))
$this->list_id = $this->table;
/* Manage default params values */ /* Manage default params values */
$use_limit = true; $use_limit = true;
if ($limit === false) if ($limit === false)
$use_limit = false; $use_limit = false;
elseif (empty($limit)) elseif (empty($limit))
{ {
if (isset($this->context->cookie->{$this->list_id.'_pagination'}) && $this->context->cookie->{$this->list_id.'_pagination'}) if (isset($this->context->cookie->{$this->table.'_pagination'}) && $this->context->cookie->{$this->table.'_pagination'})
$limit = $this->context->cookie->{$this->list_id.'_pagination'}; $limit = $this->context->cookie->{$this->table.'_pagination'};
else else
$limit = $this->_pagination[1]; $limit = $this->_pagination[1];
} }
@@ -2126,8 +2070,8 @@ class AdminControllerCore extends Controller
$prefix = str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this))); $prefix = str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this)));
if (empty($order_by)) if (empty($order_by))
{ {
if ($this->context->cookie->{$prefix.$this->list_id.'Orderby'}) if ($this->context->cookie->{$prefix.$this->table.'Orderby'})
$order_by = $this->context->cookie->{$prefix.$this->list_id.'Orderby'}; $order_by = $this->context->cookie->{$prefix.$this->table.'Orderby'};
elseif ($this->_orderBy) elseif ($this->_orderBy)
$order_by = $this->_orderBy; $order_by = $this->_orderBy;
else else
@@ -2136,16 +2080,16 @@ class AdminControllerCore extends Controller
if (empty($order_way)) if (empty($order_way))
{ {
if ($this->context->cookie->{$prefix.$this->list_id.'Orderway'}) if ($this->context->cookie->{$prefix.$this->table.'Orderway'})
$order_way = $this->context->cookie->{$prefix.$this->list_id.'Orderway'}; $order_way = $this->context->cookie->{$prefix.$this->table.'Orderway'};
elseif ($this->_orderWay) elseif ($this->_orderWay)
$order_way = $this->_orderWay; $order_way = $this->_orderWay;
else else
$order_way = $this->_defaultOrderWay; $order_way = $this->_defaultOrderWay;
} }
$limit = (int)Tools::getValue($this->list_id.'_pagination', $limit); $limit = (int)Tools::getValue('pagination', $limit);
$this->context->cookie->{$this->list_id.'_pagination'} = $limit; $this->context->cookie->{$this->table.'_pagination'} = $limit;
/* Check params validity */ /* Check params validity */
if (!Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way) if (!Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way)
@@ -2157,12 +2101,12 @@ class AdminControllerCore extends Controller
$order_by = $this->fields_list[$order_by]['filter_key']; $order_by = $this->fields_list[$order_by]['filter_key'];
/* Determine offset from current page */ /* Determine offset from current page */
if ((isset($_POST['submitFilter'.$this->list_id]) || if ((isset($_POST['submitFilter'.$this->table]) ||
isset($_POST['submitFilter'.$this->list_id.'_x']) || isset($_POST['submitFilter'.$this->table.'_x']) ||
isset($_POST['submitFilter'.$this->list_id.'_y'])) && isset($_POST['submitFilter'.$this->table.'_y'])) &&
!empty($_POST['submitFilter'.$this->list_id]) && !empty($_POST['submitFilter'.$this->table]) &&
is_numeric($_POST['submitFilter'.$this->list_id])) is_numeric($_POST['submitFilter'.$this->table]))
$start = ((int)$_POST['submitFilter'.$this->list_id] - 1) * $limit; $start = ((int)$_POST['submitFilter'.$this->table] - 1) * $limit;
/* Cache */ /* Cache */
$this->_lang = (int)$id_lang; $this->_lang = (int)$id_lang;
@@ -2260,7 +2204,7 @@ class AdminControllerCore extends Controller
$this->_listsql .= ($this->lang ? 'b.*,' : '').' a.*'; $this->_listsql .= ($this->lang ? 'b.*,' : '').' a.*';
$this->_listsql .= ' $this->_listsql .= '
'.(isset($this->_select) ? ', '.rtrim($this->_select, ', ') : '').$select_shop.' '.(isset($this->_select) ? ', '.$this->_select : '').$select_shop.'
FROM `'._DB_PREFIX_.$sql_table.'` a FROM `'._DB_PREFIX_.$sql_table.'` a
'.$lang_join.' '.$lang_join.'
'.(isset($this->_join) ? $this->_join.' ' : '').' '.(isset($this->_join) ? $this->_join.' ' : '').'
@@ -2273,7 +2217,6 @@ class AdminControllerCore extends Controller
($this->_tmpTableFilter ? ') tmpTable WHERE 1'.$this->_tmpTableFilter : ''). ($this->_tmpTableFilter ? ') tmpTable WHERE 1'.$this->_tmpTableFilter : '').
(($use_limit === true) ? ' LIMIT '.(int)$start.','.(int)$limit : ''); (($use_limit === true) ? ' LIMIT '.(int)$start.','.(int)$limit : '');
$this->_listTotal = 0;
if (!($this->_list = Db::getInstance()->executeS($this->_listsql))) if (!($this->_list = Db::getInstance()->executeS($this->_listsql)))
$this->_list_error = Db::getInstance()->getMsgError(); $this->_list_error = Db::getInstance()->getMsgError();
else else
@@ -2290,7 +2233,7 @@ class AdminControllerCore extends Controller
$all_modules = Module::getModulesOnDisk(true); $all_modules = Module::getModulesOnDisk(true);
$this->modules_list = array(); $this->modules_list = array();
foreach ($all_modules as $module) foreach($all_modules as $module)
{ {
$perm = true; $perm = true;
if ($module->id) if ($module->id)
@@ -2306,11 +2249,9 @@ class AdminControllerCore extends Controller
if (in_array($module->name, $filter_modules_list) && $perm) if (in_array($module->name, $filter_modules_list) && $perm)
{ {
$this->fillModuleData($module, 'select'); $this->fillModuleData($module, 'select');
$this->modules_list[array_search($module->name, $filter_modules_list)] = $module; $this->modules_list[] = $module;
} }
} }
ksort($this->modules_list);
if (count($this->modules_list)) if (count($this->modules_list))
return true; return true;
@@ -2497,7 +2438,7 @@ class AdminControllerCore extends Controller
call_user_func(array($class_name, 'displayFieldName'), 'passwd', $class_name) call_user_func(array($class_name, 'displayFieldName'), 'passwd', $class_name)
); );
elseif ($class_name == 'Customer' && !Validate::isPasswd($value)) elseif ($class_name == 'Customer' && !Validate::isPasswd($value))
$this->errors['passwd'] = sprintf( $this->errors[$field] = sprintf(
Tools::displayError('The %s field is invalid.'), Tools::displayError('The %s field is invalid.'),
call_user_func(array($class_name, 'displayFieldName'), 'passwd', $class_name) call_user_func(array($class_name, 'displayFieldName'), 'passwd', $class_name)
); );
@@ -2769,31 +2710,18 @@ class AdminControllerCore extends Controller
else else
{ {
$result = true; $result = true;
foreach ($this->boxes as $id) if ($this->deleted)
{ {
$to_delete = new $this->className($id); foreach ($this->boxes as $id)
$delete_ok = true;
if ($this->deleted)
{ {
$to_delete = new $this->className($id);
$to_delete->deleted = 1; $to_delete->deleted = 1;
if (!$to_delete->update()) $result = $result && $to_delete->update();
{
$result = false;
$delete_ok = false;
}
} }
else
if (!$to_delete->delete())
{
$result = false;
$delete_ok = false;
}
if ($delete_ok)
Logger::addLog(sprintf($this->l('%s deletion'), $this->className), 1, null, $this->className, (int)$to_delete->id, true, (int)$this->context->employee->id);
else
$this->errors[] = sprintf(Tools::displayError('Can\'t delete #%d'), $id);
} }
else
$result = $object->deleteSelection(Tools::getValue($this->table.'Box'));
if ($result) if ($result)
$this->redirect_after = self::$currentIndex.'&conf=2&token='.$this->token; $this->redirect_after = self::$currentIndex.'&conf=2&token='.$this->token;
$this->errors[] = Tools::displayError('An error occurred while deleting this selection.'); $this->errors[] = Tools::displayError('An error occurred while deleting this selection.');
+17 -17
View File
@@ -114,15 +114,18 @@ class FrontControllerCore extends Controller
$css_files = $this->css_files; $css_files = $this->css_files;
$js_files = $this->js_files; $js_files = $this->js_files;
// If we call a SSL controller without SSL or a non SSL controller with SSL, we redirect with the right protocol if ($this->ssl && !Tools::usingSecureMode() && Configuration::get('PS_SSL_ENABLED'))
if (Configuration::get('PS_SSL_ENABLED') && ($_SERVER['REQUEST_METHOD'] != 'POST') && $this->ssl != Tools::usingSecureMode())
{ {
header('HTTP/1.1 301 Moved Permanently'); header('HTTP/1.1 301 Moved Permanently');
header('Cache-Control: no-cache'); header('Cache-Control: no-cache');
if ($this->ssl) header('Location: '.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']);
header('Location: '.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']); exit();
else }
header('Location: '.Tools::getShopDomain(true).$_SERVER['REQUEST_URI']); elseif (Configuration::get('PS_SSL_ENABLED') && Tools::usingSecureMode() && !($this->ssl))
{
header('HTTP/1.1 301 Moved Permanently');
header('Cache-Control: no-cache');
header('Location: '.Tools::getShopDomain(true).$_SERVER['REQUEST_URI']);
exit(); exit();
} }
@@ -333,8 +336,7 @@ class FrontControllerCore extends Controller
'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') || !(bool)Group::getCurrent()->show_prices, 'PS_CATALOG_MODE' => (bool)Configuration::get('PS_CATALOG_MODE') || !(bool)Group::getCurrent()->show_prices,
'b2b_enable' => (bool)Configuration::get('PS_B2B_ENABLE'), 'b2b_enable' => (bool)Configuration::get('PS_B2B_ENABLE'),
'request' => $link->getPaginationLink(false, false, false, true), 'request' => $link->getPaginationLink(false, false, false, true)
'PS_STOCK_MANAGEMENT' => Configuration::get('PS_STOCK_MANAGEMENT')
)); ));
// Add the tpl files directory for mobile // Add the tpl files directory for mobile
@@ -594,7 +596,7 @@ class FrontControllerCore extends Controller
protected function canonicalRedirection($canonical_url = '') protected function canonicalRedirection($canonical_url = '')
{ {
if (!$canonical_url || !Configuration::get('PS_CANONICAL_REDIRECT') || strtoupper($_SERVER['REQUEST_METHOD']) != 'GET' || Tools::getValue('live_edit')) if (!$canonical_url || !Configuration::get('PS_CANONICAL_REDIRECT') || strtoupper($_SERVER['REQUEST_METHOD']) != 'GET')
return; return;
$match_url = (($this->ssl && Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; $match_url = (($this->ssl && Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
@@ -773,11 +775,9 @@ class FrontControllerCore extends Controller
public function checkLiveEditAccess() public function checkLiveEditAccess()
{ {
if (!Tools::isSubmit('live_edit') || !Tools::getValue('ad') || !Tools::getValue('liveToken')) $live_token = Tools::getAdminToken('AdminModulesPositions'.(int)Tab::getIdFromClassName('AdminModulesPositions').(int)Tools::getValue('id_employee'));
return false; $ad = Tools::getValue('ad');
if (Tools::getValue('liveToken') != Tools::getAdminToken('AdminModulesPositions'.(int)Tab::getIdFromClassName('AdminModulesPositions').(int)Tools::getValue('id_employee'))) return Tools::isSubmit('live_edit') && $ad && Tools::getValue('liveToken') == $live_token && is_dir(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.$ad);
return false;
return is_dir(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.Tools::getValue('ad'));
} }
public function getLiveEditFooter() public function getLiveEditFooter()
@@ -806,7 +806,7 @@ class FrontControllerCore extends Controller
// 'orderwaydefault' => Tools::getProductsOrder('way'), // 'orderwaydefault' => Tools::getProductsOrder('way'),
$stock_management = Configuration::get('PS_STOCK_MANAGEMENT') ? true : false; // no display quantity order if stock management disabled $stock_management = Configuration::get('PS_STOCK_MANAGEMENT') ? true : false; // no display quantity order if stock management disabled
$order_by_values = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position', 5 => 'manufacturer_name', 6 => 'quantity', 7 => 'reference'); $order_by_values = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position', 5 => 'manufacturer_name', 6 => 'quantity');
$order_way_values = array(0 => 'asc', 1 => 'desc'); $order_way_values = array(0 => 'asc', 1 => 'desc');
$this->orderBy = Tools::strtolower(Tools::getValue('orderby', $order_by_values[(int)Configuration::get('PS_PRODUCTS_ORDER_BY')])); $this->orderBy = Tools::strtolower(Tools::getValue('orderby', $order_by_values[(int)Configuration::get('PS_PRODUCTS_ORDER_BY')]));
$this->orderWay = Tools::strtolower(Tools::getValue('orderway', $order_way_values[(int)Configuration::get('PS_PRODUCTS_ORDER_WAY')])); $this->orderWay = Tools::strtolower(Tools::getValue('orderway', $order_way_values[(int)Configuration::get('PS_PRODUCTS_ORDER_WAY')]));
@@ -847,8 +847,8 @@ class FrontControllerCore extends Controller
$range = 2; /* how many pages around page selected */ $range = 2; /* how many pages around page selected */
if ($this->p < 1) if ($this->p < 0)
$this->p = 1; $this->p = 0;
if (isset($this->context->cookie->nb_item_per_page) && $this->n != $this->context->cookie->nb_item_per_page && in_array($this->n, $nArray)) if (isset($this->context->cookie->nb_item_per_page) && $this->n != $this->context->cookie->nb_item_per_page && in_array($this->n, $nArray))
$this->context->cookie->nb_item_per_page = $this->n; $this->context->cookie->nb_item_per_page = $this->n;
+2 -3
View File
@@ -51,10 +51,9 @@ abstract class ModuleAdminControllerCore extends AdminController
public function createTemplate($tpl_name) public function createTemplate($tpl_name)
{ {
if (file_exists(_PS_THEME_DIR_.'modules/'.$this->module->name.'/views/templates/admin/'.$tpl_name) && $this->viewAccess()) if (file_exists($this->getTemplatePath().$this->override_folder.$tpl_name) && $this->viewAccess())
return $this->context->smarty->createTemplate(_PS_THEME_DIR_.'modules/'.$this->module->name.'/views/templates/admin/'.$tpl_name, $this->context->smarty);
elseif (file_exists($this->getTemplatePath().$this->override_folder.$tpl_name) && $this->viewAccess())
return $this->context->smarty->createTemplate($this->getTemplatePath().$this->override_folder.$tpl_name, $this->context->smarty); return $this->context->smarty->createTemplate($this->getTemplatePath().$this->override_folder.$tpl_name, $this->context->smarty);
return parent::createTemplate($tpl_name); return parent::createTemplate($tpl_name);
} }
@@ -55,8 +55,6 @@ class ModuleFrontControllerCore extends FrontController
{ {
if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/'.$this->module->name.'/'.$template)) if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/'.$this->module->name.'/'.$template))
$this->template = _PS_THEME_DIR_.'modules/'.$this->module->name.'/'.$template; $this->template = _PS_THEME_DIR_.'modules/'.$this->module->name.'/'.$template;
elseif (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/'.$this->module->name.'/views/templates/front/'.$template))
$this->template = _PS_THEME_DIR_.'modules/'.$this->module->name.'/views/templates/front/'.$template;
elseif (Tools::file_exists_cache($this->getTemplatePath().$template)) elseif (Tools::file_exists_cache($this->getTemplatePath().$template))
$this->template = $this->getTemplatePath().$template; $this->template = $this->getTemplatePath().$template;
else else
+1 -17
View File
@@ -53,21 +53,6 @@ class DbMySQLiCore extends Db
return $this->link; return $this->link;
} }
public static function createDatabase($host, $user, $password, $dbname, $dropit = false)
{
if (strpos($host, ':') !== false)
{
list($host, $port) = explode(':', $host);
$link = @new mysqli($host, $this->user, $this->password, null, $port);
}
else
$link = @new mysqli($host, $user, $password);
$success = $link->query('CREATE DATABASE `'.str_replace('`', '\\`', $dbname).'`');
if ($dropit && ($link->query('DROP DATABASE `'.str_replace('`', '\\`', $dbname).'`') !== false))
return true;
return $success;
}
/** /**
* @see DbCore::disconnect() * @see DbCore::disconnect()
*/ */
@@ -184,8 +169,7 @@ class DbMySQLiCore extends Db
if (!$link->options(MYSQLI_OPT_CONNECT_TIMEOUT, $timeout)) if (!$link->options(MYSQLI_OPT_CONNECT_TIMEOUT, $timeout))
return 1; return 1;
// There is an @ because mysqli throw a warning when the database does not exists if (!$link->real_connect($server, $user, $pwd, $db))
if (!@$link->real_connect($server, $user, $pwd, $db))
return (mysqli_connect_errno() == 1049) ? 2 : 1; return (mysqli_connect_errno() == 1049) ? 2 : 1;
$link->close(); $link->close();
+2 -13
View File
@@ -25,6 +25,8 @@
*/ */
/** /**
* This class is currently only here for tests
*
* @since 1.5.0 * @since 1.5.0
*/ */
class DbPDOCore extends Db class DbPDOCore extends Db
@@ -44,19 +46,6 @@ class DbPDOCore extends Db
return new PDO($dsn, $user, $password, array(PDO::ATTR_TIMEOUT => $timeout, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true)); return new PDO($dsn, $user, $password, array(PDO::ATTR_TIMEOUT => $timeout, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true));
} }
public static function createDatabase($host, $user, $password, $dbname, $dropit = false)
{
try {
$link = DbPDO::_getPDO($host, $user, $password, false);
$success = $link->exec('CREATE DATABASE `'.str_replace('`', '\\`', $dbname).'`');
if ($dropit && ($link->exec('DROP DATABASE `'.str_replace('`', '\\`', $dbname).'`') !== false))
return true;
} catch (PDOException $e) {
return false;
}
return $success;
}
/** /**
* @see DbCore::connect() * @see DbCore::connect()
*/ */
-9
View File
@@ -47,15 +47,6 @@ class MySQLCore extends Db
return $this->link; return $this->link;
} }
public static function createDatabase($host, $user, $password, $dbname, $dropit = false)
{
$link = mysql_connect($host, $user, $password);
$success = mysql_query('CREATE DATABASE `'.str_replace('`', '\\`', $dbname).'`', $link);
if ($dropit && (mysql_query('DROP DATABASE `'.str_replace('`', '\\`', $dbname).'`', $link) !== false))
return true;
return $success;
}
/** /**
* @see DbCore::disconnect() * @see DbCore::disconnect()
*/ */
+3 -12
View File
@@ -51,7 +51,7 @@ class PrestaShopExceptionCore extends Exception
</style>'; </style>';
echo '<div id="psException">'; echo '<div id="psException">';
echo '<h2>['.get_class($this).']</h2>'; echo '<h2>['.get_class($this).']</h2>';
echo $this->getExtendedMessage(); echo $this->getExentedMessage();
$this->displayFileDebug($this->getFile(), $this->getLine()); $this->displayFileDebug($this->getFile(), $this->getLine());
@@ -145,23 +145,14 @@ class PrestaShopExceptionCore extends Exception
{ {
$logger = new FileLogger(); $logger = new FileLogger();
$logger->setFilename(_PS_ROOT_DIR_.'/log/'.date('Ymd').'_exception.log'); $logger->setFilename(_PS_ROOT_DIR_.'/log/'.date('Ymd').'_exception.log');
$logger->logError($this->getExtendedMessage(false)); $logger->logError($this->getExentedMessage(false));
}
/**
* @deprecated 1.5.5
*/
protected function getExentedMessage($html = true)
{
Tools::displayAsDeprecated();
return $this->getExtendedMessage($html);
} }
/** /**
* Return the content of the Exception * Return the content of the Exception
* @return string content of the exception * @return string content of the exception
*/ */
protected function getExtendedMessage($html = true) protected function getExentedMessage($html = true)
{ {
$format = '<p><b>%s</b><br /><i>at line </i><b>%d</b><i> in file </i><b>%s</b></p>'; $format = '<p><b>%s</b><br /><i>at line </i><b>%d</b><i> in file </i><b>%s</b></p>';
if (!$html) if (!$html)
+1
View File
@@ -351,6 +351,7 @@ class HelperCore
public function renderModulesList($modules_list) public function renderModulesList($modules_list)
{ {
$this->tpl_vars = array('modules_list' => $modules_list); $this->tpl_vars = array('modules_list' => $modules_list);
$tpl = $this->createTemplate('helpers/modules_list/list.tpl'); $tpl = $this->createTemplate('helpers/modules_list/list.tpl');
$tpl->assign($this->tpl_vars); $tpl->assign($this->tpl_vars);
+1
View File
@@ -167,6 +167,7 @@ class HelperFormCore extends Helper
'module_dir' => _MODULE_DIR_, 'module_dir' => _MODULE_DIR_,
'contains_states' => (isset($this->fields_value['id_country']) && isset($this->fields_value['id_state'])) ? Country::containsStates($this->fields_value['id_country']) : null, 'contains_states' => (isset($this->fields_value['id_country']) && isset($this->fields_value['id_state'])) ? Country::containsStates($this->fields_value['id_country']) : null,
)); ));
return parent::generate(); return parent::generate();
} }
+20 -23
View File
@@ -173,13 +173,13 @@ class HelperListCore extends Helper
public function displayListContent() public function displayListContent()
{ {
if ($this->position_identifier)
$id_category = (int)Tools::getValue('id_'.($this->is_cms ? 'cms_' : '').'category', ($this->is_cms ? '1' : Category::getRootCategory()->id ));
else
$id_category = Category::getRootCategory()->id;
if (isset($this->fields_list['position'])) if (isset($this->fields_list['position']))
{ {
if ($this->position_identifier)
$id_category = (int)Tools::getValue('id_'.($this->is_cms ? 'cms_' : '').'category', ($this->is_cms ? '1' : Category::getRootCategory()->id ));
else
$id_category = Category::getRootCategory()->id;
$positions = array_map(create_function('$elem', 'return (int)($elem[\'position\']);'), $this->_list); $positions = array_map(create_function('$elem', 'return (int)($elem[\'position\']);'), $this->_list);
sort($positions); sort($positions);
} }
@@ -259,7 +259,7 @@ class HelperListCore extends Helper
$path_to_image = _PS_IMG_DIR_.$params['image'].'/'.$item_id.(isset($tr['id_image']) ? '-'.(int)$tr['id_image'] : '').'.'.$this->imageType; $path_to_image = _PS_IMG_DIR_.$params['image'].'/'.$item_id.(isset($tr['id_image']) ? '-'.(int)$tr['id_image'] : '').'.'.$this->imageType;
else else
$path_to_image = _PS_IMG_DIR_.$params['image'].'/'.Image::getImgFolderStatic($tr['id_image']).(int)$tr['id_image'].'.'.$this->imageType; $path_to_image = _PS_IMG_DIR_.$params['image'].'/'.Image::getImgFolderStatic($tr['id_image']).(int)$tr['id_image'].'.'.$this->imageType;
$this->_list[$index][$key] = ImageManager::thumbnail($path_to_image, $this->table.'_mini_'.$item_id.'_'.$this->context->shop->id.'.'.$this->imageType, 45, $this->imageType); $this->_list[$index][$key] = ImageManager::thumbnail($path_to_image, $this->table.'_mini_'.$item_id.'.'.$this->imageType, 45, $this->imageType);
} }
elseif (isset($params['icon']) && isset($tr[$key]) && (isset($params['icon'][$tr[$key]]) || isset($params['icon']['default']))) elseif (isset($params['icon']) && isset($tr[$key]) && (isset($params['icon'][$tr[$key]]) || isset($params['icon']['default'])))
{ {
@@ -307,7 +307,7 @@ class HelperListCore extends Helper
'table' => $this->table, 'table' => $this->table,
'token' => $this->token, 'token' => $this->token,
'color_on_bg' => $this->colorOnBackground, 'color_on_bg' => $this->colorOnBackground,
'id_category' => isset($id_category) ? $id_category : false, 'id_category' => $id_category,
'bulk_actions' => $this->bulk_actions, 'bulk_actions' => $this->bulk_actions,
'positions' => isset($positions) ? $positions : null, 'positions' => isset($positions) ? $positions : null,
'order_by' => $this->orderBy, 'order_by' => $this->orderBy,
@@ -456,7 +456,7 @@ class HelperListCore extends Helper
); );
if ($this->specificConfirmDelete !== false) if ($this->specificConfirmDelete !== false)
$data['confirm'] = !is_null($this->specificConfirmDelete) ? '\r'.$this->specificConfirmDelete : addcslashes(Tools::htmlentitiesDecodeUTF8(self::$cache_lang['DeleteItem'].$name), '\''); $data['confirm'] = !is_null($this->specificConfirmDelete) ? '\r'.$this->specificConfirmDelete : self::$cache_lang['DeleteItem'].$name;
$tpl->assign(array_merge($this->tpl_delete_link_vars, $data)); $tpl->assign(array_merge($this->tpl_delete_link_vars, $data));
@@ -486,21 +486,18 @@ class HelperListCore extends Helper
*/ */
public function displayListHeader() public function displayListHeader()
{ {
if (!isset($this->list_id))
$this->list_id = $this->table;
$id_cat = (int)Tools::getValue('id_'.($this->is_cms ? 'cms_' : '').'category'); $id_cat = (int)Tools::getValue('id_'.($this->is_cms ? 'cms_' : '').'category');
if (!isset($token) || empty($token)) if (!isset($token) || empty($token))
$token = $this->token; $token = $this->token;
/* Determine total page number */ /* Determine total page number */
if (isset($this->context->cookie->{$this->list_id.'_pagination'}) && $this->context->cookie->{$this->list_id.'_pagination'}) if (isset($this->context->cookie->{$this->table.'_pagination'}) && $this->context->cookie->{$this->table.'_pagination'})
$default_pagination = $this->context->cookie->{$this->list_id.'_pagination'}; $default_pagination = $this->context->cookie->{$this->table.'_pagination'};
else else
$default_pagination = $this->_pagination[0]; $default_pagination = $this->_pagination[0];
$total_pages = ceil($this->listTotal / Tools::getValue($this->list_id.'_pagination', ($default_pagination))); $total_pages = ceil($this->listTotal / Tools::getValue('pagination', ($default_pagination)));
if (!$total_pages) if (!$total_pages)
$total_pages = 1; $total_pages = 1;
@@ -513,13 +510,14 @@ class HelperListCore extends Helper
$action = $this->currentIndex.$identifier.'&token='.$token.$order.'#'.$this->table; $action = $this->currentIndex.$identifier.'&token='.$token.$order.'#'.$this->table;
/* Determine current page number */ /* Determine current page number */
$page = (int)Tools::getValue('submitFilter'.$this->list_id); $page = (int)Tools::getValue('submitFilter'.$this->table);
if (!$page) if (!$page)
$page = 1; $page = 1;
/* Choose number of results per page */ /* Choose number of results per page */
$selected_pagination = Tools::getValue($this->list_id.'_pagination', $selected_pagination = Tools::getValue(
isset($this->context->cookie->{$this->list_id.'_pagination'}) ? $this->context->cookie->{$this->list_id.'_pagination'} : null 'pagination',
isset($this->context->cookie->{$this->table.'_pagination'}) ? $this->context->cookie->{$this->table.'_pagination'} : null
); );
// Cleaning links // Cleaning links
@@ -537,7 +535,7 @@ class HelperListCore extends Helper
{ {
if (!isset($params['type'])) if (!isset($params['type']))
$params['type'] = 'text'; $params['type'] = 'text';
$value = Context::getContext()->cookie->{$prefix.$this->list_id.'Filter_'.(array_key_exists('filter_key', $params) && $key != 'active' ? $params['filter_key'] : $key)}; $value = Context::getContext()->cookie->{$prefix.$this->table.'Filter_'.(array_key_exists('filter_key', $params) ? $params['filter_key'] : $key)};
switch ($params['type']) switch ($params['type'])
{ {
case 'bool': case 'bool':
@@ -549,7 +547,7 @@ class HelperListCore extends Helper
$value = Tools::unSerialize($value); $value = Tools::unSerialize($value);
if (!Validate::isCleanHtml($value[0]) || !Validate::isCleanHtml($value[1])) if (!Validate::isCleanHtml($value[0]) || !Validate::isCleanHtml($value[1]))
$value = ''; $value = '';
$name = $this->list_id.'Filter_'.(isset($params['filter_key']) ? $params['filter_key'] : $key); $name = $this->table.'Filter_'.(isset($params['filter_key']) ? $params['filter_key'] : $key);
$name_id = str_replace('!', '__', $name); $name_id = str_replace('!', '__', $name);
$params['id_date'] = $name_id; $params['id_date'] = $name_id;
@@ -561,9 +559,9 @@ class HelperListCore extends Helper
case 'select': case 'select':
foreach ($params['list'] as $option_value => $option_display) foreach ($params['list'] as $option_value => $option_display)
{ {
if (isset(Context::getContext()->cookie->{$prefix.$this->list_id.'Filter_'.$params['filter_key']}) if (isset(Context::getContext()->cookie->{$prefix.$this->table.'Filter_'.$params['filter_key']})
&& Context::getContext()->cookie->{$prefix.$this->list_id.'Filter_'.$params['filter_key']} == $option_value && Context::getContext()->cookie->{$prefix.$this->table.'Filter_'.$params['filter_key']} == $option_value
&& Context::getContext()->cookie->{$prefix.$this->list_id.'Filter_'.$params['filter_key']} != '') && Context::getContext()->cookie->{$prefix.$this->table.'Filter_'.$params['filter_key']} != '')
$this->fields_list[$key]['select'][$option_value]['selected'] = 'selected'; $this->fields_list[$key]['select'][$option_value]['selected'] = 'selected';
} }
break; break;
@@ -607,7 +605,6 @@ class HelperListCore extends Helper
'name' => isset($name) ? $name : null, 'name' => isset($name) ? $name : null,
'name_id' => isset($name_id) ? $name_id : null, 'name_id' => isset($name_id) ? $name_id : null,
'row_hover' => $this->row_hover, 'row_hover' => $this->row_hover,
'list_id' => isset($this->list_id) ? $this->list_id : $this->table
))); )));
return $this->header_tpl->fetch(); return $this->header_tpl->fetch();
+50 -75
View File
@@ -153,22 +153,18 @@ abstract class ModuleCore
// If cache is not generated, we generate it // If cache is not generated, we generate it
if (self::$modules_cache == null && !is_array(self::$modules_cache)) if (self::$modules_cache == null && !is_array(self::$modules_cache))
{ {
$id_shop = (Validate::isLoadedObject($this->context->shop) ? $this->context->shop->id : 1);
self::$modules_cache = array();
// Join clause is done to check if the module is activated in current shop context // Join clause is done to check if the module is activated in current shop context
$result = Db::getInstance()->executeS(' $sql_limit_shop = 'SELECT COUNT(*) FROM `'._DB_PREFIX_.'module_shop` ms WHERE m.`id_module` = ms.`id_module` AND ms.`id_shop` = '.((is_object(Context::getContext()->shop) && $id = (int)Context::getContext()->shop->id) ? $id : 1);
SELECT m.`id_module`, m.`name`, (
SELECT id_module $sql = 'SELECT m.`id_module`, m.`name`, ('.$sql_limit_shop.') as total FROM `'._DB_PREFIX_.'module` m';
FROM `'._DB_PREFIX_.'module_shop` ms
WHERE m.`id_module` = ms.`id_module` // Result is cached
AND ms.`id_shop` = '.(int)$id_shop.' self::$modules_cache = array();
LIMIT 1 $result = Db::getInstance()->executeS($sql);
) as mshop
FROM `'._DB_PREFIX_.'module` m');
foreach ($result as $row) foreach ($result as $row)
{ {
self::$modules_cache[$row['name']] = $row; self::$modules_cache[$row['name']] = $row;
self::$modules_cache[$row['name']]['active'] = ($row['mshop'] > 0) ? 1 : 0; self::$modules_cache[$row['name']]['active'] = ($row['total'] > 0) ? 1 : 0;
} }
} }
@@ -292,17 +288,15 @@ abstract class ModuleCore
else else
{ {
if (!$upgrade_detail['number_upgraded']) if (!$upgrade_detail['number_upgraded'])
$this->_errors[] = $this->l('No upgrade has been applied'); $this->_errors[] = $this->l('None upgrades have been applied');
else else
{ {
$this->_errors[] = sprintf($this->l('Upgraded from: %S to %s'), $upgrade_detail['upgraded_from'], $upgrade_detail['upgraded_to']); $this->_errors[] = $this->l('Upgraded from: ').$upgrade_detail['upgraded_from'].$this->l(' to ').
$upgrade_detail['upgraded_to'];
$this->_errors[] = $upgrade_detail['number_upgrade_left'].' '.$this->l('upgrade left'); $this->_errors[] = $upgrade_detail['number_upgrade_left'].' '.$this->l('upgrade left');
} }
if ($upgrade_detail['duplicate']) $this->_errors[] = $this->l('To prevent any problem, this module has been turned off');
$this->_errors[] = sprintf(Tools::displayError('Module %s cannot be upgraded this time: please refresh this page to update it.'), $this->name);
else
$this->_errors[] = $this->l('To prevent any problem, this module has been turned off');
} }
} }
} }
@@ -350,21 +344,19 @@ abstract class ModuleCore
$upgrade = &self::$modules_cache[$this->name]['upgrade']; $upgrade = &self::$modules_cache[$this->name]['upgrade'];
foreach ($upgrade['upgrade_file_left'] as $num => $file_detail) foreach ($upgrade['upgrade_file_left'] as $num => $file_detail)
{ {
if (function_exists($file_detail['upgrade_function'])) // Default variable required in the included upgrade file need to be set by default there:
{ // upgrade_version, success_upgrade
$upgrade['success'] = false; $upgrade_result = false;
$upgrade['duplicate'] = true;
break;
}
include($file_detail['file']); include($file_detail['file']);
// Call the upgrade function if defined // Call the upgrade function if defined
$upgrade['success'] = false;
if (function_exists($file_detail['upgrade_function'])) if (function_exists($file_detail['upgrade_function']))
$upgrade['success'] = $file_detail['upgrade_function']($this); $upgrade_result = $file_detail['upgrade_function']($this);
$upgrade['success'] = $upgrade_result;
// Set detail when an upgrade succeed or failed // Set detail when an upgrade succeed or failed
if ($upgrade['success']) if ($upgrade_result)
{ {
$upgrade['number_upgraded'] += 1; $upgrade['number_upgraded'] += 1;
$upgrade['upgraded_to'] = $file_detail['version']; $upgrade['upgraded_to'] = $file_detail['version'];
@@ -382,7 +374,6 @@ abstract class ModuleCore
} }
$upgrade['number_upgrade_left'] = count($upgrade['upgrade_file_left']); $upgrade['number_upgrade_left'] = count($upgrade['upgrade_file_left']);
// Update module version in DB with the last succeed upgrade // Update module version in DB with the last succeed upgrade
if ($upgrade['upgraded_to']) if ($upgrade['upgraded_to'])
Module::upgradeModuleVersion($this->name, $upgrade['upgraded_to']); Module::upgradeModuleVersion($this->name, $upgrade['upgraded_to']);
@@ -401,9 +392,9 @@ abstract class ModuleCore
public static function upgradeModuleVersion($name, $version) public static function upgradeModuleVersion($name, $version)
{ {
return Db::getInstance()->execute(' return Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'module` m UPDATE `'._DB_PREFIX_.'module` m
SET m.version = \''.bqSQL($version).'\' SET m.version = \''.bqSQL($version).'\'
WHERE m.name = \''.bqSQL($name).'\''); WHERE m.name = \''.bqSQL($name).'\'');
} }
/** /**
@@ -674,14 +665,12 @@ abstract class ModuleCore
return false; return false;
// Retrocompatibility // Retrocompatibility
$hook_name_bak = $hook_name;
if ($alias = Hook::getRetroHookName($hook_name)) if ($alias = Hook::getRetroHookName($hook_name))
$hook_name = $alias; $hook_name = $alias;
Hook::exec('actionModuleRegisterHookBefore', array('object' => $this, 'hook_name' => $hook_name)); Hook::exec('actionModuleRegisterHookBefore', array('object' => $this, 'hook_name' => $hook_name));
// Get hook id // Get hook id
$id_hook = Hook::getIdByName($hook_name); $id_hook = Hook::getIdByName($hook_name);
$live_edit = Hook::getLiveEditById((int)Hook::getIdByName($hook_name_bak));
// If hook does not exist, we create it // If hook does not exist, we create it
if (!$id_hook) if (!$id_hook)
@@ -689,7 +678,6 @@ abstract class ModuleCore
$new_hook = new Hook(); $new_hook = new Hook();
$new_hook->name = pSQL($hook_name); $new_hook->name = pSQL($hook_name);
$new_hook->title = pSQL($hook_name); $new_hook->title = pSQL($hook_name);
$new_hook->live_edit = pSQL($live_edit);
$new_hook->add(); $new_hook->add();
$id_hook = $new_hook->id; $id_hook = $new_hook->id;
if (!$id_hook) if (!$id_hook)
@@ -1362,7 +1350,7 @@ abstract class ModuleCore
elseif (isset($context->customer)) elseif (isset($context->customer))
{ {
$groups = $context->customer->getGroups(); $groups = $context->customer->getGroups();
if (!count($groups)) if (empty($groups))
$groups = array(Configuration::get('PS_UNIDENTIFIED_GROUP')); $groups = array(Configuration::get('PS_UNIDENTIFIED_GROUP'));
} }
@@ -1385,7 +1373,7 @@ abstract class ModuleCore
'.(isset($billing) && $frontend ? 'AND mc.id_country = '.(int)$billing->id_country : '').' '.(isset($billing) && $frontend ? 'AND mc.id_country = '.(int)$billing->id_country : '').'
AND (SELECT COUNT(*) FROM '._DB_PREFIX_.'module_shop ms WHERE ms.id_module = m.id_module AND ms.id_shop IN('.implode(', ', $list).')) = '.count($list).' AND (SELECT COUNT(*) FROM '._DB_PREFIX_.'module_shop ms WHERE ms.id_module = m.id_module AND ms.id_shop IN('.implode(', ', $list).')) = '.count($list).'
AND hm.id_shop IN('.implode(', ', $list).') AND hm.id_shop IN('.implode(', ', $list).')
'.((count($groups) && $frontend) ? 'AND (mg.`id_group` IN ('.implode(', ', $groups).'))' : '').$paypal_condition.' '.(count($groups) && $frontend ? 'AND (mg.`id_group` IN('.implode(', ', $groups).'))' : '').$paypal_condition.'
GROUP BY hm.id_hook, hm.id_module GROUP BY hm.id_hook, hm.id_module
ORDER BY hm.`position`, m.`name` DESC'); ORDER BY hm.`position`, m.`name` DESC');
} }
@@ -1523,12 +1511,12 @@ abstract class ModuleCore
* @param int $id_hook Hook ID * @param int $id_hook Hook ID
* @return array Exceptions * @return array Exceptions
*/ */
public function getExceptions($id_hook, $dispatch = false) protected static $exceptionsCache = null;
public function getExceptions($hookID, $dispatch = false)
{ {
$cache_id = 'exceptionsCache'; if (self::$exceptionsCache === null)
if (!Cache::isStored($cache_id))
{ {
$exceptionsCache = array(); self::$exceptionsCache = array();
$sql = 'SELECT * FROM `'._DB_PREFIX_.'hook_module_exceptions` $sql = 'SELECT * FROM `'._DB_PREFIX_.'hook_module_exceptions`
WHERE `id_shop` IN ('.implode(', ', Shop::getContextListShopID()).')'; WHERE `id_shop` IN ('.implode(', ', Shop::getContextListShopID()).')';
$result = Db::getInstance()->executeS($sql); $result = Db::getInstance()->executeS($sql);
@@ -1537,34 +1525,33 @@ abstract class ModuleCore
if (!$row['file_name']) if (!$row['file_name'])
continue; continue;
$key = $row['id_hook'].'-'.$row['id_module']; $key = $row['id_hook'].'-'.$row['id_module'];
if (!isset($exceptionsCache[$key])) if (!isset(self::$exceptionsCache[$key]))
$exceptionsCache[$key] = array(); self::$exceptionsCache[$key] = array();
if (!isset($exceptionsCache[$key][$row['id_shop']])) if (!isset(self::$exceptionsCache[$key][$row['id_shop']]))
$exceptionsCache[$key][$row['id_shop']] = array(); self::$exceptionsCache[$key][$row['id_shop']] = array();
$exceptionsCache[$key][$row['id_shop']][] = $row['file_name']; self::$exceptionsCache[$key][$row['id_shop']][] = $row['file_name'];
} }
Cache::store($cache_id, $exceptionsCache);
} }
else
$exceptionsCache = Cache::retrieve($cache_id);
$key = $id_hook.'-'.$this->id; $key = $hookID.'-'.$this->id;
$array_return = array(); if (!$dispatch)
if ($dispatch)
{ {
$files = array();
foreach (Shop::getContextListShopID() as $shop_id) foreach (Shop::getContextListShopID() as $shop_id)
if (isset($exceptionsCache[$key], $exceptionsCache[$key][$shop_id])) if (isset(self::$exceptionsCache[$key], self::$exceptionsCache[$key][$shop_id]))
$array_return[$shop_id] = $exceptionsCache[$key][$shop_id]; foreach (self::$exceptionsCache[$key][$shop_id] as $file)
if (!in_array($file, $files))
$files[] = $file;
return $files;
} }
else else
{ {
$list = array();
foreach (Shop::getContextListShopID() as $shop_id) foreach (Shop::getContextListShopID() as $shop_id)
if (isset($exceptionsCache[$key], $exceptionsCache[$key][$shop_id])) if (isset(self::$exceptionsCache[$key], self::$exceptionsCache[$key][$shop_id]))
foreach ($exceptionsCache[$key][$shop_id] as $file) $list[$shop_id] = self::$exceptionsCache[$key][$shop_id];
if (!in_array($file, $array_return)) return $list;
$array_return[] = $file;
} }
return $array_return;
} }
public static function isInstalled($module_name) public static function isInstalled($module_name)
@@ -1608,11 +1595,7 @@ abstract class ModuleCore
protected static function _isTemplateOverloadedStatic($module_name, $template) protected static function _isTemplateOverloadedStatic($module_name, $template)
{ {
if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/'.$module_name.'/'.$template)) if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/'.$module_name.'/'.$template))
return _PS_THEME_DIR_.'modules/'.$module_name.'/'.$template; return true;
elseif (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/'.$module_name.'/views/templates/hook/'.$template))
return _PS_THEME_DIR_.'modules/'.$module_name.'/views/templates/hook/'.$template;
elseif (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/'.$module_name.'/views/templates/front/'.$template))
return _PS_THEME_DIR_.'modules/'.$module_name.'/views/templates/front/'.$template;
elseif (Tools::file_exists_cache(_PS_MODULE_DIR_.$module_name.'/views/templates/hook/'.$template)) elseif (Tools::file_exists_cache(_PS_MODULE_DIR_.$module_name.'/views/templates/hook/'.$template))
return false; return false;
elseif (Tools::file_exists_cache(_PS_MODULE_DIR_.$module_name.'/'.$template)) elseif (Tools::file_exists_cache(_PS_MODULE_DIR_.$module_name.'/'.$template))
@@ -1627,16 +1610,9 @@ abstract class ModuleCore
protected function getCacheId($name = null) protected function getCacheId($name = null)
{ {
$cache_array = array( if ($name === null)
$name !== null ? $name : $this->name, $name = $this->name;
(int)Tools::usingSecureMode(), return $name.'|'.(int)Tools::usingSecureMode().'|'.(int)$this->context->shop->id.'|'.(int)Group::getCurrent()->id.'|'.(int)$this->context->language->id;
(int)$this->context->shop->id,
(int)Group::getCurrent()->id,
(int)$this->context->language->id,
(int)$this->context->currency->id,
(int)$this->context->country->id
);
return implode('|', $cache_array);
} }
public function display($file, $template, $cacheId = null, $compileId = null) public function display($file, $template, $cacheId = null, $compileId = null)
@@ -1680,9 +1656,8 @@ abstract class ModuleCore
$overloaded = $this->_isTemplateOverloaded($template); $overloaded = $this->_isTemplateOverloaded($template);
if ($overloaded === null) if ($overloaded === null)
return null; return null;
if ($overloaded) if ($overloaded)
return $overloaded; return _PS_THEME_DIR_.'modules/'.$this->name.'/'.$template;
else if (file_exists(_PS_MODULE_DIR_.$this->name.'/views/templates/hook/'.$template)) else if (file_exists(_PS_MODULE_DIR_.$this->name.'/views/templates/hook/'.$template))
return _PS_MODULE_DIR_.$this->name.'/views/templates/hook/'.$template; return _PS_MODULE_DIR_.$this->name.'/views/templates/hook/'.$template;
else else

Some files were not shown because too many files have changed in this diff Show More