* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 6839 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ /* ** Some tools using used in the module */ class MRTools { /* ** Replace all accented chars to normal */ static public function replaceAccentedCharacters($string) { if (function_exists('iconv')) { $currentLocale = setlocale(LC_ALL, NULL); setlocale(LC_ALL, 'en_US.UTF8'); $cleanedString = iconv('UTF-8','ASCII//TRANSLIT', $string); setLocale(LC_ALL, $currentLocale); } else $cleanedString = strtr($string, 'àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ', 'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY'); return $cleanedString; } /* ** Fix security and compatibility for PS < 1.4.5 */ static function bqSQL($string) { return str_replace('`', '\`', pSQL($string)); } /* ** Check zip code by country */ static public function checkZipcodeByCountry($zipcode, $params) { $id_country = $params['id_country']; $zipcodeFormat = Db::getInstance()->getValue(' SELECT `zip_code_format` FROM `'._DB_PREFIX_.'country` WHERE `id_country` = '.(int)$id_country); // -1 to warn user that no layout exist if (!$zipcodeFormat) return -1; $regxMask = str_replace( array('N', 'C', 'L'), array( '[0-9]', Country::getIsoById((int)$id_country), '[a-zA-Z]'), $zipcodeFormat); if (preg_match('/'.$regxMask.'/', $zipcode)) return true; return false; } } ?>