当前位置: 首页>>代码示例>>PHP>>正文


PHP Tools::jsonEncode方法代码示例

本文整理汇总了PHP中Tools::jsonEncode方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::jsonEncode方法的具体用法?PHP Tools::jsonEncode怎么用?PHP Tools::jsonEncode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tools的用法示例。


在下文中一共展示了Tools::jsonEncode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initContent

 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $this->productSort();
     // Override default configuration values: cause the new products page must display latest products first.
     if (!Tools::getIsset('orderway') || !Tools::getIsset('orderby')) {
         $this->orderBy = 'date_add';
         $this->orderWay = 'DESC';
     }
     $nbProducts = (int) Product::getNewProducts($this->context->language->id, null, null, true);
     $this->pagination($nbProducts);
     $products = Product::getNewProducts($this->context->language->id, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay);
     $this->addColorsToProductList($products);
     $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displayLeftColumn'), 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => (int) $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
     if ($this->ajax) {
         $product_list = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'product-list.tpl');
         $pagination = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'pagination.tpl');
         $nbLeftProducts = $nbProducts - ($this->n * ($this->p - 1) + count($products));
         $nbLeftProductsPercentage = ($nbProducts - $nbLeftProducts) / $nbProducts * 100;
         echo Tools::jsonEncode(array('productList' => utf8_encode($product_list), 'pagination' => $pagination, 'nbRenderedProducts' => $nbProducts, 'nbLeftProducts' => $nbLeftProducts, 'nbLeftProductsPercentage' => $nbLeftProductsPercentage));
         die;
     } else {
         $this->setTemplate(_PS_THEME_DIR_ . 'new-products.tpl');
     }
 }
开发者ID:WhisperingTree,项目名称:etagerca,代码行数:29,代码来源:NewProductsController.php

示例2: sendQuestion

 public function sendQuestion()
 {
     if (Tools::getValue('enviar_mensaje')) {
         $params = array();
         $params['nombre'] = pSQL(Tools::getValue('nombre', ''));
         $params['email'] = pSQL(Tools::getValue('email', ''));
         $params['ciudad'] = pSQL(Tools::getValue('ciudad', ''));
         $params['provincia'] = pSQL(Tools::getValue('provincia', ''));
         $params['consulta'] = pSQL(Tools::getValue('consulta', ''));
         $params['id_producto'] = (int) Tools::getValue('id_producto', 0);
         $params['date_add'] = date('Y-m-d H:i:s', strtotime('now'));
         $params['validado'] = 0;
         DB::getInstance()->insert('lgconsultas', $params);
         $id_consulta = Db::getInstance()->Insert_ID();
         if ($id_consulta) {
             $consulta = Db::getInstance()->getRow('SELECT * FROM `' . _DB_PREFIX_ . 'lgconsultas` WHERE id_consulta=' . (int) $id_consulta);
             $producto = Db::getInstance()->getValue('SELECT name FROM ' . _DB_PREFIX_ . 'product_lang WHERE id_product=' . (int) $consulta['id_producto'] . ' AND id_lang=' . (int) Configuration::get('PS_LANG_DEFAULT'));
             $enlace = new Link();
             $urlproducto = $enlace->getProductLink($consulta['id_producto']);
             $templateVars = array('id_consulta' => $id_consulta, '{consulta}' => pSQL($consulta['consulta']), '{nombre}' => pSQL($consulta['nombre']), '{email}' => pSQL($consulta['email']), '{provincia}' => pSQL($consulta['provincia']), '{ciudad}' => pSQL($consulta['ciudad']), '{producto}' => $producto, '{urlproducto}' => $urlproducto);
             if (!Mail::Send((int) Configuration::get('PS_LANG_DEFAULT'), 'consulta_enviada', $this->l('You have received a new question about a product'), $templateVars, Configuration::get('LG_CONSULTAS_EMAIL'), null, Configuration::get('LG_CONSULTAS_EMAIL'), Configuration::get('PS_SHOP_NAME'), null, null, _PS_MODULE_DIR_ . 'lgconsultas/mails/')) {
                 $out = array('status' => 'nok', 'msg' => $this->l('An error occurred while sending your question'));
             } else {
                 $out = array('status' => 'ok', 'msg' => $this->l('Your question has been sent'));
             }
         } else {
             $out = array('status' => 'nok', 'msg' => $this->l('An error occurred while trying to add your question'));
         }
         echo Tools::jsonEncode($out);
         die;
     }
 }
