1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 22:57:14 +02:00

toASCII method added.

This commit is contained in:
Cameron
2016-12-08 08:21:58 -08:00
parent 24d5e6a6c7
commit 2039968aab
2 changed files with 76 additions and 66 deletions

View File

@@ -2402,7 +2402,7 @@ class eUrlRule
if(is_array($route)) $route = implode('/', $route);
$tr = array();
if ($route !== $this->route)
@@ -2472,18 +2472,24 @@ class eUrlRule
}
}
}
$tp = e107::getParser();
$urlFormat = e107::getConfig()->get('url_sef_translate');
foreach ($this->params as $key => $value)
{
// FIX - non-latin URLs proper encoded
$tr["<$key>"] = rawurlencode($params[$key]);
$tr["<$key>"] = rawurlencode($params[$key]); //todo transliterate non-latin
// $tr["<$key>"] = eHelper::title2sef($tp->toASCII($params[$key]), $urlFormat); // enabled to test.
unset($params[$key]);
}
$suffix = $this->urlSuffix === null ? $manager->urlSuffix : $this->urlSuffix;
// XXX TODO Find better place for this check which will affect all types of SEF URL configurations. (@see news/sef_noid_url.php for duplicate)
$urlFormat = e107::getConfig()->get('url_sef_translate');
if($urlFormat == 'dashl' || $urlFormat == 'underscorel' || $urlFormat == 'plusl') // convert template to lowercase when using lowercase SEF URL format.
{
@@ -2491,6 +2497,7 @@ class eUrlRule
}
$url = strtr($this->template, $tr);
if(empty($params))
{
@@ -4359,7 +4366,7 @@ class eHelper
*/
public static function title2sef($title, $type = null)
{
$char_map = array(
/*$char_map = array(
// Latin
'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'Æ' => 'AE', 'Ç' => 'C',
'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I',
@@ -4416,9 +4423,11 @@ class eHelper
'Š' => 'S', 'Ū' => 'u', 'Ž' => 'Z',
'ā' => 'a', 'č' => 'c', 'ē' => 'e', 'ģ' => 'g', 'ī' => 'i', 'ķ' => 'k', 'ļ' => 'l', 'ņ' => 'n',
'š' => 's', 'ū' => 'u', 'ž' => 'z'
);
);*/
$title = str_replace(array_keys($char_map), $char_map, $title);
$tp = e107::getParser();
$title = $tp->toASCII($title);
$title = str_replace(array('/',' '),' ',$title);
$title = str_replace(array("&",",","(",")"),'',$title);
@@ -4436,7 +4445,7 @@ class eHelper
{
$type = e107::getPref('url_sef_translate');
}
$tp = e107::getParser();
switch ($type)
{
case 'dashl': //dasherize, to lower case