From: Matt Walker Date: Wed, 29 May 2013 02:52:05 +0000 (-0700) Subject: Further cleanup to Special:Version X-Git-Tag: 1.31.0-rc.0~17385^2 X-Git-Url: http://git.cyclocoop.org/fichier?a=commitdiff_plain;h=219b1ecdb3b0aad22d0e73ce71380c89cbdb0c20;p=lhc%2Fweb%2Fwiklou.git Further cleanup to Special:Version Cleaned up some HTML, added some CSS classes for the version information, and refactored some of the code. Also added column headers for the extension descriptions. Change-Id: I5bbc4d4024620ea57ab1bf778255a487fbc9b378 --- diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index 2465620246..60d6452d89 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -48,7 +48,7 @@ class SpecialVersion extends SpecialPage { * main() */ public function execute( $par ) { - global $wgSpecialVersionShowHooks, $IP, $wgExtensionCredits; + global $IP, $wgExtensionCredits; $this->setHeaders(); $this->outputHeader(); @@ -115,16 +115,18 @@ class SpecialVersion extends SpecialPage { break; default: + $out->addModules( 'mediawiki.special.version' ); $out->addWikiText( $this->getMediaWikiCredits() . $this->softwareInformation() . $this->getEntryPointInfo() ); - $out->addHtml( $this->getExtensionCredits() ); - if ( $wgSpecialVersionShowHooks ) { - $out->addWikiText( $this->getWgHooks() ); - } - + $out->addHtml( + $this->getExtensionCredits() . + $this->getParserTags() . + $this->getParserFunctionHooks() + ); + $out->addWikiText( $this->getWgHooks() ); $out->addHTML( $this->IPInfo() ); break; @@ -400,9 +402,9 @@ class SpecialVersion extends SpecialPage { * @return String: Wikitext */ function getExtensionCredits() { - global $wgExtensionCredits, $wgExtensionFunctions, $wgParser; + global $wgExtensionCredits; - if ( !count( $wgExtensionCredits ) && !count( $wgExtensionFunctions ) ) { + if ( !count( $wgExtensionCredits ) ) { return ''; } @@ -438,24 +440,63 @@ class SpecialVersion extends SpecialPage { // We want the 'other' type to be last in the list. $out .= $this->getExtensionCategory( 'other', $extensionTypes['other'] ); + $out .= Xml::closeElement( 'table' ); + + return $out; + } + + /** + * Obtains a list of installed parser tags and the associated H2 header + * + * @return string HTML output + */ + protected function getParserTags() { + global $wgParser; + $tags = $wgParser->getTags(); - $cnt = count( $tags ); - if ( $cnt ) { - for ( $i = 0; $i < $cnt; ++$i ) { - $tags[$i] = "<{$tags[$i]}>"; - } - $out .= $this->openExtType( $this->msg( 'version-parser-extensiontags' )->text(), 'parser-tags' ); - $out .= '' . $this->listToText( $tags ) . "\n"; + if ( count( $tags ) ) { + $out = Html::rawElement( + 'h2', + array( 'class' => 'mw-headline' ), + Linker::makeExternalLink( + '//www.mediawiki.org/wiki/Special:MyLanguage/Manual:Tag_extensions', + $this->msg( 'version-parser-extensiontags' )->parse(), + false /* msg()->parse() already escapes */ + ) + ); + + array_walk( $tags, function( &$value ) { + $value = '<' . htmlentities( $value ) . '>'; + } ); + $out .= $this->listToText( $tags ); + } else { + $out = ''; } + return $out; + } + + /** + * Obtains a list of installed parser function hooks and the associated H2 header + * + * @return string HTML output + */ + protected function getParserFunctionHooks() { + global $wgParser; + $fhooks = $wgParser->getFunctionHooks(); if ( count( $fhooks ) ) { - $out .= $this->openExtType( $this->msg( 'version-parser-function-hooks' )->text(), 'parser-function-hooks' ); - $out .= '' . $this->listToText( $fhooks ) . "\n"; - } + $out = Html::rawElement( 'h2', array( 'class' => 'mw-headline' ) , Linker::makeExternalLink( + '//www.mediawiki.org/wiki/Special:MyLanguage/Manual:Parser_functions', + $this->msg( 'version-parser-function-hooks' )->parse(), + false /* msg()->parse() already escapes */ + ) ); - $out .= Xml::closeElement( 'table' ); + $out .= $this->listToText( $fhooks ); + } else { + $out = ''; + } return $out; } @@ -507,13 +548,13 @@ class SpecialVersion extends SpecialPage { /** * Creates and formats a version line for a single extension. * - * Information for four columns will be created. Parameters required in the + * Information for five columns will be created. Parameters required in the * $extension array for part rendering are indicated in () * - The name of (name), and URL link to (url), the extension - * -- Also if available the short name of the license (license-name) and a linke - * to ((LICENSE)|(COPYING))(\.txt)? if it exists. * - Official version number (version) and if available version control system * revision (path), link, and date + * - If available the short name of the license (license-name) and a linke + * to ((LICENSE)|(COPYING))(\.txt)? if it exists. * - Description of extension (descriptionmsg or description) * - List of authors (author) and link to a ((AUTHORS)|(CREDITS))(\.txt)? file if it exists * @@ -588,13 +629,16 @@ class SpecialVersion extends SpecialPage { $versionString .= " {$vcsVerString}"; if ( $vcsDate ) { - $vcsTimeString = Html::element( 'br' ) . - Html::element( 'span', + $vcsTimeString = Html::element( 'span', array( 'class' => 'mw-version-ext-vcs-timestamp'), $this->getLanguage()->timeanddate( $vcsDate ) ); $versionString .= " {$vcsTimeString}"; } + $versionString = Html::rawElement( 'span', + array( 'class' => 'mw-version-ext-meta-version' ), + $versionString + ); } // ... and license information; if a license file exists we @@ -648,7 +692,8 @@ class SpecialVersion extends SpecialPage { ) ); - $html .= Html::rawElement( 'td', array(), '' . $extensionNameLink . '
' . $versionString ); + $html .= Html::rawElement( 'td', array(), $extensionNameLink ); + $html .= Html::rawElement( 'td', array(), $versionString ); $html .= Html::rawElement( 'td', array(), $licenseLink ); $html .= Html::rawElement( 'td', array( 'class' => 'mw-version-ext-description' ), $description ); $html .= Html::rawElement( 'td', array( 'class' => 'mw-version-ext-authors' ), $authors ); @@ -664,40 +709,44 @@ class SpecialVersion extends SpecialPage { * @return String: wikitext */ private function getWgHooks() { - global $wgHooks; + global $wgSpecialVersionShowHooks, $wgHooks; - if ( count( $wgHooks ) ) { + if ( $wgSpecialVersionShowHooks && count( $wgHooks ) ) { $myWgHooks = $wgHooks; ksort( $myWgHooks ); - $ret = Xml::element( 'h2', array( 'id' => 'mw-version-hooks' ), $this->msg( 'version-hooks' )->text() ) . - Xml::openElement( 'table', array( 'class' => 'wikitable', 'id' => 'sv-hooks' ) ) . - " - " . $this->msg( 'version-hook-name' )->text() . " - " . $this->msg( 'version-hook-subscribedby' )->text() . " - \n"; + $ret = array(); + $ret[] = '== {{int:version-hooks}} =='; + $ret[] = Html::openElement( 'table', array( 'class' => 'wikitable', 'id' => 'sv-hooks' ) ); + $ret[] = Html::openElement( 'tr' ); + $ret[] = Html::element( 'th', array(), $this->msg( 'version-hook-name' )->text() ); + $ret[] = Html::element( 'th', array(), $this->msg( 'version-hook-subscribedby' )->text() ); + $ret[] = Html::closeElement( 'tr' ); foreach ( $myWgHooks as $hook => $hooks ) { - $ret .= " - $hook - " . $this->listToText( $hooks ) . " - \n"; + $ret[] = Html::openElement( 'tr' ); + $ret[] = Html::element( 'td', array(), $hook ); + $ret[] = Html::element( 'td', array(), $this->listToText( $hooks ) ); + $ret[] = Html::closeElement( 'tr' ); } - $ret .= Xml::closeElement( 'table' ); - return $ret; + $ret[] = Html::closeElement( 'table' ); + + return implode( "\n", $ret ); } else { return ''; } } private function openExtType( $text, $name = null ) { - $opt = array( 'colspan' => 4 ); $out = ''; + $opt = array( 'colspan' => 5 ); if ( $this->firstExtOpened ) { // Insert a spacing line - $out .= '' . Html::element( 'td', $opt ) . "\n"; + $out .= Html::rawElement( 'tr', array( 'class' => 'sv-space' ), + Html::element( 'td', $opt ) + ); } $this->firstExtOpened = true; @@ -705,7 +754,22 @@ class SpecialVersion extends SpecialPage { $opt['id'] = "sv-$name"; } - $out .= "" . Xml::element( 'th', $opt, $text ) . "\n"; + $out .= Html::rawElement( 'tr', array(), + Html::element( 'th', $opt, $text ) + ); + + $out .= Html::openElement( 'tr' ); + $out .= Html::element( 'th', array( 'class' => 'mw-version-ext-col-label' ), + $this->msg( 'version-ext-colheader-name' )->text() ); + $out .= Html::element( 'th', array( 'class' => 'mw-version-ext-col-label' ), + $this->msg( 'version-ext-colheader-version' )->text() ); + $out .= Html::element( 'th', array( 'class' => 'mw-version-ext-col-label' ), + $this->msg( 'version-ext-colheader-license' )->text() ); + $out .= Html::element( 'th', array( 'class' => 'mw-version-ext-col-label' ), + $this->msg( 'version-ext-colheader-description' )->text() ); + $out .= Html::element( 'th', array( 'class' => 'mw-version-ext-col-label' ), + $this->msg( 'version-ext-colheader-credits' )->text() ); + $out .= Html::closeElement( 'tr' ); return $out; } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index d80ec61b13..5486978570 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -4821,6 +4821,11 @@ You can also [[Special:EditWatchlist|use the standard editor]].', 'version-credits-title' => 'Credits for $1', 'version-credits-not-found' => 'No detailed credits information was found for this extension.', 'version-ext-license' => 'License', +'version-ext-colheader-name' => 'Extension', +'version-ext-colheader-version' => 'Version', +'version-ext-colheader-license' => 'License', +'version-ext-colheader-description' => 'Description', +'version-ext-colheader-credits' => 'Authors', 'version-poweredby-credits' => "This wiki is powered by '''[//www.mediawiki.org/ MediaWiki]''', copyright © 2001-$1 $2.", 'version-poweredby-others' => 'others', 'version-poweredby-translators' => 'translatewiki.net translators', diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index 9ae5a0f20b..28a9f84b72 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -9959,6 +9959,11 @@ A short description of the script path entry point. Links to the mediawiki.org d 'version-credits-title' => 'Page title for an about/credits page for a MediaWiki extension. $1 is the name of the extension.', 'version-credits-not-found' => 'Descriptive error used when detailed about/credits for an extension are not available.', 'version-ext-license' => '{{Identical|License}}', +'version-ext-colheader-name' => 'Column header for the name of an extension', +'version-ext-colheader-version' => '{{Identical|version}} Column header for describing an extensions version', +'version-ext-colheader-license' => '{{Identical|License}} Column header for describing an extensions license', +'version-ext-colheader-description' => 'Column header for the description of an extension', +'version-ext-colheader-credits' => 'Column header for the list of authors and credits for an extension', # Special:Redirect 'redirect' => "{{doc-special|Redirect}} diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 0d990b60ab..985f82f60f 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -3660,6 +3660,11 @@ $wgMessageStructure = array( 'version-svn-revision', 'version-license', 'version-ext-license', + 'version-ext-colheader-name', + 'version-ext-colheader-version', + 'version-ext-colheader-license', + 'version-ext-colheader-description', + 'version-ext-colheader-credits', 'version-license-title', 'version-license-not-found', 'version-credits-title', diff --git a/resources/Resources.php b/resources/Resources.php index d2a06b782e..4426586453 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1100,6 +1100,9 @@ return array( 'position' => 'top', 'targets' => array( 'desktop', 'mobile' ), ), + 'mediawiki.special.version' => array( + 'styles' => 'resources/mediawiki.special/mediawiki.special.version.css', + ), /* MediaWiki Tests */ diff --git a/resources/mediawiki.special/mediawiki.special.version.css b/resources/mediawiki.special/mediawiki.special.version.css new file mode 100644 index 0000000000..917426a40a --- /dev/null +++ b/resources/mediawiki.special/mediawiki.special.version.css @@ -0,0 +1,14 @@ +/** + * Adds additional styling to the extension title/version list +**/ +.mw-version-ext-name { + font-weight: bold; +} + +.mw-version-ext-vcs-timestamp { + white-space: nowrap; +} + +th.mw-version-ext-col-label { + font-size: 0.9em; +} \ No newline at end of file