开发者ID:acreno,项目名称:pm-ps,代码行数:32,代码来源:responses.php

示例3: __call

 /**
  * Performs a request and gets the results
  *
  * @param string $method - A String containing the name of the method to be invoked.
  * @param array $params - An Array of objects to pass as arguments to the method.
  * @return array
  */
 public function __call($method, $params)
 {
     static $request_id;
     // generating uniuqe id per process
     $request_id++;
     // check if given params are correct
     $validate_params = array(false === is_scalar($method) => 'Method name has no scalar value', false === is_array($params) => 'Params must be given as array');
     $this->checkForErrors($validate_params);
     // send params as an object or an array
     $params = $this->parameters_structure == 'object' ? $params[0] : array_values($params);
     // Request (method invocation)
     $request = Tools::jsonEncode(array('jsonrpc' => '2.0', 'method' => $method, 'params' => $params, 'id' => $request_id));
     // if is_debug mode is true then add url and request to is_debug
     $this->debug('Url: ' . $this->url . "\r\n", false);
     $this->debug('Request: ' . $request . "\r\n", false);
     $response = $this->getResponse($request);
     // if is_debug mode is true then add response to is_debug and display it
     $this->debug('Response: ' . $response . "\r\n", true);
     // decode and create array ( can be object, just set to false )
     $response = Tools::jsonDecode($response, true);
     // check if response is correct
     $validate_params = array($response['id'] != $request_id => 'Request id: ' . $request_id . ' is different from Response id: ' . $response['id']);
     if (isset($response['error'])) {
         $error_message = 'Request have return error: ' . $response['error']['message'] . '; ' . "\n" . 'Request: ' . $request . '; ';
         if (isset($response['error']['data'])) {
             $error_message .= "\n" . 'Error data: ' . $response['error']['data'];
         }
         $validate_params[!is_null($response['error'])] = $error_message;
     }
     $this->checkForErrors($validate_params);
     return $response['result'];
 }
开发者ID:mitrm,项目名称:DevZone,代码行数:39,代码来源:jsonRPCClient.php

示例4: preProcess

 public function preProcess()
 {
     global $cart;
     if ($id_product = (int) Tools::getValue('id_product')) {
         $this->product = new Product($id_product, true, self::$cookie->id_lang);
     }
     if (Tools::isSubmit('ajax')) {
         if (Tools::isSubmit('submitCustomizedDatas')) {
             $this->pictureUpload($this->product, $cart);
             $this->textRecord($this->product, $cart);
             $this->formTargetFormat();
         }
         if (count($this->errors)) {
             die(Tools::jsonEncode(array('hasErrors' => true, 'errors' => $this->errors)));
         } else {
             die(Tools::jsonEncode(array('hasErrors' => false, 'conf' => Tools::displayError('Customization saved successfully.'))));
         }
     }
     if (!Validate::isLoadedObject($this->product)) {
         header('HTTP/1.1 404 Not Found');
         header('Status: 404 Not Found');
     } else {
         $this->canonicalRedirection();
     }
     parent::preProcess();
 }
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:26,代码来源:ProductController.php

