dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Avoid passing anything but a string to Title::newFromText in UploadBase::getTitle"
[lhc/web/wiklou.git]
/
languages
/
Language.php
diff --git
a/languages/Language.php
b/languages/Language.php
index
fe0bd7e
..
b47442d
100644
(file)
--- a/
languages/Language.php
+++ b/
languages/Language.php
@@
-254,10
+254,16
@@
class Language {
* @since 1.21
*/
public static function isSupportedLanguage( $code ) {
* @since 1.21
*/
public static function isSupportedLanguage( $code ) {
- return self::isValidBuiltInCode( $code )
- && ( is_readable( self::getMessagesFileName( $code ) )
- || is_readable( self::getJsonMessagesFileName( $code ) )
- );
+ if ( !self::isValidBuiltInCode( $code ) ) {
+ return false;
+ }
+
+ if ( $code === 'qqq' ) {
+ return false;
+ }
+
+ return is_readable( self::getMessagesFileName( $code ) ) ||
+ is_readable( self::getJsonMessagesFileName( $code ) );
}
/**
}
/**
@@
-547,10
+553,8
@@
class Language {
}
/**
}
/**
- * A convenience function that returns the same thing as
- * getNamespaces() except with the array values changed to ' '
- * where it found '_', useful for producing output to be displayed
- * e.g. in <select> forms.
+ * A convenience function that returns getNamespaces() with spaces instead of underscores
+ * in values. Useful for producing output to be displayed e.g. in `<select>` forms.
*
* @return array
*/
*
* @return array
*/
@@
-564,6
+568,7
@@
class Language {
/**
* Get a namespace value by key
/**
* Get a namespace value by key
+ *
* <code>
* $mw_ns = $wgContLang->getNsText( NS_MEDIAWIKI );
* echo $mw_ns; // prints 'MediaWiki'
* <code>
* $mw_ns = $wgContLang->getNsText( NS_MEDIAWIKI );
* echo $mw_ns; // prints 'MediaWiki'
@@
-574,7
+579,6
@@
class Language {
*/
function getNsText( $index ) {
$ns = $this->getNamespaces();
*/
function getNsText( $index ) {
$ns = $this->getNamespaces();
-
return isset( $ns[$index] ) ? $ns[$index] : false;
}
return isset( $ns[$index] ) ? $ns[$index] : false;
}
@@
-593,7
+597,6
@@
class Language {
*/
function getFormattedNsText( $index ) {
$ns = $this->getNsText( $index );
*/
function getFormattedNsText( $index ) {
$ns = $this->getNsText( $index );
-
return strtr( $ns, '_', ' ' );
}
return strtr( $ns, '_', ' ' );
}
@@
-2267,30
+2270,33
@@
class Language {
/**
* Get a format string for a given type and preference
/**
* 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 ) {
*
* @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 ( !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];
$this->dateFormatStrings[$type][$pref] = $df;
}
return $this->dateFormatStrings[$type][$pref];
@@
-2835,7
+2841,7
@@
class Language {
* @return bool
*/
function isMultibyte( $str ) {
* @return bool
*/
function isMultibyte( $str ) {
- return
(bool)preg_match( '/[\x80-\xff]/',
$str );
+ return
strlen( $str ) !== mb_strlen(
$str );
}
/**
}
/**