// Normalize
This commit is contained in:
+50
-51
@@ -27,46 +27,46 @@
|
||||
|
||||
class CMSCategoryCore extends ObjectModel
|
||||
{
|
||||
public $id;
|
||||
public $id;
|
||||
|
||||
/** @var integer CMSCategory ID */
|
||||
public $id_cms_category;
|
||||
public $id_cms_category;
|
||||
|
||||
/** @var string Name */
|
||||
public $name;
|
||||
public $name;
|
||||
|
||||
/** @var boolean Status for display */
|
||||
public $active = 1;
|
||||
public $active = 1;
|
||||
|
||||
/** @var string Description */
|
||||
public $description;
|
||||
public $description;
|
||||
|
||||
/** @var integer Parent CMSCategory ID */
|
||||
public $id_parent;
|
||||
public $id_parent;
|
||||
|
||||
/** @var integer category position */
|
||||
public $position;
|
||||
public $position;
|
||||
|
||||
/** @var integer Parents number */
|
||||
public $level_depth;
|
||||
public $level_depth;
|
||||
|
||||
/** @var string string used in rewrited URL */
|
||||
public $link_rewrite;
|
||||
public $link_rewrite;
|
||||
|
||||
/** @var string Meta title */
|
||||
public $meta_title;
|
||||
public $meta_title;
|
||||
|
||||
/** @var string Meta keywords */
|
||||
public $meta_keywords;
|
||||
public $meta_keywords;
|
||||
|
||||
/** @var string Meta description */
|
||||
public $meta_description;
|
||||
public $meta_description;
|
||||
|
||||
/** @var string Object creation date */
|
||||
public $date_add;
|
||||
public $date_add;
|
||||
|
||||
/** @var string Object last modification date */
|
||||
public $date_upd;
|
||||
public $date_upd;
|
||||
|
||||
protected static $_links = array();
|
||||
|
||||
@@ -95,7 +95,7 @@ class CMSCategoryCore extends ObjectModel
|
||||
),
|
||||
);
|
||||
|
||||
public function __construct($id_cms_category = NULL, $id_lang = NULL)
|
||||
public function __construct($id_cms_category = null, $id_lang = null)
|
||||
{
|
||||
parent::__construct($id_cms_category, $id_lang);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ class CMSCategoryCore extends ObjectModel
|
||||
{
|
||||
$this->position = CMSCategory::getLastPosition((int)$this->id_parent);
|
||||
$this->level_depth = $this->calcLevelDepth();
|
||||
foreach ($this->name AS $k => $value)
|
||||
foreach ($this->name as $k => $value)
|
||||
if (preg_match('/^[1-9]\./', $value))
|
||||
$this->name[$k] = '0'.$value;
|
||||
$ret = parent::add($autodate);
|
||||
@@ -115,7 +115,7 @@ class CMSCategoryCore extends ObjectModel
|
||||
public function update($nullValues = false)
|
||||
{
|
||||
$this->level_depth = $this->calcLevelDepth();
|
||||
foreach ($this->name AS $k => $value)
|
||||
foreach ($this->name as $k => $value)
|
||||
if (preg_match('/^[1-9]\./', $value))
|
||||
$this->name[$k] = '0'.$value;
|
||||
return parent::update();
|
||||
@@ -131,7 +131,7 @@ class CMSCategoryCore extends ObjectModel
|
||||
*
|
||||
* @return array Subcategories lite tree
|
||||
*/
|
||||
function recurseLiteCategTree($maxDepth = 3, $currentDepth = 0, $id_lang = NULL, $excludedIdsArray = NULL, Link $link = null)
|
||||
public function recurseLiteCategTree($maxDepth = 3, $currentDepth = 0, $id_lang = null, $excludedIdsArray = null, Link $link = null)
|
||||
{
|
||||
if (!$link)
|
||||
$link = Context::getContext()->link;
|
||||
@@ -139,16 +139,17 @@ class CMSCategoryCore extends ObjectModel
|
||||
if (is_null($id_lang))
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
|
||||
//recursivity for subcategories
|
||||
// recursivity for subcategories
|
||||
$children = array();
|
||||
if (($maxDepth == 0 OR $currentDepth < $maxDepth) AND $subcats = $this->getSubCategories($id_lang, true) AND sizeof($subcats))
|
||||
$subcats = $this->getSubCategories($id_lang, true);
|
||||
if (($maxDepth == 0 || $currentDepth < $maxDepth) && $subcats && count($subcats))
|
||||
foreach ($subcats as &$subcat)
|
||||
{
|
||||
if (!$subcat['id_cms_category'])
|
||||
break;
|
||||
elseif ( !is_array($excludedIdsArray) || !in_array($subcat['id_cms_category'], $excludedIdsArray) )
|
||||
elseif (!is_array($excludedIdsArray) || !in_array($subcat['id_cms_category'], $excludedIdsArray))
|
||||
{
|
||||
$categ = new CMSCategory($subcat['id_cms_category'] ,$id_lang);
|
||||
$categ = new CMSCategory($subcat['id_cms_category'], $id_lang);
|
||||
$categ->name = CMSCategory::hideCMSCategoryPosition($categ->name);
|
||||
$children[] = $categ->recurseLiteCategTree($maxDepth, $currentDepth + 1, $id_lang, $excludedIdsArray);
|
||||
}
|
||||
@@ -163,7 +164,7 @@ class CMSCategoryCore extends ObjectModel
|
||||
);
|
||||
}
|
||||
|
||||
static public function getRecurseCategory($id_lang = null, $current = 1, $active = 1, $links = 0, Link $link = null, Shop $shop = null)
|
||||
public static function getRecurseCategory($id_lang = null, $current = 1, $active = 1, $links = 0, Link $link = null, Shop $shop = null)
|
||||
{
|
||||
if (!$link)
|
||||
$link = Context::getContext()->link;
|
||||
@@ -199,7 +200,7 @@ class CMSCategoryCore extends ObjectModel
|
||||
if ($links == 1)
|
||||
{
|
||||
$category['link'] = $link->getCMSCategoryLink($current, $category['link_rewrite']);
|
||||
foreach($category['cms'] as $key => $cms)
|
||||
foreach ($category['cms'] as $key => $cms)
|
||||
$category['cms'][$key]['link'] = $link->getCMSLink($cms['id_cms'], $cms['link_rewrite']);
|
||||
}
|
||||
return $category;
|
||||
@@ -212,13 +213,11 @@ class CMSCategoryCore extends ObjectModel
|
||||
if ($is_html == 0)
|
||||
echo $html;
|
||||
if (isset($categories[$id_cms_category]))
|
||||
foreach (array_keys($categories[$id_cms_category]) AS $key)
|
||||
foreach (array_keys($categories[$id_cms_category]) as $key)
|
||||
$html .= CMSCategory::recurseCMSCategory($categories, $categories[$id_cms_category][$key], $key, $id_selected, $is_html);
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Recursively add specified CMSCategory childs to $toDelete array
|
||||
*
|
||||
@@ -227,14 +226,14 @@ class CMSCategoryCore extends ObjectModel
|
||||
*/
|
||||
protected function recursiveDelete(&$toDelete, $id_cms_category)
|
||||
{
|
||||
if (!is_array($toDelete) OR !$id_cms_category)
|
||||
if (!is_array($toDelete) || !$id_cms_category)
|
||||
die(Tools::displayError());
|
||||
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT `id_cms_category`
|
||||
FROM `'._DB_PREFIX_.'cms_category`
|
||||
WHERE `id_parent` = '.(int)($id_cms_category));
|
||||
foreach ($result AS $row)
|
||||
foreach ($result as $row)
|
||||
{
|
||||
$toDelete[] = (int)($row['id_cms_category']);
|
||||
$this->recursiveDelete($toDelete, (int)($row['id_cms_category']));
|
||||
@@ -253,7 +252,7 @@ class CMSCategoryCore extends ObjectModel
|
||||
$toDelete = array_unique($toDelete);
|
||||
|
||||
/* Delete CMS Category and its child from database */
|
||||
$list = sizeof($toDelete) > 1 ? implode(',', $toDelete) : (int)($this->id);
|
||||
$list = count($toDelete) > 1 ? implode(',', $toDelete) : (int)($this->id);
|
||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'cms_category` WHERE `id_cms_category` IN ('.$list.')');
|
||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'cms_category_lang` WHERE `id_cms_category` IN ('.$list.')');
|
||||
|
||||
@@ -281,7 +280,7 @@ class CMSCategoryCore extends ObjectModel
|
||||
public function deleteSelection($categories)
|
||||
{
|
||||
$return = 1;
|
||||
foreach ($categories AS $id_category_cms)
|
||||
foreach ($categories as $id_category_cms)
|
||||
{
|
||||
$category_cms = new CMSCategory((int)($id_category_cms));
|
||||
$return &= $category_cms->delete();
|
||||
@@ -326,7 +325,7 @@ class CMSCategoryCore extends ObjectModel
|
||||
return $result;
|
||||
|
||||
$categories = array();
|
||||
foreach ($result AS $row)
|
||||
foreach ($result as $row)
|
||||
$categories[$row['id_parent']][$row['id_cms_category']]['infos'] = $row;
|
||||
return $categories;
|
||||
}
|
||||
@@ -362,11 +361,9 @@ class CMSCategoryCore extends ObjectModel
|
||||
GROUP BY c.`id_cms_category`
|
||||
ORDER BY `name` ASC');
|
||||
|
||||
/* Modify SQL result */
|
||||
foreach ($result AS &$row)
|
||||
{
|
||||
// Modify SQL result
|
||||
foreach ($result as &$row)
|
||||
$row['name'] = CMSCategory::hideCMSCategoryPosition($row['name']);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -409,7 +406,7 @@ class CMSCategoryCore extends ObjectModel
|
||||
|
||||
/* Modify SQL result */
|
||||
$resultsArray = array();
|
||||
foreach ($result AS $row)
|
||||
foreach ($result as $row)
|
||||
{
|
||||
$row['name'] = CMSCategory::hideCMSCategoryPosition($row['name']);
|
||||
$resultsArray[] = $row;
|
||||
@@ -441,7 +438,7 @@ class CMSCategoryCore extends ObjectModel
|
||||
|
||||
public static function getLinkRewrite($id_cms_category, $id_lang)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_cms_category) OR !Validate::isUnsignedId($id_lang))
|
||||
if (!Validate::isUnsignedId($id_cms_category) || !Validate::isUnsignedId($id_lang))
|
||||
return false;
|
||||
|
||||
if (isset(self::$_links[$id_cms_category.'-'.$id_lang]))
|
||||
@@ -464,7 +461,7 @@ class CMSCategoryCore extends ObjectModel
|
||||
return $link->getCMSCategoryLink($this->id, $this->link_rewrite);
|
||||
}
|
||||
|
||||
public function getName($id_lang = NULL)
|
||||
public function getName($id_lang = null)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
|
||||
@@ -547,7 +544,7 @@ class CMSCategoryCore extends ObjectModel
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
|
||||
$categories[] = $result[0];
|
||||
if(!$result OR $result[0]['id_parent'] == 1)
|
||||
if (!$result || $result[0]['id_parent'] == 1)
|
||||
return $categories;
|
||||
$idCurrent = $result[0]['id_parent'];
|
||||
}
|
||||
@@ -562,8 +559,8 @@ class CMSCategoryCore extends ObjectModel
|
||||
ORDER BY cp.`position` ASC'
|
||||
))
|
||||
return false;
|
||||
foreach ($res AS $category)
|
||||
if ((int)($category['id_cms_category']) == (int)($this->id))
|
||||
foreach ($res as $category)
|
||||
if ((int)$category['id_cms_category'] == (int)$this->id)
|
||||
$movedCategory = $category;
|
||||
|
||||
if (!isset($movedCategory) || !isset($position))
|
||||
@@ -575,14 +572,14 @@ class CMSCategoryCore extends ObjectModel
|
||||
SET `position`= `position` '.($way ? '- 1' : '+ 1').'
|
||||
WHERE `position`
|
||||
'.($way
|
||||
? '> '.(int)($movedCategory['position']).' AND `position` <= '.(int)($position)
|
||||
: '< '.(int)($movedCategory['position']).' AND `position` >= '.(int)($position)).'
|
||||
? '> '.(int)($movedCategory['position']).' AND `position` <= '.(int)$position
|
||||
: '< '.(int)($movedCategory['position']).' AND `position` >= '.(int)$position).'
|
||||
AND `id_parent`='.(int)($movedCategory['id_parent']))
|
||||
AND Db::getInstance()->execute('
|
||||
&& Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'cms_category`
|
||||
SET `position` = '.(int)($position).'
|
||||
WHERE `id_parent` = '.(int)($movedCategory['id_parent']).'
|
||||
AND `id_cms_category`='.(int)($movedCategory['id_cms_category'])));
|
||||
SET `position` = '.(int)$position.'
|
||||
WHERE `id_parent` = '.(int)$movedCategory['id_parent'].'
|
||||
AND `id_cms_category`='.(int)$movedCategory['id_cms_category']));
|
||||
}
|
||||
|
||||
public static function cleanPositions($id_category_parent)
|
||||
@@ -592,8 +589,9 @@ class CMSCategoryCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'cms_category`
|
||||
WHERE `id_parent` = '.(int)($id_category_parent).'
|
||||
ORDER BY `position`');
|
||||
$sizeof = sizeof($result);
|
||||
for ($i = 0; $i < $sizeof; ++$i){
|
||||
$sizeof = count($result);
|
||||
for ($i = 0; $i < $sizeof; ++$i)
|
||||
{
|
||||
$sql = '
|
||||
UPDATE `'._DB_PREFIX_.'cms_category`
|
||||
SET `position` = '.(int)($i).'
|
||||
@@ -608,7 +606,8 @@ class CMSCategoryCore extends ObjectModel
|
||||
{
|
||||
return (Db::getInstance()->getValue('SELECT MAX(position)+1 FROM `'._DB_PREFIX_.'cms_category` WHERE `id_parent` = '.(int)($id_category_parent)));
|
||||
}
|
||||
public static function getUrlRewriteInformations($id_category)
|
||||
|
||||
public static function getUrlRewriteInformations($id_category)
|
||||
{
|
||||
$sql = '
|
||||
SELECT l.`id_lang`, c.`link_rewrite`
|
||||
|
||||
@@ -90,18 +90,16 @@ class CombinationCore extends ObjectModel
|
||||
|
||||
public function delete()
|
||||
{
|
||||
if (!parent::delete() OR $this->deleteAssociations() === false)
|
||||
if (!parent::delete() || $this->deleteAssociations() === false)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function deleteAssociations()
|
||||
{
|
||||
if (
|
||||
Db::getInstance()->execute('
|
||||
if (Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'product_attribute_combination`
|
||||
WHERE `id_product_attribute` = '.(int)($this->id)) === false
|
||||
)
|
||||
WHERE `id_product_attribute` = '.(int)$this->id) === false)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class CompareProductCore extends ObjectModel
|
||||
$compareProducts = null;
|
||||
|
||||
if ($results)
|
||||
foreach($results as $result)
|
||||
foreach ($results as $result)
|
||||
$compareProducts[] = $result['id_product'];
|
||||
|
||||
return $compareProducts;
|
||||
|
||||
+15
-15
@@ -27,22 +27,22 @@
|
||||
|
||||
class ConfigurationCore extends ObjectModel
|
||||
{
|
||||
public $id;
|
||||
public $id;
|
||||
|
||||
/** @var string Key */
|
||||
public $name;
|
||||
public $name;
|
||||
|
||||
public $id_group_shop;
|
||||
public $id_shop;
|
||||
public $id_group_shop;
|
||||
public $id_shop;
|
||||
|
||||
/** @var string Value */
|
||||
public $value;
|
||||
public $value;
|
||||
|
||||
/** @var string Object creation date */
|
||||
public $date_add;
|
||||
public $date_add;
|
||||
|
||||
/** @var string Object last modification date */
|
||||
public $date_upd;
|
||||
public $date_upd;
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
@@ -104,7 +104,7 @@ class ConfigurationCore extends ObjectModel
|
||||
/**
|
||||
* Load all configuration data
|
||||
*/
|
||||
static public function loadConfiguration()
|
||||
public static function loadConfiguration()
|
||||
{
|
||||
self::$_CONF = array();
|
||||
$sql = 'SELECT c.`name`, cl.`id_lang`, IF(cl.`id_lang` IS NULL, c.`value`, cl.`value`) AS value, c.id_group_shop, c.id_shop
|
||||
@@ -136,7 +136,7 @@ class ConfigurationCore extends ObjectModel
|
||||
* @param integer $id_lang Language ID
|
||||
* @return string Value
|
||||
*/
|
||||
static public function get($key, $langID = NULL, $shopGroupID = NULL, $shopID = NULL)
|
||||
public static function get($key, $langID = null, $shopGroupID = null, $shopID = null)
|
||||
{
|
||||
Configuration::getShopFromContext($shopGroupID, $shopID);
|
||||
$langID = (int)$langID;
|
||||
@@ -156,7 +156,7 @@ class ConfigurationCore extends ObjectModel
|
||||
return false;
|
||||
}
|
||||
|
||||
static public function getGlobalValue($key, $langID = NULL)
|
||||
public static function getGlobalValue($key, $langID = null)
|
||||
{
|
||||
return Configuration::get($key, $langID, 0, 0);
|
||||
}
|
||||
@@ -169,7 +169,7 @@ class ConfigurationCore extends ObjectModel
|
||||
* @param int $shopID
|
||||
* @return array Values in multiple languages
|
||||
*/
|
||||
static public function getInt($key, $id_group_shop = NULL, $id_shop = NULL)
|
||||
public static function getInt($key, $id_group_shop = null, $id_shop = null)
|
||||
{
|
||||
$languages = Language::getLanguages();
|
||||
$resultsArray = array();
|
||||
@@ -185,7 +185,7 @@ class ConfigurationCore extends ObjectModel
|
||||
* @param integer $id_lang Language ID
|
||||
* @return array Values
|
||||
*/
|
||||
static public function getMultiple($keys, $langID = NULL, $shopGroupID = NULL, $shopID = NULL)
|
||||
public static function getMultiple($keys, $langID = null, $shopGroupID = null, $shopID = null)
|
||||
{
|
||||
if (!is_array($keys))
|
||||
throw new PrestaShopException('keys var is not an array');
|
||||
@@ -226,7 +226,7 @@ class ConfigurationCore extends ObjectModel
|
||||
* @param int $shopGroupID
|
||||
* @param int $shopID
|
||||
*/
|
||||
static public function set($key, $values, $id_group_shop = NULL, $id_shop = NULL)
|
||||
public static function set($key, $values, $id_group_shop = null, $id_shop = null)
|
||||
{
|
||||
if (!Validate::isConfigName($key))
|
||||
die(Tools::displayError());
|
||||
@@ -254,7 +254,7 @@ class ConfigurationCore extends ObjectModel
|
||||
* @param bool $html
|
||||
* @return bool
|
||||
*/
|
||||
static public function updateGlobalValue($key, $values, $html = false)
|
||||
public static function updateGlobalValue($key, $values, $html = false)
|
||||
{
|
||||
return Configuration::updateValue($key, $values, $html, 0, 0);
|
||||
}
|
||||
@@ -269,7 +269,7 @@ class ConfigurationCore extends ObjectModel
|
||||
* @param int $shopID
|
||||
* @return boolean Update result
|
||||
*/
|
||||
static public function updateValue($key, $values, $html = false, $shopGroupID = null, $shopID = null)
|
||||
public static function updateValue($key, $values, $html = false, $shopGroupID = null, $shopID = null)
|
||||
{
|
||||
if (!Validate::isConfigName($key))
|
||||
die(Tools::displayError());
|
||||
|
||||
@@ -72,7 +72,6 @@ class ConfigurationTestCore
|
||||
*/
|
||||
public static function getDefaultTestsOp()
|
||||
{
|
||||
|
||||
return array(
|
||||
'fopen' => false,
|
||||
'register_globals' => false,
|
||||
@@ -127,7 +126,7 @@ class ConfigurationTestCore
|
||||
|
||||
public static function test_upload()
|
||||
{
|
||||
return ini_get('file_uploads');
|
||||
return ini_get('file_uploads');
|
||||
}
|
||||
|
||||
public static function test_fopen()
|
||||
@@ -163,7 +162,7 @@ class ConfigurationTestCore
|
||||
public static function test_dir($relative_dir, $recursive = false)
|
||||
{
|
||||
$dir = _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.ltrim($relative_dir, '/');
|
||||
if (!file_exists($dir) OR !$dh = opendir($dir))
|
||||
if (!file_exists($dir) || !$dh = opendir($dir))
|
||||
return false;
|
||||
$dummy = rtrim($dir, '/').'/'.uniqid();
|
||||
if (@file_put_contents($dummy, 'test'))
|
||||
@@ -188,7 +187,7 @@ class ConfigurationTestCore
|
||||
public static function test_file($file_relative)
|
||||
{
|
||||
$file = _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.$file_relative;
|
||||
return (file_exists($file) AND is_writable($file));
|
||||
return (file_exists($file) && is_writable($file));
|
||||
}
|
||||
|
||||
public static function test_config_dir($dir)
|
||||
|
||||
@@ -59,18 +59,18 @@ class ConnectionsSourceCore extends ObjectModel
|
||||
{
|
||||
if (!$cookie)
|
||||
$cookie = Context::getContext()->cookie;
|
||||
if (!isset($cookie->id_connections) OR !Validate::isUnsignedId($cookie->id_connections))
|
||||
if (!isset($cookie->id_connections) || !Validate::isUnsignedId($cookie->id_connections))
|
||||
return false;
|
||||
if (!isset($_SERVER['HTTP_REFERER']) AND !Configuration::get('TRACKING_DIRECT_TRAFFIC'))
|
||||
if (!isset($_SERVER['HTTP_REFERER']) && !Configuration::get('TRACKING_DIRECT_TRAFFIC'))
|
||||
return false;
|
||||
|
||||
$source = new ConnectionsSource();
|
||||
if (isset($_SERVER['HTTP_REFERER']) AND Validate::isAbsoluteUrl($_SERVER['HTTP_REFERER']))
|
||||
if (isset($_SERVER['HTTP_REFERER']) && Validate::isAbsoluteUrl($_SERVER['HTTP_REFERER']))
|
||||
{
|
||||
$parsed = parse_url($_SERVER['HTTP_REFERER']);
|
||||
$parsed_host = parse_url(Tools::getProtocol().Tools::getHttpHost(false, false).__PS_BASE_URI__);
|
||||
if ((preg_replace('/^www./', '', $parsed['host']) == preg_replace('/^www./', '', Tools::getHttpHost(false, false)))
|
||||
AND !strncmp($parsed['path'], $parsed_host['path'], strlen(__PS_BASE_URI__)))
|
||||
&& !strncmp($parsed['path'], $parsed_host['path'], strlen(__PS_BASE_URI__)))
|
||||
return false;
|
||||
if (Validate::isAbsoluteUrl(strval($_SERVER['HTTP_REFERER'])))
|
||||
{
|
||||
|
||||
@@ -233,9 +233,9 @@ abstract class ControllerCore
|
||||
public function addCSS($css_uri, $css_media_type = 'all')
|
||||
{
|
||||
if (is_array($css_uri))
|
||||
foreach($css_uri as $css_file => $media)
|
||||
foreach ($css_uri as $css_file => $media)
|
||||
{
|
||||
if (is_string($css_file) AND strlen($css_file) > 1)
|
||||
if (is_string($css_file) && strlen($css_file) > 1)
|
||||
{
|
||||
$css_path = Media::getCSSPath($css_file, $media);
|
||||
if ($css_path)
|
||||
@@ -248,7 +248,7 @@ abstract class ControllerCore
|
||||
$this->css_files = array_merge($css_path, $this->css_files);
|
||||
}
|
||||
}
|
||||
else if (is_string($css_uri) AND strlen($css_uri) > 1)
|
||||
else if (is_string($css_uri) && strlen($css_uri) > 1)
|
||||
{
|
||||
$css_path = Media::getCSSPath($css_uri, $css_media_type);
|
||||
if ($css_path)
|
||||
@@ -265,7 +265,7 @@ abstract class ControllerCore
|
||||
public function addJS($js_uri)
|
||||
{
|
||||
if (is_array($js_uri))
|
||||
foreach($js_uri as $js_file)
|
||||
foreach ($js_uri as $js_file)
|
||||
{
|
||||
$js_path = Media::getJSPath($js_file);
|
||||
if ($js_path)
|
||||
@@ -300,7 +300,7 @@ abstract class ControllerCore
|
||||
{
|
||||
$ui_path = array();
|
||||
if (is_array($component))
|
||||
foreach($component as $ui)
|
||||
foreach ($component as $ui)
|
||||
$ui_path = Media::getJqueryUIPath($ui, $theme, $check_dependencies);
|
||||
else
|
||||
$ui_path = Media::getJqueryUIPath($component, $theme, $check_dependencies);
|
||||
@@ -320,7 +320,7 @@ abstract class ControllerCore
|
||||
$plugin_path = array();
|
||||
if (is_array($name))
|
||||
{
|
||||
foreach($name as $plugin)
|
||||
foreach ($name as $plugin)
|
||||
{
|
||||
$plugin_path = Media::getJqueryPluginPath($plugin, $folder);
|
||||
$this->addJS($plugin_path['js']);
|
||||
|
||||
+9
-10
@@ -123,18 +123,17 @@ class CurrencyCore extends ObjectModel
|
||||
* @param int|string $iso_code int for iso code number string for iso code
|
||||
* @return boolean
|
||||
*/
|
||||
public static function exists ($iso_code)
|
||||
public static function exists($iso_code)
|
||||
{
|
||||
if(is_int($iso_code))
|
||||
if (is_int($iso_code))
|
||||
$id_currency_exists = Currency::getIdByIsoCodeNum($iso_code);
|
||||
else
|
||||
$id_currency_exists = Currency::getIdByIsoCode($iso_code);
|
||||
|
||||
if ($id_currency_exists){
|
||||
if ($id_currency_exists)
|
||||
return true;
|
||||
} else {
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteSelection($selection)
|
||||
@@ -173,7 +172,7 @@ class CurrencyCore extends ObjectModel
|
||||
* @param string $side left or right
|
||||
* @return string formated sign
|
||||
*/
|
||||
public function getSign($side=NULL)
|
||||
public function getSign($side = null)
|
||||
{
|
||||
if (!$side)
|
||||
return $this->sign;
|
||||
@@ -296,7 +295,7 @@ class CurrencyCore extends ObjectModel
|
||||
$conversion_rate = 1;
|
||||
if ($defaultCurrency->iso_code != $isoCodeSource)
|
||||
{
|
||||
foreach ($data->currency AS $currency)
|
||||
foreach ($data->currency as $currency)
|
||||
if ($currency['iso_code'] == $defaultCurrency->iso_code)
|
||||
{
|
||||
$conversion_rate = round((float)$currency['rate'], 6);
|
||||
@@ -312,15 +311,15 @@ class CurrencyCore extends ObjectModel
|
||||
$rate = 1;
|
||||
else
|
||||
{
|
||||
foreach ($data->currency AS $obj)
|
||||
foreach ($data->currency as $obj)
|
||||
if ($this->iso_code == strval($obj['iso_code']))
|
||||
{
|
||||
$rate = (float) $obj['rate'];
|
||||
$rate = (float)$obj['rate'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->conversion_rate = round($rate / $conversion_rate, 6);
|
||||
$this->conversion_rate = round($rate / $conversion_rate, 6);
|
||||
}
|
||||
$this->update();
|
||||
}
|
||||
|
||||
+10
-10
@@ -730,19 +730,19 @@ class CustomerCore extends ObjectModel
|
||||
public function getOutstanding()
|
||||
{
|
||||
$query = new DbQuery();
|
||||
$query->select('SUM(oi.total_paid_tax_incl)')
|
||||
->from('order_invoice', 'oi')
|
||||
->leftJoin('orders', 'o', 'oi.id_order = o.id_order')
|
||||
->groupBy('o.id_customer')
|
||||
->where('o.id_customer = '.(int)$this->id);
|
||||
$query->select('SUM(oi.total_paid_tax_incl)');
|
||||
$query->from('order_invoice', 'oi');
|
||||
$query->leftJoin('orders', 'o', 'oi.id_order = o.id_order');
|
||||
$query->groupBy('o.id_customer');
|
||||
$query->where('o.id_customer = '.(int)$this->id);
|
||||
$total_paid = (float)Db::getInstance()->getValue($query->build());
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->select('SUM(op.amount)')
|
||||
->from('order_payment', 'op')
|
||||
->leftJoin('orders', 'o', 'op.id_order = o.id_order')
|
||||
->groupBy('o.id_customer')
|
||||
->where('o.id_customer = '.(int)$this->id);
|
||||
$query->select('SUM(op.amount)');
|
||||
$query->from('order_payment', 'op');
|
||||
$query->leftJoin('orders', 'o', 'op.id_order = o.id_order');
|
||||
$query->groupBy('o.id_customer');
|
||||
$query->where('o.id_customer = '.(int)$this->id);
|
||||
$total_rest = (float)Db::getInstance()->getValue($query->build());
|
||||
|
||||
return $total_paid - $total_rest;
|
||||
|
||||
@@ -36,7 +36,7 @@ class CustomizationCore
|
||||
WHERE ore.`id_order` = '.(int)($id_order).' AND ord.`id_customization` != 0')) === false)
|
||||
return false;
|
||||
$customizations = array();
|
||||
foreach ($result AS $row)
|
||||
foreach ($result as $row)
|
||||
$customizations[(int)($row['id_customization'])] = $row;
|
||||
return $customizations;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ class CustomizationCore
|
||||
if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT `id_customization`, `quantity` FROM `'._DB_PREFIX_.'customization` WHERE `id_cart` = '.(int)($id_cart)))
|
||||
return false;
|
||||
$customizations = array();
|
||||
foreach ($result AS $row)
|
||||
foreach ($result as $row)
|
||||
$customizations[(int)($row['id_customization'])] = $row;
|
||||
return $customizations;
|
||||
}
|
||||
@@ -54,8 +54,8 @@ class CustomizationCore
|
||||
public static function countCustomizationQuantityByProduct($customizations)
|
||||
{
|
||||
$total = array();
|
||||
foreach ($customizations AS $customization)
|
||||
$total[(int)($customization['id_order_detail'])] = !isset($total[(int)($customization['id_order_detail'])]) ? (int)($customization['quantity']) : $total[(int)($customization['id_order_detail'])] + (int)($customization['quantity']);
|
||||
foreach ($customizations as $customization)
|
||||
$total[(int)$customization['id_order_detail']] = !isset($total[(int)$customization['id_order_detail']]) ? (int)$customization['quantity'] : $total[(int)$customization['id_order_detail']] + (int)$customization['quantity'];
|
||||
return $total;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class CustomizationCore
|
||||
$quantities = array();
|
||||
|
||||
$in_values = '';
|
||||
foreach($ids_customizations as $key => $id_customization)
|
||||
foreach ($ids_customizations as $key => $id_customization)
|
||||
{
|
||||
if ($key > 0) $in_values .= ',';
|
||||
$in_values .= (int)($id_customization);
|
||||
@@ -87,12 +87,12 @@ class CustomizationCore
|
||||
|
||||
if (!empty($in_values))
|
||||
{
|
||||
$results = Db::getInstance()->executeS(
|
||||
$results = Db::getInstance()->executeS(
|
||||
'SELECT `id_customization`, `id_product`, `quantity`, `quantity_refunded`, `quantity_returned`
|
||||
FROM `'._DB_PREFIX_.'customization`
|
||||
WHERE `id_customization` IN ('.$in_values.')');
|
||||
|
||||
foreach($results as $row)
|
||||
foreach ($results as $row)
|
||||
$quantities[$row['id_customization']] = $row;
|
||||
}
|
||||
|
||||
@@ -103,14 +103,14 @@ class CustomizationCore
|
||||
{
|
||||
$quantity = array();
|
||||
|
||||
$results = Db::getInstance()->executeS('
|
||||
$results = Db::getInstance()->executeS('
|
||||
SELECT `id_product`, `id_product_attribute`, SUM(`quantity`) AS quantity
|
||||
FROM `'._DB_PREFIX_.'customization`
|
||||
WHERE `id_cart` = '.(int)$id_cart.'
|
||||
GROUP BY `id_cart`, `id_product`, `id_product_attribute`
|
||||
');
|
||||
|
||||
foreach($results as $row)
|
||||
foreach ($results as $row)
|
||||
$quantity[$row['id_product']][$row['product_attribute_id']] = $row['quantity'];
|
||||
|
||||
return $quantity;
|
||||
|
||||
@@ -48,7 +48,7 @@ class DateRangeCore extends ObjectModel
|
||||
SELECT `id_date_range`, `time_end`
|
||||
FROM `'._DB_PREFIX_.'date_range`
|
||||
WHERE `time_end` = (SELECT MAX(`time_end`) FROM `'._DB_PREFIX_.'date_range`)');
|
||||
if (!$result['id_date_range'] OR strtotime($result['time_end']) < strtotime(date('Y-m-d H:i:s')))
|
||||
if (!$result['id_date_range'] || strtotime($result['time_end']) < strtotime(date('Y-m-d H:i:s')))
|
||||
{
|
||||
// The default range is set to 1 day less 1 second (in seconds)
|
||||
$rangeSize = 86399;
|
||||
|
||||
@@ -128,7 +128,7 @@ class DiscountCore extends CartRule
|
||||
$obj = $this->parent;
|
||||
if (in_array($method, array('add', 'update', 'getIdByName', 'getCustomerDiscounts', 'getValue', 'discountExists', 'createOrderDiscount', 'getVouchersToCartDisplay')))
|
||||
$obj = $this;
|
||||
return call_user_func_array(array(obj, $method), $args);
|
||||
return call_user_func_array(array($obj, $method), $args);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,8 +163,8 @@ class DiscountCore extends CartRule
|
||||
* @deprecated 1.5.0.1
|
||||
*/
|
||||
public static function getCustomerDiscounts($id_lang, $id_customer, $active = false, $includeGenericOnes = true, $hasStock = false, Cart $cart = null)
|
||||
{
|
||||
return parent::getCustomerCartRules($id_lang, $id_customer, $active, $includeGenericOnes, $hasStock, $cart);
|
||||
{
|
||||
return parent::getCustomerCartRules($id_lang, $id_customer, $active, $includeGenericOnes, $hasStock, $cart);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+36
-38
@@ -105,13 +105,13 @@ class FrontControllerCore extends Controller
|
||||
$css_files = $this->css_files;
|
||||
$js_files = $this->js_files;
|
||||
|
||||
if ($this->ssl AND !Tools::usingSecureMode() AND Configuration::get('PS_SSL_ENABLED'))
|
||||
if ($this->ssl && !Tools::usingSecureMode() && Configuration::get('PS_SSL_ENABLED'))
|
||||
{
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
header('Location: '.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']);
|
||||
exit();
|
||||
}
|
||||
else if (Configuration::get('PS_SSL_ENABLED') AND Tools::usingSecureMode() AND !($this->ssl))
|
||||
else if (Configuration::get('PS_SSL_ENABLED') && Tools::usingSecureMode() && !($this->ssl))
|
||||
{
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
header('Location: '.Tools::getShopDomain(true).$_SERVER['REQUEST_URI']);
|
||||
@@ -134,15 +134,15 @@ class FrontControllerCore extends Controller
|
||||
ob_start();
|
||||
|
||||
// Switch language if needed and init cookie language
|
||||
if ($iso = Tools::getValue('isolang') AND Validate::isLanguageIsoCode($iso) AND ($id_lang = (int)(Language::getIdByIso($iso))))
|
||||
if ($iso = Tools::getValue('isolang') && Validate::isLanguageIsoCode($iso) && ($id_lang = (int)(Language::getIdByIso($iso))))
|
||||
$_GET['id_lang'] = $id_lang;
|
||||
|
||||
Tools::switchLanguage();
|
||||
Tools::setCookieLanguage($this->context->cookie);
|
||||
$currency = Tools::setCurrency($this->context->cookie);
|
||||
|
||||
$protocol_link = (Configuration::get('PS_SSL_ENABLED') OR Tools::usingSecureMode()) ? 'https://' : 'http://';
|
||||
$useSSL = ((isset($this->ssl) AND $this->ssl AND Configuration::get('PS_SSL_ENABLED')) OR Tools::usingSecureMode()) ? true : false;
|
||||
$protocol_link = (Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode()) ? 'https://' : 'http://';
|
||||
$useSSL = ((isset($this->ssl) && $this->ssl && Configuration::get('PS_SSL_ENABLED')) || Tools::usingSecureMode()) ? true : false;
|
||||
$protocol_content = ($useSSL) ? 'https://' : 'http://';
|
||||
$link = new Link($protocol_link, $protocol_content);
|
||||
$this->context->link = $link;
|
||||
@@ -150,31 +150,31 @@ class FrontControllerCore extends Controller
|
||||
if ($id_cart = (int)$this->recoverCart())
|
||||
$this->context->cookie->id_cart = (int)$id_cart;
|
||||
|
||||
if ($this->auth AND !$this->context->customer->isLogged($this->guestAllowed))
|
||||
if ($this->auth && !$this->context->customer->isLogged($this->guestAllowed))
|
||||
Tools::redirect('index.php?controller=authentication'.($this->authRedirection ? '&back='.$this->authRedirection : ''));
|
||||
|
||||
/* Theme is missing or maintenance */
|
||||
if (!is_dir(_PS_THEME_DIR_))
|
||||
die(Tools::displayError('Current theme unavailable. Please check your theme directory name and permissions.'));
|
||||
elseif (basename($_SERVER['PHP_SELF']) != 'disabled.php' AND !(int)(Configuration::get('PS_SHOP_ENABLE')))
|
||||
elseif (basename($_SERVER['PHP_SELF']) != 'disabled.php' && !(int)(Configuration::get('PS_SHOP_ENABLE')))
|
||||
$this->maintenance = true;
|
||||
elseif (Configuration::get('PS_GEOLOCATION_ENABLED'))
|
||||
if (($newDefault = $this->geolocationManagement($this->context->country)) && Validate::isLoadedObject($newDefault))
|
||||
$this->context->country = $newDefault;
|
||||
|
||||
if (isset($_GET['logout']) OR ($this->context->customer->logged AND Customer::isBanned($this->context->customer->id)))
|
||||
if (isset($_GET['logout']) || ($this->context->customer->logged && Customer::isBanned($this->context->customer->id)))
|
||||
{
|
||||
$this->context->customer->logout();
|
||||
|
||||
// Login information have changed, so we check if the cart rules still apply
|
||||
CartRule::autoRemoveFromCart();
|
||||
|
||||
Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL);
|
||||
Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
|
||||
}
|
||||
elseif (isset($_GET['mylogout']))
|
||||
{
|
||||
$this->context->customer->mylogout();
|
||||
Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL);
|
||||
Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
|
||||
}
|
||||
|
||||
$_MODULES = array();
|
||||
@@ -186,13 +186,13 @@ class FrontControllerCore extends Controller
|
||||
if ($cart->OrderExists())
|
||||
unset($this->context->cookie->id_cart, $cart, $this->context->cookie->checkedTOS);
|
||||
/* Delete product of cart, if user can't make an order from his country */
|
||||
elseif (intval(Configuration::get('PS_GEOLOCATION_ENABLED')) AND
|
||||
!in_array(strtoupper($this->context->cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) AND
|
||||
$cart->nbProducts() AND intval(Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR')) != -1 AND
|
||||
elseif (intval(Configuration::get('PS_GEOLOCATION_ENABLED')) &&
|
||||
!in_array(strtoupper($this->context->cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) &&
|
||||
$cart->nbProducts() && intval(Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR')) != -1 &&
|
||||
!FrontController::isInWhitelistForGeolocation())
|
||||
unset($this->context->cookie->id_cart, $cart);
|
||||
// update cart values
|
||||
elseif ($this->context->cookie->id_customer != $cart->id_customer OR $this->context->cookie->id_lang != $cart->id_lang OR $currency->id != $cart->id_currency)
|
||||
elseif ($this->context->cookie->id_customer != $cart->id_customer || $this->context->cookie->id_lang != $cart->id_lang || $currency->id != $cart->id_currency)
|
||||
{
|
||||
if ($this->context->cookie->id_customer)
|
||||
$cart->id_customer = (int)($this->context->cookie->id_customer);
|
||||
@@ -220,7 +220,7 @@ class FrontControllerCore extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($cart) OR !$cart->id)
|
||||
if (!isset($cart) || !$cart->id)
|
||||
{
|
||||
$cart = new Cart();
|
||||
$cart->id_lang = (int)($this->context->cookie->id_lang);
|
||||
@@ -313,7 +313,7 @@ class FrontControllerCore extends Controller
|
||||
'display_tax_label' => (bool)$display_tax_label,
|
||||
'vat_management' => (int)Configuration::get('VATNUMBER_MANAGEMENT'),
|
||||
'opc' => (bool)Configuration::get('PS_ORDER_PROCESS_TYPE'),
|
||||
'PS_CATALOG_MODE' => (bool)Configuration::get('PS_CATALOG_MODE') OR !(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')
|
||||
));
|
||||
|
||||
@@ -341,7 +341,7 @@ class FrontControllerCore extends Controller
|
||||
);
|
||||
|
||||
foreach ($assignArray as $assignKey => $assignValue)
|
||||
if (substr($assignValue, 0, 1) == '/' OR $protocol_content == 'https://')
|
||||
if (substr($assignValue, 0, 1) == '/' || $protocol_content == 'https://')
|
||||
$this->context->smarty->assign($assignKey, $protocol_content.Tools::getMediaServer($assignValue).$assignValue);
|
||||
else
|
||||
$this->context->smarty->assign($assignKey, $assignValue);
|
||||
@@ -363,7 +363,7 @@ class FrontControllerCore extends Controller
|
||||
$this->displayRestrictedCountryPage();
|
||||
|
||||
//live edit
|
||||
if (Tools::isSubmit('live_edit') AND $ad = Tools::getValue('ad') AND (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_)))
|
||||
if (Tools::isSubmit('live_edit') && $ad = Tools::getValue('ad') && (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_)))
|
||||
if (!is_dir(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.$ad))
|
||||
die(Tools::displayError());
|
||||
|
||||
@@ -373,11 +373,11 @@ class FrontControllerCore extends Controller
|
||||
// Customer wasn't defined at all
|
||||
$customer = new StdClass();
|
||||
|
||||
if($this->context->cookie->id_country)
|
||||
if ($this->context->cookie->id_country)
|
||||
$customer->geoloc_id_country = (int)$this->context->cookie->id_country;
|
||||
if($this->context->cookie->id_state)
|
||||
if ($this->context->cookie->id_state)
|
||||
$customer->geoloc_id_state = (int)$this->context->cookie->id_state;
|
||||
if($this->context->cookie->postcode)
|
||||
if ($this->context->cookie->postcode)
|
||||
$customer->geoloc_postcode = (int)$this->context->cookie->postcode;
|
||||
|
||||
$this->context->cart = $cart;
|
||||
@@ -425,7 +425,7 @@ class FrontControllerCore extends Controller
|
||||
Tools::displayAsDeprecated();
|
||||
$this->initHeader();
|
||||
$hook_header = Hook::exec('displayHeader');
|
||||
if ((Configuration::get('PS_CSS_THEME_CACHE') OR Configuration::get('PS_JS_THEME_CACHE')) AND is_writable(_PS_THEME_DIR_.'cache'))
|
||||
if ((Configuration::get('PS_CSS_THEME_CACHE') || Configuration::get('PS_JS_THEME_CACHE')) && is_writable(_PS_THEME_DIR_.'cache'))
|
||||
{
|
||||
// CSS compressor management
|
||||
if (Configuration::get('PS_CSS_THEME_CACHE'))
|
||||
@@ -481,7 +481,7 @@ class FrontControllerCore extends Controller
|
||||
Tools::safePostVars();
|
||||
|
||||
// assign css_files and js_files at the very last time
|
||||
if ((Configuration::get('PS_CSS_THEME_CACHE') OR Configuration::get('PS_JS_THEME_CACHE')) AND is_writable(_PS_THEME_DIR_.'cache'))
|
||||
if ((Configuration::get('PS_CSS_THEME_CACHE') || Configuration::get('PS_JS_THEME_CACHE')) && is_writable(_PS_THEME_DIR_.'cache'))
|
||||
{
|
||||
// CSS compressor management
|
||||
if (Configuration::get('PS_CSS_THEME_CACHE'))
|
||||
@@ -523,7 +523,7 @@ class FrontControllerCore extends Controller
|
||||
$this->context->smarty->display(_PS_THEME_DIR_.'footer.tpl');
|
||||
|
||||
// live edit
|
||||
if (Tools::isSubmit('live_edit') AND $ad = Tools::getValue('ad') AND (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_)))
|
||||
if (Tools::isSubmit('live_edit') && $ad = Tools::getValue('ad') && (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_)))
|
||||
{
|
||||
$this->context->smarty->assign(array('ad' => $ad, 'live_edit' => true));
|
||||
$this->context->smarty->display(_PS_ALL_THEMES_DIR_.'live_edit.tpl');
|
||||
@@ -572,7 +572,7 @@ class FrontControllerCore extends Controller
|
||||
$strParams = ((strpos($canonicalURL, '?') === false) ? '?' : '&').implode('&', $params);
|
||||
|
||||
header('HTTP/1.0 301 Moved');
|
||||
if (defined('_PS_MODE_DEV_') AND _PS_MODE_DEV_ AND $_SERVER['REQUEST_URI'] != __PS_BASE_URI__)
|
||||
if (defined('_PS_MODE_DEV_') && _PS_MODE_DEV_ && $_SERVER['REQUEST_URI'] != __PS_BASE_URI__)
|
||||
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$canonicalURL.$strParams.'">'.$canonicalURL.$strParams.'</a>');
|
||||
Tools::redirectLink($canonicalURL.$strParams);
|
||||
}
|
||||
@@ -585,7 +585,7 @@ class FrontControllerCore extends Controller
|
||||
/* Check if Maxmind Database exists */
|
||||
if (file_exists(_PS_GEOIP_DIR_.'GeoLiteCity.dat'))
|
||||
{
|
||||
if (!isset($this->context->cookie->iso_code_country) OR (isset($this->context->cookie->iso_code_country) AND !in_array(strtoupper($this->context->cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES')))))
|
||||
if (!isset($this->context->cookie->iso_code_country) || (isset($this->context->cookie->iso_code_country) && !in_array(strtoupper($this->context->cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES')))))
|
||||
{
|
||||
include_once(_PS_GEOIP_DIR_.'geoipcity.inc');
|
||||
include_once(_PS_GEOIP_DIR_.'geoipregionvars.php');
|
||||
@@ -616,9 +616,9 @@ class FrontControllerCore extends Controller
|
||||
if (isset($this->context->cookie->iso_code_country) && ($id_country = Country::getByIso(strtoupper($this->context->cookie->iso_code_country))))
|
||||
{
|
||||
/* Update defaultCountry */
|
||||
if($defaultCountry->iso_code != $this->context->cookie->iso_code_country)
|
||||
if ($defaultCountry->iso_code != $this->context->cookie->iso_code_country)
|
||||
$defaultCountry = new Country($id_country);
|
||||
if (isset($hasBeenSet) AND $hasBeenSet)
|
||||
if (isset($hasBeenSet) && $hasBeenSet)
|
||||
$this->context->cookie->id_currency = (int)(Currency::getCurrencyInstance($defaultCountry->id_currency ? (int)$defaultCountry->id_currency : Configuration::get('PS_CURRENCY_DEFAULT'))->id);
|
||||
return $defaultCountry;
|
||||
}
|
||||
@@ -644,12 +644,12 @@ class FrontControllerCore extends Controller
|
||||
$this->addjqueryPlugin('easing');
|
||||
$this->addJS(_PS_JS_DIR_.'tools.js');
|
||||
|
||||
if (Tools::isSubmit('live_edit') AND Tools::getValue('ad') AND (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_)))
|
||||
if (Tools::isSubmit('live_edit') && Tools::getValue('ad') && (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_)))
|
||||
{
|
||||
$this->addJqueryUI('ui.sortable');
|
||||
$this->addjqueryPlugin('fancybox');
|
||||
$this->addJS(_PS_JS_DIR_.'hookLiveEdit.js');
|
||||
$this->addCSS(_PS_CSS_DIR_.'jquery.fancybox-1.3.4.css', 'all'); //TODO
|
||||
$this->addCSS(_PS_CSS_DIR_.'jquery.fancybox-1.3.4.css', 'all'); // @TODO
|
||||
}
|
||||
if ($this->context->language->is_rtl)
|
||||
$this->addCSS(_THEME_CSS_DIR_.'rtl.css');
|
||||
@@ -683,10 +683,9 @@ class FrontControllerCore extends Controller
|
||||
|
||||
public function getLiveEditFooter()
|
||||
{
|
||||
if (Tools::isSubmit('live_edit')
|
||||
if (Tools::isSubmit('live_edit')
|
||||
&& ($ad = Tools::getValue('ad'))
|
||||
&& (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_))
|
||||
)
|
||||
&& (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_)))
|
||||
{
|
||||
$data = $this->context->smarty->createData();
|
||||
$data->assign(array(
|
||||
@@ -739,7 +738,7 @@ class FrontControllerCore extends Controller
|
||||
// Clean duplicate values
|
||||
$nArray = array_unique($nArray);
|
||||
asort($nArray);
|
||||
$this->n = abs((int)(Tools::getValue('n', ((isset($this->context->cookie->nb_item_per_page) AND $this->context->cookie->nb_item_per_page >= 10) ? $this->context->cookie->nb_item_per_page : (int)(Configuration::get('PS_PRODUCTS_PER_PAGE'))))));
|
||||
$this->n = abs((int)(Tools::getValue('n', ((isset($this->context->cookie->nb_item_per_page) && $this->context->cookie->nb_item_per_page >= 10) ? $this->context->cookie->nb_item_per_page : (int)(Configuration::get('PS_PRODUCTS_PER_PAGE'))))));
|
||||
$this->p = abs((int)(Tools::getValue('p', 1)));
|
||||
|
||||
$current_url = tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']);
|
||||
@@ -751,7 +750,7 @@ class FrontControllerCore extends Controller
|
||||
if ($this->p < 0)
|
||||
$this->p = 0;
|
||||
|
||||
if (isset($this->context->cookie->nb_item_per_page) AND $this->n != $this->context->cookie->nb_item_per_page AND 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;
|
||||
|
||||
if ($this->p > ($nbProducts / $this->n))
|
||||
@@ -802,7 +801,7 @@ class FrontControllerCore extends Controller
|
||||
$allowed = false;
|
||||
$userIp = Tools::getRemoteAddr();
|
||||
$ips = explode(';', Configuration::get('PS_GEOLOCATION_WHITELIST'));
|
||||
if (is_array($ips) && sizeof($ips))
|
||||
if (is_array($ips) && count($ips))
|
||||
foreach ($ips as $ip)
|
||||
if (!empty($ip) && strpos($userIp, $ip) === 0)
|
||||
$allowed = true;
|
||||
@@ -875,7 +874,7 @@ class FrontControllerCore extends Controller
|
||||
if (Validate::isLoadedObject($cart))
|
||||
{
|
||||
$customer = new Customer((int)$cart->id_customer);
|
||||
if(Validate::isLoadedObject($customer))
|
||||
if (Validate::isLoadedObject($customer))
|
||||
{
|
||||
$this->context->cookie->id_customer = (int)$customer->id;
|
||||
$this->context->cookie->customer_lastname = $customer->lastname;
|
||||
@@ -884,7 +883,6 @@ class FrontControllerCore extends Controller
|
||||
$this->context->cookie->is_guest = $customer->isGuest();
|
||||
$this->context->cookie->passwd = $customer->passwd;
|
||||
$this->context->cookie->email = $customer->email;
|
||||
$this->context->cookie->checkedTOS = true;
|
||||
return $id_cart;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,8 +104,8 @@ class GroupReductionCore extends ObjectModel
|
||||
$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT p.`id_product`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
WHERE p.`id_category_default` = '.(int)$this->id_category
|
||||
, false);
|
||||
WHERE p.`id_category_default` = '.(int)$this->id_category,
|
||||
false);
|
||||
|
||||
$ids = array();
|
||||
foreach ($products as $product)
|
||||
@@ -154,8 +154,8 @@ class GroupReductionCore extends ObjectModel
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT gr.`id_group` as id_group, gr.`reduction` as reduction
|
||||
FROM `'._DB_PREFIX_.'group_reduction` gr
|
||||
WHERE `id_category` = '.(int)$id_category
|
||||
, false);
|
||||
WHERE `id_category` = '.(int)$id_category,
|
||||
false);
|
||||
}
|
||||
|
||||
public static function getGroupReductionByCategoryId($id_category)
|
||||
@@ -163,13 +163,13 @@ class GroupReductionCore extends ObjectModel
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT gr.`id_group_reduction` as id_group_reduction
|
||||
FROM `'._DB_PREFIX_.'group_reduction` gr
|
||||
WHERE `id_category` = '.(int)$id_category
|
||||
, false);
|
||||
WHERE `id_category` = '.(int)$id_category,
|
||||
false);
|
||||
}
|
||||
|
||||
public static function setProductReduction($id_product, $id_group, $id_category, $reduction)
|
||||
{
|
||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT pgr.`id_product`, pgr.`id_group`, pgr.`reduction`
|
||||
FROM `'._DB_PREFIX_.'product_group_reduction_cache` pgr
|
||||
WHERE pgr.`id_product` = '.(int)$id_product
|
||||
|
||||
+6
-6
@@ -72,7 +72,7 @@ class GuestCore extends ObjectModel
|
||||
),
|
||||
);
|
||||
|
||||
function userAgent()
|
||||
public function userAgent()
|
||||
{
|
||||
$userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
|
||||
$acceptLanguage = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '';
|
||||
@@ -96,7 +96,7 @@ class GuestCore extends ObjectModel
|
||||
}
|
||||
|
||||
// Only the first language is returned
|
||||
return (sizeof($langsArray) ? key($langsArray) : '');
|
||||
return (count($langsArray) ? key($langsArray) : '');
|
||||
}
|
||||
|
||||
protected function getBrowser($userAgent)
|
||||
@@ -121,7 +121,7 @@ class GuestCore extends ObjectModel
|
||||
|
||||
return $result['id_web_browser'];
|
||||
}
|
||||
return NULL;
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function getOs($userAgent)
|
||||
@@ -142,7 +142,7 @@ class GuestCore extends ObjectModel
|
||||
|
||||
return $result['id_operating_system'];
|
||||
}
|
||||
return NULL;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getFromCustomer($id_customer)
|
||||
@@ -177,9 +177,9 @@ class GuestCore extends ObjectModel
|
||||
|
||||
public static function setNewGuest($cookie)
|
||||
{
|
||||
$guest = new Guest(isset($cookie->id_customer) ? Guest::getFromCustomer((int)($cookie->id_customer)) : NULL);
|
||||
$guest = new Guest(isset($cookie->id_customer) ? Guest::getFromCustomer((int)($cookie->id_customer)) : null);
|
||||
$guest->userAgent();
|
||||
if ($guest->id_operating_system OR $guest->id_web_browser)
|
||||
if ($guest->id_operating_system || $guest->id_web_browser)
|
||||
{
|
||||
$guest->save();
|
||||
$cookie->id_guest = (int)($guest->id);
|
||||
|
||||
@@ -83,12 +83,12 @@ class HelpAccessCore
|
||||
$res = @file_get_contents($url, 0, $ctx);
|
||||
|
||||
$infos = preg_split('/\|/', $res);
|
||||
if (sizeof($infos) > 0)
|
||||
if (count($infos) > 0)
|
||||
{
|
||||
$version = trim($infos[0]);
|
||||
if (!empty($version))
|
||||
{
|
||||
if (sizeof($infos) > 1)
|
||||
if (count($infos) > 1)
|
||||
$tooltip = trim($infos[1]);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -411,7 +411,7 @@ font-style:italic;"><img style="padding-right:5px;" src="'._MODULE_DIR_.$moduleI
|
||||
$newOS = new OrderState((int)($newOrderStatusId), $order->id_lang);
|
||||
|
||||
$return = ((int)($newOS->id) == Configuration::get('PS_OS_PAYMENT')) ? Hook::exec('paymentConfirm', array('id_order' => (int)($order->id))) : true;
|
||||
$return = Hook::exec('updateOrderStatus', array('newOrderStatus' => $newOS, 'id_order' => (int)($order->id))) AND $return;
|
||||
$return = Hook::exec('updateOrderStatus', array('newOrderStatus' => $newOS, 'id_order' => (int)($order->id))) && $return;
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -459,7 +459,7 @@ font-style:italic;"><img style="padding-right:5px;" src="'._MODULE_DIR_.$moduleI
|
||||
public static function paymentReturn($id_order, $id_module)
|
||||
{
|
||||
Tools::displayAsDeprecated();
|
||||
if (Validate::isUnsignedId($id_order) AND Validate::isUnsignedId($id_module))
|
||||
if (Validate::isUnsignedId($id_order) && Validate::isUnsignedId($id_module))
|
||||
{
|
||||
$params = array();
|
||||
$order = new Order((int)($id_order));
|
||||
@@ -485,7 +485,7 @@ font-style:italic;"><img style="padding-right:5px;" src="'._MODULE_DIR_.$moduleI
|
||||
public static function PDFInvoice($pdf, $id_order)
|
||||
{
|
||||
Tools::displayAsDeprecated();
|
||||
if (!is_object($pdf) OR !Validate::isUnsignedId($id_order))
|
||||
if (!is_object($pdf) || !Validate::isUnsignedId($id_order))
|
||||
return false;
|
||||
return Hook::exec('PDFInvoice', array('pdf' => $pdf, 'id_order' => $id_order));
|
||||
}
|
||||
|
||||
+12
-12
@@ -27,34 +27,34 @@
|
||||
|
||||
class ImageTypeCore extends ObjectModel
|
||||
{
|
||||
public $id;
|
||||
public $id;
|
||||
|
||||
/** @var string Name */
|
||||
public $name;
|
||||
public $name;
|
||||
|
||||
/** @var integer Width */
|
||||
public $width;
|
||||
public $width;
|
||||
|
||||
/** @var integer Height */
|
||||
public $height;
|
||||
public $height;
|
||||
|
||||
/** @var boolean Apply to products */
|
||||
public $products;
|
||||
public $products;
|
||||
|
||||
/** @var integer Apply to categories */
|
||||
public $categories;
|
||||
public $categories;
|
||||
|
||||
/** @var integer Apply to manufacturers */
|
||||
public $manufacturers;
|
||||
public $manufacturers;
|
||||
|
||||
/** @var integer Apply to suppliers */
|
||||
public $suppliers;
|
||||
public $suppliers;
|
||||
|
||||
/** @var integer Apply to scenes */
|
||||
public $scenes;
|
||||
public $scenes;
|
||||
|
||||
/** @var integer Apply to store */
|
||||
public $stores;
|
||||
public $stores;
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
@@ -88,7 +88,7 @@ class ImageTypeCore extends ObjectModel
|
||||
* @param string|null Image type
|
||||
* @return array Image type definitions
|
||||
*/
|
||||
public static function getImagesTypes($type = NULL, $id_theme = false)
|
||||
public static function getImagesTypes($type = null, $id_theme = false)
|
||||
{
|
||||
if (!isset(self::$images_types_cache[$type.($id_theme ? '-'.$id_theme : '')]))
|
||||
{
|
||||
@@ -96,7 +96,7 @@ class ImageTypeCore extends ObjectModel
|
||||
if ($id_theme)
|
||||
$where .= ' AND id_theme='.(int)$id_theme;
|
||||
if (!empty($type))
|
||||
$where .= ' AND ' . pSQL($type) . ' = 1 ';
|
||||
$where .= ' AND '.pSQL($type).' = 1 ';
|
||||
|
||||
$query = 'SELECT * FROM `'._DB_PREFIX_.'image_type`'.$where.' ORDER BY `name` ASC';
|
||||
self::$images_types_cache[$type] = Db::getInstance()->executeS($query);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
abstract class ImportModuleCore extends Module
|
||||
{
|
||||
protected $_link = NULL;
|
||||
protected $_link = null;
|
||||
|
||||
public $server;
|
||||
|
||||
@@ -30,17 +30,17 @@ abstract class ImportModuleCore extends Module
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
if($this->_link)
|
||||
if ($this->_link)
|
||||
@mysql_close($this->_link);
|
||||
}
|
||||
|
||||
protected function initDatabaseConnection()
|
||||
{
|
||||
if ($this->_link != NULL)
|
||||
if ($this->_link != null)
|
||||
return $this->_link;
|
||||
if ($this->_link = mysql_connect($this->server, $this->user, $this->passwd, true))
|
||||
{
|
||||
if(!mysql_select_db($this->database, $this->_link))
|
||||
if (!mysql_select_db($this->database, $this->_link))
|
||||
die(Tools::displayError('The database selection cannot be made.'));
|
||||
if (!mysql_query('SET NAMES \'utf8\'', $this->_link))
|
||||
die(Tools::displayError('PrestaShop Fatal error: no utf-8 support. Please check your server configuration.'));
|
||||
@@ -71,7 +71,7 @@ abstract class ImportModuleCore extends Module
|
||||
{
|
||||
$this->initDatabaseConnection();
|
||||
$result = $this->executeS($query);
|
||||
if (!sizeof($result))
|
||||
if (!count($result))
|
||||
return 0;
|
||||
else
|
||||
return array_shift($result[0]);
|
||||
@@ -81,7 +81,7 @@ abstract class ImportModuleCore extends Module
|
||||
{
|
||||
$modules = Module::getModulesOnDisk(true);
|
||||
foreach ($modules as $key => $module)
|
||||
if(get_parent_class($module) != 'ImportModule')
|
||||
if (get_parent_class($module) != 'ImportModule')
|
||||
unset($modules[$key]);
|
||||
return $modules;
|
||||
}
|
||||
|
||||
+53
-54
@@ -27,28 +27,28 @@
|
||||
|
||||
class LanguageCore extends ObjectModel
|
||||
{
|
||||
public $id;
|
||||
public $id;
|
||||
|
||||
/** @var string Name */
|
||||
public $name;
|
||||
public $name;
|
||||
|
||||
/** @var string 2-letter iso code */
|
||||
public $iso_code;
|
||||
public $iso_code;
|
||||
|
||||
/** @var string 5-letter iso code */
|
||||
public $language_code;
|
||||
public $language_code;
|
||||
|
||||
/** @var string date format http://http://php.net/manual/en/function.date.php with the date only */
|
||||
public $date_format_lite = 'Y-m-d';
|
||||
public $date_format_lite = 'Y-m-d';
|
||||
|
||||
/** @var string date format http://http://php.net/manual/en/function.date.php with hours and minutes */
|
||||
public $date_format_full = 'Y-m-d H:i:s';
|
||||
public $date_format_full = 'Y-m-d H:i:s';
|
||||
|
||||
/** @var bool true if this language is right to left language */
|
||||
public $is_rtl = false;
|
||||
public $is_rtl = false;
|
||||
|
||||
/** @var boolean Status */
|
||||
public $active = true;
|
||||
public $active = true;
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
@@ -85,7 +85,7 @@ class LanguageCore extends ObjectModel
|
||||
'pdf' => '_LANGPDF',
|
||||
);
|
||||
|
||||
public function __construct($id = NULL, $id_lang = NULL)
|
||||
public function __construct($id = null, $id_lang = null)
|
||||
{
|
||||
parent::__construct($id);
|
||||
}
|
||||
@@ -125,7 +125,7 @@ class LanguageCore extends ObjectModel
|
||||
*/
|
||||
public function moveToIso($newIso)
|
||||
{
|
||||
if($newIso == $this->iso_code)
|
||||
if ($newIso == $this->iso_code)
|
||||
return true;
|
||||
|
||||
if (file_exists(_PS_TRANSLATIONS_DIR_.$this->iso_code))
|
||||
@@ -173,7 +173,7 @@ class LanguageCore extends ObjectModel
|
||||
if (empty($themes))
|
||||
{
|
||||
$installed_themes = Theme::getThemes();
|
||||
foreach($installed_themes as $theme)
|
||||
foreach ($installed_themes as $theme)
|
||||
$themes[$theme->directory] = array('name' => $theme->name);
|
||||
}
|
||||
return $themes;
|
||||
@@ -233,7 +233,7 @@ class LanguageCore extends ObjectModel
|
||||
if (empty($iso_from))
|
||||
die(Tools::displayError());
|
||||
|
||||
$copy = ($iso_to AND $theme_to) ? true : false;
|
||||
$copy = ($iso_to && $theme_to) ? true : false;
|
||||
|
||||
$lPath_from = _PS_TRANSLATIONS_DIR_.(string)$iso_from.'/';
|
||||
$tPath_from = _PS_ROOT_DIR_.'/themes/'.(string)$theme_from.'/';
|
||||
@@ -246,8 +246,8 @@ class LanguageCore extends ObjectModel
|
||||
$mPath_to = _PS_MAIL_DIR_.(string)$iso_to.'/';
|
||||
}
|
||||
|
||||
$lFiles = array('admin'.'.php', 'errors'.'.php', 'fields'.'.php', 'pdf'.'.php');
|
||||
$mFiles = array('account.html', 'account.txt', 'bankwire.html', 'bankwire.txt',
|
||||
$lFiles = array('admin.php', 'errors.php', 'fields.php', 'pdf.php');
|
||||
$mFiles = array('account.html', 'account.txt', 'bankwire.html', 'bankwire.txt',
|
||||
'cheque.html', 'cheque.txt', 'contact.html', 'contact.txt', 'contact_form.html',
|
||||
'contact_form.txt', 'credit_slip.html', 'credit_slip.txt', 'download_product.html',
|
||||
'download_product.txt', 'download-product.tpl', 'employee_password.html', 'employee_password.txt',
|
||||
@@ -273,10 +273,10 @@ class LanguageCore extends ObjectModel
|
||||
// to an other theme for the same language,
|
||||
// it's avoid to copy Translations, Mails files
|
||||
// and modules files which are not override by theme.
|
||||
if (!$copy OR $iso_from != $iso_to)
|
||||
if (!$copy || $iso_from != $iso_to)
|
||||
{
|
||||
// Translations files
|
||||
if (!$check OR ($check AND (string)$iso_from != 'en'))
|
||||
if (!$check || ($check && (string)$iso_from != 'en'))
|
||||
foreach ($lFiles as $file)
|
||||
$files_tr[$lPath_from.$file] = ($copy ? $lPath_to.$file : ++$number);
|
||||
if ($select == 'tr')
|
||||
@@ -284,7 +284,7 @@ class LanguageCore extends ObjectModel
|
||||
$files = array_merge($files, $files_tr);
|
||||
|
||||
// Mail files
|
||||
if (!$check OR ($check AND (string)$iso_from != 'en'))
|
||||
if (!$check || ($check && (string)$iso_from != 'en'))
|
||||
$files_mail[$mPath_from.'lang.php'] = ($copy ? $mPath_to.'lang.php' : ++$number);
|
||||
foreach ($mFiles as $file)
|
||||
$files_mail[$mPath_from.$file] = ($copy ? $mPath_to.$file : ++$number);
|
||||
@@ -309,7 +309,7 @@ class LanguageCore extends ObjectModel
|
||||
{
|
||||
$dirFiles = scandir($modMailDirFrom);
|
||||
foreach ($dirFiles as $file)
|
||||
if (file_exists($modMailDirFrom.'/'.$file) AND $file != '.' AND $file != '..' AND $file != '.svn')
|
||||
if (file_exists($modMailDirFrom.'/'.$file) && $file != '.' && $file != '..' && $file != '.svn')
|
||||
$files_modules[$modMailDirFrom.'/'.$file] = ($copy ? $modMailDirTo.'/'.$file : ++$number);
|
||||
}
|
||||
}
|
||||
@@ -318,18 +318,16 @@ class LanguageCore extends ObjectModel
|
||||
$files = array_merge($files, $files_modules);
|
||||
}
|
||||
}
|
||||
else if ($select == 'mail' OR $select == 'tr')
|
||||
{
|
||||
else if ($select == 'mail' || $select == 'tr')
|
||||
return $files;
|
||||
}
|
||||
|
||||
// Theme files
|
||||
if (!$check OR ($check AND (string)$iso_from != 'en'))
|
||||
if (!$check || ($check && (string)$iso_from != 'en'))
|
||||
{
|
||||
$files_theme[$tPath_from.'lang/'.(string)$iso_from.'.php'] = ($copy ? $tPath_to.'lang/'.(string)$iso_to.'.php' : ++$number);
|
||||
$module_theme_files = (file_exists($tPath_from.'modules/') ? scandir($tPath_from.'modules/') : array());
|
||||
foreach ($module_theme_files as $module)
|
||||
if ($module !== '.' AND $module != '..' AND $module !== '.svn' AND file_exists($tPath_from.'modules/'.$module.'/'.(string)$iso_from.'.php'))
|
||||
if ($module !== '.' && $module != '..' && $module !== '.svn' && file_exists($tPath_from.'modules/'.$module.'/'.(string)$iso_from.'.php'))
|
||||
$files_theme[$tPath_from.'modules/'.$module.'/'.(string)$iso_from.'.php'] = ($copy ? $tPath_to.'modules/'.$module.'/'.(string)$iso_to.'.php' : ++$number);
|
||||
}
|
||||
if ($select == 'theme')
|
||||
@@ -350,29 +348,30 @@ class LanguageCore extends ObjectModel
|
||||
$tables = Db::getInstance()->executeS('SHOW TABLES LIKE \''._DB_PREFIX_.'%_lang\' ');
|
||||
$langTables = array();
|
||||
|
||||
foreach($tables as $table)
|
||||
foreach($table as $t)
|
||||
foreach ($tables as $table)
|
||||
foreach ($table as $t)
|
||||
if ($t != _DB_PREFIX_.'configuration_lang')
|
||||
$langTables[] = $t;
|
||||
|
||||
Db::getInstance()->execute('SET @id_lang_default = (SELECT c.`value` FROM `'._DB_PREFIX_.'configuration` c WHERE c.`name` = \'PS_LANG_DEFAULT\' LIMIT 1)');
|
||||
$return = true;
|
||||
foreach($langTables as $name)
|
||||
foreach ($langTables as $name)
|
||||
{
|
||||
$fields = '';
|
||||
$columns = Db::getInstance()->executeS('SHOW COLUMNS FROM `'.$name.'`');
|
||||
foreach($columns as $column)
|
||||
foreach ($columns as $column)
|
||||
$fields .= $column['Field'].', ';
|
||||
$fields = rtrim($fields, ', ');
|
||||
preg_match('#^'.preg_quote(_DB_PREFIX_).'(.+)_lang$#i', $name, $m);
|
||||
$identifier = 'id_'.$m[1];
|
||||
|
||||
$sql = 'INSERT IGNORE INTO `'.$name.'` ('.$fields.') (SELECT ';
|
||||
foreach($columns as $column) {
|
||||
if ($identifier != $column['Field'] and $column['Field'] != 'id_lang')
|
||||
foreach ($columns as $column)
|
||||
{
|
||||
if ($identifier != $column['Field'] && $column['Field'] != 'id_lang')
|
||||
$sql .= '(SELECT `'.$column['Field'].'` FROM `'.$name.'` tl WHERE tl.`id_lang` = @id_lang_default AND tl.`'.$identifier.'` = `'.str_replace('_lang', '', $name).'`.`'.$identifier.'`), ';
|
||||
else
|
||||
$sql.= '`'.$column['Field'].'`, ';
|
||||
$sql .= '`'.$column['Field'].'`, ';
|
||||
}
|
||||
$sql = rtrim($sql, ', ');
|
||||
$sql .= ' FROM `'._DB_PREFIX_.'lang` CROSS JOIN `'.str_replace('_lang', '', $name).'`) ;';
|
||||
@@ -407,16 +406,16 @@ class LanguageCore extends ObjectModel
|
||||
|
||||
// Database translations deletion
|
||||
$result = Db::getInstance()->executeS('SHOW TABLES FROM `'._DB_NAME_.'`');
|
||||
foreach ($result AS $row)
|
||||
foreach ($result as $row)
|
||||
if (preg_match('/_lang/', $row['Tables_in_'._DB_NAME_]))
|
||||
if (!Db::getInstance()->execute('DELETE FROM `'.$row['Tables_in_'._DB_NAME_].'` WHERE `id_lang` = '.(int)($this->id)))
|
||||
if (!Db::getInstance()->execute('DELETE FROM `'.$row['Tables_in_'._DB_NAME_].'` WHERE `id_lang` = '.(int)$this->id))
|
||||
return false;
|
||||
|
||||
// Delete tags
|
||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'tag WHERE id_lang = '.(int)($this->id));
|
||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'tag WHERE id_lang = '.(int)$this->id);
|
||||
|
||||
// Delete search words
|
||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'search_word WHERE id_lang = '.(int)($this->id));
|
||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'search_word WHERE id_lang = '.(int)$this->id);
|
||||
|
||||
// Files deletion
|
||||
foreach (Language::getFilesList($this->iso_code, _THEME_NAME_, false, false, false, true, true) as $key => $file)
|
||||
@@ -430,7 +429,7 @@ class LanguageCore extends ObjectModel
|
||||
if (count($files) <= 2)
|
||||
Language::recurseDeleteDir(_PS_MODULE_DIR_.$mod.'/mails/');
|
||||
|
||||
if(file_exists(_PS_MODULE_DIR_.$mod.'/'.$this->iso_code.'.php'))
|
||||
if (file_exists(_PS_MODULE_DIR_.$mod.'/'.$this->iso_code.'.php'))
|
||||
{
|
||||
unlink(_PS_MODULE_DIR_.$mod.'/'.$this->iso_code.'.php');
|
||||
$files = @scandir(_PS_MODULE_DIR_.$mod);
|
||||
@@ -449,8 +448,8 @@ class LanguageCore extends ObjectModel
|
||||
// delete images
|
||||
$files_copy = array('/en.jpg', '/en-default-thickbox.jpg', '/en-default-home.jpg', '/en-default-large.jpg', '/en-default-medium.jpg', '/en-default-small.jpg', '/en-default-large_scene.jpg');
|
||||
$tos = array(_PS_CAT_IMG_DIR_, _PS_MANU_IMG_DIR_, _PS_PROD_IMG_DIR_, _PS_SUPP_IMG_DIR_);
|
||||
foreach($tos AS $to)
|
||||
foreach($files_copy AS $file)
|
||||
foreach ($tos as $to)
|
||||
foreach ($files_copy as $file)
|
||||
{
|
||||
$name = str_replace('/en', ''.$this->iso_code, $file);
|
||||
|
||||
@@ -473,7 +472,7 @@ class LanguageCore extends ObjectModel
|
||||
foreach ($selection as $id)
|
||||
{
|
||||
$this->id = (int)($id);
|
||||
$result = $result AND $this->delete();
|
||||
$result = $result && $this->delete();
|
||||
}
|
||||
|
||||
Tools::generateHtaccess();
|
||||
@@ -492,9 +491,9 @@ class LanguageCore extends ObjectModel
|
||||
Language::loadLanguages();
|
||||
|
||||
$languages = array();
|
||||
foreach (self::$_LANGUAGES AS $language)
|
||||
foreach (self::$_LANGUAGES as $language)
|
||||
{
|
||||
if ($active AND !$language['active'] OR ($id_shop AND !isset($language['shops'][(int)$id_shop])))
|
||||
if ($active && !$language['active'] || ($id_shop && !isset($language['shops'][(int)$id_shop])))
|
||||
continue;
|
||||
$languages[] = $language;
|
||||
}
|
||||
@@ -557,19 +556,19 @@ class LanguageCore extends ObjectModel
|
||||
public static function copyLanguageData($from, $to)
|
||||
{
|
||||
$result = Db::getInstance()->executeS('SHOW TABLES FROM `'._DB_NAME_.'`');
|
||||
foreach ($result AS $row)
|
||||
if (preg_match('/_lang/', $row['Tables_in_'._DB_NAME_]) AND $row['Tables_in_'._DB_NAME_] != _DB_PREFIX_.'lang')
|
||||
foreach ($result as $row)
|
||||
if (preg_match('/_lang/', $row['Tables_in_'._DB_NAME_]) && $row['Tables_in_'._DB_NAME_] != _DB_PREFIX_.'lang')
|
||||
{
|
||||
$result2 = Db::getInstance()->executeS('SELECT * FROM `'.$row['Tables_in_'._DB_NAME_].'` WHERE `id_lang` = '.(int)($from));
|
||||
if (!sizeof($result2))
|
||||
$result2 = Db::getInstance()->executeS('SELECT * FROM `'.$row['Tables_in_'._DB_NAME_].'` WHERE `id_lang` = '.(int)$from);
|
||||
if (!count($result2))
|
||||
continue;
|
||||
Db::getInstance()->execute('DELETE FROM `'.$row['Tables_in_'._DB_NAME_].'` WHERE `id_lang` = '.(int)($to));
|
||||
Db::getInstance()->execute('DELETE FROM `'.$row['Tables_in_'._DB_NAME_].'` WHERE `id_lang` = '.(int)$to);
|
||||
$query = 'INSERT INTO `'.$row['Tables_in_'._DB_NAME_].'` VALUES ';
|
||||
foreach ($result2 AS $row2)
|
||||
foreach ($result2 as $row2)
|
||||
{
|
||||
$query .= '(';
|
||||
$row2['id_lang'] = $to;
|
||||
foreach ($row2 AS $field)
|
||||
foreach ($row2 as $field)
|
||||
$query .= '\''.pSQL($field, true).'\',';
|
||||
$query = rtrim($query, ',').'),';
|
||||
}
|
||||
@@ -591,7 +590,7 @@ class LanguageCore extends ObjectModel
|
||||
LEFT JOIN `'._DB_PREFIX_.'lang_shop` ls ON (l.id_lang = ls.id_lang)';
|
||||
|
||||
$result = Db::getInstance()->executeS($sql);
|
||||
foreach ($result AS $row)
|
||||
foreach ($result as $row)
|
||||
{
|
||||
if (!isset(self::$_LANGUAGES[(int)$row['id_lang']]))
|
||||
self::$_LANGUAGES[(int)$row['id_lang']] = $row;
|
||||
@@ -613,7 +612,7 @@ class LanguageCore extends ObjectModel
|
||||
return true;
|
||||
else
|
||||
{
|
||||
if(@fsockopen('api.prestashop.com', 80))
|
||||
if (@fsockopen('api.prestashop.com', 80))
|
||||
{
|
||||
$lang = new Language();
|
||||
$lang->iso_code = $iso_code;
|
||||
@@ -626,14 +625,14 @@ class LanguageCore extends ObjectModel
|
||||
&& isset($lang_pack->iso_code))
|
||||
$lang->name = $lang_pack->name;
|
||||
}
|
||||
if (!$lang->name OR !$lang->add())
|
||||
if (!$lang->name || !$lang->add())
|
||||
return false;
|
||||
$insert_id = (int)($lang->id);
|
||||
$insert_id = (int)$lang->id;
|
||||
|
||||
if ($lang_pack)
|
||||
{
|
||||
$flag = Tools::file_get_contents('http://api.prestashop.com/download/lang_packs/flags/jpeg/'.$iso_code.'.jpg');
|
||||
if ($flag != NULL && !preg_match('/<body>/', $flag))
|
||||
if ($flag != null && !preg_match('/<body>/', $flag))
|
||||
{
|
||||
$file = fopen(dirname(__FILE__).'/../img/l/'.$insert_id.'.jpg', 'w');
|
||||
if ($file)
|
||||
@@ -652,8 +651,8 @@ class LanguageCore extends ObjectModel
|
||||
|
||||
$files_copy = array('/en.jpg', '/en-default-thickbox.jpg', '/en-default-home.jpg', '/en-default-large.jpg', '/en-default-medium.jpg', '/en-default-small.jpg', '/en-default-large_scene.jpg');
|
||||
$tos = array(_PS_CAT_IMG_DIR_, _PS_MANU_IMG_DIR_, _PS_PROD_IMG_DIR_, _PS_SUPP_IMG_DIR_);
|
||||
foreach($tos AS $to)
|
||||
foreach($files_copy AS $file)
|
||||
foreach ($tos as $to)
|
||||
foreach ($files_copy as $file)
|
||||
{
|
||||
$name = str_replace('/en', '/'.$iso_code, $file);
|
||||
copy(dirname(__FILE__).'/../img/l'.$file, $to.$name);
|
||||
|
||||
+12
-12
@@ -196,7 +196,7 @@ class LinkCore
|
||||
*/
|
||||
public function getCMSLink($cms, $alias = null, $ssl = false, $id_lang = null)
|
||||
{
|
||||
$base = (($ssl AND Configuration::get('PS_SSL_ENABLED')) ? Tools::getShopDomainSsl(true) : Tools::getShopDomain(true));
|
||||
$base = (($ssl && Configuration::get('PS_SSL_ENABLED')) ? Tools::getShopDomainSsl(true) : Tools::getShopDomain(true));
|
||||
|
||||
if (!$id_lang)
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
@@ -369,7 +369,7 @@ class LinkCore
|
||||
unset($request['controller']);
|
||||
|
||||
$uri_path = Dispatcher::getInstance()->createUrl($controller, $request);
|
||||
$url = ($ssl AND Configuration::get('PS_SSL_ENABLED')) ? Tools::getShopDomainSsl(true) : Tools::getShopDomain(true);
|
||||
$url = ($ssl && Configuration::get('PS_SSL_ENABLED')) ? Tools::getShopDomainSsl(true) : Tools::getShopDomain(true);
|
||||
$url .= __PS_BASE_URI__.$this->getLangLink($id_lang).ltrim($uri_path, '/');
|
||||
|
||||
return $url;
|
||||
@@ -412,7 +412,7 @@ class LinkCore
|
||||
|
||||
public function goPage($url, $p)
|
||||
{
|
||||
return $url.($p == 1 ? '' : (!strstr($url, '?') ? '?' : '&').'p='.(int)($p));
|
||||
return $url.($p == 1 ? '' : (!strstr($url, '?') ? '?' : '&').'p='.(int)$p);
|
||||
}
|
||||
|
||||
public function getPaginationLink($type, $id_object, $nb = false, $sort = false, $pagination = false, $array = false)
|
||||
@@ -426,9 +426,9 @@ class LinkCore
|
||||
$url = $this->getPageLink(basename($url));
|
||||
}
|
||||
$vars = (!$array) ? '' : array();
|
||||
$varsNb = array('n', 'search_query');
|
||||
$varsSort = array('orderby', 'orderway');
|
||||
$varsPagination = array('p');
|
||||
$vars_nb = array('n', 'search_query');
|
||||
$vars_sort = array('orderby', 'orderway');
|
||||
$vars_pagination = array('p');
|
||||
|
||||
$n = 0;
|
||||
foreach ($_GET as $k => $value)
|
||||
@@ -436,10 +436,10 @@ class LinkCore
|
||||
{
|
||||
if (Configuration::get('PS_REWRITING_SETTINGS') && ($k == 'isolang' || $k == 'id_lang'))
|
||||
continue;
|
||||
$ifNb = (!$nb || ($nb && !in_array($k, $varsNb)));
|
||||
$ifSort = (!$sort || ($sort && !in_array($k, $varsSort)));
|
||||
$ifPagination = (!$pagination || ($pagination && !in_array($k, $varsPagination)));
|
||||
if ($ifNb && $ifSort && $ifPagination && !is_array($value))
|
||||
$if_nb = (!$nb || ($nb && !in_array($k, $vars_nb)));
|
||||
$if_sort = (!$sort || ($sort && !in_array($k, $vars_sort)));
|
||||
$if_pagination = (!$pagination || ($pagination && !in_array($k, $vars_pagination)));
|
||||
if ($if_nb && $if_sort && $if_pagination && !is_array($value))
|
||||
!$array ? ($vars .= ((!$n++ && ($this->allow == 1 || $url == $this->url)) ? '?' : '&').urlencode($k).'='.urlencode($value)) : ($vars[urlencode($k)] = urlencode($value));
|
||||
}
|
||||
if (!$array)
|
||||
@@ -455,11 +455,11 @@ class LinkCore
|
||||
return $url.(!strstr($url, '?') ? '?' : '&').'orderby='.urlencode($orderby).'&orderway='.urlencode($orderway);
|
||||
}
|
||||
|
||||
protected function getLangLink($id_lang = NULL, Context $context = null)
|
||||
protected function getLangLink($id_lang = null, Context $context = null)
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
if (!$this->allow OR !Language::isMultiLanguageActivated())
|
||||
if (!$this->allow || !Language::isMultiLanguageActivated())
|
||||
return '';
|
||||
|
||||
if (!$id_lang)
|
||||
|
||||
@@ -34,15 +34,15 @@ class LocalizationPackCore
|
||||
|
||||
protected $iso_code_lang;
|
||||
protected $iso_currency;
|
||||
protected $_errors = array();
|
||||
protected $_errors = array();
|
||||
|
||||
public function loadLocalisationPack($file, $selection, $install_mode = false)
|
||||
{
|
||||
if (!$xml = simplexml_load_string($file))
|
||||
return false;
|
||||
$mainAttributes = $xml->attributes();
|
||||
$this->name = strval($mainAttributes['name']);
|
||||
$this->version = strval($mainAttributes['version']);
|
||||
$main_attributes = $xml->attributes();
|
||||
$this->name = (string)$main_attributes['name'];
|
||||
$this->version = (string)$main_attributes['version'];
|
||||
if (empty($selection))
|
||||
{
|
||||
$res = true;
|
||||
@@ -54,13 +54,13 @@ class LocalizationPackCore
|
||||
$res &= $this->installModules($xml);
|
||||
$res &= $this->updateDefaultGroupDisplayMethod($xml);
|
||||
|
||||
if (!defined('_PS_MODE_DEV_') OR !_PS_MODE_DEV_)
|
||||
if (!defined('_PS_MODE_DEV_') || !_PS_MODE_DEV_)
|
||||
$res &= $this->_installLanguages($xml, $install_mode);
|
||||
|
||||
if ($res AND isset($this->iso_code_lang))
|
||||
if ($res && isset($this->iso_code_lang))
|
||||
Configuration::updateValue('PS_LANG_DEFAULT', (int)Language::getIdByIso($this->iso_code_lang));
|
||||
|
||||
if ($install_mode AND $res AND isset($this->iso_currency))
|
||||
if ($install_mode && $res && isset($this->iso_currency))
|
||||
{
|
||||
$res &= Configuration::updateValue('PS_CURRENCY_DEFAULT', (int)Currency::getIdByIsoCode($this->iso_currency));
|
||||
Currency::refreshCurrencies();
|
||||
@@ -68,8 +68,8 @@ class LocalizationPackCore
|
||||
|
||||
return $res;
|
||||
}
|
||||
foreach ($selection AS $selected)
|
||||
if (!Validate::isLocalizationPackSelection($selected) OR !$this->{'_install'.ucfirst($selected)}($xml))
|
||||
foreach ($selection as $selected)
|
||||
if (!Validate::isLocalizationPackSelection($selected) || !$this->{'_install'.ucfirst($selected)}($xml))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -149,8 +149,8 @@ class LocalizationPackCore
|
||||
if (Tax::getTaxIdByName($attributes['name']))
|
||||
continue;
|
||||
$tax = new Tax();
|
||||
$tax->name[(int)(Configuration::get('PS_LANG_DEFAULT'))] = strval($attributes['name']);
|
||||
$tax->rate = (float)($attributes['rate']);
|
||||
$tax->name[(int)Configuration::get('PS_LANG_DEFAULT')] = (string)$attributes['name'];
|
||||
$tax->rate = (float)$attributes['rate'];
|
||||
$tax->active = 1;
|
||||
|
||||
if (!$tax->validateFields())
|
||||
@@ -161,7 +161,7 @@ class LocalizationPackCore
|
||||
|
||||
if (!$tax->add())
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('An error occurred while importing the tax: ').strval($attributes['name']);
|
||||
$this->_errors[] = Tools::displayError('An error occurred while importing the tax: ').(string)$attributes['name'];
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -238,26 +238,27 @@ class LocalizationPackCore
|
||||
{
|
||||
if (isset($xml->currencies->currency))
|
||||
{
|
||||
if (!$feed = Tools::simplexml_load_file('http://api.prestashop.com/xml/currencies.xml') AND !$feed = @simplexml_load_file(dirname(__FILE__).'/../localization/currencies.xml'))
|
||||
if (!$feed = Tools::simplexml_load_file('http://api.prestashop.com/xml/currencies.xml')
|
||||
&& !$feed = @simplexml_load_file(dirname(__FILE__).'/../localization/currencies.xml'))
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('Cannot parse the currencies XML feed.');
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($xml->currencies->currency AS $data)
|
||||
foreach ($xml->currencies->currency as $data)
|
||||
{
|
||||
$attributes = $data->attributes();
|
||||
if(Currency::exists($attributes['iso_code']))
|
||||
if (Currency::exists($attributes['iso_code']))
|
||||
continue;
|
||||
$currency = new Currency();
|
||||
$currency->name = strval($attributes['name']);
|
||||
$currency->iso_code = strval($attributes['iso_code']);
|
||||
$currency->iso_code_num = (int)($attributes['iso_code_num']);
|
||||
$currency->sign = strval($attributes['sign']);
|
||||
$currency->blank = (int)($attributes['blank']);
|
||||
$currency->name = (string)$attributes['name'];
|
||||
$currency->iso_code = (string)$attributes['iso_code'];
|
||||
$currency->iso_code_num = (int)$attributes['iso_code_num'];
|
||||
$currency->sign = (string)$attributes['sign'];
|
||||
$currency->blank = (int)$attributes['blank'];
|
||||
$currency->conversion_rate = 1; // This value will be updated if the store is online
|
||||
$currency->format = (int)($attributes['format']);
|
||||
$currency->decimals = (int)($attributes['decimals']);
|
||||
$currency->format = (int)$attributes['format'];
|
||||
$currency->decimals = (int)$attributes['decimals'];
|
||||
$currency->active = $install_mode;
|
||||
if (!$currency->validateFields())
|
||||
{
|
||||
@@ -278,7 +279,7 @@ class LocalizationPackCore
|
||||
|
||||
Currency::refreshCurrencies();
|
||||
|
||||
if (!sizeof($this->_errors) AND $install_mode AND isset($attributes['iso_code']) AND sizeof($xml->currencies->currency) == 1)
|
||||
if (!count($this->_errors) && $install_mode && isset($attributes['iso_code']) && count($xml->currencies->currency) == 1)
|
||||
$this->iso_currency = $attributes['iso_code'];
|
||||
}
|
||||
|
||||
@@ -289,19 +290,20 @@ class LocalizationPackCore
|
||||
{
|
||||
$attributes = array();
|
||||
if (isset($xml->languages->language))
|
||||
foreach ($xml->languages->language AS $data)
|
||||
foreach ($xml->languages->language as $data)
|
||||
{
|
||||
$attributes = $data->attributes();
|
||||
if (Language::getIdByIso($attributes['iso_code']))
|
||||
continue;
|
||||
$native_lang = Language::getLanguages();
|
||||
$native_iso_code = array();
|
||||
foreach ($native_lang AS $lang)
|
||||
foreach ($native_lang as $lang)
|
||||
$native_iso_code[] = $lang['iso_code'];
|
||||
if ((in_array((string)$attributes['iso_code'], $native_iso_code) AND !$install_mode) OR !in_array((string)$attributes['iso_code'], $native_iso_code))
|
||||
if ((in_array((string)$attributes['iso_code'], $native_iso_code) && !$install_mode)
|
||||
|| !in_array((string)$attributes['iso_code'], $native_iso_code))
|
||||
$errno = 0;
|
||||
$errstr = '';
|
||||
if(@fsockopen('api.prestashop.com', 80, $errno, $errstr, 10))
|
||||
if (@fsockopen('api.prestashop.com', 80, $errno, $errstr, 10))
|
||||
{
|
||||
if ($lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://api.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$attributes['iso_code'])))
|
||||
{
|
||||
@@ -338,7 +340,7 @@ class LocalizationPackCore
|
||||
}
|
||||
|
||||
// change the default language if there is only one language in the localization pack
|
||||
if (!sizeof($this->_errors) AND $install_mode AND isset($attributes['iso_code']) AND sizeof($xml->languages->language) == 1)
|
||||
if (!count($this->_errors) && $install_mode && isset($attributes['iso_code']) && count($xml->languages->language) == 1)
|
||||
$this->iso_code_lang = $attributes['iso_code'];
|
||||
|
||||
return true;
|
||||
@@ -348,7 +350,7 @@ class LocalizationPackCore
|
||||
{
|
||||
$varNames = array('weight' => 'PS_WEIGHT_UNIT', 'volume' => 'PS_VOLUME_UNIT', 'short_distance' => 'PS_DIMENSION_UNIT', 'base_distance' => 'PS_BASE_DISTANCE_UNIT', 'long_distance' => 'PS_DISTANCE_UNIT');
|
||||
if (isset($xml->units->unit))
|
||||
foreach ($xml->units->unit AS $data)
|
||||
foreach ($xml->units->unit as $data)
|
||||
{
|
||||
$attributes = $data->attributes();
|
||||
if (!isset($varNames[strval($attributes['type'])]))
|
||||
@@ -373,7 +375,7 @@ class LocalizationPackCore
|
||||
protected function installModules($xml)
|
||||
{
|
||||
if (isset($xml->modules))
|
||||
foreach($xml->modules->module as $data)
|
||||
foreach ($xml->modules->module as $data)
|
||||
{
|
||||
$attributes = $data->attributes();
|
||||
$name = (string)$attributes['name'];
|
||||
@@ -385,17 +387,17 @@ class LocalizationPackCore
|
||||
{
|
||||
if (!Module::isInstalled($name))
|
||||
if (!$module->install())
|
||||
$this->_errors[] = Tools::displayError('An error has occured during the module installation: '). $name;
|
||||
$this->_errors[] = Tools::displayError('An error has occured during the module installation: ').$name;
|
||||
}
|
||||
else
|
||||
if (Module::isInstalled($name))
|
||||
if (!$module->uninstall())
|
||||
$this->_errors[] = Tools::displayError('An error has occured during the module uninstall: '). $name;
|
||||
$this->_errors[] = Tools::displayError('An error has occured during the module uninstall: ').$name;
|
||||
|
||||
unset($module);
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('An error has occured, this module doesnt exists: '). $name;
|
||||
$this->_errors[] = Tools::displayError('An error has occured, this module doesnt exists: ').$name;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -409,14 +411,14 @@ class LocalizationPackCore
|
||||
protected function installConfiguration($xml)
|
||||
{
|
||||
if (isset($xml->configurations))
|
||||
foreach($xml->configurations->configuration as $data)
|
||||
foreach ($xml->configurations->configuration as $data)
|
||||
{
|
||||
$attributes = $data->attributes();
|
||||
$name = (string)$attributes['name'];
|
||||
|
||||
if (isset($name) && isset($attributes['value']) && Configuration::get($name) !== false)
|
||||
if (!Configuration::updateValue($name, (string)$attributes['value']))
|
||||
$this->_errors[] = Tools::displayError('An error has occured during the configuration setup: '. $name);
|
||||
$this->_errors[] = Tools::displayError('An error has occured during the configuration setup: '.$name);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user