|
24 | 24 | * International Registered Trademark & Property of PrestaShop SA |
25 | 25 | */ |
26 | 26 |
|
27 | | -if (!defined('_PS_ADMIN_DIR_')) |
| 27 | +if (!defined('_PS_ADMIN_DIR_')) { |
28 | 28 | define('_PS_ADMIN_DIR_', getcwd()); |
| 29 | +} |
29 | 30 | include(_PS_ADMIN_DIR_.'/../config/config.inc.php'); |
30 | 31 |
|
31 | 32 | /* Getting cookie or logout */ |
32 | 33 | require_once(_PS_ADMIN_DIR_.'/init.php'); |
33 | 34 |
|
34 | 35 | $context = Context::getContext(); |
35 | 36 |
|
36 | | -if (Tools::isSubmit('ajaxReferrers')) |
| 37 | +if (Tools::isSubmit('ajaxReferrers')) { |
37 | 38 | require(_PS_CONTROLLER_DIR_.'admin/AdminReferrersController.php'); |
| 39 | +} |
38 | 40 |
|
39 | | -if (Tools::getValue('page') == 'prestastore' and @fsockopen('addons.prestashop.com', 80, $errno, $errst, 3)) |
| 41 | +if (Tools::getValue('page') == 'prestastore' and @fsockopen('addons.prestashop.com', 80, $errno, $errst, 3)) { |
40 | 42 | readfile('http://addons.prestashop.com/adminmodules.php?lang='.$context->language->iso_code); |
| 43 | +} |
41 | 44 |
|
42 | | -if (Tools::isSubmit('getAvailableFields') and Tools::isSubmit('entity')) |
43 | | -{ |
| 45 | +if (Tools::isSubmit('getAvailableFields') and Tools::isSubmit('entity')) { |
44 | 46 | $jsonArray = array(); |
45 | 47 | $import = new AdminImportController(); |
46 | 48 |
|
47 | 49 | $fields = $import->getAvailableFields(true); |
48 | | - foreach ($fields as $field) |
| 50 | + foreach ($fields as $field) { |
49 | 51 | $jsonArray[] = '{"field":"'.addslashes($field).'"}'; |
| 52 | + } |
50 | 53 | die('['.implode(',', $jsonArray).']'); |
51 | 54 | } |
52 | 55 |
|
53 | | -if (Tools::isSubmit('ajaxProductPackItems')) |
54 | | -{ |
| 56 | +if (Tools::isSubmit('ajaxProductPackItems')) { |
55 | 57 | $jsonArray = array(); |
56 | 58 | $products = Db::getInstance()->executeS(' |
57 | 59 | SELECT p.`id_product`, pl.`name` |
|
62 | 64 | AND NOT EXISTS (SELECT 1 FROM `'._DB_PREFIX_.'pack` WHERE `id_product_pack` = p.`id_product`) |
63 | 65 | AND p.`id_product` != '.(int)(Tools::getValue('id_product'))); |
64 | 66 |
|
65 | | - foreach ($products as $packItem) |
| 67 | + foreach ($products as $packItem) { |
66 | 68 | $jsonArray[] = '{"value": "'.(int)($packItem['id_product']).'-'.addslashes($packItem['name']).'", "text":"'.(int)($packItem['id_product']).' - '.addslashes($packItem['name']).'"}'; |
| 69 | + } |
67 | 70 | die('['.implode(',', $jsonArray).']'); |
68 | 71 | } |
69 | 72 |
|
70 | | -if (Tools::isSubmit('getChildrenCategories') && Tools::isSubmit('id_category_parent')) |
71 | | -{ |
| 73 | +if (Tools::isSubmit('getChildrenCategories') && Tools::isSubmit('id_category_parent')) { |
72 | 74 | $children_categories = Category::getChildrenWithNbSelectedSubCat(Tools::getValue('id_category_parent'), Tools::getValue('selectedCat'), Context::getContext()->language->id, null, Tools::getValue('use_shop_context')); |
73 | 75 | die(Tools::jsonEncode($children_categories)); |
74 | 76 | } |
75 | 77 |
|
76 | | -if (Tools::isSubmit('getNotifications')) |
77 | | -{ |
| 78 | +if (Tools::isSubmit('getNotifications')) { |
78 | 79 | $notification = new Notification; |
79 | 80 | die(Tools::jsonEncode($notification->getLastElements())); |
80 | 81 | } |
81 | 82 |
|
82 | | -if (Tools::isSubmit('updateElementEmployee') && Tools::getValue('updateElementEmployeeType')) |
83 | | -{ |
| 83 | +if (Tools::isSubmit('updateElementEmployee') && Tools::getValue('updateElementEmployeeType')) { |
84 | 84 | $notification = new Notification; |
85 | 85 | die($notification->updateEmployeeLastElement(Tools::getValue('updateElementEmployeeType'))); |
86 | 86 | } |
87 | 87 |
|
88 | | -if (Tools::isSubmit('searchCategory')) |
89 | | -{ |
| 88 | +if (Tools::isSubmit('searchCategory')) { |
90 | 89 | $q = Tools::getValue('q'); |
91 | 90 | $limit = Tools::getValue('limit'); |
92 | 91 | $results = Db::getInstance()->executeS( |
|
98 | 97 | GROUP BY c.id_category |
99 | 98 | ORDER BY c.`position` |
100 | 99 | LIMIT '.(int)$limit); |
101 | | - if ($results) |
102 | | - foreach ($results as $result) |
103 | | - echo trim($result['name']).'|'.(int)$result['id_category']."\n"; |
| 100 | + if ($results) { |
| 101 | + foreach ($results as $result) { |
| 102 | + echo trim($result['name']).'|'.(int)$result['id_category']."\n"; |
| 103 | + } |
| 104 | + } |
104 | 105 | } |
105 | 106 |
|
106 | | -if (Tools::isSubmit('getParentCategoriesId') && $id_category = Tools::getValue('id_category')) |
107 | | -{ |
| 107 | +if (Tools::isSubmit('getParentCategoriesId') && $id_category = Tools::getValue('id_category')) { |
108 | 108 | $category = new Category((int)$id_category); |
109 | 109 | $results = Db::getInstance()->executeS('SELECT `id_category` FROM `'._DB_PREFIX_.'category` c WHERE c.`nleft` < '.(int)$category->nleft.' AND c.`nright` > '.(int)$category->nright.''); |
110 | 110 | $output = array(); |
111 | | - foreach ($results as $result) |
| 111 | + foreach ($results as $result) { |
112 | 112 | $output[] = $result; |
| 113 | + } |
113 | 114 |
|
114 | 115 | die(Tools::jsonEncode($output)); |
115 | 116 | } |
116 | 117 |
|
117 | | -if (Tools::isSubmit('getZones')) |
118 | | -{ |
| 118 | +if (Tools::isSubmit('getZones')) { |
119 | 119 | $html = '<select id="zone_to_affect" name="zone_to_affect">'; |
120 | | - foreach (Zone::getZones() as $z) |
| 120 | + foreach (Zone::getZones() as $z) { |
121 | 121 | $html .= '<option value="'.$z['id_zone'].'">'.$z['name'].'</option>'; |
| 122 | + } |
122 | 123 | $html .= '</select>'; |
123 | 124 | $array = array('hasError' => false, 'errors' => '', 'data' => $html); |
124 | 125 | die(Tools::jsonEncode($array)); |
|
0 commit comments