diff --git a/admin-dev/themes/template/layout-ajax.tpl b/admin-dev/themes/template/layout-ajax.tpl
index 5a3fc8dc2..cfe4d654c 100644
--- a/admin-dev/themes/template/layout-ajax.tpl
+++ b/admin-dev/themes/template/layout-ajax.tpl
@@ -25,7 +25,7 @@
*}
{if isset($conf)}
-

{$conf}
+ {$conf}
{/if}
diff --git a/admin-dev/themes/template/modules/list.tpl b/admin-dev/themes/template/modules/list.tpl
index 4cf2bf74b..5623e502b 100644
--- a/admin-dev/themes/template/modules/list.tpl
+++ b/admin-dev/themes/template/modules/list.tpl
@@ -212,7 +212,7 @@
{l s='Description'} : {$module->description}
- {if isset($module->message)}
{$module->message}
{/if}
+ {if isset($module->message)}{$module->message}
{/if}
{$module->optionsHtml}
diff --git a/classes/AdminTab.php b/classes/AdminTab.php
index 3a2bff7a8..23b273101 100644
--- a/classes/AdminTab.php
+++ b/classes/AdminTab.php
@@ -1247,7 +1247,7 @@ abstract class AdminTabCore
if ($conf = Tools::getValue('conf'))
echo '
-