示例5: renderForm

 public function renderForm()
 {
     $update_htaccess = Tools::modRewriteActive() && (file_exists('.htaccess') && is_writable('.htaccess') || is_writable(dirname('.htaccess')));
     $this->multiple_fieldsets = true;
     if (!$update_htaccess) {
         $desc_virtual_uri = array('<span class="warning_mod_rewrite">' . $this->l('You need to activate URL Rewriting if you want to add a virtual URL.') . '</span>');
     } else {
         $desc_virtual_uri = array($this->l('You can use this option if you want to create a store with a URL that doesn\'t exist on your server (e.g. if you want your store to be available with the URL www.my-prestashop.com/my-store/shoes/, you have to set shoes/ in this field, assuming that my-store/ is your Physical URL).'), '<strong>' . $this->l('URL rewriting must be activated on your server to use this feature.') . '</strong>');
     }
     $this->fields_form = array(array('form' => array('legend' => array('title' => $this->l('URL options'), 'icon' => 'icon-cogs'), 'input' => array(array('type' => 'select', 'label' => $this->l('Shop'), 'name' => 'id_shop', 'onchange' => 'checkMainUrlInfo(this.value);', 'options' => array('optiongroup' => array('query' => Shop::getTree(), 'label' => 'name'), 'options' => array('query' => 'shops', 'id' => 'id_shop', 'name' => 'name'))), array('type' => 'switch', 'label' => $this->l('Main URL'), 'name' => 'main', 'class' => 't', 'values' => array(array('id' => 'main_on', 'value' => 1), array('id' => 'main_off', 'value' => 0)), 'desc' => array($this->l('If you set this URL as the Main URL for the selected shop, all URLs set to this shop will be redirected to this URL (you can only have one Main URL per shop).'), array('text' => $this->l('Since the selected shop has no main URL, you have to set this URL as the Main URL.'), 'id' => 'mainUrlInfo'), array('text' => $this->l('The selected shop already has a Main URL. Therefore, if you set this one as the Main URL, the older of the two will be set as the normal URL.'), 'id' => 'mainUrlInfoExplain'))), array('type' => 'switch', 'label' => $this->l('Enabled'), 'name' => 'active', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'active_on', 'value' => 1), array('id' => 'active_off', 'value' => 0)))), 'submit' => array('title' => $this->l('Save')))), array('form' => array('legend' => array('title' => $this->l('Shop URL'), 'icon' => 'icon-shopping-cart'), 'input' => array(array('type' => 'text', 'label' => $this->l('Domain'), 'name' => 'domain', 'size' => 50), array('type' => 'text', 'label' => $this->l('Domain SSL'), 'name' => 'domain_ssl', 'size' => 50)), 'submit' => array('title' => $this->l('Save')))));
     if (!defined('_PS_HOST_MODE_')) {
         $this->fields_form[1]['form']['input'] = array_merge($this->fields_form[1]['form']['input'], array(array('type' => 'text', 'label' => $this->l('Physical URL'), 'name' => 'physical_uri', 'desc' => $this->l('This is the physical folder for your store on the server. Leave this field empty if your store is installed on the root path (e.g. if your store is available at www.my-prestashop.com/my-store/, you input my-store/ in this field).'), 'size' => 50)));
     }
     $this->fields_form[1]['form']['input'] = array_merge($this->fields_form[1]['form']['input'], array(array('type' => 'text', 'label' => $this->l('Virtual URL'), 'name' => 'virtual_uri', 'desc' => $desc_virtual_uri, 'size' => 50, 'hint' => !$update_htaccess ? $this->l('Warning: URL rewriting (e.g. mod_rewrite for Apache) seems to be disabled. If your URL doesn\'t work, please check with your host provider on how to activate URL rewriting.') : null), array('type' => 'text', 'label' => $this->l('Your final URL will be'), 'name' => 'final_url', 'size' => 76, 'readonly' => true)));
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     self::$currentIndex = self::$currentIndex . '&id_shop=' . $obj->id;
     $current_shop = Shop::initialize();
     $list_shop_with_url = array();
     foreach (Shop::getShops(false, null, true) as $id) {
         $list_shop_with_url[$id] = (bool) count(ShopUrl::getShopUrls($id));
     }
     $this->tpl_form_vars = array('js_shop_url' => Tools::jsonEncode($list_shop_with_url));
     $this->fields_value = array('domain' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'domain') : $current_shop->domain, 'domain_ssl' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'domain_ssl') : $current_shop->domain_ssl, 'physical_uri' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'physical_uri') : $current_shop->physical_uri, 'active' => true);
     return parent::renderForm();
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:27,代码来源:AdminShopUrlController.php

