From c304a2c620e9cf98fd809a5eb94d24ae187c9537 Mon Sep 17 00:00:00 2001 From: lLefevre Date: Wed, 28 Sep 2011 08:26:46 +0000 Subject: [PATCH] //fix correction norm in AdminProducts git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8830 b9a71923-0436-4b27-9f14-aed3839534dd --- admin-dev/tabs/AdminProducts.php | 388 ++++++++++++------------ controllers/front/ProductController.php | 6 +- translations/fr/admin.php | 52 +--- 3 files changed, 201 insertions(+), 245 deletions(-) diff --git a/admin-dev/tabs/AdminProducts.php b/admin-dev/tabs/AdminProducts.php index 93917b6df..7e7c3b29a 100644 --- a/admin-dev/tabs/AdminProducts.php +++ b/admin-dev/tabs/AdminProducts.php @@ -74,7 +74,7 @@ class AdminProducts extends AdminTab { $out = array(); $words = explode(',', $keywords); - foreach($words as $word_item) + foreach ($words as $word_item) { $word_item = trim($word_item); if (!empty($word_item) && $word_item != '') @@ -104,9 +104,9 @@ class AdminProducts extends AdminTab $_POST['height'] = empty($_POST['height']) ? '0' : str_replace(',', '.', $_POST['height']); $_POST['depth'] = empty($_POST['depth']) ? '0' : str_replace(',', '.', $_POST['depth']); $_POST['weight'] = empty($_POST['weight']) ? '0' : str_replace(',', '.', $_POST['weight']); - if ($_POST['unit_price'] != NULL) + if ($_POST['unit_price'] != null) $object->unit_price = str_replace(',', '.', $_POST['unit_price']); - if (array_key_exists('ecotax', $_POST) && $_POST['ecotax'] != NULL) + if (array_key_exists('ecotax', $_POST) && $_POST['ecotax'] != null) $object->ecotax = str_replace(',', '.', $_POST['ecotax']); $object->available_for_order = (int)(Tools::isSubmit('available_for_order')); $object->show_price = $object->available_for_order ? 1 : (int)(Tools::isSubmit('show_price')); @@ -114,7 +114,7 @@ class AdminProducts extends AdminTab $object->online_only = Tools::isSubmit('online_only'); } - public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL, $id_lang_shop = NULL) + public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, $limit = null, $id_lang_shop = null) { $orderByPriceFinal = (empty($orderBy) ? ($this->context->cookie->__get($this->table.'Orderby') ? $this->context->cookie->__get($this->table.'Orderby') : 'id_'.$this->table) : $orderBy); $orderWayPriceFinal = (empty($orderWay) ? ($this->context->cookie->__get($this->table.'Orderway') ? $this->context->cookie->__get($this->table.'Orderby') : 'ASC') : $orderWay); @@ -133,17 +133,17 @@ class AdminProducts extends AdminTab /* update product final price */ for ($i = 0; $i < $nb; $i++) - $this->_list[$i]['price_tmp'] = Product::getPriceStatic($this->_list[$i]['id_product'], true, NULL, 6, NULL, false, true, 1, true); + $this->_list[$i]['price_tmp'] = Product::getPriceStatic($this->_list[$i]['id_product'], true, null, 6, null, false, true, 1, true); } if ($orderByPriceFinal == 'price_final') { - if(strtolower($orderWayPriceFinal) == 'desc') + if (strtolower($orderWayPriceFinal) == 'desc') uasort($this->_list, 'cmpPriceDesc'); else uasort($this->_list, 'cmpPriceAsc'); } - for ($i = 0; $this->_list AND $i < $nb; $i++) + for ($i = 0; $this->_list && $i < $nb; $i++) { $this->_list[$i]['price_final'] = $this->_list[$i]['price_tmp']; unset($this->_list[$i]['price_tmp']); @@ -164,12 +164,12 @@ class AdminProducts extends AdminTab * @param mixed $token * @return void */ - public function postProcess($token = NULL) + public function postProcess($token = null) { /* Add a new product */ - if (Tools::isSubmit('submitAddproduct') OR Tools::isSubmit('submitAddproductAndStay') OR Tools::isSubmit('submitAddProductAndPreview')) + if (Tools::isSubmit('submitAddproduct') || Tools::isSubmit('submitAddproductAndStay') || Tools::isSubmit('submitAddProductAndPreview')) { - if ((Tools::getValue('id_product') AND $this->tabAccess['edit'] === '1') OR ($this->tabAccess['add'] === '1' AND !Tools::isSubmit('id_product'))) + if ((Tools::getValue('id_product') && $this->tabAccess['edit'] === '1') || ($this->tabAccess['add'] === '1' && !Tools::isSubmit('id_product'))) $this->submitAddproduct($token); else $this->_errors[] = Tools::displayError('You do not have permission to add here.'); @@ -185,21 +185,21 @@ class AdminProducts extends AdminTab } /* Update attachments */ - elseif (Tools::isSubmit('submitAddAttachments')) + else if (Tools::isSubmit('submitAddAttachments')) { if ($this->tabAccess['add'] === '1') { $languages = Language::getLanguages(false); $is_attachment_name_valid = false; - foreach ($languages AS $language) + foreach ($languages as $language) { $attachment_name_lang = Tools::getValue('attachment_name_'.(int)($language['id_lang'])); if (strlen($attachment_name_lang ) > 0) $is_attachment_name_valid = true; - if(!Validate::isGenericName(Tools::getValue('attachment_name_'.(int)($language['id_lang'])))) + if (!Validate::isGenericName(Tools::getValue('attachment_name_'.(int)($language['id_lang'])))) $this->_errors[] = Tools::displayError('Invalid Name'); - elseif (Tools::strlen(Tools::getValue('attachment_name_'.(int)($language['id_lang']))) > 32) + else if (Tools::strlen(Tools::getValue('attachment_name_'.(int)($language['id_lang']))) > 32) $this->_errors[] = Tools::displayError('Name is too long'); if (!Validate::isCleanHtml(Tools::getValue('attachment_description_'.(int)($language['id_lang'])))) $this->_errors[] = Tools::displayError('Invalid description'); @@ -209,7 +209,7 @@ class AdminProducts extends AdminTab if (empty($this->_errors)) { - if (isset($_FILES['attachment_file']) AND is_uploaded_file($_FILES['attachment_file']['tmp_name'])) + if (isset($_FILES['attachment_file']) && is_uploaded_file($_FILES['attachment_file']['tmp_name'])) { if ($_FILES['attachment_file']['size'] > (Configuration::get('PS_ATTACHMENT_MAXIMUM_SIZE') * 1024 * 1024)) $this->_errors[] = $this->l('File too large, maximum size allowed:').' '.(Configuration::get('PS_ATTACHMENT_MAXIMUM_SIZE') * 1024).' '.$this->l('kb').'. '.$this->l('File size you\'re trying to upload is:').number_format(($_FILES['attachment_file']['size']/1024), 2, '.', '').$this->l('kb'); @@ -229,10 +229,10 @@ class AdminProducts extends AdminTab $this->_errors[] = $this->l('the File').' '.$_FILES['attachment_file']['name'].' '.$this->l('exceeds the size allowed by the server, this limit is set to').' '.$upload_mb.$this->l('Mb').''; } - if(empty($this->_errors) && isset($uniqid)) + if (empty($this->_errors) && isset($uniqid)) { $attachment = new Attachment(); - foreach ($languages AS $language) + foreach ($languages as $language) { if (isset($_POST['attachment_name_'.(int)($language['id_lang'])])) $attachment->name[(int)($language['id_lang'])] = pSQL($_POST['attachment_name_'.(int)($language['id_lang'])]); @@ -242,7 +242,7 @@ class AdminProducts extends AdminTab $attachment->file = $uniqid; $attachment->mime = $_FILES['attachment_file']['type']; $attachment->file_name = pSQL($_FILES['attachment_file']['name']); - if (empty($attachment->mime) OR Tools::strlen($attachment->mime) > 128) + if (empty($attachment->mime) || Tools::strlen($attachment->mime) > 128) $this->_errors[] = Tools::displayError('Invalid file extension'); if (!Validate::isGenericName($attachment->file_name)) $this->_errors[] = Tools::displayError('Invalid file name'); @@ -261,7 +261,7 @@ class AdminProducts extends AdminTab else $this->_errors[] = Tools::displayError('You do not have permission to add here.'); } - elseif (Tools::isSubmit('submitAttachments')) + else if (Tools::isSubmit('submitAttachments')) { if ($this->tabAccess['edit'] === '1') if ($id = (int)(Tools::getValue($this->identifier))) @@ -270,7 +270,7 @@ class AdminProducts extends AdminTab } /* Product duplication */ - elseif (isset($_GET['duplicate'.$this->table])) + else if (isset($_GET['duplicate'.$this->table])) { if ($this->tabAccess['add'] === '1') { @@ -282,22 +282,22 @@ class AdminProducts extends AdminTab $product->indexed = 0; $product->active = 0; if ($product->add() - AND Category::duplicateProductCategories($id_product_old, $product->id) - AND ($combinationImages = Product::duplicateAttributes($id_product_old, $product->id)) !== false - AND GroupReduction::duplicateReduction($id_product_old, $product->id) - AND Product::duplicateAccessories($id_product_old, $product->id) - AND Product::duplicateFeatures($id_product_old, $product->id) - AND Product::duplicateSpecificPrices($id_product_old, $product->id) - AND Pack::duplicate($id_product_old, $product->id) - AND Product::duplicateCustomizationFields($id_product_old, $product->id) - AND Product::duplicateTags($id_product_old, $product->id) - AND Product::duplicateDownload($id_product_old, $product->id) - AND $product->duplicateShops($id_product_old)) + && Category::duplicateProductCategories($id_product_old, $product->id) + && ($combinationImages = Product::duplicateAttributes($id_product_old, $product->id)) !== false + && GroupReduction::duplicateReduction($id_product_old, $product->id) + && Product::duplicateAccessories($id_product_old, $product->id) + && Product::duplicateFeatures($id_product_old, $product->id) + && Product::duplicateSpecificPrices($id_product_old, $product->id) + && Pack::duplicate($id_product_old, $product->id) + && Product::duplicateCustomizationFields($id_product_old, $product->id) + && Product::duplicateTags($id_product_old, $product->id) + && Product::duplicateDownload($id_product_old, $product->id) + && $product->duplicateShops($id_product_old)) { if ($product->hasAttributes()) Product::updateDefaultAttribute($product->id); - if (!Tools::getValue('noimage') AND !Image::duplicateProductImages($id_product_old, $product->id, $combinationImages)) + if (!Tools::getValue('noimage') && !Image::duplicateProductImages($id_product_old, $product->id, $combinationImages)) $this->_errors[] = Tools::displayError('An error occurred while copying images.'); else { @@ -314,14 +314,14 @@ class AdminProducts extends AdminTab $this->_errors[] = Tools::displayError('You do not have permission to add here.'); } /* Change object statuts (active, inactive) */ - elseif (isset($_GET['status']) AND Tools::getValue($this->identifier)) + else if (isset($_GET['status']) && Tools::getValue($this->identifier)) { if ($this->tabAccess['edit'] === '1') { if (Validate::isLoadedObject($object = $this->loadObject())) { if ($object->toggleStatus()) - Tools::redirectAdmin(self::$currentIndex.'&conf=5'.((($id_category = (!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1')) AND Tools::getValue('id_product')) ? '&id_category='.$id_category : '').'&token='.$token); + Tools::redirectAdmin(self::$currentIndex.'&conf=5'.((($id_category = (!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1')) && Tools::getValue('id_product')) ? '&id_category='.$id_category : '').'&token='.$token); else $this->_errors[] = Tools::displayError('An error occurred while updating status.'); } @@ -332,14 +332,14 @@ class AdminProducts extends AdminTab $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } /* Delete object */ - elseif (isset($_GET['delete'.$this->table])) + else if (isset($_GET['delete'.$this->table])) { if ($this->tabAccess['delete'] === '1') { - if (Validate::isLoadedObject($object = $this->loadObject()) AND isset($this->fieldImageSettings)) + if (Validate::isLoadedObject($object = $this->loadObject()) && isset($this->fieldImageSettings)) { // check if request at least one object with noZeroObject - if (isset($object->noZeroObject) AND sizeof($taxes = call_user_func(array($this->className, $object->noZeroObject))) <= 1) + if (isset($object->noZeroObject) && sizeof($taxes = call_user_func(array($this->className, $object->noZeroObject))) <= 1) $this->_errors[] = Tools::displayError('You need at least one object.').' '.$this->table.'
'.Tools::displayError('You cannot delete all of the items.'); else { @@ -353,7 +353,7 @@ class AdminProducts extends AdminTab if ($object->update()) Tools::redirectAdmin(self::$currentIndex.'&conf=1&token='.($token ? $token : $this->token).$category_url); } - elseif ($object->delete()) + else if ($object->delete()) Tools::redirectAdmin(self::$currentIndex.'&conf=1&token='.($token ? $token : $this->token).$category_url); $this->_errors[] = Tools::displayError('An error occurred during deletion.'); } @@ -366,7 +366,7 @@ class AdminProducts extends AdminTab } /* Delete multiple objects */ - elseif (Tools::getValue('submitDel'.$this->table)) + else if (Tools::getValue('submitDel'.$this->table)) { if ($this->tabAccess['delete'] === '1') { @@ -374,20 +374,20 @@ class AdminProducts extends AdminTab { $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($_POST[$this->table.'Box']) == sizeof(call_user_func(array($this->className, $object->noZeroObject))))) + (sizeof(call_user_func(array($this->className, $object->noZeroObject))) <= 1 || sizeof($_POST[$this->table.'Box']) == sizeof(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(Tools::getValue($this->table.'Box') as $id) + foreach (Tools::getValue($this->table.'Box') as $id) { $toDelete = new $this->className($id); $toDelete->deleted = 1; - $result = $result AND $toDelete->update(); + $result = $result && $toDelete->update(); } } else @@ -411,7 +411,7 @@ class AdminProducts extends AdminTab } /* Product images management */ - elseif (($id_image = (int)(Tools::getValue('id_image'))) AND Validate::isUnsignedId($id_image) AND Validate::isLoadedObject($image = new Image($id_image))) + else if (($id_image = (int)(Tools::getValue('id_image'))) && Validate::isUnsignedId($id_image) && Validate::isLoadedObject($image = new Image($id_image))) { if ($this->tabAccess['edit'] === '1') { @@ -429,7 +429,7 @@ class AdminProducts extends AdminTab } /* Choose product cover image */ - elseif (isset($_GET['coverImage'])) + else if (isset($_GET['coverImage'])) { Image::deleteCover($image->id_product); $image->cover = 1; @@ -445,7 +445,7 @@ class AdminProducts extends AdminTab } /* Choose product image position */ - elseif (isset($_GET['imgPosition']) AND isset($_GET['imgDirection'])) + else if (isset($_GET['imgPosition']) && isset($_GET['imgDirection'])) { $image->updatePosition(Tools::getValue('imgDirection'), Tools::getValue('imgPosition')); Tools::redirectAdmin(self::$currentIndex.'&id_product='.$image->id_product.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&add'.$this->table.'&tabs=1&token='.($token ? $token : $this->token)); @@ -456,15 +456,15 @@ class AdminProducts extends AdminTab } /* Product attributes management */ - elseif (Tools::isSubmit('submitProductAttribute')) + else if (Tools::isSubmit('submitProductAttribute')) { if (!Combination::isFeatureActive()) return; if (Validate::isLoadedObject($product = new Product((int)(Tools::getValue('id_product'))))) { - if (!isset($_POST['attribute_price']) OR $_POST['attribute_price'] == NULL) + if (!isset($_POST['attribute_price']) || $_POST['attribute_price'] == null) $this->_errors[] = Tools::displayError('Attribute price required.'); - if (!isset($_POST['attribute_combinaison_list']) OR !sizeof($_POST['attribute_combinaison_list'])) + if (!isset($_POST['attribute_combinaison_list']) || !sizeof($_POST['attribute_combinaison_list'])) $this->_errors[] = Tools::displayError('You must add at least one attribute.'); if (!sizeof($this->_errors)) @@ -503,9 +503,9 @@ class AdminProducts extends AdminTab Tools::getValue('minimal_quantity'), Tools::getValue('available_date')); - if ($id_reason = (int)Tools::getValue('id_mvt_reason') AND (int)Tools::getValue('attribute_mvt_quantity') > 0 AND $id_reason > 0) + if ($id_reason = (int)Tools::getValue('id_mvt_reason') && (int)Tools::getValue('attribute_mvt_quantity') > 0 && $id_reason > 0) { - if (!$product->addStockMvt(Tools::getValue('attribute_mvt_quantity'), $id_reason, $id_product_attribute, NULL, $this->context->employee->id)) + if (!$product->addStockMvt(Tools::getValue('attribute_mvt_quantity'), $id_reason, $id_product_attribute, null, $this->context->employee->id)) $this->_errors[] = Tools::displayError('An error occurred while updating qty.'); } Hook::updateProductAttribute((int)$id_product_attribute); @@ -559,13 +559,13 @@ class AdminProducts extends AdminTab } } } - elseif (Tools::isSubmit('deleteProductAttribute')) + else if (Tools::isSubmit('deleteProductAttribute')) { if (!Combination::isFeatureActive()) return; if ($this->tabAccess['delete'] === '1') { - if (($id_product = (int)(Tools::getValue('id_product'))) AND Validate::isUnsignedId($id_product) AND Validate::isLoadedObject($product = new Product($id_product))) + if (($id_product = (int)(Tools::getValue('id_product'))) && Validate::isUnsignedId($id_product) && Validate::isLoadedObject($product = new Product($id_product))) { $product->deleteAttributeCombinaison(Tools::getValue('id_product_attribute')); $product->checkDefaultAttributes(); @@ -586,13 +586,13 @@ class AdminProducts extends AdminTab else $this->_errors[] = Tools::displayError('You do not have permission to delete here.'); } - elseif (Tools::isSubmit('deleteAllProductAttributes')) + else if (Tools::isSubmit('deleteAllProductAttributes')) { if (!Combination::isFeatureActive()) return; if ($this->tabAccess['delete'] === '1') { - if (($id_product = (int)(Tools::getValue('id_product'))) AND Validate::isUnsignedId($id_product) AND Validate::isLoadedObject($product = new Product($id_product))) + if (($id_product = (int)(Tools::getValue('id_product'))) && Validate::isUnsignedId($id_product) && Validate::isLoadedObject($product = new Product($id_product))) { $product->deleteProductAttributes(); $product->updateQuantityProductWithAttributeQuantity(); @@ -609,7 +609,7 @@ class AdminProducts extends AdminTab else $this->_errors[] = Tools::displayError('You do not have permission to delete here.'); } - elseif (Tools::isSubmit('defaultProductAttribute')) + else if (Tools::isSubmit('defaultProductAttribute')) { if (!Combination::isFeatureActive()) return; @@ -624,7 +624,7 @@ class AdminProducts extends AdminTab } /* Product features management */ - elseif (Tools::isSubmit('submitProductFeature')) + else if (Tools::isSubmit('submitProductFeature')) { if (!Feature::isFeatureActive()) return; @@ -637,7 +637,7 @@ class AdminProducts extends AdminTab // add new objects $languages = Language::getLanguages(false); - foreach ($_POST AS $key => $val) + foreach ($_POST as $key => $val) { if (preg_match('/^feature_([0-9]+)_value/i', $key, $match)) { @@ -648,7 +648,7 @@ class AdminProducts extends AdminTab if ($default_value = $this->checkFeatures($languages, $match[1])) { $id_value = $product->addFeaturesToDB($match[1], 0, 1, (int)$language['id_lang']); - foreach ($languages AS $language) + foreach ($languages as $language) { if ($cust = Tools::getValue('custom_'.$match[1].'_'.(int)$language['id_lang'])) $product->addFeaturesCustomToDB($id_value, (int)$language['id_lang'], $cust); @@ -668,7 +668,7 @@ class AdminProducts extends AdminTab $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } /* Product specific prices management */ - elseif (Tools::isSubmit('submitPricesModification')) + else if (Tools::isSubmit('submitPricesModification')) { $_POST['tabs'] = 5; if ($this->tabAccess['edit'] === '1') @@ -708,7 +708,7 @@ class AdminProducts extends AdminTab else $this->_errors[] = Tools::displayError('You do not have permission to add here.'); } - elseif (Tools::isSubmit('submitPriceAddition')) + else if (Tools::isSubmit('submitPriceAddition')) { if ($this->tabAccess['add'] === '1') { @@ -746,13 +746,13 @@ class AdminProducts extends AdminTab else $this->_errors[] = Tools::displayError('You do not have permission to add here.'); } - elseif (Tools::isSubmit('deleteSpecificPrice')) + else if (Tools::isSubmit('deleteSpecificPrice')) { if ($this->tabAccess['delete'] === '1') { if (!($obj = $this->loadObject())) return; - if (!$id_specific_price = Tools::getValue('id_specific_price') OR !Validate::isUnsignedId($id_specific_price)) + if (!$id_specific_price = Tools::getValue('id_specific_price') || !Validate::isUnsignedId($id_specific_price)) $this->_errors[] = Tools::displayError('Invalid specific price ID'); else { @@ -766,26 +766,26 @@ class AdminProducts extends AdminTab else $this->_errors[] = Tools::displayError('You do not have permission to delete here.'); } - elseif (Tools::isSubmit('submitSpecificPricePriorities')) + else if (Tools::isSubmit('submitSpecificPricePriorities')) { if (!($obj = $this->loadObject())) return; if (!$priorities = Tools::getValue('specificPricePriority')) $this->_errors[] = Tools::displayError('Please specify priorities'); - elseif (Tools::isSubmit('specificPricePriorityToAll')) + else if (Tools::isSubmit('specificPricePriorityToAll')) { if (!SpecificPrice::setPriorities($priorities)) $this->_errors[] = Tools::displayError('An error occurred while updating priorities.'); else Tools::redirectAdmin(self::$currentIndex.'&id_product='.$obj->id.'&add'.$this->table.'&tabs=2&conf=4&token='.($token ? $token : $this->token)); } - elseif (!SpecificPrice::setSpecificPriority((int)($obj->id), $priorities)) + else if (!SpecificPrice::setSpecificPriority((int)($obj->id), $priorities)) $this->_errors[] = Tools::displayError('An error occurred while setting priorities.'); else Tools::redirectAdmin(self::$currentIndex.(Tools::getValue('id_category') ? '&id_category='.Tools::getValue('id_category') : '').'&id_product='.$obj->id.'&add'.$this->table.'&tabs=2&conf=4&token='.($token ? $token : $this->token)); } /* Customization management */ - elseif (Tools::isSubmit('submitCustomizationConfiguration')) + else if (Tools::isSubmit('submitCustomizationConfiguration')) { if ($this->tabAccess['edit'] === '1') { @@ -793,12 +793,12 @@ class AdminProducts extends AdminTab { if (!$product->createLabels((int)($_POST['uploadable_files']) - (int)($product->uploadable_files), (int)($_POST['text_fields']) - (int)($product->text_fields))) $this->_errors[] = Tools::displayError('An error occurred while creating customization fields.'); - if (!sizeof($this->_errors) AND !$product->updateLabels()) + if (!sizeof($this->_errors) && !$product->updateLabels()) $this->_errors[] = Tools::displayError('An error occurred while updating customization.'); $product->uploadable_files = (int)($_POST['uploadable_files']); $product->text_fields = (int)($_POST['text_fields']); - $product->customizable = ((int)($_POST['uploadable_files']) > 0 OR (int)($_POST['text_fields']) > 0) ? 1 : 0; - if (!sizeof($this->_errors) AND !$product->update()) + $product->customizable = ((int)($_POST['uploadable_files']) > 0 || (int)($_POST['text_fields']) > 0) ? 1 : 0; + if (!sizeof($this->_errors) && !$product->update()) $this->_errors[] = Tools::displayError('An error occurred while updating customization configuration.'); if (!sizeof($this->_errors)) Tools::redirectAdmin(self::$currentIndex.'&id_product='.$product->id.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&add'.$this->table.'&tabs=5&token='.($token ? $token : $this->token)); @@ -809,16 +809,16 @@ class AdminProducts extends AdminTab else $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } - elseif (Tools::isSubmit('submitProductCustomization')) + else if (Tools::isSubmit('submitProductCustomization')) { if ($this->tabAccess['edit'] === '1') { if (Validate::isLoadedObject($product = new Product((int)(Tools::getValue('id_product'))))) { - foreach ($_POST AS $field => $value) - if (strncmp($field, 'label_', 6) == 0 AND !Validate::isLabel($value)) + foreach ($_POST as $field => $value) + if (strncmp($field, 'label_', 6) == 0 && !Validate::isLabel($value)) $this->_errors[] = Tools::displayError('Label fields are invalid'); - if (!sizeof($this->_errors) AND !$product->updateLabels()) + if (!sizeof($this->_errors) && !$product->updateLabels()) $this->_errors[] = Tools::displayError('An error occurred while updating customization.'); if (!sizeof($this->_errors)) Tools::redirectAdmin(self::$currentIndex.'&id_product='.$product->id.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&add'.$this->table.'&tabs=5&token='.($token ? $token : $this->token)); @@ -829,11 +829,11 @@ class AdminProducts extends AdminTab else $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } - elseif (isset($_GET['position'])) + else if (isset($_GET['position'])) { if ($this->tabAccess['edit'] !== '1') $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); - elseif (!Validate::isLoadedObject($object = $this->loadObject())) + else if (!Validate::isLoadedObject($object = $this->loadObject())) $this->_errors[] = Tools::displayError('An error occurred while updating status for object.').' '.$this->table.' '.Tools::displayError('(cannot load object)'); if (!$object->updatePosition((int)(Tools::getValue('way')), (int)(Tools::getValue('position')))) $this->_errors[] = Tools::displayError('Failed to update the position.'); @@ -872,11 +872,11 @@ class AdminProducts extends AdminTab if (Tools::getValue('updateProductImageShopAsso')) { - if ($id_image = (int)Tools::getValue('id_image') AND $id_shop = (int)Tools::getValue('id_shop')) + if ($id_image = (int)Tools::getValue('id_image') && $id_shop = (int)Tools::getValue('id_shop')) if (Tools::getValue('active') == "true") die(Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'image_shop (`id_image`, `id_shop`) VALUES('.(int)$id_image.', '.(int)$id_shop.')')); else - die(Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'image_shop WHERE `id_image`='.(int)$id_image.' AND `id_shop`='.(int)$id_shop)); + die(Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'image_shop WHERE `id_image`='.(int)$id_image.' && `id_shop`='.(int)$id_shop)); } if (Tools::getValue('deleteImage')) @@ -901,15 +901,15 @@ class AdminProducts extends AdminTab } protected function _validateSpecificPrice($id_shop, $id_currency, $id_country, $id_group, $price, $from_quantity, $reduction, $reduction_type, $from, $to) { - if (!Validate::isUnsignedId($id_shop) OR !Validate::isUnsignedId($id_currency) OR !Validate::isUnsignedId($id_country) OR !Validate::isUnsignedId($id_group)) + if (!Validate::isUnsignedId($id_shop) || !Validate::isUnsignedId($id_currency) || !Validate::isUnsignedId($id_country) || !Validate::isUnsignedId($id_group)) $this->_errors[] = Tools::displayError('Wrong ID\'s'); - elseif ((empty($price) AND empty($reduction)) OR (!empty($price) AND !Validate::isPrice($price)) OR (!empty($reduction) AND !Validate::isPrice($reduction))) + else if ((empty($price) && empty($reduction)) || (!empty($price) && !Validate::isPrice($price)) || (!empty($reduction) && !Validate::isPrice($reduction))) $this->_errors[] = Tools::displayError('Invalid price/reduction amount'); - elseif (!Validate::isUnsignedInt($from_quantity)) + else if (!Validate::isUnsignedInt($from_quantity)) $this->_errors[] = Tools::displayError('Invalid quantity'); - elseif ($reduction AND !Validate::isReductionType($reduction_type)) + else if ($reduction && !Validate::isReductionType($reduction_type)) $this->_errors[] = Tools::displayError('Please select a reduction type (amount or percentage)'); - elseif ($from AND $to AND (!Validate::isDateFormat($from) OR !Validate::isDateFormat($to))) + else if ($from && $to && (!Validate::isDateFormat($from) || !Validate::isDateFormat($to))) $this->_errors[] = Tools::displayError('Wrong from/to date'); else return true; @@ -922,13 +922,13 @@ class AdminProducts extends AdminTab $rules = call_user_func(array('FeatureValue', 'getValidationRules'), 'FeatureValue'); $feature = Feature::getFeature(Configuration::get('PS_LANG_DEFAULT'), $feature_id); $val = 0; - foreach ($languages AS $language) + foreach ($languages as $language) if ($val = Tools::getValue('custom_'.$feature_id.'_'.$language['id_lang'])) { $currentLanguage = new Language($language['id_lang']); if (Tools::strlen($val) > $rules['sizeLang']['value']) $this->_errors[] = Tools::displayError('name for feature').' '.$feature['name'].' '.Tools::displayError('is too long in').' '.$currentLanguage->name; - elseif (!call_user_func(array('Validate', $rules['validateLang']['value']), $val)) + else if (!call_user_func(array('Validate', $rules['validateLang']['value']), $val)) $this->_errors[] = Tools::displayError('Valid name required for feature.').' '.$feature['name'].' '.Tools::displayError('in').' '.$currentLanguage->name; if (sizeof($this->_errors)) return (0); @@ -960,19 +960,19 @@ class AdminProducts extends AdminTab $image->cover = $cover; $this->validateRules('Image'); $this->copyFromPost($image, 'image'); - if (sizeof($this->_errors) OR !$image->update()) + if (sizeof($this->_errors) || !$image->update()) $this->_errors[] = Tools::displayError('An error occurred while updating image.'); - elseif (isset($_FILES['image_product']['tmp_name']) AND $_FILES['image_product']['tmp_name'] != NULL) + else if (isset($_FILES['image_product']['tmp_name']) && $_FILES['image_product']['tmp_name'] != null) $this->copyImage($product->id, $image->id, $method); } } - if (isset($image) AND Validate::isLoadedObject($image) AND !file_exists(_PS_PROD_IMG_DIR_.$image->getExistingImgPath().'.'.$image->image_format)) + if (isset($image) && Validate::isLoadedObject($image) && !file_exists(_PS_PROD_IMG_DIR_.$image->getExistingImgPath().'.'.$image->image_format)) $image->delete(); if (sizeof($this->_errors)) return false; @unlink(_PS_TMP_IMG_DIR_.'/product_'.$product->id.'.jpg'); @unlink(_PS_TMP_IMG_DIR_.'/product_mini_'.$product->id.'.jpg'); - return ((isset($id_image) AND is_int($id_image) AND $id_image) ? $id_image : true); + return ((isset($id_image) && is_int($id_image) && $id_image) ? $id_image : true); } /** * Copy a product image @@ -992,14 +992,14 @@ class AdminProducts extends AdminTab if (!$new_path = $image->getPathForCreation()) $this->_errors[] = Tools::displayError('An error occurred during new folder creation'); - if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') OR !move_uploaded_file($_FILES['image_product']['tmp_name'], $tmpName)) + if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') || !move_uploaded_file($_FILES['image_product']['tmp_name'], $tmpName)) $this->_errors[] = Tools::displayError('An error occurred during the image upload'); - elseif (!imageResize($tmpName, $new_path.'.'.$image->image_format)) + else if (!imageResize($tmpName, $new_path.'.'.$image->image_format)) $this->_errors[] = Tools::displayError('An error occurred while copying image.'); - elseif($method == 'auto') + else if ($method == 'auto') { $imagesTypes = ImageType::getImagesTypes('products'); - foreach ($imagesTypes AS $k => $imageType) + foreach ($imagesTypes as $k => $imageType) if (!imageResize($tmpName, $new_path.'-'.stripslashes($imageType['name']).'.'.$image->image_format, $imageType['width'], $imageType['height'], $image->image_format)) $this->_errors[] = Tools::displayError('An error occurred while copying image:').' '.stripslashes($imageType['name']); } @@ -1012,7 +1012,7 @@ class AdminProducts extends AdminTab /** * Add or update a product */ - public function submitAddProduct($token = NULL) + public function submitAddProduct($token = null) { $className = 'Product'; $rules = call_user_func(array($this->className, 'getValidationRules'), $this->className); @@ -1020,22 +1020,22 @@ class AdminProducts extends AdminTab $languages = Language::getLanguages(false); /* Check required fields */ - foreach ($rules['required'] AS $field) - if (($value = Tools::getValue($field)) == false AND $value != '0') + foreach ($rules['required'] as $field) + if (($value = Tools::getValue($field)) == false && $value != '0') { - if (Tools::getValue('id_'.$this->table) AND $field == 'passwd') + if (Tools::getValue('id_'.$this->table) && $field == 'passwd') continue; $this->_errors[] = $this->l('the field').' '.call_user_func(array($className, 'displayFieldName'), $field, $className).' '.$this->l('is required'); } /* Check multilingual required fields */ - foreach ($rules['requiredLang'] AS $fieldLang) + foreach ($rules['requiredLang'] as $fieldLang) if (!Tools::getValue($fieldLang.'_'.$defaultLanguage->id)) $this->_errors[] = $this->l('the field').' '.call_user_func(array($className, 'displayFieldName'), $fieldLang, $className).' '.$this->l('is required at least in').' '.$defaultLanguage->name; /* Check fields sizes */ - foreach ($rules['size'] AS $field => $maxLength) - if ($value = Tools::getValue($field) AND Tools::strlen($value) > $maxLength) + foreach ($rules['size'] as $field => $maxLength) + if ($value = Tools::getValue($field) && Tools::strlen($value) > $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').')'; if (isset($_POST['description_short'])) @@ -1047,41 +1047,41 @@ class AdminProducts extends AdminTab /* Check description short size without html */ $limit = (int)Configuration::get('PS_PRODUCT_SHORT_DESC_LIMIT'); if ($limit <= 0) $limit = 400; - foreach ($languages AS $language) + foreach ($languages as $language) if ($value = Tools::getValue('description_short_'.$language['id_lang'])) if (Tools::strlen(strip_tags($value)) > $limit) $this->_errors[] = $this->l('the field').' '.call_user_func(array($className, 'displayFieldName'), 'description_short').' ('.$language['name'].') '.$this->l('is too long').' : '.$limit.' '.$this->l('chars max').' ('.$this->l('count now').' '.Tools::strlen(strip_tags($value)).')'; /* Check multilingual fields sizes */ - foreach ($rules['sizeLang'] AS $fieldLang => $maxLength) - foreach ($languages AS $language) - if ($value = Tools::getValue($fieldLang.'_'.$language['id_lang']) AND Tools::strlen($value) > $maxLength) + foreach ($rules['sizeLang'] as $fieldLang => $maxLength) + foreach ($languages as $language) + if ($value = Tools::getValue($fieldLang.'_'.$language['id_lang']) && Tools::strlen($value) > $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').')'; if (isset($_POST['description_short'])) $_POST['description_short'] = $saveShort; /* Check fields validity */ - foreach ($rules['validate'] AS $field => $function) + foreach ($rules['validate'] as $field => $function) if ($value = Tools::getValue($field)) if (!Validate::$function($value)) $this->_errors[] = $this->l('the field').' '.call_user_func(array($className, 'displayFieldName'), $field, $className).' '.$this->l('is invalid'); /* Check multilingual fields validity */ - foreach ($rules['validateLang'] AS $fieldLang => $function) - foreach ($languages AS $language) + foreach ($rules['validateLang'] as $fieldLang => $function) + foreach ($languages as $language) if ($value = Tools::getValue($fieldLang.'_'.$language['id_lang'])) if (!Validate::$function($value)) $this->_errors[] = $this->l('the field').' '.call_user_func(array($className, 'displayFieldName'), $fieldLang, $className).' ('.$language['name'].') '.$this->l('is invalid'); /* Categories */ $productCats = ''; - if (!Tools::isSubmit('categoryBox') OR !sizeof(Tools::getValue('categoryBox'))) + if (!Tools::isSubmit('categoryBox') || !sizeof(Tools::getValue('categoryBox'))) $this->_errors[] = $this->l('product must be in at least one Category'); - if (!is_array(Tools::getValue('categoryBox')) OR !in_array(Tools::getValue('id_category_default'), Tools::getValue('categoryBox'))) + if (!is_array(Tools::getValue('categoryBox')) || !in_array(Tools::getValue('id_category_default'), Tools::getValue('categoryBox'))) $this->_errors[] = $this->l('product must be in the default category'); /* Tags */ - foreach ($languages AS $language) + foreach ($languages as $language) if ($value = Tools::getValue('tags_'.$language['id_lang'])) if (!Validate::isTagsList($value)) $this->_errors[] = $this->l('Tags list').' ('.$language['name'].') '.$this->l('is invalid'); @@ -1092,7 +1092,7 @@ class AdminProducts extends AdminTab $tagError = true; /* Update an existing product */ - if (isset($id) AND !empty($id)) + if (isset($id) && !empty($id)) { $object = new $this->className($id); if (Validate::isLoadedObject($object)) @@ -1101,9 +1101,9 @@ class AdminProducts extends AdminTab $this->copyFromPost($object, $this->table); if ($object->update()) { - if ($id_reason = (int)Tools::getValue('id_mvt_reason') AND Tools::getValue('mvt_quantity') > 0 AND $id_reason > 0) + if ($id_reason = (int)Tools::getValue('id_mvt_reason') && Tools::getValue('mvt_quantity') > 0 && $id_reason > 0) { - if (!$object->addStockMvt(Tools::getValue('mvt_quantity'), $id_reason, NULL, NULL, $this->context->employee->id)) + if (!$object->addStockMvt(Tools::getValue('mvt_quantity'), $id_reason, null, null, $this->context->employee->id)) $this->_errors[] = Tools::displayError('An error occurred while updating qty.'); } $this->updateAccessories($object); @@ -1112,17 +1112,17 @@ class AdminProducts extends AdminTab if (!$this->updatePackItems($object)) $this->_errors[] = Tools::displayError('An error occurred while adding products to the pack.'); - elseif (!$object->updateCategories($_POST['categoryBox'], true)) + else if (!$object->updateCategories($_POST['categoryBox'], true)) $this->_errors[] = Tools::displayError('An error occurred while linking object.').' '.$this->table.' '.Tools::displayError('To categories'); - elseif (!$this->updateTags($languages, $object)) + else if (!$this->updateTags($languages, $object)) $this->_errors[] = Tools::displayError('An error occurred while adding tags.'); - elseif ($id_image = $this->addProductImage($object, Tools::getValue('resizer'))) + else if ($id_image = $this->addProductImage($object, Tools::getValue('resizer'))) { self::$currentIndex .= '&image_updated='.(int)Tools::getValue('id_image'); Hook::updateProduct($object); Search::indexation(false, $object->id); - if (Tools::getValue('resizer') == 'man' && isset($id_image) AND is_int($id_image) AND $id_image) - Tools::redirectAdmin(self::$currentIndex.'&id_product='.$object->id.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&edit='.strval(Tools::getValue('productCreated')).'&id_image='.$id_image.'&imageresize&toconf=4&submitAddAndStay='.((Tools::isSubmit('submitAdd'.$this->table.'AndStay') OR Tools::getValue('productCreated') == 'on') ? 'on' : 'off').'&token='.(($token ? $token : $this->token))); + if (Tools::getValue('resizer') == 'man' && isset($id_image) && is_int($id_image) && $id_image) + Tools::redirectAdmin(self::$currentIndex.'&id_product='.$object->id.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&edit='.strval(Tools::getValue('productCreated')).'&id_image='.$id_image.'&imageresize&toconf=4&submitAddAndStay='.((Tools::isSubmit('submitAdd'.$this->table.'AndStay') || Tools::getValue('productCreated') == 'on') ? 'on' : 'off').'&token='.(($token ? $token : $this->token))); // Save and preview if (Tools::isSubmit('submitAddProductAndPreview')) @@ -1133,14 +1133,14 @@ class AdminProducts extends AdminTab $admin_dir = dirname($_SERVER['PHP_SELF']); $admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1); $token = Tools::encrypt('PreviewProduct'.$object->id); - if(strpos($preview_url, '?') === false) + if (strpos($preview_url, '?') === false) $preview_url .= '?'; else $preview_url .= '&'; $preview_url .= 'adtoken='.$token.'&ad='.$admin_dir; } Tools::redirectAdmin($preview_url); - } else if (Tools::isSubmit('submitAdd'.$this->table.'AndStay') OR ($id_image AND $id_image !== true)) // Save and stay on same form + } else if (Tools::isSubmit('submitAdd'.$this->table.'AndStay') || ($id_image && $id_image !== true)) // Save and stay on same form // Save and stay on same form if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) Tools::redirectAdmin(self::$currentIndex.'&id_product='.$object->id.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&addproduct&conf=4&tabs='.(int)(Tools::getValue('tabs')).'&token='.($token ? $token : $this->token)); @@ -1175,7 +1175,7 @@ class AdminProducts extends AdminTab $this->_errors[] = Tools::displayError('An error occurred while linking object.').' '.$this->table.' '.Tools::displayError('To categories'); else if (!$this->updateTags($languages, $object)) $this->_errors[] = Tools::displayError('An error occurred while adding tags.'); - elseif ($id_image = $this->addProductImage($object)) + else if ($id_image = $this->addProductImage($object)) { Hook::addProduct($object); Search::indexation(false, $object->id); @@ -1195,7 +1195,7 @@ class AdminProducts extends AdminTab Tools::redirectAdmin($preview_url); } - if (Tools::getValue('resizer') == 'man' && isset($id_image) AND is_int($id_image) AND $id_image) + if (Tools::getValue('resizer') == 'man' && isset($id_image) && is_int($id_image) && $id_image) Tools::redirectAdmin(self::$currentIndex.'&id_product='.$object->id.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&id_image='.$id_image.'&imageresize&toconf=3&submitAddAndStay='.(Tools::isSubmit('submitAdd'.$this->table.'AndStay') ? 'on' : 'off').'&token='.(($token ? $token : $this->token))); // Save and stay on same form if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) @@ -1249,7 +1249,7 @@ class AdminProducts extends AdminTab $this->_errors[] = $this->l('the field').' '.$this->l('number of days').' '.$this->l('is required'); return false; } - if (Tools::getValue('virtual_product_expiration_date') AND !Validate::isDate(Tools::getValue('virtual_product_expiration_date'))) + if (Tools::getValue('virtual_product_expiration_date') && !Validate::isDate(Tools::getValue('virtual_product_expiration_date'))) { $this->_errors[] = $this->l('the field').' '.$this->l('expiration date').' '.$this->l('is not valid'); return false; @@ -1321,17 +1321,17 @@ class AdminProducts extends AdminTab WHERE `id_product` = '.(int)($product->id))) return false; /* Assign tags to this product */ - foreach ($languages AS $language) + foreach ($languages as $language) if ($value = Tools::getValue('tags_'.$language['id_lang'])) $tagError &= Tag::addTags($language['id_lang'], (int)($product->id), $value); return $tagError; } - public function display($token = NULL) + public function display($token = null) { if ($id_category = (int)Tools::getValue('id_category')) AdminTab::$currentIndex .= '&id_category='.$id_category; - $this->getList($this->context->language->id, !$this->context->cookie->__get($this->table.'Orderby') ? 'position' : NULL, !$this->context->cookie->__get($this->table.'Orderway') ? 'ASC' : NULL, 0, NULL, $this->context->shop->getID(true)); + $this->getList($this->context->language->id, !$this->context->cookie->__get($this->table.'Orderby') ? 'position' : null, !$this->context->cookie->__get($this->table.'Orderway') ? 'ASC' : null, 0, null, $this->context->shop->getID(true)); $id_category = Tools::getValue('id_category', 1); if (!$id_category) @@ -1339,7 +1339,7 @@ class AdminProducts extends AdminTab echo '

'.(!$this->_listTotal ? ($this->l('No products found')) : ($this->_listTotal.' '.($this->_listTotal > 1 ? $this->l('products') : $this->l('product')))).' '. $this->l('in category').' "'.stripslashes($this->_category->getName()).'"

'; if ($this->tabAccess['add'] === '1') - echo ' '.$this->l('Add a new product').''; + echo ' '.$this->l('Add a new product').''; echo '
'; $this->displayList($token); echo '
'; @@ -1351,7 +1351,7 @@ class AdminProducts extends AdminTab * @param mixed $token * @return void */ - public function displayList($token = NULL) + public function displayList($token = null) { /* Display list header (filtering, pagination and column names) */ $this->displayListHeader($token); @@ -1373,7 +1373,7 @@ class AdminProducts extends AdminTab * @param array $current Current category * @param integer $id_category Current category id */ - public static function recurseCategoryForInclude($id_obj, $indexedCategories, $categories, $current, $id_category = 1, $id_category_default = NULL, $has_suite = array()) + public static function recurseCategoryForInclude($id_obj, $indexedCategories, $categories, $current, $id_category = 1, $id_category_default = null, $has_suite = array()) { global $done; static $irow; @@ -1390,7 +1390,7 @@ class AdminProducts extends AdminTab echo ' - + '.$id_category.' @@ -1405,7 +1405,7 @@ class AdminProducts extends AdminTab if ($level > 1) $has_suite[] = ($todo == $doneC ? 0 : 1); if (isset($categories[$id_category])) - foreach ($categories[$id_category] AS $key => $row) + foreach ($categories[$id_category] as $key => $row) if ($key != 'infos') self::recurseCategoryForInclude($id_obj, $indexedCategories, $categories, $categories[$id_category][$key], $key, $id_category_default, $has_suite); } @@ -1414,13 +1414,13 @@ class AdminProducts extends AdminTab { if ($this->includeSubTab('displayErrors')) ; - elseif ($nbErrors = sizeof($this->_errors)) + else if ($nbErrors = sizeof($this->_errors)) { echo '
'.$nbErrors.' '.($nbErrors > 1 ? $this->l('errors') : $this->l('error')).'
    '; - foreach ($this->_errors AS $error) + foreach ($this->_errors as $error) echo '
  1. '.$error.'
  2. '; echo '
@@ -1471,7 +1471,7 @@ class AdminProducts extends AdminTab }); function updateMvtStatus(id_mvt_reason) { - if(id_mvt_reason == -1) + if (id_mvt_reason == -1) return $(\'#mvt_sign\').hide(); if ($(\'#id_mvt_reason option:selected\').attr(\'rel\') == -1) $(\'#mvt_sign\').html(\' '.$this->l('Decrease your stock').'\'); @@ -1633,7 +1633,7 @@ class AdminProducts extends AdminTab '; - if (!is_array($specificPrices) OR !sizeof($specificPrices)) + if (!is_array($specificPrices) || !sizeof($specificPrices)) echo ' '.$this->l('No specific prices').' @@ -1649,7 +1649,7 @@ class AdminProducts extends AdminTab else $reduction = Tools::displayPrice(Tools::ps_round($specificPrice['reduction'], 2), $current_specific_currency); - if ($specificPrice['from'] == '0000-00-00 00:00:00' AND $specificPrice['to'] == '0000-00-00 00:00:00') + if ($specificPrice['from'] == '0000-00-00 00:00:00' && $specificPrice['to'] == '0000-00-00 00:00:00') $period = $this->l('Unlimited'); else $period = $this->l('From').' '.($specificPrice['from'] != '0000-00-00 00:00:00' ? $specificPrice['from'] : '0000-00-00 00:00:00').'
'.$this->l('To').' '.($specificPrice['to'] != '0000-00-00 00:00:00' ? $specificPrice['to'] : '0000-00-00 00:00:00'); @@ -1830,10 +1830,10 @@ class AdminProducts extends AdminTab { $customizableFieldIds = array(); if (isset($labels[Product::CUSTOMIZE_FILE])) - foreach ($labels[Product::CUSTOMIZE_FILE] AS $id_customization_field => $label) + foreach ($labels[Product::CUSTOMIZE_FILE] as $id_customization_field => $label) $customizableFieldIds[] = 'label_'.Product::CUSTOMIZE_FILE.'_'.(int)($id_customization_field); if (isset($labels[Product::CUSTOMIZE_TEXTFIELD])) - foreach ($labels[Product::CUSTOMIZE_TEXTFIELD] AS $id_customization_field => $label) + foreach ($labels[Product::CUSTOMIZE_TEXTFIELD] as $id_customization_field => $label) $customizableFieldIds[] = 'label_'.Product::CUSTOMIZE_TEXTFIELD.'_'.(int)($id_customization_field); $j = 0; for ($i = $alreadyGenerated[Product::CUSTOMIZE_FILE]; $i < (int)($this->getFieldValue($obj, 'uploadable_files')); $i++) @@ -1872,7 +1872,7 @@ class AdminProducts extends AdminTab $fieldIds = $this->_getCustomizationFieldIds($labels, $labelGenerated, $obj); if (isset($labels[$type])) - foreach ($labels[$type] AS $id_customization_field => $label) + foreach ($labels[$type] as $id_customization_field => $label) $this->_displayLabelField($label, $languages, $defaultLanguage, $type, $fieldIds, (int)($id_customization_field)); } @@ -1942,7 +1942,7 @@ class AdminProducts extends AdminTab echo ' '; - if ($hasFileLabels OR $hasTextLabels) + if ($hasFileLabels || $hasTextLabels) echo ''; echo ' @@ -1996,7 +1996,7 @@ class AdminProducts extends AdminTab

'.$this->l('Attachments for this product:').'



@@ -2006,7 +2006,7 @@ class AdminProducts extends AdminTab

'.$this->l('Available attachments:').'



@@ -2072,7 +2072,7 @@ class AdminProducts extends AdminTab } }); - if($(\'#available_for_order\').is(\':checked\')){ + if ($(\'#available_for_order\').is(\':checked\')){ $(\'#show_price\').attr(\'checked\', \'checked\'); $(\'#show_price\').attr(\'disabled\', \'disabled\'); } @@ -2195,7 +2195,7 @@ class AdminProducts extends AdminTab active ? 'style="display:none"' : '').'> '.$this->l('Options:').' - getFieldValue($obj, 'available_for_order') ? 'checked="checked" ' : '').' onclick="if($(this).is(\':checked\')){$(\'#show_price\').attr(\'checked\', \'checked\');$(\'#show_price\').attr(\'disabled\', \'disabled\');}else{$(\'#show_price\').attr(\'disabled\', \'\');}"/> + getFieldValue($obj, 'available_for_order') ? 'checked="checked" ' : '').' onclick="if ($(this).is(\':checked\')){$(\'#show_price\').attr(\'checked\', \'checked\');$(\'#show_price\').attr(\'disabled\', \'disabled\');}else{$(\'#show_price\').attr(\'disabled\', \'\');}"/>
getFieldValue($obj, 'show_price') ? 'checked="checked" ' : '').' /> @@ -2314,7 +2314,7 @@ class AdminProducts extends AdminTab var msg = data.getAttribute("msg"); var fileName = data.getAttribute("filename"); - if(result == "error") + if (result == "error") { $("#upload-confirmation").html('

error: ' + msg + '

'); } @@ -2351,21 +2351,21 @@ class AdminProducts extends AdminTab ?> -

id OR Tools::getValue('is_virtual_good')=='true') AND $productDownload->active) echo 'checked="checked"' ?> /> +

id || Tools::getValue('is_virtual_good')=='true') && $productDownload->active) echo 'checked="checked"' ?> />

