2007年2月7日 星期三

WikiMedia Latin filter for search

in include\Utf8case.php add

wikiSearchChars

in language\language.php
change

static function getCaseMaps() {
static $wikiUpperChars, $wikiLowerChars;
if ( isset( $wikiUpperChars ) ) {
return array( $wikiUpperChars, $wikiLowerChars, $wikiSearchChars );
}

wfProfileIn( __METHOD__ );
$arr = wfGetPrecompiledData( 'Utf8Case.ser' );
if ( $arr === false ) {
throw new MWException(
"Utf8Case.ser is missing, please run \"make\" in the serialized directory\n" );
}
extract( $arr );
wfProfileOut( __METHOD__ );
return array( $wikiUpperChars, $wikiLowerChars, $wikiSearchChars );
}



and the various call to it

The StripForSearch

function stripForSearch( $string ) {
global $wgDBtype;
if ( $wgDBtype != 'mysql' ) {
return $string;
}

# MySQL fulltext index doesn't grok utf-8, so we
# need to fold cases and convert to hex

wfProfileIn( __METHOD__ );
list( , , $wikiSearchChars ) = self::getCaseMaps();
$s = strtr(string, $wikiSearchChars);
$out = preg_replace(
"/([\\xc0-\\xff][\\x80-\\xbf]*)/e",
"' U8' . bin2hex( \"\$1\" )",
$s );
}
wfProfileOut( __METHOD__ );
return $out;
}