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


PHP Tools::replaceAccentedChars方法代码示例

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


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

示例1: str2url

 public static function str2url($str)
 {
     static $allow_accented_chars = null;
     if ($allow_accented_chars === null) {
         $allow_accented_chars = Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
     }
     $str = trim($str);
     if (function_exists('mb_strtolower')) {
         $str = mb_strtolower($str, 'utf-8');
     }
     if (!$allow_accented_chars) {
         $str = Tools::replaceAccentedChars($str);
     }
     // Remove all non-whitelist chars.
     if ($allow_accented_chars) {
         $str = preg_replace('/[^a-zA-Z0-9\\s\'\\:\\/\\[\\]-\\pL\\pM]/u', '', $str);
     } else {
         $str = preg_replace('/[^a-zA-Z0-9\\s\'\\:\\/\\[\\]-]/', '', $str);
     }
     $str = preg_replace('/[\\s\'\\:\\/\\[\\]-]+/', ' ', $str);
     $str = str_replace(array(' ', '/'), '-', $str);
     // If it was not possible to lowercase the string with mb_strtolower, we do it after the transformations.
     // This way we lose fewer special chars.
     if (!function_exists('mb_strtolower')) {
         $str = strtolower($str);
     }
     return $str;
 }
开发者ID:nokaek,项目名称:Easy-Fix-Thai-PrestaShop-15,代码行数:28,代码来源:Tools.php

示例2: 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

示例3: add

 public function add($autodate = true, $nullValues = false)
 {
     $this->alias = Tools::replaceAccentedChars($this->alias);
     $this->search = Tools::replaceAccentedChars($this->search);
     if (parent::add($autodate, $nullValues)) {
         // Set cache of feature detachable to true
         Configuration::updateGlobalValue('PS_ALIAS_FEATURE_ACTIVE', '1');
         return true;
     }
     return false;
 }
开发者ID:nmardones,项目名称:PrestaShop,代码行数:11,代码来源:Alias.php

示例4: str2url

 public static function str2url($str)
 {
     $str = trim($str);
     if (function_exists('mb_strtolower')) {
         $str = mb_strtolower($str, 'utf-8');
     }
     $str = Tools::replaceAccentedChars($str);
     $str = preg_replace('/[^a-zA-Z0-9\\s\'\\:\\/\\[\\]-]/', '', $str);
     $str = preg_replace('/[\\s\'\\:\\/\\[\\]\\-]+/', ' ', $str);
     $str = str_replace(array(' ', '/'), '-', $str);
     return $str;
 }
开发者ID:kinkinweb,项目名称:lhvb,代码行数:12,代码来源:Tools.php