示例6: ajax_agile_getcustomers

function ajax_agile_getcustomers()
{
    ${${"GLOBALS"}["jjszcyoinwyy"]} = explode(" ", Tools::getValue("customer_search"));
    ${"GLOBALS"}["btkmsumgqi"] = "customers";
    $lwjbynsy = "searches";
    $mfzpveyc = "to_return";
    $bmwjhsn = "customers";
    ${"GLOBALS"}["mcqemkddxvk"] = "searches";
    $cccuivsxp = "to_return";
    ${${"GLOBALS"}["kglmxvwgfexa"]} = array();
    ${${"GLOBALS"}["mcqemkddxvk"]} = array_unique(${$lwjbynsy});
    foreach (${${"GLOBALS"}["jjszcyoinwyy"]} as ${${"GLOBALS"}["dotono"]}) {
        $mimdxaoxdl = "results";
        if (!empty(${${"GLOBALS"}["dotono"]}) && (${$mimdxaoxdl} = Customer::searchByName(${${"GLOBALS"}["dotono"]}))) {
            foreach (${${"GLOBALS"}["itmfakpwu"]} as ${${"GLOBALS"}["dbgjiec"]}) {
                ${"GLOBALS"}["cgwtffyvk"] = "result";
                ${${"GLOBALS"}["kglmxvwgfexa"]}[${${"GLOBALS"}["dbgjiec"]}["id_customer"]] = ${${"GLOBALS"}["cgwtffyvk"]};
            }
        }
    }
    if (count(${${"GLOBALS"}["btkmsumgqi"]})) {
        ${$cccuivsxp} = array("customers" => ${$bmwjhsn}, "found" => true);
    } else {
        ${$mfzpveyc} = array("found" => false);
    }
    return Tools::jsonEncode(${${"GLOBALS"}["nduihox"]});
}
开发者ID:sho5kubota,项目名称:guidingyou2,代码行数:27,代码来源:ajax_agile_getcustomers.php

示例7: getFields

 public function getFields()
 {
     if (parent::validateFields()) {
         ShopgateLogger::getInstance()->log('Validation for shopgate database fields invalid', ShopgateLogger::LOGTYPE_ERROR);
     }
     if ($this->shopgate_order instanceof ShopgateOrder) {
         $this->shopgate_order = pSQL(base64_encode(serialize($this->shopgate_order)));
     }
     if (is_array($this->comments)) {
         if (method_exists("Tools", "jsonEncode")) {
             $encodedData = Tools::jsonEncode($this->comments);
         } else {
             $encodedData = json_encode($this->comments);
         }
         $this->comments = pSQL(base64_encode($encodedData));
     } else {
         $this->comments = pSQL($this->comments);
     }
     $fields = array();
     $fields['id_cart'] = (int) $this->id_cart;
     $fields['id_order'] = (int) $this->id_order;
     $fields['shopgate_order'] = pSQL(base64_encode(serialize($this->shopgate_order)));
     $fields['order_number'] = pSQL($this->order_number);
     $fields['shipping_service'] = pSQL($this->shipping_service);
     $fields['shipping_cost'] = (double) $this->shipping_cost;
     $fields['shop_number'] = pSQL($this->shop_number);
     $fields['comments'] = $this->comments;
     $fields['status'] = (int) $this->status;
     $fields['tracking_number'] = pSQL($this->tracking_number);
     $fields['is_sent_to_shopgate'] = (int) $this->is_sent_to_shopgate;
     return $fields;
 }
开发者ID:pankajshoffex,项目名称:shoffex_prestashop,代码行数:32,代码来源:Order.php

