DokuWiki配置秘笈
1. 存档目录支持中文字符
第1处修订:
修改文件dokuwiki/conf/local.php,新增一行配置:
$conf['fnencode'] = 'utf-8';
第2处修订:
修改文件dokuwiki/inc/pageutils.php,以下函数:
function utf8_encodeFN($file,$safe=true){
global $conf;
if($conf['fnencode'] == 'utf-8') return $file;
if($safe && preg_match('#^[a-zA-Z0-9/_\-\.%]+$#',$file)){
return $file;
}
......
}
修改为:
function utf8_encodeFN($file,$safe=true){
global $conf;
//if($conf['fnencode'] == 'utf-8') return $file;
if($conf['fnencode'] == 'utf-8') return iconv('UTF-8','GB2312',$file);
if($safe && preg_match('#^[a-zA-Z0-9/_\-\.%]+$#',$file)){
return $file;
}
......
}
第3处修订:
以下函数:
function utf8_decodeFN($file){
global $conf;
if($conf['fnencode'] == 'utf-8') return $file;
if($conf['fnencode'] == 'safe'){
return SafeFN::decode($file);
}
return urldecode($file);
}
修改为:
function utf8_decodeFN($file){
global $conf;
//if($conf['fnencode'] == 'utf-8') return $file;
if($conf['fnencode'] == 'utf-8') return iconv('GB2312','UTF-8',$file);
if($conf['fnencode'] == 'safe'){
return SafeFN::decode($file);
}
return urldecode($file);
}
2. 修复词条时间乱码问题
修改dokuwiki/inc/common.php文件,以下函数:
function dformat($dt = null, $format = '') {
global $conf;
if(is_null($dt)) $dt = time();
$dt = (int) $dt;
if(!$format) $format = $conf['dformat'];
$format = str_replace('%f', datetime_h($dt), $format);
return strftime($format, $dt);
}
修改为:
function dformat($dt = null, $format = '') {
global $conf;
if(is_null($dt)) $dt = time();
$dt = (int) $dt;
if(!$format) $format = $conf['dformat'];
// add by fairyfar
if($format=='%f') return str_replace('%f', datetime_h($dt), $format);
$format = str_replace('%f', datetime_h($dt), $format);
return strftime($format, $dt);
}