示例5: initContent

 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $query = Tools::replaceAccentedChars(urldecode(Tools::getValue('q')));
     if ($this->ajax_search) {
         $searchResults = Search::find((int) Tools::getValue('id_lang'), $query, 1, 10, 'position', 'desc', true);
         foreach ($searchResults as &$product) {
             $product['product_link'] = $this->context->link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']);
         }
         die(Tools::jsonEncode($searchResults));
     }
     if ($this->instant_search && !is_array($query)) {
         $this->productSort();
         $this->n = abs((int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_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->context->smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $query, 'instant_search' => $this->instant_search, 'homeSize' => Image::getSize('home_default')));
     } else {
         if (($query = Tools::getValue('search_query', Tools::getValue('ref'))) && !is_array($query)) {
             $this->productSort();
             $this->n = abs((int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')));
             $this->p = abs((int) Tools::getValue('p', 1));
             $search = Search::find($this->context->language->id, $query, $this->p, $this->n, $this->orderBy, $this->orderWay);
             Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
             $nbProducts = $search['total'];
             $this->pagination($nbProducts);
             $this->context->smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $query, 'homeSize' => Image::getSize('home_default')));
         } else {
             if (($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->context->smarty->assign(array('search_tag' => $tag, 'products' => $result, 'search_products' => $result, 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize('home_default')));
             } 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:rrameshsat,项目名称:Prestashop,代码行数:49,代码来源:SearchController.php

示例6: str2url

 public static function str2url($str)
 {
     if (function_exists('mb_strtolower')) {
         $str = mb_strtolower($str, 'utf-8');
     }
     $str = trim($str);
     if (!function_exists('mb_strtolower')) {
         $str = Tools::replaceAccentedChars($str);
     }
     // Remove all non-whitelist chars.
     $str = preg_replace('/[^a-zA-Z0-9\\s\'\\:\\/\\[\\]-\\pL\\pM]/u', '', $str);
     $str = preg_replace('/[\\s\'\\:\\/\\[\\]-]+/', ' ', $str);
     $str = str_replace(array(' ', '/'), '-', $str);
     // If it was not possible to lowercase the string with mb_strtolower, we do it after the transformations.
     // This way we lose fewer special chars.
     if (!function_exists('mb_strtolower')) {
         $str = strtolower($str);
     }
     return $str;
 }
开发者ID:nokaek,项目名称:Easy-Fix-Thai-PrestaShop-15,代码行数:20,代码来源:Tools.php

示例7: ps16012_update_alias

function ps16012_update_alias()
{
    $step = 3000;
    $count_alias = Db::getInstance()->getValue('SELECT count(id_alias) FROM ' . _DB_PREFIX_ . 'alias');
    $nb_loop = $start = 0;
    if ($count_alias > 0) {
        $nb_loop = ceil($count_alias / $step);
    }
    for ($i = 0; $i < $nb_loop; $i++) {
        $sql = 'SELECT id_alias, alias, search FROM `' . _DB_PREFIX_ . 'alias`';
        $start = intval(($i + 1) * $step);
        if ($aliass = Db::getInstance()->query($sql)) {
            while ($alias = Db::getInstance()->nextRow($aliass)) {
                if (is_array($alias)) {
                    Db::getInstance()->execute('
					UPDATE `' . _DB_PREFIX_ . 'alias`
					SET alias = \'' . pSQL(Tools::replaceAccentedChars($alias['alias'])) . '\',
					search = \'' . pSQL(Tools::replaceAccentedChars($alias['search'])) . '\'
					WHERE id_alias = ' . (int) $alias['id_alias']);
                }
            }
        }
    }
}
开发者ID:sowerr,项目名称:PrestaShop,代码行数:24,代码来源:ps16012_update_alias.php

示例8: str2url

 /**
  * Return a friendly url made from the provided string
  * If the mbstring library is available, the output is the same as the js function of the same name
  *
  * @param string $str
  * @return string
  */
 public static function str2url($str)
 {
     static $array_str = array();
     static $allow_accented_chars = null;
     static $has_mb_strtolower = null;
     if ($has_mb_strtolower === null) {
         $has_mb_strtolower = function_exists('mb_strtolower');
     }
     if (isset($array_str[$str])) {
         return $array_str[$str];
     }
     if (!is_string($str)) {
         return false;
     }
     if ($str == '') {
         return '';
     }
     if ($allow_accented_chars === null) {
         $allow_accented_chars = Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
     }
     $return_str = trim($str);
     if ($has_mb_strtolower) {
         $return_str = mb_strtolower($return_str, 'utf-8');
     }
     if (!$allow_accented_chars) {
         $return_str = Tools::replaceAccentedChars($return_str);
     }
     // Remove all non-whitelist chars.
     if ($allow_accented_chars) {
         $return_str = preg_replace('/[^a-zA-Z0-9\\s\'\\:\\/\\[\\]\\-\\p{L}]/u', '', $return_str);
     } else {
         $return_str = preg_replace('/[^a-zA-Z0-9\\s\'\\:\\/\\[\\]\\-]/', '', $return_str);
     }
     $return_str = preg_replace('/[\\s\'\\:\\/\\[\\]\\-]+/', ' ', $return_str);
     $return_str = str_replace(array(' ', '/'), '-', $return_str);
     // If it was not possible to lowercase the string with mb_strtolower, we do it after the transformations.
     // This way we lose fewer special chars.
     if (!$has_mb_strtolower) {
         $return_str = Tools::strtolower($return_str);
     }
     $array_str[$str] = $return_str;
     return $return_str;
 }
开发者ID:jpodracky,项目名称:dogs,代码行数:50,代码来源:Tools.php

示例9: replaceAccentedChars

 private function replaceAccentedChars($text)
 {
     if (version_compare(_PS_VERSION_, '1.4.5.1', '>=')) {
         return Tools::replaceAccentedChars($text);
     }
     $patterns = array('/[\\x{00E0}\\x{00E1}\\x{00E2}\\x{00E3}\\x{00E4}\\x{00E5}\\x{0101}\\x{0103}\\x{0105}\\x{0430}]/u', '/[\\x{0431}]/u', '/[\\x{00E7}\\x{0107}\\x{0109}\\x{010D}\\x{0446}]/u', '/[\\x{010F}\\x{0111}\\x{0434}]/u', '/[\\x{00E8}\\x{00E9}\\x{00EA}\\x{00EB}\\x{0113}\\x{0115}\\x{0117}\\x{0119}\\x{011B}\\x{0435}\\x{044D}]/u', '/[\\x{0444}]/u', '/[\\x{011F}\\x{0121}\\x{0123}\\x{0433}\\x{0491}]/u', '/[\\x{0125}\\x{0127}]/u', '/[\\x{00EC}\\x{00ED}\\x{00EE}\\x{00EF}\\x{0129}\\x{012B}\\x{012D}\\x{012F}\\x{0131}\\x{0438}\\x{0456}]/u', '/[\\x{0135}\\x{0439}]/u', '/[\\x{0137}\\x{0138}\\x{043A}]/u', '/[\\x{013A}\\x{013C}\\x{013E}\\x{0140}\\x{0142}\\x{043B}]/u', '/[\\x{043C}]/u', '/[\\x{00F1}\\x{0144}\\x{0146}\\x{0148}\\x{0149}\\x{014B}\\x{043D}]/u', '/[\\x{00F2}\\x{00F3}\\x{00F4}\\x{00F5}\\x{00F6}\\x{00F8}\\x{014D}\\x{014F}\\x{0151}\\x{043E}]/u', '/[\\x{043F}]/u', '/[\\x{0155}\\x{0157}\\x{0159}\\x{0440}]/u', '/[\\x{015B}\\x{015D}\\x{015F}\\x{0161}\\x{0441}]/u', '/[\\x{00DF}]/u', '/[\\x{0163}\\x{0165}\\x{0167}\\x{0442}]/u', '/[\\x{00F9}\\x{00FA}\\x{00FB}\\x{00FC}\\x{0169}\\x{016B}\\x{016D}\\x{016F}\\x{0171}\\x{0173}\\x{0443}]/u', '/[\\x{0432}]/u', '/[\\x{0175}]/u', '/[\\x{00FF}\\x{0177}\\x{00FD}\\x{044B}]/u', '/[\\x{017A}\\x{017C}\\x{017E}\\x{0437}]/u', '/[\\x{00E6}]/u', '/[\\x{0447}]/u', '/[\\x{0445}]/u', '/[\\x{0153}]/u', '/[\\x{0448}]/u', '/[\\x{0449}]/u', '/[\\x{044F}]/u', '/[\\x{0454}]/u', '/[\\x{0457}]/u', '/[\\x{0451}]/u', '/[\\x{044E}]/u', '/[\\x{0436}]/u', '/[\\x{0100}\\x{0102}\\x{0104}\\x{00C0}\\x{00C1}\\x{00C2}\\x{00C3}\\x{00C4}\\x{00C5}\\x{0410}]/u', '/[\\x{0411}]]/u', '/[\\x{00C7}\\x{0106}\\x{0108}\\x{010A}\\x{010C}\\x{0426}]/u', '/[\\x{010E}\\x{0110}\\x{0414}]/u', '/[\\x{00C8}\\x{00C9}\\x{00CA}\\x{00CB}\\x{0112}\\x{0114}\\x{0116}\\x{0118}\\x{011A}\\x{0415}\\x{042D}]/u', '/[\\x{0424}]/u', '/[\\x{011C}\\x{011E}\\x{0120}\\x{0122}\\x{0413}\\x{0490}]/u', '/[\\x{0124}\\x{0126}]/u', '/[\\x{0128}\\x{012A}\\x{012C}\\x{012E}\\x{0130}\\x{0418}\\x{0406}]/u', '/[\\x{0134}\\x{0419}]/u', '/[\\x{0136}\\x{041A}]/u', '/[\\x{0139}\\x{013B}\\x{013D}\\x{0139}\\x{0141}\\x{041B}]/u', '/[\\x{041C}]/u', '/[\\x{00D1}\\x{0143}\\x{0145}\\x{0147}\\x{014A}\\x{041D}]/u', '/[\\x{00D3}\\x{014C}\\x{014E}\\x{0150}\\x{041E}]/u', '/[\\x{041F}]/u', '/[\\x{0154}\\x{0156}\\x{0158}\\x{0420}]/u', '/[\\x{015A}\\x{015C}\\x{015E}\\x{0160}\\x{0421}]/u', '/[\\x{0162}\\x{0164}\\x{0166}\\x{0422}]/u', '/[\\x{00D9}\\x{00DA}\\x{00DB}\\x{00DC}\\x{0168}\\x{016A}\\x{016C}\\x{016E}\\x{0170}\\x{0172}\\x{0423}]/u', '/[\\x{0412}]/u', '/[\\x{0174}]/u', '/[\\x{0176}\\x{042B}]/u', '/[\\x{0179}\\x{017B}\\x{017D}\\x{0417}]/u', '/[\\x{00C6}]/u', '/[\\x{0427}]/u', '/[\\x{0425}]/u', '/[\\x{0152}]/u', '/[\\x{0428}]/u', '/[\\x{0429}]/u', '/[\\x{042F}]/u', '/[\\x{0404}]/u', '/[\\x{0407}]/u', '/[\\x{0401}]/u', '/[\\x{042E}]/u', '/[\\x{0416}]/u');
     // ö to oe
     // å to aa
     // ä to ae
     $replacements = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 'ss', 't', 'u', 'v', 'w', 'y', 'z', 'ae', 'ch', 'kh', 'oe', 'sh', 'shh', 'ya', 'ye', 'yi', 'yo', 'yu', 'zh', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'V', 'W', 'Y', 'Z', 'AE', 'CH', 'KH', 'OE', 'SH', 'SHH', 'YA', 'YE', 'YI', 'YO', 'YU', 'ZH');
     return preg_replace($patterns, $replacements, $text);
 }
开发者ID:tomideru,项目名称:PrestaShop-modules,代码行数:12,代码来源:seur.php

示例10: fillProductArray

 /**
  * @param $product_array
  * @param $weight_array
  * @param $key
  * @param $value
  * @param $id_lang
  * @param $iso_code
  */
 protected static function fillProductArray(&$product_array, $weight_array, $key, $value, $id_lang, $iso_code)
 {
     if (strncmp($key, 'id_', 3) && isset($weight_array[$key])) {
         $words = explode(' ', Search::sanitize($value, (int) $id_lang, true, $iso_code));
         foreach ($words as $word) {
             if (!empty($word)) {
                 $word = Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH);
                 // Remove accents
                 $word = Tools::replaceAccentedChars($word);
                 if (!isset($product_array[$word])) {
                     $product_array[$word] = 0;
                 }
                 $product_array[$word] += $weight_array[$key];
             }
         }
     }
 }
开发者ID:nmardones,项目名称:PrestaShop,代码行数:25,代码来源:Search.php

示例11: cleaner

 static function cleaner($string)
 {
     return Tools::replaceAccentedChars($string);
 }
开发者ID:simonbonjean,项目名称:PrestaSuperTool-Api,代码行数:4,代码来源:PstToolsHelper.php

示例12: renderList

 public function renderList()
 {
     $this->toolbar_title = $this->l('Order Management');
     $statuses_array = array();
     $statuses = ErpOrderState::getOrderStates((int) $this->context->language->id);
     foreach ($statuses as $status) {
         $statuses_array[$status['id_order_state']] = $status['name'];
     }
     require_once _PS_MODULE_DIR_ . 'erpillicopresta/models/ErpFeature.php';
     $this->context->smarty->assign(array('token_mr' => ModuleCore::isEnabled('mondialrelay') ? MondialRelay::getToken('back') : 'false', 'token_expeditor' => ModuleCore::isEnabled('expeditor') ? Tools::getAdminToken('AdminExpeditor' . (int) Tab::getIdFromClassName('AdminExpeditor') . (int) $this->context->employee->id) : 'false', 'id_employee' => (int) $this->context->employee->id, 'order_statuses' => $statuses_array, 'controller_status' => $this->controller_status, 'erp_feature' => ErpFeature::getFeaturesWithToken($this->context->language->iso_code), 'template_path' => $this->template_path, 'expeditor_status' => Configuration::get('EXPEDITOR_STATE_EXP'), '_module_dir_' => _MODULE_DIR_));
     $this->tpl_list_vars['has_bulk_actions'] = 'true';
     // handle may contain error messages
     $handle = Tools::getValue('handle');
     switch (trim($handle)) {
         case '':
             break;
         case 'false':
             $this->confirmations[] = $this->l('All orders have been updated') . '<br/>';
             break;
         default:
             if (!empty($handle)) {
                 // $handle = str_replace('u00e9', 'é', $handle);
                 // $handle = str_replace('u00ea', 'ê', $handle);
                 $handle = Tools::replaceAccentedChars($handle);
                 // We take note about orders with error: no valid carrier (split on order number #)
                 $orderWithoutShipping = strstr($handle, '#') != false ? true : false;
                 $errors = explode('<br/>', str_replace('#', '<br/>', $handle));
                 foreach ($errors as $key => $error) {
                     if (!empty($error)) {
                         if (!$orderWithoutShipping) {
                             $message = $error;
                         } else {
                             $message = $error;
                         }
                         $this->errors[] = Tools::displayError($message);
                     }
                 }
             }
             break;
     }
     if (Tools::getValue('linkPDF') != '' && Tools::getValue('newState') != '') {
         // if state need invoice generation
         if (ErpOrderState::invoiceAvailable(Tools::getValue('newState'))) {
             $pdf_link = new Link();
             $pdf_link = $pdf_link->getAdminLink("AdminAdvancedOrder", true) . '&submitAction=generateInvoicesPDF3&id_orders=' . Tools::getValue('linkPDF');
             $this->confirmations[] = '&nbsp;<a target="_blank" href="' . $pdf_link . '" alt="invoices">' . $this->l('Download all invoices') . '<br/></a>';
         }
         // if state need delivery slip generation
         if (ErpOrderState::deliverySlipAvailable(Tools::getValue('newState'))) {
             $pdf_link = new Link();
             $pdf_link = $pdf_link->getAdminLink("AdminAdvancedOrder", true) . '&submitAction=generateDeliverySlipsPDF2&id_orders=' . Tools::getValue('linkPDF');
             $this->confirmations[] = '&nbsp;<a target="_blank" href="' . $pdf_link . '" alt="delivery">' . $this->l('Download all delivery slip') . '<br/></a>';
         }
     }
     if (Tools::getValue('linkPDFPrint') != '') {
         if ($this->controller_status == STATUS1 && count(explode(',', Tools::getValue('linkPDFPrint'))) > ERP_ORDERFR) {
             $this->informations[] = sprintf($this->l('You are using the free version of 1-Click ERP which limits the possible number of documents to print to %d orders'), ERP_ORDERFR);
         } else {
             $invoices = '';
             $delivery = '';
             foreach (explode(',', Tools::getValue('linkPDFPrint')) as $id_order) {
                 if (ErpOrderState::invoiceAvailable(ErpOrder::getIdStateByIdOrder($id_order))) {
                     $invoices .= $id_order . ',';
                 }
                 if (ErpOrderState::deliverySlipAvailable(ErpOrder::getIdStateByIdOrder($id_order))) {
                     $delivery .= $id_order . ',';
                 }
             }
             if ($invoices != '') {
                 $pdf_link = new Link();
                 $pdf_link = $pdf_link->getAdminLink("AdminAdvancedOrder", true) . '&submitAction=generateInvoicesPDF3&id_orders=' . Tools::substr($invoices, 0, -1);
                 $this->confirmations[] = '&nbsp;<a target="_blank" href="' . $pdf_link . '" alt="invoices">' . $this->l('Download all invoices') . '</br></a>';
             }
             if ($delivery != '') {
                 $pdf_link = new Link();
                 $pdf_link = $pdf_link->getAdminLink("AdminAdvancedOrder", true) . '&submitAction=generateDeliverySlipsPDF2&id_orders=' . Tools::substr($delivery, 0, -1);
                 $this->confirmations[] = '&nbsp;<a target="_blank" href="' . $pdf_link . '" alt="delivery">' . $this->l('Download all delivery slip') . '</br></a>';
             }
             if ($invoices == '' && $delivery == '') {
                 $this->errors[] = $this->l('The selected orders have no invoice or delivery !') . '<br/>';
             }
         }
     }
     if (Tools::getValue('etiquettesMR') != '') {
         // Downlad all pdf and zip then delete and display link to zip file
         $etiquettesMR = explode(' ', Tools::getValue('etiquettesMR'));
         unset($etiquettesMR[count($etiquettesMR) - 1]);
         $zipPath = '../modules/erpillicopresta/export/mondialrelay.zip';
         $zip = new ZipArchive();
         if ($zip->open($zipPath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
             throw new Exception($this->l('Impossible to create the zip archive containing the shipping labels to Mondial Relay carrier !') . '<br/>');
         }
         foreach ($etiquettesMR as $key => $i) {
             $zip->addFromString('mondialrelay_' . $key . '.pdf', Tools::file_get_contents($i));
         }
         $zip->close();
         //Display link to dl zip file
         $this->confirmations[] = '&nbsp;<a target="_blank" href="' . $zipPath . '" alt="zip_file">' . $this->l('Download zip archive which contents all labels for Mondial Relay shipment') . '<br/></a>';
         if (Tools::getValue('deliveryNumbersMR') != '') {
             // Get all tracking numbers
//.........这里部分代码省略.........
开发者ID:prestamodule,项目名称:erpillicopresta,代码行数:101,代码来源:AdminAdvancedOrder.php

示例13: smartyClassname

function smartyClassname($classname)
{
    $classname = Tools::replaceAccentedChars(strtolower($classname));
    $classname = preg_replace('/[^A-Za-z0-9]/', '-', $classname);
    $classname = preg_replace('/[-]+/', '-', $classname);
    return $classname;
}
开发者ID:M03G,项目名称:PrestaShop,代码行数:7,代码来源:smarty.config.inc.php

示例14: displayAjax

 public function displayAjax()
 {
     $query = Tools::getValue('search_query');
     $original_query = $query;
     $query = Tools::replaceAccentedChars(urldecode($query));
     $this->productSort();
     $this->n = abs((int) Tools::getValue('n', isset($this->context->cookie->nb_item_per_page) ? (int) $this->context->cookie->nb_item_per_page : Configuration::get('PS_PRODUCTS_PER_PAGE')));
     $this->p = abs((int) Tools::getValue('p', 1));
     $facets = Tools::getValue('cm_select');
     $search = Cmsearch::find($this->context->language->id, $query, $this->p, $this->n, $this->orderBy, $this->orderWay, false, true, null, $facets);
     if ($search) {
         $position = 1;
         foreach ($search['result'] as &$product) {
             $product['link'] .= (strpos($product['link'], '?') === false ? '?' : '&') . 'search_query=' . urlencode($query) . '&results=' . (int) $search['total'] . '&pid=' . (int) $product['id_product'] . '&position=' . $position . '&page=' . $this->p . '&num=' . $this->n;
             $position++;
         }
         Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
         $nbProducts = $search['total'];
         $this->pagination($nbProducts);
         if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
             $this->addColorsToProductList($search['result']);
         }
         if (stripos($search['cm_result']->State, 'nothing')) {
             $cm_message = 'nothing found';
         } elseif (!empty($search['cm_result']->Corrections) && $search['cm_result']->Corrections[0]->Apply) {
             if (!empty($search['cm_result']->Query)) {
                 $cm_message = 'your request has been corrected to ' . $search['cm_result']->Query;
             } else {
                 $cm_message = 'nothing found';
             }
         } else {
             $cm_message = false;
         }
         $this->context->smarty->assign(array('search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => !empty($search['cm_result']->OriginalQuery) ? $search['cm_result']->OriginalQuery : ' ', 'cm_message' => $cm_message, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
         $list = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'convermax/views/templates/front/search.tpl');
         $this->context->smarty->assign(array('facets' => $search['cm_result']->Facets, 'query' => $search['cm_result']->Query, 'pagenumber' => $this->p, 'pagesize' => $this->n, 'col_img_dir' => _PS_COL_IMG_DIR_));
         $facets = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'convermax/views/templates/hook/facet.tpl');
         $vars = array('productList' => utf8_encode($list), 'facets' => $facets, 'redirect_url' => isset($search['cm_result']->Actions[0]->RedirectUrl) ? $search['cm_result']->Actions[0]->RedirectUrl : false);
     } else {
         $this->context->smarty->assign(array('search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => !empty($original_query) ? $original_query : ' ', 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
         $list = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'convermax/views/templates/front/search.tpl');
         $vars = array('productList' => utf8_encode($list), 'facets' => array(), 'redirect_url' => false);
     }
     echo Tools::jsonEncode($vars);
 }
开发者ID:Convermax,项目名称:PrestaShop,代码行数:45,代码来源:search.php

示例15: initContent

 public function initContent()
 {
     include _PS_MODULE_DIR_ . 'blocksearch_mod' . DIRECTORY_SEPARATOR . 'IqitSearch.php';
     $query = Tools::replaceAccentedChars(urldecode(Tools::getValue('q')));
     $original_query = Tools::getValue('q');
     $search_query_cat = (int) Tools::getValue('search_query_cat');
     if ($this->ajax_search) {
         self::$link = new Link();
         $image = new Image();
         $searchResults = IqitSearch::find((int) Tools::getValue('id_lang'), $query, $search_query_cat, 1, 10, 'position', 'desc', true);
         $taxes = Product::getTaxCalculationMethod();
         $currency = (int) Context::getContext()->currency->id;
         $iso_code = $this->context->language->iso_code;
         if (is_array($searchResults)) {
             foreach ($searchResults as &$product) {
                 $imageID = $image->getCover($product['id_product']);
                 if (isset($imageID['id_image'])) {
                     $imgLink = $this->context->link->getImageLink($product['prewrite'], (int) $product['id_product'] . '-' . $imageID['id_image'], 'small_default');
                 } else {
                     $imgLink = _THEME_PROD_DIR_ . $iso_code . "-default-small_default.jpg";
                 }
                 $product['product_link'] = $this->context->link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']);
                 $product['obr_thumb'] = $imgLink;
                 $product['product_price'] = Product::getPriceStatic((int) $product['id_product'], false, NULL, 2);
                 if ($taxes == 0 or $taxes == 2) {
                     $product['product_price'] = Tools::displayPrice(Product::getPriceStatic((int) $product['id_product'], true), $currency);
                 } elseif ($taxes == 1) {
                     $product['product_price'] = Tools::displayPrice(Product::getPriceStatic((int) $product['id_product'], false), $currency);
                 }
             }
         }
         $this->ajaxDie(Tools::jsonEncode($searchResults));
     }
     // Only controller content initialization when the user use the normal search
     parent::initContent();
     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 = IqitSearch::find($this->context->language->id, $query, $search_query_cat, 1, 10, 'position', 'desc');
         Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
         $nbProducts = $search['total'];
         $this->pagination($nbProducts);
         $this->addColorsToProductList($search['result']);
         if (method_exists('Product', 'getProductsImgs')) {
             $image_array = array();
             for ($i = 0; $i < $nbProducts; $i++) {
                 if (isset($search['result'][$i]['id_product'])) {
                     $image_array[$search['result'][$i]['id_product']] = Product::getProductsImgs($search['result'][$i]['id_product']);
                 }
             }
             $this->context->smarty->assign('productimg', (isset($image_array) and $image_array) ? $image_array : NULL);
         }
         $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', Configuration::get('PS_PRODUCTS_PER_PAGE')));
         $this->p = abs((int) Tools::getValue('p', 1));
         $original_query = $query;
         $query = Tools::replaceAccentedChars(urldecode($query));
         $search = IqitSearch::find($this->context->language->id, $query, $search_query_cat, $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']);
         /************************* /Images Array ******************************/
         if (method_exists('Product', 'getProductsImgs')) {
             $image_array = array();
             for ($i = 0; $i < $nbProducts; $i++) {
                 if (isset($search['result'][$i]['id_product'])) {
                     $image_array[$search['result'][$i]['id_product']] = Product::getProductsImgs($search['result'][$i]['id_product']);
                 }
             }
             $this->context->smarty->assign('productimg', (isset($image_array) and $image_array) ? $image_array : NULL);
         }
         /************************* /Images Array ******************************/
         $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);
         /************************* /Images Array ******************************/
         if (method_exists('Product', 'getProductsImgs')) {
             $image_array = array();
             for ($i = 0; $i < $nbProducts; $i++) {
                 if (isset($result[$i]['id_product'])) {
                     $image_array[$result[$i]['id_product']] = Product::getProductsImgs($result[$i]['id_product']);
                 }
             }
             $this->context->smarty->assign('productimg', (isset($image_array) and $image_array) ? $image_array : NULL);
         }
         /************************* /Images Array ******************************/
         $this->context->smarty->assign(array('search_tag' => $tag, 'products' => $result, 'search_products' => $result, 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
//.........这里部分代码省略.........
开发者ID:evgrishin,项目名称:se1614,代码行数:101,代码来源:SearchController.php


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