示例8: run

 public function run()
 {
     $this->init();
     $this->preProcess();
     if (Tools::getValue('ajax') == 'true') {
         if (Tools::getIsset('summary')) {
             if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
                 if (self::$cookie->id_customer) {
                     $customer = new Customer((int) self::$cookie->id_customer);
                     $groups = $customer->getGroups();
                 } else {
                     $groups = array(1);
                 }
                 if ((int) self::$cart->id_address_delivery) {
                     $deliveryAddress = new Address((int) self::$cart->id_address_delivery);
                 }
                 $result = array('carriers' => Carrier::getCarriersForOrder((int) Country::getIdZone((isset($deliveryAddress) and (int) $deliveryAddress->id) ? (int) $deliveryAddress->id_country : (int) Configuration::get('PS_COUNTRY_DEFAULT')), $groups));
             }
             $result['summary'] = self::$cart->getSummaryDetails();
             $result['customizedDatas'] = Product::getAllCustomizedDatas((int) self::$cart->id);
             $result['HOOK_SHOPPING_CART'] = Module::hookExec('shoppingCart', $result['summary']);
             $result['HOOK_SHOPPING_CART_EXTRA'] = Module::hookExec('shoppingCartExtra', $result['summary']);
             die(Tools::jsonEncode($result));
         } else {
             $this->includeCartModule();
         }
     } else {
         $this->setMedia();
         $this->displayHeader();
         $this->process();
         $this->displayContent();
         $this->displayFooter();
     }
 }
开发者ID:hecbuma,项目名称:quali-fisioterapia,代码行数:34,代码来源:CartController.php

示例9: addQuickLink

 public function addQuickLink()
 {
     if (!isset($this->className) || empty($this->className)) {
         return false;
     }
     $this->validateRules();
     if (count($this->errors) <= 0) {
         $this->object = new $this->className();
         $this->copyFromPost($this->object, $this->table);
         $exists = Db::getInstance()->getValue('SELECT id_quick_access FROM ' . _DB_PREFIX_ . 'quick_access WHERE link = "' . pSQL($this->object->link) . '"');
         if ($exists) {
             return true;
         }
         $this->beforeAdd($this->object);
         if (method_exists($this->object, 'add') && !$this->object->add()) {
             $this->errors[] = Tools::displayError('An error occurred while creating an object.') . ' <b>' . $this->table . ' (' . Db::getInstance()->getMsgError() . ')</b>';
         } elseif (($_POST[$this->identifier] = $this->object->id) && $this->postImage($this->object->id) && !count($this->errors) && $this->_redirect) {
             PrestaShopLogger::addLog(sprintf($this->l('%s addition', 'AdminTab', false, false), $this->className), 1, null, $this->className, (int) $this->object->id, true, (int) $this->context->employee->id);
             $this->afterAdd($this->object);
         }
     }
     $this->errors = array_unique($this->errors);
     if (!empty($this->errors)) {
         $this->errors['has_errors'] = true;
         $this->ajaxDie(Tools::jsonEncode($this->errors));
         return false;
     }
     return $this->getQuickAccessesList();
 }
开发者ID:jpodracky,项目名称:dogs,代码行数:29,代码来源:AdminQuickAccessesController.php

