X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=languages%2FLanguage.php;h=b47442d75c3584fec0cd996e0e904d2e0515e161;hb=d87ef737df0286da050e6a2c4b50ade65d20749a;hp=b698bebf439466a714d44c167b278c47c413fec6;hpb=ca56f1fbc32529622cf430fe2ed44347b85e3c24;p=lhc%2Fweb%2Fwiklou.git diff --git a/languages/Language.php b/languages/Language.php index b698bebf43..b47442d75c 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -2270,30 +2270,33 @@ class Language { /** * Get a format string for a given type and preference - * @param string $type May be date, time or both - * @param string $pref The format name as it appears in Messages*.php + * @param string $type May be 'date', 'time', 'both', or 'pretty'. + * @param string $pref The format name as it appears in Messages*.php under + * $datePreferences. * * @since 1.22 New type 'pretty' that provides a more readable timestamp format * * @return string */ function getDateFormatString( $type, $pref ) { + $wasDefault = false; + if ( $pref == 'default' ) { + $wasDefault = true; + $pref = $this->getDefaultDateFormat(); + } + if ( !isset( $this->dateFormatStrings[$type][$pref] ) ) { - if ( $pref == 'default' ) { - $pref = $this->getDefaultDateFormat(); - $df = self::$dataCache->getSubitem( $this->mCode, 'dateFormats', "$pref $type" ); - } else { - $df = self::$dataCache->getSubitem( $this->mCode, 'dateFormats', "$pref $type" ); + $df = self::$dataCache->getSubitem( $this->mCode, 'dateFormats', "$pref $type" ); - if ( $type === 'pretty' && $df === null ) { - $df = $this->getDateFormatString( 'date', $pref ); - } + if ( $type === 'pretty' && $df === null ) { + $df = $this->getDateFormatString( 'date', $pref ); + } - if ( $df === null ) { - $pref = $this->getDefaultDateFormat(); - $df = self::$dataCache->getSubitem( $this->mCode, 'dateFormats', "$pref $type" ); - } + if ( !$wasDefault && $df === null ) { + $pref = $this->getDefaultDateFormat(); + $df = self::$dataCache->getSubitem( $this->mCode, 'dateFormats', "$pref $type" ); } + $this->dateFormatStrings[$type][$pref] = $df; } return $this->dateFormatStrings[$type][$pref]; @@ -2838,7 +2841,7 @@ class Language { * @return bool */ function isMultibyte( $str ) { - return (bool)preg_match( '/[\x80-\xff]/', $str ); + return strlen( $str ) !== mb_strlen( $str ); } /**