20/10/2010, 00:28:52
Joli, mais attention aux espaces et caractères spéciaux. Remplace-les par des tirets (comme les alias qui se créent à partir du titre).
Voir : /lib/misc.functions.php ligne 1337
Voir : /lib/misc.functions.php ligne 1337
Code :
/**
* convert a human readable string into something that is suitable for use in URLS
* because many browsers don't support UTF-8 characters in URLS
*
* @internal
* @param string String to convert
* @param boolean indicates whether output string should be converted to lower case
* @return string
*/
function munge_string_to_url($alias, $tolower = false)
{
// replacement.php is encoded utf-8 and must be the first modification of alias
include(dirname(__FILE__) . '/replacement.php');
$alias = str_replace($toreplace, $replacement, $alias);
// lowercase only on empty aliases
if ($tolower == true)
{
$alias = strtolower($alias);
}
$alias = preg_replace('/[^a-z0-9-_]+/i','-',$alias);
//$alias = preg_replace("/[^\w-]+/", "-", $alias);
$alias = trim($alias, '-');
return $alias;
}