Prestashop – přepis čeština

Při instalaci eshopu Prestashop, jsem se setkal s problémem přepisu cestiny v URL adrese. Po přepsání, respektive doplnění funkce link_rewrite, již přepis funguje bez problémů.

Soubor pro úpravu: /classes/tools.php

static public function link_rewrite($str, $utf8_decode = false)
{
$purified = '';
$length = Tools::strlen($str);
if ($utf8_decode)
$str = utf8_decode($str);
$utf8table = array ("xc3xa1"=>"a", "xc3xa4"=>"a", "xc4x8d"=>"c", "xc4x8f"=>"d", "xc3xa9"=>"e", "xc4x9b"=>"e", "xc3xad"=>"i", "xc4xbe"=>"l", "xc4xba"=>"l", "xc5x88"=>"n", "xc3xb3"=>"o", "xc3xb6"=>"o", "xc5x91"=>"o", "xc3xb4"=>"o", "xc5x99"=>"r", "xc5x95"=>"r", "xc5xa1"=>"s", "xc5xa5"=>"t", "xc3xba"=>"u", "xc5xaf"=>"u", "xc3xbc"=>"u", "xc5xb1"=>"u", "xc3xbd"=>"y", "xc5xbe"=>"z", "xc3x81"=>"A", "xc3x84"=>"A", "xc4x8c"=>"C", "xc4x8e"=>"D", "xc3x89"=>"E", "xc4x9a"=>"E", "xc3x8d"=>"I", "xc4xbd"=>"L", "xc4xb9"=>"L", "xc5x87"=>"N", "xc3x93"=>"O", "xc3x96"=>"O", "xc5x90"=>"O", "xc3x94"=>"O", "xc5x98"=>"R", "xc5x94"=>"R", "xc5xa0"=>"S", "xc5xa4"=>"T", "xc3x9a"=>"U", "xc5xae"=>"U", "xc3x9c"=>"U", "xc5xb0"=>"U", "xc3x9d"=>"Y", "xc5xbd"=>"Z");
$str = strtr($str, $utf8table);
$str = Str_Replace ("-", "", $str);
$str = Str_Replace ("  ", " ", $str);
for ($i = 0; $i < $length; $i++)
{
$char = Tools::substr($str, $i, 1);
if (Tools::strlen(htmlentities($char)) > 1)
{
$entity = htmlentities($char, ENT_COMPAT, 'UTF-8');
$purified .= $entity{1};
}
elseif (preg_match('|[[:alpha:]]{1}|u', $char))
$purified .= $char;
elseif (preg_match('<[[:digit:]]|-{1}>', $char))
$purified .= $char;
elseif ($char == ' ')
$purified .= '-';
}
return trim(self::strtolower($purified));
}

Napsat komentář

Vaše e-mailová adresa nebude zveřejněna. Vyžadované informace jsou označeny *