// Normalize
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12680 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
1 parent
bd7ba6969b
commit
c994c25fe1
21 files changed
+181
-185
No files matched your search
@@ -42,7 +42,7 @@ class AccountingCore
|
|||||||
$values = '';
|
$values = '';
|
||||||
|
|
||||||
// Build the query for the update
|
// Build the query for the update
|
||||||
foreach($assoZoneShopList as $asso)
|
foreach ($assoZoneShopList as $asso)
|
||||||
if (array_key_exists('id_zone', $asso) &&
|
if (array_key_exists('id_zone', $asso) &&
|
||||||
array_key_exists('id_shop', $asso) &&
|
array_key_exists('id_shop', $asso) &&
|
||||||
array_key_exists('num', $asso))
|
array_key_exists('num', $asso))
|
||||||
@@ -67,7 +67,7 @@ class AccountingCore
|
|||||||
VALUES %s';
|
VALUES %s';
|
||||||
|
|
||||||
$values = '';
|
$values = '';
|
||||||
foreach($assoProductZoneShop as $asso)
|
foreach ($assoProductZoneShop as $asso)
|
||||||
if (array_key_exists('id_zone', $asso) &&
|
if (array_key_exists('id_zone', $asso) &&
|
||||||
array_key_exists('id_shop', $asso) &&
|
array_key_exists('id_shop', $asso) &&
|
||||||
array_key_exists('id_product', $asso) &&
|
array_key_exists('id_product', $asso) &&
|
||||||
|
|||||||
+15
-16
@@ -117,7 +117,7 @@ class AddressFormatCore extends ObjectModel
|
|||||||
|
|
||||||
// Check if the property is accessible
|
// Check if the property is accessible
|
||||||
$publicProperties = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
|
$publicProperties = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
|
||||||
foreach($publicProperties as $property)
|
foreach ($publicProperties as $property)
|
||||||
{
|
{
|
||||||
$propertyName = $property->getName();
|
$propertyName = $property->getName();
|
||||||
if (($propertyName == $fieldName) && ($isIdField ||
|
if (($propertyName == $fieldName) && ($isIdField ||
|
||||||
@@ -195,12 +195,12 @@ class AddressFormatCore extends ObjectModel
|
|||||||
|
|
||||||
$multipleLineFields = explode("\n", $this->format);
|
$multipleLineFields = explode("\n", $this->format);
|
||||||
if ($multipleLineFields && is_array($multipleLineFields))
|
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 (($patternsName = preg_split(self::_CLEANING_REGEX_, $lineField, -1, PREG_SPLIT_NO_EMPTY)))
|
||||||
if (is_array($patternsName))
|
if (is_array($patternsName))
|
||||||
{
|
{
|
||||||
foreach($patternsName as $patternName)
|
foreach ($patternsName as $patternName)
|
||||||
{
|
{
|
||||||
if (!in_array($patternName, $usedKeyList))
|
if (!in_array($patternName, $usedKeyList))
|
||||||
{
|
{
|
||||||
@@ -234,13 +234,13 @@ class AddressFormatCore extends ObjectModel
|
|||||||
if ($currentKeyList && is_array($currentKeyList))
|
if ($currentKeyList && is_array($currentKeyList))
|
||||||
if ($originalFormattedPatternList = explode(' ', $currentLine))
|
if ($originalFormattedPatternList = explode(' ', $currentLine))
|
||||||
// Foreach the available pattern
|
// 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
|
// Var allows to modify the good formatted key value when multiple key exist into the same pattern
|
||||||
$mainFormattedKey = '';
|
$mainFormattedKey = '';
|
||||||
|
|
||||||
// Multiple key can be found in the same pattern
|
// 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
|
// Check if we need to use an older modified pattern if a key has already be matched before
|
||||||
$replacedValue = empty($mainFormattedKey) ? $pattern : $formattedValueList[$mainFormattedKey];
|
$replacedValue = empty($mainFormattedKey) ? $pattern : $formattedValueList[$mainFormattedKey];
|
||||||
@@ -266,12 +266,12 @@ class AddressFormatCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public static function cleanOrderedAddress(&$orderedAddressField)
|
public static function cleanOrderedAddress(&$orderedAddressField)
|
||||||
{
|
{
|
||||||
foreach($orderedAddressField as &$line)
|
foreach ($orderedAddressField as &$line)
|
||||||
{
|
{
|
||||||
$cleanedLine = '';
|
$cleanedLine = '';
|
||||||
if (($keyList = preg_split(self::_CLEANING_REGEX_, $line, -1, PREG_SPLIT_NO_EMPTY)))
|
if (($keyList = preg_split(self::_CLEANING_REGEX_, $line, -1, PREG_SPLIT_NO_EMPTY)))
|
||||||
{
|
{
|
||||||
foreach($keyList as $key)
|
foreach ($keyList as $key)
|
||||||
$cleanedLine .= $key.' ';
|
$cleanedLine .= $key.' ';
|
||||||
$cleanedLine = trim($cleanedLine);
|
$cleanedLine = trim($cleanedLine);
|
||||||
$line = $cleanedLine;
|
$line = $cleanedLine;
|
||||||
@@ -295,11 +295,11 @@ class AddressFormatCore extends ObjectModel
|
|||||||
|
|
||||||
// Check if $address exist and it's an instanciate object of Address
|
// Check if $address exist and it's an instanciate object of Address
|
||||||
if ($address && ($address instanceof 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))
|
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))
|
if ($associateName = explode(':', $pattern))
|
||||||
{
|
{
|
||||||
$totalName = count($associateName);
|
$totalName = count($associateName);
|
||||||
@@ -331,7 +331,7 @@ class AddressFormatCore extends ObjectModel
|
|||||||
}
|
}
|
||||||
AddressFormat::cleanOrderedAddress($addressFormat);
|
AddressFormat::cleanOrderedAddress($addressFormat);
|
||||||
// Free the instanciate objects
|
// Free the instanciate objects
|
||||||
foreach($temporyObject as &$object)
|
foreach ($temporyObject as &$object)
|
||||||
unset($object);
|
unset($object);
|
||||||
return $tab;
|
return $tab;
|
||||||
}
|
}
|
||||||
@@ -354,7 +354,7 @@ class AddressFormatCore extends ObjectModel
|
|||||||
if (($patternsList = preg_split(self::_CLEANING_REGEX_, $line, -1, PREG_SPLIT_NO_EMPTY)))
|
if (($patternsList = preg_split(self::_CLEANING_REGEX_, $line, -1, PREG_SPLIT_NO_EMPTY)))
|
||||||
{
|
{
|
||||||
$tmpText = '';
|
$tmpText = '';
|
||||||
foreach($patternsList as $pattern)
|
foreach ($patternsList as $pattern)
|
||||||
if ((!array_key_exists('avoid', $patternRules)) ||
|
if ((!array_key_exists('avoid', $patternRules)) ||
|
||||||
(array_key_exists('avoid', $patternRules) && !in_array($pattern, $patternRules['avoid'])))
|
(array_key_exists('avoid', $patternRules) && !in_array($pattern, $patternRules['avoid'])))
|
||||||
$tmpText .= (isset($addressFormatedValues[$pattern]) && !empty($addressFormatedValues[$pattern])) ?
|
$tmpText .= (isset($addressFormatedValues[$pattern]) && !empty($addressFormatedValues[$pattern])) ?
|
||||||
@@ -397,7 +397,7 @@ class AddressFormatCore extends ObjectModel
|
|||||||
|
|
||||||
// Check if the property is accessible
|
// Check if the property is accessible
|
||||||
$publicProperties = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
|
$publicProperties = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
|
||||||
foreach($publicProperties as $property)
|
foreach ($publicProperties as $property)
|
||||||
{
|
{
|
||||||
$propertyName = $property->getName();
|
$propertyName = $property->getName();
|
||||||
if ((!in_array($propertyName, AddressFormat::$forbiddenPropertyList)) &&
|
if ((!in_array($propertyName, AddressFormat::$forbiddenPropertyList)) &&
|
||||||
@@ -424,7 +424,7 @@ class AddressFormatCore extends ObjectModel
|
|||||||
|
|
||||||
// Get all the name object liable to the Address class
|
// Get all the name object liable to the Address class
|
||||||
$publicProperties = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
|
$publicProperties = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
|
||||||
foreach($publicProperties as $property)
|
foreach ($publicProperties as $property)
|
||||||
{
|
{
|
||||||
$propertyName = $property->getName();
|
$propertyName = $property->getName();
|
||||||
if (preg_match('#id_\w#', $propertyName) && strlen($propertyName) > 3)
|
if (preg_match('#id_\w#', $propertyName) && strlen($propertyName) > 3)
|
||||||
@@ -457,7 +457,7 @@ class AddressFormatCore extends ObjectModel
|
|||||||
if ($cleaned)
|
if ($cleaned)
|
||||||
$keyList = ($cleaned) ? preg_split(self::_CLEANING_REGEX_, $field_item, -1, PREG_SPLIT_NO_EMPTY) :
|
$keyList = ($cleaned) ? preg_split(self::_CLEANING_REGEX_, $field_item, -1, PREG_SPLIT_NO_EMPTY) :
|
||||||
explode(' ', $field_item);
|
explode(' ', $field_item);
|
||||||
foreach($keyList as $word_item)
|
foreach ($keyList as $word_item)
|
||||||
$out[] = trim($word_item);
|
$out[] = trim($word_item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -490,8 +490,7 @@ class AddressFormatCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public static function getAddressCountryFormat($id_country = 0)
|
public static function getAddressCountryFormat($id_country = 0)
|
||||||
{
|
{
|
||||||
$out = '';
|
$id_country = (int)$id_country;
|
||||||
$id_country = (int) $id_country;
|
|
||||||
|
|
||||||
$tmp_obj = new AddressFormat();
|
$tmp_obj = new AddressFormat();
|
||||||
$tmp_obj->id_country = $id_country;
|
$tmp_obj->id_country = $id_country;
|
||||||
|
|||||||
@@ -661,9 +661,8 @@ class AdminControllerCore extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->errors = array_unique($this->errors);
|
$this->errors = array_unique($this->errors);
|
||||||
if (count($this->errors) > 0) {
|
if (count($this->errors) > 0)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
@@ -1915,7 +1914,7 @@ class AdminControllerCore extends Controller
|
|||||||
$this->boxes = Tools::getValue($this->table.'Box');
|
$this->boxes = Tools::getValue($this->table.'Box');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if(Tools::isSubmit('submitBulk'))
|
else if (Tools::isSubmit('submitBulk'))
|
||||||
{
|
{
|
||||||
$this->action = 'bulk'.Tools::getValue('select_submitBulk');
|
$this->action = 'bulk'.Tools::getValue('select_submitBulk');
|
||||||
$this->boxes = Tools::getValue($this->table.'Box');
|
$this->boxes = Tools::getValue($this->table.'Box');
|
||||||
@@ -2235,12 +2234,16 @@ class AdminControllerCore extends Controller
|
|||||||
/**
|
/**
|
||||||
* Overload this method for custom checking
|
* Overload this method for custom checking
|
||||||
*/
|
*/
|
||||||
protected function _childValidation(){}
|
protected function _childValidation()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display object details
|
* Display object details
|
||||||
*/
|
*/
|
||||||
public function viewDetails(){}
|
public function viewDetails()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called before deletion
|
* Called before deletion
|
||||||
@@ -2429,7 +2432,7 @@ class AdminControllerCore extends Controller
|
|||||||
$max_size = isset($this->max_image_size) ? $this->max_image_size : 0;
|
$max_size = isset($this->max_image_size) ? $this->max_image_size : 0;
|
||||||
if ($error = ImageManager::validateUpload($_FILES[$name], Tools::getMaxUploadSize($max_size)))
|
if ($error = ImageManager::validateUpload($_FILES[$name], Tools::getMaxUploadSize($max_size)))
|
||||||
$this->errors[] = $error;
|
$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;
|
return false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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
|
// 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])
|
if (!isset($this->index[$classname])
|
||||||
|| ($this->index[$classname] && !is_file($this->root_dir.$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();
|
$this->generateIndex();
|
||||||
|
|
||||||
// If $classname has not core suffix (E.g. Shop, Product)
|
// If $classname has not core suffix (E.g. Shop, Product)
|
||||||
|
|||||||
+23
-23
@@ -34,7 +34,7 @@ class BackupCore
|
|||||||
/** @var string default backup directory. */
|
/** @var string default backup directory. */
|
||||||
public static $backupDir = '/backups/';
|
public static $backupDir = '/backups/';
|
||||||
/** @var string custom backup directory. */
|
/** @var string custom backup directory. */
|
||||||
public $customBackupDir = NULL;
|
public $customBackupDir = null;
|
||||||
|
|
||||||
public $psBackupAll = true;
|
public $psBackupAll = true;
|
||||||
public $psBackupDropTable = true;
|
public $psBackupDropTable = true;
|
||||||
@@ -44,7 +44,7 @@ class BackupCore
|
|||||||
*
|
*
|
||||||
* @param string $filename Filename of the backup file
|
* @param string $filename Filename of the backup file
|
||||||
*/
|
*/
|
||||||
public function __construct($filename = NULL)
|
public function __construct($filename = null)
|
||||||
{
|
{
|
||||||
if ($filename)
|
if ($filename)
|
||||||
$this->id = $this->getRealBackupPath($filename);
|
$this->id = $this->getRealBackupPath($filename);
|
||||||
@@ -64,8 +64,8 @@ class BackupCore
|
|||||||
*/
|
*/
|
||||||
public function setCustomBackupPath($dir)
|
public function setCustomBackupPath($dir)
|
||||||
{
|
{
|
||||||
$customDir = DIRECTORY_SEPARATOR.trim($dir,'/').DIRECTORY_SEPARATOR;
|
$customDir = DIRECTORY_SEPARATOR.trim($dir, '/').DIRECTORY_SEPARATOR;
|
||||||
if(is_dir(_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.$customDir.DIRECTORY_SEPARATOR))
|
if (is_dir(_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.$customDir.DIRECTORY_SEPARATOR))
|
||||||
$this->customBackupDir = $customDir;
|
$this->customBackupDir = $customDir;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
@@ -80,14 +80,14 @@ class BackupCore
|
|||||||
* @param string $filename filename to use
|
* @param string $filename filename to use
|
||||||
* @return string full path
|
* @return string full path
|
||||||
*/
|
*/
|
||||||
public function getRealBackupPath($filename = NULL)
|
public function getRealBackupPath($filename = null)
|
||||||
{
|
{
|
||||||
$backupDir = Backup::getBackupPath($filename);
|
$backupDir = Backup::getBackupPath($filename);
|
||||||
if (!empty($this->customBackupDir))
|
if (!empty($this->customBackupDir))
|
||||||
{
|
{
|
||||||
$backupDir = str_replace(_PS_ADMIN_DIR_.self::$backupDir, _PS_ADMIN_DIR_.$this->customBackupDir, $backupDir);
|
$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;
|
$backupDir .= DIRECTORY_SEPARATOR;
|
||||||
}
|
}
|
||||||
return $backupDir;
|
return $backupDir;
|
||||||
@@ -106,12 +106,12 @@ class BackupCore
|
|||||||
die(Tools::displayError('Backups directory does not exist.'));
|
die(Tools::displayError('Backups directory does not exist.'));
|
||||||
|
|
||||||
// Check the realpath so we can validate the backup file is under the backup directory
|
// Check the realpath so we can validate the backup file is under the backup directory
|
||||||
if(!empty($filename))
|
if (!empty($filename))
|
||||||
$backupfile = realpath($backupdir.'/'.$filename);
|
$backupfile = realpath($backupdir.'/'.$filename);
|
||||||
else
|
else
|
||||||
$backupfile = $backupdir.DIRECTORY_SEPARATOR;
|
$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());
|
die (Tools::displayError());
|
||||||
|
|
||||||
return $backupfile;
|
return $backupfile;
|
||||||
@@ -197,19 +197,19 @@ class BackupCore
|
|||||||
|
|
||||||
if ($fp === false)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->id = realpath($backupfile);
|
$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");
|
fwrite($fp, "\n".'SET NAMES \'utf8\';'."\n\n");
|
||||||
|
|
||||||
// Find all tables
|
// Find all tables
|
||||||
$tables = Db::getInstance()->executeS('SHOW TABLES');
|
$tables = Db::getInstance()->executeS('SHOW TABLES');
|
||||||
$found = 0;
|
$found = 0;
|
||||||
foreach ($tables AS $table)
|
foreach ($tables as $table)
|
||||||
{
|
{
|
||||||
$table = current($table);
|
$table = current($table);
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@ class BackupCore
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Export the table schema
|
// 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']))
|
if (count($schema) != 1 || !isset($schema[0]['Table']) || !isset($schema[0]['Create Table']))
|
||||||
{
|
{
|
||||||
@@ -228,36 +228,36 @@ class BackupCore
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fwrite($fp, '/* Scheme for table ' . $schema[0]['Table'] . " */\n");
|
fwrite($fp, '/* Scheme for table '.$schema[0]['Table']." */\n");
|
||||||
|
|
||||||
if ($this->psBackupDropTable)
|
if ($this->psBackupDropTable)
|
||||||
fwrite($fp, 'DROP TABLE IF EXISTS `'.$schema[0]['Table'].'`;'."\n");
|
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))
|
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();
|
$sizeof = DB::getInstance()->NumRows();
|
||||||
$lines = explode("\n", $schema[0]['Create Table']);
|
$lines = explode("\n", $schema[0]['Create Table']);
|
||||||
|
|
||||||
if ($data AND $sizeof > 0)
|
if ($data && $sizeof > 0)
|
||||||
{
|
{
|
||||||
// Export the table data
|
// Export the table data
|
||||||
fwrite($fp, 'INSERT INTO `' . $schema[0]['Table'] . "` VALUES\n");
|
fwrite($fp, 'INSERT INTO `'.$schema[0]['Table']."` VALUES\n");
|
||||||
$i = 1;
|
$i = 1;
|
||||||
while ($row = DB::getInstance()->nextRow($data))
|
while ($row = DB::getInstance()->nextRow($data))
|
||||||
{
|
{
|
||||||
$s = '(';
|
$s = '(';
|
||||||
|
|
||||||
foreach ($row AS $field => $value)
|
foreach ($row as $field => $value)
|
||||||
{
|
{
|
||||||
$tmp = "'" . pSQL($value) . "',";
|
$tmp = "'".pSQL($value)."',";
|
||||||
if($tmp != "'',")
|
if ($tmp != "'',")
|
||||||
$s .= $tmp;
|
$s .= $tmp;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach($lines AS $line)
|
foreach ($lines as $line)
|
||||||
if (strpos($line, '`'.$field.'`') !== false)
|
if (strpos($line, '`'.$field.'`') !== false)
|
||||||
{
|
{
|
||||||
if (preg_match('/(.*NOT NULL.*)/Ui', $line))
|
if (preg_match('/(.*NOT NULL.*)/Ui', $line))
|
||||||
@@ -270,7 +270,7 @@ class BackupCore
|
|||||||
}
|
}
|
||||||
$s = rtrim($s, ',');
|
$s = rtrim($s, ',');
|
||||||
|
|
||||||
if ($i%200 == 0 AND $i < $sizeof)
|
if ($i % 200 == 0 && $i < $sizeof)
|
||||||
$s .= ");\nINSERT INTO `".$schema[0]['Table']."` VALUES\n";
|
$s .= ");\nINSERT INTO `".$schema[0]['Table']."` VALUES\n";
|
||||||
elseif ($i < $sizeof)
|
elseif ($i < $sizeof)
|
||||||
$s .= "),\n";
|
$s .= "),\n";
|
||||||
|
|||||||
+17
-17
@@ -63,15 +63,15 @@ class CMSCore extends ObjectModel
|
|||||||
'objectsNodeName' => 'content_management_system',
|
'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);
|
$this->position = CMS::getLastPosition((int)$this->id_cms_category);
|
||||||
return parent::add($autodate, true);
|
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 $this->cleanPositions($this->id_cms_category);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ class CMSCore extends ObjectModel
|
|||||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||||
SELECT c.id_cms, cl.link_rewrite, cl.meta_title
|
SELECT c.id_cms, cl.link_rewrite, cl.meta_title
|
||||||
FROM '._DB_PREFIX_.'cms c
|
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').'
|
'.Context::getContext()->shop->addSqlAssociation('cms', 'c').'
|
||||||
WHERE 1
|
WHERE 1
|
||||||
'.(($selection !== null) ? ' AND c.id_cms IN ('.implode(',', array_map('intval', $selection)).')' : '').
|
'.(($selection !== null) ? ' AND c.id_cms IN ('.implode(',', array_map('intval', $selection)).')' : '').
|
||||||
@@ -102,7 +102,7 @@ class CMSCore extends ObjectModel
|
|||||||
if ($result)
|
if ($result)
|
||||||
foreach ($result as $row)
|
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;
|
$links[] = $row;
|
||||||
}
|
}
|
||||||
return $links;
|
return $links;
|
||||||
@@ -119,7 +119,7 @@ class CMSCore extends ObjectModel
|
|||||||
JOIN '._DB_PREFIX_.'cms_lang l ON (c.id_cms = l.id_cms)
|
JOIN '._DB_PREFIX_.'cms_lang l ON (c.id_cms = l.id_cms)
|
||||||
'.Context::getContext()->shop->addSqlAssociation('cms', 'c').'
|
'.Context::getContext()->shop->addSqlAssociation('cms', 'c').'
|
||||||
'.(($id_block) ? 'JOIN '._DB_PREFIX_.'block_cms b ON (c.id_cms = b.id_cms)' : '').'
|
'.(($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
|
GROUP BY c.id_cms
|
||||||
ORDER BY c.`position`');
|
ORDER BY c.`position`');
|
||||||
}
|
}
|
||||||
@@ -135,10 +135,10 @@ class CMSCore extends ObjectModel
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
foreach ($res as $cms)
|
foreach ($res as $cms)
|
||||||
if ((int)($cms['id_cms']) == (int)($this->id))
|
if ((int)$cms['id_cms'] == (int)$this->id)
|
||||||
$movedCms = $cms;
|
$moved_cms = $cms;
|
||||||
|
|
||||||
if (!isset($movedCms) || !isset($position))
|
if (!isset($moved_cms) || !isset($position))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// < and > statements rather than BETWEEN operator
|
// < and > statements rather than BETWEEN operator
|
||||||
@@ -148,14 +148,14 @@ class CMSCore extends ObjectModel
|
|||||||
SET `position`= `position` '.($way ? '- 1' : '+ 1').'
|
SET `position`= `position` '.($way ? '- 1' : '+ 1').'
|
||||||
WHERE `position`
|
WHERE `position`
|
||||||
'.($way
|
'.($way
|
||||||
? '> '.(int)($movedCms['position']).' AND `position` <= '.(int)($position)
|
? '> '.(int)$moved_cms['position'].' AND `position` <= '.(int)$position
|
||||||
: '< '.(int)($movedCms['position']).' AND `position` >= '.(int)($position)).'
|
: '< '.(int)$moved_cms['position'].' AND `position` >= '.(int)$position).'
|
||||||
AND `id_cms_category`='.(int)($movedCms['id_cms_category']))
|
AND `id_cms_category`='.(int)$moved_cms['id_cms_category'])
|
||||||
&& Db::getInstance()->execute('
|
&& Db::getInstance()->execute('
|
||||||
UPDATE `'._DB_PREFIX_.'cms`
|
UPDATE `'._DB_PREFIX_.'cms`
|
||||||
SET `position` = '.(int)($position).'
|
SET `position` = '.(int)$position.'
|
||||||
WHERE `id_cms` = '.(int)($movedCms['id_cms']).'
|
WHERE `id_cms` = '.(int)$moved_cms['id_cms'].'
|
||||||
AND `id_cms_category`='.(int)($movedCms['id_cms_category'])));
|
AND `id_cms_category`='.(int)$moved_cms['id_cms_category']));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function cleanPositions($id_category)
|
public static function cleanPositions($id_category)
|
||||||
@@ -163,7 +163,7 @@ class CMSCore extends ObjectModel
|
|||||||
$result = Db::getInstance()->executeS('
|
$result = Db::getInstance()->executeS('
|
||||||
SELECT `id_cms`
|
SELECT `id_cms`
|
||||||
FROM `'._DB_PREFIX_.'cms`
|
FROM `'._DB_PREFIX_.'cms`
|
||||||
WHERE `id_cms_category` = '.(int)($id_category).'
|
WHERE `id_cms_category` = '.(int)$id_category.'
|
||||||
ORDER BY `position`');
|
ORDER BY `position`');
|
||||||
for ($i = 0, $total = count($result); $i < $total; ++$i)
|
for ($i = 0, $total = count($result); $i < $total; ++$i)
|
||||||
{
|
{
|
||||||
@@ -178,7 +178,7 @@ class CMSCore extends ObjectModel
|
|||||||
|
|
||||||
public static function getLastPosition($id_category)
|
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)
|
public static function getCMSPages($id_lang = null, $id_cms_category = null, $active = true)
|
||||||
|
|||||||
+67
-72
@@ -95,43 +95,38 @@ class CMSCategoryCore extends ObjectModel
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
public function __construct($id_cms_category = null, $id_lang = null)
|
public function add($autodate = true, $null_values = false)
|
||||||
{
|
|
||||||
parent::__construct($id_cms_category, $id_lang);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function add($autodate = true, $nullValues = false)
|
|
||||||
{
|
{
|
||||||
$this->position = CMSCategory::getLastPosition((int)$this->id_parent);
|
$this->position = CMSCategory::getLastPosition((int)$this->id_parent);
|
||||||
$this->level_depth = $this->calcLevelDepth();
|
$this->level_depth = $this->calcLevelDepth();
|
||||||
foreach ($this->name as $k => $value)
|
foreach ($this->name as $k => $value)
|
||||||
if (preg_match('/^[1-9]\./', $value))
|
if (preg_match('/^[1-9]\./', $value))
|
||||||
$this->name[$k] = '0'.$value;
|
$this->name[$k] = '0'.$value;
|
||||||
$ret = parent::add($autodate);
|
$ret = parent::add($autodate, $null_values);
|
||||||
$this->cleanPositions($this->id_parent);
|
$this->cleanPositions($this->id_parent);
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($nullValues = false)
|
public function update($null_values = false)
|
||||||
{
|
{
|
||||||
$this->level_depth = $this->calcLevelDepth();
|
$this->level_depth = $this->calcLevelDepth();
|
||||||
foreach ($this->name as $k => $value)
|
foreach ($this->name as $k => $value)
|
||||||
if (preg_match('/^[1-9]\./', $value))
|
if (preg_match('/^[1-9]\./', $value))
|
||||||
$this->name[$k] = '0'.$value;
|
$this->name[$k] = '0'.$value;
|
||||||
return parent::update();
|
return parent::update($null_values);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursive scan of subcategories
|
* 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 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
|
* @param integer $idLang Specify the id of the language used
|
||||||
*
|
*
|
||||||
* @return array Subcategories lite tree
|
* @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)
|
if (!$link)
|
||||||
$link = Context::getContext()->link;
|
$link = Context::getContext()->link;
|
||||||
@@ -142,16 +137,16 @@ class CMSCategoryCore extends ObjectModel
|
|||||||
// recursivity for subcategories
|
// recursivity for subcategories
|
||||||
$children = array();
|
$children = array();
|
||||||
$subcats = $this->getSubCategories($id_lang, true);
|
$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)
|
foreach ($subcats as &$subcat)
|
||||||
{
|
{
|
||||||
if (!$subcat['id_cms_category'])
|
if (!$subcat['id_cms_category'])
|
||||||
break;
|
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 = new CMSCategory($subcat['id_cms_category'], $id_lang);
|
||||||
$categ->name = CMSCategory::hideCMSCategoryPosition($categ->name);
|
$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)
|
public static function recurseCMSCategory($categories, $current, $id_cms_category = 1, $id_selected = 1, $is_html = 0)
|
||||||
{
|
{
|
||||||
$html = '<option value="'.$id_cms_category.'"'.(($id_selected == $id_cms_category) ? ' selected="selected"' : '').'>'.
|
$html = '<option value="'.$id_cms_category.'"'.(($id_selected == $id_cms_category) ? ' selected="selected"' : '').'>'
|
||||||
str_repeat(' ', $current['infos']['level_depth'] * 5).CMSCategory::hideCMSCategoryPosition(stripslashes($current['infos']['name'])).'</option>';
|
.str_repeat(' ', $current['infos']['level_depth'] * 5)
|
||||||
|
.CMSCategory::hideCMSCategoryPosition(stripslashes($current['infos']['name'])).'</option>';
|
||||||
if ($is_html == 0)
|
if ($is_html == 0)
|
||||||
echo $html;
|
echo $html;
|
||||||
if (isset($categories[$id_cms_category]))
|
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 &$toDelete Array reference where categories ID will be saved
|
||||||
* @param array $id_cms_category Parent CMSCategory ID
|
* @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());
|
die(Tools::displayError());
|
||||||
|
|
||||||
$result = Db::getInstance()->executeS('
|
$result = Db::getInstance()->executeS('
|
||||||
SELECT `id_cms_category`
|
SELECT `id_cms_category`
|
||||||
FROM `'._DB_PREFIX_.'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)
|
foreach ($result as $row)
|
||||||
{
|
{
|
||||||
$toDelete[] = (int)($row['id_cms_category']);
|
$to_delete[] = (int)$row['id_cms_category'];
|
||||||
$this->recursiveDelete($toDelete, (int)($row['id_cms_category']));
|
$this->recursiveDelete($to_delete, (int)$row['id_cms_category']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,26 +242,26 @@ class CMSCategoryCore extends ObjectModel
|
|||||||
|
|
||||||
$this->clearCache();
|
$this->clearCache();
|
||||||
|
|
||||||
/* Get childs categories */
|
// Get children categories
|
||||||
$toDelete = array((int)($this->id));
|
$to_delete = array((int)$this->id);
|
||||||
$this->recursiveDelete($toDelete, (int)($this->id));
|
$this->recursiveDelete($to_delete, (int)$this->id);
|
||||||
$toDelete = array_unique($toDelete);
|
$to_delete = array_unique($to_delete);
|
||||||
|
|
||||||
/* Delete CMS Category and its child from database */
|
// Delete CMS Category and its child from database
|
||||||
$list = count($toDelete) > 1 ? implode(',', $toDelete) : (int)($this->id);
|
$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` WHERE `id_cms_category` IN ('.$list.')');
|
||||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'cms_category_lang` 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);
|
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('
|
$result = Db::getInstance()->executeS('
|
||||||
SELECT `id_cms`
|
SELECT `id_cms`
|
||||||
FROM `'._DB_PREFIX_.'cms`
|
FROM `'._DB_PREFIX_.'cms`
|
||||||
WHERE `id_cms_category` IN ('.$list.')');
|
WHERE `id_cms_category` IN ('.$list.')');
|
||||||
foreach ($result as $p)
|
foreach ($result as $p)
|
||||||
{
|
{
|
||||||
$product = new CMS((int)($p['id_cms']));
|
$product = new CMS($p['id_cms']);
|
||||||
if (Validate::isLoadedObject($product))
|
if (Validate::isLoadedObject($product))
|
||||||
$product->delete();
|
$product->delete();
|
||||||
}
|
}
|
||||||
@@ -282,7 +278,7 @@ class CMSCategoryCore extends ObjectModel
|
|||||||
$return = 1;
|
$return = 1;
|
||||||
foreach ($categories as $id_category_cms)
|
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 &= $category_cms->delete();
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
@@ -295,7 +291,7 @@ class CMSCategoryCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public function calcLevelDepth()
|
public function calcLevelDepth()
|
||||||
{
|
{
|
||||||
$parentCMSCategory = new CMSCategory((int)($this->id_parent));
|
$parentCMSCategory = new CMSCategory($this->id_parent);
|
||||||
if (!$parentCMSCategory)
|
if (!$parentCMSCategory)
|
||||||
die('parent CMS Category does not exist');
|
die('parent CMS Category does not exist');
|
||||||
return $parentCMSCategory->level_depth + 1;
|
return $parentCMSCategory->level_depth + 1;
|
||||||
@@ -317,7 +313,7 @@ class CMSCategoryCore extends ObjectModel
|
|||||||
SELECT *
|
SELECT *
|
||||||
FROM `'._DB_PREFIX_.'cms_category` c
|
FROM `'._DB_PREFIX_.'cms_category` c
|
||||||
LEFT JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON c.`id_cms_category` = cl.`id_cms_category`
|
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' : '').'
|
'.($active ? 'AND `active` = 1' : '').'
|
||||||
ORDER BY `name` ASC');
|
ORDER BY `name` ASC');
|
||||||
|
|
||||||
@@ -336,7 +332,7 @@ class CMSCategoryCore extends ObjectModel
|
|||||||
SELECT c.`id_cms_category`, cl.`name`
|
SELECT c.`id_cms_category`, cl.`name`
|
||||||
FROM `'._DB_PREFIX_.'cms_category` c
|
FROM `'._DB_PREFIX_.'cms_category` c
|
||||||
LEFT JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON (c.`id_cms_category` = cl.`id_cms_category`)
|
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`');
|
ORDER BY cl.`name`');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,8 +351,8 @@ class CMSCategoryCore extends ObjectModel
|
|||||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
$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
|
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
|
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 `id_parent` = '.(int)($this->id).'
|
WHERE `id_parent` = '.(int)$this->id.'
|
||||||
'.($active ? 'AND `active` = 1' : '').'
|
'.($active ? 'AND `active` = 1' : '').'
|
||||||
GROUP BY c.`id_cms_category`
|
GROUP BY c.`id_cms_category`
|
||||||
ORDER BY `name` ASC');
|
ORDER BY `name` ASC');
|
||||||
@@ -399,19 +395,19 @@ class CMSCategoryCore extends ObjectModel
|
|||||||
SELECT c.`id_cms_category`, cl.`name`, cl.`link_rewrite`
|
SELECT c.`id_cms_category`, cl.`name`, cl.`link_rewrite`
|
||||||
FROM `'._DB_PREFIX_.'cms_category` c
|
FROM `'._DB_PREFIX_.'cms_category` c
|
||||||
LEFT JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON c.`id_cms_category` = cl.`id_cms_category`
|
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.'
|
||||||
AND c.`id_parent` = '.(int)($id_parent).'
|
AND c.`id_parent` = '.(int)$id_parent.'
|
||||||
'.($active ? 'AND `active` = 1' : '').'
|
'.($active ? 'AND `active` = 1' : '').'
|
||||||
ORDER BY `name` ASC');
|
ORDER BY `name` ASC');
|
||||||
|
|
||||||
/* Modify SQL result */
|
// Modify SQL result
|
||||||
$resultsArray = array();
|
$results_array = array();
|
||||||
foreach ($result as $row)
|
foreach ($result as $row)
|
||||||
{
|
{
|
||||||
$row['name'] = CMSCategory::hideCMSCategoryPosition($row['name']);
|
$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_cms_category == $id_parent) return false;
|
||||||
if ($id_parent == 1) return true;
|
if ($id_parent == 1) return true;
|
||||||
$i = (int)($id_parent);
|
$i = (int)$id_parent;
|
||||||
|
|
||||||
while (42)
|
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 (!isset($result['id_parent'])) return false;
|
||||||
if ($result['id_parent'] == $id_cms_category) return false;
|
if ($result['id_parent'] == $id_cms_category) return false;
|
||||||
if ($result['id_parent'] == 1) return true;
|
if ($result['id_parent'] == 1) return true;
|
||||||
@@ -448,8 +444,8 @@ class CMSCategoryCore extends ObjectModel
|
|||||||
SELECT cl.`link_rewrite`
|
SELECT cl.`link_rewrite`
|
||||||
FROM `'._DB_PREFIX_.'cms_category` c
|
FROM `'._DB_PREFIX_.'cms_category` c
|
||||||
LEFT JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON c.`id_cms_category` = cl.`id_cms_category`
|
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.'
|
||||||
AND c.`id_cms_category` = '.(int)($id_cms_category));
|
AND c.`id_cms_category` = '.(int)$id_cms_category);
|
||||||
self::$_links[$id_cms_category.'-'.$id_lang] = $result['link_rewrite'];
|
self::$_links[$id_cms_category.'-'.$id_lang] = $result['link_rewrite'];
|
||||||
return $result['link_rewrite'];
|
return $result['link_rewrite'];
|
||||||
}
|
}
|
||||||
@@ -464,13 +460,12 @@ class CMSCategoryCore extends ObjectModel
|
|||||||
public function getName($id_lang = null)
|
public function getName($id_lang = null)
|
||||||
{
|
{
|
||||||
$context = Context::getContext();
|
$context = Context::getContext();
|
||||||
|
|
||||||
if (!$id_lang)
|
if (!$id_lang)
|
||||||
{
|
{
|
||||||
if (isset($this->name[Context::getContext()->language->id]))
|
if (isset($this->name[$context->language->id]))
|
||||||
$id_lang = Context::getContext()->language->id;
|
$id_lang = $context->language->id;
|
||||||
else
|
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] : '';
|
return isset($this->name[$id_lang]) ? $this->name[$id_lang] : '';
|
||||||
}
|
}
|
||||||
@@ -495,7 +490,7 @@ class CMSCategoryCore extends ObjectModel
|
|||||||
return Db::getInstance()->executeS('
|
return Db::getInstance()->executeS('
|
||||||
SELECT c.*, cl.*
|
SELECT c.*, cl.*
|
||||||
FROM `'._DB_PREFIX_.'cms_category` c
|
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');
|
WHERE `name` LIKE \'%'.pSQL($query).'%\' AND c.`id_cms_category` != 1');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -514,10 +509,10 @@ class CMSCategoryCore extends ObjectModel
|
|||||||
return Db::getInstance()->getRow('
|
return Db::getInstance()->getRow('
|
||||||
SELECT c.*, cl.*
|
SELECT c.*, cl.*
|
||||||
FROM `'._DB_PREFIX_.'cms_category` c
|
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).'\'
|
WHERE `name` LIKE \''.pSQL($CMSCategory_name).'\'
|
||||||
AND c.`id_cms_category` != 1
|
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;
|
$id_lang = Context::getContext()->language->id;
|
||||||
|
|
||||||
$categories = null;
|
$categories = null;
|
||||||
$idCurrent = $this->id;
|
$id_current = $this->id;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
$query = '
|
$query = '
|
||||||
SELECT c.*, cl.*
|
SELECT c.*, cl.*
|
||||||
FROM `'._DB_PREFIX_.'cms_category` c
|
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 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);
|
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||||
|
|
||||||
$categories[] = $result[0];
|
$categories[] = $result[0];
|
||||||
if (!$result || $result[0]['id_parent'] == 1)
|
if (!$result || $result[0]['id_parent'] == 1)
|
||||||
return $categories;
|
return $categories;
|
||||||
$idCurrent = $result[0]['id_parent'];
|
$id_current = $result[0]['id_parent'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,9 +556,9 @@ class CMSCategoryCore extends ObjectModel
|
|||||||
return false;
|
return false;
|
||||||
foreach ($res as $category)
|
foreach ($res as $category)
|
||||||
if ((int)$category['id_cms_category'] == (int)$this->id)
|
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;
|
return false;
|
||||||
// < and > statements rather than BETWEEN operator
|
// < and > statements rather than BETWEEN operator
|
||||||
// since BETWEEN is treated differently according to databases
|
// since BETWEEN is treated differently according to databases
|
||||||
@@ -572,14 +567,14 @@ class CMSCategoryCore extends ObjectModel
|
|||||||
SET `position`= `position` '.($way ? '- 1' : '+ 1').'
|
SET `position`= `position` '.($way ? '- 1' : '+ 1').'
|
||||||
WHERE `position`
|
WHERE `position`
|
||||||
'.($way
|
'.($way
|
||||||
? '> '.(int)($movedCategory['position']).' AND `position` <= '.(int)$position
|
? '> '.(int)$moved_category['position'].' AND `position` <= '.(int)$position
|
||||||
: '< '.(int)($movedCategory['position']).' AND `position` >= '.(int)$position).'
|
: '< '.(int)$moved_category['position'].' AND `position` >= '.(int)$position).'
|
||||||
AND `id_parent`='.(int)($movedCategory['id_parent']))
|
AND `id_parent`='.(int)$moved_category['id_parent'])
|
||||||
&& Db::getInstance()->execute('
|
&& Db::getInstance()->execute('
|
||||||
UPDATE `'._DB_PREFIX_.'cms_category`
|
UPDATE `'._DB_PREFIX_.'cms_category`
|
||||||
SET `position` = '.(int)$position.'
|
SET `position` = '.(int)$position.'
|
||||||
WHERE `id_parent` = '.(int)$movedCategory['id_parent'].'
|
WHERE `id_parent` = '.(int)$moved_category['id_parent'].'
|
||||||
AND `id_cms_category`='.(int)$movedCategory['id_cms_category']));
|
AND `id_cms_category`='.(int)$moved_category['id_cms_category']));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function cleanPositions($id_category_parent)
|
public static function cleanPositions($id_category_parent)
|
||||||
@@ -587,24 +582,24 @@ class CMSCategoryCore extends ObjectModel
|
|||||||
$result = Db::getInstance()->executeS('
|
$result = Db::getInstance()->executeS('
|
||||||
SELECT `id_cms_category`
|
SELECT `id_cms_category`
|
||||||
FROM `'._DB_PREFIX_.'cms_category`
|
FROM `'._DB_PREFIX_.'cms_category`
|
||||||
WHERE `id_parent` = '.(int)($id_category_parent).'
|
WHERE `id_parent` = '.(int)$id_category_parent.'
|
||||||
ORDER BY `position`');
|
ORDER BY `position`');
|
||||||
$sizeof = count($result);
|
$sizeof = count($result);
|
||||||
for ($i = 0; $i < $sizeof; ++$i)
|
for ($i = 0; $i < $sizeof; ++$i)
|
||||||
{
|
{
|
||||||
$sql = '
|
$sql = '
|
||||||
UPDATE `'._DB_PREFIX_.'cms_category`
|
UPDATE `'._DB_PREFIX_.'cms_category`
|
||||||
SET `position` = '.(int)($i).'
|
SET `position` = '.(int)$i.'
|
||||||
WHERE `id_parent` = '.(int)($id_category_parent).'
|
WHERE `id_parent` = '.(int)$id_category_parent.'
|
||||||
AND `id_cms_category` = '.(int)($result[$i]['id_cms_category']);
|
AND `id_cms_category` = '.(int)$result[$i]['id_cms_category'];
|
||||||
Db::getInstance()->execute($sql);
|
Db::getInstance()->execute($sql);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getLastPosition($id_category_parent)
|
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)
|
public static function getUrlRewriteInformations($id_category)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
abstract class CarrierModuleCore extends Module
|
abstract class CarrierModuleCore extends Module
|
||||||
{
|
{
|
||||||
abstract function getOrderShippingCost($params,$shipping_cost);
|
abstract public function getOrderShippingCost($params, $shipping_cost);
|
||||||
abstract function getOrderShippingCostExternal($params);
|
abstract public function getOrderShippingCostExternal($params);
|
||||||
}
|
}
|
||||||
|
|
||||||
+7
-11
@@ -787,9 +787,7 @@ class CartCore extends ObjectModel
|
|||||||
$product_qty = (int)$result2['quantity'];
|
$product_qty = (int)$result2['quantity'];
|
||||||
// Quantity for product pack
|
// Quantity for product pack
|
||||||
if (Pack::isPack($id_product))
|
if (Pack::isPack($id_product))
|
||||||
{
|
|
||||||
$product_qty = Pack::getQuantity($id_product, $id_product_attribute);
|
$product_qty = Pack::getQuantity($id_product, $id_product_attribute);
|
||||||
}
|
|
||||||
$new_qty = (int)$result['quantity'] + (int)$quantity;
|
$new_qty = (int)$result['quantity'] + (int)$quantity;
|
||||||
$qty = '+ '.(int)$quantity;
|
$qty = '+ '.(int)$quantity;
|
||||||
|
|
||||||
@@ -834,9 +832,7 @@ class CartCore extends ObjectModel
|
|||||||
|
|
||||||
// Quantity for product pack
|
// Quantity for product pack
|
||||||
if (Pack::isPack($id_product))
|
if (Pack::isPack($id_product))
|
||||||
{
|
|
||||||
$result2['quantity'] = Pack::getQuantity($id_product, $id_product_attribute);
|
$result2['quantity'] = Pack::getQuantity($id_product, $id_product_attribute);
|
||||||
}
|
|
||||||
|
|
||||||
if (!Product::isAvailableWhenOutOfStock((int)$result2['out_of_stock']))
|
if (!Product::isAvailableWhenOutOfStock((int)$result2['out_of_stock']))
|
||||||
if ((int)$quantity > $result2['quantity'])
|
if ((int)$quantity > $result2['quantity'])
|
||||||
@@ -868,7 +864,7 @@ class CartCore extends ObjectModel
|
|||||||
CartRule::autoAddToCart($context);
|
CartRule::autoAddToCart($context);
|
||||||
|
|
||||||
if ($product->customizable)
|
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
|
else
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1866,7 +1862,7 @@ class CartCore extends ObjectModel
|
|||||||
$nameList = array();
|
$nameList = array();
|
||||||
foreach ($option['carrier_list'] as $carrier)
|
foreach ($option['carrier_list'] as $carrier)
|
||||||
$nameList[] = $carrier['instance']->name;
|
$nameList[] = $carrier['instance']->name;
|
||||||
$name = join(' -' , $nameList);
|
$name = join(' -', $nameList);
|
||||||
$img = ''; // No images if multiple carriers
|
$img = ''; // No images if multiple carriers
|
||||||
$delay = '';
|
$delay = '';
|
||||||
}
|
}
|
||||||
@@ -1906,7 +1902,7 @@ class CartCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
$elm = explode($delimiter, $string);
|
$elm = explode($delimiter, $string);
|
||||||
$max = max($elm);
|
$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];
|
$delimiter_len = $int[0];
|
||||||
$int = substr($int, 1);
|
$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);
|
return join($delimiter, $elm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1967,7 +1963,7 @@ class CartCore extends ObjectModel
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$delivery_option_list = $this->getDeliveryOptionList(null , true);
|
$delivery_option_list = $this->getDeliveryOptionList(null, true);
|
||||||
|
|
||||||
foreach ($delivery_option_list as $id_address => $options)
|
foreach ($delivery_option_list as $id_address => $options)
|
||||||
if (!isset($delivery_option[$id_address]))
|
if (!isset($delivery_option[$id_address]))
|
||||||
@@ -2916,8 +2912,8 @@ class CartCore extends ObjectModel
|
|||||||
$sql->where('id_cart = '.(int)$this->id);
|
$sql->where('id_cart = '.(int)$this->id);
|
||||||
$duplicatedQuantity = Db::getInstance()->getValue($sql);
|
$duplicatedQuantity = Db::getInstance()->getValue($sql);
|
||||||
|
|
||||||
if ($duplicatedQuantity > $quantity) {
|
if ($duplicatedQuantity > $quantity)
|
||||||
|
{
|
||||||
$sql = 'UPDATE '._DB_PREFIX_.'cart_product
|
$sql = 'UPDATE '._DB_PREFIX_.'cart_product
|
||||||
SET `quantity` = `quantity` - '.(int)$quantity.'
|
SET `quantity` = `quantity` - '.(int)$quantity.'
|
||||||
WHERE id_cart = '.(int)$this->id.'
|
WHERE id_cart = '.(int)$this->id.'
|
||||||
|
|||||||
+19
-15
@@ -216,7 +216,7 @@ class CartRuleCore extends ObjectModel
|
|||||||
|
|
||||||
public function getProductRules()
|
public function getProductRules()
|
||||||
{
|
{
|
||||||
if (!Validate::isLoadedObject($this) OR $this->product_restriction == 0)
|
if (!Validate::isLoadedObject($this) || $this->product_restriction == 0)
|
||||||
return array();
|
return array();
|
||||||
|
|
||||||
$productRules = array();
|
$productRules = array();
|
||||||
@@ -274,7 +274,7 @@ class CartRuleCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
if ($otherCartRule['id_cart_rule'] == $this->id && !$alreadyInCart)
|
if ($otherCartRule['id_cart_rule'] == $this->id && !$alreadyInCart)
|
||||||
return Tools::displayError('This voucher is already in your cart');
|
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('
|
$combinable = Db::getInstance()->getValue('
|
||||||
SELECT id_cart_rule_1
|
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
|
// 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('
|
$id_cart_rule = (int)Db::getInstance()->getValue('
|
||||||
SELECT crc.id_cart_rule
|
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
|
// 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('
|
$id_cart_rule = (int)Db::getInstance()->getValue('
|
||||||
SELECT crc.id_cart_rule
|
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())
|
if (!CartRule::isFeatureActive())
|
||||||
return 0;
|
return 0;
|
||||||
@@ -435,13 +441,11 @@ class CartRuleCore extends ObjectModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Discount (%) on the whole order
|
// 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;
|
$reductionValue += $context->cart->getOrderTotal($useTax, Cart::ONLY_PRODUCTS) * $this->reduction_percent / 100;
|
||||||
}
|
|
||||||
|
|
||||||
// Discount (%) on a specific product
|
// 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)
|
foreach ($context->cart->getProducts() as $product)
|
||||||
if ($product['id_product'] == $this->reduction_product)
|
if ($product['id_product'] == $this->reduction_product)
|
||||||
@@ -449,7 +453,7 @@ class CartRuleCore extends ObjectModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Discount (%) on the cheapest product
|
// Discount (%) on the cheapest product
|
||||||
if ($this->reduction_percent AND $this->reduction_product == -1)
|
if ($this->reduction_percent && $this->reduction_product == -1)
|
||||||
{
|
{
|
||||||
$minPrice = false;
|
$minPrice = false;
|
||||||
foreach ($context->cart->getProducts() as $product)
|
foreach ($context->cart->getProducts() as $product)
|
||||||
@@ -610,7 +614,7 @@ class CartRuleCore extends ObjectModel
|
|||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function autoRemoveFromCart($context = NULL)
|
public static function autoRemoveFromCart($context = null)
|
||||||
{
|
{
|
||||||
if (!CartRule::isFeatureActive())
|
if (!CartRule::isFeatureActive())
|
||||||
return;
|
return;
|
||||||
@@ -630,14 +634,14 @@ class CartRuleCore extends ObjectModel
|
|||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function autoAddToCart($context = NULL)
|
public static function autoAddToCart(Context $context = null)
|
||||||
{
|
{
|
||||||
if ($context === NULL)
|
if ($context === null)
|
||||||
$context = Context::getContext();
|
$context = Context::getContext();
|
||||||
if (!CartRule::isFeatureActive() || !Validate::isLoadedObject($context->cart))
|
if (!CartRule::isFeatureActive() || !Validate::isLoadedObject($context->cart))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$result = Db::getInstance()->ExecuteS('
|
$result = Db::getInstance()->executeS('
|
||||||
SELECT cr.*
|
SELECT cr.*
|
||||||
FROM '._DB_PREFIX_.'cart_rule cr
|
FROM '._DB_PREFIX_.'cart_rule cr
|
||||||
LEFT JOIN '._DB_PREFIX_.'cart_rule_carrier crca ON cr.id_cart_rule = crca.id_cart_rule
|
LEFT JOIN '._DB_PREFIX_.'cart_rule_carrier crca ON cr.id_cart_rule = crca.id_cart_rule
|
||||||
|
|||||||
@@ -150,12 +150,12 @@ class CategoryCore extends ObjectModel
|
|||||||
return strip_tags(stripslashes($description));
|
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);
|
$this->position = Category::getLastPosition((int)$this->id_parent);
|
||||||
if (!isset($this->level_depth))
|
if (!isset($this->level_depth))
|
||||||
$this->level_depth = $this->calcLevelDepth();
|
$this->level_depth = $this->calcLevelDepth();
|
||||||
$ret = parent::add($autodate);
|
$ret = parent::add($autodate, $null_values);
|
||||||
if (!isset($this->doNotRegenerateNTree) || !$this->doNotRegenerateNTree)
|
if (!isset($this->doNotRegenerateNTree) || !$this->doNotRegenerateNTree)
|
||||||
Category::regenerateEntireNtree();
|
Category::regenerateEntireNtree();
|
||||||
$this->updateGroup($this->groupBox);
|
$this->updateGroup($this->groupBox);
|
||||||
@@ -166,10 +166,10 @@ class CategoryCore extends ObjectModel
|
|||||||
/**
|
/**
|
||||||
* update category positions in parent
|
* update category positions in parent
|
||||||
*
|
*
|
||||||
* @param mixed $nullValues
|
* @param mixed $null_values
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function update($nullValues = false)
|
public function update($null_values = false)
|
||||||
{
|
{
|
||||||
if ($this->id_parent == $this->id)
|
if ($this->id_parent == $this->id)
|
||||||
throw new PrestaShopException('a category cannot be it\'s own parent');
|
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 the parent category was changed, we don't want to have 2 categories with the same position
|
||||||
if ($this->getDuplicatePosition())
|
if ($this->getDuplicatePosition())
|
||||||
$this->position = Category::getLastPosition((int)$this->id_parent);
|
$this->position = Category::getLastPosition((int)$this->id_parent);
|
||||||
$ret = parent::update($nullValues);
|
$ret = parent::update($null_values);
|
||||||
if (!isset($this->doNotRegenerateNTree) || !$this->doNotRegenerateNTree)
|
if (!isset($this->doNotRegenerateNTree) || !$this->doNotRegenerateNTree)
|
||||||
{
|
{
|
||||||
Category::regenerateEntireNtree();
|
Category::regenerateEntireNtree();
|
||||||
|
|||||||
+2
-2
@@ -142,12 +142,12 @@ class Curve
|
|||||||
$this->values = $values;
|
$this->values = $values;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValues($timeMode = false)
|
public function getValues($time_mode = false)
|
||||||
{
|
{
|
||||||
ksort($this->values);
|
ksort($this->values);
|
||||||
$string = '';
|
$string = '';
|
||||||
foreach ($this->values as $key => $value)
|
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 : '').'}';
|
return '{data:['.rtrim($string, ',').']'.(!empty($this->label) ? ',label:"'.$this->label.'"' : '').''.(!empty($this->type) ? ','.$this->type : '').'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ class QqUploadedFileForm
|
|||||||
$image = new Image($id_image);
|
$image = new Image($id_image);
|
||||||
if (!$new_path = $image->getPathForCreation())
|
if (!$new_path = $image->getPathForCreation())
|
||||||
return array('error' => Tools::displayError('An error occurred during new folder creation'));
|
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'));
|
return array('error' => Tools::displayError('An error occurred during the image upload'));
|
||||||
elseif (!ImageManager::resize($tmpName, $new_path.'.'.$image->image_format))
|
elseif (!ImageManager::resize($tmpName, $new_path.'.'.$image->image_format))
|
||||||
return array('error' => Tools::displayError('An error occurred while copying image.'));
|
return array('error' => Tools::displayError('An error occurred while copying image.'));
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ class FrontControllerCore extends Controller
|
|||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
// Switch language if needed and init cookie language
|
// 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;
|
$_GET['id_lang'] = $id_lang;
|
||||||
|
|
||||||
Tools::switchLanguage();
|
Tools::switchLanguage();
|
||||||
@@ -363,7 +363,7 @@ class FrontControllerCore extends Controller
|
|||||||
$this->displayRestrictedCountryPage();
|
$this->displayRestrictedCountryPage();
|
||||||
|
|
||||||
//live edit
|
//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))
|
if (!is_dir(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.$ad))
|
||||||
die(Tools::displayError());
|
die(Tools::displayError());
|
||||||
|
|
||||||
@@ -523,7 +523,7 @@ class FrontControllerCore extends Controller
|
|||||||
$this->context->smarty->display(_PS_THEME_DIR_.'footer.tpl');
|
$this->context->smarty->display(_PS_THEME_DIR_.'footer.tpl');
|
||||||
|
|
||||||
// live edit
|
// 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->assign(array('ad' => $ad, 'live_edit' => true));
|
||||||
$this->context->smarty->display(_PS_ALL_THEMES_DIR_.'live_edit.tpl');
|
$this->context->smarty->display(_PS_ALL_THEMES_DIR_.'live_edit.tpl');
|
||||||
|
|||||||
+1
-1
@@ -662,7 +662,7 @@ class ProductCore extends ObjectModel
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ($id = ProductDownload::getIdFromIdProduct($this->id))
|
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 false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Vendored
+1
-1
@@ -249,7 +249,7 @@ abstract class CacheCore
|
|||||||
|
|
||||||
// Get all table from the query and save them in cache
|
// Get all table from the query and save them in cache
|
||||||
if (preg_match_all('/('._DB_PREFIX_.'[a-z_-]*)`?.*/i', $query, $res))
|
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]))
|
if (!isset($this->sql_tables_cached[$table][$key]))
|
||||||
$this->sql_tables_cached[$table][$key] = true;
|
$this->sql_tables_cached[$table][$key] = true;
|
||||||
$this->set(self::SQL_TABLES_NAME, $this->sql_tables_cached);
|
$this->set(self::SQL_TABLES_NAME, $this->sql_tables_cached);
|
||||||
|
|||||||
Vendored
+1
-1
@@ -132,7 +132,7 @@ class CacheFsCore extends Cache
|
|||||||
if (!$directory)
|
if (!$directory)
|
||||||
$directory = _PS_CACHEFS_DIRECTORY_;
|
$directory = _PS_CACHEFS_DIRECTORY_;
|
||||||
$chars = '0123456789abcdef';
|
$chars = '0123456789abcdef';
|
||||||
for ($i = 0; $i < strlen($chars); $i++)
|
for ($i = 0, $length = strlen($chars); $i < $length; $i++)
|
||||||
{
|
{
|
||||||
$new_dir = $directory.$chars[$i].'/';
|
$new_dir = $directory.$chars[$i].'/';
|
||||||
if (mkdir($new_dir))
|
if (mkdir($new_dir))
|
||||||
|
|||||||
Vendored
+2
-2
@@ -53,7 +53,7 @@ class CacheMemcacheCore extends Cache
|
|||||||
if ($this->memcache->getExtendedStats('cachedump', (int)$slab_id))
|
if ($this->memcache->getExtendedStats('cachedump', (int)$slab_id))
|
||||||
foreach ($dump as $entries)
|
foreach ($dump as $entries)
|
||||||
foreach ($entries as $entry)
|
foreach ($entries as $entry)
|
||||||
$this->keys[$entry] = 0;;
|
$this->keys[$entry] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
@@ -70,7 +70,7 @@ class CacheMemcacheCore extends Cache
|
|||||||
$servers = CacheMemcache::getMemcachedServers();
|
$servers = CacheMemcache::getMemcachedServers();
|
||||||
if (!$servers)
|
if (!$servers)
|
||||||
return false;
|
return false;
|
||||||
foreach ($servers AS $server)
|
foreach ($servers as $server)
|
||||||
$this->memcache->addServer($server['ip'], $server['port'], $server['weight']);
|
$this->memcache->addServer($server['ip'], $server['port'], $server['weight']);
|
||||||
|
|
||||||
$this->is_connected = true;
|
$this->is_connected = true;
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ class HelperCore
|
|||||||
{
|
{
|
||||||
// if the class is extended by a module, use modules/[module_name]/xx.php lang file
|
// if the class is extended by a module, use modules/[module_name]/xx.php lang file
|
||||||
$currentClass = get_class($this);
|
$currentClass = get_class($this);
|
||||||
if(Module::getModuleNameFromClass($currentClass))
|
if (Module::getModuleNameFromClass($currentClass))
|
||||||
{
|
{
|
||||||
$string = str_replace('\'', '\\\'', $string);
|
$string = str_replace('\'', '\\\'', $string);
|
||||||
return Module::findTranslation(Module::$classInModule[$currentClass], $string, $currentClass);
|
return Module::findTranslation(Module::$classInModule[$currentClass], $string, $currentClass);
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ class HelperFormCore extends Helper
|
|||||||
foreach ($this->fields_form as $fieldset)
|
foreach ($this->fields_form as $fieldset)
|
||||||
if (isset($fieldset['form']['input']))
|
if (isset($fieldset['form']['input']))
|
||||||
foreach ($fieldset['form']['input'] as $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 true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ class HelperOptionsCore extends Helper
|
|||||||
echo '<img src="../themes/'.$theme['name'].'/preview.jpg" alt="'.Tools::strtolower($theme['name']).'">';
|
echo '<img src="../themes/'.$theme['name'].'/preview.jpg" alt="'.Tools::strtolower($theme['name']).'">';
|
||||||
echo '</label>';
|
echo '</label>';
|
||||||
echo '</td>';
|
echo '</td>';
|
||||||
if (isset($field['max']) && ($i +1 ) % $field['max'] == 0)
|
if (isset($field['max']) && ($i + 1) % $field['max'] == 0)
|
||||||
echo '</tr><tr>';
|
echo '</tr><tr>';
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user