* Added experimental global variable $i18n_filename_utf8 that can

be set in a serendipity_config_local.inc.php or language include
      file, which will return Unicode-Permalinks.
      (http://board.s9y.org/viewtopic.php?f=11&t=15896)
This commit is contained in:
Garvin Hicking 2009-12-08 13:32:05 +00:00
parent 4996015ab4
commit b5507f35b8
2 changed files with 31 additions and 20 deletions

View File

@ -2,6 +2,10 @@
Version 1.6 ()
------------------------------------------------------------------------
* Added experimental global variable $i18n_filename_utf8 that can
be set in a serendipity_config_local.inc.php or language include
file, which will return Unicode-Permalinks.
(http://board.s9y.org/viewtopic.php?f=11&t=15896)
Version 1.5 ()
------------------------------------------------------------------------

View File

@ -108,29 +108,36 @@ function serendipity_makeFilename($str, $stripDots = false) {
'y');
if (isset($GLOBALS['i18n_filename_from'])) {
// Replace international chars not detected by every locale.
// The array of chars is defined in the language file.
$str = str_replace($GLOBALS['i18n_filename_from'], $GLOBALS['i18n_filename_to'], $str);
if (LANG_CHARSET == 'UTF-8') {
// URLs need to be 7bit - since this function takes care of the most common ISO-8859-1
// characters, try to UTF8-decode the string first.
$str = utf8_decode($str);
}
if (isset($GLOBALS['i18n_filename_utf8'])) {
$str = str_replace(' ', '_', $str);
$str = str_replace('&', '%25', $str);
$str = str_replace('/', '%2F', $str);
$str = urlencode($str);
} else {
// Replace international chars not detected by every locale
if (LANG_CHARSET == 'UTF-8') {
// URLs need to be 7bit - since this function takes care of the most common ISO-8859-1
// characters, try to UTF8-decode the string first.
$str = utf8_decode($str);
if (isset($GLOBALS['i18n_filename_from'])) {
// Replace international chars not detected by every locale.
// The array of chars is defined in the language file.
$str = str_replace($GLOBALS['i18n_filename_from'], $GLOBALS['i18n_filename_to'], $str);
if (LANG_CHARSET == 'UTF-8') {
// URLs need to be 7bit - since this function takes care of the most common ISO-8859-1
// characters, try to UTF8-decode the string first.
$str = utf8_decode($str);
}
} else {
// Replace international chars not detected by every locale
if (LANG_CHARSET == 'UTF-8') {
// URLs need to be 7bit - since this function takes care of the most common ISO-8859-1
// characters, try to UTF8-decode the string first.
$str = utf8_decode($str);
}
$str = str_replace($from, $to, $str);
}
$str = str_replace($from, $to, $str);
}
// Nuke chars not allowed in our URI
$str = preg_replace('#[^' . PAT_FILENAME . ']#i', '', $str);
// Nuke chars not allowed in our URI
$str = preg_replace('#[^' . PAT_FILENAME . ']#i', '', $str);
}
// Check if dots are allowed
if ($stripDots) {