First version of Page Language selector
[lhc/web/wiklou.git] / includes / actions / InfoAction.php
index 918fc9e..c2c1ff5 100644 (file)
@@ -33,7 +33,7 @@ class InfoAction extends FormlessAction {
        /**
         * Returns the name of the action this object responds to.
         *
-        * @return string lowercase
+        * @return string Lowercase name
         */
        public function getName() {
                return 'info';
@@ -194,7 +194,7 @@ class InfoAction extends FormlessAction {
         */
        protected function pageInfo() {
                global $wgContLang, $wgRCMaxAge, $wgMemc, $wgMiserMode,
-                       $wgUnwatchedPageThreshold, $wgPageInfoTransclusionLimit;
+                       $wgUnwatchedPageThreshold, $wgPageInfoTransclusionLimit, $wgPageLanguageUseDB;
 
                $user = $this->getUser();
                $lang = $this->getLanguage();
@@ -262,6 +262,7 @@ class InfoAction extends FormlessAction {
                        $sortKey = $pageProperties['defaultsort'];
                }
 
+               $sortKey = htmlspecialchars( $sortKey );
                $pageInfo['header-basic'][] = array( $this->msg( 'pageinfo-default-sort' ), $sortKey );
 
                // Page length (in bytes)
@@ -274,7 +275,20 @@ class InfoAction extends FormlessAction {
 
                // Language in which the page content is (supposed to be) written
                $pageLang = $title->getPageLanguage()->getCode();
-               $pageInfo['header-basic'][] = array( $this->msg( 'pageinfo-language' ),
+
+               if ( $wgPageLanguageUseDB && $this->getTitle()->userCan( 'pagelang' ) ) {
+                       // Link to Special:PageLanguage with pre-filled page title if user has permissions
+                       $titleObj = SpecialPage::getTitleFor( 'PageLanguage', $title->getPrefixedText() );
+                       $langDisp = Linker::link(
+                               $titleObj,
+                               $this->msg( 'pageinfo-language' )->escaped()
+                       );
+               } else {
+                       // Display just the message
+                       $langDisp = $this->msg( 'pageinfo-language' )->escaped();
+               }
+
+               $pageInfo['header-basic'][] = array( $langDisp,
                        Language::fetchLanguageName( $pageLang, $lang->getCode() )
                        . ' ' . $this->msg( 'parentheses', $pageLang ) );
 
@@ -289,6 +303,9 @@ class InfoAction extends FormlessAction {
                if ( isset( $pageProperties['noindex'] ) ) {
                        $pOutput->setIndexPolicy( 'noindex' );
                }
+               if ( isset( $pageProperties['index'] ) ) {
+                       $pOutput->setIndexPolicy( 'index' );
+               }
 
                // Use robot policy logic
                $policy = $this->page->getRobotPolicy( 'view', $pOutput );
@@ -760,7 +777,7 @@ class InfoAction extends FormlessAction {
 
        /**
         * Get a list of contributors of $article
-        * @return string: html
+        * @return string Html
         */
        protected function getContributors() {
                global $wgHiddenPrefs;