示例10: loadPageDefault

 public static function loadPageDefault()
 {
     $langId = Context::getContext()->language->id;
     $shopId = Context::getContext()->shop->id;
     $groupID = intval($_POST['groupID']);
     $type = $_POST['type'];
     $itemId = intval($_POST['itemId']);
     $page = intval($_POST['page']);
     $itemWidth = intval($_POST['itemWidth']);
     $itemHeight = round($_POST['itemHeight'], 3);
     $css = 'width: ' . $itemWidth . 'px; height:' . $itemHeight . "px;";
     $group = DB::getInstance()->getRow("Select * From " . _DB_PREFIX_ . "groupcategory_groups Where id = " . $groupID);
     $response = '';
     $products = array();
     if ($group) {
         $module = new GroupCategory();
         $itemConfig = json_decode($group['itemConfig']);
         if (!$itemConfig->countItem || (int) $itemConfig->countItem <= 0) {
             $pageSize = 3;
         } else {
             $pageSize = $itemConfig->countItem;
         }
         $offset = $page * $pageSize;
         if ($itemId == 0) {
             $arrSubCategory = GroupCategoryLibraries::getCategoryIds($group['categoryId']);
             $arrSubCategory[] = $group['categoryId'];
             if ($type == 'saller') {
                 $products = GroupCategoryLibraries::getProducts_Sales($langId, $arrSubCategory, null, false, $pageSize, $offset);
             } elseif ($type == 'view') {
                 $products = GroupCategoryLibraries::getProducts_View($langId, $arrSubCategory, null, false, $pageSize, $offset);
             } elseif ($type == 'special') {
                 $products = GroupCategoryLibraries::getProducts_Special($langId, $arrSubCategory, null, false, $pageSize, $offset);
             } elseif ($type == 'arrival') {
                 $products = GroupCategoryLibraries::getProducts_AddDate($langId, $arrSubCategory, null, false, $pageSize, $offset);
             } else {
                 if ($group['type_default'] == 'saller') {
                     $products = GroupCategoryLibraries::getProducts_Sales($langId, $arrSubCategory, null, false, $pageSize, $offset);
                 } elseif ($group['type_default'] == 'view') {
                     $products = GroupCategoryLibraries::getProducts_View($langId, $arrSubCategory, null, false, $pageSize, $offset);
                 } elseif ($group['type_default'] == 'special') {
                     $products = GroupCategoryLibraries::getProducts_Special($langId, $arrSubCategory, null, false, $pageSize, $offset);
                 } else {
                     $products = GroupCategoryLibraries::getProducts_AddDate($langId, $arrSubCategory, null, false, $pageSize, $offset);
                 }
             }
         } else {
             $item = DB::getInstance()->getRow("Select * From " . _DB_PREFIX_ . "groupcategory_items Where id = " . $itemId);
             if ($item) {
                 $arrSubCategory = GroupCategoryLibraries::getCategoryIds($item['categoryId']);
                 $arrSubCategory[] = $item['categoryId'];
                 $products = GroupCategoryLibraries::getProducts_AddDate($langId, $arrSubCategory, null, false, $pageSize, $offset);
             }
         }
         if ($products) {
             $response = $module->generationHtml_default($products, $css);
         }
     }
     die(Tools::jsonEncode($response));
 }
开发者ID:abdoumej,项目名称:libsamy,代码行数:59,代码来源:front-end-ajax.php

示例11: processBulkcssexport

 public function processBulkcssexport()
 {
     $order_box = Tools::getValue('orderBox');
     if (empty($order_box)) {
         $this->displayWarning($this->l('You must selected orders for the export'));
         return;
     }
     Tools::redirectAdmin('../modules/chronopost/importExport.php?shared_secret=' . Configuration::get('CHRONOPOST_SECRET') . '&cible=CSS&orders=' . implode(';', Tools::getValue('orderBox')) . '&multi=' . addslashes(Tools::jsonEncode(Tools::getValue('multi'))));
 }
开发者ID:rcollard,项目名称:chronopost,代码行数:9,代码来源:AdminExportChronopost.php

示例12: ajaxProcessGamificationTasks

 public function ajaxProcessGamificationTasks()
 {
     if (!Configuration::get('GF_INSTALL_CALC')) {
         $this->processRefreshData();
         $this->processInstallCalculation();
         Configuration::updateGlobalValue('GF_INSTALL_CALC', 1);
     }
     die(Tools::jsonEncode(array('refresh_data' => $this->processRefreshData(), 'daily_calculation' => $this->processMakeDailyCalculation(), 'advice_validation' => $this->processAdviceValidation(), 'advices_to_display' => $this->processGetAdvicesToDisplay(), 'level_badge_validation' => $this->processLevelAndBadgeValidation(), 'header_notification' => $this->module->renderHeaderNotification())));
 }
开发者ID:rongandat,项目名称:vatfairfoot,代码行数:9,代码来源:AdminGamificationController.php

