diff --git a/admin/ajax.php b/admin/ajax.php index be2c91bc4..2506e809d 100644 --- a/admin/ajax.php +++ b/admin/ajax.php @@ -72,12 +72,12 @@ if (Tools::isSubmit('ajaxProductPackItems')) { if (Tools::isSubmit('getChildrenCategories') && Tools::isSubmit('id_category_parent')) { $children_categories = Category::getChildrenWithNbSelectedSubCat(Tools::getValue('id_category_parent'), Tools::getValue('selectedCat'), Context::getContext()->language->id, null, Tools::getValue('use_shop_context')); - die(Tools::jsonEncode($children_categories)); + die(json_encode($children_categories)); } if (Tools::isSubmit('getNotifications')) { $notification = new Notification; - die(Tools::jsonEncode($notification->getLastElements())); + die(json_encode($notification->getLastElements())); } if (Tools::isSubmit('updateElementEmployee') && Tools::getValue('updateElementEmployeeType')) { @@ -111,7 +111,7 @@ if (Tools::isSubmit('getParentCategoriesId') && $id_category = Tools::getValue(' $output[] = $result; } - die(Tools::jsonEncode($output)); + die(json_encode($output)); } if (Tools::isSubmit('getZones')) { @@ -121,7 +121,7 @@ if (Tools::isSubmit('getZones')) { } $html .= ''; $array = array('hasError' => false, 'errors' => '', 'data' => $html); - die(Tools::jsonEncode($array)); + die(json_encode($array)); } if (Tools::isSubmit('getEmailHTML') && $email = Tools::getValue('email')) { diff --git a/admin/ajax_products_list.php b/admin/ajax_products_list.php index 137020a37..03a5f4999 100644 --- a/admin/ajax_products_list.php +++ b/admin/ajax_products_list.php @@ -137,7 +137,7 @@ if ($items && ($excludeIds || strpos($_SERVER['HTTP_REFERER'], 'AdminScenes') != } } $results = array_values($results); - echo Tools::jsonEncode($results); + echo json_encode($results); } else { - Tools::jsonEncode(new stdClass); + json_encode(new stdClass); } diff --git a/admin/functions.php b/admin/functions.php index 15c397049..ae72f6340 100644 --- a/admin/functions.php +++ b/admin/functions.php @@ -524,8 +524,8 @@ function runAdminTab($tab, $ajax_mode = false) } // we can display the correct url - // die(Tools::jsonEncode(array(Translate::getAdminTranslation('Invalid security token'),$url))); - die(Tools::jsonEncode(Translate::getAdminTranslation('Invalid security token'))); + // die(json_encode(array(Translate::getAdminTranslation('Invalid security token'),$url))); + die(json_encode(Translate::getAdminTranslation('Invalid security token'))); } else { // If this is an XSS attempt, then we should only display a simple, secure page if (ob_get_level() && ob_get_length() > 0) { diff --git a/classes/Cart.php b/classes/Cart.php index 7d380889b..079f10c86 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -4317,7 +4317,7 @@ class CartCore extends ObjectModel $postData = trim(file_get_contents('php://input')); libxml_use_internal_errors(true); $xml = simplexml_load_string(utf8_decode($postData)); - $cartData = Tools::jsonDecode(Tools::jsonEncode($xml, true)); + $cartData = json_decode(json_encode($xml, true)); $this->id_address_delivery = $cartData->cart->id_address; $this->id_address_invoice = $cartData->cart->id_address; @@ -4344,7 +4344,7 @@ class CartCore extends ObjectModel $postData = trim(file_get_contents('php://input')); libxml_use_internal_errors(true); $xml = simplexml_load_string(utf8_decode($postData)); - $cartData = Tools::jsonDecode(Tools::jsonEncode($xml, true)); + $cartData = json_decode(json_encode($xml, true)); $this->id_address_delivery = $cartData->cart->id_address; $this->id_address_invoice = $cartData->cart->id_address; @@ -4384,14 +4384,14 @@ class CartCore extends ObjectModel $extraDemands = null; foreach ($bookingRows as $booking) { - $booking = Tools::jsonDecode(Tools::jsonEncode($booking, true), true); + $booking = json_decode(json_encode($booking, true), true); if (isset($booking['extra_demands']['extra_demand'])) { $extraDemands = $booking['extra_demands']['extra_demand']; if (isset($extraDemands['id_global_demand'])) { $extraDemands = array($extraDemands); } - // $extraDemands = Tools::jsonDecode($extraDemands, true); - $extraDemands = Tools::jsonEncode($extraDemands); + // $extraDemands = json_decode($extraDemands, true); + $extraDemands = json_encode($extraDemands); } // get room booking info diff --git a/classes/Language.php b/classes/Language.php index 59f5f2e01..af8e9998a 100644 --- a/classes/Language.php +++ b/classes/Language.php @@ -798,7 +798,7 @@ class LanguageCore extends ObjectModel // If the language pack has not been provided, retrieve it from prestashop.com if (!$lang_pack) { - $lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$iso_code)); + $lang_pack = json_decode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$iso_code)); } // If a language pack has been found or provided, prefill the language object with the value @@ -914,7 +914,7 @@ class LanguageCore extends ObjectModel if (!$lang_pack_link = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='.$version.'&iso_lang='.Tools::strtolower((string)$iso))) { $errors[] = Tools::displayError('Archive cannot be downloaded from prestashop.com.'); - } elseif (!$lang_pack = Tools::jsonDecode($lang_pack_link)) { + } elseif (!$lang_pack = json_decode($lang_pack_link)) { $errors[] = Tools::displayError('Error occurred when language was checked according to your Prestashop version.'); } elseif (empty($lang_pack->error) && ($content = Tools::file_get_contents('http://translations.prestashop.com/download/lang_packs/gzip/'.$lang_pack->version.'/'.Tools::strtolower($lang_pack->iso_code.'.gzip')))) { if (!@file_put_contents($file, $content)) { diff --git a/classes/Product.php b/classes/Product.php index ca3c683bb..1fff837fe 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -5776,7 +5776,7 @@ class ProductCore extends ObjectModel libxml_use_internal_errors(true); $xml = simplexml_load_string(utf8_decode($postData)); - $roomtypeData = Tools::jsonDecode(Tools::jsonEncode($xml), true); + $roomtypeData = json_decode(json_encode($xml), true); // set room map info for the hotel from request return Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'htl_room_type` (`id_product`, `id_hotel`, `adult`, `children`, `date_add`, `date_upd`) VALUES ('.(int)$this->id.', '.(int) $roomtypeData['room_type']['id_hotel'].', '.(int) $roomtypeData['room_type']['adults'].', '.(int) $roomtypeData['room_type']['children'].', \''.date('Y-m-d h:i:s').'\', \''.date('Y-m-d h:i:s').'\')'); diff --git a/classes/Referrer.php b/classes/Referrer.php index a37ee888c..ad38d84b2 100644 --- a/classes/Referrer.php +++ b/classes/Referrer.php @@ -349,6 +349,6 @@ class ReferrerCore extends ObjectModel 'percent_fee' => Tools::displayPrice($stats_sales['sales'] * $referrer->percent_fee / 100, $currency), ); - die('['.Tools::jsonEncode($json_array).']'); + die('['.json_encode($json_array).']'); } } diff --git a/classes/Tools.php b/classes/Tools.php index 22ddaf612..3e8b66dcc 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1066,7 +1066,7 @@ class ToolsCore echo ' '; } @@ -2660,19 +2660,15 @@ exit; /** * jsonDecode convert json string to php array / object * - * @param string $json + * @param string $data * @param bool $assoc (since 1.4.2.4) if true, convert to associativ array * @return array */ - public static function jsonDecode($json, $assoc = false) + public static function jsonDecode($data, $assoc = false, $depth = 512, $options = 0 + ) { - if (function_exists('json_decode')) { - return json_decode($json, $assoc); - } else { - include_once(_PS_TOOL_DIR_.'json/json.php'); - $pear_json = new Services_JSON(($assoc) ? SERVICES_JSON_LOOSE_TYPE : 0); - return $pear_json->decode($json); - } + Tools::displayAsDeprecated(); + return json_decode($data, $assoc, $depth, $options); } /** @@ -2681,15 +2677,15 @@ exit; * @param array $data * @return string json */ - public static function jsonEncode($data) + public static function jsonEncode($data, $options = 0, $depth = 512) { - if (function_exists('json_encode')) { - return json_encode($data); - } else { - include_once(_PS_TOOL_DIR_.'json/json.php'); - $pear_json = new Services_JSON(); - return $pear_json->encode($data); + Tools::displayAsDeprecated(); + if (PHP_VERSION_ID < 50500) { /* PHP version < 5.5.0 */ + return json_encode($data, $options); } + + return json_encode($data, $options, $depth); + } /** diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 6bc800a5f..650355110 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -1803,14 +1803,14 @@ class AdminControllerCore extends Controller } if ($conf = Tools::getValue('conf')) { - $this->context->smarty->assign('conf', $this->json ? Tools::jsonEncode($this->_conf[(int)$conf]) : $this->_conf[(int)$conf]); + $this->context->smarty->assign('conf', $this->json ? json_encode($this->_conf[(int)$conf]) : $this->_conf[(int)$conf]); } foreach (array('errors', 'warnings', 'informations', 'confirmations') as $type) { if (!is_array($this->$type)) { $this->$type = (array)$this->$type; } - $this->context->smarty->assign($type, $this->json ? Tools::jsonEncode(array_unique($this->$type)) : array_unique($this->$type)); + $this->context->smarty->assign($type, $this->json ? json_encode(array_unique($this->$type)) : array_unique($this->$type)); } if ($this->show_page_header_toolbar && !$this->lite_display) { @@ -1824,7 +1824,7 @@ class AdminControllerCore extends Controller $this->context->smarty->assign( array( - 'page' => $this->json ? Tools::jsonEncode($page) : $page, + 'page' => $this->json ? json_encode($page) : $page, 'header' => $this->context->smarty->fetch($header_tpl), 'footer' => $this->context->smarty->fetch($footer_tpl), ) diff --git a/classes/helper/HelperList.php b/classes/helper/HelperList.php index 0686a9dcf..c6e2dbcbb 100644 --- a/classes/helper/HelperList.php +++ b/classes/helper/HelperList.php @@ -435,7 +435,7 @@ class HelperListCore extends Helper 'token' => $token != null ? $token : $this->token, 'action' => self::$cache_lang['Details'], 'params' => $ajax_params, - 'json_params' => Tools::jsonEncode($ajax_params) + 'json_params' => json_encode($ajax_params) )); return $tpl->fetch(); } diff --git a/classes/pdf/HTMLTemplateInvoice.php b/classes/pdf/HTMLTemplateInvoice.php index 15a2eda93..11247097c 100644 --- a/classes/pdf/HTMLTemplateInvoice.php +++ b/classes/pdf/HTMLTemplateInvoice.php @@ -142,8 +142,8 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate */ public function getContent() { - $invoiceAddressPatternRules = Tools::jsonDecode(Configuration::get('PS_INVCE_INVOICE_ADDR_RULES'), true); - $deliveryAddressPatternRules = Tools::jsonDecode(Configuration::get('PS_INVCE_DELIVERY_ADDR_RULES'), true); + $invoiceAddressPatternRules = json_decode(Configuration::get('PS_INVCE_INVOICE_ADDR_RULES'), true); + $deliveryAddressPatternRules = json_decode(Configuration::get('PS_INVCE_DELIVERY_ADDR_RULES'), true); $invoice_address = new Address((int)$this->order->id_address_invoice); $country = new Country((int)$invoice_address->id_country); diff --git a/classes/tree/TreeToolbarSearch.php b/classes/tree/TreeToolbarSearch.php index 417023e50..edfb693cf 100644 --- a/classes/tree/TreeToolbarSearch.php +++ b/classes/tree/TreeToolbarSearch.php @@ -76,7 +76,7 @@ class TreeToolbarSearchCore extends TreeToolbarButtonCore implements $html = ''; foreach ($data as $item) { - $html .= Tools::jsonEncode($item).','; + $html .= json_encode($item).','; if (array_key_exists('children', $item) && !empty($item['children'])) { $html .= $this->_renderData($item['children']); } diff --git a/classes/tree/TreeToolbarSearchCategories.php b/classes/tree/TreeToolbarSearchCategories.php index 2a6f93d66..a00f387de 100644 --- a/classes/tree/TreeToolbarSearchCategories.php +++ b/classes/tree/TreeToolbarSearchCategories.php @@ -73,7 +73,7 @@ class TreeToolbarSearchCategoriesCore extends TreeToolbarButtonCore implements $html = ''; foreach ($data as $item) { - $html .= Tools::jsonEncode($item).','; + $html .= json_encode($item).','; if (array_key_exists('children', $item) && !empty($item['children'])) { $html .= $this->_renderData($item['children']); } diff --git a/controllers/admin/AdminAddressesController.php b/controllers/admin/AdminAddressesController.php index c57e24b1e..ce37b1743 100644 --- a/controllers/admin/AdminAddressesController.php +++ b/controllers/admin/AdminAddressesController.php @@ -495,7 +495,7 @@ class AdminAddressesControllerCore extends AdminController $customer = Customer::searchByName($email); if (!empty($customer)) { $customer = $customer['0']; - echo Tools::jsonEncode(array('infos' => pSQL($customer['firstname']).'_'.pSQL($customer['lastname']).'_'.pSQL($customer['company']))); + echo json_encode(array('infos' => pSQL($customer['firstname']).'_'.pSQL($customer['lastname']).'_'.pSQL($customer['company']))); } } die; diff --git a/controllers/admin/AdminAttributesGroupsController.php b/controllers/admin/AdminAttributesGroupsController.php index 19e8c55c0..c47cb31e3 100644 --- a/controllers/admin/AdminAttributesGroupsController.php +++ b/controllers/admin/AdminAttributesGroupsController.php @@ -297,7 +297,7 @@ class AdminAttributesGroupsControllerCore extends AdminController $associations = array(); } - $this->fields_form['shop_associations'] = Tools::jsonEncode($associations); + $this->fields_form['shop_associations'] = json_encode($associations); $this->fields_form['input'][] = array( 'type' => 'color', diff --git a/controllers/admin/AdminCarrierWizardController.php b/controllers/admin/AdminCarrierWizardController.php index e5057a4ec..c00efd707 100644 --- a/controllers/admin/AdminCarrierWizardController.php +++ b/controllers/admin/AdminCarrierWizardController.php @@ -652,7 +652,7 @@ class AdminCarrierWizardControllerCore extends AdminController $return['errors'] = $this->errors; } if (count($this->errors) || $die) { - die(Tools::jsonEncode($return)); + die(json_encode($return)); } } @@ -870,7 +870,7 @@ class AdminCarrierWizardControllerCore extends AdminController $return['id_carrier'] = $carrier->id; } } - die(Tools::jsonEncode($return)); + die(json_encode($return)); } protected function changeGroups($id_carrier, $delete = true) diff --git a/controllers/admin/AdminCartRulesController.php b/controllers/admin/AdminCartRulesController.php index 9dccbb5db..87509df72 100644 --- a/controllers/admin/AdminCartRulesController.php +++ b/controllers/admin/AdminCartRulesController.php @@ -140,7 +140,7 @@ class AdminCartRulesControllerCore extends AdminController } } } - echo Tools::jsonEncode(array('html' => $html, 'next_link' => $next_link)); + echo json_encode(array('html' => $html, 'next_link' => $next_link)); } public function setMedia() @@ -589,7 +589,7 @@ class AdminCartRulesControllerCore extends AdminController ) ORDER BY c.`firstname`, c.`lastname` ASC LIMIT 50'); - die(Tools::jsonEncode($customers)); + die(json_encode($customers)); } // Both product filter (free product and product discount) search for products if (Tools::isSubmit('giftProductFilter') || Tools::isSubmit('reductionProductFilter')) { @@ -599,7 +599,7 @@ class AdminCartRulesControllerCore extends AdminController $products, $this->context->employee->id_profile ); - die(Tools::jsonEncode($products)); + die(json_encode($products)); } } @@ -642,7 +642,7 @@ class AdminCartRulesControllerCore extends AdminController public function ajaxProcessSearchProducts() { $array = $this->searchProducts(Tools::getValue('product_search')); - $this->content = trim(Tools::jsonEncode($array)); + $this->content = trim(json_encode($array)); } public function renderForm() @@ -771,6 +771,6 @@ class AdminCartRulesControllerCore extends AdminController if ($vouchers = CartRule::getCartsRuleByCode(Tools::getValue('q'), (int)$this->context->language->id, true)) { $found = true; } - echo Tools::jsonEncode(array('found' => $found, 'vouchers' => $vouchers)); + echo json_encode(array('found' => $found, 'vouchers' => $vouchers)); } } diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index cea2b24b6..ebd03b7a4 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -403,10 +403,10 @@ class AdminCartsControllerCore extends AdminController $errors[] = Tools::displayError('Invalid combination'); } if (count($errors)) { - die(Tools::jsonEncode($errors)); + die(json_encode($errors)); } if ($this->context->cart->deleteProduct($id_product, $id_product_attribute, (int)Tools::getValue('id_customization'))) { - echo Tools::jsonEncode($this->ajaxReturnVars()); + echo json_encode($this->ajaxReturnVars()); } } } @@ -520,7 +520,7 @@ class AdminCartsControllerCore extends AdminController } } - echo Tools::jsonEncode(array_merge($this->ajaxReturnVars(), array('errors' => $errors))); + echo json_encode(array_merge($this->ajaxReturnVars(), array('errors' => $errors))); } } @@ -541,7 +541,7 @@ class AdminCartsControllerCore extends AdminController $this->context->cart->gift_message = $gift_message; } $this->context->cart->save(); - echo Tools::jsonEncode($this->ajaxReturnVars()); + echo json_encode($this->ajaxReturnVars()); } } @@ -563,7 +563,7 @@ class AdminCartsControllerCore extends AdminController } elseif (Validate::isLoadedObject($message)) { $message->delete(); } - echo Tools::jsonEncode($this->ajaxReturnVars()); + echo json_encode($this->ajaxReturnVars()); } } @@ -593,7 +593,7 @@ class AdminCartsControllerCore extends AdminController $result = $this->ajaxReturnVars(); $result['cart_detail_html'] = $cart_dtl_tpl;//tpl is added to the returned array - echo Tools::jsonEncode($result); + echo json_encode($result); } } public function ajaxProcessUpdateLang() @@ -604,7 +604,7 @@ class AdminCartsControllerCore extends AdminController $this->context->cart->id_lang = (int)$lang->id; $this->context->cart->save(); } - echo Tools::jsonEncode($this->ajaxReturnVars()); + echo json_encode($this->ajaxReturnVars()); } } @@ -623,7 +623,7 @@ class AdminCartsControllerCore extends AdminController $errors[] = Tools::displayError('The order cannot be renewed.'); } else { $this->context->cart = $new_cart['cart']; - echo Tools::jsonEncode($this->ajaxReturnVars()); + echo json_encode($this->ajaxReturnVars()); } } } @@ -632,7 +632,7 @@ class AdminCartsControllerCore extends AdminController { if ($this->tabAccess['edit'] === '1') { if ($this->context->cart->removeCartRule((int)Tools::getValue('id_cart_rule'))) { - echo Tools::jsonEncode($this->ajaxReturnVars()); + echo json_encode($this->ajaxReturnVars()); } } } @@ -663,7 +663,7 @@ class AdminCartsControllerCore extends AdminController $this->context->cart->addCartRule((int)$cart_rule->id); } - echo Tools::jsonEncode($this->ajaxReturnVars()); + echo json_encode($this->ajaxReturnVars()); } } @@ -681,14 +681,14 @@ class AdminCartsControllerCore extends AdminController $errors[] = Tools::displayError('Can\'t add the voucher.'); } } - echo Tools::jsonEncode(array_merge($this->ajaxReturnVars(), array('errors' => $errors))); + echo json_encode(array_merge($this->ajaxReturnVars(), array('errors' => $errors))); } } public function ajaxProcessUpdateAddress() { if ($this->tabAccess['edit'] === '1') { - echo Tools::jsonEncode(array('addresses' => $this->context->customer->getAddresses((int)$this->context->cart->id_lang))); + echo json_encode(array('addresses' => $this->context->customer->getAddresses((int)$this->context->cart->id_lang))); } } @@ -709,7 +709,7 @@ class AdminCartsControllerCore extends AdminController /*$this->context->cart->id_address_invoice = (int)$address_invoice->id;*/ $this->context->cart->save(); - echo Tools::jsonEncode($this->ajaxReturnVars()); + echo json_encode($this->ajaxReturnVars()); } } @@ -825,7 +825,7 @@ class AdminCartsControllerCore extends AdminController $to_return = array_merge($this->ajaxReturnVars(), array('found' => false)); } - echo Tools::jsonEncode($to_return); + echo json_encode($to_return); } public function ajaxReturnVars() @@ -879,7 +879,7 @@ class AdminCartsControllerCore extends AdminController public function displayAjaxGetSummary() { - echo Tools::jsonEncode($this->ajaxReturnVars()); + echo json_encode($this->ajaxReturnVars()); } public function ajaxProcessUpdateProductPrice() @@ -903,7 +903,7 @@ class AdminCartsControllerCore extends AdminController $specific_price->from = '0000-00-00 00:00:00'; $specific_price->to = '0000-00-00 00:00:00'; $specific_price->add(); - echo Tools::jsonEncode($this->ajaxReturnVars()); + echo json_encode($this->ajaxReturnVars()); } } diff --git a/controllers/admin/AdminCategoriesController.php b/controllers/admin/AdminCategoriesController.php index 999f85bf8..4d8d9c922 100644 --- a/controllers/admin/AdminCategoriesController.php +++ b/controllers/admin/AdminCategoriesController.php @@ -961,14 +961,14 @@ class AdminCategoriesControllerCore extends AdminController public function ajaxProcessStatusCategory() { if (!$id_category = (int)Tools::getValue('id_category')) { - die(Tools::jsonEncode(array('success' => false, 'error' => true, 'text' => $this->l('Failed to update the status')))); + die(json_encode(array('success' => false, 'error' => true, 'text' => $this->l('Failed to update the status')))); } else { $category = new Category((int)$id_category); if (Validate::isLoadedObject($category)) { $category->active = $category->active == 1 ? 0 : 1; $category->save() ? - die(Tools::jsonEncode(array('success' => true, 'text' => $this->l('The status has been updated successfully')))) : - die(Tools::jsonEncode(array('success' => false, 'error' => true, 'text' => $this->l('Failed to update the status')))); + die(json_encode(array('success' => true, 'text' => $this->l('The status has been updated successfully')))) : + die(json_encode(array('success' => false, 'error' => true, 'text' => $this->l('Failed to update the status')))); } } } diff --git a/controllers/admin/AdminCustomerThreadsController.php b/controllers/admin/AdminCustomerThreadsController.php index 53689d797..fa01f8cbc 100644 --- a/controllers/admin/AdminCustomerThreadsController.php +++ b/controllers/admin/AdminCustomerThreadsController.php @@ -896,7 +896,7 @@ class AdminCustomerThreadsControllerCore extends AdminController } if (Tools::isSubmit('syncImapMail')) { - die(Tools::jsonEncode($this->syncImap())); + die(json_encode($this->syncImap())); } } diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index 1721be4c5..3150be406 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -1104,7 +1104,7 @@ class AdminCustomersControllerCore extends AdminController $to_return = array('found' => false); } - $this->content = Tools::jsonEncode($to_return); + $this->content = json_encode($to_return); } /** diff --git a/controllers/admin/AdminDashboardController.php b/controllers/admin/AdminDashboardController.php index 00a845e0f..ebb22ce89 100644 --- a/controllers/admin/AdminDashboardController.php +++ b/controllers/admin/AdminDashboardController.php @@ -370,7 +370,7 @@ class AdminDashboardControllerCore extends AdminController 'extra' => (int)Tools::getValue('extra') ); - die(Tools::jsonEncode(Hook::exec('dashboardData', $params, $id_module, true, true, (int)Tools::getValue('dashboard_use_push')))); + die(json_encode(Hook::exec('dashboardData', $params, $id_module, true, true, (int)Tools::getValue('dashboard_use_push')))); } public function ajaxProcessSetSimulationMode() @@ -437,7 +437,7 @@ class AdminDashboardControllerCore extends AdminController } } } - die(Tools::jsonEncode($return)); + die(json_encode($return)); } public function ajaxProcessSaveDashConfig() @@ -475,6 +475,6 @@ class AdminDashboardControllerCore extends AdminController $return['widget_html'] = $module_obj->$hook($params); } - die(Tools::jsonEncode($return)); + die(json_encode($return)); } } diff --git a/controllers/admin/AdminEmployeesController.php b/controllers/admin/AdminEmployeesController.php index 6453095b7..44ab21028 100644 --- a/controllers/admin/AdminEmployeesController.php +++ b/controllers/admin/AdminEmployeesController.php @@ -673,6 +673,6 @@ class AdminEmployeesControllerCore extends AdminController } } } - die(Tools::jsonEncode($this->tabs_list)); + die(json_encode($this->tabs_list)); } } diff --git a/controllers/admin/AdminGroupsController.php b/controllers/admin/AdminGroupsController.php index 72353abde..6762d8f18 100644 --- a/controllers/admin/AdminGroupsController.php +++ b/controllers/admin/AdminGroupsController.php @@ -451,7 +451,7 @@ class AdminGroupsControllerCore extends AdminController $result['discount'] = $category_reduction; $result['hasError'] = false; } - die(Tools::jsonEncode($result)); + die(json_encode($result)); } /** diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index d576bd55b..77cc49d2d 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -665,7 +665,7 @@ class AdminImportControllerCore extends AdminController $_FILES['file']['filename'] = $filename_prefix.str_replace('\0', '', $_FILES['file']['name']); } - die(Tools::jsonEncode($_FILES)); + die(json_encode($_FILES)); } public function renderView() diff --git a/controllers/admin/AdminInformationController.php b/controllers/admin/AdminInformationController.php index e740a895f..cf96c1f69 100644 --- a/controllers/admin/AdminInformationController.php +++ b/controllers/admin/AdminInformationController.php @@ -169,11 +169,11 @@ class AdminInformationControllerCore extends AdminController $this->file_list = array('missing' => array(), 'updated' => array()); $xml = @simplexml_load_file(_PS_API_URL_.'/xml/md5/'._PS_VERSION_.'.xml'); if (!$xml || !isset($xml->ps_root_dir[0])) { - die(Tools::jsonEncode($this->file_list)); + die(json_encode($this->file_list)); } $this->getListOfUpdatedFiles($xml->ps_root_dir[0]); - die(Tools::jsonEncode($this->file_list)); + die(json_encode($this->file_list)); } public function getListOfUpdatedFiles(SimpleXMLElement $dir, $path = '') diff --git a/controllers/admin/AdminLanguagesController.php b/controllers/admin/AdminLanguagesController.php index 8702fef19..56fca56ad 100644 --- a/controllers/admin/AdminLanguagesController.php +++ b/controllers/admin/AdminLanguagesController.php @@ -543,7 +543,7 @@ class AdminLanguagesControllerCore extends AdminController // Get all iso code available if ($lang_packs = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='.Tools::getValue('ps_version').'&iso_lang='.Tools::strtolower(Tools::getValue('iso_lang')))) { - $result = Tools::jsonDecode($lang_packs); + $result = json_decode($lang_packs); if ($lang_packs !== '' && $result && !isset($result->error)) { $this->status = 'ok'; $this->content = $lang_packs; diff --git a/controllers/admin/AdminLoginController.php b/controllers/admin/AdminLoginController.php index 1172dab94..4daeaadf0 100644 --- a/controllers/admin/AdminLoginController.php +++ b/controllers/admin/AdminLoginController.php @@ -219,14 +219,14 @@ class AdminLoginControllerCore extends AdminController } if (Tools::isSubmit('ajax')) { - die(Tools::jsonEncode(array('hasErrors' => false, 'redirect' => $url))); + die(json_encode(array('hasErrors' => false, 'redirect' => $url))); } else { $this->redirect_after = $url; } } } if (Tools::isSubmit('ajax')) { - die(Tools::jsonEncode(array('hasErrors' => true, 'errors' => $this->errors))); + die(json_encode(array('hasErrors' => true, 'errors' => $this->errors))); } } @@ -270,19 +270,19 @@ class AdminLoginControllerCore extends AdminController if (!$result) { $this->errors[] = Tools::displayError('An error occurred while attempting to change your password.'); } else { - die(Tools::jsonEncode(array( + die(json_encode(array( 'hasErrors' => false, 'confirm' => $this->l('Your password has been emailed to you.', 'AdminTab', false, false) ))); } } else { - die(Tools::jsonEncode(array( + die(json_encode(array( 'hasErrors' => true, 'errors' => array(Tools::displayError('An error occurred while attempting to change your password.')) ))); } } elseif (Tools::isSubmit('ajax')) { - die(Tools::jsonEncode(array('hasErrors' => true, 'errors' => $this->errors))); + die(json_encode(array('hasErrors' => true, 'errors' => $this->errors))); } } } diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php index 395bf377f..655daa744 100644 --- a/controllers/admin/AdminModulesController.php +++ b/controllers/admin/AdminModulesController.php @@ -218,7 +218,7 @@ class AdminModulesControllerCore extends AdminController public function displayAjaxRefreshModuleList() { - echo Tools::jsonEncode(array('status' => $this->status)); + echo json_encode(array('status' => $this->status)); } @@ -1091,7 +1091,7 @@ class AdminModulesControllerCore extends AdminController // Get the list of installed module ans prepare it for ajax call. if (($list = Tools::getValue('installed_modules'))) { - Context::getContext()->smarty->assign('installed_modules', Tools::jsonEncode(explode('|', $list))); + Context::getContext()->smarty->assign('installed_modules', json_encode(explode('|', $list))); } // If redirect parameter is present and module already installed, we redirect on configuration module page @@ -1532,7 +1532,7 @@ class AdminModulesControllerCore extends AdminController } // AutoComplete array - $autocomplete_list .= Tools::jsonEncode(array( + $autocomplete_list .= json_encode(array( 'displayName' => (string)$module->displayName, 'desc' => (string)$module->description, 'name' => (string)$module->name, diff --git a/controllers/admin/AdminModulesPositionsController.php b/controllers/admin/AdminModulesPositionsController.php index be5266f61..cf6f52b82 100644 --- a/controllers/admin/AdminModulesPositionsController.php +++ b/controllers/admin/AdminModulesPositionsController.php @@ -552,7 +552,7 @@ class AdminModulesPositionsControllerCore extends AdminController } } $hookableList['hasError'] = false; - die(Tools::jsonEncode($hookableList)); + die(json_encode($hookableList)); } } @@ -582,7 +582,7 @@ class AdminModulesPositionsControllerCore extends AdminController } } } - die(Tools::jsonEncode($hookableModulesList)); + die(json_encode($hookableModulesList)); } } public function ajaxProcessSaveHook() diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index bac43229c..f54b27a73 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1715,7 +1715,7 @@ class AdminOrdersControllerCore extends AdminController $to_return = array('found' => false); } - $this->content = Tools::jsonEncode($to_return); + $this->content = json_encode($to_return); } public function ajaxProcessSendMailValidateOrder() @@ -1745,11 +1745,11 @@ class AdminOrdersControllerCore extends AdminController true, $cart->id_shop )) { - die(Tools::jsonEncode(array('errors' => false, 'result' => $this->l('The email was sent to your customer.')))); + die(json_encode(array('errors' => false, 'result' => $this->l('The email was sent to your customer.')))); } } } - $this->content = Tools::jsonEncode(array('errors' => true, 'result' => $this->l('Error in sending the email to your customer.'))); + $this->content = json_encode(array('errors' => true, 'result' => $this->l('Error in sending the email to your customer.'))); } } @@ -1759,7 +1759,7 @@ class AdminOrdersControllerCore extends AdminController $id_order = (int) Tools::getValue('id_order'); $order = new Order($id_order); if (!Validate::isLoadedObject($order)) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('The order object cannot be loaded.') ))); @@ -1768,7 +1768,7 @@ class AdminOrdersControllerCore extends AdminController $old_cart_rules = Context::getContext()->cart->getCartRules(); if ($order->hasBeenShipped()) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('You cannot add products to delivered orders. ') ))); @@ -1782,37 +1782,37 @@ class AdminOrdersControllerCore extends AdminController $curr_date = date('Y-m-d'); /*Validations*/ if ($date_from == '') { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Please Enter Check In Date.'), ))); } elseif (!Validate::isDateFormat($date_from)) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Please Enter a Valid Check In Date.'), ))); } elseif ($date_to == '') { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Please Enter Check Out Date.'), ))); } elseif (!Validate::isDateFormat($date_to)) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Please Enter a valid Check out Date.'), ))); } elseif ($date_from < $curr_date) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Check In date should not be date before current date.'), ))); } elseif ($date_to <= $date_from) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Check out Date Should be after Check In date.'), ))); } elseif (!Validate::isUnsignedInt($product_informations['product_quantity'])) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Please Enter a valid Quantity.'), ))); @@ -1836,19 +1836,19 @@ class AdminOrdersControllerCore extends AdminController $total_available_rooms = $hotel_room_data['stats']['num_avail']; if ($total_available_rooms < $req_rm) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Required number of rooms are not available.'), ))); } } else { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Some error occured Please try again.'), ))); } } else { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Some error occured Please try again.'), ))); @@ -1865,7 +1865,7 @@ class AdminOrdersControllerCore extends AdminController $idProduct = $product_informations['product_id']; $product = new Product($idProduct, false, $order->id_lang); if (!Validate::isLoadedObject($product)) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('The product object cannot be loaded.') ))); @@ -1874,7 +1874,7 @@ class AdminOrdersControllerCore extends AdminController if (isset($product_informations['product_attribute_id']) && $product_informations['product_attribute_id']) { $combination = new Combination($product_informations['product_attribute_id']); if (!Validate::isLoadedObject($combination)) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('The combination object cannot be loaded.') ))); @@ -1986,9 +1986,9 @@ class AdminOrdersControllerCore extends AdminController if ($update_quantity < 0) { // If product has attribute, minimal quantity is set with minimal quantity of attribute $minimal_quantity = ($product_informations['product_attribute_id']) ? Attribute::getAttributeMinimalQty($product_informations['product_attribute_id']) : $product->minimal_quantity; - die(Tools::jsonEncode(array('error' => sprintf(Tools::displayError('You must add %d minimum quantity', false), $minimal_quantity)))); + die(json_encode(array('error' => sprintf(Tools::displayError('You must add %d minimum quantity', false), $minimal_quantity)))); } elseif (!$update_quantity) { - die(Tools::jsonEncode(array('error' => Tools::displayError('You already have the maximum quantity available for this product.', false)))); + die(json_encode(array('error' => Tools::displayError('You already have the maximum quantity available for this product.', false)))); } // If order is valid, we can create a new invoice or edit an existing invoice @@ -2264,7 +2264,7 @@ class AdminOrdersControllerCore extends AdminController } } - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => true, //'view' => $this->createTemplate('_product_line.tpl')->fetch(), 'can_edit' => $this->tabAccess['add'], @@ -2290,7 +2290,7 @@ class AdminOrdersControllerCore extends AdminController { // $order_detail = new OrderDetail(Tools::getValue('id_order_detail')); // if (!Validate::isLoadedObject($order_detail)) - // die(Tools::jsonEncode(array( + // die(json_encode(array( // 'result' => false, // 'error' => Tools::displayError('The OrderDetail object cannot be loaded.') // ))); @@ -2298,7 +2298,7 @@ class AdminOrdersControllerCore extends AdminController $id_product = Tools::getValue('id_product'); $product = new Product($id_product); if (!Validate::isLoadedObject($product)) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('The product object cannot be loaded.') ))); @@ -2306,13 +2306,13 @@ class AdminOrdersControllerCore extends AdminController $address = new Address(Tools::getValue('id_address')); if (!Validate::isLoadedObject($address)) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('The address object cannot be loaded.') ))); } - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => true, 'product' => $product, 'tax_rate' => $product->getTaxesRate($address), @@ -2354,47 +2354,47 @@ class AdminOrdersControllerCore extends AdminController $qty_diff = $product_quantity - $old_product_quantity; /*By webkul to validate fields before deleting the cart and order data form the tables*/ if ($id_hotel == '') { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Hotel Id is mising.'), ))); } elseif ($id_room == '') { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Room Id is missing.'), ))); } elseif ($new_date_from == '') { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Please Enter Check In Date.'), ))); } elseif (!Validate::isDateFormat($new_date_from)) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Please Enter a Valid Check In Date.'), ))); } elseif ($new_date_to == '') { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Please Enter Check Out Date.'), ))); } elseif (!Validate::isDateFormat($new_date_to)) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Please Enter a valid Check out Date.'), ))); } elseif ($new_date_from < $curr_date) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Check In date should not be after current date.'), ))); } elseif ($new_date_to <= $new_date_from) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Check out Date Should be after Check In date.'), ))); } elseif (!Validate::isUnsignedInt($product_quantity)) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Invalid quantity.'), ))); @@ -2402,7 +2402,7 @@ class AdminOrdersControllerCore extends AdminController $rooms_booked = $obj_booking_detail->getRoomBookinInformationForDateRangeByOrder($id_room, $old_date_from, $old_date_to, $new_date_from, $new_date_to); if ($rooms_booked) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('This Room Unavailable For Selected Duration.'), ))); @@ -2580,7 +2580,7 @@ class AdminOrdersControllerCore extends AdminController )); if (!$res) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => $res, 'error' => Tools::displayError('An error occurred while editing the product line.') ))); @@ -2597,7 +2597,7 @@ class AdminOrdersControllerCore extends AdminController $this->sendChangedNotification($order); - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => $res, 'view' => $view, 'can_edit' => $this->tabAccess['add'], @@ -2627,32 +2627,32 @@ class AdminOrdersControllerCore extends AdminController $product_quantity = (int) $obj_booking_detail->getNumberOfDays($date_from, $date_to); /*By webkul to validate fields before deleting the cart and order data form the tables*/ if ($id_hotel == '') { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Hotel Id is mising.'), ))); } elseif ($id_room == '') { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Room Id is missing.'), ))); } elseif ($date_from == '') { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Check In Date is missing.'), ))); } elseif ($date_to == '') { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Check Out Date is missing.'), ))); } elseif ($date_to == '') { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Check Out Date is missing.'), ))); } elseif (!Validate::isUnsignedInt($product_quantity)) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Invalid quantity.'), ))); @@ -2757,7 +2757,7 @@ class AdminOrdersControllerCore extends AdminController } if (!$res) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => $res, 'error' => Tools::displayError('An error occurred while attempting to delete the product line.') ))); @@ -2795,7 +2795,7 @@ class AdminOrdersControllerCore extends AdminController $this->sendChangedNotification($order); - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => $res, 'order' => $order, 'invoices' => $invoice_array, @@ -2807,28 +2807,28 @@ class AdminOrdersControllerCore extends AdminController protected function doEditProductValidation(OrderDetail $order_detail, Order $order, OrderInvoice $order_invoice = null) { if (!Validate::isLoadedObject($order_detail)) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('The Order Detail object could not be loaded.') ))); } if (!empty($order_invoice) && !Validate::isLoadedObject($order_invoice)) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('The invoice object cannot be loaded.') ))); } if (!Validate::isLoadedObject($order)) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('The order object cannot be loaded.') ))); } if ($order_detail->id_order != $order->id) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('You cannot edit the order detail for this order.') ))); @@ -2836,14 +2836,14 @@ class AdminOrdersControllerCore extends AdminController // We can't edit a delivered order if ($order->hasBeenDelivered()) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('You cannot edit a delivered order.') ))); } if (!empty($order_invoice) && $order_invoice->id_order != Tools::getValue('id_order')) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('You cannot use this invoice for the order') ))); @@ -2854,21 +2854,21 @@ class AdminOrdersControllerCore extends AdminController $product_price_tax_excl = str_replace(',', '.', Tools::getValue('product_price_tax_excl')); if (!Validate::isPrice($product_price_tax_incl) || !Validate::isPrice($product_price_tax_excl)) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Invalid price') ))); } //commented by webkul here quantity is gap between booking days which is calulated and validated in ajaxProcessEditProductOnOrder(); /*if (!is_array(Tools::getValue('product_quantity')) && !Validate::isUnsignedInt(Tools::getValue('product_quantity'))) - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Invalid quantity') ))); elseif (is_array(Tools::getValue('product_quantity'))) foreach (Tools::getValue('product_quantity') as $qty) if (!Validate::isUnsignedInt($qty)) - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Invalid quantity') )));*/ @@ -2877,21 +2877,21 @@ class AdminOrdersControllerCore extends AdminController protected function doDeleteProductLineValidation(OrderDetail $order_detail, Order $order) { if (!Validate::isLoadedObject($order_detail)) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('The Order Detail object could not be loaded.') ))); } if (!Validate::isLoadedObject($order)) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('The order object cannot be loaded.') ))); } if ($order_detail->id_order != $order->id) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('You cannot delete the order detail.') ))); @@ -2899,7 +2899,7 @@ class AdminOrdersControllerCore extends AdminController // We can't edit a delivered order if ($order->hasBeenDelivered()) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('You cannot edit a delivered order.') ))); @@ -2916,13 +2916,13 @@ class AdminOrdersControllerCore extends AdminController $StockAvailable = StockAvailable::getQuantityAvailableByProduct($order_detail->product_id, $order_detail->product_attribute_id, $order_detail->id_shop); $product = new Product($order_detail->product_id, true, null, $order_detail->id_shop); if (!Validate::isLoadedObject($product)) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('The Product object could not be loaded.') ))); } else { if (($StockAvailable < $add_quantity) && (!$product->isAvailableWhenOutOfStock((int)$product->out_of_stock))) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => false, 'error' => Tools::displayError('This product is no longer in stock with those attributes ') ))); @@ -3074,7 +3074,7 @@ class AdminOrdersControllerCore extends AdminController $authorized_modules = array(); if (!Validate::isLoadedObject($customer) || !is_array($modules)) { - die(Tools::jsonEncode(array('result' => false))); + die(json_encode(array('result' => false))); } foreach ($modules as $module) { @@ -3093,7 +3093,7 @@ class AdminOrdersControllerCore extends AdminController 'payment_modules' => $payment_modules, )); - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => true, 'view' => $this->createTemplate('_select_payment.tpl')->fetch(), ))); @@ -3128,7 +3128,7 @@ class AdminOrdersControllerCore extends AdminController $result['status'] = 'failed'; } - die(Tools::jsonEncode($result)); + die(json_encode($result)); } // To show rooms extra demands in the modal box in order details view page @@ -3238,8 +3238,8 @@ class AdminOrdersControllerCore extends AdminController if ($idCartBooking = Tools::getValue('id_cart_booking')) { if (Validate::isLoadedObject($objCartbookingCata = new HotelCartBookingData($idCartBooking))) { $roomDemands = Tools::getValue('room_demands'); - $roomDemands = Tools::jsonDecode($roomDemands, true); - $roomDemands = Tools::jsonEncode($roomDemands); + $roomDemands = json_decode($roomDemands, true); + $roomDemands = json_encode($roomDemands); $objCartbookingCata->extra_demands = $roomDemands; if ($objCartbookingCata->save()) { die('1'); @@ -3255,7 +3255,7 @@ class AdminOrdersControllerCore extends AdminController if ($idHtlBooking = Tools::getValue('id_htl_booking')) { if (Validate::isLoadedObject($objBookingDetail = new HotelBookingDetail($idHtlBooking))) { $roomDemands = Tools::getValue('room_demands'); - if ($roomDemands = Tools::jsonDecode($roomDemands, true)) { + if ($roomDemands = json_decode($roomDemands, true)) { $order = new Order($objBookingDetail->id_order); $vatAddress = new Address((int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); $idLang = (int)$order->id_lang; diff --git a/controllers/admin/AdminPerformanceController.php b/controllers/admin/AdminPerformanceController.php index 5f2e4f9b7..3e5976b34 100644 --- a/controllers/admin/AdminPerformanceController.php +++ b/controllers/admin/AdminPerformanceController.php @@ -1014,7 +1014,7 @@ class AdminPerformanceControllerCore extends AdminController $res = @memcache_get_server_status($memcache, $host, $port); } } - die(Tools::jsonEncode(array($res))); + die(json_encode(array($res))); } } die; diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 35879aea7..fc20ec176 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -600,7 +600,7 @@ class AdminProductsControllerCore extends AdminController public function ajaxProcessAddAttachment() { if ($this->tabAccess['edit'] === '0') { - return die(Tools::jsonEncode(array('error' => $this->l('You do not have the right permission')))); + return die(json_encode(array('error' => $this->l('You do not have the right permission')))); } if (isset($_FILES['attachment_file'])) { if ((int)$_FILES['attachment_file']['error'] === 1) { @@ -720,7 +720,7 @@ class AdminProductsControllerCore extends AdminController } } - die(Tools::jsonEncode($_FILES)); + die(json_encode($_FILES)); } } @@ -1296,7 +1296,7 @@ class AdminProductsControllerCore extends AdminController ); } - die(Tools::jsonEncode($json)); + die(json_encode($json)); } public function processSpecificPricePriorities() @@ -1632,7 +1632,7 @@ class AdminProductsControllerCore extends AdminController ); } - die(Tools::jsonEncode($json)); + die(json_encode($json)); } public function ajaxProcessDefaultProductAttribute() @@ -1656,7 +1656,7 @@ class AdminProductsControllerCore extends AdminController ); } - die(Tools::jsonEncode($json)); + die(json_encode($json)); } } @@ -1671,7 +1671,7 @@ class AdminProductsControllerCore extends AdminController $combinations[$key]['attributes'][] = array($combination['group_name'], $combination['attribute_name'], $combination['id_attribute']); } - die(Tools::jsonEncode($combinations)); + die(json_encode($combinations)); } } } @@ -1732,13 +1732,13 @@ class AdminProductsControllerCore extends AdminController public function ajaxProcessUpdateImagePosition() { if ($this->tabAccess['edit'] === '0') { - return die(Tools::jsonEncode(array('error' => $this->l('You do not have the right permission')))); + return die(json_encode(array('error' => $this->l('You do not have the right permission')))); } $res = false; if ($json = Tools::getValue('json')) { $res = true; $json = stripslashes($json); - $images = Tools::jsonDecode($json, true); + $images = json_decode($json, true); foreach ($images as $id => $position) { $img = new Image((int)$id); $img->position = (int)$position; @@ -1755,7 +1755,7 @@ class AdminProductsControllerCore extends AdminController public function ajaxProcessUpdateCover() { if ($this->tabAccess['edit'] === '0') { - return die(Tools::jsonEncode(array('error' => $this->l('You do not have the right permission')))); + return die(json_encode(array('error' => $this->l('You do not have the right permission')))); } Image::deleteCover((int)Tools::getValue('id_product')); $img = new Image((int)Tools::getValue('id_image')); @@ -2742,7 +2742,7 @@ class AdminProductsControllerCore extends AdminController if ($manufacturers) { foreach ($manufacturers as $manufacturer) { $tmp = array("optionValue" => $manufacturer['id_manufacturer'], "optionDisplay" => htmlspecialchars(trim($manufacturer['name']))); - $jsonArray[] = Tools::jsonEncode($tmp); + $jsonArray[] = json_encode($tmp); } } @@ -2965,7 +2965,7 @@ class AdminProductsControllerCore extends AdminController $this->tpl_form_vars['token'] = $this->token; $this->tpl_form_vars['combinationImagesJs'] = $this->getCombinationImagesJs(); $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int)Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'); - $this->tpl_form_vars['post_data'] = Tools::jsonEncode($_POST); + $this->tpl_form_vars['post_data'] = json_encode($_POST); $this->tpl_form_vars['save_error'] = !empty($this->errors); $this->tpl_form_vars['mod_evasive'] = Tools::apacheModExists('evasive'); $this->tpl_form_vars['mod_security'] = Tools::apacheModExists('security'); @@ -3339,7 +3339,7 @@ class AdminProductsControllerCore extends AdminController foreach ($hotelRoomInfo as &$room) { if ($room['id_status'] == 3) { $disabledDates = $objRoomDisableDates->getRoomDisableDates($room['id']); - $room['disabled_dates_json'] = Tools::jsonEncode($disabledDates); + $room['disabled_dates_json'] = json_encode($disabledDates); } } $data->assign('htl_room_info', $hotelRoomInfo); @@ -3492,7 +3492,7 @@ class AdminProductsControllerCore extends AdminController $disableDtsArr = array(); foreach ($room_status as $key => $status) { if ($status == 3) { - $disableDtsArr[$key] = Tools::jsonDecode($disable_dates[$key], true); + $disableDtsArr[$key] = json_decode($disable_dates[$key], true); $this->validateDisableDateRanges($disableDtsArr[$key]); } } @@ -3714,7 +3714,7 @@ class AdminProductsControllerCore extends AdminController } if ($booking_calendar_data) { - die(Tools::jsonEncode($booking_calendar_data)); + die(json_encode($booking_calendar_data)); } else { die(0); } @@ -4793,7 +4793,7 @@ class AdminProductsControllerCore extends AdminController } } - die(Tools::jsonEncode(array($image_uploader->getName() => $files))); + die(json_encode(array($image_uploader->getName() => $files))); } /** @@ -5421,28 +5421,28 @@ class AdminProductsControllerCore extends AdminController public function ajaxProcessProductQuantity() { if ($this->tabAccess['edit'] === '0') { - return die(Tools::jsonEncode(array('error' => $this->l('You do not have the right permission')))); + return die(json_encode(array('error' => $this->l('You do not have the right permission')))); } if (!Tools::getValue('actionQty')) { - return Tools::jsonEncode(array('error' => $this->l('Undefined action'))); + return json_encode(array('error' => $this->l('Undefined action'))); } $product = new Product((int)Tools::getValue('id_product'), true); switch (Tools::getValue('actionQty')) { case 'depends_on_stock': if (Tools::getValue('value') === false) { - die(Tools::jsonEncode(array('error' => $this->l('Undefined value')))); + die(json_encode(array('error' => $this->l('Undefined value')))); } if ((int)Tools::getValue('value') != 0 && (int)Tools::getValue('value') != 1) { - die(Tools::jsonEncode(array('error' => $this->l('Incorrect value')))); + die(json_encode(array('error' => $this->l('Incorrect value')))); } if (!$product->advanced_stock_management && (int)Tools::getValue('value') == 1) { - die(Tools::jsonEncode(array('error' => $this->l('Not possible if advanced stock management is disabled. ')))); + die(json_encode(array('error' => $this->l('Not possible if advanced stock management is disabled. ')))); } if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && (int)Tools::getValue('value') == 1 && (Pack::isPack($product->id) && !Pack::allUsesAdvancedStockManagement($product->id) && ($product->pack_stock_type == 2 || $product->pack_stock_type == 1 || ($product->pack_stock_type == 3 && (Configuration::get('PS_PACK_STOCK_TYPE') == 1 || Configuration::get('PS_PACK_STOCK_TYPE') == 2))))) { - die(Tools::jsonEncode(array('error' => $this->l('You cannot use advanced stock management for this pack because').'
'. + die(json_encode(array('error' => $this->l('You cannot use advanced stock management for this pack because').'
'. $this->l('- advanced stock management is not enabled for these room types').'
'. $this->l('- you have chosen to decrement room types quantities.')))); } @@ -5453,15 +5453,15 @@ class AdminProductsControllerCore extends AdminController case 'pack_stock_type': $value = Tools::getValue('value'); if ($value === false) { - die(Tools::jsonEncode(array('error' => $this->l('Undefined value')))); + die(json_encode(array('error' => $this->l('Undefined value')))); } if ((int)$value != 0 && (int)$value != 1 && (int)$value != 2 && (int)$value != 3) { - die(Tools::jsonEncode(array('error' => $this->l('Incorrect value')))); + die(json_encode(array('error' => $this->l('Incorrect value')))); } if ($product->depends_on_stock && !Pack::allUsesAdvancedStockManagement($product->id) && ((int)$value == 1 || (int)$value == 2 || ((int)$value == 3 && (Configuration::get('PS_PACK_STOCK_TYPE') == 1 || Configuration::get('PS_PACK_STOCK_TYPE') == 2)))) { - die(Tools::jsonEncode(array('error' => $this->l('You cannot use this stock management option because:').'
'. + die(json_encode(array('error' => $this->l('You cannot use this stock management option because:').'
'. $this->l('- advanced stock management is not enabled for these room types').'
'. $this->l('- advanced stock management is enabled for the pack')))); } @@ -5471,10 +5471,10 @@ class AdminProductsControllerCore extends AdminController case 'out_of_stock': if (Tools::getValue('value') === false) { - die(Tools::jsonEncode(array('error' => $this->l('Undefined value')))); + die(json_encode(array('error' => $this->l('Undefined value')))); } if (!in_array((int)Tools::getValue('value'), array(0, 1, 2))) { - die(Tools::jsonEncode(array('error' => $this->l('Incorrect value')))); + die(json_encode(array('error' => $this->l('Incorrect value')))); } StockAvailable::setProductOutOfStock($product->id, (int)Tools::getValue('value')); @@ -5482,10 +5482,10 @@ class AdminProductsControllerCore extends AdminController case 'set_qty': if (Tools::getValue('value') === false || (!is_numeric(trim(Tools::getValue('value'))))) { - die(Tools::jsonEncode(array('error' => $this->l('Undefined value')))); + die(json_encode(array('error' => $this->l('Undefined value')))); } if (Tools::getValue('id_product_attribute') === false) { - die(Tools::jsonEncode(array('error' => $this->l('Undefined id room type attribute')))); + die(json_encode(array('error' => $this->l('Undefined id room type attribute')))); } StockAvailable::setQuantity($product->id, (int)Tools::getValue('id_product_attribute'), (int)Tools::getValue('value')); @@ -5495,18 +5495,18 @@ class AdminProductsControllerCore extends AdminController $error = ob_get_contents(); if (!empty($error)) { ob_end_clean(); - die(Tools::jsonEncode(array('error' => $error))); + die(json_encode(array('error' => $error))); } break; case 'advanced_stock_management' : if (Tools::getValue('value') === false) { - die(Tools::jsonEncode(array('error' => $this->l('Undefined value')))); + die(json_encode(array('error' => $this->l('Undefined value')))); } if ((int)Tools::getValue('value') != 1 && (int)Tools::getValue('value') != 0) { - die(Tools::jsonEncode(array('error' => $this->l('Incorrect value')))); + die(json_encode(array('error' => $this->l('Incorrect value')))); } if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && (int)Tools::getValue('value') == 1) { - die(Tools::jsonEncode(array('error' => $this->l('Not possible if advanced stock management is disabled. ')))); + die(json_encode(array('error' => $this->l('Not possible if advanced stock management is disabled. ')))); } $product->setAdvancedStockManagement((int)Tools::getValue('value')); @@ -5516,7 +5516,7 @@ class AdminProductsControllerCore extends AdminController break; } - die(Tools::jsonEncode(array('error' => false))); + die(json_encode(array('error' => false))); } public function getCombinationImagesJS() @@ -5666,7 +5666,7 @@ class AdminProductsControllerCore extends AdminController GROUP BY pl.`id_product` LIMIT '.(int)$limit); } - die(Tools::jsonEncode($result)); + die(json_encode($result)); } } diff --git a/controllers/admin/AdminQuickAccessesController.php b/controllers/admin/AdminQuickAccessesController.php index 450a1579b..38923e60d 100644 --- a/controllers/admin/AdminQuickAccessesController.php +++ b/controllers/admin/AdminQuickAccessesController.php @@ -153,7 +153,7 @@ class AdminQuickAccessesControllerCore extends AdminController public function getQuickAccessesList() { $links = QuickAccess::getQuickAccesses($this->context->language->id); - return Tools::jsonEncode(array_map(array($this, 'getLinkToken'), $links)); + return json_encode(array_map(array($this, 'getLinkToken'), $links)); } public function getLinkToken($item) @@ -195,7 +195,7 @@ class AdminQuickAccessesControllerCore extends AdminController $this->errors = array_unique($this->errors); if (!empty($this->errors)) { $this->errors['has_errors'] = true; - $this->ajaxDie(Tools::jsonEncode($this->errors)); + $this->ajaxDie(json_encode($this->errors)); return false; } return $this->getQuickAccessesList(); diff --git a/controllers/admin/AdminRequestSqlController.php b/controllers/admin/AdminRequestSqlController.php index 121bdcf5f..a8e5507b1 100644 --- a/controllers/admin/AdminRequestSqlController.php +++ b/controllers/admin/AdminRequestSqlController.php @@ -197,7 +197,7 @@ class AdminRequestSqlControllerCore extends AdminController unset($attributes[$key]['Default']); unset($attributes[$key]['Extra']); } - die(Tools::jsonEncode($attributes)); + die(json_encode($attributes)); } } diff --git a/controllers/admin/AdminSearchController.php b/controllers/admin/AdminSearchController.php index af5b89e8a..b8dc233dc 100644 --- a/controllers/admin/AdminSearchController.php +++ b/controllers/admin/AdminSearchController.php @@ -191,7 +191,7 @@ class AdminSearchControllerCore extends AdminController $iso_lang = Tools::strtolower(Context::getContext()->language->iso_code); $iso_country = Tools::strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))); if (($json_content = Tools::file_get_contents('https://api-addons.prestashop.com/'._PS_VERSION_.'/search/'.urlencode($this->query).'/'.$iso_country.'/'.$iso_lang.'/')) != false) { - $results = Tools::jsonDecode($json_content, true); + $results = json_decode($json_content, true); if (isset($results['id'])) { $this->_list['addons'] = array($results); } else { diff --git a/controllers/admin/AdminShopController.php b/controllers/admin/AdminShopController.php index a8624c117..2105ef397 100644 --- a/controllers/admin/AdminShopController.php +++ b/controllers/admin/AdminShopController.php @@ -36,7 +36,7 @@ class AdminShopControllerCore extends AdminController $this->table = 'shop'; $this->className = 'Shop'; $this->multishop_context = Shop::CONTEXT_ALL; - + $this->id_shop_group = (int)Tools::getValue('id_shop_group'); /* if $_GET['id_shop'] is transmitted, virtual url can be loaded in config.php, so we wether transmit shop_id in herfs */ @@ -250,7 +250,7 @@ class AdminShopControllerCore extends AdminController elseif (Shop::getTotalShops() == 1) $this->errors[] = Tools::displayError('You cannot disable the last shop.'); }*/ - + if (Tools::isSubmit('submitAddshopAndStay') || Tools::isSubmit('submitAddshop')) { $shop_group = new ShopGroup((int)Tools::getValue('id_shop_group')); if ($shop_group->shopNameExists(Tools::getValue('name'), (int)Tools::getValue('id_shop'))) { @@ -475,7 +475,7 @@ class AdminShopControllerCore extends AdminController $root_category = new Category($root_categories[0]['id_category']); $children = $root_category->getAllChildren($this->context->language->id); $selected_cat[] = $root_categories[0]['id_category']; - + foreach ($children as $child) { $selected_cat[] = $child->id; } @@ -576,7 +576,7 @@ class AdminShopControllerCore extends AdminController 'zone' => $this->l('Zones'), 'cart_rule' => $this->l('Cart rules'), ); - + // Hook for duplication of shop data $modules_list = Hook::getHookModuleExecList('actionShopDataDuplication'); if (is_array($modules_list) && count($modules_list) > 0) { @@ -586,7 +586,7 @@ class AdminShopControllerCore extends AdminController } asort($import_data); - + if (!$this->object->id) { $this->fields_import_form = array( 'radio' => array( @@ -653,7 +653,7 @@ class AdminShopControllerCore extends AdminController if (Tools::isSubmit('id_category_default')) { $_POST['id_category'] = (int)Tools::getValue('id_category_default'); } - + /* Checking fields validity */ $this->validateRules(); @@ -711,13 +711,13 @@ class AdminShopControllerCore extends AdminController if (!array_key_exists('Edit', self::$cache_lang)) { self::$cache_lang['Edit'] = $this->l('Edit', 'Helper'); } - + $tpl->assign(array( 'href' => $this->context->link->getAdminLink('AdminShop').'&shop_id='.(int)$id.'&update'.$this->table, 'action' => self::$cache_lang['Edit'], 'id' => $id )); - + return $tpl->fetch(); } else { return; @@ -738,7 +738,7 @@ class AdminShopControllerCore extends AdminController $root_category = new Category($root_categories[0]['id_category']); $children = $root_category->getAllChildren($this->context->language->id); $selected_cat[] = $root_categories[0]['id_category']; - + foreach ($children as $child) { $selected_cat[] = $child->id; } @@ -860,6 +860,6 @@ class AdminShopControllerCore extends AdminController 'children' => $tree, )); - die(Tools::jsonEncode($tree)); + die(json_encode($tree)); } } diff --git a/controllers/admin/AdminShopUrlController.php b/controllers/admin/AdminShopUrlController.php index d3e334c9d..f0e9f20ae 100644 --- a/controllers/admin/AdminShopUrlController.php +++ b/controllers/admin/AdminShopUrlController.php @@ -281,7 +281,7 @@ class AdminShopUrlControllerCore extends AdminController } $this->tpl_form_vars = array( - 'js_shop_url' => Tools::jsonEncode($list_shop_with_url) + 'js_shop_url' => json_encode($list_shop_with_url) ); $this->fields_value = array( diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index 2d53728dc..8494928a5 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -542,7 +542,7 @@ class AdminStatsControllerCore extends AdminStatsTabController } $value .= '%'; - // ConfigurationKPI::updateValue('CONVERSION_RATE_CHART', Tools::jsonEncode($data)); + // ConfigurationKPI::updateValue('CONVERSION_RATE_CHART', json_encode($data)); ConfigurationKPI::updateValue('CONVERSION_RATE', $value); ConfigurationKPI::updateValue('CONVERSION_RATE_EXPIRE', strtotime(date('Y-m-d 00:00:00', strtotime('+1 day')))); break; @@ -793,8 +793,8 @@ class AdminStatsControllerCore extends AdminStatsTabController if (isset($data)) { $array['data'] = $data; } - die(Tools::jsonEncode($array)); + die(json_encode($array)); } - die(Tools::jsonEncode(array('has_errors' => true))); + die(json_encode(array('has_errors' => true))); } } diff --git a/controllers/admin/AdminStatsTabController.php b/controllers/admin/AdminStatsTabController.php index c8e7e38eb..54b1682fb 100644 --- a/controllers/admin/AdminStatsTabController.php +++ b/controllers/admin/AdminStatsTabController.php @@ -51,7 +51,7 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor } $this->content .= $this->renderView(); } - + $this->content .= $this->displayMenu(); $this->content .= $this->displayCalendar(); $this->content .= $this->displayStats(); @@ -97,7 +97,7 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor $identifier = 'module'; $id = Tools::getValue('module'); } - + $action = Context::getContext()->link->getAdminLink('AdminStats'); $action .= ($action && $table ? '&'.Tools::safeOutput($action) : ''); $action .= ($identifier && $id ? '&'.Tools::safeOutput($identifier).'='.(int)$id : ''); @@ -172,7 +172,7 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor return $tpl->fetch(); } - + public function checkModulesNames($a, $b) { return (bool)($a['displayName'] > $b['displayName']); @@ -205,7 +205,7 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor if (!isset($module_instance)) { $module_instance = Module::getInstanceByName($module_name); } - + if ($module_instance && $module_instance->active) { $hook = Hook::exec('displayAdminStatsModules', null, $module_instance->id); } @@ -223,9 +223,9 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor public function postProcess() { $this->context = Context::getContext(); - + $this->processDateRange(); - + if (Tools::getValue('submitSettings')) { if ($this->tabAccess['edit'] === '1') { self::$currentIndex .= '&module='.Tools::getValue('module'); @@ -237,7 +237,7 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor } } } - + public function processDateRange() { if (Tools::isSubmit('submitDatePicker')) { @@ -281,21 +281,21 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor } } } - + public function ajaxProcessSetDashboardDateRange() { $this->processDateRange(); - + if ($this->isXmlHttpRequest()) { if (is_array($this->errors) && count($this->errors)) { - die(Tools::jsonEncode(array( + die(json_encode(array( 'has_errors' => true, 'errors' => array($this->errors), 'date_from' => $this->context->employee->stats_date_from, 'date_to' => $this->context->employee->stats_date_to) )); } else { - die(Tools::jsonEncode(array( + die(json_encode(array( 'has_errors' => false, 'date_from' => $this->context->employee->stats_date_from, 'date_to' => $this->context->employee->stats_date_to) diff --git a/controllers/admin/AdminSupplyOrdersController.php b/controllers/admin/AdminSupplyOrdersController.php index cdae27c2a..94702f5a2 100644 --- a/controllers/admin/AdminSupplyOrdersController.php +++ b/controllers/admin/AdminSupplyOrdersController.php @@ -1771,7 +1771,7 @@ class AdminSupplyOrdersControllerCore extends AdminController } } if ($items) { - die(Tools::jsonEncode($items)); + die(json_encode($items)); } die(1); diff --git a/controllers/admin/AdminTaxRulesGroupController.php b/controllers/admin/AdminTaxRulesGroupController.php index 3c54318ca..ba62da512 100644 --- a/controllers/admin/AdminTaxRulesGroupController.php +++ b/controllers/admin/AdminTaxRulesGroupController.php @@ -546,7 +546,7 @@ class AdminTaxRulesGroupControllerCore extends AdminController foreach ($tax_rules as $key => $result) { $output[$key] = $result; } - die(Tools::jsonEncode($output)); + die(json_encode($output)); } } diff --git a/controllers/admin/AdminTranslationsController.php b/controllers/admin/AdminTranslationsController.php index 87a586dcb..941e82739 100644 --- a/controllers/admin/AdminTranslationsController.php +++ b/controllers/admin/AdminTranslationsController.php @@ -179,8 +179,8 @@ class AdminTranslationsControllerCore extends AdminController $file_name = $this->link_lang_pack.'?version='._PS_VERSION_; $array_stream_context = @stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 8))); if ($lang_packs = Tools::file_get_contents($file_name, false, $array_stream_context)) { - // Notice : for php < 5.2 compatibility, Tools::jsonDecode. The second parameter to true will set us - if ($lang_packs != '' && $lang_packs = Tools::jsonDecode($lang_packs, true)) { + // Notice : for php < 5.2 compatibility, json_decode. The second parameter to true will set us + if ($lang_packs != '' && $lang_packs = json_decode($lang_packs, true)) { foreach ($lang_packs as $key => $lang_pack) { if (!Language::isInstalled($lang_pack['iso_code'])) { $packs_to_install[$key] = $lang_pack; diff --git a/controllers/front/AddressController.php b/controllers/front/AddressController.php index 2606da4ab..a03befc81 100644 --- a/controllers/front/AddressController.php +++ b/controllers/front/AddressController.php @@ -204,7 +204,7 @@ class AddressControllerCore extends FrontController 'hasError' => (bool)$this->errors, 'errors' => $this->errors ); - $this->ajaxDie(Tools::jsonEncode($return)); + $this->ajaxDie(json_encode($return)); } } @@ -231,7 +231,7 @@ class AddressControllerCore extends FrontController 'id_address_delivery' => (int)$this->context->cart->id_address_delivery, 'id_address_invoice' => (int)$this->context->cart->id_address_invoice ); - $this->ajaxDie(Tools::jsonEncode($return)); + $this->ajaxDie(json_encode($return)); } // Redirect to old page or current page @@ -364,7 +364,7 @@ class AddressControllerCore extends FrontController 'hasError' => !empty($this->errors), 'errors' => $this->errors ); - $this->ajaxDie(Tools::jsonEncode($return)); + $this->ajaxDie(json_encode($return)); } } } diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index 686694ef8..b1b374b2b 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -168,7 +168,7 @@ class AuthControllerCore extends FrontController 'page' => $this->context->smarty->fetch($this->template), 'token' => Tools::getToken(false) ); - $this->ajaxDie(Tools::jsonEncode($return)); + $this->ajaxDie(json_encode($return)); } } @@ -349,7 +349,7 @@ class AuthControllerCore extends FrontController 'errors' => $this->errors, 'token' => Tools::getToken(false) ); - $this->ajaxDie(Tools::jsonEncode($return)); + $this->ajaxDie(json_encode($return)); } else { $this->context->smarty->assign('authentification_error', $this->errors); } @@ -516,7 +516,7 @@ class AuthControllerCore extends FrontController 'id_address_invoice' => $this->context->cart->id_address_invoice, 'token' => Tools::getToken(false) ); - $this->ajaxDie(Tools::jsonEncode($return)); + $this->ajaxDie(json_encode($return)); } if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back)) { @@ -690,7 +690,7 @@ class AuthControllerCore extends FrontController 'id_address_invoice' => $this->context->cart->id_address_invoice, 'token' => Tools::getToken(false) ); - $this->ajaxDie(Tools::jsonEncode($return)); + $this->ajaxDie(json_encode($return)); } // if registration type is in two steps, we redirect to register address if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount')) { @@ -730,7 +730,7 @@ class AuthControllerCore extends FrontController 'isSaved' => false, 'id_customer' => 0 ); - $this->ajaxDie(Tools::jsonEncode($return)); + $this->ajaxDie(json_encode($return)); } $this->context->smarty->assign('account_error', $this->errors); } diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php index 842629439..4ee5f81cd 100644 --- a/controllers/front/CartController.php +++ b/controllers/front/CartController.php @@ -105,7 +105,7 @@ class CartControllerCore extends FrontController } } elseif (!$this->isTokenValid()) { if (Tools::getValue('ajax')) { - $this->ajaxDie(Tools::jsonEncode(array( + $this->ajaxDie(json_encode(array( 'hasError' => true, 'errors' => array(Tools::displayError('Impossible to add the product to the cart. Please refresh page.')), ))); @@ -137,7 +137,7 @@ class CartControllerCore extends FrontController } if ($total_quantity < $minimal_quantity) { - $this->ajaxDie(Tools::jsonEncode(array( + $this->ajaxDie(json_encode(array( 'hasError' => true, 'errors' => array(sprintf(Tools::displayError('You must add %d minimum quantity', !Tools::getValue('ajax')), $minimal_quantity)), ))); @@ -210,7 +210,7 @@ class CartControllerCore extends FrontController $new_id_address_delivery = (int)Tools::getValue('new_id_address_delivery'); if (!count(Carrier::getAvailableCarrierList(new Product($this->id_product), null, $new_id_address_delivery))) { - $this->ajaxDie(Tools::jsonEncode(array( + $this->ajaxDie(json_encode(array( 'hasErrors' => true, 'error' => Tools::displayError('It is not possible to deliver this product to the selected address.', false), ))); @@ -312,7 +312,7 @@ class CartControllerCore extends FrontController if (isset($hotel_room_data['stats']['num_avail'])) { $total_available_rooms = $hotel_room_data['stats']['num_avail']; if ($total_available_rooms < $req_rm) { - die(Tools::jsonEncode(array('status' => 'unavailable_quantity', 'avail_rooms' => $total_available_rooms))); + die(json_encode(array('status' => 'unavailable_quantity', 'avail_rooms' => $total_available_rooms))); } } else { $this->errors[] = Tools::displayError('Rooms are unavailable. Please try with different dates'); @@ -322,10 +322,10 @@ class CartControllerCore extends FrontController } } } else { - die(Tools::jsonEncode(array('status' => 'failed3'))); + die(json_encode(array('status' => 'failed3'))); } } else { - die(Tools::jsonEncode(array('status' => 'failed4'))); + die(json_encode(array('status' => 'failed4'))); } } @@ -416,8 +416,8 @@ class CartControllerCore extends FrontController foreach ($hotel_room_info_arr as $key_hotel_room_info => $val_hotel_room_info) { if ($chkQty < $req_rm) { $roomDemand = Tools::getValue('roomDemands'); - $roomDemand = Tools::jsonDecode($roomDemand, true); - $roomDemand = Tools::jsonEncode($roomDemand); + $roomDemand = json_decode($roomDemand, true); + $roomDemand = json_encode($roomDemand); $obj_htl_cart_booking_data = new HotelCartBookingData(); $obj_htl_cart_booking_data->id_cart = $this->context->cart->id; $obj_htl_cart_booking_data->id_guest = $this->context->cart->id_guest; @@ -519,10 +519,10 @@ class CartControllerCore extends FrontController public function displayAjax() { if ($this->errors) { - $this->ajaxDie(Tools::jsonEncode(array('hasError' => true, 'errors' => $this->errors))); + $this->ajaxDie(json_encode(array('hasError' => true, 'errors' => $this->errors))); } if ($this->ajax_refresh) { - $this->ajaxDie(Tools::jsonEncode(array('refresh' => true))); + $this->ajaxDie(json_encode(array('refresh' => true))); } // write cookie if can't on destruct @@ -560,7 +560,7 @@ class CartControllerCore extends FrontController $json = ''; Hook::exec('actionCartListOverride', array('summary' => $result, 'json' => &$json)); - $this->ajaxDie(Tools::jsonEncode(array_merge($result, (array)Tools::jsonDecode($json, true)))); + $this->ajaxDie(json_encode(array_merge($result, (array)json_decode($json, true)))); } // @todo create a hook elseif (file_exists(_PS_MODULE_DIR_.'/blockcart/blockcart-ajax.php')) { diff --git a/controllers/front/ContactController.php b/controllers/front/ContactController.php index 526fc6aee..54c5dbe17 100644 --- a/controllers/front/ContactController.php +++ b/controllers/front/ContactController.php @@ -305,7 +305,7 @@ class ContactControllerCore extends FrontController if (Configuration::get('WK_GOOGLE_ACTIVE_MAP')) { $hotelLocationArray = $objHotelInfo->getMapFormatHotelsInfo(Configuration::get('WK_MAP_HOTEL_ACTIVE_ONLY')); if ($hotelLocationArray) { - $this->context->smarty->assign('hotelLocationArray', Tools::jsonEncode($hotelLocationArray)); + $this->context->smarty->assign('hotelLocationArray', json_encode($hotelLocationArray)); } } //End diff --git a/controllers/front/OrderController.php b/controllers/front/OrderController.php index 340d534d9..a0b19b57d 100644 --- a/controllers/front/OrderController.php +++ b/controllers/front/OrderController.php @@ -138,7 +138,7 @@ class OrderControllerCore extends ParentOrderController ) ) ); - $this->ajaxDie(Tools::jsonEncode($return)); + $this->ajaxDie(json_encode($return)); } if ($this->nbProducts) { diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index cde394877..19c3a1def 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -208,7 +208,7 @@ class OrderDetailControllerCore extends FrontController $hasError = 1; } if ($bookingRefunds = Tools::getValue('bookings_to_refund')) { - if (!count($bookingRefunds = Tools::jsonDecode($bookingRefunds, true))) { + if (!count($bookingRefunds = json_decode($bookingRefunds, true))) { $hasError = 1; } else { foreach ($bookingRefunds as $idHtlBooking) { @@ -248,9 +248,9 @@ class OrderDetailControllerCore extends FrontController // Emails to customer, admin on refund request state change $objOrderReturn->changeIdOrderReturnState(OrderReturnState::ORDER_RETRUN_FIRST_STATUS, $objOrderReturn->id); - die(Tools::jsonEncode(array('status' => 1))); + die(json_encode(array('status' => 1))); } - die(Tools::jsonEncode(array('status' => 0))); + die(json_encode(array('status' => 0))); } // END ajax request handle diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index bb7730527..1c0227326 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -75,7 +75,7 @@ class OrderOpcControllerCore extends ParentOrderController $this->getFormatedSummaryDetail() ); Cart::addExtraCarriers($return); - $this->ajaxDie(Tools::jsonEncode($return)); + $this->ajaxDie(json_encode($return)); } else { $this->errors[] = Tools::displayError('An error occurred while updating the cart.'); } @@ -89,7 +89,7 @@ class OrderOpcControllerCore extends ParentOrderController case 'updateTOSStatusAndGetPayments': if (Tools::isSubmit('checked')) { $this->context->cookie->checkedTOS = (int)Tools::getValue('checked'); - $this->ajaxDie(Tools::jsonEncode(array( + $this->ajaxDie(json_encode(array( 'HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods() ))); @@ -97,7 +97,7 @@ class OrderOpcControllerCore extends ParentOrderController break; case 'getCarrierList': - $this->ajaxDie(Tools::jsonEncode($this->_getCarrierList())); + $this->ajaxDie(json_encode($this->_getCarrierList())); break; case 'editCustomer': @@ -132,14 +132,14 @@ class OrderOpcControllerCore extends ParentOrderController } else { $return['isSaved'] = false; } - $this->ajaxDie(Tools::jsonEncode($return)); + $this->ajaxDie(json_encode($return)); break; case 'getAddressBlockAndCarriersAndPayments': if ($this->context->customer->isLogged() || $this->context->customer->isGuest()) { // check if customer have addresses if (!Customer::getAddressesTotalById($this->context->customer->id)) { - $this->ajaxDie(Tools::jsonEncode(array('no_address' => 1))); + $this->ajaxDie(json_encode(array('no_address' => 1))); } if (file_exists(_PS_MODULE_DIR_.'blockuserinfo/blockuserinfo.php')) { include_once(_PS_MODULE_DIR_.'blockuserinfo/blockuserinfo.php'); @@ -183,7 +183,7 @@ class OrderOpcControllerCore extends ParentOrderController ), $this->getFormatedSummaryDetail() ); - $this->ajaxDie(Tools::jsonEncode($return)); + $this->ajaxDie(json_encode($return)); } die(Tools::displayError()); break; @@ -265,11 +265,11 @@ class OrderOpcControllerCore extends ParentOrderController 'refresh' => (bool)$this->ajax_refresh), $this->getFormatedSummaryDetail() ); - $this->ajaxDie(Tools::jsonEncode($result)); + $this->ajaxDie(json_encode($result)); } } if (count($this->errors)) { - $this->ajaxDie(Tools::jsonEncode(array( + $this->ajaxDie(json_encode(array( 'hasError' => true, 'errors' => $this->errors ))); @@ -958,8 +958,8 @@ class OrderOpcControllerCore extends ParentOrderController if ($idCartBooking = Tools::getValue('id_cart_booking')) { if (Validate::isLoadedObject($objCartbookingCata = new HotelCartBookingData($idCartBooking))) { $roomDemands = Tools::getValue('room_demands'); - $roomDemands = Tools::jsonDecode($roomDemands, true); - $roomDemands = Tools::jsonEncode($roomDemands); + $roomDemands = json_decode($roomDemands, true); + $roomDemands = json_encode($roomDemands); $objCartbookingCata->extra_demands = $roomDemands; if ($objCartbookingCata->save()) { die('1'); diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 46cfd89d0..cafe51955 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -969,7 +969,7 @@ class ProductControllerCore extends FrontController $totalPrice += $totalRoomPrice; $demandsPrice = 0; if ($roomDemand = Tools::getValue('room_demands')) { - if ($roomDemand = Tools::jsonDecode($roomDemand, true)) { + if ($roomDemand = json_decode($roomDemand, true)) { $objRoomDemandPrice = new HotelRoomTypeDemandPrice(); $demandsPrice = $objRoomDemandPrice->getRoomTypeDemandsTotalPrice( $idProduct, @@ -1009,6 +1009,6 @@ class ProductControllerCore extends FrontController $result['msg'] = 'failed3'; $result['avail_rooms'] = 0; } - die(Tools::jsonEncode($result)); + die(json_encode($result)); } } diff --git a/controllers/front/SearchController.php b/controllers/front/SearchController.php index 7e36fc1a3..ebe5d78a5 100644 --- a/controllers/front/SearchController.php +++ b/controllers/front/SearchController.php @@ -64,12 +64,12 @@ class SearchControllerCore extends FrontController } Hook::exec('actionSearch', array('expr' => $query, 'total' => count($searchResults))); } - $this->ajaxDie(Tools::jsonEncode($searchResults)); + $this->ajaxDie(json_encode($searchResults)); } //Only controller content initialization when the user use the normal search parent::initContent(); - + $product_per_page = isset($this->context->cookie->nb_item_per_page) ? (int)$this->context->cookie->nb_item_per_page : Configuration::get('PS_PRODUCTS_PER_PAGE'); if ($this->instant_search && !is_array($query)) { diff --git a/install/classes/controllerHttp.php b/install/classes/controllerHttp.php index de96a6a60..caceb3a16 100644 --- a/install/classes/controllerHttp.php +++ b/install/classes/controllerHttp.php @@ -430,7 +430,7 @@ abstract class InstallControllerHttp if (!$success && empty($message)) { $message = print_r(@error_get_last(), true); } - die(Tools::jsonEncode(array( + die(json_encode(array( 'success' => (bool)$success, 'message' => $message, // 'memory' => round(memory_get_peak_usage()/1024/1024, 2).' Mo', diff --git a/install/controllers/console/process.php b/install/controllers/console/process.php index fa56b6bec..afeadfe82 100644 --- a/install/controllers/console/process.php +++ b/install/controllers/console/process.php @@ -221,7 +221,7 @@ class InstallControllerConsoleProcess extends InstallControllerConsole $this->model_install->xml_loader_ids = $this->datas->xml_loader_ids; $result = $this->model_install->populateDatabase(); $this->datas->xml_loader_ids = $this->model_install->xml_loader_ids; - Configuration::updateValue('PS_INSTALL_XML_LOADERS_ID', Tools::jsonEncode($this->datas->xml_loader_ids)); + Configuration::updateValue('PS_INSTALL_XML_LOADERS_ID', json_encode($this->datas->xml_loader_ids)); return $result; } @@ -269,7 +269,7 @@ class InstallControllerConsoleProcess extends InstallControllerConsole { $this->initializeContext(); - if ((!$this->datas->xml_loader_ids || !is_array($this->datas->xml_loader_ids)) && ($xml_ids = Tools::jsonDecode(Configuration::get('PS_INSTALL_XML_LOADERS_ID'), true))) { + if ((!$this->datas->xml_loader_ids || !is_array($this->datas->xml_loader_ids)) && ($xml_ids = json_decode(Configuration::get('PS_INSTALL_XML_LOADERS_ID'), true))) { $this->datas->xml_loader_ids = $xml_ids; } diff --git a/install/dev/index.phtml b/install/dev/index.phtml index 76984a2b5..0eb7e2be0 100644 --- a/install/dev/index.phtml +++ b/install/dev/index.phtml @@ -113,7 +113,7 @@ $this->loader->setDefaultPath(); ?>
Selectionnez la liste des entités à resynchroniser. Afin d'éviter au maximum les erreurs, sélectionnez uniquement les entitiés que vous avez modifier. diff --git a/install/theme/views/process.phtml b/install/theme/views/process.phtml index 5eace8bb6..8111f5021 100644 --- a/install/theme/views/process.phtml +++ b/install/theme/views/process.phtml @@ -3,7 +3,7 @@ diff --git a/install/upgrade/php/ps1607_language_code_update.php b/install/upgrade/php/ps1607_language_code_update.php index c5fd639dc..5ac86d4d7 100644 --- a/install/upgrade/php/ps1607_language_code_update.php +++ b/install/upgrade/php/ps1607_language_code_update.php @@ -31,7 +31,7 @@ function ps1607_language_code_update() if (is_array($langs) && $langs) { foreach ($langs as $lang) { if (Tools::strlen($lang['language_code']) == 2) { - $result = Tools::jsonDecode(Tools::file_get_contents('https://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.Tools::strtolower($lang['iso_code']))); + $result = json_decode(Tools::file_get_contents('https://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.Tools::strtolower($lang['iso_code']))); if ($result && !isset($result->error) && Tools::strlen($result->language_code) > 2) { Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'lang` SET `language_code` = \''.pSQL($result->language_code).'\' WHERE `id_lang` = '.(int)$lang['id_lang']).' LIMIT 1'; } diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index fd5847434..073a85ea4 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -224,7 +224,7 @@ class blockcart extends Module } $this->assignContentVars($params); - $res = Tools::jsonDecode($this->display(__FILE__, 'blockcart-json.tpl'), true); + $res = json_decode($this->display(__FILE__, 'blockcart-json.tpl'), true); if (isset($params['cookie']->avail_rooms)) { $res['avail_rooms'] = $params['cookie']->avail_rooms; @@ -237,7 +237,7 @@ class blockcart extends Module $res['crossSelling'] = $this->display(__FILE__, 'crossselling.tpl'); } - $res = Tools::jsonEncode($res); + $res = json_encode($res); return $res; } diff --git a/modules/blockcart/checkroomavailabilityajaxprocess.php b/modules/blockcart/checkroomavailabilityajaxprocess.php index 51efaabd4..6fdcb30b0 100644 --- a/modules/blockcart/checkroomavailabilityajaxprocess.php +++ b/modules/blockcart/checkroomavailabilityajaxprocess.php @@ -57,21 +57,21 @@ break; } } - die(Tools::jsonEncode(array('status'=>'success', 'avail_rooms'=>$total_available_rooms))); + die(json_encode(array('status'=>'success', 'avail_rooms'=>$total_available_rooms))); } else { - die(Tools::jsonEncode(array('status'=>'failed1'))); + die(json_encode(array('status'=>'failed1'))); } } else { - die(Tools::jsonEncode(array('status'=>'unavailable_quantity', 'avail_rooms'=>$total_available_rooms))); + die(json_encode(array('status'=>'unavailable_quantity', 'avail_rooms'=>$total_available_rooms))); } } else { - die(Tools::jsonEncode(array('status'=>'failed2'))); + die(json_encode(array('status'=>'failed2'))); } } else { - die(Tools::jsonEncode(array('status'=>'failed3'))); + die(json_encode(array('status'=>'failed3'))); } } else { - die(Tools::jsonEncode(array('status'=>'failed4'))); + die(json_encode(array('status'=>'failed4'))); } } @@ -94,9 +94,9 @@ $result = $obj_htl_cart_booking_data->deleteCartBookingData($id_cart, $id_product); if ($result) { - die(Tools::jsonEncode(array('status'=>'success', 'avail_rooms'=>$total_available_rooms))); + die(json_encode(array('status'=>'success', 'avail_rooms'=>$total_available_rooms))); } else { - die(Tools::jsonEncode(array('status'=>'failed'))); + die(json_encode(array('status'=>'failed'))); } } @@ -109,10 +109,10 @@ $cart_obj = new Cart($id_cart); $update_cart_product = $cart_obj->updateQty($num_rooms_to_decr_from_cart, $id_product, null, false, $operator = 'down', 0, null, true); if ($update_cart_product) { - die(Tools::jsonEncode(array('status'=>'success', 'msg'=>'successfully cart product updated.'))); + die(json_encode(array('status'=>'success', 'msg'=>'successfully cart product updated.'))); } else { - die(Tools::jsonEncode(array('status'=>'failed', 'msg'=>'error while updating cart product.'))); + die(json_encode(array('status'=>'failed', 'msg'=>'error while updating cart product.'))); } } - die(Tools::jsonEncode(array('status'=>'failed', 'msg'=>'error while deleting room from cart booking table.'))); + die(json_encode(array('status'=>'failed', 'msg'=>'error while deleting room from cart booking table.'))); } diff --git a/modules/blockcart/controllers/front/checkroomavailabilityajaxprocess.php b/modules/blockcart/controllers/front/checkroomavailabilityajaxprocess.php index 081eba2a8..547daedfa 100644 --- a/modules/blockcart/controllers/front/checkroomavailabilityajaxprocess.php +++ b/modules/blockcart/controllers/front/checkroomavailabilityajaxprocess.php @@ -50,7 +50,7 @@ class BlockcartCheckRoomAvailabilityAjaxProcessModuleFrontController extends Mod } } die( - Tools::jsonEncode( + json_encode( array( 'status'=>'success', 'msg'=>'successfully cart product updated.', @@ -60,7 +60,7 @@ class BlockcartCheckRoomAvailabilityAjaxProcessModuleFrontController extends Mod ); } die( - Tools::jsonEncode( + json_encode( array('status'=>'failed', 'msg'=>'error while deleting room from cart booking table.') ) ); diff --git a/modules/blockcategories/controllers/admin/AdminBlockCategoriesController.php b/modules/blockcategories/controllers/admin/AdminBlockCategoriesController.php index 42367ed85..4a95beb6a 100644 --- a/modules/blockcategories/controllers/admin/AdminBlockCategoriesController.php +++ b/modules/blockcategories/controllers/admin/AdminBlockCategoriesController.php @@ -48,7 +48,7 @@ class AdminBlockCategoriesController extends ModuleAdminController } public function ajaxProcessuploadThumbnailImages() - { + { $category = new Category((int)Tools::getValue('id_category')); if (isset($_FILES['thumbnail'])) @@ -74,7 +74,7 @@ class AdminBlockCategoriesController extends ModuleAdminController { $total_errors['name'] = sprintf(Tools::displayError('An error occurred while uploading the image :')); $total_errors['error'] = sprintf(Tools::displayError('You cannot upload more files')); - die(Tools::jsonEncode(array('thumbnail' => array($total_errors)))); + die(json_encode(array('thumbnail' => array($total_errors)))); } foreach ($files as $key => &$file) @@ -99,7 +99,7 @@ class AdminBlockCategoriesController extends ModuleAdminController unset($file['save_path']); if (isset($file['tmp_name'])) - unset($file['tmp_name']); + unset($file['tmp_name']); //Add image preview and delete url $file['image'] = ImageManager::thumbnail(_PS_CAT_IMG_DIR_.(int)$category->id.'-'.$id.'_thumb.jpg', @@ -113,7 +113,7 @@ class AdminBlockCategoriesController extends ModuleAdminController else Tools::clearSmartyCache(); - die(Tools::jsonEncode(array('thumbnail' => $files))); + die(json_encode(array('thumbnail' => $files))); } } } diff --git a/modules/blocklayered/blocklayered-url-indexer.php b/modules/blocklayered/blocklayered-url-indexer.php index bc33f3e59..da474797e 100644 --- a/modules/blocklayered/blocklayered-url-indexer.php +++ b/modules/blocklayered/blocklayered-url-indexer.php @@ -7,5 +7,5 @@ if (substr(Tools::encrypt('blocklayered/index'),0,10) != Tools::getValue('token' die('Bad token'); $blockLayered = new BlockLayered(); -$cursor = Tools::jsonDecode(Tools::getValue('cursor', '{}'), true); +$cursor = json_decode(Tools::getValue('cursor', '{}'), true); echo $blockLayered->indexUrl($cursor, (int)Tools::getValue('truncate')); \ No newline at end of file diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php index 89c25af64..18a59a8d9 100644 --- a/modules/blocklayered/blocklayered.php +++ b/modules/blocklayered/blocklayered.php @@ -1621,7 +1621,7 @@ class BlockLayered extends Module 'template_name' => $template['name'], 'attribute_groups' => $attribute_groups, 'features' => $features, - 'filters' => Tools::jsonEncode($filters), + 'filters' => json_encode($filters), 'total_filters' => 6+count($attribute_groups)+count($features) )); @@ -2005,7 +2005,7 @@ class BlockLayered extends Module $this->products = array(); else { - $product_per_page = isset($this->context->cookie->nb_item_per_page) ? (int)$this->context->cookie->nb_item_per_page : Configuration::get('PS_PRODUCTS_PER_PAGE'); + $product_per_page = isset($this->context->cookie->nb_item_per_page) ? (int)$this->context->cookie->nb_item_per_page : Configuration::get('PS_PRODUCTS_PER_PAGE'); $n = (int)Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')); $nb_day_new_product = (Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20); @@ -3177,7 +3177,7 @@ class BlockLayered extends Module $vars = array_merge($vars, array('pagination_bottom' => $smarty->assign('paginationId', 'bottom') ->fetch(_PS_THEME_DIR_.'pagination.tpl'))); /* We are sending an array in jSon to the .js controller, it will update both the filters and the products zones */ - return Tools::jsonEncode($vars); + return json_encode($vars); } public function getProducts($selected_filters, &$products, &$nb_products, &$p, &$n, &$pages_nb, &$start, &$stop, &$range) diff --git a/modules/blockwishlist/controllers/front/mywishlist.php b/modules/blockwishlist/controllers/front/mywishlist.php index 61dab94ea..d94e13b95 100644 --- a/modules/blockwishlist/controllers/front/mywishlist.php +++ b/modules/blockwishlist/controllers/front/mywishlist.php @@ -51,7 +51,7 @@ class BlockWishListMyWishListModuleFrontController extends ModuleFrontController elseif (!empty($action) && method_exists($this, 'ajaxProcess'.Tools::toCamelCase($action))) $this->{'ajaxProcess'.Tools::toCamelCase($action)}(); else - die(Tools::jsonEncode(array('error' => 'method doesn\'t exist'))); + die(json_encode(array('error' => 'method doesn\'t exist'))); } /** @@ -150,7 +150,7 @@ class BlockWishListMyWishListModuleFrontController extends ModuleFrontController public function ajaxProcessDeleteList() { if (!$this->context->customer->isLogged()) - die(Tools::jsonEncode(array('success' => false, + die(json_encode(array('success' => false, 'error' => $this->module->l('You aren\'t logged in', 'mywishlist')))); $default = Tools::getIsset('default'); @@ -165,7 +165,7 @@ class BlockWishListMyWishListModuleFrontController extends ModuleFrontController $wishlist->delete(); } else - die(Tools::jsonEncode(array('success' => false, + die(json_encode(array('success' => false, 'error' => $this->module->l('Cannot delete this wishlist', 'mywishlist')))); if ($default_change) @@ -173,19 +173,19 @@ class BlockWishListMyWishListModuleFrontController extends ModuleFrontController $array = WishList::getDefault($id_customer); if (count($array)) - die(Tools::jsonEncode(array( + die(json_encode(array( 'success' => true, 'id_default' => $array[0]['id_wishlist'] ))); } - die(Tools::jsonEncode(array('success' => true))); + die(json_encode(array('success' => true))); } public function ajaxProcessSetDefault() { if (!$this->context->customer->isLogged()) - die(Tools::jsonEncode(array('success' => false, + die(json_encode(array('success' => false, 'error' => $this->module->l('You aren\'t logged in', 'mywishlist')))); $default = Tools::getIsset('default'); @@ -196,16 +196,16 @@ class BlockWishListMyWishListModuleFrontController extends ModuleFrontController { $wishlist = new WishList((int)$id_wishlist); if (Validate::isLoadedObject($wishlist) && $wishlist->id_customer == $this->context->customer->id && $wishlist->setDefault()) - die(Tools::jsonEncode(array('success' => true))); + die(json_encode(array('success' => true))); } - die(Tools::jsonEncode(array('error' => true))); + die(json_encode(array('error' => true))); } public function ajaxProcessProductChangeWishlist() { if (!$this->context->customer->isLogged()) - die(Tools::jsonEncode(array('success' => false, + die(json_encode(array('success' => false, 'error' => $this->module->l('You aren\'t logged in', 'mywishlist')))); $id_product = (int)Tools::getValue('id_product'); @@ -222,7 +222,7 @@ class BlockWishListMyWishListModuleFrontController extends ModuleFrontController !is_int($priority) || ($priority < 0 && $priority > 2) || !$id_old_wishlist || !$id_new_wishlist || (Validate::isLoadedObject($new_wishlist) && $new_wishlist->id_customer != $this->context->customer->id) || (Validate::isLoadedObject($old_wishlist) && $old_wishlist->id_customer != $this->context->customer->id)) - die(Tools::jsonEncode(array('success' => false, 'error' => $this->module->l('Error while moving product to another list', 'mywishlist')))); + die(json_encode(array('success' => false, 'error' => $this->module->l('Error while moving product to another list', 'mywishlist')))); $res = true; $check = (int)Db::getInstance()->getValue('SELECT quantity FROM '._DB_PREFIX_.'wishlist_product @@ -240,7 +240,7 @@ class BlockWishListMyWishListModuleFrontController extends ModuleFrontController } if (!$res) - die(Tools::jsonEncode(array('success' => false, 'error' => $this->module->l('Error while moving product to another list', 'mywishlist')))); - die(Tools::jsonEncode(array('success' => true, 'msg' => $this->module->l('The product has been correctly moved', 'mywishlist')))); + die(json_encode(array('success' => false, 'error' => $this->module->l('Error while moving product to another list', 'mywishlist')))); + die(json_encode(array('success' => true, 'msg' => $this->module->l('The product has been correctly moved', 'mywishlist')))); } } diff --git a/modules/graphnvd3/graphnvd3.php b/modules/graphnvd3/graphnvd3.php index 2c0f4e277..b9cd126d6 100644 --- a/modules/graphnvd3/graphnvd3.php +++ b/modules/graphnvd3/graphnvd3.php @@ -176,6 +176,6 @@ class GraphNvD3 extends ModuleGraphEngine $array['data'][] = array('values' => $nvd3_values, 'key' => $this->_titles['main'][$layer]); } } - die(preg_replace('/"([0-9]+)"/', '$1', Tools::jsonEncode($array))); + die(preg_replace('/"([0-9]+)"/', '$1', json_encode($array))); } } diff --git a/modules/gridhtml/gridhtml.php b/modules/gridhtml/gridhtml.php index 10b2ecec6..d0f68efd4 100644 --- a/modules/gridhtml/gridhtml.php +++ b/modules/gridhtml/gridhtml.php @@ -43,19 +43,19 @@ class GridHtml extends ModuleGridEngine $this->version = '1.3.1'; $this->author = 'PrestaShop'; $this->need_instance = 0; - + Module::__construct(); - + $this->displayName = $this->l('Simple HTML table display'); $this->description = $this->l('Allows the statistics system to display data in a grid.'); } } - + function install() { return (parent::install() AND $this->registerHook('GridEngine')); } - + public static function hookGridEngine($params, $grider) { self::$_columns = $params['columns']; @@ -112,7 +112,7 @@ class GridHtml extends ModuleGridEngine $("#grid_1 tbody").append("'.$params['emptyMsg'].'"); }); } - + function gridNextPage(url) { var from = url.match(/&start=[0-9]+/i); @@ -123,7 +123,7 @@ class GridHtml extends ModuleGridEngine url = url.replace(/&start=[0-9]+/i, "") + from; getGridData(url); } - + function gridPrevPage(url) { var from = url.match(/&start=[0-9]+/i); @@ -145,46 +145,46 @@ class GridHtml extends ModuleGridEngine '; return $html; } - + public function setColumnsInfos(&$infos) { } - + public function setValues($values) { $this->_values = $values; } - + public function setTitle($title) { $this->_title = $title; } - + public function setSize($width, $height) { $this->_width = $width; $this->_height = $height; } - + public function setTotalCount($totalCount) { $this->_totalCount = $totalCount; } - + public function setLimit($start, $limit) { $this->_start = (int)$start; $this->_limit = (int)$limit; } - + public function render() { - echo Tools::jsonEncode(array( + echo json_encode(array( 'total' => $this->_totalCount, 'from' => min($this->_start + 1, $this->_totalCount), 'to' => min($this->_start + $this->_limit, $this->_totalCount), 'values' => $this->_values )); - } + } } diff --git a/modules/hotelreservationsystem/classes/HotelBranchInformation.php b/modules/hotelreservationsystem/classes/HotelBranchInformation.php index 1056deafe..fb4561107 100644 --- a/modules/hotelreservationsystem/classes/HotelBranchInformation.php +++ b/modules/hotelreservationsystem/classes/HotelBranchInformation.php @@ -840,7 +840,7 @@ class HotelBranchInformation extends ObjectModel libxml_use_internal_errors(true); $xml = simplexml_load_string(utf8_decode($postData)); - $hotelData = Tools::jsonDecode(Tools::jsonEncode($xml)); + $hotelData = json_decode(json_encode($xml)); if (isset($hotelData->hotel->max_order_date)) { if ($maxOrderDate = $hotelData->hotel->max_order_date) { $this->setWsMaxOrderDate($maxOrderDate); @@ -863,7 +863,7 @@ class HotelBranchInformation extends ObjectModel libxml_use_internal_errors(true); $xml = simplexml_load_string(utf8_decode($postData)); - $hotelData = Tools::jsonDecode(Tools::jsonEncode($xml)); + $hotelData = json_decode(json_encode($xml)); if (isset($hotelData->hotel->max_order_date)) { if ($maxOrderDate = $hotelData->hotel->max_order_date) { $this->setWsMaxOrderDate($maxOrderDate); diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index fc234d227..61cd21458 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -764,7 +764,7 @@ class HotelCartBookingData extends ObjectModel AND fp.`active`=1 AND fp.`date_from` <= \''.pSQL($date).'\' AND fp.`date_to` >= \''.pSQL($date).'\'' )) { foreach ($featurePrice as $fRow) { - $specialDays = Tools::jsonDecode($fRow['special_days']); + $specialDays = json_decode($fRow['special_days']); if (in_array(strtolower(date('D', strtotime($date))), $specialDays)) { return $fRow; } @@ -1105,7 +1105,7 @@ class HotelCartBookingData extends ObjectModel if ($getTotalPrice) { if ($roomTypeDemands['extra_demands'] - && ($extraDemand = Tools::jsonDecode($roomTypeDemands['extra_demands'], true)) + && ($extraDemand = json_decode($roomTypeDemands['extra_demands'], true)) ) { $totalDemandsPrice += $objRoomDemandPrice->getRoomTypeDemandsTotalPrice( $roomTypeDemands['id_product'], @@ -1116,7 +1116,7 @@ class HotelCartBookingData extends ObjectModel ); } } else { - $roomTypeDemands['extra_demands'] = Tools::jsonDecode( + $roomTypeDemands['extra_demands'] = json_decode( $roomTypeDemands['extra_demands'], true ); @@ -1146,7 +1146,7 @@ class HotelCartBookingData extends ObjectModel foreach ($roomTypeDemands as $key => &$demand) { if ($getTotalPrice) { if ($demand['extra_demands'] - && ($extraDemand = Tools::jsonDecode($demand['extra_demands'], true)) + && ($extraDemand = json_decode($demand['extra_demands'], true)) ) { $totalDemandsPrice += $objRoomDemandPrice->getRoomTypeDemandsTotalPrice( $demand['id_product'], @@ -1157,7 +1157,7 @@ class HotelCartBookingData extends ObjectModel ); } } else { - $demand['extra_demands'] = Tools::jsonDecode( + $demand['extra_demands'] = json_decode( $demand['extra_demands'], true ); @@ -1193,7 +1193,7 @@ class HotelCartBookingData extends ObjectModel // Webservice :: get extra demands for the cart booking public function getWsExtraDemands() { - $extraDemands = Tools::jsonDecode($this->extra_demands, true); + $extraDemands = json_decode($this->extra_demands, true); if (count($extraDemands)) { foreach ($extraDemands as &$demnad) { $demnad['id'] = $demnad['id_global_demand']; diff --git a/modules/hotelreservationsystem/classes/HotelRoomTypeDemandPrice.php b/modules/hotelreservationsystem/classes/HotelRoomTypeDemandPrice.php index 53a2ce945..522b78584 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomTypeDemandPrice.php +++ b/modules/hotelreservationsystem/classes/HotelRoomTypeDemandPrice.php @@ -143,7 +143,7 @@ class HotelRoomTypeDemandPrice extends ObjectModel } if ($cartChanged) { if (Validate::isLoadedObject($objCartBooking = new HotelCartBookingData($demandInfo['id']))) { - $objCartBooking->extra_demands = Tools::jsonEncode($demandInfo['extra_demands']); + $objCartBooking->extra_demands = json_encode($demandInfo['extra_demands']); $objCartBooking->save(); } } diff --git a/modules/hotelreservationsystem/classes/HotelRoomTypeGlobalDemand.php b/modules/hotelreservationsystem/classes/HotelRoomTypeGlobalDemand.php index 285cbaa27..b5b6bfa17 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomTypeGlobalDemand.php +++ b/modules/hotelreservationsystem/classes/HotelRoomTypeGlobalDemand.php @@ -100,7 +100,7 @@ class HotelRoomTypeGlobalDemand extends ObjectModel } if ($cartChanged) { if (Validate::isLoadedObject($objCartBooking = new HotelCartBookingData($demandInfo['id']))) { - $objCartBooking->extra_demands = Tools::jsonEncode($demandInfo['extra_demands']); + $objCartBooking->extra_demands = json_encode($demandInfo['extra_demands']); $objCartBooking->save(); } } diff --git a/modules/hotelreservationsystem/classes/HotelRoomTypeGlobalDemandAdvanceOption.php b/modules/hotelreservationsystem/classes/HotelRoomTypeGlobalDemandAdvanceOption.php index 398aa7545..282139aff 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomTypeGlobalDemandAdvanceOption.php +++ b/modules/hotelreservationsystem/classes/HotelRoomTypeGlobalDemandAdvanceOption.php @@ -80,7 +80,7 @@ class HotelRoomTypeGlobalDemandAdvanceOption extends ObjectModel } if ($cartChanged) { if (Validate::isLoadedObject($objCartBooking = new HotelCartBookingData($demandInfo['id']))) { - $objCartBooking->extra_demands = Tools::jsonEncode($demandInfo['extra_demands']); + $objCartBooking->extra_demands = json_encode($demandInfo['extra_demands']); $objCartBooking->save(); } } diff --git a/modules/hotelreservationsystem/classes/QloRoomType.php b/modules/hotelreservationsystem/classes/QloRoomType.php index 3aa606312..c5bc3ac02 100644 --- a/modules/hotelreservationsystem/classes/QloRoomType.php +++ b/modules/hotelreservationsystem/classes/QloRoomType.php @@ -156,7 +156,7 @@ class QloRoomType extends QloWebservice // } // // convert object to array - // $address = Tools::jsonDecode(Tools::jsonEncode($address), true); + // $address = json_decode(json_encode($address), true); // $this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('address', array()); // $address['country'] = Country::getNameById($this->id_lang, $address['id_country']); diff --git a/modules/hotelreservationsystem/classes/WebserviceSpecificManagementQlo.php b/modules/hotelreservationsystem/classes/WebserviceSpecificManagementQlo.php index 959aa6c45..11280b267 100644 --- a/modules/hotelreservationsystem/classes/WebserviceSpecificManagementQlo.php +++ b/modules/hotelreservationsystem/classes/WebserviceSpecificManagementQlo.php @@ -80,7 +80,7 @@ class WebserviceSpecificManagementQlo implements WebserviceSpecificManagementInt $outputXML = $this->objOutput->getObjectRender()->overrideContent($this->output); if (isset($this->wsObject->urlFragments['outputformat']) && $this->wsObject->urlFragments['outputformat'] == 'json') { $outputXML = simplexml_load_string($outputXML, null, LIBXML_NOCDATA); - $json = Tools::jsonEncode($outputXML); + $json = json_encode($outputXML); $content = preg_replace("/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", $json); header('Content-Type: application/json'); die($content); @@ -153,7 +153,7 @@ class WebserviceSpecificManagementQlo implements WebserviceSpecificManagementInt } } else { // If input type is json - $array = Tools::jsonDecode($inputXML, true); + $array = json_decode($inputXML, true); if (isset($array['json']) && $array['json'] && isset($array[$head])) { return ($head ? $array[$head] : $array); } else { @@ -172,7 +172,7 @@ class WebserviceSpecificManagementQlo implements WebserviceSpecificManagementInt $xmlEntities = $xml->children(); // Convert multi-dimention xml into an array - $array = Tools::jsonDecode(Tools::jsonEncode($xmlEntities), true); + $array = json_decode(json_encode($xmlEntities), true); return ($head ? $array[$head] : $array); } diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php index 9e943ae9c..b8d9921d9 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php @@ -493,7 +493,7 @@ class AdminAddHotelController extends ModuleAdminController } } } - die(Tools::jsonEncode($states)); + die(json_encode($states)); } public function ajaxProcessUploadHotelImages() @@ -514,19 +514,19 @@ class AdminAddHotelController extends ModuleAdminController $hotelImgPath = _PS_MODULE_DIR_.'hotelreservationsystem/views/img/hotel_img/'; $imageDetail = $objHotelImage->uploadHotelImages($_FILES['hotel_image'], $idHotel, $hotelImgPath); if ($imageDetail) { - die(Tools::jsonEncode($imageDetail)); + die(json_encode($imageDetail)); } else { - die(Tools::jsonEncode(array('hasError' => true))); + die(json_encode(array('hasError' => true))); } } else { die( - Tools::jsonEncode( + json_encode( array('hasError' => true, 'message' => $_FILES['hotel_image']['name'].': '.$invalidImg) ) ); } } else { - die(Tools::jsonEncode(array('hasError' => true))); + die(json_encode(array('hasError' => true))); } } diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php index 24c94a068..27b7f0694 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php @@ -190,7 +190,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController } } if ($objFeaturePrice->special_days) { - $smartyVars['special_days'] = Tools::jsonDecode($objFeaturePrice->special_days, true); + $smartyVars['special_days'] = json_decode($objFeaturePrice->special_days, true); } $smartyVars['objFeaturePrice'] = $objFeaturePrice; $smartyVars['edit'] = 1; @@ -247,7 +247,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController $impactValue = Tools::getValue('impact_value'); $dateSelectionType = Tools::getValue('date_selection_type'); $specificDate = date('Y-m-d', strtotime(Tools::getValue('specific_date'))); - $jsonSpecialDays = Tools::jsonEncode($specialDays); + $jsonSpecialDays = json_encode($specialDays); $defaultLangId = Configuration::get('PS_LANG_DEFAULT'); $objFeaturePricing = new HotelRoomTypeFeaturePricing(); @@ -437,18 +437,18 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController $product['name'].= ' / '.$onjBranchInfo->hotel_name; } } - echo Tools::jsonEncode($productsByName, true); + echo json_encode($productsByName, true); die; } else { die( - Tools::jsonEncode( + json_encode( array('status' => 'failed', 'msg' => $this->l('No match found for entered room type name.')) ) ); } } else { die( - Tools::jsonEncode( + json_encode( array('status' => 'failed', 'msg' => $this->l('No match found for entered room type name.')) ) ); diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 56eff9819..1d14a138c 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -292,7 +292,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController $hotel_id = Tools::getValue('hotel_id'); $obj_room_type = new HotelRoomType(); $room_type_info = $obj_room_type->getRoomTypeByHotelId($hotel_id, Configuration::get('PS_LANG_DEFAULT'), 1); - die(Tools::jsonEncode($room_type_info)); + die(json_encode($room_type_info)); } public function ajaxProcessAddDataToCart() @@ -412,7 +412,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController 'id_cart_book_data' => $obj_cart_book_data->id); if ($obj_cart_book_data->id) { - die(Tools::jsonEncode($cart_data)); + die(json_encode($cart_data)); } else { die(0); } @@ -495,7 +495,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController 'booking_data' => $booking_data, ); } - die(Tools::jsonEncode($cart_data)); + die(json_encode($cart_data)); } else { die(0); } @@ -534,7 +534,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController $start_date = date('Y-m-d', strtotime('+1 day', strtotime($start_date))); } if ($booking_calendar_data) { - die(Tools::jsonEncode($booking_calendar_data)); + die(json_encode($booking_calendar_data)); } else { die(0); } diff --git a/modules/hotelreservationsystem/hotelreservationsystem.php b/modules/hotelreservationsystem/hotelreservationsystem.php index 70fa33c49..8197de6a8 100644 --- a/modules/hotelreservationsystem/hotelreservationsystem.php +++ b/modules/hotelreservationsystem/hotelreservationsystem.php @@ -299,7 +299,7 @@ class hotelreservationsystem extends Module if (Validate::isLoadedObject( $objCartBooking = new HotelCartBookingData($demandInfo['id']) )) { - $objCartBooking->extra_demands = Tools::jsonEncode($demandInfo['extra_demands']); + $objCartBooking->extra_demands = json_encode($demandInfo['extra_demands']); $objCartBooking->save(); } } @@ -443,7 +443,7 @@ class hotelreservationsystem extends Module if ($objHtlBkDtl->save()) { // save extra demands info if ($objCartBkData->extra_demands - && ($extraDemands = Tools::jsonDecode($objCartBkData->extra_demands, true)) + && ($extraDemands = json_decode($objCartBkData->extra_demands, true)) ) { $objRoomDemandPrice = new HotelRoomTypeDemandPrice(); foreach ($extraDemands as $demand) { diff --git a/modules/paypal/api/ApiPaypalPlus.php b/modules/paypal/api/ApiPaypalPlus.php index 21550cdea..56fd693b7 100644 --- a/modules/paypal/api/ApiPaypalPlus.php +++ b/modules/paypal/api/ApiPaypalPlus.php @@ -99,7 +99,7 @@ class ApiPaypalPlus /* * Init variable */ - $oPayPalToken = Tools::jsonDecode($result); + $oPayPalToken = json_decode($result); if (isset($oPayPalToken->error)) { return false; @@ -159,7 +159,7 @@ class ApiPaypalPlus 'Authorization:Bearer '.$accessToken, ); - $result = Tools::jsonDecode($this->sendByCURL(URL_PPP_WEBPROFILE, Tools::jsonEncode($data), $header)); + $result = json_decode($this->sendByCURL(URL_PPP_WEBPROFILE, json_encode($data), $header)); if (isset($result->id)) { return $result->id; } else { @@ -189,7 +189,7 @@ class ApiPaypalPlus 'Authorization:Bearer '.$accessToken, ); - return Tools::jsonDecode($this->sendByCURL(URL_PPP_WEBPROFILE, false, $header)); + return json_decode($this->sendByCURL(URL_PPP_WEBPROFILE, false, $header)); } } @@ -358,7 +358,7 @@ class ApiPaypalPlus 'Authorization:Bearer '.$access_token, ); - $result = $this->sendByCURL(URL_PPP_CREATE_PAYMENT, Tools::jsonEncode($data), $header); + $result = $this->sendByCURL(URL_PPP_CREATE_PAYMENT, json_encode($data), $header); return $result; } diff --git a/modules/paypal/api/CallApiPaypalPlus.php b/modules/paypal/api/CallApiPaypalPlus.php index 22fce69d8..80444cb9e 100644 --- a/modules/paypal/api/CallApiPaypalPlus.php +++ b/modules/paypal/api/CallApiPaypalPlus.php @@ -57,7 +57,7 @@ class CallApiPaypalPlus extends ApiPaypalPlus if ($accessToken != false) { - $result = Tools::jsonDecode($this->createPayment($this->customer, $this->cart, $accessToken)); + $result = json_decode($this->createPayment($this->customer, $this->cart, $accessToken)); if (isset($result->links)) { @@ -105,7 +105,7 @@ class CallApiPaypalPlus extends ApiPaypalPlus ); $data = array('payer_id' => $payer_id); - $response = $this->sendByCURL(URL_PPP_EXECUTE_PAYMENT.$paymentId.'/execute/', Tools::jsonEncode($data), $header); + $response = $this->sendByCURL(URL_PPP_EXECUTE_PAYMENT.$paymentId.'/execute/', json_encode($data), $header); return $response; } @@ -124,7 +124,7 @@ class CallApiPaypalPlus extends ApiPaypalPlus 'Authorization:Bearer '.$accessToken, ); - return $this->sendByCURL(URL_PPP_EXECUTE_REFUND.$paymentId.'/refund', Tools::jsonEncode($data), $header); + return $this->sendByCURL(URL_PPP_EXECUTE_REFUND.$paymentId.'/refund', json_encode($data), $header); } public function patch($id_payment, $address) @@ -203,7 +203,7 @@ class CallApiPaypalPlus extends ApiPaypalPlus 'Content-Type:application/json', 'Authorization:Bearer '.$accessToken, ); - $body = str_replace('\/transactions\/0\/item_list\/shipping_address', '/transactions/0/item_list/shipping_address', Tools::jsonEncode($payment)); + $body = str_replace('\/transactions\/0\/item_list\/shipping_address', '/transactions/0/item_list/shipping_address', json_encode($payment)); return $this->sendByCURL(URL_PPP_PATCH.$id_payment, $body, $header, false, 'PATCH'); } } diff --git a/modules/paypal/classes/Braintree.php b/modules/paypal/classes/Braintree.php index f62147ed7..4f24350f2 100644 --- a/modules/paypal/classes/Braintree.php +++ b/modules/paypal/classes/Braintree.php @@ -306,7 +306,7 @@ class PrestaBraintree curl_close($ch); - $json = Tools::jsonDecode($resp); + $json = json_decode($resp); Configuration::updateValue('PAYPAL_BRAINTREE_ACCESS_TOKEN', $json->data->accessToken); Configuration::updateValue('PAYPAL_BRAINTREE_REFRESH_TOKEN', $json->data->refreshToken); diff --git a/modules/paypal/controllers/front/submitplus.php b/modules/paypal/controllers/front/submitplus.php index 78b360932..2b6fcab58 100644 --- a/modules/paypal/controllers/front/submitplus.php +++ b/modules/paypal/controllers/front/submitplus.php @@ -68,7 +68,7 @@ class PayPalSubmitplusModuleFrontController extends ModuleFrontController if (!empty($this->id_cart) && !empty($this->paymentId) && !empty($this->token)) { $CallApiPaypalPlus = new CallApiPaypalPlus(); - $payment = Tools::jsonDecode($CallApiPaypalPlus->lookUpPayment($this->paymentId)); + $payment = json_decode($CallApiPaypalPlus->lookUpPayment($this->paymentId)); if (isset($payment->state)) { $this->context->smarty->assign('state', $payment->state); @@ -172,7 +172,7 @@ class PayPalSubmitplusModuleFrontController extends ModuleFrontController $return = array(); if (!$ajax) { $return['error'][] = $this->module->l('An error occured during the payment'); - echo Tools::jsonEncode($return); + echo json_encode($return); die(); } @@ -187,7 +187,7 @@ class PayPalSubmitplusModuleFrontController extends ModuleFrontController && !empty($submit) ) { $CallApiPaypalPlus = new CallApiPaypalPlus(); - $payment = Tools::jsonDecode($CallApiPaypalPlus->executePayment($payerID, $paymentId)); + $payment = json_decode($CallApiPaypalPlus->executePayment($payerID, $paymentId)); if (isset($payment->state)) { @@ -230,7 +230,7 @@ class PayPalSubmitplusModuleFrontController extends ModuleFrontController $paypal_plus_pui = new PaypalPlusPui(); $paypal_plus_pui->id_order = $id_order; - $paypal_plus_pui->pui_informations = Tools::jsonEncode($payment->payment_instruction); + $paypal_plus_pui->pui_informations = json_encode($payment->payment_instruction); $paypal_plus_pui->save(); } @@ -254,7 +254,7 @@ class PayPalSubmitplusModuleFrontController extends ModuleFrontController $return['error'][] = $this->module->l('An error occured during the payment'); } - echo Tools::jsonEncode($return); + echo json_encode($return); die(); } diff --git a/modules/paypal/integral_evolution/notifier.php b/modules/paypal/integral_evolution/notifier.php index be2f95eab..24b32f21f 100644 --- a/modules/paypal/integral_evolution/notifier.php +++ b/modules/paypal/integral_evolution/notifier.php @@ -108,6 +108,6 @@ class PayPalNotifier extends PayPal if ($custom = Tools::getValue('custom')) { $notifier = new PayPalNotifier(); - $result = Tools::jsonDecode($custom, true); + $result = json_decode($custom, true); $notifier->confirmOrder($result); } diff --git a/modules/paypal/ipn.php b/modules/paypal/ipn.php index 55cb90d4b..20f1282ae 100644 --- a/modules/paypal/ipn.php +++ b/modules/paypal/ipn.php @@ -148,7 +148,7 @@ class PayPalIPN extends PayPal $cart_details = Context::getContext()->cart->getSummaryDetails(null, true); $cart_hash = sha1(serialize(Context::getContext()->cart->nbProducts())); - $custom = Tools::jsonDecode(Tools::getValue('custom'), true); + $custom = json_decode(Tools::getValue('custom'), true); $shipping = $cart_details['total_shipping_tax_exc']; $subtotal = $cart_details['total_price_without_tax'] - $cart_details['total_shipping_tax_exc']; @@ -234,7 +234,7 @@ if (Tools::getValue('receiver_email') == Configuration::get('PAYPAL_BUSINESS_ACC if (Tools::getIsset('custom')) { $ipn = new PayPalIPN(); - $custom = Tools::jsonDecode(Tools::getValue('custom'), true); + $custom = json_decode(Tools::getValue('custom'), true); $ipn->confirmOrder($custom); } } diff --git a/modules/paypal/paypal.php b/modules/paypal/paypal.php index 67f1c3c06..96085597b 100644 --- a/modules/paypal/paypal.php +++ b/modules/paypal/paypal.php @@ -699,7 +699,7 @@ class PayPal extends PaymentModule //'PayPal_version_tls_checked' => $tls_version, 'Presta_version' => _PS_VERSION_, 'Currencies' => Currency::getCurrencies(), - 'PayPal_account_braintree' => (array) Tools::jsonDecode(Configuration::get('PAYPAL_ACCOUNT_BRAINTREE')), + 'PayPal_account_braintree' => (array) json_decode(Configuration::get('PAYPAL_ACCOUNT_BRAINTREE')), 'Currency_default'=> Configuration::get('PS_CURRENCY_DEFAULT'), //*TO DELETE* 'PayPal_braintree_public_key'=> Configuration::get('PAYPAL_BRAINTREE_PUBLIC_KEY'), //*TO DELETE* 'PayPal_braintree_private_key'=> Configuration::get('PAYPAL_BRAINTREE_PRIVATE_KEY'), @@ -1070,7 +1070,7 @@ class PayPal extends PaymentModule 'currency' => new Currency((int) $cart->id_currency), 'customer' => $this->context->customer, 'business_account' => Configuration::get('PAYPAL_BUSINESS_ACCOUNT'), - 'custom' => Tools::jsonEncode(array('id_cart' => $cart->id, 'hash' => sha1(serialize($cart->nbProducts())))), + 'custom' => json_encode(array('id_cart' => $cart->id, 'hash' => sha1(serialize($cart->nbProducts())))), 'gift_price' => (float) $this->getGiftWrappingPrice(), 'billing_address' => $billing_address, 'delivery_address' => $delivery_address, @@ -1879,7 +1879,7 @@ class PayPal extends PaymentModule } $account_brain = Tools::getValue('account_braintree'); - Configuration::updateValue('PAYPAL_ACCOUNT_BRAINTREE', Tools::jsonEncode($account_brain)); + Configuration::updateValue('PAYPAL_ACCOUNT_BRAINTREE', json_encode($account_brain)); $this->context->smarty->assign('PayPal_save_success', true); @@ -1985,7 +1985,7 @@ class PayPal extends PaymentModule $callApiPaypalPlus = new CallApiPaypalPlus(); - return Tools::jsonDecode($callApiPaypalPlus->executeRefund($id_transaction, $params)); + return json_decode($callApiPaypalPlus->executeRefund($id_transaction, $params)); } } @@ -2052,7 +2052,7 @@ class PayPal extends PaymentModule $message = $this->l('Refund operation result:')." \r\n"; foreach ($response as $key => $value) { if (is_object($value) || is_array($value)) { - $message .= $key.': '.Tools::jsonEncode($value)." \r\n"; + $message .= $key.': '.json_encode($value)." \r\n"; } else { $message .= $key.': '.$value." \r\n"; } @@ -2587,7 +2587,7 @@ class PayPal extends PaymentModule public function set_good_context() { - $account_braintree = Tools::jsonDecode(Configuration::get('PAYPAL_ACCOUNT_BRAINTREE'), true); + $account_braintree = json_decode(Configuration::get('PAYPAL_ACCOUNT_BRAINTREE'), true); $currency = new Currency($this->context->cart->id_currency); $this->context_modified = false; $this->id_currency_origin_cart = $this->context->cart->id_currency; @@ -2616,7 +2616,7 @@ class PayPal extends PaymentModule if (Validate::isLoadedObject($order = new Order($params['object']->id_order))) { if ($order->module == $this->name) { $order_detail = PaypalPlusPui::getByIdOrder($params['object']->id_order); - $information = Tools::jsonDecode($order_detail['pui_informations'], true); + $information = json_decode($order_detail['pui_informations'], true); $tab = ' diff --git a/modules/paypal/paypal_login/paypal_login.php b/modules/paypal/paypal_login/paypal_login.php index c497066dc..3e14d73be 100644 --- a/modules/paypal/paypal_login/paypal_login.php +++ b/modules/paypal/paypal_login/paypal_login.php @@ -103,7 +103,7 @@ class PayPalLogin fclose($handle); }*/ - $result = Tools::jsonDecode($result); + $result = json_decode($result); if ($result) { @@ -161,7 +161,7 @@ class PayPalLogin } */ - $result = Tools::jsonDecode($result); + $result = json_decode($result); if ($result) { $login->access_token = $result->access_token; @@ -199,7 +199,7 @@ class PayPalLogin } */ - $result = Tools::jsonDecode($result); + $result = json_decode($result); if ($result) { $customer = new Customer(); diff --git a/modules/paypal/paypal_plus/submit.php b/modules/paypal/paypal_plus/submit.php index edd6e6cfe..c0a231522 100644 --- a/modules/paypal/paypal_plus/submit.php +++ b/modules/paypal/paypal_plus/submit.php @@ -70,7 +70,7 @@ function displayConfirm($context) if (!empty($id_cart) && !empty($paymentId) && !empty($token)) { $CallApiPaypalPlus = new CallApiPaypalPlus(); - $payment = Tools::jsonDecode($CallApiPaypalPlus->lookUpPayment($paymentId)); + $payment = json_decode($CallApiPaypalPlus->lookUpPayment($paymentId)); if (isset($payment->state)) { $context->smarty->assign('state', $payment->state); @@ -158,7 +158,7 @@ function displayAjax($context) include_once _PS_MODULE_DIR_.'paypal/paypal.php'; $CallApiPaypalPlus = new CallApiPaypalPlus(); - $payment = Tools::jsonDecode($CallApiPaypalPlus->executePayment($payerID, $paymentId)); + $payment = json_decode($CallApiPaypalPlus->executePayment($payerID, $paymentId)); if (isset($payment->state)) { $transaction = array( @@ -198,7 +198,7 @@ function displayAjax($context) $order = Order::getOrderByCartId($id_cart); $paypal_plus_pui = new PaypalPlusPui(); $paypal_plus_pui->id_order = $order->id; - $paypal_plus_pui->pui_informations = Tools::jsonEncode($payment->payment_instruction); + $paypal_plus_pui->pui_informations = json_encode($payment->payment_instruction); } } elseif ($submit == 'confirmCancel') { $paypal->validateOrder( @@ -220,7 +220,7 @@ function displayAjax($context) $return['error'][] = $paypal->l('An error occured during the payment'); } - echo Tools::jsonEncode($return); + echo json_encode($return); die(); } diff --git a/modules/productcomments/controllers/front/default.php b/modules/productcomments/controllers/front/default.php index 2f7196bcb..e53694ed3 100644 --- a/modules/productcomments/controllers/front/default.php +++ b/modules/productcomments/controllers/front/default.php @@ -144,7 +144,7 @@ class ProductCommentsDefaultModuleFrontController extends ModuleFrontController else $result = false; - die(Tools::jsonEncode(array( + die(json_encode(array( 'result' => $result, 'errors' => $errors ))); diff --git a/modules/productcomments/productcomments-ajax.php b/modules/productcomments/productcomments-ajax.php index 770d261cc..f3ec718f3 100644 --- a/modules/productcomments/productcomments-ajax.php +++ b/modules/productcomments/productcomments-ajax.php @@ -52,7 +52,7 @@ if (Tools::getValue('action') && Tools::getValue('id_product_comment') && Contex } else if (Tools::getValue('action') && Tools::getValue('secure_key') == $productCom->secure_key) { - $review = Tools::jsonDecode(Tools::getValue('review')); + $review = json_decode(Tools::getValue('review')); $id_product = 0; $content = null; $title = null; diff --git a/modules/sendtoafriend/sendtoafriend_ajax.php b/modules/sendtoafriend/sendtoafriend_ajax.php index cccceef4d..97843d855 100644 --- a/modules/sendtoafriend/sendtoafriend_ajax.php +++ b/modules/sendtoafriend/sendtoafriend_ajax.php @@ -35,7 +35,7 @@ if (Module::isEnabled('sendtoafriend') && Tools::getValue('action') == 'sendToMy // Retrocompatibilty with old theme if($friend = Tools::getValue('friend')) { - $friend = Tools::jsonDecode($friend, true); + $friend = json_decode($friend, true); foreach ($friend as $key => $value) { diff --git a/modules/wkroomsearchblock/controllers/front/autocompletesearch.php b/modules/wkroomsearchblock/controllers/front/autocompletesearch.php index f9770446e..d8aa6ad59 100644 --- a/modules/wkroomsearchblock/controllers/front/autocompletesearch.php +++ b/modules/wkroomsearchblock/controllers/front/autocompletesearch.php @@ -60,6 +60,6 @@ class WkRoomSearchBlockAutoCompleteSearchModuleFrontController extends ModuleFro } else { $result['status'] = 'failed3'; } - die(Tools::jsonEncode($result)); + die(json_encode($result)); } } diff --git a/tools/json/.htaccess b/tools/json/.htaccess deleted file mode 100644 index 93169e4eb..000000000 --- a/tools/json/.htaccess +++ /dev/null @@ -1,2 +0,0 @@ -Order deny,allow -Deny from all diff --git a/tools/json/LICENSE b/tools/json/LICENSE deleted file mode 100644 index 6462558d9..000000000 --- a/tools/json/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2005 Michal Migurski - -Redistribution and use in source and binary forms, with or -without modification, are permitted provided that the following -conditions are met: Redistributions of source code must retain the -above copyright notice, this list of conditions and the following -disclaimer. Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. diff --git a/tools/json/index.php b/tools/json/index.php deleted file mode 100644 index df55e1000..000000000 --- a/tools/json/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2017 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/tools/json/json.php b/tools/json/json.php deleted file mode 100644 index 6e48eac6a..000000000 --- a/tools/json/json.php +++ /dev/null @@ -1,804 +0,0 @@ - - * @author Matt Knapp - * @author Brett Stimmerman - * @copyright 2005 Michal Migurski - * @version CVS: $Id: json.php 6844 2011-06-03 14:46:51Z dMetzger $ - * @license http://www.opensource.org/licenses/bsd-license.php - * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198 - */ - -/** - * Marker constant for Services_JSON::decode(), used to flag stack state - */ -define('SERVICES_JSON_SLICE', 1); - -/** - * Marker constant for Services_JSON::decode(), used to flag stack state - */ -define('SERVICES_JSON_IN_STR', 2); - -/** - * Marker constant for Services_JSON::decode(), used to flag stack state - */ -define('SERVICES_JSON_IN_ARR', 3); - -/** - * Marker constant for Services_JSON::decode(), used to flag stack state - */ -define('SERVICES_JSON_IN_OBJ', 4); - -/** - * Marker constant for Services_JSON::decode(), used to flag stack state - */ -define('SERVICES_JSON_IN_CMT', 5); - -/** - * Behavior switch for Services_JSON::decode() - */ -define('SERVICES_JSON_LOOSE_TYPE', 16); - -/** - * Behavior switch for Services_JSON::decode() - */ -define('SERVICES_JSON_SUPPRESS_ERRORS', 32); - -/** - * Converts to and from JSON format. - * - * Brief example of use: - * - * - * // create a new instance of Services_JSON - * $json = new Services_JSON(); - * - * // convert a complexe value to JSON notation, and send it to the browser - * $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4))); - * $output = $json->encode($value); - * - * print($output); - * // prints: ["foo","bar",[1,2,"baz"],[3,[4]]] - * - * // accept incoming POST data, assumed to be in JSON notation - * $input = file_get_contents('php://input', 1000000); - * $value = $json->decode($input); - * - */ -class Services_JSON -{ - /** - * constructs a new JSON instance - * - * @param int $use object behavior flags; combine with boolean-OR - * - * possible values: - * - SERVICES_JSON_LOOSE_TYPE: loose typing. - * "{...}" syntax creates associative arrays - * instead of objects in decode(). - * - SERVICES_JSON_SUPPRESS_ERRORS: error suppression. - * Values which can't be encoded (e.g. resources) - * appear as NULL instead of throwing errors. - * By default, a deeply-nested resource will - * bubble up with an error, so all return values - * from encode() should be checked with isError() - */ - function __construct($use = 0) - { - $this->use = $use; - } - - /** - * convert a string from one UTF-16 char to one UTF-8 char - * - * Normally should be handled by mb_convert_encoding, but - * provides a slower PHP-only method for installations - * that lack the multibye string extension. - * - * @param string $utf16 UTF-16 character - * @return string UTF-8 character - * @access private - */ - function utf162utf8($utf16) - { - // oh please oh please oh please oh please oh please - if(function_exists('mb_convert_encoding')) { - return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16'); - } - - $bytes = (ord($utf16{0}) << 8) | ord($utf16{1}); - - switch(true) { - case ((0x7F & $bytes) == $bytes): - // this case should never be reached, because we are in ASCII range - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0x7F & $bytes); - - case (0x07FF & $bytes) == $bytes: - // return a 2-byte UTF-8 character - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0xC0 | (($bytes >> 6) & 0x1F)) - . chr(0x80 | ($bytes & 0x3F)); - - case (0xFFFF & $bytes) == $bytes: - // return a 3-byte UTF-8 character - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0xE0 | (($bytes >> 12) & 0x0F)) - . chr(0x80 | (($bytes >> 6) & 0x3F)) - . chr(0x80 | ($bytes & 0x3F)); - } - - // ignoring UTF-32 for now, sorry - return ''; - } - - /** - * convert a string from one UTF-8 char to one UTF-16 char - * - * Normally should be handled by mb_convert_encoding, but - * provides a slower PHP-only method for installations - * that lack the multibye string extension. - * - * @param string $utf8 UTF-8 character - * @return string UTF-16 character - * @access private - */ - function utf82utf16($utf8) - { - // oh please oh please oh please oh please oh please - if(function_exists('mb_convert_encoding')) { - return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); - } - - switch(strlen($utf8)) { - case 1: - // this case should never be reached, because we are in ASCII range - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return $utf8; - - case 2: - // return a UTF-16 character from a 2-byte UTF-8 char - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0x07 & (ord($utf8{0}) >> 2)) - . chr((0xC0 & (ord($utf8{0}) << 6)) - | (0x3F & ord($utf8{1}))); - - case 3: - // return a UTF-16 character from a 3-byte UTF-8 char - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr((0xF0 & (ord($utf8{0}) << 4)) - | (0x0F & (ord($utf8{1}) >> 2))) - . chr((0xC0 & (ord($utf8{1}) << 6)) - | (0x7F & ord($utf8{2}))); - } - - // ignoring UTF-32 for now, sorry - return ''; - } - - /** - * encodes an arbitrary variable into JSON format - * - * @param mixed $var any number, boolean, string, array, or object to be encoded. - * see argument 1 to Services_JSON() above for array-parsing behavior. - * if var is a strng, note that encode() always expects it - * to be in ASCII or UTF-8 format! - * - * @return mixed JSON string representation of input var or an error if a problem occurs - * @access public - */ - function encode($var) - { - switch (gettype($var)) { - case 'boolean': - return $var ? 'true' : 'false'; - - case 'NULL': - return 'null'; - - case 'integer': - return (int) $var; - - case 'double': - case 'float': - return (float) $var; - - case 'string': - // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT - $ascii = ''; - $strlen_var = strlen($var); - - /* - * Iterate over every character in the string, - * escaping with a slash or encoding to UTF-8 where necessary - */ - for ($c = 0; $c < $strlen_var; ++$c) { - - $ord_var_c = ord($var{$c}); - - switch (true) { - case $ord_var_c == 0x08: - $ascii .= '\b'; - break; - case $ord_var_c == 0x09: - $ascii .= '\t'; - break; - case $ord_var_c == 0x0A: - $ascii .= '\n'; - break; - case $ord_var_c == 0x0C: - $ascii .= '\f'; - break; - case $ord_var_c == 0x0D: - $ascii .= '\r'; - break; - - case $ord_var_c == 0x22: - case $ord_var_c == 0x2F: - case $ord_var_c == 0x5C: - // double quote, slash, slosh - $ascii .= '\\'.$var{$c}; - break; - - case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): - // characters U-00000000 - U-0000007F (same as ASCII) - $ascii .= $var{$c}; - break; - - case (($ord_var_c & 0xE0) == 0xC0): - // characters U-00000080 - U-000007FF, mask 110XXXXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, ord($var{$c + 1})); - $c += 1; - $utf16 = $this->utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xF0) == 0xE0): - // characters U-00000800 - U-0000FFFF, mask 1110XXXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2})); - $c += 2; - $utf16 = $this->utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xF8) == 0xF0): - // characters U-00010000 - U-001FFFFF, mask 11110XXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2}), - ord($var{$c + 3})); - $c += 3; - $utf16 = $this->utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xFC) == 0xF8): - // characters U-00200000 - U-03FFFFFF, mask 111110XX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2}), - ord($var{$c + 3}), - ord($var{$c + 4})); - $c += 4; - $utf16 = $this->utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xFE) == 0xFC): - // characters U-04000000 - U-7FFFFFFF, mask 1111110X - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2}), - ord($var{$c + 3}), - ord($var{$c + 4}), - ord($var{$c + 5})); - $c += 5; - $utf16 = $this->utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - } - } - - return '"'.$ascii.'"'; - - case 'array': - /* - * As per JSON spec if any array key is not an integer - * we must treat the the whole array as an object. We - * also try to catch a sparsely populated associative - * array with numeric keys here because some JS engines - * will create an array with empty indexes up to - * max_index which can cause memory issues and because - * the keys, which may be relevant, will be remapped - * otherwise. - * - * As per the ECMA and JSON specification an object may - * have any string as a property. Unfortunately due to - * a hole in the ECMA specification if the key is a - * ECMA reserved word or starts with a digit the - * parameter is only accessible using ECMAScript's - * bracket notation. - */ - - // treat as a JSON object - if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) { - $properties = array_map(array($this, 'name_value'), - array_keys($var), - array_values($var)); - - foreach($properties as $property) { - if(Services_JSON::isError($property)) { - return $property; - } - } - - return '{' . join(',', $properties) . '}'; - } - - // treat it like a regular array - $elements = array_map(array($this, 'encode'), $var); - - foreach($elements as $element) { - if(Services_JSON::isError($element)) { - return $element; - } - } - - return '[' . join(',', $elements) . ']'; - - case 'object': - $vars = get_object_vars($var); - - $properties = array_map(array($this, 'name_value'), - array_keys($vars), - array_values($vars)); - - foreach($properties as $property) { - if(Services_JSON::isError($property)) { - return $property; - } - } - - return '{' . join(',', $properties) . '}'; - - default: - return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS) - ? 'null' - : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string"); - } - } - - /** - * array-walking function for use in generating JSON-formatted name-value pairs - * - * @param string $name name of key to use - * @param mixed $value reference to an array element to be encoded - * - * @return string JSON-formatted name-value pair, like '"name":value' - * @access private - */ - function name_value($name, $value) - { - $encoded_value = $this->encode($value); - - if(Services_JSON::isError($encoded_value)) { - return $encoded_value; - } - - return $this->encode(strval($name)) . ':' . $encoded_value; - } - - /** - * reduce a string by removing leading and trailing comments and whitespace - * - * @param $str string string value to strip of comments and whitespace - * - * @return string string value stripped of comments and whitespace - * @access private - */ - function reduce_string($str) - { - $str = preg_replace(array( - - // eliminate single line comments in '// ...' form - '#^\s*//(.+)$#m', - - // eliminate multi-line comments in '/* ... */' form, at start of string - '#^\s*/\*(.+)\*/#Us', - - // eliminate multi-line comments in '/* ... */' form, at end of string - '#/\*(.+)\*/\s*$#Us' - - ), '', $str); - - // eliminate extraneous space - return trim($str); - } - - /** - * decodes a JSON string into appropriate variable - * - * @param string $str JSON-formatted string - * - * @return mixed number, boolean, string, array, or object - * corresponding to given JSON input string. - * See argument 1 to Services_JSON() above for object-output behavior. - * Note that decode() always returns strings - * in ASCII or UTF-8 format! - * @access public - */ - function decode($str) - { - $str = $this->reduce_string($str); - - switch (strtolower($str)) { - case 'true': - return true; - - case 'false': - return false; - - case 'null': - return null; - - default: - $m = array(); - - if (is_numeric($str)) { - // Lookie-loo, it's a number - - // This would work on its own, but I'm trying to be - // good about returning integers where appropriate: - // return (float)$str; - - // Return float or int, as appropriate - return ((float)$str == (integer)$str) - ? (integer)$str - : (float)$str; - - } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) { - // STRINGS RETURNED IN UTF-8 FORMAT - $delim = substr($str, 0, 1); - $chrs = substr($str, 1, -1); - $utf8 = ''; - $strlen_chrs = strlen($chrs); - - for ($c = 0; $c < $strlen_chrs; ++$c) { - - $substr_chrs_c_2 = substr($chrs, $c, 2); - $ord_chrs_c = ord($chrs{$c}); - - switch (true) { - case $substr_chrs_c_2 == '\b': - $utf8 .= chr(0x08); - ++$c; - break; - case $substr_chrs_c_2 == '\t': - $utf8 .= chr(0x09); - ++$c; - break; - case $substr_chrs_c_2 == '\n': - $utf8 .= chr(0x0A); - ++$c; - break; - case $substr_chrs_c_2 == '\f': - $utf8 .= chr(0x0C); - ++$c; - break; - case $substr_chrs_c_2 == '\r': - $utf8 .= chr(0x0D); - ++$c; - break; - - case $substr_chrs_c_2 == '\\"': - case $substr_chrs_c_2 == '\\\'': - case $substr_chrs_c_2 == '\\\\': - case $substr_chrs_c_2 == '\\/': - if (($delim == '"' && $substr_chrs_c_2 != '\\\'') || - ($delim == "'" && $substr_chrs_c_2 != '\\"')) { - $utf8 .= $chrs{++$c}; - } - break; - - case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)): - // single, escaped unicode character - $utf16 = chr(hexdec(substr($chrs, ($c + 2), 2))) - . chr(hexdec(substr($chrs, ($c + 4), 2))); - $utf8 .= $this->utf162utf8($utf16); - $c += 5; - break; - - case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F): - $utf8 .= $chrs{$c}; - break; - - case ($ord_chrs_c & 0xE0) == 0xC0: - // characters U-00000080 - U-000007FF, mask 110XXXXX - //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $utf8 .= substr($chrs, $c, 2); - ++$c; - break; - - case ($ord_chrs_c & 0xF0) == 0xE0: - // characters U-00000800 - U-0000FFFF, mask 1110XXXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $utf8 .= substr($chrs, $c, 3); - $c += 2; - break; - - case ($ord_chrs_c & 0xF8) == 0xF0: - // characters U-00010000 - U-001FFFFF, mask 11110XXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $utf8 .= substr($chrs, $c, 4); - $c += 3; - break; - - case ($ord_chrs_c & 0xFC) == 0xF8: - // characters U-00200000 - U-03FFFFFF, mask 111110XX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $utf8 .= substr($chrs, $c, 5); - $c += 4; - break; - - case ($ord_chrs_c & 0xFE) == 0xFC: - // characters U-04000000 - U-7FFFFFFF, mask 1111110X - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $utf8 .= substr($chrs, $c, 6); - $c += 5; - break; - - } - - } - - return $utf8; - - } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) { - // array, or object notation - - if ($str{0} == '[') { - $stk = array(SERVICES_JSON_IN_ARR); - $arr = array(); - } else { - if ($this->use & SERVICES_JSON_LOOSE_TYPE) { - $stk = array(SERVICES_JSON_IN_OBJ); - $obj = array(); - } else { - $stk = array(SERVICES_JSON_IN_OBJ); - $obj = new stdClass(); - } - } - - array_push($stk, array('what' => SERVICES_JSON_SLICE, - 'where' => 0, - 'delim' => false)); - - $chrs = substr($str, 1, -1); - $chrs = $this->reduce_string($chrs); - - if ($chrs == '') { - if (reset($stk) == SERVICES_JSON_IN_ARR) { - return $arr; - - } else { - return $obj; - - } - } - - //print("\nparsing {$chrs}\n"); - - $strlen_chrs = strlen($chrs); - - for ($c = 0; $c <= $strlen_chrs; ++$c) { - - $top = end($stk); - $substr_chrs_c_2 = substr($chrs, $c, 2); - - if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) { - // found a comma that is not inside a string, array, etc., - // OR we've reached the end of the character list - $slice = substr($chrs, $top['where'], ($c - $top['where'])); - array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false)); - //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); - - if (reset($stk) == SERVICES_JSON_IN_ARR) { - // we are in an array, so just push an element onto the stack - array_push($arr, $this->decode($slice)); - - } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) { - // we are in an object, so figure - // out the property name and set an - // element in an associative array, - // for now - $parts = array(); - - if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) { - // "name":value pair - $key = $this->decode($parts[1]); - $val = $this->decode($parts[2]); - - if ($this->use & SERVICES_JSON_LOOSE_TYPE) { - $obj[$key] = $val; - } else { - $obj->$key = $val; - } - } elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) { - // name:value pair, where name is unquoted - $key = $parts[1]; - $val = $this->decode($parts[2]); - - if ($this->use & SERVICES_JSON_LOOSE_TYPE) { - $obj[$key] = $val; - } else { - $obj->$key = $val; - } - } - - } - - } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) { - // found a quote, and we are not inside a string - array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c})); - //print("Found start of string at {$c}\n"); - - } elseif (($chrs{$c} == $top['delim']) && - ($top['what'] == SERVICES_JSON_IN_STR) && - ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) { - // found a quote, we're in a string, and it's not escaped - // we know that it's not escaped becase there is _not_ an - // odd number of backslashes at the end of the string so far - array_pop($stk); - //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n"); - - } elseif (($chrs{$c} == '[') && - in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { - // found a left-bracket, and we are in an array, object, or slice - array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false)); - //print("Found start of array at {$c}\n"); - - } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) { - // found a right-bracket, and we're in an array - array_pop($stk); - //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); - - } elseif (($chrs{$c} == '{') && - in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { - // found a left-brace, and we are in an array, object, or slice - array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false)); - //print("Found start of object at {$c}\n"); - - } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) { - // found a right-brace, and we're in an object - array_pop($stk); - //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); - - } elseif (($substr_chrs_c_2 == '/*') && - in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { - // found a comment start, and we are in an array, object, or slice - array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false)); - $c++; - //print("Found start of comment at {$c}\n"); - - } elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) { - // found a comment end, and we're in one now - array_pop($stk); - $c++; - - for ($i = $top['where']; $i <= $c; ++$i) - $chrs = substr_replace($chrs, ' ', $i, 1); - - //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); - - } - - } - - if (reset($stk) == SERVICES_JSON_IN_ARR) { - return $arr; - - } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) { - return $obj; - - } - - } - } - } - - /** - * @todo Ultimately, this should just call PEAR::isError() - */ - function isError($data, $code = null) - { - if (class_exists('pear')) { - return @PEAR::isError($data, $code); - } elseif (is_object($data) && (get_class($data) == 'services_json_error' || - is_subclass_of($data, 'services_json_error'))) { - return true; - } - - return false; - } -} - -if (class_exists('PEAR_Error')) { - - class Services_JSON_Error extends PEAR_Error - { - function Services_JSON_Error($message = 'unknown error', $code = null, - $mode = null, $options = null, $userinfo = null) - { - parent::PEAR_Error($message, $code, $mode, $options, $userinfo); - } - } - -} else { - - /** - * @todo Ultimately, this class shall be descended from PEAR_Error - */ - class Services_JSON_Error - { - function Services_JSON_Error($message = 'unknown error', $code = null, - $mode = null, $options = null, $userinfo = null) - { - - } - } - -}
'.$this->l('Bank name').''.$information['recipient_banking_instruction']['bank_name'].'