'.$this->_conf[(int)($conf)].'
+ '.$this->_conf[(int)($conf)].'
';
}
diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php
index a0f01695b..29fa942a3 100644
--- a/modules/blocklayered/blocklayered.php
+++ b/modules/blocklayered/blocklayered.php
@@ -1,6 +1,6 @@
displayName = $this->l('Layered navigation block');
$this->description = $this->l('Displays a block with layered navigation filters.');
}
-
+
public function install()
{
if (parent::install() && $this->registerHook('leftColumn') && $this->registerHook('header') && $this->registerHook('footer')
@@ -60,7 +60,7 @@ class BlockLayered extends Module
{
Configuration::updateValue('PS_LAYERED_HIDE_0_VALUES', 0);
Configuration::updateValue('PS_LAYERED_SHOW_QTIES', 1);
-
+
$this->rebuildLayeredStructure();
$this->rebuildLayeredCache();
self::installPriceIndexTable();
@@ -70,10 +70,10 @@ class BlockLayered extends Module
$this->indexUrl();
$this->indexAttribute();
-
+
if (Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'product`') < 10000) // Lock price indexation if too many products
self::fullPricesIndexProcess();
-
+
return true;
}
else
@@ -90,7 +90,7 @@ class BlockLayered extends Module
Configuration::deleteByName('PS_LAYERED_HIDE_0_VALUES');
Configuration::deleteByName('PS_LAYERED_SHOW_QTIES');
Configuration::deleteByName('PS_LAYERED_INDEXED');
-
+
Db::getInstance()->execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_price_index');
Db::getInstance()->execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_friendly_url');
Db::getInstance()->execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_indexable_attribute_group');
@@ -102,11 +102,11 @@ class BlockLayered extends Module
Db::getInstance()->execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_product_attribute');
return parent::uninstall();
}
-
+
private static function installPriceIndexTable()
{
Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_price_index`');
-
+
Db::getInstance()->execute('
CREATE TABLE `'._DB_PREFIX_.'layered_price_index` (
`id_product` INT NOT NULL, `id_currency` INT NOT NULL,
@@ -114,7 +114,7 @@ class BlockLayered extends Module
PRIMARY KEY (`id_product`, `id_currency`), INDEX `id_currency` (`id_currency`),
INDEX `price_min` (`price_min`), INDEX `price_max` (`price_max`)) ENGINE = '._MYSQL_ENGINE_);
}
-
+
private function installFriendlyUrlTable()
{
Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_friendly_url`');
@@ -129,7 +129,7 @@ class BlockLayered extends Module
Db::getInstance()->execute('CREATE INDEX `url_key` ON `'._DB_PREFIX_.'layered_friendly_url`(url_key(5))');
}
-
+
private function installIndexableAttributeTable()
{
// Attributes Groups
@@ -142,7 +142,7 @@ class BlockLayered extends Module
Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'layered_indexable_attribute_group`
SELECT id_attribute_group, 1 FROM `'._DB_PREFIX_.'attribute_group`');
-
+
Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_attribute_group_lang_value`');
Db::getInstance()->execute('
CREATE TABLE `'._DB_PREFIX_.'layered_indexable_attribute_group_lang_value` (
@@ -151,7 +151,7 @@ class BlockLayered extends Module
`url_name` VARCHAR(20),
`meta_title` VARCHAR(20),
PRIMARY KEY (`id_attribute_group`, `id_lang`)) ENGINE = '._MYSQL_ENGINE_);
-
+
// Attributes
Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_attribute_lang_value`');
Db::getInstance()->execute('
@@ -161,8 +161,8 @@ class BlockLayered extends Module
`url_name` VARCHAR(20),
`meta_title` VARCHAR(20),
PRIMARY KEY (`id_attribute`, `id_lang`)) ENGINE = '._MYSQL_ENGINE_);
-
-
+
+
// Features
Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_feature`');
Db::getInstance()->execute('
@@ -170,11 +170,11 @@ class BlockLayered extends Module
`id_feature` INT NOT NULL,
`indexable` BOOL NOT NULL DEFAULT 0,
PRIMARY KEY (`id_feature`)) ENGINE = '._MYSQL_ENGINE_);
-
+
Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'layered_indexable_feature`
SELECT id_feature, 1 FROM `'._DB_PREFIX_.'feature`');
-
+
Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_feature_lang_value`');
Db::getInstance()->execute('
CREATE TABLE `'._DB_PREFIX_.'layered_indexable_feature_lang_value` (
@@ -183,7 +183,7 @@ class BlockLayered extends Module
`url_name` VARCHAR(20) NOT NULL,
`meta_title` VARCHAR(20),
PRIMARY KEY (`id_feature`, `id_lang`)) ENGINE = '._MYSQL_ENGINE_);
-
+
// Features values
Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_feature_value_lang_value`');
Db::getInstance()->execute('
@@ -194,9 +194,9 @@ class BlockLayered extends Module
`meta_title` VARCHAR(20),
PRIMARY KEY (`id_feature_value`, `id_lang`)) ENGINE = '._MYSQL_ENGINE_);
}
-
+
/**
- *
+ *
* create table product attribute
*/
public function installProductAttributeTable()
@@ -210,9 +210,9 @@ class BlockLayered extends Module
KEY `id_attribute` (`id_attribute`)
) ENGINE= '._MYSQL_ENGINE_);
}
-
+
/**
- *
+ *
* Generate data product attribute
*/
public function indexAttribute($id_product = null)
@@ -221,16 +221,16 @@ class BlockLayered extends Module
Db::getInstance()->execute('TRUNCATE '._DB_PREFIX_.'layered_product_attribute');
else
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_product_attribute WHERE id_product = '.(int)$id_product);
-
- Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'layered_product_attribute` (`id_attribute`, `id_product`, `id_attribute_group`)
- SELECT pac.id_attribute, pa.id_product, ag.id_attribute_group
- FROM '._DB_PREFIX_.'product_attribute pa
- INNER JOIN '._DB_PREFIX_.'product_attribute_combination pac ON pac.id_product_attribute = pa.id_product_attribute
- INNER JOIN '._DB_PREFIX_.'attribute a ON (a.id_attribute = pac.id_attribute)
+
+ Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'layered_product_attribute` (`id_attribute`, `id_product`, `id_attribute_group`)
+ SELECT pac.id_attribute, pa.id_product, ag.id_attribute_group
+ FROM '._DB_PREFIX_.'product_attribute pa
+ INNER JOIN '._DB_PREFIX_.'product_attribute_combination pac ON pac.id_product_attribute = pa.id_product_attribute
+ INNER JOIN '._DB_PREFIX_.'attribute a ON (a.id_attribute = pac.id_attribute)
INNER JOIN '._DB_PREFIX_.'attribute_group ag ON ag.id_attribute_group = a.id_attribute_group
'.(is_null($id_product) ? '' : 'AND pa.id_product = '.(int)$id_product).'
GROUP BY a.id_attribute, pa.id_product');
-
+
return 1;
}
/*
@@ -240,7 +240,7 @@ class BlockLayered extends Module
{
if ($truncate)
Db::getInstance()->execute('TRUNCATE '._DB_PREFIX_.'layered_friendly_url');
-
+
$attributeValuesByLang = array();
$filters = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT lc.*, id_lang, name, link_rewrite, cl.id_category
FROM '._DB_PREFIX_.'layered_category lc
@@ -248,7 +248,7 @@ class BlockLayered extends Module
GROUP BY type, id_value, id_lang');
if (!$filters)
return;
-
+
foreach ($filters as $filter)
switch ($filter['type'])
{
@@ -282,7 +282,7 @@ class BlockLayered extends Module
'type' => $filter['type']);
}
break;
-
+
case 'id_feature':
$features = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT fl.name name, fl.id_feature id_name, fvl.id_feature_value id_value, fvl.value value, fl.id_lang, fl.id_lang,
@@ -312,7 +312,7 @@ class BlockLayered extends Module
'type' => $filter['type']);
}
break;
-
+
case 'category':
$categories = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT cl.name, cl.id_lang, c.id_category
@@ -330,13 +330,13 @@ class BlockLayered extends Module
'category_name' => $filter['link_rewrite'], 'type' => $filter['type']);
}
break;
-
+
case 'manufacturer':
$manufacturers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT m.name as name,l.id_lang as id_lang, id_manufacturer
FROM '._DB_PREFIX_.'manufacturer m , '._DB_PREFIX_.'lang l
WHERE l.id_lang = '.(int)$filter['id_lang'].' ');
-
+
foreach ($manufacturers as $manufacturer)
{
if (!isset($attributeValuesByLang[$manufacturer['id_lang']]))
@@ -348,7 +348,7 @@ class BlockLayered extends Module
'category_name' => $filter['link_rewrite'], 'type' => $filter['type']);
}
break;
-
+
case 'quantity':
$avaibility_list = array(
$this->translateWord('Not available', (int)$filter['id_lang']),
@@ -359,7 +359,7 @@ class BlockLayered extends Module
'id_name' => null, 'value' => $quantity, 'id_value' => $key, 'id_id_value' => 0,
'category_name' => $filter['link_rewrite'], 'type' => $filter['type']);
break;
-
+
case 'condition':
$condition_list = array(
'new' => $this->translateWord('New', (int)$filter['id_lang']),
@@ -372,7 +372,7 @@ class BlockLayered extends Module
'category_name' => $filter['link_rewrite'], 'type' => $filter['type']);
break;
}
-
+
// Foreach langs
foreach ($attributeValuesByLang as $id_lang => $attributeValues)
{
@@ -401,8 +401,8 @@ class BlockLayered extends Module
else
return 1;
}
-
- public function translateWord($string, $id_lang )
+
+ public function translateWord($string, $id_lang )
{
static $_MODULES = array();
global $_MODULE;
@@ -423,7 +423,7 @@ class BlockLayered extends Module
$_MODULES[$id_lang] = array_change_key_case($_MODULES[$id_lang]);
$currentKey = '<{'.strtolower( $this->name).'}'.strtolower(_THEME_NAME_).'>'.strtolower($this->name).'_'.md5($string);
$defaultKey = '<{'.strtolower( $this->name).'}prestashop>'.strtolower($this->name).'_'.md5($string);
-
+
if (isset($_MODULES[$id_lang][$currentKey]))
$ret = stripslashes($_MODULES[$id_lang][$currentKey]);
else if (isset($_MODULES[$id_lang][Tools::strtolower($currentKey)]))
@@ -437,7 +437,7 @@ class BlockLayered extends Module
return str_replace('"', '"', $ret);
}
-
+
public function hookProductListAssign($params)
{
global $smarty;
@@ -453,18 +453,18 @@ class BlockLayered extends Module
if (is_array($filterBlock['title_values']))
foreach ($filterBlock['title_values'] as $key => $val)
$title .= ' – '.$key.' '.implode('/', $val);
-
+
$smarty->assign('categoryNameComplement', $title);
$this->getProducts($selectedFilters, $params['catProducts'], $params['nbProducts'], $p, $n, $pages_nb, $start, $stop, $range);
// Need a nofollow on the pagination links?
$smarty->assign('no_follow', $filterBlock['nofollow']);
}
-
+
public function hookAfterSaveProduct($params)
{
if (!$params['id_product'])
return;
-
+
self::indexProductPrices((int)$params['id_product']);
$this->indexAttribute((int)$params['id_product']);
}
@@ -473,10 +473,10 @@ class BlockLayered extends Module
{
if (!$params['id_feature'] || Tools::getValue('layered_indexable') === false)
return;
-
+
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_feature WHERE id_feature = '.(int)$params['id_feature']);
Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_feature VALUES ('.(int)$params['id_feature'].', '.(int)Tools::getValue('layered_indexable').')');
-
+
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_feature_lang_value WHERE id_feature = '.(int)$params['id_feature']); // don't care about the id_lang
foreach (Language::getLanguages(false) as $language)
{
@@ -492,7 +492,7 @@ class BlockLayered extends Module
{
if (!$params['id_feature_value'])
return;
-
+
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_feature_value_lang_value WHERE id_feature_value = '.(int)$params['id_feature_value']); // don't care about the id_lang
foreach (Language::getLanguages(false) as $language)
{
@@ -503,25 +503,25 @@ class BlockLayered extends Module
\''.pSQL(Tools::safeOutput(Tools::getValue('meta_title_'.$id_lang), true)).'\')');
}
}
-
+
public function hookAfterDeleteFeatureValue($params)
{
if (!$params['id_feature_value'])
return;
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_feature_value_lang_value WHERE id_feature_value = '.(int)$params['id_feature_value']);
}
-
+
public function hookPostProcessFeatureValue($params)
{
$this->hookPostProcessAttributeGroup($params);
}
-
+
public function hookFeatureValueForm($params)
{
$languages = Language::getLanguages(false);
$default_form_language = (int)(Configuration::get('PS_LANG_DEFAULT'));
$langValue = array();
-
+
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
'SELECT url_name, meta_title, id_lang FROM '._DB_PREFIX_.'layered_indexable_feature_value_lang_value
WHERE id_feature_value = '.(int)$params['id_feature_value']);
@@ -559,12 +559,12 @@ class BlockLayered extends Module
';
return $return;
}
-
+
public function hookAfterSaveAttribute($params)
{
if (!$params['id_attribute'])
return;
-
+
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_lang_value WHERE id_attribute = '.(int)$params['id_attribute']); // don't care about the id_lang
foreach (Language::getLanguages(false) as $language)
{
@@ -575,25 +575,25 @@ class BlockLayered extends Module
\''.pSQL(Tools::safeOutput(Tools::getValue('meta_title_'.$id_lang), true)).'\')');
}
}
-
+
public function hookAfterDeleteAttribute($params)
{
if (!$params['id_attribute'])
return;
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_lang_value WHERE id_attribute = '.(int)$params['id_attribute']);
}
-
+
public function hookPostProcessAttribute($params)
{
$this->hookPostProcessAttributeGroup($params);
}
-
+
public function hookAttributeForm($params)
{
$languages = Language::getLanguages(false);
$default_form_language = (int)(Configuration::get('PS_LANG_DEFAULT'));
$langValue = array();
-
+
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
'SELECT url_name, meta_title, id_lang FROM '._DB_PREFIX_.'layered_indexable_attribute_lang_value
WHERE id_attribute = '.(int)$params['id_attribute']);
@@ -631,7 +631,7 @@ class BlockLayered extends Module
';
return $return;
}
-
+
public function hookPostProcessFeature($params)
{
$this->hookPostProcessAttributeGroup($params);
@@ -643,12 +643,12 @@ class BlockLayered extends Module
return;
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_feature WHERE id_feature = '.(int)$params['id_feature']);
}
-
+
public function hookAfterSaveAttributeGroup($params)
{
if (!$params['id_attribute_group'] || Tools::getValue('layered_indexable') === false)
return;
-
+
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_group WHERE id_attribute_group = '.(int)$params['id_attribute_group']);
Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_attribute_group VALUES ('.(int)$params['id_attribute_group'].', '.(int)Tools::getValue('layered_indexable').')');
@@ -662,7 +662,7 @@ class BlockLayered extends Module
\''.pSQL(Tools::safeOutput(Tools::getValue('meta_title_'.$id_lang), true)).'\')');
}
}
-
+
public function hookPostProcessAttributeGroup($params)
{
// Limit to one call
@@ -670,7 +670,7 @@ class BlockLayered extends Module
if ($once)
return;
$once = true;
-
+
$errors = array();
foreach (Language::getLanguages(false) as $language)
{
@@ -683,7 +683,7 @@ class BlockLayered extends Module
}
}
}
-
+
public function hookAfterDeleteAttributeGroup($params)
{
if (!$params['id_attribute_group'])
@@ -692,7 +692,7 @@ class BlockLayered extends Module
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_group WHERE id_attribute_group = '.(int)$params['id_attribute_group']);
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_group_lang_value WHERE id_attribute_group = '.(int)$params['id_attribute_group']);
}
-
+
public function hookAttributeGroupForm($params)
{
$languages = Language::getLanguages(false);
@@ -700,7 +700,7 @@ class BlockLayered extends Module
$indexable = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT indexable FROM '._DB_PREFIX_.'layered_indexable_attribute_group
WHERE id_attribute_group = '.(int)$params['id_attribute_group']);
$langValue = array();
-
+
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
'SELECT url_name, meta_title, id_lang FROM '._DB_PREFIX_.'layered_indexable_attribute_group_lang_value
WHERE id_attribute_group = '.(int)$params['id_attribute_group']);
@@ -752,27 +752,27 @@ class BlockLayered extends Module
';
return $return;
}
-
+
public function hookFeatureForm($params)
{
$languages = Language::getLanguages(false);
$default_form_language = (int)(Configuration::get('PS_LANG_DEFAULT'));
$indexable = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT indexable FROM '._DB_PREFIX_.'layered_indexable_feature WHERE id_feature = '.(int)$params['id_feature']);
$langValue = array();
-
+
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
'SELECT url_name, meta_title, id_lang FROM '._DB_PREFIX_.'layered_indexable_feature_lang_value
WHERE id_feature = '.(int)$params['id_feature']);
if ($result)
foreach ($result as $data)
$langValue[$data['id_lang']] = array('url_name' => $data['url_name'], 'meta_title' => $data['meta_title']);
-
-
+
+
if ($indexable === false)
$on = true;
else
$on = (bool)$indexable;
-
+
$return = '
@@ -812,7 +812,7 @@ class BlockLayered extends Module
';
return $return;
}
-
+
/*
* $cursor $cursor in order to restart indexing from the last state
*/
@@ -820,10 +820,10 @@ class BlockLayered extends Module
{
if ($cursor == 0 && !$smart)
self::installPriceIndexTable();
-
+
return self::indexPrices($cursor, true, $ajax, $smart);
}
-
+
/*
* $cursor $cursor in order to restart indexing from the last state
*/
@@ -831,7 +831,7 @@ class BlockLayered extends Module
{
return self::indexPrices($cursor, false, $ajax);
}
-
+
private static function indexPrices($cursor = null, $full = false, $ajax = false, $smart = false)
{
if ($full)
@@ -841,20 +841,20 @@ class BlockLayered extends Module
'SELECT COUNT(*) FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'layered_price_index` psi ON (psi.id_product = p.id_product)
WHERE `active` = 1 AND psi.id_product IS NULL');
-
+
$maxExecutionTime = @ini_get('max_execution_time');
if ($maxExecutionTime > 5 || $maxExecutionTime <= 0)
$maxExecutionTime = 5;
-
+
$startTime = microtime(true);
-
+
do
{
$cursor = (int)self::indexPricesUnbreakable((int)$cursor, $full, $smart);
$timeElapsed = microtime(true) - $startTime;
}
while ($cursor < $nbProducts && (Tools::getMemoryLimit()) > memory_get_peak_usage() && $timeElapsed < $maxExecutionTime);
-
+
if (($nbProducts > 0 && !$full || $cursor < $nbProducts && $full) && !$ajax)
{
$token = substr(Tools::encrypt('blocklayered/index'), 0, 10);
@@ -876,17 +876,17 @@ class BlockLayered extends Module
return -1;
}
}
-
+
/*
* $cursor $cursor in order to restart indexing from the last state
*/
private static function indexPricesUnbreakable($cursor, $full = false, $smart = false)
{
static $length = 100; // Nb of products to index
-
+
if (is_null($cursor))
$cursor = 0;
-
+
if ($full)
$query = '
SELECT id_product
@@ -900,13 +900,13 @@ class BlockLayered extends Module
LEFT JOIN `'._DB_PREFIX_.'layered_price_index` psi ON (psi.id_product = p.id_product)
WHERE `active` = 1 AND psi.id_product is null
ORDER by id_product LIMIT 0,'.(int)$length;
-
+
foreach (Db::getInstance()->executeS($query) as $product)
self::indexProductPrices((int)$product['id_product'], ($smart && $full));
return (int)($cursor + $length);
}
-
+
public static function indexProductPrices($idProduct, $smart = true)
{
static $groups = null;
@@ -917,17 +917,17 @@ class BlockLayered extends Module
if (!$groups)
$groups = array();
}
-
+
static $currencyList = null;
if (is_null($currencyList))
$currencyList = Currency::getCurrencies();
-
+
$minPrice = array();
$maxPrice = array();
-
+
if ($smart)
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'layered_price_index` WHERE `id_product` = '.(int)$idProduct);
-
+
$maxTaxRate = Db::getInstance()->getValue('
SELECT max(t.rate) max_rate
FROM `'._DB_PREFIX_.'product` p
@@ -936,19 +936,19 @@ class BlockLayered extends Module
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.id_tax = tr.id_tax AND t.active = 1)
WHERE id_product = '.(int)$idProduct.'
GROUP BY id_product');
-
+
$productMinPrices = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT id_shop, id_currency, id_country, id_group, from_quantity
FROM `'._DB_PREFIX_.'specific_price`
WHERE id_product = '.(int)$idProduct);
-
+
// Get min price
foreach ($currencyList as $currency)
{
$price = Product::priceCalculation(null, (int)$idProduct, null, null, null, null,
$currency['id_currency'], null, null, false, true, false, true, true,
$specificPriceOutput, true);
-
+
if (!isset($maxPrice[$currency['id_currency']]))
$maxPrice[$currency['id_currency']] = 0;
if (!isset($minPrice[$currency['id_currency']]))
@@ -960,7 +960,7 @@ class BlockLayered extends Module
if (is_null($minPrice[$currency['id_currency']]) || $price < $minPrice[$currency['id_currency']])
$minPrice[$currency['id_currency']] = $price;
}
-
+
foreach ($productMinPrices as $specificPrice)
foreach ($currencyList as $currency)
{
@@ -970,7 +970,7 @@ class BlockLayered extends Module
null, (($specificPrice['id_country'] == 0) ? null : $specificPrice['id_country']), null, null,
$currency['id_currency'], (($specificPrice['id_group'] == 0) ? null : $specificPrice['id_group']),
$specificPrice['from_quantity'], false, true, false, true, true, $specificPriceOutput, true);
-
+
if (!isset($maxPrice[$currency['id_currency']]))
$maxPrice[$currency['id_currency']] = 0;
if (!isset($minPrice[$currency['id_currency']]))
@@ -982,13 +982,13 @@ class BlockLayered extends Module
if (is_null($minPrice[$currency['id_currency']]) || $price < $minPrice[$currency['id_currency']])
$minPrice[$currency['id_currency']] = $price;
}
-
+
foreach ($groups as $group)
foreach ($currencyList as $currency)
{
$price = Product::priceCalculation(null, (int)$idProduct, null, null, null, null, (int)$currency['id_currency'], (int)$group['id_group'],
null, false, true, false, true, true, $specificPriceOutput, true);
-
+
if (!isset($maxPrice[$currency['id_currency']]))
$maxPrice[$currency['id_currency']] = 0;
if (!isset($minPrice[$currency['id_currency']]))
@@ -1000,12 +1000,12 @@ class BlockLayered extends Module
if (is_null($minPrice[$currency['id_currency']]) || $price < $minPrice[$currency['id_currency']])
$minPrice[$currency['id_currency']] = $price;
}
-
+
$values = array();
foreach ($currencyList as $currency)
$values[] = '('.(int)$idProduct.', '.(int)$currency['id_currency'].',
'.(int)$minPrice[$currency['id_currency']].', '.(int)($maxPrice[$currency['id_currency']] * (100 + $maxTaxRate) / 100).')';
-
+
Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'layered_price_index` (id_product, id_currency, price_min, price_max)
VALUES '.implode(',', $values).'
@@ -1025,12 +1025,12 @@ class BlockLayered extends Module
public function hookHeader($params)
{
global $smarty, $cookie;
-
+
// No filters => module disable
if ($filterBlock = $this->getFilterBlock($this->getSelectedFilters()))
if ($filterBlock['nbr_filterBlocks'] == 0)
return false;
-
+
if (Tools::getValue('id_category', Tools::getValue('id_category_layered', 1)) == 1)
return;
@@ -1045,7 +1045,7 @@ class BlockLayered extends Module
foreach ($filterBlock['title_values'] as $key => $val)
$title .= $key.' '.implode('/', $val).' – ';
$title = rtrim($title, ' – ');
-
+
if (!empty($title))
{
$smarty->assign('meta_title', ucfirst(strtolower(preg_replace('/^'.$categoryTitle.'/', $categoryTitle.' – '.$title, $categoryMetas['meta_title']))));
@@ -1053,17 +1053,17 @@ class BlockLayered extends Module
}
else
$smarty->assign('meta_title', ucfirst(strtolower($categoryMetas['meta_title'])));
-
+
$metaKeyWordsComplement = substr(str_replace(' – ', ', ', strtolower($title)), 1000);
if (!empty($metaKeyWordsComplement))
$smarty->assign('meta_keywords', rtrim($categoryTitle.', '.$metaKeyWordsComplement.', '.$categoryMetas['meta_keywords'], ', '));
-
+
$this->context->controller->addJs($this->_path.'blocklayered.js');
$this->context->controller->addJqueryUI('ui.slider');
$this->context->controller->addCSS($this->_path.'blocklayered.css', 'all');
Tools::addJS(_PS_JS_DIR_.'jquery/jquery.scrollTo-1.4.2-min.js');
}
-
+
public function hookFooter($params)
{
if (basename($_SERVER['PHP_SELF']) == 'category.php')
@@ -1118,7 +1118,7 @@ class BlockLayered extends Module
{
if (isset($_POST['id_layered_filter']) && $_POST['id_layered_filter'])
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_filter WHERE id_layered_filter = '.(int)Tools::getValue('id_layered_filter'));
-
+
if (Tools::getValue('scope') == 1)
{
Db::getInstance()->execute('TRUNCATE TABLE '._DB_PREFIX_.'layered_filter');
@@ -1126,20 +1126,20 @@ class BlockLayered extends Module
foreach ($categories as $category)
$_POST['categoryBox'][] = (int)$category['id_category'];
}
-
+
if (count($_POST['categoryBox']))
{
/* Clean categoryBox before use */
if (isset($_POST['categoryBox']) && is_array($_POST['categoryBox']))
foreach ($_POST['categoryBox'] as &$categoryBoxTmp)
$categoryBoxTmp = (int)$categoryBoxTmp;
-
+
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_category WHERE id_category IN ('.implode(',', array_map('intval', $_POST['categoryBox'])).')');
-
+
$filterValues = array();
foreach ($_POST['categoryBox'] as $idc)
$filterValues['categories'][] = (int)$idc;
-
+
$sqlToInsert = 'INSERT INTO '._DB_PREFIX_.'layered_category (id_category, id_value, type, position) VALUES ';
foreach ($_POST['categoryBox'] as $id_category_layered)
{
@@ -1167,9 +1167,9 @@ class BlockLayered extends Module
$sqlToInsert .= '('.(int)$id_category_layered.','.(int)str_replace('layered_selection_feat_', '', $key).',\'id_feature\','.(int)$n.'),';
}
}
-
+
Db::getInstance()->execute(rtrim($sqlToInsert, ','));
-
+
$valuesToInsert = array(
'name' => pSQL(Tools::getValue('layered_tpl_name')),
'filters' => pSQL(serialize($filterValues)),
@@ -1177,10 +1177,10 @@ class BlockLayered extends Module
'date_add' => date('Y-m-d H:i:s'));
if (isset($_POST['id_layered_filter']) && $_POST['id_layered_filter'])
$valuesToInsert['id_layered_filter'] = (int)Tools::getValue('id_layered_filter');
-
+
Db::getInstance()->AutoExecute(_DB_PREFIX_.'layered_filter', $valuesToInsert, 'INSERT');
- echo '
+ echo '
'.$this->l('Your filter').' "'.Tools::safeOutput(Tools::getValue('layered_tpl_name')).'" '.
((isset($_POST['id_layered_filter']) && $_POST['id_layered_filter']) ? $this->l('was updated successfully.') : $this->l('was added successfully.')).'
';
}
@@ -1190,26 +1190,26 @@ class BlockLayered extends Module
{
Configuration::updateValue('PS_LAYERED_HIDE_0_VALUES', Tools::getValue('ps_layered_hide_0_values'));
Configuration::updateValue('PS_LAYERED_SHOW_QTIES', Tools::getValue('ps_layered_show_qties'));
-
+
$html .= '
-

'.$this->l('Settings saved successfully').'
+ '.$this->l('Settings saved successfully').'
';
}
else if (isset($_GET['deleteFilterTemplate']))
{
$layeredValues = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
- SELECT filters
- FROM '._DB_PREFIX_.'layered_filter
+ SELECT filters
+ FROM '._DB_PREFIX_.'layered_filter
WHERE id_layered_filter = '.(int)$_GET['id_layered_filter']);
-
+
if ($layeredValues)
{
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_filter WHERE id_layered_filter = '.(int)$_GET['id_layered_filter'].' LIMIT 1');
-
+
$html .= '
-

'.$this->l('Filters template deleted, categories updated (reverted to default Filters template).').'
+ '.$this->l('Filters template deleted, categories updated (reverted to default Filters template).').'
';
}
else
@@ -1220,10 +1220,10 @@ class BlockLayered extends Module
';
}
}
-
+
$html .= '
-