示例13: setErrorMessage

 public function setErrorMessage($message)
 {
     $old_message = $this->cookie->{self::DPD_GROUP_ERROR_MESSAGE};
     if ($old_message && Validate::isSerializedArray($old_message)) {
         $old_message = Tools::jsonDecode($old_message);
         $message = array_merge($message, $old_message);
     }
     $this->cookie->{self::DPD_GROUP_ERROR_MESSAGE} = is_array($message) ? Tools::jsonEncode($message) : $message;
 }
开发者ID:remixaz,项目名称:dpdgroup,代码行数:9,代码来源:Messages.controller.php

示例14: update

 protected function update()
 {
     if (Tools::isSubmit('saveBtn')) {
         $config = [];
         $config['show_barcode'] = Tools::getValue('show_barcode');
         Configuration::updateValue($this->name, Tools::jsonEncode($config));
         return $this->displayConfirmation('Settings updated');
     }
 }
开发者ID:villers,项目名称:PHP_avance_II_My_Presta,代码行数:9,代码来源:mylabelgenerator.php

示例15: initContent

 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     $original_query = Tools::getValue('q');
     $query = Tools::replaceAccentedChars(urldecode($original_query));
     if ($this->ajax_search) {
         $searchResults = Search::find((int) Tools::getValue('id_lang'), $query, 1, 10, 'position', 'desc', true);
         if (is_array($searchResults)) {
             foreach ($searchResults as &$product) {
                 $product['product_link'] = $this->context->link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']);
             }
             Hook::exec('actionSearch', array('expr' => $query, 'total' => count($searchResults)));
         }
         $this->ajaxDie(Tools::jsonEncode($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)) {
         $this->productSort();
         $this->n = abs((int) Tools::getValue('n', $product_per_page));
         $this->p = abs((int) Tools::getValue('p', 1));
         $search = Search::find($this->context->language->id, $query, 1, 10, 'position', 'desc');
         Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
         $nbProducts = $search['total'];
         $this->pagination($nbProducts);
         $this->addColorsToProductList($search['result']);
         $this->context->smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $original_query, 'instant_search' => $this->instant_search, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
     } elseif (($query = Tools::getValue('search_query', Tools::getValue('ref'))) && !is_array($query)) {
         $this->productSort();
         $this->n = abs((int) Tools::getValue('n', $product_per_page));
         $this->p = abs((int) Tools::getValue('p', 1));
         $original_query = $query;
         $query = Tools::replaceAccentedChars(urldecode($query));
         $search = Search::find($this->context->language->id, $query, $this->p, $this->n, $this->orderBy, $this->orderWay);
         if (is_array($search['result'])) {
             foreach ($search['result'] as &$product) {
                 $product['link'] .= (strpos($product['link'], '?') === false ? '?' : '&') . 'search_query=' . urlencode($query) . '&results=' . (int) $search['total'];
             }
         }
         Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
         $nbProducts = $search['total'];
         $this->pagination($nbProducts);
         $this->addColorsToProductList($search['result']);
         $this->context->smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $original_query, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
     } elseif (($tag = urldecode(Tools::getValue('tag'))) && !is_array($tag)) {
         $nbProducts = (int) Search::searchTag($this->context->language->id, $tag, true);
         $this->pagination($nbProducts);
         $result = Search::searchTag($this->context->language->id, $tag, false, $this->p, $this->n, $this->orderBy, $this->orderWay);
         Hook::exec('actionSearch', array('expr' => $tag, 'total' => count($result)));
         $this->addColorsToProductList($result);
         $this->context->smarty->assign(array('search_tag' => $tag, 'products' => $result, 'search_products' => $result, 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
     } else {
         $this->context->smarty->assign(array('products' => array(), 'search_products' => array(), 'pages_nb' => 1, 'nbProducts' => 0));
     }
     $this->context->smarty->assign(array('add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
     $this->setTemplate(_PS_THEME_DIR_ . 'search.tpl');
 }
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:61,代码来源:SearchController.php


注:本文中的Tools::jsonEncode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。