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' );
}
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 getMonthName( $key ) {
return $this->getMessageFromDB( self::$mMonthMsgs[$key - 1] );
}
-
+
function getMonthNamesArray() {
$monthNames = array( '' );
- for ( $i=1; $i < 13; $i++ ) {
+ for ( $i=1; $i < 13; $i++ ) {
$monthNames[] = $this->getMonthName( $i );
}
return $monthNames;
}
-
+
function getMonthNameGen( $key ) {
return $this->getMessageFromDB( self::$mMonthGenMsgs[$key - 1] );
}
function getMonthAbbreviation( $key ) {
return $this->getMessageFromDB( self::$mMonthAbbrevMsgs[$key - 1] );
}
-
+
function getMonthAbbreviationsArray() {
$monthNames = array('');
- for ( $i=1; $i < 13; $i++ ) {
+ for ( $i=1; $i < 13; $i++ ) {
$monthNames[] = $this->getMonthAbbreviation( $i );
}
return $monthNames;
}
-
+
function getWeekdayName( $key ) {
return $this->getMessageFromDB( self::$mWeekdayMsgs[$key - 1] );
}
}
# 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
* @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;
}
*/
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;
}