global $wgLanguageNames;
require_once( dirname( __FILE__ ) . '/Names.php' );
-global $wgInputEncoding, $wgOutputEncoding;
-
-/**
- * These are always UTF-8, they exist only for backwards compatibility
- */
-$wgInputEncoding = 'UTF-8';
-$wgOutputEncoding = 'UTF-8';
-
if ( function_exists( 'mb_strtoupper' ) ) {
mb_internal_encoding( 'UTF-8' );
}
*/
var $transformData = array();
+ /**
+ * @var LocalisationCache
+ */
static public $dataCache;
+
static public $mLangObjCache = array();
static public $mWeekdayMsgs = array(
static $recursionLevel = 0;
// Protect against path traversal below
- if ( !Language::isValidCode( $code )
- || strcspn( $code, ":/\\\000" ) !== strlen( $code ) )
+ if ( !Language::isValidCode( $code )
+ || strcspn( $code, ":/\\\000" ) !== strlen( $code ) )
{
throw new MWException( "Invalid language code \"$code\"" );
}
if ( !Language::isValidBuiltInCode( $code ) ) {
- // It's not possible to customise this code with class files, so
+ // It's not possible to customise this code with class files, so
// just return a Language object. This is to support uselang= hacks.
$lang = new Language;
$lang->setCode( $code );
}
/**
- * Returns true if a language code string is of a valid form, whether or
- * not it exists. This includes codes which are used solely for
+ * Returns true if a language code string is of a valid form, whether or
+ * not it exists. This includes codes which are used solely for
* customisation via the MediaWiki namespace.
*/
public static function isValidCode( $code ) {
- return
+ return
strcspn( $code, ":/\\\000" ) === strlen( $code )
&& !preg_match( Title::getTitleInvalidRegex(), $code );
}
/**
- * Returns true if a language code is of a valid form for the purposes of
+ * Returns true if a language code is of a valid form for the purposes of
* internal customisation of MediaWiki, via Messages*.php.
*/
public static function isValidBuiltInCode( $code ) {
*/
function initContLang() { }
- /**
- * @deprecated Use User::getDefaultOptions()
- * @return array
- */
- function getDefaultUserOptions() {
- wfDeprecated( __METHOD__ );
- return User::getDefaultOptions();
- }
-
function getFallbackLanguageCode() {
if ( $this->mCode === 'en' ) {
return false;
);
}
- function getMathNames() {
- return self::$dataCache->getItem( $this->mCode, 'mathNames' );
- }
-
function getDatePreferences() {
return self::$dataCache->getItem( $this->mCode, 'datePreferences' );
}
return $this->getMessageFromDB( self::$mMonthMsgs[$key - 1] );
}
+ function getMonthNamesArray() {
+ $monthNames = array( '' );
+ for ( $i=1; $i < 13; $i++ ) {
+ $monthNames[] = $this->getMonthName( $i );
+ }
+ return $monthNames;
+ }
+
function getMonthNameGen( $key ) {
return $this->getMessageFromDB( self::$mMonthGenMsgs[$key - 1] );
}
return $this->getMessageFromDB( self::$mMonthAbbrevMsgs[$key - 1] );
}
+ function getMonthAbbreviationsArray() {
+ $monthNames = array('');
+ for ( $i=1; $i < 13; $i++ ) {
+ $monthNames[] = $this->getMonthAbbreviation( $i );
+ }
+ return $monthNames;
+ }
+
function getWeekdayName( $key ) {
return $this->getMessageFromDB( self::$mWeekdayMsgs[$key - 1] );
}
return $s;
}
- $isutf8 = ( $s == iconv("UTF-8","UTF-8//IGNORE", $s));
+ $isutf8 = preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
+ '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
if ( $isutf8 ) {
return $s;
}
}
# Do not truncate if the ellipsis makes the string longer/equal (bug 22181).
# This check is *not* redundant if $adjustLength, due to the single case where
- # LEN($ellipsis) > ABS($limit arg); $stringOriginal could be shorter than $string.
+ # LEN($ellipsis) > ABS($limit arg); $stringOriginal could be shorter than $string.
if ( strlen( $string ) < strlen( $stringOriginal ) ) {
return $string;
} else {
return $string;
}
- /*
+ /**
* Truncate a string of valid HTML to a specified length in bytes,
* appending an optional string (e.g. for ellipses), and return valid HTML
*
return $skipCount;
}
- /*
+ /**
* truncateHtml() helper function
* (a) push or pop $tag from $openTags as needed
* (b) clear $tag value
/**
* Checks that convertPlural was given an array and pads it to requested
- * amound of forms by copying the last one.
+ * amount of forms by copying the last one.
*
* @param $count Integer: How many forms should there be at least
* @param $forms Array of forms given to convertPlural
* @see LanguageFi.php for example implementation
*/
function translateBlockExpiry( $str ) {
- foreach( SpecialBlock::getSuggestedDurations( $this ) as $show => $value ){
+ $duration = SpecialBlock::getSuggestedDurations( $this );
+ foreach( $duration as $show => $value ){
if ( strcmp( $str, $value ) == 0 ) {
return htmlspecialchars( trim( $show ) );
}
}
+
+ // Since usually only infinite or indefinite is only on list, so try
+ // equivalents if still here.
+ $indefs = array( 'infinite', 'infinity', 'indefinite' );
+ if ( in_array( $str, $indefs ) ) {
+ foreach( $indefs as $val ) {
+ $show = array_search( $val, $duration, true );
+ if ( $show !== false ) {
+ return htmlspecialchars( trim( $show ) );
+ }
+ }
+ }
+ // If all else fails, return the original string.
return $str;
}
* into an array of all possible variants of the text:
* 'variant' => text in that variant
*
- * @deprecated Use autoConvertToAllVariants()
+ * @deprecated since 1.17 Use autoConvertToAllVariants()
*/
function convertLinkToAllVariants( $text ) {
return $this->mConverter->convertLinkToAllVariants( $text );
*/
static function getFileName( $prefix = 'Language', $code, $suffix = '.php' ) {
// Protect against path traversal
- if ( !Language::isValidCode( $code )
- || strcspn( $code, ":/\\\000" ) !== strlen( $code ) )
+ if ( !Language::isValidCode( $code )
+ || strcspn( $code, ":/\\\000" ) !== strlen( $code ) )
{
throw new MWException( "Invalid language code \"$code\"" );
}
-
+
return $prefix . str_replace( '-', '_', ucfirst( $code ) ) . $suffix;
}