if( $usePrefs ) {
$datePreference = $wgUser->getDatePreference();
} else {
- $options = User::getDefaultOptions();
- $datePreference = (string)$options['date'];
+ $datePreference = (string)User::getDefaultOption( 'date' );
}
} else {
$datePreference = (string)$usePrefs;
* @param $string String
* @return String
*/
- function wordSegmentation( $string ) {
+ function segmentByWord( $string ) {
return $string;
}
* @return String
*/
function normalizeForSearch( $string ) {
- return $string;
+ return self::convertDoubleWidth($string);
}
/**
* range: ff00-ff5f ~= 0020-007f
*/
protected static function convertDoubleWidth( $string ) {
- $string = preg_replace( '/\xef\xbc([\x80-\xbf])/e', 'chr((ord("$1") & 0x3f) + 0x20)', $string );
- $string = preg_replace( '/\xef\xbd([\x80-\x99])/e', 'chr((ord("$1") & 0x3f) + 0x60)', $string );
+ static $full = null;
+ static $half = null;
+
+ if( $full === null ) {
+ $fullWidth = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ $halfWidth = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ $full = str_split( $fullWidth, 3 );
+ $half = str_split( $halfWidth );
+ }
+
+ $string = str_replace( $full, $half, $string );
return $string;
}
function formatTimePeriod( $seconds ) {
if ( $seconds < 10 ) {
- return $this->formatNum( sprintf( "%.1f", $seconds ) ) . wfMsg( 'seconds-abbrev' );
+ return $this->formatNum( sprintf( "%.1f", $seconds ) ) . ' ' . wfMsg( 'seconds-abbrev' );
} elseif ( $seconds < 60 ) {
- return $this->formatNum( round( $seconds ) ) . wfMsg( 'seconds-abbrev' );
+ return $this->formatNum( round( $seconds ) ) . ' ' . wfMsg( 'seconds-abbrev' );
} elseif ( $seconds < 3600 ) {
- return $this->formatNum( floor( $seconds / 60 ) ) . wfMsg( 'minutes-abbrev' ) .
- $this->formatNum( round( fmod( $seconds, 60 ) ) ) . wfMsg( 'seconds-abbrev' );
+ return $this->formatNum( floor( $seconds / 60 ) ) . ' ' . wfMsg( 'minutes-abbrev' ) . ' ' .
+ $this->formatNum( round( fmod( $seconds, 60 ) ) ) . ' ' . wfMsg( 'seconds-abbrev' );
} else {
$hours = floor( $seconds / 3600 );
$minutes = floor( ( $seconds - $hours * 3600 ) / 60 );
$secondsPart = round( $seconds - $hours * 3600 - $minutes * 60 );
- return $this->formatNum( $hours ) . wfMsg( 'hours-abbrev' ) .
- $this->formatNum( $minutes ) . wfMsg( 'minutes-abbrev' ) .
- $this->formatNum( $secondsPart ) . wfMsg( 'seconds-abbrev' );
+ return $this->formatNum( $hours ) . ' ' . wfMsg( 'hours-abbrev' ) . ' ' .
+ $this->formatNum( $minutes ) . ' ' . wfMsg( 'minutes-abbrev' ) . ' ' .
+ $this->formatNum( $secondsPart ) . ' ' . wfMsg( 'seconds-abbrev' );
}
}