-
id OR !$productDownload->active) echo 'style="display:none;"' ?> > - +
id || !$productDownload->active) echo 'style="display:none;"' ?> > +

l('Your download repository is not writable.'); ?>

- id) echo '' ?> + id) echo '' ?>

- checkFile()): ?> + checkFile()): ?>

- id): ?> + id): ?>

l('This product is missing') ?>:
physically_filename ?> @@ -2395,7 +2395,7 @@ class AdminProducts extends AdminTab

-
+

@@ -2404,7 +2404,7 @@ class AdminProducts extends AdminTab

- l('Format: YYYY-MM-DD'); ?>

@@ -2441,7 +2441,7 @@ class AdminProducts extends AdminTab '.$this->l('Pre-tax retail price:').' - '.($currency->format % 2 != 0 ? $currency->sign.' ' : '').''.($currency->format % 2 == 0 ? ' '.$currency->sign : '').' * + '.($currency->format % 2 != 0 ? $currency->sign.' ' : '').''.($currency->format % 2 == 0 ? ' '.$currency->sign : '').' * '.$this->l('The pre-tax retail price to sell this product').' '; @@ -2453,7 +2453,7 @@ class AdminProducts extends AdminTab echo 'taxesArray = new Array ();'."\n"; echo 'taxesArray[0] = 0', ";\n"; - foreach ($tax_rules_groups AS $tax_rules_group) + foreach ($tax_rules_groups as $tax_rules_group) { $tax_rate = (array_key_exists($tax_rules_group['id_tax_rules_group'], $taxesRatesByGroup) ? $taxesRatesByGroup[$tax_rules_group['id_tax_rules_group']] : 0); echo 'taxesArray['.$tax_rules_group['id_tax_rules_group'].']='.$tax_rate."\n"; @@ -2469,7 +2469,7 @@ class AdminProducts extends AdminTab @@ -2491,7 +2491,7 @@ class AdminProducts extends AdminTab '.$this->l('Eco-tax (tax incl.):').' - '.($currency->format % 2 != 0 ? $currency->sign.' ' : '').''.($currency->format % 2 == 0 ? ' '.$currency->sign : '').' + '.($currency->format % 2 != 0 ? $currency->sign.' ' : '').''.($currency->format % 2 == 0 ? ' '.$currency->sign : '').' ('.$this->l('already included in price').') '; @@ -2560,7 +2560,7 @@ class AdminProducts extends AdminTab '; $reasons = StockMvtReason::getStockMvtReasons($this->context->language->id); - foreach ($reasons AS $reason) + foreach ($reasons as $reason) echo ''; echo '    @@ -2704,7 +2704,7 @@ class AdminProducts extends AdminTab } echo ' @@ -2732,7 +2732,7 @@ class AdminProducts extends AdminTab '.$this->l('Meta title:').' '; - foreach ($this->_languages AS $language) + foreach ($this->_languages as $language) echo '
@@ -2805,14 +2805,14 @@ class AdminProducts extends AdminTab '; $images = Image::getImages($this->context->language->id, $obj->id); - if($images) + if ($images) { echo '
- '.$this->l('You want an image associated with the product in your description ?').' + '.$this->l('Do you want an image associated with the product in your description?').' '.$this->l('Click here').'. @@ -2822,7 +2822,7 @@ class AdminProducts extends AdminTab '; echo ' - + '; echo ' - + '; - foreach ($images AS $k => $image) + foreach ($images as $k => $image) echo $this->getLineTableImage($image, $imagesTotal, $token, $shops); @@ -3228,14 +3228,14 @@ class AdminProducts extends AdminTab $attributes = Attribute::getAttributes($this->context->language->id, true); $attributeJs = array(); - foreach ($attributes AS $k => $attribute) + foreach ($attributes as $k => $attribute) $attributeJs[$attribute['id_attribute_group']][$attribute['id_attribute']] = $attribute['name']; - foreach ($attributeJs AS $idgrp => $group) + foreach ($attributeJs as $idgrp => $group) { echo ' attrs['.$idgrp.'] = new Array(0, \'---\' '; - foreach ($group AS $idattr => $attrname) + foreach ($group as $idattr => $attrname) echo ', '.$idattr.', \''.addslashes(($attrname)).'\''; echo ');'; } @@ -3264,7 +3264,7 @@ class AdminProducts extends AdminTab $html .= ' '; if (Shop::isMultiShopActivated()) - foreach ($shops AS $shop) + foreach ($shops as $shop) $html .= ' '; $html .= ' @@ -3284,11 +3284,11 @@ class AdminProducts extends AdminTab $content = 'var combination_images = new Array();'; if (!$allCombinationImages = $obj->getCombinationImages($this->context->language->id)) return $content; - foreach ($allCombinationImages AS $id_product_attribute => $combinationImages) + foreach ($allCombinationImages as $id_product_attribute => $combinationImages) { $i = 0; $content .= 'combination_images['.(int)($id_product_attribute).'] = new Array();'; - foreach ($combinationImages AS $combinationImage) + foreach ($combinationImages as $combinationImage) $content .= 'combination_images['.(int)($id_product_attribute).']['.$i++.'] = '.(int)($combinationImage['id_image']).';'; } return $content; @@ -3304,7 +3304,7 @@ class AdminProducts extends AdminTab $attributeJs = array(); $attributes = Attribute::getAttributes($this->context->language->id, true); - foreach ($attributes AS $k => $attribute) + foreach ($attributes as $k => $attribute) $attributeJs[$attribute['id_attribute_group']][$attribute['id_attribute']] = $attribute['name']; $currency = $this->context->currency; $attributes_groups = AttributeGroup::getAttributesGroups($this->context->language->id); @@ -3335,7 +3335,7 @@ class AdminProducts extends AdminTab