First version of Page Language selector
[lhc/web/wiklou.git] / includes / Title.php
index d8f6b75..e038cc7 100644 (file)
@@ -150,6 +150,9 @@ class Title {
        /** @var bool The (string) language code of the page's language and content code. */
        private $mPageLanguage = false;
 
+       /** @var string The page language code from the database */
+       private $mDbPageLanguage = null;
+
        /** @var TitleValue A corresponding TitleValue object */
        private $mTitleValue = null;
        // @}
@@ -439,6 +442,9 @@ class Title {
                        } else {
                                $this->mContentModel = false; # initialized lazily in getContentModel()
                        }
+                       if ( isset( $row->page_lang ) ) {
+                               $this->mDbPageLanguage = (string)$row->page_lang;
+                       }
                } else { // page not found
                        $this->mArticleID = 0;
                        $this->mLength = 0;
@@ -2723,11 +2729,14 @@ class Title {
         * Cascading protection: Get the source of any cascading restrictions on this page.
         *
         * @param bool $getPages Whether or not to retrieve the actual pages
-        *        that the restrictions have come from.
-        * @return array|bool Array of Title objects of the pages from which cascading restrictions
-        *     have come, false for none, or true if such restrictions exist, but $getPages
-        *     was not set.  The restriction array is an array of each type, each of which
-        *     contains a array of unique groups.
+        *        that the restrictions have come from and the actual restrictions
+        *        themselves.
+        * @return array Two elements: First is an array of Title objects of the
+        *        pages from which cascading restrictions have come, false for
+        *        none, or true if such restrictions exist but $getPages was not
+        *        set. Second is an array like that returned by
+        *        Title::getAllRestrictions(), or an empty array if $getPages is
+        *        false.
         */
        public function getCascadeProtectionSources( $getPages = true ) {
                global $wgContLang;
@@ -2834,7 +2843,8 @@ class Title {
         * Accessor/initialisation for mRestrictions
         *
         * @param string $action Action that permission needs to be checked for
-        * @return array Array of Strings the array of groups allowed to edit this article
+        * @return array Restriction levels needed to take the action. All levels
+        *     are required.
         */
        public function getRestrictions( $action ) {
                if ( !$this->mRestrictionsLoaded ) {
@@ -2848,9 +2858,8 @@ class Title {
        /**
         * Accessor/initialisation for mRestrictions
         *
-        * @return array Array of Arrays of Strings the first level indexed by
-        * action, the second level containing the names of the groups
-        * allowed to perform each action
+        * @return array Keys are actions, values are arrays as returned by
+        *     Title::getRestrictions()
         * @since 1.23
         */
        public function getAllRestrictions() {
@@ -3317,6 +3326,7 @@ class Title {
                $this->mContentModel = false;
                $this->mEstimateRevisions = null;
                $this->mPageLanguage = false;
+               $this->mDbPageLanguage = null;
        }
 
        /**
@@ -4974,6 +4984,12 @@ class Title {
                        return $wgLang;
                }
 
+               // Checking if DB language is set
+               if ( $this->mDbPageLanguage ) {
+                       wfProfileOut( __METHOD__ );
+                       return wfGetLangObj( $this->mDbPageLanguage );
+               }
+
                if ( !$this->mPageLanguage || $this->mPageLanguage[1] !== $wgLanguageCode ) {
                        // Note that this may depend on user settings, so the cache should
                        // be only per-request.
@@ -4987,6 +5003,7 @@ class Title {
                } else {
                        $langObj = wfGetLangObj( $this->mPageLanguage[0] );
                }
+
                wfProfileOut( __METHOD__ );
                return $langObj;
        }