diff --git a/admin-dev/themes/template/layout.tpl b/admin-dev/themes/template/layout.tpl
index bc9ab21ac..173ca2d01 100644
--- a/admin-dev/themes/template/layout.tpl
+++ b/admin-dev/themes/template/layout.tpl
@@ -25,8 +25,43 @@
*}
{include file='header.tpl'}
-{if count($warnings)}
+{if isset($conf)}
+
+

{$conf}
+
+{/if}
+
+{if count($errors)} {* @todo what is ??? AND $this->_includeContainer *}
+
+
+


+ {if count($errors) == 1}
+ {$errors[0]}
+ {else}
+ {$errors|count} {l s='errors'}
+
+
+ {foreach from=$errors item=$error}
+ - {$error}
+ {/foreach}
+
+ {/if}
+
+{/if}
+
+{if count($warnings)}
- 

';
- if (count($this->_errors) == 1)
- $content .= $this->_errors[0];
- else
- {
- $content .= $nbErrors.' '.$this->l('errors').'
';
- foreach ($this->_errors AS $error)
- $content .= '- '.$error.'
';
- $content .= '
';
- }
- $content .= '
';
- }
// @TODO includesubtab
$this->includeSubTab('displayErrors');
return $content;
@@ -1169,7 +1142,7 @@ class AdminControllerCore extends Controller
* @param integer $start Offset in LIMIT clause
* @param integer $limit Row count in LIMIT clause
*/
- public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL, $id_lang_shop = false)
+ public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, $limit = null, $id_lang_shop = false)
{
/* Manage default params values */
if (empty($limit))
@@ -1188,16 +1161,16 @@ class AdminControllerCore extends Controller
/* Check params validity */
- if (!Validate::isOrderBy($orderBy) OR !Validate::isOrderWay($orderWay)
- OR !is_numeric($start) OR !is_numeric($limit)
- OR !Validate::isUnsignedId($id_lang))
+ if (!Validate::isOrderBy($orderBy) || !Validate::isOrderWay($orderWay)
+ || !is_numeric($start) || !is_numeric($limit)
+ || !Validate::isUnsignedId($id_lang))
die(Tools::displayError('get list params is not valid'));
/* Determine offset from current page */
- if ((isset($_POST['submitFilter'.$this->table]) OR
- isset($_POST['submitFilter'.$this->table.'_x']) OR
- isset($_POST['submitFilter'.$this->table.'_y'])) AND
- !empty($_POST['submitFilter'.$this->table]) AND
+ if ((isset($_POST['submitFilter'.$this->table]) ||
+ isset($_POST['submitFilter'.$this->table.'_x']) ||
+ isset($_POST['submitFilter'.$this->table.'_y'])) &&
+ !empty($_POST['submitFilter'.$this->table]) &&
is_numeric($_POST['submitFilter'.$this->table]))
$start = (int)($_POST['submitFilter'.$this->table] - 1) * $limit;
@@ -1227,7 +1200,7 @@ class AdminControllerCore extends Controller
else if (Context::shop() == Shop::CONTEXT_GROUP)
{
$assos = GroupShop::getAssoTables();
- if (isset($assos[$this->table]) AND $assos[$this->table]['type'] == 'group_shop')
+ if (isset($assos[$this->table]) && $assos[$this->table]['type'] == 'group_shop')
{
$filterKey = $assos[$this->table]['type'];
$idenfierShop = array($this->context->shop->getGroupID());
@@ -1276,10 +1249,10 @@ class AdminControllerCore extends Controller
* @param integer $id_lang Language id (optional)
* @return string
*/
- protected function getFieldValue($obj, $key, $id_lang = NULL)
+ protected function getFieldValue($obj, $key, $id_lang = null)
{
if ($id_lang)
- $defaultValue = ($obj->id AND isset($obj->{$key}[$id_lang])) ? $obj->{$key}[$id_lang] : '';
+ $defaultValue = ($obj->id && isset($obj->{$key}[$id_lang])) ? $obj->{$key}[$id_lang] : '';
else
$defaultValue = isset($obj->{$key}) ? $obj->{$key} : '';
@@ -1299,59 +1272,59 @@ class AdminControllerCore extends Controller
/* Class specific validation rules */
$rules = call_user_func(array($className, 'getValidationRules'), $className);
- if ((sizeof($rules['requiredLang']) OR sizeof($rules['sizeLang']) OR sizeof($rules['validateLang'])))
+ if ((count($rules['requiredLang']) || count($rules['sizeLang']) || count($rules['validateLang'])))
{
/* Language() instance determined by default language */
- $defaultLanguage = new Language((int)(Configuration::get('PS_LANG_DEFAULT')));
+ $default_language = new Language((int)(Configuration::get('PS_LANG_DEFAULT')));
/* All availables languages */
$languages = Language::getLanguages(false);
}
/* Checking for required fields */
- foreach ($rules['required'] AS $field)
- if (($value = Tools::getValue($field)) == false AND (string)$value != '0')
- if (!Tools::getValue($this->identifier) OR ($field != 'passwd' AND $field != 'no-picture'))
+ foreach ($rules['required'] as $field)
+ if (($value = Tools::getValue($field)) == false && (string)$value != '0')
+ if (!Tools::getValue($this->identifier) || ($field != 'passwd' && $field != 'no-picture'))
$this->_errors[] = $this->l('the field').' '.call_user_func(array($className, 'displayFieldName'), $field, $className).' '.$this->l('is required');
/* Checking for multilingual required fields */
- foreach ($rules['requiredLang'] AS $fieldLang)
- if (($empty = Tools::getValue($fieldLang.'_'.$defaultLanguage->id)) === false OR $empty !== '0' AND empty($empty))
- $this->_errors[] = $this->l('the field').' '.call_user_func(array($className, 'displayFieldName'), $fieldLang, $className).' '.$this->l('is required at least in').' '.$defaultLanguage->name;
+ foreach ($rules['requiredLang'] as $fieldLang)
+ if (($empty = Tools::getValue($fieldLang.'_'.$default_language->id)) === false || $empty !== '0' && empty($empty))
+ $this->_errors[] = $this->l('the field').' '.call_user_func(array($className, 'displayFieldName'), $fieldLang, $className).' '.$this->l('is required at least in').' '.$default_language->name;
/* Checking for maximum fields sizes */
- foreach ($rules['size'] AS $field => $maxLength)
- if (Tools::getValue($field) !== false AND Tools::strlen(Tools::getValue($field)) > $maxLength)
+ foreach ($rules['size'] as $field => $maxLength)
+ if (Tools::getValue($field) !== false && Tools::strlen(Tools::getValue($field)) > $maxLength)
$this->_errors[] = $this->l('the field').' '.call_user_func(array($className, 'displayFieldName'), $field, $className).' '.$this->l('is too long').' ('.$maxLength.' '.$this->l('chars max').')';
/* Checking for maximum multilingual fields size */
- foreach ($rules['sizeLang'] AS $fieldLang => $maxLength)
- foreach ($languages AS $language)
- if (Tools::getValue($fieldLang.'_'.$language['id_lang']) !== false AND Tools::strlen(Tools::getValue($fieldLang.'_'.$language['id_lang'])) > $maxLength)
+ foreach ($rules['sizeLang'] as $fieldLang => $maxLength)
+ foreach ($languages as $language)
+ if (Tools::getValue($fieldLang.'_'.$language['id_lang']) !== false && Tools::strlen(Tools::getValue($fieldLang.'_'.$language['id_lang'])) > $maxLength)
$this->_errors[] = $this->l('the field').' '.call_user_func(array($className, 'displayFieldName'), $fieldLang, $className).' ('.$language['name'].') '.$this->l('is too long').' ('.$maxLength.' '.$this->l('chars max, html chars including').')';
/* Overload this method for custom checking */
$this->_childValidation();
/* Checking for fields validity */
- foreach ($rules['validate'] AS $field => $function)
- if (($value = Tools::getValue($field)) !== false AND ($field != 'passwd'))
+ foreach ($rules['validate'] as $field => $function)
+ if (($value = Tools::getValue($field)) !== false && ($field != 'passwd'))
if (!Validate::$function($value))
$this->_errors[] = $this->l('the field').' '.call_user_func(array($className, 'displayFieldName'), $field, $className).' '.$this->l('is invalid');
/* Checking for passwd_old validity */
if (($value = Tools::getValue('passwd')) != false)
{
- if ($className == 'Employee' AND !Validate::isPasswdAdmin($value))
+ if ($className == 'Employee' && !Validate::isPasswdAdmin($value))
$this->_errors[] = $this->l('the field').' '.call_user_func(array($className, 'displayFieldName'), 'passwd', $className).' '.$this->l('is invalid');
- elseif ($className == 'Customer' AND !Validate::isPasswd($value))
+ else if ($className == 'Customer' && !Validate::isPasswd($value))
$this->_errors[] = $this->l('the field').' '.call_user_func(array($className, 'displayFieldName'), 'passwd', $className).' '.$this->l('is invalid');
}
/* Checking for multilingual fields validity */
- foreach ($rules['validateLang'] AS $fieldLang => $function)
- foreach ($languages AS $language)
- if (($value = Tools::getValue($fieldLang.'_'.$language['id_lang'])) !== false AND !empty($value))
+ foreach ($rules['validateLang'] as $fieldLang => $function)
+ foreach ($languages as $language)
+ if (($value = Tools::getValue($fieldLang.'_'.$language['id_lang'])) !== false && !empty($value))
if (!Validate::$function($value))
$this->_errors[] = $this->l('the field').' '.call_user_func(array($className, 'displayFieldName'), $fieldLang, $className).' ('.$language['name'].') '.$this->l('is invalid');
}
@@ -1359,12 +1332,12 @@ 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
@@ -1372,7 +1345,10 @@ class AdminControllerCore extends Controller
* @param object $object Object
* @return boolean
*/
- protected function beforeDelete($object) { return true; }
+ protected function beforeDelete($object)
+ {
+ return true;
+ }
/**
* Called before deletion
@@ -1380,11 +1356,20 @@ class AdminControllerCore extends Controller
* @param object $object Object
* @return boolean
*/
- protected function afterDelete($object, $oldId) { return true; }
+ protected function afterDelete($object, $oldId)
+ {
+ return true;
+ }
- protected function afterAdd($object) { return true; }
+ protected function afterAdd($object)
+ {
+ return true;
+ }
- protected function afterUpdate($object) { return true; }
+ protected function afterUpdate($object)
+ {
+ return true;
+ }
/**
* Check rights to view the current tab
@@ -1392,7 +1377,8 @@ class AdminControllerCore extends Controller
* @return boolean
*/
- protected function afterImageUpload() {
+ protected function afterImageUpload()
+ {
return true;
}
@@ -1405,46 +1391,46 @@ class AdminControllerCore extends Controller
protected function copyFromPost(&$object, $table)
{
/* Classical fields */
- foreach ($_POST AS $key => $value)
- if (key_exists($key, $object) AND $key != 'id_'.$table)
+ foreach ($_POST as $key => $value)
+ if (key_exists($key, $object) && $key != 'id_'.$table)
{
/* Do not take care of password field if empty */
- if ($key == 'passwd' AND Tools::getValue('id_'.$table) AND empty($value))
+ if ($key == 'passwd' && Tools::getValue('id_'.$table) && empty($value))
continue;
/* Automatically encrypt password in MD5 */
- if ($key == 'passwd' AND !empty($value))
+ if ($key == 'passwd' && !empty($value))
$value = Tools::encrypt($value);
$object->{$key} = $value;
}
/* Multilingual fields */
$rules = call_user_func(array(get_class($object), 'getValidationRules'), get_class($object));
- if (sizeof($rules['validateLang']))
+ if (count($rules['validateLang']))
{
$languages = Language::getLanguages(false);
- foreach ($languages AS $language)
- foreach (array_keys($rules['validateLang']) AS $field)
- if (isset($_POST[$field.'_'.(int)($language['id_lang'])]))
- $object->{$field}[(int)($language['id_lang'])] = $_POST[$field.'_'.(int)($language['id_lang'])];
+ foreach ($languages as $language)
+ foreach (array_keys($rules['validateLang']) as $field)
+ if (isset($_POST[$field.'_'.(int)$language['id_lang']]))
+ $object->{$field}[(int)$language['id_lang']] = $_POST[$field.'_'.(int)($language['id_lang'])];
}
}
protected function updateAssoShop($id_object = false)
{
if (!Shop::isMultiShopActivated())
- return ;
+ return;
- $shopAsso = Shop::getAssoTables();
- $groupShopAsso = GroupShop::getAssoTables();
- if (isset($shopAsso[$this->table]) && $shopAsso[$this->table]['type'] == 'shop')
+ $shop_asso = Shop::getAssoTables();
+ $group_shop_asso = GroupShop::getAssoTables();
+ if (isset($shop_asso[$this->table]) && $shop_asso[$this->table]['type'] == 'shop')
$type = 'shop';
- else if (isset($groupShopAsso[$this->table]) && $groupShopAsso[$this->table]['type'] == 'group_shop')
+ else if (isset($group_shop_asso[$this->table]) && $group_shop_asso[$this->table]['type'] == 'group_shop')
$type = 'group_shop';
else
- return ;
+ return;
$assos = array();
- foreach ($_POST AS $k => $row)
+ foreach ($_POST as $k => $row)
{
if (!preg_match('/^checkBox'.Tools::toCamelCase($type, true).'Asso_'.$this->table.'_([0-9]+)?_([0-9]+)$/Ui', $k, $res))
continue;
@@ -1453,7 +1439,7 @@ class AdminControllerCore extends Controller
}
Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.$this->table.'_'.$type.($id_object ? ' WHERE `'.$this->identifier.'`='.(int)$id_object : ''));
- foreach ($assos AS $asso)
+ foreach ($assos as $asso)
Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.$this->table.'_'.$type.' (`'.pSQL($this->identifier).'`, id_'.$type.')
VALUES('.(int)$asso['id_object'].', '.(int)$asso['id_'.$type].')');
}
@@ -1466,13 +1452,13 @@ class AdminControllerCore extends Controller
*/
protected function postImage($id)
{
- if (isset($this->fieldImageSettings['name']) AND isset($this->fieldImageSettings['dir']))
+ if (isset($this->fieldImageSettings['name']) && isset($this->fieldImageSettings['dir']))
return $this->uploadImage($id, $this->fieldImageSettings['name'], $this->fieldImageSettings['dir'].'/');
- elseif (!empty($this->fieldImageSettings))
- foreach ($this->fieldImageSettings AS $image)
- if (isset($image['name']) AND isset($image['dir']))
+ else if (!empty($this->fieldImageSettings))
+ foreach ($this->fieldImageSettings as $image)
+ if (isset($image['name']) && isset($image['dir']))
$this->uploadImage($id, $image['name'], $image['dir'].'/');
- return !sizeof($this->_errors) ? true : false;
+ return !count($this->_errors) ? true : false;
}
protected function bulkDelete($boxes)
@@ -1480,20 +1466,20 @@ class AdminControllerCore extends Controller
if (is_array($boxes) && !empty($boxes))
{
$object = new $this->className();
- if (isset($object->noZeroObject) AND
+ if (isset($object->noZeroObject) &&
// Check if all object will be deleted
- (sizeof(call_user_func(array($this->className, $object->noZeroObject))) <= 1 OR sizeof($boxes) == sizeof(call_user_func(array($this->className, $object->noZeroObject)))))
+ (count(call_user_func(array($this->className, $object->noZeroObject))) <= 1 || count($boxes) == count(call_user_func(array($this->className, $object->noZeroObject)))))
$this->_errors[] = Tools::displayError('You need at least one object.').' '.$this->table.'
'.Tools::displayError('You cannot delete all of the items.');
else
{
$result = true;
if ($this->deleted)
{
- foreach($boxes as $id)
+ foreach ($boxes as $id)
{
- $toDelete = new $this->className($id);
- $toDelete->deleted = 1;
- $result = $result AND $toDelete->update();
+ $to_delete = new $this->className($id);
+ $to_delete->deleted = 1;
+ $result = $result && $to_delete->update();
}
}
else