* functionality), or if it is true then use the wikis
* @return Language object
*/
-function wfGetLangObj( $langcode = false ){
+function wfGetLangObj( $langcode = false ) {
# Identify which language to get or create a language object for.
- if( $langcode instanceof Language )
- # Great, we already have the object!
+ # Using is_object here due to Stub objects.
+ if( is_object( $langcode ) ) {
+ # Great, we already have the object (hopefully)!
return $langcode;
+ }
- global $wgContLang;
- if( $langcode === $wgContLang->getCode() || $langcode === true )
+ global $wgContLang, $wgLanguageCode;
+ if( $langcode === true || $langcode === $wgLanguageCode ) {
# $langcode is the language code of the wikis content language object.
# or it is a boolean and value is true
return $wgContLang;
+ }
global $wgLang;
- if( $langcode === $wgLang->getCode() || $langcode === false )
+ if( $langcode === false || $langcode === $wgLang->getCode() ) {
# $langcode is the language code of user language object.
# or it was a boolean and value is false
return $wgLang;
+ }
$validCodes = array_keys( Language::getLanguageNames() );
- if( in_array( $langcode, $validCodes ) )
+ if( in_array( $langcode, $validCodes ) ) {
# $langcode corresponds to a valid language.
return Language::factory( $langcode );
+ }
# $langcode is a string, but not a valid language code; use content language.
wfDebug( "Invalid language code passed to wfGetLangObj, falling back to content language.\n" );
return $wgContLang;
}
+function wfUILang() {
+ global $wgBetterDirectionality;
+ return wfGetLangObj( $wgBetterDirectionality ? false: true );
+}
+
/**
* Get a message from anywhere, for the current user language.
*
* behaves as a content language switch if it is a boolean.
* @param $transform Boolean: whether to parse magic words, etc.
* @return string
- * @private
*/
function wfMsgGetKey( $key, $useDB, $langCode = false, $transform = true ) {
global $wgContLang, $wgMessageCache;
wfRunHooks('NormalizeMessageKey', array(&$key, &$useDB, &$langCode, &$transform));
- # If $wgMessageCache isn't initialised yet, try to return something sensible.
- if( is_object( $wgMessageCache ) ) {
- $message = $wgMessageCache->get( $key, $useDB, $langCode );
- if( $message === false ){
- $message = '<' . htmlspecialchars( $key ) . '>';
- } elseif ( $transform ) {
- $message = $wgMessageCache->transform( $message );
- }
- } else {
- $lang = wfGetLangObj( $langCode );
-
- # MessageCache::get() does this already, Language::getMessage() doesn't
- # ISSUE: Should we try to handle "message/lang" here too?
- $key = str_replace( ' ' , '_' , $wgContLang->lcfirst( $key ) );
-
- if( is_object( $lang ) ) {
- $message = $lang->getMessage( $key );
- } else {
- $message = false;
- }
+ if ( !is_object( $wgMessageCache ) ) {
+ throw new MWException( "Trying to get message before message cache is initialised" );
}
+ $message = $wgMessageCache->get( $key, $useDB, $langCode );
+ if( $message === false ){
+ $message = '<' . htmlspecialchars( $key ) . '>';
+ } elseif ( $transform ) {
+ $message = $wgMessageCache->transform( $message );
+ }
return $message;
}
* @deprecated
*/
function &wfGetMimeMagic() {
+ wfDeprecated( __FUNCTION__ );
return MimeMagic::singleton();
}
if ( is_null( $mode ) )
$mode = $wgDirectoryMode;
+ // Turn off the normal warning, we're doing our own below
+ wfSuppressWarnings();
$ok = mkdir( $dir, $mode, true ); // PHP5 <3
+ wfRestoreWarnings();
+
if( !$ok ) {
// PHP doesn't report the path in its warning message, so add our own to aid in diagnosis.
trigger_error( __FUNCTION__ . ": failed to mkdir \"$dir\" mode $mode", E_USER_WARNING );
throw new MWException( "MediaWiki $req_ver required--this is only $wgVersion" );
}
-/**
- * @deprecated use StringUtils::escapeRegexReplacement
- */
-function wfRegexReplacement( $string ) {
- return StringUtils::escapeRegexReplacement( $string );
-}
-
/**
* Return the final portion of a pathname.
* Reimplemented because PHP5's basename() is buggy with multibyte text.
$wgPostCommitUpdateList = array();
}
-/**
- * @deprecated use StringUtils::explodeMarkup
- */
-function wfExplodeMarkup( $separator, $text ) {
- return StringUtils::explodeMarkup( $separator, $text );
-}
-
/**
* Convert an arbitrarily-long digit string from one numeric base
* to another, optionally zero-padding to a minimum column width.
}
}
-/**
- * Alias for modularized function
- * @deprecated Use Http::isLocalURL() instead
- */
-function wfIsLocalURL( $url ) {
- wfDeprecated(__FUNCTION__);
- return Http::isLocalURL( $url );
-}
-
function wfHttpOnlySafe() {
global $wgHttpOnlyBlacklist;
if( !version_compare("5.2", PHP_VERSION, "<") )