// Normalize

This commit is contained in:
rMalie
2012-01-26 09:29:50 +00:00
parent 668c117133
commit caa389bc46
16 changed files with 134 additions and 170 deletions
@@ -111,7 +111,7 @@ class AdminAccountingManagementControllerCore extends AdminController
Configuration::updateValue( Configuration::updateValue(
'default_account_number', 'default_account_number',
Tools::getValue('default_account_number'), Tools::getValue('default_account_number'),
false, NULL, false, null,
$id_shop); $id_shop);
// If zone still exist, then update the database with the new value // If zone still exist, then update the database with the new value
@@ -119,7 +119,7 @@ class AdminAccountingManagementControllerCore extends AdminController
{ {
$tab = array(); $tab = array();
foreach ($zones as $zone) foreach ($zones as $zone)
if (($num = Tools::getValue('zone_'.$zone['id_zone'])) !== NULL) if (($num = Tools::getValue('zone_'.$zone['id_zone'])) !== null)
$tab[] = array( $tab[] = array(
'id_zone' => $zone['id_zone'], 'id_zone' => $zone['id_zone'],
'id_shop' => $id_shop, 'id_shop' => $id_shop,
@@ -89,7 +89,7 @@ class AdminCmsContentControllerCore extends AdminController
$cms_tabs = array('cms_category', 'cms'); $cms_tabs = array('cms_category', 'cms');
// Cleaning links // Cleaning links
$catBarIndex = self::$currentIndex; $catBarIndex = self::$currentIndex;
foreach ($cms_tabs AS $tab) foreach ($cms_tabs as $tab)
if (Tools::getValue($tab.'Orderby') && Tools::getValue($tab.'Orderway')) if (Tools::getValue($tab.'Orderby') && Tools::getValue($tab.'Orderway'))
$catBarIndex = preg_replace('/&'.$tab.'Orderby=([a-z _]*)&'.$tab.'Orderway=([a-z]*)/i', '', self::$currentIndex); $catBarIndex = preg_replace('/&'.$tab.'Orderby=([a-z _]*)&'.$tab.'Orderway=([a-z]*)/i', '', self::$currentIndex);
@@ -108,11 +108,11 @@ class AdminCmsContentControllerCore extends AdminController
public function postProcess() public function postProcess()
{ {
if (((Tools::isSubmit('submitAddcms_category') || Tools::isSubmit('submitAddcms_categoryAndStay')) && sizeof($this->adminCMSCategories->errors)) if (((Tools::isSubmit('submitAddcms_category') || Tools::isSubmit('submitAddcms_categoryAndStay')) && count($this->adminCMSCategories->errors))
|| isset($_GET['updatecms_category']) || isset($_GET['updatecms_category'])
|| isset($_GET['addcms_category'])) || isset($_GET['addcms_category']))
$this->display = 'edit_category'; $this->display = 'edit_category';
elseif (((Tools::isSubmit('submitAddcms') || Tools::isSubmit('submitAddcmsAndStay')) && sizeof($this->adminCMS->errors)) elseif (((Tools::isSubmit('submitAddcms') || Tools::isSubmit('submitAddcmsAndStay')) && count($this->adminCMS->errors))
|| isset($_GET['updatecms']) || isset($_GET['updatecms'])
|| isset($_GET['addcms'])) || isset($_GET['addcms']))
$this->display = 'edit_page'; $this->display = 'edit_page';
@@ -91,7 +91,7 @@ class AdminProfilesControllerCore extends AdminController
} }
/* PrestaShop demo mode*/ /* PrestaShop demo mode*/
if (isset($_GET['delete'.$this->table]) AND $_GET[$this->identifier] == (int)(_PS_ADMIN_PROFILE_)) if (isset($_GET['delete'.$this->table]) && $_GET[$this->identifier] == (int)(_PS_ADMIN_PROFILE_))
$this->errors[] = $this->l('For security reasons, you cannot delete the Administrator profile'); $this->errors[] = $this->l('For security reasons, you cannot delete the Administrator profile');
else else
parent::postProcess(); parent::postProcess();
@@ -52,8 +52,8 @@ class AdminRangeWeightControllerCore extends AdminController
public function renderForm() public function renderForm()
{ {
$carriers = Carrier::getCarriers($this->context->language->id, true , false, false, NULL, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE); $carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
foreach ($carriers AS $key => $carrier) foreach ($carriers as $key => $carrier)
if ($carrier['is_free']) if ($carrier['is_free'])
unset($carriers[$key]); unset($carriers[$key]);
@@ -210,9 +210,7 @@ class AdminRequestSqlControllerCore extends AdminController
$this->content .= $this->renderView(); $this->content .= $this->renderView();
} }
else if ($this->display == 'export') else if ($this->display == 'export')
{
$this->generateExport(); $this->generateExport();
}
else if (!$this->ajax) else if (!$this->ajax)
{ {
$this->content .= $this->renderList(); $this->content .= $this->renderList();
+7 -13
View File
@@ -123,16 +123,10 @@ class AdminReturnControllerCore extends AdminController
$order = new Order($this->object->id_order); $order = new Order($this->object->id_order);
$quantityDisplayed = array(); $quantityDisplayed = array();
/* Customized products */ // Customized products */
if ($returnedCustomizations = OrderReturn::getReturnedCustomizedProducts((int)($this->object->id_order))) if ($returnedCustomizations = OrderReturn::getReturnedCustomizedProducts((int)($this->object->id_order)))
{ foreach ($returnedCustomizations as $returnedCustomization)
$allCustomizedDatas = Product::getAllCustomizedDatas((int)($order->id_cart));
foreach ($returnedCustomizations AS $returnedCustomization)
{
$customizationDatas = &$allCustomizedDatas[(int)($returnedCustomization['product_id'])][(int)($returnedCustomization['product_attribute_id'])][(int)($returnedCustomization['id_customization'])]['datas'];
$quantityDisplayed[(int)($returnedCustomization['id_order_detail'])] = isset($quantityDisplayed[(int)($returnedCustomization['id_order_detail'])]) ? $quantityDisplayed[(int)($returnedCustomization['id_order_detail'])] + (int)($returnedCustomization['product_quantity']) : (int)($returnedCustomization['product_quantity']); $quantityDisplayed[(int)($returnedCustomization['id_order_detail'])] = isset($quantityDisplayed[(int)($returnedCustomization['id_order_detail'])]) ? $quantityDisplayed[(int)($returnedCustomization['id_order_detail'])] + (int)($returnedCustomization['product_quantity']) : (int)($returnedCustomization['product_quantity']);
}
}
// Classic products // Classic products
$products = OrderReturn::getOrdersReturnProducts($this->object->id, $order); $products = OrderReturn::getOrdersReturnProducts($this->object->id, $order);
@@ -171,9 +165,9 @@ class AdminReturnControllerCore extends AdminController
{ {
if ($this->tabAccess['delete'] === '1') if ($this->tabAccess['delete'] === '1')
{ {
if (($id_order_detail = (int)(Tools::getValue('id_order_detail'))) AND Validate::isUnsignedId($id_order_detail)) if (($id_order_detail = (int)(Tools::getValue('id_order_detail'))) && Validate::isUnsignedId($id_order_detail))
{ {
if (($id_order_return = (int)(Tools::getValue('id_order_return'))) AND Validate::isUnsignedId($id_order_return)) if (($id_order_return = (int)(Tools::getValue('id_order_return'))) && Validate::isUnsignedId($id_order_return))
{ {
$orderReturn = new OrderReturn($id_order_return); $orderReturn = new OrderReturn($id_order_return);
if (!Validate::isLoadedObject($orderReturn)) if (!Validate::isLoadedObject($orderReturn))
@@ -201,7 +195,7 @@ class AdminReturnControllerCore extends AdminController
{ {
if ($this->tabAccess['edit'] === '1') if ($this->tabAccess['edit'] === '1')
{ {
if (($id_order_return = (int)(Tools::getValue('id_order_return'))) AND Validate::isUnsignedId($id_order_return)) if (($id_order_return = (int)(Tools::getValue('id_order_return'))) && Validate::isUnsignedId($id_order_return))
{ {
$orderReturn = new OrderReturn($id_order_return); $orderReturn = new OrderReturn($id_order_return);
$order = new Order($orderReturn->id_order); $order = new Order($orderReturn->id_order);
@@ -216,8 +210,8 @@ class AdminReturnControllerCore extends AdminController
'{id_order_return}' => $id_order_return, '{id_order_return}' => $id_order_return,
'{state_order_return}' => (isset($orderReturnState->name[(int)$order->id_lang]) ? $orderReturnState->name[(int)$order->id_lang] : $orderReturnState->name[(int)Configuration::get('PS_LANG_DEFAULT')])); '{state_order_return}' => (isset($orderReturnState->name[(int)$order->id_lang]) ? $orderReturnState->name[(int)$order->id_lang] : $orderReturnState->name[(int)Configuration::get('PS_LANG_DEFAULT')]));
Mail::Send((int)$order->id_lang, 'order_return_state', Mail::l('Your order return state has changed', $order->id_lang), Mail::Send((int)$order->id_lang, 'order_return_state', Mail::l('Your order return state has changed', $order->id_lang),
$vars, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL, $vars, $customer->email, $customer->firstname.' '.$customer->lastname, null, null, null,
NULL, _PS_MAIL_DIR_, true); null, _PS_MAIL_DIR_, true);
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token); Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
} }
} }
+15 -14
View File
@@ -40,15 +40,15 @@ class AdminSearchControllerCore extends AdminController
} }
else else
{ {
if (!$searchType and strlen($this->query) > 1) if (!$searchType && strlen($this->query) > 1)
$this->searchFeatures(); $this->searchFeatures();
/* Product research */ /* Product research */
if (!$searchType OR $searchType == 1) if (!$searchType || $searchType == 1)
{ {
/* Handle product ID */ /* Handle product ID */
if ($searchType == 1 AND (int)$this->query AND Validate::isUnsignedInt((int)$this->query)) if ($searchType == 1 && (int)$this->query && Validate::isUnsignedInt((int)$this->query))
if ($product = new Product((int)$this->query) AND Validate::isLoadedObject($product)) if (($product = new Product($this->query)) && Validate::isLoadedObject($product))
Tools::redirectAdmin('index.php?tab=AdminProducts&id_product='.(int)($product->id).'&addproduct'.'&token='.Tools::getAdminTokenLite('AdminProducts')); Tools::redirectAdmin('index.php?tab=AdminProducts&id_product='.(int)($product->id).'&addproduct'.'&token='.Tools::getAdminTokenLite('AdminProducts'));
/* Normal catalog search */ /* Normal catalog search */
@@ -56,14 +56,14 @@ class AdminSearchControllerCore extends AdminController
} }
/* Customer */ /* Customer */
if (!$searchType OR $searchType == 2 OR $searchType == 6) if (!$searchType || $searchType == 2 || $searchType == 6)
{ {
if (!$searchType OR $searchType == 2) if (!$searchType || $searchType == 2)
{ {
/* Handle customer ID */ /* Handle customer ID */
if ($searchType AND (int)$this->query AND Validate::isUnsignedInt((int)$this->query)) if ($searchType && (int)$this->query && Validate::isUnsignedInt((int)$this->query))
if ($customer = new Customer((int)$this->query) AND Validate::isLoadedObject($customer)) if (($customer = new Customer($this->query)) && Validate::isLoadedObject($customer))
Tools::redirectAdmin('index.php?tab=AdminCustomers&id_customer='.(int)($customer->id).'&viewcustomer'.'&token='.Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)$this->context->employee->id)); Tools::redirectAdmin('index.php?tab=AdminCustomers&id_customer='.(int)$customer->id.'&viewcustomer'.'&token='.Tools::getAdminToken('AdminCustomers'.(int)Tab::getIdFromClassName('AdminCustomers').(int)$this->context->employee->id));
/* Normal customer search */ /* Normal customer search */
$this->searchCustomer(); $this->searchCustomer();
@@ -76,7 +76,8 @@ class AdminSearchControllerCore extends AdminController
/* Order */ /* Order */
if ($searchType == 3) if ($searchType == 3)
{ {
if ((int)$this->query AND Validate::isUnsignedInt((int)$this->query) AND $order = new Order((int)$this->query) AND Validate::isLoadedObject($order)) $order = new Order($this->query);
if ((int)$this->query && Validate::isUnsignedInt((int)$this->query) && $order && Validate::isLoadedObject($order))
Tools::redirectAdmin('index.php?tab=AdminOrders&id_order='.(int)($order->id).'&vieworder'.'&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)$this->context->employee->id)); Tools::redirectAdmin('index.php?tab=AdminOrders&id_order='.(int)($order->id).'&vieworder'.'&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)$this->context->employee->id));
$this->errors[] = Tools::displayError('No order found with this ID:').' '.Tools::htmlentitiesUTF8($this->query); $this->errors[] = Tools::displayError('No order found with this ID:').' '.Tools::htmlentitiesUTF8($this->query);
} }
@@ -84,7 +85,7 @@ class AdminSearchControllerCore extends AdminController
/* Invoices */ /* Invoices */
if ($searchType == 4) if ($searchType == 4)
{ {
if ((int)$this->query AND Validate::isUnsignedInt((int)$this->query) AND $invoice = Order::getInvoice((int)$this->query)) if ((int)$this->query && Validate::isUnsignedInt((int)$this->query) && ($invoice = Order::getInvoice((int)$this->query)))
Tools::redirectAdmin('pdf.php?id_order='.(int)($invoice['id_order']).'&pdf'); Tools::redirectAdmin('pdf.php?id_order='.(int)($invoice['id_order']).'&pdf');
$this->errors[] = Tools::displayError('No invoice found with this ID:').' '.Tools::htmlentitiesUTF8($this->query); $this->errors[] = Tools::displayError('No invoice found with this ID:').' '.Tools::htmlentitiesUTF8($this->query);
} }
@@ -92,7 +93,7 @@ class AdminSearchControllerCore extends AdminController
/* Cart */ /* Cart */
if ($searchType == 5) if ($searchType == 5)
{ {
if ((int)$this->query AND Validate::isUnsignedInt((int)$this->query) AND $cart = new Cart((int)$this->query) AND Validate::isLoadedObject($cart)) if ((int)$this->query && Validate::isUnsignedInt((int)$this->query) && ($cart = new Cart($this->query)) && Validate::isLoadedObject($cart))
Tools::redirectAdmin('index.php?tab=AdminCarts&id_cart='.(int)($cart->id).'&viewcart'.'&token='.Tools::getAdminToken('AdminCarts'.(int)(Tab::getIdFromClassName('AdminCarts')).(int)$this->context->employee->id)); Tools::redirectAdmin('index.php?tab=AdminCarts&id_cart='.(int)($cart->id).'&viewcart'.'&token='.Tools::getAdminToken('AdminCarts'.(int)(Tab::getIdFromClassName('AdminCarts')).(int)$this->context->employee->id));
$this->errors[] = Tools::displayError('No cart found with this ID:').' '.Tools::htmlentitiesUTF8($this->query); $this->errors[] = Tools::displayError('No cart found with this ID:').' '.Tools::htmlentitiesUTF8($this->query);
} }
@@ -221,7 +222,7 @@ class AdminSearchControllerCore extends AdminController
$this->addJqueryPlugin('highlight'); $this->addJqueryPlugin('highlight');
} }
// Override because we don't want any buttons /* Override because we don't want any buttons */
public function initToolbar() public function initToolbar()
{ {
} }
@@ -236,7 +237,7 @@ class AdminSearchControllerCore extends AdminController
$this->tpl_view_vars['query'] = $this->query; $this->tpl_view_vars['query'] = $this->query;
$this->tpl_view_vars['show_toolbar'] = true; $this->tpl_view_vars['show_toolbar'] = true;
if (sizeof($this->errors)) if (count($this->errors))
return parent::renderView(); return parent::renderView();
else else
{ {
@@ -34,8 +34,8 @@ class AdminShippingControllerCore extends AdminController
parent::__construct(); parent::__construct();
$this->table = 'delivery'; $this->table = 'delivery';
$carriers = Carrier::getCarriers($this->context->language->id, true , false, false, NULL, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE); $carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
foreach ($carriers AS $key => $carrier) foreach ($carriers as $key => $carrier)
if ($carrier['is_free']) if ($carrier['is_free'])
unset($carriers[$key]); unset($carriers[$key]);
@@ -91,8 +91,8 @@ class AdminShippingControllerCore extends AdminController
public function initContent() public function initContent()
{ {
$carriers = Carrier::getCarriers($this->context->language->id, true , false, false, NULL, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE); $carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
foreach ($carriers AS $key => $carrier) foreach ($carriers as $key => $carrier)
if ($carrier['is_free']) if ($carrier['is_free'])
unset($carriers[$key]); unset($carriers[$key]);
@@ -114,7 +114,7 @@ class AdminShippingControllerCore extends AdminController
$ranges = $rangeObj->getRanges($id_carrier); $ranges = $rangeObj->getRanges($id_carrier);
$delivery = Carrier::getDeliveryPriceByRanges($rangeTable, $id_carrier); $delivery = Carrier::getDeliveryPriceByRanges($rangeTable, $id_carrier);
$deliveryArray = array(); $deliveryArray = array();
foreach ($delivery AS $deliv) foreach ($delivery as $deliv)
$deliveryArray[$deliv['id_zone']][$deliv['id_carrier']][$deliv[$rangeIdentifier]] = $deliv['price']; $deliveryArray[$deliv['id_zone']][$deliv['id_carrier']][$deliv[$rangeIdentifier]] = $deliv['price'];
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
@@ -140,7 +140,7 @@ class AdminShippingControllerCore extends AdminController
{ {
if ($this->tabAccess['edit'] === '1') if ($this->tabAccess['edit'] === '1')
{ {
if (($id_carrier = (int)(Tools::getValue('id_carrier'))) AND $id_carrier == ($id_carrier2 = (int)(Tools::getValue('id_carrier2')))) if (($id_carrier = (int)(Tools::getValue('id_carrier'))) && $id_carrier == ($id_carrier2 = (int)(Tools::getValue('id_carrier2'))))
{ {
$carrier = new Carrier($id_carrier); $carrier = new Carrier($id_carrier);
if (Validate::isLoadedObject($carrier)) if (Validate::isLoadedObject($carrier))
@@ -154,7 +154,7 @@ class AdminShippingControllerCore extends AdminController
/* Build prices list */ /* Build prices list */
$priceList = array(); $priceList = array();
foreach ($_POST AS $key => $value) foreach ($_POST as $key => $value)
if (strstr($key, 'fees_')) if (strstr($key, 'fees_'))
{ {
$tmpArray = explode('_', $key); $tmpArray = explode('_', $key);
@@ -183,9 +183,7 @@ class AdminShippingControllerCore extends AdminController
$this->errors[] = Tools::displayError('An error occurred while updating fees (cannot load carrier object).'); $this->errors[] = Tools::displayError('An error occurred while updating fees (cannot load carrier object).');
} }
elseif (isset($id_carrier2)) elseif (isset($id_carrier2))
{
$_POST['id_carrier'] = $id_carrier2; $_POST['id_carrier'] = $id_carrier2;
}
else else
$this->errors[] = Tools::displayError('An error occurred while updating fees (cannot load carrier object).'); $this->errors[] = Tools::displayError('An error occurred while updating fees (cannot load carrier object).');
} }
@@ -154,7 +154,7 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor
{ {
$tpl = $this->createTemplate('stats.tpl'); $tpl = $this->createTemplate('stats.tpl');
if (!($module_name = Tools::getValue('module')) && $module_instance = Module::getInstanceByName('statsforecast') AND $module_instance->active) if (!($module_name = Tools::getValue('module')) && ($module_instance = Module::getInstanceByName('statsforecast')) && $module_instance->active)
$module_name = 'statsforecast'; $module_name = 'statsforecast';
if ($module_name) if ($module_name)
@@ -78,8 +78,8 @@ class AdminSubDomainsControllerCore extends AdminController
SELECT `id_subdomain` SELECT `id_subdomain`
FROM `'._DB_PREFIX_.'subdomain` FROM `'._DB_PREFIX_.'subdomain`
'); ');
if (sizeof($result) === 1) if (count($result) === 1)
foreach ($result AS $row) foreach ($result as $row)
$this->_listSkipDelete = array($row['id_subdomain']); $this->_listSkipDelete = array($row['id_subdomain']);
return parent::postProcess(); return parent::postProcess();
@@ -311,8 +311,8 @@ class AdminSuppliersControllerCore extends AdminController
public function afterImageUpload() public function afterImageUpload()
{ {
/* Generate image with differents size */ /* Generate image with differents size */
if (($id_supplier = (int)Tools::getValue('id_supplier')) AND if (($id_supplier = (int)Tools::getValue('id_supplier')) &&
isset($_FILES) AND count($_FILES) AND file_exists(_PS_SUPP_IMG_DIR_.$id_supplier.'.jpg')) isset($_FILES) && count($_FILES) && file_exists(_PS_SUPP_IMG_DIR_.$id_supplier.'.jpg'))
{ {
$images_types = ImageType::getImagesTypes('suppliers'); $images_types = ImageType::getImagesTypes('suppliers');
foreach ($images_types as $k => $image_type) foreach ($images_types as $k => $image_type)
+4 -8
View File
@@ -101,7 +101,7 @@ class AdminTaxesControllerCore extends AdminController
*/ */
public function displayEnableLink($token, $id, $value, $active, $id_category = null, $id_product = null) public function displayEnableLink($token, $id, $value, $active, $id_category = null, $id_product = null)
{ {
if ($value AND TaxRule::isTaxInUse($id)) if ($value && TaxRule::isTaxInUse($id))
$confirm = $this->l('This tax is currently in use in a tax rule. If you continue this tax will be removed from the tax rule, are you sure?'); $confirm = $this->l('This tax is currently in use in a tax rule. If you continue this tax will be removed from the tax rule, are you sure?');
$tpl_enable = $this->context->smarty->createTemplate('helper/list/list_action_enable.tpl'); $tpl_enable = $this->context->smarty->createTemplate('helper/list/list_action_enable.tpl');
@@ -189,12 +189,12 @@ class AdminTaxesControllerCore extends AdminController
{ {
/* Checking fields validity */ /* Checking fields validity */
$this->validateRules(); $this->validateRules();
if (!sizeof($this->errors)) if (!count($this->errors))
{ {
$id = (int)(Tools::getValue('id_'.$this->table)); $id = (int)(Tools::getValue('id_'.$this->table));
/* Object update */ /* Object update */
if (isset($id) AND !empty($id)) if (isset($id) && !empty($id))
{ {
$object = new $this->className($id); $object = new $this->className($id);
if (Validate::isLoadedObject($object)) if (Validate::isLoadedObject($object))
@@ -205,10 +205,8 @@ class AdminTaxesControllerCore extends AdminController
if (!$result) if (!$result)
$this->errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.$this->table.'</b>'; $this->errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.$this->table.'</b>';
elseif ($this->postImage($object->id)) elseif ($this->postImage($object->id))
{
Tools::redirectAdmin(self::$currentIndex.'&id_'.$this->table.'='.$object->id.'&conf=4'.'&token='.$this->token); Tools::redirectAdmin(self::$currentIndex.'&id_'.$this->table.'='.$object->id.'&conf=4'.'&token='.$this->token);
} }
}
else else
$this->errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)'); $this->errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
} }
@@ -220,13 +218,11 @@ class AdminTaxesControllerCore extends AdminController
$this->copyFromPost($object, $this->table); $this->copyFromPost($object, $this->table);
if (!$object->add()) if (!$object->add())
$this->errors[] = Tools::displayError('An error occurred while creating object.').' <b>'.$this->table.'</b>'; $this->errors[] = Tools::displayError('An error occurred while creating object.').' <b>'.$this->table.'</b>';
elseif (($_POST['id_'.$this->table] = $object->id /* voluntary */) AND $this->postImage($object->id) AND $this->_redirect) elseif (($_POST['id_'.$this->table] = $object->id /* voluntary */) && $this->postImage($object->id) && $this->_redirect)
{
Tools::redirectAdmin(self::$currentIndex.'&id_'.$this->table.'='.$object->id.'&conf=3'.'&token='.$this->token); Tools::redirectAdmin(self::$currentIndex.'&id_'.$this->table.'='.$object->id.'&conf=3'.'&token='.$this->token);
} }
} }
} }
}
else else
parent::postProcess(); parent::postProcess();
} }
+24 -25
View File
@@ -136,7 +136,8 @@ class AdminThemesControllerCore extends AdminController
} }
public function renderForm(){ public function renderForm()
{
$getAvailableThemes = Theme::getAvailable(false); $getAvailableThemes = Theme::getAvailable(false);
$available_theme_dir = array(); $available_theme_dir = array();
$selected_theme_dir = null; $selected_theme_dir = null;
@@ -149,6 +150,7 @@ class AdminThemesControllerCore extends AdminController
$available_theme_dir[$k]['label'] = $dirname; $available_theme_dir[$k]['label'] = $dirname;
$available_theme_dir[$k]['id'] = $dirname; $available_theme_dir[$k]['id'] = $dirname;
}; };
$this->fields_form = array( $this->fields_form = array(
'tinymce' => false, 'tinymce' => false,
'legend' => array( 'legend' => array(
@@ -209,13 +211,12 @@ class AdminThemesControllerCore extends AdminController
return parent::renderForm(); return parent::renderForm();
} }
public function renderList(){
public function renderList()
{
$this->addRowAction('edit'); $this->addRowAction('edit');
$this->addRowAction('delete'); $this->addRowAction('delete');
// $this->_filter .= ' AND `id_parent` = '.(int)$this->_category->id.' ';
// $this->_select = 'position ';
return parent::renderList(); return parent::renderList();
} }
@@ -252,7 +253,8 @@ class AdminThemesControllerCore extends AdminController
return $res; return $res;
} }
public function processAdd($token){ public function processAdd($token)
{
$new_dir = Tools::getValue('directory'); $new_dir = Tools::getValue('directory');
$res = true; $res = true;
if (Validate::isDirName($new_dir) && !is_dir(_PS_ALL_THEMES_DIR_.$new_dir)) if (Validate::isDirName($new_dir) && !is_dir(_PS_ALL_THEMES_DIR_.$new_dir))
@@ -272,7 +274,8 @@ class AdminThemesControllerCore extends AdminController
return parent::processAdd($token); return parent::processAdd($token);
} }
public function processDelete($token){ public function processDelete($token)
{
$obj = $this->loadObject(); $obj = $this->loadObject();
if ($obj && $obj->isUsed()) if ($obj && $obj->isUsed())
{ {
@@ -328,7 +331,6 @@ class AdminThemesControllerCore extends AdminController
*/ */
protected function _isThemeCompatible($theme_dir) protected function _isThemeCompatible($theme_dir)
{ {
$all_errors='';
$return = true; $return = true;
$check_version = AdminThemes::$check_features_version; $check_version = AdminThemes::$check_features_version;
@@ -341,10 +343,8 @@ class AdminThemesControllerCore extends AdminController
{ {
$xml = @simplexml_load_file(_PS_ALL_THEMES_DIR_.$theme_dir.'/config.xml'); $xml = @simplexml_load_file(_PS_ALL_THEMES_DIR_.$theme_dir.'/config.xml');
if (!$xml) if (!$xml)
{
$this->errors[] = Tools::displayError('config.xml is not a valid xml file in your theme path.').'<br/>'; $this->errors[] = Tools::displayError('config.xml is not a valid xml file in your theme path.').'<br/>';
} }
}
// will be set to false if any version node in xml is correct // will be set to false if any version node in xml is correct
$xml_version_too_old = true; $xml_version_too_old = true;
@@ -352,20 +352,19 @@ class AdminThemesControllerCore extends AdminController
// node means feature, attributes has to match // node means feature, attributes has to match
// the corresponding value in AdminThemes::$check_features[feature] array // the corresponding value in AdminThemes::$check_features[feature] array
$xmlArray = simpleXMLToArray($xml); $xmlArray = simpleXMLToArray($xml);
foreach($xmlArray AS $version) foreach ($xmlArray as $version)
{ {
if (isset($version['value']) AND version_compare($version['value'], $check_version) >= 0) if (isset($version['value']) && version_compare($version['value'], $check_version) >= 0)
{ {
$checkedFeature = array(); foreach (AdminThemes::$check_features as $codeFeature => $arrConfigToCheck)
foreach (AdminThemes::$check_features AS $codeFeature => $arrConfigToCheck) foreach ($arrConfigToCheck['attributes'] as $attr => $v)
foreach ($arrConfigToCheck['attributes'] AS $attr => $v) if (!isset($version[$codeFeature]) || !isset($version[$codeFeature][$attr]) || $version[$codeFeature][$attr] != $v['value'])
if (!isset($version[$codeFeature]) OR !isset($version[$codeFeature][$attr]) OR $version[$codeFeature][$attr] != $v['value'])
if (!$this->_checkConfigForFeatures($codeFeature, $attr)) // feature missing in config.xml file, or wrong attribute value if (!$this->_checkConfigForFeatures($codeFeature, $attr)) // feature missing in config.xml file, or wrong attribute value
$return = false; $return = false;
$xml_version_too_old = false; $xml_version_too_old = false;
} }
} }
if ($xml_version_too_old AND !$this->_checkConfigForFeatures(array_keys(AdminThemes::$check_features))) if ($xml_version_too_old && !$this->_checkConfigForFeatures(array_keys(AdminThemes::$check_features)))
{ {
$this->errors[] .= Tools::displayError('config.xml theme file has not been created for this version of prestashop.'); $this->errors[] .= Tools::displayError('config.xml theme file has not been created for this version of prestashop.');
$return = false; $return = false;
@@ -386,7 +385,7 @@ class AdminThemesControllerCore extends AdminController
if (is_array($configItem)) if (is_array($configItem))
{ {
foreach ($arrFeatures as $feature) foreach ($arrFeatures as $feature)
if (!sizeof($configItem)) if (!count($configItem))
$configItem = array_keys(AdminThemes::$check_features[$feature]['attributes']); $configItem = array_keys(AdminThemes::$check_features[$feature]['attributes']);
foreach ($configItem as $attr) foreach ($configItem as $attr)
{ {
@@ -434,7 +433,7 @@ class AdminThemesControllerCore extends AdminController
// new check compatibility theme feature (1.4) : // new check compatibility theme feature (1.4) :
$val = Tools::getValue('PS_THEME'); $val = Tools::getValue('PS_THEME');
Configuration::updateValue('PS_IMG_UPDATE_TIME', time()); Configuration::updateValue('PS_IMG_UPDATE_TIME', time());
if (!empty($val) AND !$this->_isThemeCompatible($val)) // don't submit if errors if (!empty($val) && !$this->_isThemeCompatible($val)) // don't submit if errors
unset($_POST['submitThemes'.$this->table]); unset($_POST['submitThemes'.$this->table]);
Tools::clearCache($this->context->smarty); Tools::clearCache($this->context->smarty);
@@ -447,7 +446,7 @@ class AdminThemesControllerCore extends AdminController
public function updateOptionPsLogo() public function updateOptionPsLogo()
{ {
$id_shop = Context::getContext()->shop->getID(); $id_shop = Context::getContext()->shop->getID();
if (isset($_FILES['PS_LOGO']['tmp_name']) AND $_FILES['PS_LOGO']['tmp_name']) if (isset($_FILES['PS_LOGO']['tmp_name']) && $_FILES['PS_LOGO']['tmp_name'])
{ {
if ($error = ImageManager::validateUpload($_FILES['PS_LOGO'], 300000)) if ($error = ImageManager::validateUpload($_FILES['PS_LOGO'], 300000))
$this->errors[] = $error; $this->errors[] = $error;
@@ -469,7 +468,7 @@ class AdminThemesControllerCore extends AdminController
public function updateOptionPsLogoMail() public function updateOptionPsLogoMail()
{ {
$id_shop = Context::getContext()->shop->getID(); $id_shop = Context::getContext()->shop->getID();
if (isset($_FILES['PS_LOGO_MAIL']['tmp_name']) AND $_FILES['PS_LOGO_MAIL']['tmp_name']) if (isset($_FILES['PS_LOGO_MAIL']['tmp_name']) && $_FILES['PS_LOGO_MAIL']['tmp_name'])
{ {
if ($error = ImageManager::validateUpload($_FILES['PS_LOGO_MAIL'], 300000)) if ($error = ImageManager::validateUpload($_FILES['PS_LOGO_MAIL'], 300000))
$this->errors[] = $error; $this->errors[] = $error;
@@ -490,7 +489,7 @@ class AdminThemesControllerCore extends AdminController
public function updateOptionPsLogoInvoice() public function updateOptionPsLogoInvoice()
{ {
$id_shop = Context::getContext()->shop->getID(); $id_shop = Context::getContext()->shop->getID();
if (isset($_FILES['PS_LOGO_INVOICE']['tmp_name']) AND $_FILES['PS_LOGO_INVOICE']['tmp_name']) if (isset($_FILES['PS_LOGO_INVOICE']['tmp_name']) && $_FILES['PS_LOGO_INVOICE']['tmp_name'])
{ {
if ($error = ImageManager::validateUpload($_FILES['PS_LOGO_INVOICE'], 300000)) if ($error = ImageManager::validateUpload($_FILES['PS_LOGO_INVOICE'], 300000))
$this->errors[] = $error; $this->errors[] = $error;
@@ -512,7 +511,7 @@ class AdminThemesControllerCore extends AdminController
public function updateOptionPsStoresIcon() public function updateOptionPsStoresIcon()
{ {
$id_shop = Context::getContext()->shop->getID(); $id_shop = Context::getContext()->shop->getID();
if (isset($_FILES['PS_STORES_ICON']['tmp_name']) AND $_FILES['PS_STORES_ICON']['tmp_name']) if (isset($_FILES['PS_STORES_ICON']['tmp_name']) && $_FILES['PS_STORES_ICON']['tmp_name'])
{ {
if ($error = ImageManager::validateUpload($_FILES['PS_STORES_ICON'], 300000)) if ($error = ImageManager::validateUpload($_FILES['PS_STORES_ICON'], 300000))
$this->errors[] = $error; $this->errors[] = $error;
@@ -535,11 +534,11 @@ class AdminThemesControllerCore extends AdminController
{ {
if (isset($_FILES[$name]['tmp_name']) && !empty($_FILES[$name]['tmp_name'])) if (isset($_FILES[$name]['tmp_name']) && !empty($_FILES[$name]['tmp_name']))
{ {
/* Check ico validity */ // Check ico validity
if ($error = ImageManager::validateIconUpload($_FILES[$name])) if ($error = ImageManager::validateIconUpload($_FILES[$name]))
$this->errors[] = $error; $this->errors[] = $error;
/* Copy new ico */ // Copy new ico
elseif (!copy($_FILES[$name]['tmp_name'], $dest)) elseif (!copy($_FILES[$name]['tmp_name'], $dest))
$this->errors[] = Tools::displayError('an error occurred while uploading favicon: '.$_FILES[$name]['tmp_name'].' to '.$dest); $this->errors[] = Tools::displayError('an error occurred while uploading favicon: '.$_FILES[$name]['tmp_name'].' to '.$dest);
} }
@@ -141,9 +141,7 @@ class AdminTranslationsControllerCore extends AdminController
{ {
$_NEW_MODULE = array(); $_NEW_MODULE = array();
foreach ($_MODULE as $key => $value) foreach ($_MODULE as $key => $value)
{
$_NEW_MODULE[self::DEFAULT_THEME_NAME.$key] = $value; $_NEW_MODULE[self::DEFAULT_THEME_NAME.$key] = $value;
}
$_MODULE = $_NEW_MODULE; $_MODULE = $_NEW_MODULE;
} }
$_MODULES = (is_array($_MODULES) && is_array($_MODULE)) ? array_merge($_MODULES, $_MODULE) : $_MODULE; $_MODULES = (is_array($_MODULES) && is_array($_MODULE)) ? array_merge($_MODULES, $_MODULE) : $_MODULE;
@@ -733,13 +731,12 @@ class AdminTranslationsControllerCore extends AdminController
{ {
if ($group == 'core_mail' || $group == 'module_mail') if ($group == 'core_mail' || $group == 'module_mail')
$array_subjects['core_and_modules']['translations'] = array_merge($array_subjects['core_and_modules']['translations'], $subject_translation); $array_subjects['core_and_modules']['translations'] = array_merge($array_subjects['core_and_modules']['translations'], $subject_translation);
elseif ( isset($array_subjects['themes_and_modules']) && ($group == 'theme_mail' || $group == 'theme_module_mail')) { elseif (isset($array_subjects['themes_and_modules']) && ($group == 'theme_mail' || $group == 'theme_module_mail'))
$array_subjects['themes_and_modules']['translations'] = array_merge($array_subjects['themes_and_modules']['translations'], $subject_translation); $array_subjects['themes_and_modules']['translations'] = array_merge($array_subjects['themes_and_modules']['translations'], $subject_translation);
} }
} }
}
if (!empty($array_subjects)) if (!empty($array_subjects))
foreach ($array_subjects as $type => $infos) foreach ($array_subjects as $infos)
$this->writeSubjectTranslationFile($infos['translations'], $infos['path']); $this->writeSubjectTranslationFile($infos['translations'], $infos['path']);
if (count($this->errors) == 0) if (count($this->errors) == 0)
@@ -912,8 +909,6 @@ class AdminTranslationsControllerCore extends AdminController
$tabs = array_merge($tabs, Tools::scandir(_PS_ADMIN_CONTROLLER_DIR_, 'php', '../../classes/helper')); $tabs = array_merge($tabs, Tools::scandir(_PS_ADMIN_CONTROLLER_DIR_, 'php', '../../classes/helper'));
$tabs[] = '../../classes/AdminController.php'; $tabs[] = '../../classes/AdminController.php';
$files = array();
$i=0;
foreach ($tabs as $tab) foreach ($tabs as $tab)
if (preg_match('/^(.*)\.php$/', $tab) && file_exists($tpl = _PS_ADMIN_CONTROLLER_DIR_.$tab)) if (preg_match('/^(.*)\.php$/', $tab) && file_exists($tpl = _PS_ADMIN_CONTROLLER_DIR_.$tab))
{ {
@@ -988,7 +983,7 @@ class AdminTranslationsControllerCore extends AdminController
$pos = strrpos($prefix_key, DIRECTORY_SEPARATOR); $pos = strrpos($prefix_key, DIRECTORY_SEPARATOR);
$tmp = substr($prefix_key, 0, $pos); $tmp = substr($prefix_key, 0, $pos);
if (preg_match("#controllers#", $tmp)) if (preg_match('#controllers#', $tmp))
{ {
$parentClass = explode(DIRECTORY_SEPARATOR, $tmp); $parentClass = explode(DIRECTORY_SEPARATOR, $tmp);
$key = array_search('controllers', $parentClass); $key = array_search('controllers', $parentClass);
@@ -1031,9 +1026,7 @@ class AdminTranslationsControllerCore extends AdminController
$trans_key = $prefix_key.md5($english_string); $trans_key = $prefix_key.md5($english_string);
if (isset($_LANGADM[$trans_key])) if (isset($_LANGADM[$trans_key]))
{
$new_lang[$english_string] = html_entity_decode($_LANGADM[$trans_key], ENT_COMPAT, 'UTF-8'); $new_lang[$english_string] = html_entity_decode($_LANGADM[$trans_key], ENT_COMPAT, 'UTF-8');
}
else else
{ {
$new_lang[$english_string] = ''; $new_lang[$english_string] = '';
@@ -1104,7 +1097,7 @@ class AdminTranslationsControllerCore extends AdminController
} }
foreach ($dirToParse as $dir) foreach ($dirToParse as $dir)
foreach (scandir($dir) as $file) foreach (scandir($dir) as $file)
if (preg_match('/\.php$/', $file) AND file_exists($fn = $dir.$file) AND $file != 'index.php') if (preg_match('/\.php$/', $file) && file_exists($fn = $dir.$file) && $file != 'index.php')
{ {
if (!filesize($fn)) if (!filesize($fn))
continue; continue;
@@ -1112,7 +1105,6 @@ class AdminTranslationsControllerCore extends AdminController
foreach ($matches[1] as $key) foreach ($matches[1] as $key)
$stringToTranslate[$key] = (key_exists(md5($key), $_ERRORS)) ? html_entity_decode($_ERRORS[md5($key)], ENT_COMPAT, 'UTF-8') : ''; $stringToTranslate[$key] = (key_exists(md5($key), $_ERRORS)) ? html_entity_decode($_ERRORS[md5($key)], ENT_COMPAT, 'UTF-8') : '';
} }
$irow = 0;
$this->tpl_view_vars = array( $this->tpl_view_vars = array(
'lang' => Tools::strtoupper($lang), 'lang' => Tools::strtoupper($lang),
@@ -1142,7 +1134,7 @@ class AdminTranslationsControllerCore extends AdminController
foreach (scandir(_PS_CLASS_DIR_) as $classFile) foreach (scandir(_PS_CLASS_DIR_) as $classFile)
{ {
if (!preg_match('/\.php$/', $classFile) OR $classFile == 'index.php') if (!preg_match('/\.php$/', $classFile) || $classFile == 'index.php')
continue; continue;
include_once(_PS_CLASS_DIR_.$classFile); include_once(_PS_CLASS_DIR_.$classFile);
$prefix_key = substr($classFile, 0, -4); $prefix_key = substr($classFile, 0, -4);
@@ -1233,25 +1225,23 @@ class AdminTranslationsControllerCore extends AdminController
{ {
$email_name = substr($email_file, 0, strripos($email_file, '.')); $email_name = substr($email_file, 0, strripos($email_file, '.'));
$type = substr($email_file, strripos($email_file, '.') + 1); $type = substr($email_file, strripos($email_file, '.') + 1);
if (!isset($arr_return['files'][$email_name])) { if (!isset($arr_return['files'][$email_name]))
$arr_return['files'][$email_name] = array(); $arr_return['files'][$email_name] = array();
}
$arr_return['files'][$email_name][$type]['en'] = $this->getMailContent($dir, $email_file, 'en'); $arr_return['files'][$email_name][$type]['en'] = $this->getMailContent($dir, $email_file, 'en');
// check if the file exists in the language to translate // check if the file exists in the language to translate
if (file_exists($dir.$lang.'/'.$email_file)) { if (file_exists($dir.$lang.'/'.$email_file))
$arr_return['files'][$email_name][$type][$lang] = $this->getMailContent($dir, $email_file, $lang); $arr_return['files'][$email_name][$type][$lang] = $this->getMailContent($dir, $email_file, $lang);
} else { else
$arr_return['files'][$email_name][$type][$lang] = ''; $arr_return['files'][$email_name][$type][$lang] = '';
}
if ($arr_return['files'][$email_name][$type][$lang] == '') { if ($arr_return['files'][$email_name][$type][$lang] == '')
$arr_return['empty_values']++; $arr_return['empty_values']++;
} else { else
$arr_return['total_filled']++; $arr_return['total_filled']++;
} }
} }
} }
}
return $arr_return; return $arr_return;
} }
@@ -1265,12 +1255,10 @@ class AdminTranslationsControllerCore extends AdminController
*/ */
protected function getMailContent($dir, $file, $lang) protected function getMailContent($dir, $file, $lang)
{ {
$arr_return = array();
$content = file_get_contents($dir.$lang.'/'.$file); $content = file_get_contents($dir.$lang.'/'.$file);
if (Tools::strlen($content) === 0) { if (Tools::strlen($content) === 0)
$content = ''; $content = '';
}
return $content; return $content;
} }
@@ -1291,9 +1279,8 @@ class AdminTranslationsControllerCore extends AdminController
$str_return = ''; $str_return = '';
$group_name = 'mail'; $group_name = 'mail';
if (key_exists('group_name', $mails)) if (key_exists('group_name', $mails))
{
$group_name = $mails['group_name']; $group_name = $mails['group_name'];
}
$str_return .= ' $str_return .= '
<div class="mails_field" > <div class="mails_field" >
<h3 style="cursor : pointer" onclick="$(\'#'.$id_html.'\').slideToggle();">'.$title.' - <font color="red">'.$mails['empty_values'].'</font> ' <h3 style="cursor : pointer" onclick="$(\'#'.$id_html.'\').slideToggle();">'.$title.' - <font color="red">'.$mails['empty_values'].'</font> '
@@ -1304,7 +1291,7 @@ class AdminTranslationsControllerCore extends AdminController
{ {
foreach ($mails['files'] as $mail_name => $mail_files) foreach ($mails['files'] as $mail_name => $mail_files)
{ {
if ((key_exists('html', $mail_files) OR key_exists('txt', $mail_files))) if (key_exists('html', $mail_files) || key_exists('txt', $mail_files))
{ {
if (key_exists($mail_name, $all_subject_mail)) if (key_exists($mail_name, $all_subject_mail))
{ {
@@ -1332,12 +1319,11 @@ class AdminTranslationsControllerCore extends AdminController
$url_mail = $base_uri.$obj_lang->iso_code.'/'.$mail_name.'.html'; $url_mail = $base_uri.$obj_lang->iso_code.'/'.$mail_name.'.html';
$str_return .= $this->displayMailBlockHtml($mail_files['html'], $obj_lang->iso_code, $url_mail, $mail_name, $group_name, $name_for_module); $str_return .= $this->displayMailBlockHtml($mail_files['html'], $obj_lang->iso_code, $url_mail, $mail_name, $group_name, $name_for_module);
} }
if (key_exists('txt', $mail_files)) { if (key_exists('txt', $mail_files))
$str_return .= $this->displayMailBlockTxt($mail_files['txt'], $obj_lang->iso_code, $mail_name, $group_name, $name_for_module); $str_return .= $this->displayMailBlockTxt($mail_files['txt'], $obj_lang->iso_code, $mail_name, $group_name, $name_for_module);
} }
} }
} }
}
else else
{ {
$str_return .= ' $str_return .= '
@@ -1435,20 +1421,15 @@ class AdminTranslationsControllerCore extends AdminController
{ {
$arr_modules = array(); $arr_modules = array();
foreach (scandir(_PS_MODULE_DIR_) as $module_dir) foreach (scandir(_PS_MODULE_DIR_) as $module_dir)
{ if ($module_dir[0] != '.' && file_exists(_PS_MODULE_DIR_.$module_dir.'/mails'))
if ($module_dir[0] != '.' AND file_exists(_PS_MODULE_DIR_.$module_dir.'/mails'))
{
$arr_modules[$module_dir] = _PS_MODULE_DIR_.$module_dir; $arr_modules[$module_dir] = _PS_MODULE_DIR_.$module_dir;
}
}
return $arr_modules; return $arr_modules;
} }
protected function getTinyMCEForMails($iso_lang) protected function getTinyMCEForMails($iso_lang)
{ {
// TinyMCE // TinyMCE
$isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$iso_lang.'.js') ? $iso_lang : 'en'); $isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$iso_lang.'.js') ? $iso_lang : 'en');
$ad = dirname($_SERVER["PHP_SELF"]); $ad = dirname($_SERVER['PHP_SELF']);
return ' return '
<script type="text/javascript"> <script type="text/javascript">
var iso = \''.$isoTinyMCE.'\' ; var iso = \''.$isoTinyMCE.'\' ;
@@ -1480,9 +1461,8 @@ class AdminTranslationsControllerCore extends AdminController
_PS_ADMIN_DIR_, _PS_ADMIN_DIR_,
); );
$arr_files_to_parse = array_merge($arr_files_to_parse, $modules_has_mails); $arr_files_to_parse = array_merge($arr_files_to_parse, $modules_has_mails);
foreach ($arr_files_to_parse as $path) { foreach ($arr_files_to_parse as $path)
$subject_mail = AdminTranslationsController::getSubjectMail($path, $subject_mail); $subject_mail = AdminTranslationsController::getSubjectMail($path, $subject_mail);
}
$core_mails = $this->getMailFiles(_PS_MAIL_DIR_, $lang, 'core_mail'); $core_mails = $this->getMailFiles(_PS_MAIL_DIR_, $lang, 'core_mail');
$core_mails['subject'] = $this->getSubjectMailContent(_PS_MAIL_DIR_.$lang); $core_mails['subject'] = $this->getSubjectMailContent(_PS_MAIL_DIR_.$lang);
@@ -1507,7 +1487,7 @@ class AdminTranslationsControllerCore extends AdminController
{ {
foreach (scandir(_PS_THEME_DIR_.'/modules') as $module_dir) foreach (scandir(_PS_THEME_DIR_.'/modules') as $module_dir)
{ {
if ($module_dir[0] != '.' AND file_exists(_PS_THEME_DIR_.'modules/'.$module_dir.'/mails')) if ($module_dir[0] != '.' && file_exists(_PS_THEME_DIR_.'modules/'.$module_dir.'/mails'))
{ {
$theme_mails[$module_dir] = $this->getMailFiles(_PS_THEME_DIR_.'modules/'.$module_dir.'/mails/', $lang, 'theme_module_mail'); $theme_mails[$module_dir] = $this->getMailFiles(_PS_THEME_DIR_.'modules/'.$module_dir.'/mails/', $lang, 'theme_module_mail');
$theme_mails[$module_dir]['subject'] = $theme_mails['theme_mail']['subject']; $theme_mails[$module_dir]['subject'] = $theme_mails['theme_mail']['subject'];
@@ -1560,10 +1540,10 @@ class AdminTranslationsControllerCore extends AdminController
{ {
foreach (scandir($directory) as $filename) foreach (scandir($directory) as $filename)
{ {
if (strripos($filename, '.php') > 0 AND $filename != 'AdminTranslations.php') if (strripos($filename, '.php') > 0 && $filename != 'AdminTranslations.php')
{ {
$content = file_get_contents($directory.'/'.$filename); $content = file_get_contents($directory.'/'.$filename);
$content = str_replace("\n", " ", $content); $content = str_replace("\n", ' ', $content);
if (preg_match_all('/Mail::Send([^;]*);/si', $content, $tab)) if (preg_match_all('/Mail::Send([^;]*);/si', $content, $tab))
{ {
for ($i = 0; isset($tab[1][$i]); $i++) for ($i = 0; isset($tab[1][$i]); $i++)
@@ -1582,7 +1562,7 @@ class AdminTranslationsControllerCore extends AdminController
} }
} }
} }
if ($filename != '.svn' AND $filename != '.' AND $filename != '..' AND is_dir(($directory.'/'.$filename))) if ($filename != '.svn' && $filename != '.' && $filename != '..' && is_dir(($directory.'/'.$filename)))
$subject_mail = AdminTranslationsController::getSubjectMail($directory.'/'.$filename, $subject_mail); $subject_mail = AdminTranslationsController::getSubjectMail($directory.'/'.$filename, $subject_mail);
} }
return $subject_mail; return $subject_mail;
@@ -1661,11 +1641,9 @@ class AdminTranslationsControllerCore extends AdminController
if (!empty($dir_module)) if (!empty($dir_module))
{ {
foreach ($dir_module as $folder) foreach ($dir_module as $folder)
{
$this->recursiveGetModuleFiles($path.$folder.'/', $array_files, $module_name, $lang_file, $is_default); $this->recursiveGetModuleFiles($path.$folder.'/', $array_files, $module_name, $lang_file, $is_default);
} }
} }
}
/** /**
* This method get translation in each translations file. * This method get translation in each translations file.
@@ -1682,7 +1660,7 @@ class AdminTranslationsControllerCore extends AdminController
$array_files = array(); $array_files = array();
foreach ($modules as $module) foreach ($modules as $module)
{ {
if ($module{0} != '.' AND is_dir($root_dir.$module)) if ($module{0} != '.' && is_dir($root_dir.$module))
{ {
@include($root_dir.$module.'/'.$lang.'.php'); @include($root_dir.$module.'/'.$lang.'.php');
AdminTranslationsController::getModuleTranslations($is_default); AdminTranslationsController::getModuleTranslations($is_default);
@@ -1787,7 +1765,7 @@ class AdminTranslationsControllerCore extends AdminController
$regex = '/HTMLTemplate.*::l\(\''._PS_TRANS_PATTERN_.'\'[\)|\,]/U'; $regex = '/HTMLTemplate.*::l\(\''._PS_TRANS_PATTERN_.'\'[\)|\,]/U';
// need to parse PDF.php in order to find $regex and add this to $tabs_array // need to parse PDF.php in order to find $regex and add this to $tabs_array
// this has to be done for the core class, and eventually for the override // this has to be done for the core class, and eventually for the override
foreach (glob(_PS_CLASS_DIR_.'pdf/'."*.php") as $filename) foreach (glob(_PS_CLASS_DIR_.'pdf/*.php') as $filename)
{ {
$tabs_array = $this->_parsePdfClass($filename, $regex, $_LANGPDF, $prefix_key, $tabs_array); $tabs_array = $this->_parsePdfClass($filename, $regex, $_LANGPDF, $prefix_key, $tabs_array);
if (file_exists(_PS_ROOT_DIR_.'/override/classes/pdf/'.basename($filename))) if (file_exists(_PS_ROOT_DIR_.'/override/classes/pdf/'.basename($filename)))
@@ -1848,7 +1826,7 @@ class AdminTranslationsControllerCore extends AdminController
{ {
$dir = opendir(_PS_ALL_THEMES_DIR_); $dir = opendir(_PS_ALL_THEMES_DIR_);
while ($folder = readdir($dir)) while ($folder = readdir($dir))
if ($folder != '.' AND $folder != '..' AND is_dir(_PS_ALL_THEMES_DIR_.DIRECTORY_SEPARATOR.$folder) AND file_exists(_PS_ALL_THEMES_DIR_.'/'.$folder.'/preview.jpg')) if ($folder != '.' && $folder != '..' && is_dir(_PS_ALL_THEMES_DIR_.DIRECTORY_SEPARATOR.$folder) && file_exists(_PS_ALL_THEMES_DIR_.'/'.$folder.'/preview.jpg'))
$themes[$folder]['name'] = $folder; $themes[$folder]['name'] = $folder;
closedir($dir); closedir($dir);
return isset($themes) ? $themes : array(); return isset($themes) ? $themes : array();