Follow-up to r90265: directionality improvements as part of bug 6100 (under $wgBetter...
[lhc/web/wiklou.git] / includes / parser / ParserOptions.php
index 52a5b84..49473ca 100644 (file)
@@ -17,8 +17,7 @@ class ParserOptions {
        var $mInterwikiMagic;            # Interlanguage links are removed and returned in an array
        var $mAllowExternalImages;       # Allow external images inline
        var $mAllowExternalImagesFrom;   # If not, any exception?
-       var $mEnableImageWhitelist;      # If not or it doesn't match, should we check an on-wiki whitelist?
-       var $mSkin = null;               # Reference to the preferred skin
+       var $mEnableImageWhitelist;      # If not or it doesn't match, should we check an on-wiki whitelist? 
        var $mDateFormat = null;         # Date format index
        var $mEditSection = true;        # Create "edit section" links
        var $mAllowSpecialInclusion;     # Allow inclusion of special pages
@@ -67,7 +66,17 @@ class ParserOptions {
        function getAllowSpecialInclusion()         { return $this->mAllowSpecialInclusion; }
        function getTidy()                          { return $this->mTidy; }
        function getInterfaceMessage()              { return $this->mInterfaceMessage; }
-       function getTargetLanguage()                { return $this->mTargetLanguage; }
+       function getTargetLanguage( $title = null ) {
+               if ( $title && $title->isCssOrJsPage() ) {
+                       return Language::factory( 'en' ); // css/js should always be LTR
+               } elseif ( $title && $title->getNamespace() == NS_MEDIAWIKI ) {
+                       // Parse mediawiki messages with correct target language
+                       list( /* $unused */, $lang ) = MessageCache::singleton()->figureMessage( $title->getText() );
+                       $obj = wfGetLangObj( $lang );
+                       return $obj;
+               }
+       return $this->mTargetLanguage;
+}
        function getMaxIncludeSize()                { return $this->mMaxIncludeSize; }
        function getMaxPPNodeCount()                { return $this->mMaxPPNodeCount; }
        function getMaxPPExpandDepth()              { return $this->mMaxPPExpandDepth; }
@@ -91,16 +100,14 @@ class ParserOptions {
        function getUser()                          { return $this->mUser; }
        function getPreSaveTransform()              { return $this->mPreSaveTransform; }
 
-       /**
-        * @param $title Title
-        * @return Skin
-        * @deprecated Use Linker::* instead
-        */
-       function getSkin( $title = null ) {
-               if ( !isset( $this->mSkin ) ) {
-                       $this->mSkin = $this->mUser->getSkin( $title );
-               }
-               return $this->mSkin;
+       /**      
+        * @param $title Title   
+        * @return Skin          
+        * @deprecated since 1.18 Use Linker::* instead
+        */      
+       function getSkin( $title = null ) {      
+               wfDeprecated( __METHOD__ );
+               return new DummyLinker;
        }
 
        function getDateFormat() {
@@ -122,6 +129,8 @@ class ParserOptions {
         * You shouldn't use this. Really. $parser->getFunctionLang() is all you need.
         * Using this fragments the cache and is discouraged. Yes, {{int: }} uses this,
         * producing inconsistent tables (Bug 14404).
+        * @return String   Language code
+        * @since 1.17
         */
        function getUserLang() {
                $this->optionUsed('userlang');
@@ -140,7 +149,7 @@ class ParserOptions {
        function setTidy( $x )                      { return wfSetVar( $this->mTidy, $x); }
        function setSkin( $x )                      { $this->mSkin = $x; }
        function setInterfaceMessage( $x )          { return wfSetVar( $this->mInterfaceMessage, $x); }
-       function setTargetLanguage( $x )            { return wfSetVar( $this->mTargetLanguage, $x); }
+       function setTargetLanguage( $x )            { return wfSetVar( $this->mTargetLanguage, $x, true ); }
        function setMaxIncludeSize( $x )            { return wfSetVar( $this->mMaxIncludeSize, $x ); }
        function setMaxPPNodeCount( $x )            { return wfSetVar( $this->mMaxPPNodeCount, $x ); }
        function setMaxTemplateDepth( $x )          { return wfSetVar( $this->mMaxTemplateDepth, $x ); }
@@ -151,7 +160,12 @@ class ParserOptions {
        function setCleanSignatures( $x )           { return wfSetVar( $this->mCleanSignatures, $x ); }
        function setExternalLinkTarget( $x )        { return wfSetVar( $this->mExternalLinkTarget, $x ); }
        function setMath( $x )                      { return wfSetVar( $this->mMath, $x ); }
-       function setUserLang( $x )                  { return wfSetVar( $this->mUserLang, $x ); }
+       function setUserLang( $x )                  {
+               if ( $x instanceof Language ) {
+                       $x = $x->getCode();
+               }
+               return wfSetVar( $this->mUserLang, $x );
+       }
        function setThumbSize( $x )                 { return wfSetVar( $this->mThumbSize, $x ); }
        function setStubThreshold( $x )             { return wfSetVar( $this->mStubThreshold, $x ); }
        function setPreSaveTransform( $x )          { return wfSetVar( $this->mPreSaveTransform, $x ); }
@@ -310,13 +324,9 @@ class ParserOptions {
                        $confstr .= '!*';
 
                // add in language specific options, if any
-               // FIXME: This is just a way of retrieving the url/user preferred variant
+               // @todo FIXME: This is just a way of retrieving the url/user preferred variant
                $confstr .= $wgContLang->getExtraHashOptions();
 
-               // Since the skin could be overloading link(), it should be
-               // included here but in practice, none of our skins do that.
-               // $confstr .= "!" . $this->mSkin->getSkinName();
-
                $confstr .= $wgRenderHashAppend;
 
                if ( !in_array( 'editsection', $forOptions ) ) {