Expose installed external libraries on Special:Version

Change-Id: Ic767a06ccfd938fbe519333bbd683f6116aaa262
This commit is contained in:
Kunal Mehta 2014-12-29 12:16:59 -08:00 committed by BryanDavis
parent ce49874d9f
commit 528297f8db
3 changed files with 46 additions and 0 deletions

View 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
*

View file

@ -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": "",

View file

@ -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]]",