this old-fashioned code (shame on me) can make it work, until the api is 100% complete :
<?php
$title
=
'Title of the document'
;
makeAlias(
$title
);
function
makeAlias(
$url
){
$url
= no_accent(
$url
);
$url
=
ereg_replace
(
"[^a-z A-Z0-9-]*"
,
""
,
$url
);
$url
=
ereg_replace
(
"-{2,}"
,
"-"
,
$url
);
$url
=
ereg_replace
(
' '
,
'-'
,
$url
);
$url
= trim(
strtolower
(
$url
));
$url
= ltrim(
$url
,
'-'
);
$url
= rtrim(
$url
,
'-'
);
return
$url
;
}
function
no_accent(
$filename
) {
$str
=
strtr
(utf8_decode(
$filename
),utf8_decode(
"ÀÁÂÃÄÅÇÑñÇçÈÉÊËÌÍÎÏÒÓÔÕÖØÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöøùúûüýÿ' "
),
"AAAAAACNnCcEEEEIIIIOOOOOOUUUUYaaaaaaceeeeiiiiooooooouuuuyy--"
);
return
$str
;
}
?>
0 comments:
Post a Comment