r71072 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71071‎ | r71072 | r71073 >
Date:14:36, 14 August 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Work on Special:Extensions
Modified paths:
  • /trunk/extensions/Deployment/Deployment.i18n.php (modified) (history)
  • /trunk/extensions/Deployment/specials/SpecialExtensions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Deployment/specials/SpecialExtensions.php
@@ -34,8 +34,10 @@
3535 'http://svn.wikimedia.org/svnroot/mediawiki' => 'http://svn.wikimedia.org/viewvc/mediawiki',
3636 # Doesn't work at the time of writing but maybe some day:
3737 'https://svn.wikimedia.org/viewvc/mediawiki' => 'http://svn.wikimedia.org/viewvc/mediawiki',
38 - );
 38+ );
3939
 40+ protected $typeFilter;
 41+
4042 /**
4143 * Constructor.
4244 */
@@ -52,6 +54,8 @@
5355 */
5456 public function execute( $arg ) {
5557 global $wgOut, $wgUser;
 58+
 59+ $this->typeFilter = is_null( $arg ) ? 'all' : $arg;
5660
5761 $wgOut->setPageTitle( wfMsg( 'extensions-title' ) );
5862
@@ -105,22 +109,55 @@
106110 $extensionAmount = 0;
107111 $filterSegments = array();
108112
109 - // TODO: links
 113+ $extensionTypes = SpecialVersion::getExtensionTypes();
110114
111 - foreach ( $wgExtensionCredits as $type => $extensions ) {
112 - $amount = count( $extensions );
113 - $name = SpecialVersion::getExtensionTypeName( $type );
 115+ foreach ( $extensionTypes as $type => $message ) {
 116+ if ( !array_key_exists( $type, $wgExtensionCredits ) ) {
 117+ continue;
 118+ }
114119
115 - $filterSegments[] = "$name ($amount)";
116 - $extensionAmount += $amount;
 120+ $amount = count( $wgExtensionCredits[$type] );
 121+
 122+ if ( $amount > 0 ) {
 123+ $filterSegments[] = $this->getTypeLink( $type, $message, $amount );
 124+ $extensionAmount += $amount;
 125+ }
117126 }
118127
119 - $filterSegments = array_merge( array( "All ($extensionAmount)" ), $filterSegments );
 128+ $all = array( $this->getTypeLink( 'all', wfMsg( 'extension-type-all' ), $extensionAmount ) );
120129
121 - $wgOut->addHTML( implode( ' | ', $filterSegments ) );
 130+ $wgOut->addHTML( implode( ' | ', array_merge( $all, $filterSegments ) ) );
122131 }
123132
124133 /**
 134+ * Builds and returns the HTML for a single item in the filter control.
 135+ *
 136+ * @since 0.1
 137+ *
 138+ * @param $type String
 139+ * @param $message String
 140+ * @param $amount Integer
 141+ *
 142+ * @return string
 143+ */
 144+ protected function getTypeLink( $type, $message, $amount ) {
 145+ if ( $this->typeFilter == $type ) {
 146+ $name = Html::element( 'b', array(), $message );
 147+ }
 148+ else {
 149+ $name = Html::element(
 150+ 'a',
 151+ array(
 152+ 'href' => self::getTitle( $type )->getFullURL()
 153+ ),
 154+ $message
 155+ );
 156+ }
 157+
 158+ return "$name ($amount)";
 159+ }
 160+
 161+ /**
125162 * Creates and outputs the bilk actions control.
126163 *
127164 * @since 0.1
Index: trunk/extensions/Deployment/Deployment.i18n.php
@@ -35,6 +35,7 @@
3636
3737 // Special:Extensions
3838 'add-new-extensions' => 'Add new',
 39+ 'extension-type-all' => 'All',
3940
4041 // Special:Update
4142 'mediawiki-up-to-date' => 'You have the latest version of MediaWiki.',

Status & tagging log