diff --git a/classes/Accounting.php b/classes/Accounting.php
index 89f8f465c..2c6fa208e 100644
--- a/classes/Accounting.php
+++ b/classes/Accounting.php
@@ -42,8 +42,8 @@ class AccountingCore
$values = '';
// Build the query for the update
- foreach($assoZoneShopList as $asso)
- if (array_key_exists('id_zone', $asso) &&
+ foreach ($assoZoneShopList as $asso)
+ if (array_key_exists('id_zone', $asso) &&
array_key_exists('id_shop', $asso) &&
array_key_exists('num', $asso))
$values .= '('.(int)$asso['id_zone'].','.(int)$asso['id_shop'].', \''.pSQL($asso['num']).'\'), ';
@@ -67,8 +67,8 @@ class AccountingCore
VALUES %s';
$values = '';
- foreach($assoProductZoneShop as $asso)
- if (array_key_exists('id_zone', $asso) &&
+ foreach ($assoProductZoneShop as $asso)
+ if (array_key_exists('id_zone', $asso) &&
array_key_exists('id_shop', $asso) &&
array_key_exists('id_product', $asso) &&
array_key_exists('num', $asso))
diff --git a/classes/AddressFormat.php b/classes/AddressFormat.php
index c8afe583a..aba9c6667 100644
--- a/classes/AddressFormat.php
+++ b/classes/AddressFormat.php
@@ -117,7 +117,7 @@ class AddressFormatCore extends ObjectModel
// Check if the property is accessible
$publicProperties = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
- foreach($publicProperties as $property)
+ foreach ($publicProperties as $property)
{
$propertyName = $property->getName();
if (($propertyName == $fieldName) && ($isIdField ||
@@ -195,12 +195,12 @@ class AddressFormatCore extends ObjectModel
$multipleLineFields = explode("\n", $this->format);
if ($multipleLineFields && is_array($multipleLineFields))
- foreach($multipleLineFields as $lineField)
+ foreach ($multipleLineFields as $lineField)
{
if (($patternsName = preg_split(self::_CLEANING_REGEX_, $lineField, -1, PREG_SPLIT_NO_EMPTY)))
if (is_array($patternsName))
{
- foreach($patternsName as $patternName)
+ foreach ($patternsName as $patternName)
{
if (!in_array($patternName, $usedKeyList))
{
@@ -234,13 +234,13 @@ class AddressFormatCore extends ObjectModel
if ($currentKeyList && is_array($currentKeyList))
if ($originalFormattedPatternList = explode(' ', $currentLine))
// Foreach the available pattern
- foreach($originalFormattedPatternList as $patternNum => $pattern)
+ foreach ($originalFormattedPatternList as $patternNum => $pattern)
{
// Var allows to modify the good formatted key value when multiple key exist into the same pattern
$mainFormattedKey = '';
// Multiple key can be found in the same pattern
- foreach($currentKeyList as $key)
+ foreach ($currentKeyList as $key)
{
// Check if we need to use an older modified pattern if a key has already be matched before
$replacedValue = empty($mainFormattedKey) ? $pattern : $formattedValueList[$mainFormattedKey];
@@ -266,12 +266,12 @@ class AddressFormatCore extends ObjectModel
*/
public static function cleanOrderedAddress(&$orderedAddressField)
{
- foreach($orderedAddressField as &$line)
+ foreach ($orderedAddressField as &$line)
{
$cleanedLine = '';
if (($keyList = preg_split(self::_CLEANING_REGEX_, $line, -1, PREG_SPLIT_NO_EMPTY)))
{
- foreach($keyList as $key)
+ foreach ($keyList as $key)
$cleanedLine .= $key.' ';
$cleanedLine = trim($cleanedLine);
$line = $cleanedLine;
@@ -295,11 +295,11 @@ class AddressFormatCore extends ObjectModel
// Check if $address exist and it's an instanciate object of Address
if ($address && ($address instanceof Address))
- foreach($addressFormat as $line)
+ foreach ($addressFormat as $line)
{
if (($keyList = preg_split(self::_CLEANING_REGEX_, $line, -1, PREG_SPLIT_NO_EMPTY)) && is_array($keyList))
{
- foreach($keyList as $pattern)
+ foreach ($keyList as $pattern)
if ($associateName = explode(':', $pattern))
{
$totalName = count($associateName);
@@ -331,7 +331,7 @@ class AddressFormatCore extends ObjectModel
}
AddressFormat::cleanOrderedAddress($addressFormat);
// Free the instanciate objects
- foreach($temporyObject as &$object)
+ foreach ($temporyObject as &$object)
unset($object);
return $tab;
}
@@ -354,7 +354,7 @@ class AddressFormatCore extends ObjectModel
if (($patternsList = preg_split(self::_CLEANING_REGEX_, $line, -1, PREG_SPLIT_NO_EMPTY)))
{
$tmpText = '';
- foreach($patternsList as $pattern)
+ foreach ($patternsList as $pattern)
if ((!array_key_exists('avoid', $patternRules)) ||
(array_key_exists('avoid', $patternRules) && !in_array($pattern, $patternRules['avoid'])))
$tmpText .= (isset($addressFormatedValues[$pattern]) && !empty($addressFormatedValues[$pattern])) ?
@@ -397,7 +397,7 @@ class AddressFormatCore extends ObjectModel
// Check if the property is accessible
$publicProperties = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
- foreach($publicProperties as $property)
+ foreach ($publicProperties as $property)
{
$propertyName = $property->getName();
if ((!in_array($propertyName, AddressFormat::$forbiddenPropertyList)) &&
@@ -424,7 +424,7 @@ class AddressFormatCore extends ObjectModel
// Get all the name object liable to the Address class
$publicProperties = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
- foreach($publicProperties as $property)
+ foreach ($publicProperties as $property)
{
$propertyName = $property->getName();
if (preg_match('#id_\w#', $propertyName) && strlen($propertyName) > 3)
@@ -457,7 +457,7 @@ class AddressFormatCore extends ObjectModel
if ($cleaned)
$keyList = ($cleaned) ? preg_split(self::_CLEANING_REGEX_, $field_item, -1, PREG_SPLIT_NO_EMPTY) :
explode(' ', $field_item);
- foreach($keyList as $word_item)
+ foreach ($keyList as $word_item)
$out[] = trim($word_item);
}
else
@@ -490,8 +490,7 @@ class AddressFormatCore extends ObjectModel
*/
public static function getAddressCountryFormat($id_country = 0)
{
- $out = '';
- $id_country = (int) $id_country;
+ $id_country = (int)$id_country;
$tmp_obj = new AddressFormat();
$tmp_obj->id_country = $id_country;
diff --git a/classes/AdminController.php b/classes/AdminController.php
index 1051cc21a..59496c045 100644
--- a/classes/AdminController.php
+++ b/classes/AdminController.php
@@ -661,9 +661,8 @@ class AdminControllerCore extends Controller
}
$this->errors = array_unique($this->errors);
- if (count($this->errors) > 0) {
+ if (count($this->errors) > 0)
return;
- }
return $object;
}
@@ -1915,7 +1914,7 @@ class AdminControllerCore extends Controller
$this->boxes = Tools::getValue($this->table.'Box');
break;
}
- else if(Tools::isSubmit('submitBulk'))
+ else if (Tools::isSubmit('submitBulk'))
{
$this->action = 'bulk'.Tools::getValue('select_submitBulk');
$this->boxes = Tools::getValue($this->table.'Box');
@@ -2235,12 +2234,16 @@ class AdminControllerCore extends Controller
/**
* Overload this method for custom checking
*/
- protected function _childValidation(){}
+ protected function _childValidation()
+ {
+ }
/**
* Display object details
*/
- public function viewDetails(){}
+ public function viewDetails()
+ {
+ }
/**
* Called before deletion
@@ -2429,7 +2432,7 @@ class AdminControllerCore extends Controller
$max_size = isset($this->max_image_size) ? $this->max_image_size : 0;
if ($error = ImageManager::validateUpload($_FILES[$name], Tools::getMaxUploadSize($max_size)))
$this->errors[] = $error;
- else if (!$tmp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS') || !move_uploaded_file($_FILES[$name]['tmp_name'], $tmp_name))
+ else if (!($tmp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !move_uploaded_file($_FILES[$name]['tmp_name'], $tmp_name))
return false;
else
{
diff --git a/classes/Autoload.php b/classes/Autoload.php
index 367993212..85f3d60c7 100644
--- a/classes/Autoload.php
+++ b/classes/Autoload.php
@@ -80,8 +80,7 @@ class Autoload
// regenerate the class index if the requested class is not found in the index or if the requested file doesn't exists
if (!isset($this->index[$classname])
|| ($this->index[$classname] && !is_file($this->root_dir.$this->index[$classname]))
- || (isset($this->index[$classname.'Core']) && $this->index[$classname.'Core'] && !is_file($this->root_dir.$this->index[$classname]))
- )
+ || (isset($this->index[$classname.'Core']) && $this->index[$classname.'Core'] && !is_file($this->root_dir.$this->index[$classname])))
$this->generateIndex();
// If $classname has not core suffix (E.g. Shop, Product)
diff --git a/classes/Backup.php b/classes/Backup.php
index d34b1b9e5..f98a07dee 100644
--- a/classes/Backup.php
+++ b/classes/Backup.php
@@ -34,7 +34,7 @@ class BackupCore
/** @var string default backup directory. */
public static $backupDir = '/backups/';
/** @var string custom backup directory. */
- public $customBackupDir = NULL;
+ public $customBackupDir = null;
public $psBackupAll = true;
public $psBackupDropTable = true;
@@ -44,7 +44,7 @@ class BackupCore
*
* @param string $filename Filename of the backup file
*/
- public function __construct($filename = NULL)
+ public function __construct($filename = null)
{
if ($filename)
$this->id = $this->getRealBackupPath($filename);
@@ -64,8 +64,8 @@ class BackupCore
*/
public function setCustomBackupPath($dir)
{
- $customDir = DIRECTORY_SEPARATOR.trim($dir,'/').DIRECTORY_SEPARATOR;
- if(is_dir(_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.$customDir.DIRECTORY_SEPARATOR))
+ $customDir = DIRECTORY_SEPARATOR.trim($dir, '/').DIRECTORY_SEPARATOR;
+ if (is_dir(_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.$customDir.DIRECTORY_SEPARATOR))
$this->customBackupDir = $customDir;
else
return false;
@@ -80,14 +80,14 @@ class BackupCore
* @param string $filename filename to use
* @return string full path
*/
- public function getRealBackupPath($filename = NULL)
+ public function getRealBackupPath($filename = null)
{
$backupDir = Backup::getBackupPath($filename);
if (!empty($this->customBackupDir))
{
$backupDir = str_replace(_PS_ADMIN_DIR_.self::$backupDir, _PS_ADMIN_DIR_.$this->customBackupDir, $backupDir);
- if(strrpos($backupDir,DIRECTORY_SEPARATOR))
+ if (strrpos($backupDir, DIRECTORY_SEPARATOR))
$backupDir .= DIRECTORY_SEPARATOR;
}
return $backupDir;
@@ -106,12 +106,12 @@ class BackupCore
die(Tools::displayError('Backups directory does not exist.'));
// Check the realpath so we can validate the backup file is under the backup directory
- if(!empty($filename))
- $backupfile = realpath($backupdir.'/'.$filename);
+ if (!empty($filename))
+ $backupfile = realpath($backupdir.'/'.$filename);
else
$backupfile = $backupdir.DIRECTORY_SEPARATOR;
- if ($backupfile === false OR strncmp($backupdir, $backupfile, strlen($backupdir)) != 0)
+ if ($backupfile === false || strncmp($backupdir, $backupfile, strlen($backupdir)) != 0)
die (Tools::displayError());
return $backupfile;
@@ -197,19 +197,19 @@ class BackupCore
if ($fp === false)
{
- echo Tools::displayError('Unable to create backup file') . ' "' . addslashes($backupfile) . '"';
+ echo Tools::displayError('Unable to create backup file').' "'.addslashes($backupfile).'"';
return false;
}
$this->id = realpath($backupfile);
- fwrite($fp, '/* Backup for ' . Tools::getHttpHost(false, false) . __PS_BASE_URI__ . "\n * at " . date($date) . "\n */\n");
+ fwrite($fp, '/* Backup for '.Tools::getHttpHost(false, false).__PS_BASE_URI__."\n * at ".date($date)."\n */\n");
fwrite($fp, "\n".'SET NAMES \'utf8\';'."\n\n");
// Find all tables
$tables = Db::getInstance()->executeS('SHOW TABLES');
$found = 0;
- foreach ($tables AS $table)
+ foreach ($tables as $table)
{
$table = current($table);
@@ -218,7 +218,7 @@ class BackupCore
continue;
// Export the table schema
- $schema = Db::getInstance()->executeS('SHOW CREATE TABLE `' . $table . '`');
+ $schema = Db::getInstance()->executeS('SHOW CREATE TABLE `'.$table.'`');
if (count($schema) != 1 || !isset($schema[0]['Table']) || !isset($schema[0]['Create Table']))
{
@@ -228,36 +228,36 @@ class BackupCore
return false;
}
- fwrite($fp, '/* Scheme for table ' . $schema[0]['Table'] . " */\n");
+ fwrite($fp, '/* Scheme for table '.$schema[0]['Table']." */\n");
if ($this->psBackupDropTable)
fwrite($fp, 'DROP TABLE IF EXISTS `'.$schema[0]['Table'].'`;'."\n");
- fwrite($fp, $schema[0]['Create Table'] . ";\n\n");
+ fwrite($fp, $schema[0]['Create Table'].";\n\n");
if (!in_array($schema[0]['Table'], $ignore_insert_table))
{
- $data = Db::getInstance()->query('SELECT * FROM `' . $schema[0]['Table'] . '`', false);
+ $data = Db::getInstance()->query('SELECT * FROM `'.$schema[0]['Table'].'`', false);
$sizeof = DB::getInstance()->NumRows();
$lines = explode("\n", $schema[0]['Create Table']);
- if ($data AND $sizeof > 0)
+ if ($data && $sizeof > 0)
{
// Export the table data
- fwrite($fp, 'INSERT INTO `' . $schema[0]['Table'] . "` VALUES\n");
+ fwrite($fp, 'INSERT INTO `'.$schema[0]['Table']."` VALUES\n");
$i = 1;
while ($row = DB::getInstance()->nextRow($data))
{
$s = '(';
- foreach ($row AS $field => $value)
+ foreach ($row as $field => $value)
{
- $tmp = "'" . pSQL($value) . "',";
- if($tmp != "'',")
+ $tmp = "'".pSQL($value)."',";
+ if ($tmp != "'',")
$s .= $tmp;
else
{
- foreach($lines AS $line)
+ foreach ($lines as $line)
if (strpos($line, '`'.$field.'`') !== false)
{
if (preg_match('/(.*NOT NULL.*)/Ui', $line))
@@ -270,7 +270,7 @@ class BackupCore
}
$s = rtrim($s, ',');
- if ($i%200 == 0 AND $i < $sizeof)
+ if ($i % 200 == 0 && $i < $sizeof)
$s .= ");\nINSERT INTO `".$schema[0]['Table']."` VALUES\n";
elseif ($i < $sizeof)
$s .= "),\n";
diff --git a/classes/CMS.php b/classes/CMS.php
index bf9f7e463..ae3a59b19 100644
--- a/classes/CMS.php
+++ b/classes/CMS.php
@@ -63,15 +63,15 @@ class CMSCore extends ObjectModel
'objectsNodeName' => 'content_management_system',
);
- public function add($autodate = true, $nullValues = false)
+ public function add($autodate = true, $null_values = false)
{
$this->position = CMS::getLastPosition((int)$this->id_cms_category);
return parent::add($autodate, true);
}
- public function update($nullValues = false)
+ public function update($null_values = false)
{
- if (parent::update($nullValues))
+ if (parent::update($null_values))
return $this->cleanPositions($this->id_cms_category);
return false;
}
@@ -90,7 +90,7 @@ class CMSCore extends ObjectModel
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.id_cms, cl.link_rewrite, cl.meta_title
FROM '._DB_PREFIX_.'cms c
- LEFT JOIN '._DB_PREFIX_.'cms_lang cl ON (c.id_cms = cl.id_cms AND cl.id_lang = '.(int)($id_lang).')
+ LEFT JOIN '._DB_PREFIX_.'cms_lang cl ON (c.id_cms = cl.id_cms AND cl.id_lang = '.(int)$id_lang.')
'.Context::getContext()->shop->addSqlAssociation('cms', 'c').'
WHERE 1
'.(($selection !== null) ? ' AND c.id_cms IN ('.implode(',', array_map('intval', $selection)).')' : '').
@@ -102,7 +102,7 @@ class CMSCore extends ObjectModel
if ($result)
foreach ($result as $row)
{
- $row['link'] = $link->getCMSLink((int)($row['id_cms']), $row['link_rewrite']);
+ $row['link'] = $link->getCMSLink((int)$row['id_cms'], $row['link_rewrite']);
$links[] = $row;
}
return $links;
@@ -119,7 +119,7 @@ class CMSCore extends ObjectModel
JOIN '._DB_PREFIX_.'cms_lang l ON (c.id_cms = l.id_cms)
'.Context::getContext()->shop->addSqlAssociation('cms', 'c').'
'.(($id_block) ? 'JOIN '._DB_PREFIX_.'block_cms b ON (c.id_cms = b.id_cms)' : '').'
- WHERE l.id_lang = '.(int)($id_lang).(($id_block) ? ' AND b.id_block = '.(int)($id_block) : '').($active ? ' AND c.`active` = 1 ' : '').'
+ WHERE l.id_lang = '.(int)$id_lang.(($id_block) ? ' AND b.id_block = '.(int)$id_block : '').($active ? ' AND c.`active` = 1 ' : '').'
GROUP BY c.id_cms
ORDER BY c.`position`');
}
@@ -135,10 +135,10 @@ class CMSCore extends ObjectModel
return false;
foreach ($res as $cms)
- if ((int)($cms['id_cms']) == (int)($this->id))
- $movedCms = $cms;
+ if ((int)$cms['id_cms'] == (int)$this->id)
+ $moved_cms = $cms;
- if (!isset($movedCms) || !isset($position))
+ if (!isset($moved_cms) || !isset($position))
return false;
// < and > statements rather than BETWEEN operator
@@ -148,14 +148,14 @@ class CMSCore extends ObjectModel
SET `position`= `position` '.($way ? '- 1' : '+ 1').'
WHERE `position`
'.($way
- ? '> '.(int)($movedCms['position']).' AND `position` <= '.(int)($position)
- : '< '.(int)($movedCms['position']).' AND `position` >= '.(int)($position)).'
- AND `id_cms_category`='.(int)($movedCms['id_cms_category']))
+ ? '> '.(int)$moved_cms['position'].' AND `position` <= '.(int)$position
+ : '< '.(int)$moved_cms['position'].' AND `position` >= '.(int)$position).'
+ AND `id_cms_category`='.(int)$moved_cms['id_cms_category'])
&& Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'cms`
- SET `position` = '.(int)($position).'
- WHERE `id_cms` = '.(int)($movedCms['id_cms']).'
- AND `id_cms_category`='.(int)($movedCms['id_cms_category'])));
+ SET `position` = '.(int)$position.'
+ WHERE `id_cms` = '.(int)$moved_cms['id_cms'].'
+ AND `id_cms_category`='.(int)$moved_cms['id_cms_category']));
}
public static function cleanPositions($id_category)
@@ -163,7 +163,7 @@ class CMSCore extends ObjectModel
$result = Db::getInstance()->executeS('
SELECT `id_cms`
FROM `'._DB_PREFIX_.'cms`
- WHERE `id_cms_category` = '.(int)($id_category).'
+ WHERE `id_cms_category` = '.(int)$id_category.'
ORDER BY `position`');
for ($i = 0, $total = count($result); $i < $total; ++$i)
{
@@ -178,7 +178,7 @@ class CMSCore extends ObjectModel
public static function getLastPosition($id_category)
{
- return (Db::getInstance()->getValue('SELECT MAX(position)+1 FROM `'._DB_PREFIX_.'cms` WHERE `id_cms_category` = '.(int)($id_category)));
+ return (Db::getInstance()->getValue('SELECT MAX(position)+1 FROM `'._DB_PREFIX_.'cms` WHERE `id_cms_category` = '.(int)$id_category));
}
public static function getCMSPages($id_lang = null, $id_cms_category = null, $active = true)
diff --git a/classes/CMSCategory.php b/classes/CMSCategory.php
index a348a29cd..8a1815856 100644
--- a/classes/CMSCategory.php
+++ b/classes/CMSCategory.php
@@ -95,43 +95,38 @@ class CMSCategoryCore extends ObjectModel
),
);
- public function __construct($id_cms_category = null, $id_lang = null)
- {
- parent::__construct($id_cms_category, $id_lang);
- }
-
- public function add($autodate = true, $nullValues = false)
+ public function add($autodate = true, $null_values = false)
{
$this->position = CMSCategory::getLastPosition((int)$this->id_parent);
$this->level_depth = $this->calcLevelDepth();
foreach ($this->name as $k => $value)
if (preg_match('/^[1-9]\./', $value))
$this->name[$k] = '0'.$value;
- $ret = parent::add($autodate);
+ $ret = parent::add($autodate, $null_values);
$this->cleanPositions($this->id_parent);
return $ret;
}
- public function update($nullValues = false)
+ public function update($null_values = false)
{
$this->level_depth = $this->calcLevelDepth();
foreach ($this->name as $k => $value)
if (preg_match('/^[1-9]\./', $value))
$this->name[$k] = '0'.$value;
- return parent::update();
+ return parent::update($null_values);
}
/**
* Recursive scan of subcategories
*
- * @param integer $maxDepth Maximum depth of the tree (i.e. 2 => 3 levels depth)
+ * @param integer $max_depth Maximum depth of the tree (i.e. 2 => 3 levels depth)
* @param integer $currentDepth specify the current depth in the tree (don't use it, only for rucursivity!)
- * @param array $excludedIdsArray specify a list of ids to exclude of results
+ * @param array $excluded_ids_array specify a list of ids to exclude of results
* @param integer $idLang Specify the id of the language used
*
* @return array Subcategories lite tree
*/
- public function recurseLiteCategTree($maxDepth = 3, $currentDepth = 0, $id_lang = null, $excludedIdsArray = null, Link $link = null)
+ public function recurseLiteCategTree($max_depth = 3, $currentDepth = 0, $id_lang = null, $excluded_ids_array = null, Link $link = null)
{
if (!$link)
$link = Context::getContext()->link;
@@ -142,16 +137,16 @@ class CMSCategoryCore extends ObjectModel
// recursivity for subcategories
$children = array();
$subcats = $this->getSubCategories($id_lang, true);
- if (($maxDepth == 0 || $currentDepth < $maxDepth) && $subcats && count($subcats))
+ if (($max_depth == 0 || $currentDepth < $max_depth) && $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($excluded_ids_array) || !in_array($subcat['id_cms_category'], $excluded_ids_array))
{
$categ = new CMSCategory($subcat['id_cms_category'], $id_lang);
$categ->name = CMSCategory::hideCMSCategoryPosition($categ->name);
- $children[] = $categ->recurseLiteCategTree($maxDepth, $currentDepth + 1, $id_lang, $excludedIdsArray);
+ $children[] = $categ->recurseLiteCategTree($max_depth, $currentDepth + 1, $id_lang, $excluded_ids_array);
}
}
@@ -208,8 +203,9 @@ class CMSCategoryCore extends ObjectModel
public static function recurseCMSCategory($categories, $current, $id_cms_category = 1, $id_selected = 1, $is_html = 0)
{
- $html = '';
+ $html = '';
if ($is_html == 0)
echo $html;
if (isset($categories[$id_cms_category]))
@@ -224,19 +220,19 @@ class CMSCategoryCore extends ObjectModel
* @param array &$toDelete Array reference where categories ID will be saved
* @param array $id_cms_category Parent CMSCategory ID
*/
- protected function recursiveDelete(&$toDelete, $id_cms_category)
+ protected function recursiveDelete(&$to_delete, $id_cms_category)
{
- if (!is_array($toDelete) || !$id_cms_category)
+ if (!is_array($to_delete) || !$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));
+ WHERE `id_parent` = '.(int)$id_cms_category);
foreach ($result as $row)
{
- $toDelete[] = (int)($row['id_cms_category']);
- $this->recursiveDelete($toDelete, (int)($row['id_cms_category']));
+ $to_delete[] = (int)$row['id_cms_category'];
+ $this->recursiveDelete($to_delete, (int)$row['id_cms_category']);
}
}
@@ -246,26 +242,26 @@ class CMSCategoryCore extends ObjectModel
$this->clearCache();
- /* Get childs categories */
- $toDelete = array((int)($this->id));
- $this->recursiveDelete($toDelete, (int)($this->id));
- $toDelete = array_unique($toDelete);
+ // Get children categories
+ $to_delete = array((int)$this->id);
+ $this->recursiveDelete($to_delete, (int)$this->id);
+ $to_delete = array_unique($to_delete);
- /* Delete CMS Category and its child from database */
- $list = count($toDelete) > 1 ? implode(',', $toDelete) : (int)($this->id);
+ // Delete CMS Category and its child from database
+ $list = count($to_delete) > 1 ? implode(',', $to_delete) : (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.')');
CMSCategory::cleanPositions($this->id_parent);
- /* Delete pages which are in categories to delete */
+ // Delete pages which are in categories to delete
$result = Db::getInstance()->executeS('
SELECT `id_cms`
FROM `'._DB_PREFIX_.'cms`
WHERE `id_cms_category` IN ('.$list.')');
foreach ($result as $p)
{
- $product = new CMS((int)($p['id_cms']));
+ $product = new CMS($p['id_cms']);
if (Validate::isLoadedObject($product))
$product->delete();
}
@@ -282,7 +278,7 @@ class CMSCategoryCore extends ObjectModel
$return = 1;
foreach ($categories as $id_category_cms)
{
- $category_cms = new CMSCategory((int)($id_category_cms));
+ $category_cms = new CMSCategory($id_category_cms);
$return &= $category_cms->delete();
}
return $return;
@@ -295,7 +291,7 @@ class CMSCategoryCore extends ObjectModel
*/
public function calcLevelDepth()
{
- $parentCMSCategory = new CMSCategory((int)($this->id_parent));
+ $parentCMSCategory = new CMSCategory($this->id_parent);
if (!$parentCMSCategory)
die('parent CMS Category does not exist');
return $parentCMSCategory->level_depth + 1;
@@ -317,7 +313,7 @@ class CMSCategoryCore extends ObjectModel
SELECT *
FROM `'._DB_PREFIX_.'cms_category` c
LEFT JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON c.`id_cms_category` = cl.`id_cms_category`
- WHERE `id_lang` = '.(int)($id_lang).'
+ WHERE `id_lang` = '.(int)$id_lang.'
'.($active ? 'AND `active` = 1' : '').'
ORDER BY `name` ASC');
@@ -336,7 +332,7 @@ class CMSCategoryCore extends ObjectModel
SELECT c.`id_cms_category`, cl.`name`
FROM `'._DB_PREFIX_.'cms_category` c
LEFT JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON (c.`id_cms_category` = cl.`id_cms_category`)
- WHERE cl.`id_lang` = '.(int)($id_lang).'
+ WHERE cl.`id_lang` = '.(int)$id_lang.'
ORDER BY cl.`name`');
}
@@ -355,8 +351,8 @@ class CMSCategoryCore extends ObjectModel
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.*, cl.id_lang, cl.name, cl.description, cl.link_rewrite, cl.meta_title, cl.meta_keywords, cl.meta_description
FROM `'._DB_PREFIX_.'cms_category` c
- LEFT JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON (c.`id_cms_category` = cl.`id_cms_category` AND `id_lang` = '.(int)($id_lang).')
- WHERE `id_parent` = '.(int)($this->id).'
+ LEFT JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON (c.`id_cms_category` = cl.`id_cms_category` AND `id_lang` = '.(int)$id_lang.')
+ WHERE `id_parent` = '.(int)$this->id.'
'.($active ? 'AND `active` = 1' : '').'
GROUP BY c.`id_cms_category`
ORDER BY `name` ASC');
@@ -399,19 +395,19 @@ class CMSCategoryCore extends ObjectModel
SELECT c.`id_cms_category`, cl.`name`, cl.`link_rewrite`
FROM `'._DB_PREFIX_.'cms_category` c
LEFT JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON c.`id_cms_category` = cl.`id_cms_category`
- WHERE `id_lang` = '.(int)($id_lang).'
- AND c.`id_parent` = '.(int)($id_parent).'
+ WHERE `id_lang` = '.(int)$id_lang.'
+ AND c.`id_parent` = '.(int)$id_parent.'
'.($active ? 'AND `active` = 1' : '').'
ORDER BY `name` ASC');
- /* Modify SQL result */
- $resultsArray = array();
+ // Modify SQL result
+ $results_array = array();
foreach ($result as $row)
{
$row['name'] = CMSCategory::hideCMSCategoryPosition($row['name']);
- $resultsArray[] = $row;
+ $results_array[] = $row;
}
- return $resultsArray;
+ return $results_array;
}
/**
@@ -424,11 +420,11 @@ class CMSCategoryCore extends ObjectModel
{
if ($id_cms_category == $id_parent) return false;
if ($id_parent == 1) return true;
- $i = (int)($id_parent);
+ $i = (int)$id_parent;
while (42)
{
- $result = Db::getInstance()->getRow('SELECT `id_parent` FROM `'._DB_PREFIX_.'cms_category` WHERE `id_cms_category` = '.(int)($i));
+ $result = Db::getInstance()->getRow('SELECT `id_parent` FROM `'._DB_PREFIX_.'cms_category` WHERE `id_cms_category` = '.(int)$i);
if (!isset($result['id_parent'])) return false;
if ($result['id_parent'] == $id_cms_category) return false;
if ($result['id_parent'] == 1) return true;
@@ -448,8 +444,8 @@ class CMSCategoryCore extends ObjectModel
SELECT cl.`link_rewrite`
FROM `'._DB_PREFIX_.'cms_category` c
LEFT JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON c.`id_cms_category` = cl.`id_cms_category`
- WHERE `id_lang` = '.(int)($id_lang).'
- AND c.`id_cms_category` = '.(int)($id_cms_category));
+ WHERE `id_lang` = '.(int)$id_lang.'
+ AND c.`id_cms_category` = '.(int)$id_cms_category);
self::$_links[$id_cms_category.'-'.$id_lang] = $result['link_rewrite'];
return $result['link_rewrite'];
}
@@ -464,13 +460,12 @@ class CMSCategoryCore extends ObjectModel
public function getName($id_lang = null)
{
$context = Context::getContext();
-
if (!$id_lang)
{
- if (isset($this->name[Context::getContext()->language->id]))
- $id_lang = Context::getContext()->language->id;
+ if (isset($this->name[$context->language->id]))
+ $id_lang = $context->language->id;
else
- $id_lang = (int)(Configuration::get('PS_LANG_DEFAULT'));
+ $id_lang = (int)Configuration::get('PS_LANG_DEFAULT');
}
return isset($this->name[$id_lang]) ? $this->name[$id_lang] : '';
}
@@ -495,7 +490,7 @@ class CMSCategoryCore extends ObjectModel
return Db::getInstance()->executeS('
SELECT c.*, cl.*
FROM `'._DB_PREFIX_.'cms_category` c
- LEFT JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON (c.`id_cms_category` = cl.`id_cms_category` AND `id_lang` = '.(int)($id_lang).')
+ LEFT JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON (c.`id_cms_category` = cl.`id_cms_category` AND `id_lang` = '.(int)$id_lang.')
WHERE `name` LIKE \'%'.pSQL($query).'%\' AND c.`id_cms_category` != 1');
}
@@ -514,10 +509,10 @@ class CMSCategoryCore extends ObjectModel
return Db::getInstance()->getRow('
SELECT c.*, cl.*
FROM `'._DB_PREFIX_.'cms_category` c
- LEFT JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON (c.`id_cms_category` = cl.`id_cms_category` AND `id_lang` = '.(int)($id_lang).')
+ LEFT JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON (c.`id_cms_category` = cl.`id_cms_category` AND `id_lang` = '.(int)$id_lang.')
WHERE `name` LIKE \''.pSQL($CMSCategory_name).'\'
AND c.`id_cms_category` != 1
- AND c.`id_parent` = '.(int)($id_parent_CMSCategory));
+ AND c.`id_parent` = '.(int)$id_parent_CMSCategory);
}
/**
@@ -532,21 +527,21 @@ class CMSCategoryCore extends ObjectModel
$id_lang = Context::getContext()->language->id;
$categories = null;
- $idCurrent = $this->id;
+ $id_current = $this->id;
while (true)
{
$query = '
SELECT c.*, cl.*
FROM `'._DB_PREFIX_.'cms_category` c
LEFT JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON (c.`id_cms_category` = cl.`id_cms_category` AND `id_lang` = '.(int)$id_lang.')
- WHERE c.`id_cms_category` = '.(int)$idCurrent.' AND c.`id_parent` != 0
+ WHERE c.`id_cms_category` = '.(int)$id_current.' AND c.`id_parent` != 0
';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
$categories[] = $result[0];
if (!$result || $result[0]['id_parent'] == 1)
return $categories;
- $idCurrent = $result[0]['id_parent'];
+ $id_current = $result[0]['id_parent'];
}
}
@@ -561,9 +556,9 @@ class CMSCategoryCore extends ObjectModel
return false;
foreach ($res as $category)
if ((int)$category['id_cms_category'] == (int)$this->id)
- $movedCategory = $category;
+ $moved_category = $category;
- if (!isset($movedCategory) || !isset($position))
+ if (!isset($moved_category) || !isset($position))
return false;
// < and > statements rather than BETWEEN operator
// since BETWEEN is treated differently according to databases
@@ -572,14 +567,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).'
- AND `id_parent`='.(int)($movedCategory['id_parent']))
+ ? '> '.(int)$moved_category['position'].' AND `position` <= '.(int)$position
+ : '< '.(int)$moved_category['position'].' AND `position` >= '.(int)$position).'
+ AND `id_parent`='.(int)$moved_category['id_parent'])
&& 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']));
+ WHERE `id_parent` = '.(int)$moved_category['id_parent'].'
+ AND `id_cms_category`='.(int)$moved_category['id_cms_category']));
}
public static function cleanPositions($id_category_parent)
@@ -587,24 +582,24 @@ class CMSCategoryCore extends ObjectModel
$result = Db::getInstance()->executeS('
SELECT `id_cms_category`
FROM `'._DB_PREFIX_.'cms_category`
- WHERE `id_parent` = '.(int)($id_category_parent).'
+ WHERE `id_parent` = '.(int)$id_category_parent.'
ORDER BY `position`');
$sizeof = count($result);
for ($i = 0; $i < $sizeof; ++$i)
{
- $sql = '
- UPDATE `'._DB_PREFIX_.'cms_category`
- SET `position` = '.(int)($i).'
- WHERE `id_parent` = '.(int)($id_category_parent).'
- AND `id_cms_category` = '.(int)($result[$i]['id_cms_category']);
- Db::getInstance()->execute($sql);
- }
+ $sql = '
+ UPDATE `'._DB_PREFIX_.'cms_category`
+ SET `position` = '.(int)$i.'
+ WHERE `id_parent` = '.(int)$id_category_parent.'
+ AND `id_cms_category` = '.(int)$result[$i]['id_cms_category'];
+ Db::getInstance()->execute($sql);
+ }
return true;
}
public static function getLastPosition($id_category_parent)
{
- return (Db::getInstance()->getValue('SELECT MAX(position)+1 FROM `'._DB_PREFIX_.'cms_category` WHERE `id_parent` = '.(int)($id_category_parent)));
+ 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)
diff --git a/classes/CarrierModule.php b/classes/CarrierModule.php
index 46abb660a..edf7a32fb 100644
--- a/classes/CarrierModule.php
+++ b/classes/CarrierModule.php
@@ -27,7 +27,7 @@
abstract class CarrierModuleCore extends Module
{
- abstract function getOrderShippingCost($params,$shipping_cost);
- abstract function getOrderShippingCostExternal($params);
+ abstract public function getOrderShippingCost($params, $shipping_cost);
+ abstract public function getOrderShippingCostExternal($params);
}
diff --git a/classes/Cart.php b/classes/Cart.php
index 535194042..f0e8d784e 100644
--- a/classes/Cart.php
+++ b/classes/Cart.php
@@ -787,9 +787,7 @@ class CartCore extends ObjectModel
$product_qty = (int)$result2['quantity'];
// Quantity for product pack
if (Pack::isPack($id_product))
- {
$product_qty = Pack::getQuantity($id_product, $id_product_attribute);
- }
$new_qty = (int)$result['quantity'] + (int)$quantity;
$qty = '+ '.(int)$quantity;
@@ -834,9 +832,7 @@ class CartCore extends ObjectModel
// Quantity for product pack
if (Pack::isPack($id_product))
- {
$result2['quantity'] = Pack::getQuantity($id_product, $id_product_attribute);
- }
if (!Product::isAvailableWhenOutOfStock((int)$result2['out_of_stock']))
if ((int)$quantity > $result2['quantity'])
@@ -868,7 +864,7 @@ class CartCore extends ObjectModel
CartRule::autoAddToCart($context);
if ($product->customizable)
- return $this->_updateCustomizationQuantity((int)$quantity, (int)$id_customization, (int)$id_product, (int)$id_product_attribute, (int)$id_address_delivery , $operator);
+ return $this->_updateCustomizationQuantity((int)$quantity, (int)$id_customization, (int)$id_product, (int)$id_product_attribute, (int)$id_address_delivery, $operator);
else
return true;
}
@@ -1866,7 +1862,7 @@ class CartCore extends ObjectModel
$nameList = array();
foreach ($option['carrier_list'] as $carrier)
$nameList[] = $carrier['instance']->name;
- $name = join(' -' , $nameList);
+ $name = join(' -', $nameList);
$img = ''; // No images if multiple carriers
$delay = '';
}
@@ -1906,7 +1902,7 @@ class CartCore extends ObjectModel
{
$elm = explode($delimiter, $string);
$max = max($elm);
- return strlen($max).join(str_repeat('0', strlen($max)+1), $elm);
+ return strlen($max).join(str_repeat('0', strlen($max) + 1), $elm);
}
/**
@@ -1916,7 +1912,7 @@ class CartCore extends ObjectModel
{
$delimiter_len = $int[0];
$int = substr($int, 1);
- $elm = explode(str_repeat('0',$delimiter_len+1), $int);
+ $elm = explode(str_repeat('0', $delimiter_len + 1), $int);
return join($delimiter, $elm);
}
@@ -1967,7 +1963,7 @@ class CartCore extends ObjectModel
return;
}
- $delivery_option_list = $this->getDeliveryOptionList(null , true);
+ $delivery_option_list = $this->getDeliveryOptionList(null, true);
foreach ($delivery_option_list as $id_address => $options)
if (!isset($delivery_option[$id_address]))
@@ -2916,8 +2912,8 @@ class CartCore extends ObjectModel
$sql->where('id_cart = '.(int)$this->id);
$duplicatedQuantity = Db::getInstance()->getValue($sql);
- if ($duplicatedQuantity > $quantity) {
-
+ if ($duplicatedQuantity > $quantity)
+ {
$sql = 'UPDATE '._DB_PREFIX_.'cart_product
SET `quantity` = `quantity` - '.(int)$quantity.'
WHERE id_cart = '.(int)$this->id.'
diff --git a/classes/CartRule.php b/classes/CartRule.php
index dbaf9e271..e7019687a 100644
--- a/classes/CartRule.php
+++ b/classes/CartRule.php
@@ -216,7 +216,7 @@ class CartRuleCore extends ObjectModel
public function getProductRules()
{
- if (!Validate::isLoadedObject($this) OR $this->product_restriction == 0)
+ if (!Validate::isLoadedObject($this) || $this->product_restriction == 0)
return array();
$productRules = array();
@@ -274,7 +274,7 @@ class CartRuleCore extends ObjectModel
{
if ($otherCartRule['id_cart_rule'] == $this->id && !$alreadyInCart)
return Tools::displayError('This voucher is already in your cart');
- if ($this->carrier_restriction AND $otherCartRule['cart_rule_restriction'])
+ if ($this->carrier_restriction && $otherCartRule['cart_rule_restriction'])
{
$combinable = Db::getInstance()->getValue('
SELECT id_cart_rule_1
@@ -302,7 +302,7 @@ class CartRuleCore extends ObjectModel
}
// Check if the customer delivery address is usable with the cart rule
- if ($this->country_restriction AND $context->cart->id_address_delivery)
+ if ($this->country_restriction && $context->cart->id_address_delivery)
{
$id_cart_rule = (int)Db::getInstance()->getValue('
SELECT crc.id_cart_rule
@@ -314,7 +314,7 @@ class CartRuleCore extends ObjectModel
}
// Check if the carrier chosen by the customer is usable with the cart rule
- if ($this->carrier_restriction AND $context->cart->id_carrier)
+ if ($this->carrier_restriction && $context->cart->id_carrier)
{
$id_cart_rule = (int)Db::getInstance()->getValue('
SELECT crc.id_cart_rule
@@ -405,8 +405,14 @@ class CartRuleCore extends ObjectModel
}
}
- // The reduction value is POSITIVE
- public function getContextualValue($useTax, Context $context = NULL)
+ /**
+ * The reduction value is POSITIVE
+ *
+ * @param bool $useTax
+ * @param Context $context
+ * @return float|int|string
+ */
+ public function getContextualValue($useTax, Context $context = null)
{
if (!CartRule::isFeatureActive())
return 0;
@@ -435,13 +441,11 @@ class CartRuleCore extends ObjectModel
}
// Discount (%) on the whole order
- if ($this->reduction_percent AND $this->reduction_product == 0)
- {
+ if ($this->reduction_percent && $this->reduction_product == 0)
$reductionValue += $context->cart->getOrderTotal($useTax, Cart::ONLY_PRODUCTS) * $this->reduction_percent / 100;
- }
// Discount (%) on a specific product
- if ($this->reduction_percent AND $this->reduction_product > 0)
+ if ($this->reduction_percent && $this->reduction_product > 0)
{
foreach ($context->cart->getProducts() as $product)
if ($product['id_product'] == $this->reduction_product)
@@ -449,7 +453,7 @@ class CartRuleCore extends ObjectModel
}
// Discount (%) on the cheapest product
- if ($this->reduction_percent AND $this->reduction_product == -1)
+ if ($this->reduction_percent && $this->reduction_product == -1)
{
$minPrice = false;
foreach ($context->cart->getProducts() as $product)
@@ -610,7 +614,7 @@ class CartRuleCore extends ObjectModel
return $array;
}
- public static function autoRemoveFromCart($context = NULL)
+ public static function autoRemoveFromCart($context = null)
{
if (!CartRule::isFeatureActive())
return;
@@ -630,14 +634,14 @@ class CartRuleCore extends ObjectModel
return $errors;
}
- public static function autoAddToCart($context = NULL)
+ public static function autoAddToCart(Context $context = null)
{
- if ($context === NULL)
+ if ($context === null)
$context = Context::getContext();
if (!CartRule::isFeatureActive() || !Validate::isLoadedObject($context->cart))
return;
- $result = Db::getInstance()->ExecuteS('
+ $result = Db::getInstance()->executeS('
SELECT cr.*
FROM '._DB_PREFIX_.'cart_rule cr
LEFT JOIN '._DB_PREFIX_.'cart_rule_carrier crca ON cr.id_cart_rule = crca.id_cart_rule
diff --git a/classes/Category.php b/classes/Category.php
index 457399394..9d0c2dc2c 100644
--- a/classes/Category.php
+++ b/classes/Category.php
@@ -78,10 +78,10 @@ class CategoryCore extends ObjectModel
public $is_root_category;
public $groupBox;
-
+
/** @var boolean does the product have to be removed during the delete process */
public $remove_products = true;
-
+
/** @var boolean does the product have to be disable during the delete process */
public $disable_products = false;
@@ -150,12 +150,12 @@ class CategoryCore extends ObjectModel
return strip_tags(stripslashes($description));
}
- public function add($autodate = true, $nullValues = false)
+ public function add($autodate = true, $null_values = false)
{
$this->position = Category::getLastPosition((int)$this->id_parent);
if (!isset($this->level_depth))
$this->level_depth = $this->calcLevelDepth();
- $ret = parent::add($autodate);
+ $ret = parent::add($autodate, $null_values);
if (!isset($this->doNotRegenerateNTree) || !$this->doNotRegenerateNTree)
Category::regenerateEntireNtree();
$this->updateGroup($this->groupBox);
@@ -166,10 +166,10 @@ class CategoryCore extends ObjectModel
/**
* update category positions in parent
*
- * @param mixed $nullValues
+ * @param mixed $null_values
* @return void
*/
- public function update($nullValues = false)
+ public function update($null_values = false)
{
if ($this->id_parent == $this->id)
throw new PrestaShopException('a category cannot be it\'s own parent');
@@ -180,7 +180,7 @@ class CategoryCore extends ObjectModel
// If the parent category was changed, we don't want to have 2 categories with the same position
if ($this->getDuplicatePosition())
$this->position = Category::getLastPosition((int)$this->id_parent);
- $ret = parent::update($nullValues);
+ $ret = parent::update($null_values);
if (!isset($this->doNotRegenerateNTree) || !$this->doNotRegenerateNTree)
{
Category::regenerateEntireNtree();
@@ -318,7 +318,7 @@ class CategoryCore extends ObjectModel
{
if ($this->disable_products)
$product->active = 0;
-
+
$product->addToCategories($this->id_parent);
$product->save();
}
diff --git a/classes/Chart.php b/classes/Chart.php
index 60b2e29d6..bc6918cce 100644
--- a/classes/Chart.php
+++ b/classes/Chart.php
@@ -1,6 +1,6 @@
granularity = $granularity;
-
+
if (Validate::isDate($from))
$from = strtotime($from);
$this->from = $from;
if (Validate::isDate($to))
$to = strtotime($to);
$this->to = $to;
-
+
if ($granularity == 'd')
$this->format = '%d/%m/%y';
if ($granularity == 'w')
@@ -84,17 +84,17 @@ class ChartCore
$this->format = '%m/%y';
if ($granularity == 'y')
$this->format = '%y';
-
+
$this->timeMode = true;
}
-
+
public function getCurve($i)
{
if (!array_key_exists($i, $this->curves))
$this->curves[$i] = new Curve();
return $this->curves[$i];
}
-
+
/** @prototype void public function display() */
public function display()
{
@@ -112,7 +112,7 @@ class ChartCore
if (!$curve->getPoint($i))
$curve->setPoint($i, 0);
}
-
+
$jsCurves = array();
foreach ($this->curves as $curve)
$jsCurves[] = $curve->getValues($this->timeMode);
@@ -142,12 +142,12 @@ class Curve
$this->values = $values;
}
- public function getValues($timeMode = false)
+ public function getValues($time_mode = false)
{
ksort($this->values);
$string = '';
foreach ($this->values as $key => $value)
- $string .= '['.addslashes((string)$key).($timeMode ? '000' : '').','.(float)$value.'],';
+ $string .= '['.addslashes((string)$key).($time_mode ? '000' : '').','.(float)$value.'],';
return '{data:['.rtrim($string, ',').']'.(!empty($this->label) ? ',label:"'.$this->label.'"' : '').''.(!empty($this->type) ? ','.$this->type : '').'}';
}
@@ -156,12 +156,12 @@ class Curve
{
$this->values[(string)$x] = (float)$y;
}
-
+
public function setLabel($label)
{
$this->label = $label;
}
-
+
public function setType($type)
{
$this->type = '';
@@ -170,7 +170,7 @@ class Curve
if ($type == 'steps')
$this->type = 'lines:{show:true,steps:true}';
}
-
+
public function getPoint($x)
{
if (array_key_exists((string)$x, $this->values))
diff --git a/classes/FileUploader.php b/classes/FileUploader.php
index 9d348f2b0..92114d335 100755
--- a/classes/FileUploader.php
+++ b/classes/FileUploader.php
@@ -120,7 +120,7 @@ class QqUploadedFileForm
$image = new Image($id_image);
if (!$new_path = $image->getPathForCreation())
return array('error' => Tools::displayError('An error occurred during new folder creation'));
- if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') || !move_uploaded_file($_FILES['qqfile']['tmp_name'], $tmpName))
+ if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !move_uploaded_file($_FILES['qqfile']['tmp_name'], $tmpName))
return array('error' => Tools::displayError('An error occurred during the image upload'));
elseif (!ImageManager::resize($tmpName, $new_path.'.'.$image->image_format))
return array('error' => Tools::displayError('An error occurred while copying image.'));
diff --git a/classes/FrontController.php b/classes/FrontController.php
index 9ef796155..bde5c419c 100755
--- a/classes/FrontController.php
+++ b/classes/FrontController.php
@@ -134,7 +134,7 @@ class FrontControllerCore extends Controller
ob_start();
// Switch language if needed and init cookie language
- if ($iso = Tools::getValue('isolang') && Validate::isLanguageIsoCode($iso) && ($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();
@@ -363,7 +363,7 @@ class FrontControllerCore extends Controller
$this->displayRestrictedCountryPage();
//live edit
- if (Tools::isSubmit('live_edit') && $ad = Tools::getValue('ad') && (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());
@@ -523,7 +523,7 @@ class FrontControllerCore extends Controller
$this->context->smarty->display(_PS_THEME_DIR_.'footer.tpl');
// live edit
- if (Tools::isSubmit('live_edit') && $ad = Tools::getValue('ad') && (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');
diff --git a/classes/Product.php b/classes/Product.php
index d9835cb69..0618619ae 100644
--- a/classes/Product.php
+++ b/classes/Product.php
@@ -662,7 +662,7 @@ class ProductCore extends ObjectModel
return false;
if ($id = ProductDownload::getIdFromIdProduct($this->id))
- if ($product_download = new ProductDownload($id) && !$product_download->delete(true))
+ if (($product_download = new ProductDownload($id)) && !$product_download->delete(true))
return false;
return true;
diff --git a/classes/cache/Cache.php b/classes/cache/Cache.php
index 89beaaba4..eba4aa1aa 100755
--- a/classes/cache/Cache.php
+++ b/classes/cache/Cache.php
@@ -249,7 +249,7 @@ abstract class CacheCore
// Get all table from the query and save them in cache
if (preg_match_all('/('._DB_PREFIX_.'[a-z_-]*)`?.*/i', $query, $res))
- foreach($res[1] as $table)
+ foreach ($res[1] as $table)
if (!isset($this->sql_tables_cached[$table][$key]))
$this->sql_tables_cached[$table][$key] = true;
$this->set(self::SQL_TABLES_NAME, $this->sql_tables_cached);
diff --git a/classes/cache/CacheFs.php b/classes/cache/CacheFs.php
index 03342472b..8f631e442 100755
--- a/classes/cache/CacheFs.php
+++ b/classes/cache/CacheFs.php
@@ -132,7 +132,7 @@ class CacheFsCore extends Cache
if (!$directory)
$directory = _PS_CACHEFS_DIRECTORY_;
$chars = '0123456789abcdef';
- for ($i = 0; $i < strlen($chars); $i++)
+ for ($i = 0, $length = strlen($chars); $i < $length; $i++)
{
$new_dir = $directory.$chars[$i].'/';
if (mkdir($new_dir))
diff --git a/classes/cache/CacheMemcache.php b/classes/cache/CacheMemcache.php
index 3960d5240..e02a9e7ea 100755
--- a/classes/cache/CacheMemcache.php
+++ b/classes/cache/CacheMemcache.php
@@ -53,7 +53,7 @@ class CacheMemcacheCore extends Cache
if ($this->memcache->getExtendedStats('cachedump', (int)$slab_id))
foreach ($dump as $entries)
foreach ($entries as $entry)
- $this->keys[$entry] = 0;;
+ $this->keys[$entry] = 0;
}
public function __destruct()
@@ -70,7 +70,7 @@ class CacheMemcacheCore extends Cache
$servers = CacheMemcache::getMemcachedServers();
if (!$servers)
return false;
- foreach ($servers AS $server)
+ foreach ($servers as $server)
$this->memcache->addServer($server['ip'], $server['port'], $server['weight']);
$this->is_connected = true;
diff --git a/classes/helper/Helper.php b/classes/helper/Helper.php
index 39fafca58..bd37253f6 100755
--- a/classes/helper/Helper.php
+++ b/classes/helper/Helper.php
@@ -278,7 +278,7 @@ class HelperCore
{
// if the class is extended by a module, use modules/[module_name]/xx.php lang file
$currentClass = get_class($this);
- if(Module::getModuleNameFromClass($currentClass))
+ if (Module::getModuleNameFromClass($currentClass))
{
$string = str_replace('\'', '\\\'', $string);
return Module::findTranslation(Module::$classInModule[$currentClass], $string, $currentClass);
diff --git a/classes/helper/HelperForm.php b/classes/helper/HelperForm.php
index 250cf0d65..1e89a7262 100644
--- a/classes/helper/HelperForm.php
+++ b/classes/helper/HelperForm.php
@@ -175,7 +175,7 @@ class HelperFormCore extends Helper
foreach ($this->fields_form as $fieldset)
if (isset($fieldset['form']['input']))
foreach ($fieldset['form']['input'] as $input)
- if (array_key_exists('required', $input) && $input['required'] && $input['type'] != 'radio')
+ if (array_key_exists('required', $input) && $input['required'] && $input['type'] != 'radio')
return true;
return false;
diff --git a/classes/helper/HelperOptions.php b/classes/helper/HelperOptions.php
index 73ac0e829..a30787153 100644
--- a/classes/helper/HelperOptions.php
+++ b/classes/helper/HelperOptions.php
@@ -177,7 +177,7 @@ class HelperOptionsCore extends Helper
echo '
';
echo '';
echo '';
- if (isset($field['max']) && ($i +1 ) % $field['max'] == 0)
+ if (isset($field['max']) && ($i + 1) % $field['max'] == 0)
echo '