Merge "(bug 44338) set the site internal id when loading sites from the db"
[lhc/web/wiklou.git] / includes / specials / SpecialVersion.php
index 4e5b6bf..01a12c0 100644 (file)
@@ -48,29 +48,43 @@ class SpecialVersion extends SpecialPage {
         * main()
         */
        public function execute( $par ) {
         * main()
         */
        public function execute( $par ) {
-               global $wgSpecialVersionShowHooks;
+               global $wgSpecialVersionShowHooks, $IP;
 
                $this->setHeaders();
                $this->outputHeader();
                $out = $this->getOutput();
                $out->allowClickjacking();
 
 
                $this->setHeaders();
                $this->outputHeader();
                $out = $this->getOutput();
                $out->allowClickjacking();
 
-               $text =
-                       $this->getMediaWikiCredits() .
-                       $this->softwareInformation() .
-                       $this->getEntryPointInfo() .
-                       $this->getExtensionCredits();
-               if ( $wgSpecialVersionShowHooks ) {
-                       $text .= $this->getWgHooks();
-               }
+               if( $par !== 'Credits' ) {
+                       $text =
+                               $this->getMediaWikiCredits() .
+                               $this->softwareInformation() .
+                               $this->getEntryPointInfo() .
+                               $this->getExtensionCredits();
+                       if ( $wgSpecialVersionShowHooks ) {
+                               $text .= $this->getWgHooks();
+                       }
 
 
-               $out->addWikiText( $text );
-               $out->addHTML( $this->IPInfo() );
+                       $out->addWikiText( $text );
+                       $out->addHTML( $this->IPInfo() );
 
 
-               if ( $this->getRequest()->getVal( 'easteregg' ) ) {
-                       if ( $this->showEasterEgg() ) {
-                               // TODO: put something interesting here
+                       if ( $this->getRequest()->getVal( 'easteregg' ) ) {
+                               if ( $this->showEasterEgg() ) {
+                                       // TODO: put something interesting here
+                               }
                        }
                        }
+               } else {
+                       // Credits sub page
+
+                       // Header
+                       $out->addHTML( wfMessage( 'version-credits-summary' )->parseAsBlock() );
+
+                       $wikiText = file_get_contents( $IP . '/CREDITS' );
+
+                       // Take everything from the first section onwards, to remove the (not localized) header
+                       $wikiText = substr( $wikiText, strpos( $wikiText, '==' ) );
+
+                       $out->addWikiText( $wikiText );
                }
        }
 
                }
        }
 
@@ -108,10 +122,10 @@ class SpecialVersion extends SpecialPage {
                        'Alexandre Emsenhuber', 'Siebrand Mazeland', 'Chad Horohoe',
                        'Roan Kattouw', 'Trevor Parscal', 'Bryan Tong Minh', 'Sam Reed',
                        'Victor Vasiliev', 'Rotem Liss', 'Platonides', 'Antoine Musso',
                        'Alexandre Emsenhuber', 'Siebrand Mazeland', 'Chad Horohoe',
                        'Roan Kattouw', 'Trevor Parscal', 'Bryan Tong Minh', 'Sam Reed',
                        'Victor Vasiliev', 'Rotem Liss', 'Platonides', 'Antoine Musso',
-                       'Timo Tijhof',
-                       '[{{SERVER}}{{SCRIPTPATH}}/CREDITS ' .
+                       'Timo Tijhof', 'Daniel Kinzler', 'Jeroen De Dauw',
+                       '[[Special:Version/Credits|' .
                        wfMessage( 'version-poweredby-others' )->text() .
                        wfMessage( 'version-poweredby-others' )->text() .
-                       ']'
+                       ']]'
                );
 
                return wfMessage( 'version-poweredby-credits', date( 'Y' ),
                );
 
                return wfMessage( 'version-poweredby-credits', date( 'Y' ),
@@ -222,7 +236,7 @@ class SpecialVersion extends SpecialPage {
         * @return string wgVersion + a link to subversion revision of svn BASE
         */
        private static function getVersionLinkedSvn() {
         * @return string wgVersion + a link to subversion revision of svn BASE
         */
        private static function getVersionLinkedSvn() {
-               global $wgVersion, $IP;
+               global $IP;
 
                $info = self::getSvnInfo( $IP );
                if( !isset( $info['checkout-rev'] ) ) {
 
                $info = self::getSvnInfo( $IP );
                if( !isset( $info['checkout-rev'] ) ) {
@@ -236,19 +250,33 @@ class SpecialVersion extends SpecialPage {
                )->text();
 
                if ( isset( $info['viewvc-url'] ) ) {
                )->text();
 
                if ( isset( $info['viewvc-url'] ) ) {
-                       $version = "$wgVersion [{$info['viewvc-url']} $linkText]";
+                       $version = "[{$info['viewvc-url']} $linkText]";
                } else {
                } else {
-                       $version = "$wgVersion $linkText";
+                       $version = $linkText;
                }
 
                }
 
-               return $version;
+               return self::getwgVersionLinked() . " $version";
+       }
+
+       /**
+        * @return string
+        */
+       private static function getwgVersionLinked() {
+               global $wgVersion;
+               $versionUrl = "";
+               if( wfRunHooks( 'SpecialVersionVersionUrl', array( $wgVersion, &$versionUrl ) ) ) {
+                       $versionParts = array();
+                       preg_match( "/^(\d+\.\d+)/", $wgVersion, $versionParts );
+                       $versionUrl = "https://www.mediawiki.org/wiki/MediaWiki_{$versionParts[1]}";
+               }
+               return "[$versionUrl $wgVersion]";
        }
 
        /**
         * @return bool|string wgVersion + HEAD sha1 stripped to the first 7 chars. False on failure
         */
        private static function getVersionLinkedGit() {
        }
 
        /**
         * @return bool|string wgVersion + HEAD sha1 stripped to the first 7 chars. False on failure
         */
        private static function getVersionLinkedGit() {
-               global $wgVersion, $IP;
+               global $IP;
 
                $gitInfo = new GitInfo( $IP );
                $headSHA1 = $gitInfo->getHeadSHA1();
 
                $gitInfo = new GitInfo( $IP );
                $headSHA1 = $gitInfo->getHeadSHA1();
@@ -261,7 +289,7 @@ class SpecialVersion extends SpecialPage {
                if ( $viewerUrl !== false ) {
                        $shortSHA1 = "[$viewerUrl $shortSHA1]";
                }
                if ( $viewerUrl !== false ) {
                        $shortSHA1 = "[$viewerUrl $shortSHA1]";
                }
-               return "$wgVersion $shortSHA1";
+               return self::getwgVersionLinked() . " $shortSHA1";
        }
 
        /**
        }
 
        /**
@@ -747,25 +775,39 @@ class SpecialVersion extends SpecialPage {
                return $repo->getHeadSHA1();
        }
 
                return $repo->getHeadSHA1();
        }
 
+
        /**
         * Get the list of entry points and their URLs
         * @return string Wikitext
         */
        public function getEntryPointInfo() {
                global $wgArticlePath, $wgScriptPath;
        /**
         * Get the list of entry points and their URLs
         * @return string Wikitext
         */
        public function getEntryPointInfo() {
                global $wgArticlePath, $wgScriptPath;
+               $scriptPath = $wgScriptPath ? $wgScriptPath : "/";
                $entryPoints = array(
                        'version-entrypoints-articlepath' => $wgArticlePath,
                $entryPoints = array(
                        'version-entrypoints-articlepath' => $wgArticlePath,
-                       'version-entrypoints-scriptpath' => $wgScriptPath,
+                       'version-entrypoints-scriptpath' => $scriptPath,
                        'version-entrypoints-index-php' => wfScript( 'index' ),
                        'version-entrypoints-api-php' => wfScript( 'api' ),
                        'version-entrypoints-load-php' => wfScript( 'load' ),
                );
 
                        'version-entrypoints-index-php' => wfScript( 'index' ),
                        'version-entrypoints-api-php' => wfScript( 'api' ),
                        'version-entrypoints-load-php' => wfScript( 'load' ),
                );
 
+               $language = $this->getLanguage();
+               $thAttribures = array(
+                       'dir' => $language->getDir(),
+                       'lang' => $language->getCode()
+               );
                $out = Html::element( 'h2', array( 'id' => 'mw-version-entrypoints' ), $this->msg( 'version-entrypoints' )->text() ) .
                $out = Html::element( 'h2', array( 'id' => 'mw-version-entrypoints' ), $this->msg( 'version-entrypoints' )->text() ) .
-                       Html::openElement( 'table', array( 'class' => 'wikitable plainlinks', 'id' => 'mw-version-entrypoints-table' ) ) .
+                       Html::openElement( 'table',
+                               array(
+                                       'class' => 'wikitable plainlinks',
+                                       'id' => 'mw-version-entrypoints-table',
+                                       'dir' => 'ltr',
+                                       'lang' => 'en'
+                               )
+                       ) .
                        Html::openElement( 'tr' ) .
                        Html::openElement( 'tr' ) .
-                       Html::element( 'th', array(), $this->msg( 'version-entrypoints-header-entrypoint' )->text() ) .
-                       Html::element( 'th', array(), $this->msg( 'version-entrypoints-header-url' )->text() ) .
+                       Html::element( 'th', $thAttribures, $this->msg( 'version-entrypoints-header-entrypoint' )->text() ) .
+                       Html::element( 'th', $thAttribures, $this->msg( 'version-entrypoints-header-url' )->text() ) .
                        Html::closeElement( 'tr' );
 
                foreach ( $entryPoints as $message => $value ) {
                        Html::closeElement( 'tr' );
 
                foreach ( $entryPoints as $message => $value ) {