function smartyModifierPPSafeoutput($string, $type = null) { if ($type === null) { $type = 'html'; } switch ($type) { case 'html': return PP::safeOutput($string); case 'js': case 'javascript': return PP::safeOutputJS($string); case 'value': return PP::safeOutputValue($string); default: return $string; } }
public function checkReplacedStringsAndReport($filename, $param, $key = null) { $result = $this->checkReplacedStrings($filename, $param); $length = count($result); if ($length > 0) { $key = $key == null ? $this->module->l('Files integration') : $key; $test_results = array(); $notes = array(); for ($i = 0; $i < $length; $i++) { foreach ($result[$i] as $type => $value) { $info = ''; $details = ''; $note = false; switch ($type) { case 'file_not_found': $info = '<span class="warning"> ' . $this->module->l('(file not found)') . '</span>'; break; case 'string_not_found': $info = $this->notWritableWarning($filename); if (Tools::strlen($info) == 0) { $info = '<span class="warning"> ' . $this->module->l('(string not found)') . '</span>'; $details = '<br><span class="warning-details"><span class="warning">' . $this->module->l('searching for:') . ' </span>' . PP::safeOutput(mb_strimwidth($value[0], 0, 150, ' ...')) . '</span>' . '<br><span class="warning-details"><span class="warning">' . $this->module->l('replace with:') . ' </span>' . PP::safeOutput(mb_strimwidth($value[1], 0, 150, ' ...')) . '</span>'; } break; case 'string_not_found_note': $note = true; $info = $this->notWritableWarning($filename); if (Tools::strlen($info) == 0) { $info = '<span class="note"> ' . $this->module->l('(optional string not found, no action required)') . '</span>'; $details = '<br><span class="note-details"><span class="note">' . $this->module->l('searching for:') . ' </span>' . PP::safeOutput(mb_strimwidth($value[0], 0, 150, ' ...')) . '</span>' . '<br><span class="note-details"><span class="note">' . $this->module->l('replace with:') . ' </span>' . PP::safeOutput(mb_strimwidth($value[1], 0, 150, ' ...')) . '</span>'; } break; case 'string_count': $info = $this->notWritableWarning($filename); if (Tools::strlen($info) == 0) { $info = '<span class="warning"> ' . sprintf($this->module->l('(string expected to be found %d times, found %d times)'), $value[2], $value[3]) . '</span>'; $details = '<br><span class="warning-details"><span class="warning">' . $this->module->l('searching for:') . ' </span>' . PP::safeOutput(mb_strimwidth($value[0], 0, 150, ' ...')) . '</span>' . '<br><span class="warning-details"><span class="warning">' . $this->module->l('replace with:') . ' </span>' . PP::safeOutput(mb_strimwidth($value[1], 0, 150, ' ...')) . '</span>'; } break; default: break; } $str = sprintf($note ? $this->module->l('String replacement note for file: %s%s') : $this->module->l('String replacement warning for file: %s%s'), PSM::normalizePath($filename, 'relative'), $info); if (!in_array($str, $note ? $notes : $test_results)) { if ($note) { $notes[] = $str; } else { $test_results[] = $str; } } if (Tools::strlen($details) > 0) { if ($note) { $notes[] = $details; } else { $test_results[] = $details; } } } } if (count($test_results)) { $str = implode($test_results); if (!isset($this->module->integration_test_result[$key]) || !in_array($str, $this->module->integration_test_result[$key])) { $this->module->integration_test_result[$key][] = $str; } } if (count($notes)) { if (!isset($this->module->integration_test_result_notes)) { $this->module->integration_test_result_notes = array(); } $str = implode($notes); if (!isset($this->module->integration_test_result_notes[$key]) || !in_array($str, $this->module->integration_test_result_notes[$key])) { $this->module->integration_test_result_notes[$key][] = $str; } } return false; } return true; }
private function getTemplatesTabHtml() { $helper = $this->createTemplate('templates'); $helper->tpl_vars['integrated'] = $this->integrated; if ($this->integrated) { $templates = PP::getTemplates(); $buy_block_text = array(); foreach ($templates as &$template) { $display_mode = array(); if (($template['pp_display_mode'] & 1) == 1) { $display_mode[] = 1; } if (($template['pp_display_mode'] & 2) == 2) { $display_mode[] = 2; } if (($template['pp_display_mode'] & 4) == 4) { $display_mode[] = 3; } $template['display_mode'] = implode(',', $display_mode); if ($template['pp_explanation']) { $buy_block_text[$template['pp_bo_buy_block_index']] = PP::safeOutputLenient($template['pp_explanation']); } } ksort($buy_block_text, SORT_NUMERIC); $helper->tpl_vars['templates'] = PP::safeOutput($templates); $helper->tpl_vars['buy_block_text'] = $buy_block_text; $translations = $this->getTranslations('EditTemplate'); $helper->tpl_vars['display_mode_text'] = array($translations['s_pp_display_mode_1_long'], $translations['s_pp_display_mode_2'], $translations['s_pp_display_mode_4']); } else { $helper->tpl_vars['integration_message'] = $this->getTabIntegrationWarning(); } return $helper->generate(); }
public static function smartyConvertPrice($params, &$smarty = null) { $currency = self::smartyGetCurrency($params); $price = array_key_exists('price', $params) ? $params['price'] : null; $product = array_key_exists('product', $params) ? $params['product'] : self::$smarty_product; if ($product != null) { $product_properties = PP::getProductProperties($product); $mode = array_key_exists('m', $params) ? $params['m'] : null; list($key, $price) = PP::calcProductDisplayPrice($product, $product_properties, $price, $mode); $display = is_numeric($price) ? Tools::displayPrice($price, $currency) : ($price === null ? 0 : $price); if ($key) { $display .= ' <span class="' . $key . '">' . PP::safeOutput($product_properties[$key]) . '</span>'; } } else { $display = Tools::displayPrice($price === null ? 0 : $price, $currency); } return $display; }
public function ajaxProcessSearchProducts() { Context::getContext()->customer = new Customer((int) Tools::getValue('id_customer')); $currency = new Currency((int) Tools::getValue('id_currency')); if ($products = Product::searchByName((int) $this->context->language->id, pSQL(Tools::getValue('product_search')))) { foreach ($products as &$product) { // Formatted price $product['formatted_price'] = Tools::displayPrice(Tools::convertPrice($product['price_tax_incl'], $currency), $currency); // Concret price $product['price_tax_incl'] = Tools::ps_round(Tools::convertPrice($product['price_tax_incl'], $currency), 2); $product['price_tax_excl'] = Tools::ps_round(Tools::convertPrice($product['price_tax_excl'], $currency), 2); $productObj = new Product((int) $product['id_product'], false, (int) $this->context->language->id); $combinations = array(); $product["pproperties"] = PP::safeOutput($productObj->productProperties()); $attributes = $productObj->getAttributesGroups((int) $this->context->language->id); // Tax rate for this customer if (Tools::isSubmit('id_address')) { $product['tax_rate'] = $productObj->getTaxesRate(new Address(Tools::getValue('id_address'))); } $product['warehouse_list'] = array(); foreach ($attributes as $attribute) { if (!isset($combinations[$attribute['id_product_attribute']]['attributes'])) { $combinations[$attribute['id_product_attribute']]['attributes'] = ''; } $combinations[$attribute['id_product_attribute']]['attributes'] .= $attribute['attribute_name'] . ' - '; $combinations[$attribute['id_product_attribute']]['id_product_attribute'] = $attribute['id_product_attribute']; $combinations[$attribute['id_product_attribute']]['default_on'] = $attribute['default_on']; if (!isset($combinations[$attribute['id_product_attribute']]['price'])) { $price_tax_incl = Product::getPriceStatic((int) $product['id_product'], true, $attribute['id_product_attribute']); $price_tax_excl = Product::getPriceStatic((int) $product['id_product'], false, $attribute['id_product_attribute']); $combinations[$attribute['id_product_attribute']]['price_tax_incl'] = Tools::ps_round(Tools::convertPrice($price_tax_incl, $currency), 2); $combinations[$attribute['id_product_attribute']]['price_tax_excl'] = Tools::ps_round(Tools::convertPrice($price_tax_excl, $currency), 2); $combinations[$attribute['id_product_attribute']]['formatted_price'] = Tools::displayPrice(Tools::convertPrice($price_tax_excl, $currency), $currency); } if (!isset($combinations[$attribute['id_product_attribute']]['qty_in_stock'])) { $combinations[$attribute['id_product_attribute']]['qty_in_stock'] = StockAvailable::getQuantityAvailableByProduct((int) $product['id_product'], $attribute['id_product_attribute'], (int) $this->context->shop->id); } if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && (int) $product['advanced_stock_management'] == 1) { $product['warehouse_list'][$attribute['id_product_attribute']] = Warehouse::getProductWarehouseList($product['id_product'], $attribute['id_product_attribute']); } else { $product['warehouse_list'][$attribute['id_product_attribute']] = array(); } $product['stock'][$attribute['id_product_attribute']] = Product::getRealQuantity($product['id_product'], $attribute['id_product_attribute']); } if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && (int) $product['advanced_stock_management'] == 1) { $product['warehouse_list'][0] = Warehouse::getProductWarehouseList($product['id_product']); } else { $product['warehouse_list'][0] = array(); } $product['stock'][0] = StockAvailable::getQuantityAvailableByProduct((int) $product['id_product'], 0, (int) $this->context->shop->id); foreach ($combinations as &$combination) { $combination['attributes'] = rtrim($combination['attributes'], ' - '); } $product['combinations'] = $combinations; if ($product['customizable']) { $product_instance = new Product((int) $product['id_product']); $product['customization_fields'] = $product_instance->getCustomizationFields($this->context->language->id); } } $to_return = array('products' => $products, 'found' => true); } else { $to_return = array('found' => false); } $this->content = Tools::jsonEncode($to_return); }