Expose installed external libraries on Special:Version
authorKunal Mehta <legoktm@gmail.com>
Mon, 29 Dec 2014 20:16:59 +0000 (12:16 -0800)
committerBryanDavis <bdavis@wikimedia.org>
Mon, 29 Dec 2014 23:29:09 +0000 (23:29 +0000)
Change-Id: Ic767a06ccfd938fbe519333bbd683f6116aaa262

includes/specials/SpecialVersion.php
languages/i18n/en.json
languages/i18n/qqq.json

index d057b7c..3747e92 100644 (file)
@@ -132,6 +132,7 @@ class SpecialVersion extends SpecialPage {
                                $out->addHtml(
                                        $this->getSkinCredits() .
                                        $this->getExtensionCredits() .
+                                       $this->getExternalLibraries() .
                                        $this->getParserTags() .
                                        $this->getParserFunctionHooks()
                                );
@@ -503,6 +504,45 @@ class SpecialVersion extends SpecialPage {
                return $out;
        }
 
+       /**
+        * Generate an HTML table for external libraries that are installed
+        *
+        * @return string
+        */
+       protected function getExternalLibraries() {
+               global $IP;
+               $path = "$IP/composer.lock";
+               if ( !file_exists( $path ) ) {
+                       // Maybe they're using mediawiki/vendor?
+                       $path = "$IP/vendor/composer.lock";
+                       if ( !file_exists( $path ) ) {
+                               return '';
+                       }
+               }
+
+               $lock = new ComposerLock( $path );
+               $out = Html::element(
+                       'h2',
+                       array( 'id' => 'mw-version-libraries' ),
+                       $this->msg( 'version-libraries' )->text()
+               );
+               $out .= Html::openElement( 'table', array( 'class' => 'wikitable plainlinks', 'id' => 'sv-libraries' ) );
+               $out .= Html::openElement( 'tr' )
+                       . Html::element( 'th', array(), $this->msg( 'version-libraries-library' )->text() )
+                       . Html::element( 'th', array(), $this->msg( 'version-libraries-version' )->text() )
+                       . Html::closeElement( 'tr' );
+               ;
+               foreach ( $lock->getInstalledDependencies() as $name => $version ) {
+                       $out .= Html::openElement( 'tr' )
+                               . Html::rawElement( 'td', array(), Linker::makeExternalLink( "https://packagist.org/packages/$name", $name ) )
+                               . Html::element( 'td', array(), $version )
+                               . Html::closeElement( 'tr' );
+               }
+               $out .= Html::closeElement( 'table' );
+
+               return $out;
+       }
+
        /**
         * Obtains a list of installed parser tags and the associated H2 header
         *
index 14efc70..fddc975 100644 (file)
        "version-entrypoints-index-php": "[https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:index.php index.php]",
        "version-entrypoints-api-php": "[https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:api.php api.php]",
        "version-entrypoints-load-php": "[https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:load.php load.php]",
+       "version-libraries": "Installed libraries",
+       "version-libraries-library": "Library",
+       "version-libraries-version": "Version",
        "redirect": "Redirect by file, user, page or revision ID",
        "redirect-legend": "Redirect to a file or page",
        "redirect-text": "",
index 04a6f9d..69cfd8c 100644 (file)
        "version-entrypoints-index-php": "A short description of the index.php entry point. Links to the mediawiki.org documentation page for index.php.",
        "version-entrypoints-api-php": "A short description of the api.php entry point. Links to the mediawiki.org documentation page for api.php.",
        "version-entrypoints-load-php": "A short description of the load.php entry point. Links to the mediawiki.org documentation page for load.php.",
+       "version-libraries": "Header on [[Special:Version]] above a table that lists installed external libraries and their version numbers.",
+       "version-libraries-library": "Column header for the library's name",
+       "version-libraries-version": "Column header for the library's version number",
        "redirect": "{{doc-special|Redirect}}\nThis means \"Redirect by file'''name''', user '''ID''', page '''ID''', or revision ID\".",
        "redirect-legend": "Legend of fieldset around input box in [[Special:Redirect]]",
        "redirect-text": "Inside fieldset for [[Special:Redirect]]",