cleanID UTF8 patch

darcs-hash:20050117192112-9977f-084e54a393e8ff0af3954e3a51b8072931529f9b.gz
This commit is contained in:
andi 2005-01-17 20:21:12 +01:00
parent 87a1de9a52
commit c41c03f3ff
1 changed files with 17 additions and 7 deletions

View File

@ -8,6 +8,7 @@
require_once("conf/dokuwiki.php");
require_once("inc/io.php");
require_once('inc/utf8.php');
//set up error reporting to sane values
error_reporting(E_ALL ^ E_NOTICE);
@ -392,32 +393,41 @@ function cleanID($id){
global $conf;
global $lang;
$id = trim($id);
$id = strtolower($id);
$id = utf8_strtolower($id);
//alternative namespace seperator
$id = strtr($id,';',':');
if($conf['useslash']) $id = strtr($id,'/',':');
//FIXME use config to ask for deaccenting
$id = utf8_deaccent($id,-1);
//remove specials (only ascii specials are removed)
$id = preg_replace('#[ !"§$%&()\[\]{}\\?`\'\#~*+=,<>\|^°@µ¹²³¼½¬]#u','_',$id);
/* DELETEME legacy code
if(!$conf['localnames']){
if($lang['encoding'] == 'iso-8859-15'){
// replace accented chars with unaccented ones
// this may look strange on your terminal - just don't touch
$id = strtr(
strtr($id,
'ŠŽšžŸÀÁÂÃÅÇÈÉÊËÌÍÎÏÑÒÓÔÕØÙÚÛÝàáâãåçèéêëìíîïñòóôõøùúûýÿ',
'ŠŽšžŸÀÁÂÃÅÇÈÉÊËÌÍÎÏÑÒÓÔÕØÙÚÛÝàáâãåçèéêëìíîïñòóôõøùúûýÿ',
'szszyaaaaaceeeeiiiinooooouuuyaaaaaceeeeiiiinooooouuuyy'),
array('Þ' => 'th', 'þ' => 'th', 'Ð' => 'dh', 'ð' => 'dh', 'ß' => 'ss',
'Œ' => 'oe', ' => 'oe', 'Æ' => 'ae', 'æ' => 'ae', 'µ' => 'u',
'ü' => 'ue', 'ö' => 'oe', 'ä' => 'ae', 'Ü' => 'ue', 'Ö' => 'ö',
'Ä' => 'ae'));
array('Þ' => 'th', 'þ' => 'th', 'Ð' => 'dh', 'ð' => 'dh', 'ß' => 'ss',
'Œ' => 'oe', 'œ' => 'oe', 'Æ' => 'ae', 'æ' => 'ae', 'µ' => 'u',
'ü' => 'ue', 'ö' => 'oe', 'ä' => 'ae', 'Ü' => 'ue', 'Ö' => 'ö',
'Ä' => 'ae'));
}
$WORD = 'a-z';
}else{
$WORD = '\w';
}
//special chars left will be converted to _
$id = preg_replace('#[^'.$WORD.'0-9:\-\.]#','_',$id);
*/
//clean up
$id = preg_replace('#__#','_',$id);
$id = preg_replace('#:+#',':',$id);
$id = trim($id,':._-');