+

@@ -1241,12 +1241,12 @@ class BlockLayered extends Module
$(\'#full-index\').click();
});
';
-
+
$categoryList = array();
foreach (Db::getInstance()->executeS('SELECT id_category FROM `'._DB_PREFIX_.'category`') as $category)
if ($category['id_category'] != 1)
$categoryList[] = $category['id_category'];
-
+
$base_url = Tools::getCurrentUrlProtocolPrefix().Tools::getHttpHost().__PS_BASE_URI__;
$html .= '
l('(in progress)')).'\');
$(\'#indexing-warning\').show();
}
-
+
this.restartAllowed = false;
-
+
$.ajax({
url: this.href+\'&ajax=1\',
context: this,
@@ -1325,7 +1325,7 @@ class BlockLayered extends Module
$(\'#ajax-message-ko span\').html(\''.addslashes($this->l('Url indexation failed')).'\');
$(\'#ajax-message-ko\').show();
$(this).html(this.legend);
-
+
this.running = false;
}
});
@@ -1335,28 +1335,28 @@ class BlockLayered extends Module
$(elm).click(function() {
if (this.cursor == undefined)
this.cursor = 0;
-
+
if (this.legend == undefined)
this.legend = $(this).html();
-
+
if (this.running == undefined)
this.running = false;
-
+
if (this.running == true)
return false;
-
+
$(\'.ajax-message\').hide();
-
+
this.running = true;
-
+
if (typeof(this.restartAllowed) == \'undefined\' || this.restartAllowed)
{
$(this).html(this.legend+\' '.addslashes($this->l('(in progress)')).'\');
$(\'#indexing-warning\').show();
}
-
+
this.restartAllowed = false;
-
+
$.ajax({
url: this.href+\'&ajax=1&cursor=\'+this.cursor,
context: this,
@@ -1385,7 +1385,7 @@ class BlockLayered extends Module
$(\'#ajax-message-ko span\').html(\''.addslashes($this->l('Price indexation failed')).'\');
$(\'#ajax-message-ko\').show();
$(this).html(this.legend);
-
+
this.cursor = 0;
this.running = false;
}
@@ -1398,7 +1398,7 @@ class BlockLayered extends Module