Autor Zpráva
ferdinant
Profil *
Vedel by mi niekto poradiť ako upraviť tento kód tak aby negeneroval linky aj s diakritikou:

function convert_title_to_alias($title)

{
$chacters=array(','=>'-',';'=>'-','/'=>'-');
$title = str_replace(
array_keys($chacters),
array_values($chacters),
$title
);
return stringURLUnicodeSlug($title); // Use unicode (mimic J 1.6)
//return stringURLSafe($title); // Use unicode aliase (mimic J 1.6)
}

function stringURLUnicodeSlug($string)
{
//replace double byte whitespaces by single byte (Far-East languages)
$str = preg_replace('/\xE3\x80\x80/', ' ', $string);


// remove any '-' from the string as they will be used as concatenator.
// Would be great to let the spaces in but only Firefox is friendly with this

$str = str_replace('-', ' ', $str);

// replace forbidden characters by whitespaces
$str = preg_replace( '#[:\#\*"@+=;!&\.%()\]\/\'\\\\|\[]#',"\x20", $str );

//delete all '?'
$str = str_replace('?', '', $str);

//trim white spaces at beginning and end of alias, make lowercase
$str = trim(JString::strtolower($str));

// remove any duplicate whitespace and replace whitespaces by hyphens
$str =preg_replace('#\x20+#','-', $str);
return $str;
}
function stringURLSafe($title)
{
$alias = str_replace(':','-',$title);
$alias = str_replace('-', ' ', $alias);
$alias = utf8_latin_to_ascii($alias);

// convert certain symbols to letter representation
$alias = str_replace(array('&', '"', '<', '>'), array('a', 'q', 'l', 'g'), $alias);

// lowercase and trim
$alias = trim(strtolower($alias));
// remove any duplicate whitespace, and ensure all characters are alphanumeric
$alias = preg_replace(array('/\s+/','/[^A-Za-z0-9\-]/'), array('-',''), $alias);

//$alias = JFilterOutput::stringURLSafe(str_replace(':','-',$title));
while(strpos($alias,'--')!==false)
{
$alias = str_replace('--','-',$alias);
}
return $alias;
}
function utf8_latin_to_ascii( $string, $case=0 )
{
static $UTF8_LOWER_ACCENTS = NULL;
static $UTF8_UPPER_ACCENTS = NULL;

if($case <= 0)
{
if ( is_null($UTF8_LOWER_ACCENTS) )
{
$UTF8_LOWER_ACCENTS = array(
'à' => 'a', 'ô' => 'o', 'ď' => 'd', 'ḟ' => 'f', 'ë' => 'e', 'š' => 's', 'ơ' => 'o',
'ß' => 'ss', 'ă' => 'a', 'ř' => 'r', 'ț' => 't', 'ň' => 'n', 'ā' => 'a', 'ķ' => 'k',
'ŝ' => 's', 'ỳ' => 'y', 'ņ' => 'n', 'ĺ' => 'l', 'ħ' => 'h', 'ṗ' => 'p', 'ó' => 'o',
'ú' => 'u', 'ě' => 'e', 'é' => 'e', 'ç' => 'c', 'ẁ' => 'w', 'ċ' => 'c', 'õ' => 'o',
'ṡ' => 's', 'ø' => 'o', 'ģ' => 'g', 'ŧ' => 't', 'ș' => 's', 'ė' => 'e', 'ĉ' => 'c',
'ś' => 's', 'î' => 'i', 'ű' => 'u', 'ć' => 'c', 'ę' => 'e', 'ŵ' => 'w', 'ṫ' => 't',
'ū' => 'u', 'č' => 'c', 'ö' => 'oe', 'è' => 'e', 'ŷ' => 'y', 'ą' => 'a', 'ł' => 'l',
'ų' => 'u', 'ů' => 'u', 'ş' => 's', 'ğ' => 'g', 'ļ' => 'l', 'ƒ' => 'f', 'ž' => 'z',
'ẃ' => 'w', 'ḃ' => 'b', 'å' => 'a', 'ì' => 'i', 'ï' => 'i', 'ḋ' => 'd', 'ť' => 't',
'ŗ' => 'r', 'ä' => 'ae', 'í' => 'i', 'ŕ' => 'r', 'ê' => 'e', 'ü' => 'ue', 'ò' => 'o',
'ē' => 'e', 'ñ' => 'n', 'ń' => 'n', 'ĥ' => 'h', 'ĝ' => 'g', 'đ' => 'd', 'ĵ' => 'j',
'ÿ' => 'y', 'ũ' => 'u', 'ŭ' => 'u', 'ư' => 'u', 'ţ' => 't', 'ý' => 'y', 'ő' => 'o',
'â' => 'a', 'ľ' => 'l', 'ẅ' => 'w', 'ż' => 'z', 'ī' => 'i', 'ã' => 'a', 'ġ' => 'g',
'ṁ' => 'm', 'ō' => 'o', 'ĩ' => 'i', 'ù' => 'u', 'į' => 'i', 'ź' => 'z', 'á' => 'a',
'û' => 'u', 'þ' => 'th', 'ð' => 'dh', 'æ' => 'ae', 'µ' => 'u', 'ĕ' => 'e', 'œ' => 'oe',
);
}

$string = str_replace(
array_keys($UTF8_LOWER_ACCENTS),
array_values($UTF8_LOWER_ACCENTS),
$string
);
}

if($case >= 0)
{
if ( is_null($UTF8_UPPER_ACCENTS) )
{
$UTF8_UPPER_ACCENTS = array(
'À' => 'A', 'Ô' => 'O', 'Ď' => 'D', 'Ḟ' => 'F', 'Ë' => 'E', 'Š' => 'S', 'Ơ' => 'O',
'Ă' => 'A', 'Ř' => 'R', 'Ț' => 'T', 'Ň' => 'N', 'Ā' => 'A', 'Ķ' => 'K',
'Ŝ' => 'S', 'Ỳ' => 'Y', 'Ņ' => 'N', 'Ĺ' => 'L', 'Ħ' => 'H', 'Ṗ' => 'P', 'Ó' => 'O',
'Ú' => 'U', 'Ě' => 'E', 'É' => 'E', 'Ç' => 'C', 'Ẁ' => 'W', 'Ċ' => 'C', 'Õ' => 'O',
'Ṡ' => 'S', 'Ø' => 'O', 'Ģ' => 'G', 'Ŧ' => 'T', 'Ș' => 'S', 'Ė' => 'E', 'Ĉ' => 'C',
'Ś' => 'S', 'Î' => 'I', 'Ű' => 'U', 'Ć' => 'C', 'Ę' => 'E', 'Ŵ' => 'W', 'Ṫ' => 'T',
'Ū' => 'U', 'Č' => 'C', 'Ö' => 'Oe', 'È' => 'E', 'Ŷ' => 'Y', 'Ą' => 'A', 'Ł' => 'L',
'Ų' => 'U', 'Ů' => 'U', 'Ş' => 'S', 'Ğ' => 'G', 'Ļ' => 'L', 'Ƒ' => 'F', 'Ž' => 'Z',
'Ẃ' => 'W', 'Ḃ' => 'B', 'Å' => 'A', 'Ì' => 'I', 'Ï' => 'I', 'Ḋ' => 'D', 'Ť' => 'T',
'Ŗ' => 'R', 'Ä' => 'Ae', 'Í' => 'I', 'Ŕ' => 'R', 'Ê' => 'E', 'Ü' => 'Ue', 'Ò' => 'O',
'Ē' => 'E', 'Ñ' => 'N', 'Ń' => 'N', 'Ĥ' => 'H', 'Ĝ' => 'G', 'Đ' => 'D', 'Ĵ' => 'J',
'Ÿ' =
ferdinant
Profil *
Pridávam odkaz na celý súbor:
www.ulozto.sk/8110740/router-php
_es
Profil
ferdinant:
Možno sa ti zíde, že na úpravu URI a častí URI s hocijakými znakmi slúžia metódy encodeURIComponent, decodeURIComponent, encodeURI a decodeURI.

Vaše odpověď


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0