From: Kunal Mehta Date: Mon, 29 Dec 2014 20:16:59 +0000 (-0800) Subject: Expose installed external libraries on Special:Version X-Git-Tag: 1.31.0-rc.0~12840 X-Git-Url: https://git.heureux-cyclage.org/index.php?a=commitdiff_plain;h=528297f8db8dea32d7f6ec8742489ec44ed01468;p=lhc%2Fweb%2Fwiklou.git Expose installed external libraries on Special:Version Change-Id: Ic767a06ccfd938fbe519333bbd683f6116aaa262 --- diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index d057b7cdf0..3747e923d3 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -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 * diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 14efc708ef..fddc975026 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -3302,6 +3302,9 @@ "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": "", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 04a6f9dd14..69cfd8c887 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -3466,6 +3466,9 @@ "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]]",