r71093 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71092‎ | r71093 | r71094 >
Date:22:17, 14 August 2010
Author:ashley
Status:reverted
Tags:
Comment:
MWReleases: coding style tweaks and consistent capitalization for 'MediaWiki' (thus renamed MediawikiRelease -> MediaWikiRelease and SpecialDownloadMediawiki -> SpecialDownloadMediaWiki) and added check for MW environment to the setup file
Modified paths:
  • /trunk/extensions/MWReleases/MWReleases.alias.php (modified) (history)
  • /trunk/extensions/MWReleases/MWReleases.i18n.php (modified) (history)
  • /trunk/extensions/MWReleases/MWReleases.php (modified) (history)
  • /trunk/extensions/MWReleases/api/ApiMWReleases.php (modified) (history)
  • /trunk/extensions/MWReleases/backend/Release.php (modified) (history)
  • /trunk/extensions/MWReleases/backend/ReleaseRepo.php (modified) (history)
  • /trunk/extensions/MWReleases/ui/SpecialDownloadMediawiki.php (modified) (history)
  • /trunk/extensions/MWReleases/ui/SpecialReleaseManager.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MWReleases/MWReleases.alias.php
@@ -1,6 +1,6 @@
22 <?php
33 /**
4 - * Aliases for MWReleases
 4+ * Special page aliases for MWReleases extension.
55 *
66 * @file
77 * @ingroup Extensions
@@ -8,10 +8,10 @@
99
1010 $aliases = array();
1111
12 -/**
13 - * English
 12+/** English
 13+ * @author Chad Horohoe
1414 */
1515 $aliases['en'] = array(
1616 'ReleaseManager' => array( 'ReleaseManager' ),
17 - 'DownloadMediawiki' => array( 'DownloadMediawiki' ),
 17+ 'DownloadMediaWiki' => array( 'DownloadMediaWiki' ),
1818 );
Index: trunk/extensions/MWReleases/backend/Release.php
@@ -6,7 +6,7 @@
77 const SUPPORTED = 2;
88 }
99
10 -class MediawikiRelease implements Release {
 10+class MediaWikiRelease implements Release {
1111
1212 private $id, $name, $number, $reldate, $eoldate, $branch, $tag,
1313 $announcement, $supported = null;
Index: trunk/extensions/MWReleases/backend/ReleaseRepo.php
@@ -43,12 +43,12 @@
4444
4545 public function releaseExists( $id ) {
4646 $this->load();
47 - return isset( $this->releases[ $id ] );
 47+ return isset( $this->releases[$id] );
4848 }
4949
5050 public function getReleaseForId( $id ) {
5151 if( $this->releaseExists( $id ) ) {
52 - return $this->releases[ $id ];
 52+ return $this->releases[$id];
5353 }
5454 return null;
5555 }
@@ -71,9 +71,9 @@
7272 $this->releases = array();
7373 $res = $dbr->select( 'mwreleases', '*', array(), __METHOD__ );
7474 foreach( $res as $row ) {
75 - if( !isset( $this->releases[ $row->mwr_id ] ) ) {
76 - $mw = MediawikiRelease::newFromRow( $row );
77 - $this->releases[ $mw->getId() ] = $mw;
 75+ if( !isset( $this->releases[$row->mwr_id] ) ) {
 76+ $mw = MediaWikiRelease::newFromRow( $row );
 77+ $this->releases[$mw->getId()] = $mw;
7878 }
7979 }
8080 uasort( $this->releases, array( $this, 'sortReleasesDesc' ) );
Index: trunk/extensions/MWReleases/api/ApiMWReleases.php
@@ -5,8 +5,8 @@
66 */
77
88 class ApiMWReleases extends ApiBase {
9 - public function __construct($main, $action) {
10 - parent :: __construct($main, $action);
 9+ public function __construct( $main, $action ) {
 10+ parent::__construct( $main, $action );
1111 }
1212
1313 public function execute() {
@@ -55,15 +55,15 @@
5656 }
5757 $results[] = $r;
5858 }
59 - $this->getResult()->setIndexedTagName($results, 'release');
60 - $this->getResult()->addValue(null, $this->getModuleName(), $results);
 59+ $this->getResult()->setIndexedTagName( $results, 'release' );
 60+ $this->getResult()->addValue( null, $this->getModuleName(), $results );
6161 }
6262
6363 public function getAllowedParams() {
6464 return array(
6565 'prop' => array(
6666 ApiBase::PARAM_ISMULTI => true,
67 - ApiBase::PARAM_TYPE => array (
 67+ ApiBase::PARAM_TYPE => array(
6868 'name',
6969 'number',
7070 'reldate',
@@ -87,8 +87,8 @@
8888 }
8989
9090 public function getDescription() {
91 - return array (
92 - 'Get the list of current Mediawiki releases'
 91+ return array(
 92+ 'Get the list of current MediaWiki releases'
9393 );
9494 }
9595
@@ -98,6 +98,7 @@
9999 'api.php?action=mwreleases&&allreleases=1&prop=name|reldate|eoldate'
100100 );
101101 }
 102+
102103 public function getVersion() {
103104 return __CLASS__ . ': ' . MWRELEASES_VERSION;
104105 }
Index: trunk/extensions/MWReleases/MWReleases.i18n.php
@@ -1,23 +1,26 @@
22 <?php
3 -
43 /**
5 - * Internationalization file for MWReleases
 4+ * Internationalization file for MWReleases extension.
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
68 */
 9+
710 $messages = array();
811
9 -/**
10 - * English
 12+/** English
 13+ * @author Chad Horohoe
1114 */
1215 $messages['en'] = array(
1316 'mwr-desc' => 'Manages releases of the MediaWiki software',
14 - 'releasemanager' => 'Mediawiki release manager',
15 - 'releasemanager-header' => 'Welcome to the Mediawiki release manager. Use the options below to manage the releases',
 17+ 'releasemanager' => 'MediaWiki release manager',
 18+ 'releasemanager-header' => 'Welcome to the MediaWiki release manager. Use the options below to manage the releases',
1619 'releasemanager-add' => 'Add new release',
1720 'releasemanager-supported-til-eol' => 'Supported until EOL date, currently: $1', // $1 is yes/no
1821 'releasemanager-supported-overriden' => 'Support overridden, currently: $1', // $1 is yes/no
1922 'releasemanager-doesnotexist' => 'The specified release does not exist',
2023 'releasemanager-delete-confirm' => 'Are you sure you want to delete this release?',
21 - 'downloadmediawiki' => 'Download Mediawiki',
 24+ 'downloadmediawiki' => 'Download MediaWiki',
2225 'mwr-field-name' => 'Name',
2326 'mwr-field-number' => 'Number',
2427 'mwr-field-eoldate' => 'End of life date',
Index: trunk/extensions/MWReleases/MWReleases.php
@@ -1,7 +1,7 @@
22 <?php
33 /**
44 * MWReleases - lets us maintain a list of releases that we support
5 - * on Mediawiki.org, to be queried by the API. Goal is to have the
 5+ * on MediaWiki.org, to be queried by the API. Goal is to have the
66 * installer and updater check MW.org for latest versions :)
77 *
88 * This program is free software; you can redistribute it and/or modify
@@ -23,6 +23,10 @@
2424 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
2525 */
2626
 27+if ( !defined( 'MEDIAWIKI' ) ) {
 28+ die( 'This is not a valid entry point.' );
 29+}
 30+
2731 define( 'MWRELEASES_VERSION', '2.0' );
2832
2933 $wgExtensionCredits['other'][] = array(
@@ -40,8 +44,8 @@
4145 $wgAutoloadClasses['ApiMWReleases'] = $dir . 'api/ApiMWReleases.php';
4246 $wgAutoloadClasses['ReleaseRepo'] = $dir . 'backend/ReleaseRepo.php';
4347 $wgAutoloadClasses['Release'] = $dir . 'backend/Release.php';
44 -$wgAutoloadClasses['MediawikiRelease'] = $dir . 'backend/Release.php';
45 -$wgAutoloadClasses['SpecialDownloadMediawiki'] = $dir . 'ui/SpecialDownloadMediawiki.php';
 48+$wgAutoloadClasses['MediaWikiRelease'] = $dir . 'backend/Release.php';
 49+$wgAutoloadClasses['SpecialDownloadMediaWiki'] = $dir . 'ui/SpecialDownloadMediawiki.php';
4650 $wgAutoloadClasses['SpecialReleaseManager'] = $dir . 'ui/SpecialReleaseManager.php';
4751
4852 // i18n
@@ -52,7 +56,7 @@
5357 $wgAPIModules['mwreleases'] = 'ApiMWReleases';
5458
5559 // Special pages
56 -$wgSpecialPages['DownloadMediawiki'] = 'SpecialDownloadMediawiki';
 60+$wgSpecialPages['DownloadMediaWiki'] = 'SpecialDownloadMediaWiki';
5761 $wgSpecialPages['ReleaseManager'] = 'SpecialReleaseManager';
5862
5963 // Hooks
@@ -70,6 +74,6 @@
7175 function wfMWReleaseSchemaUpdates() {
7276 global $wgExtNewTables;
7377 $wgExtNewTables['mwreleases'] = dirname(__FILE__) . '/MWReleases.sql';
74 -
 78+
7579 return true;
7680 }
\ No newline at end of file
Index: trunk/extensions/MWReleases/ui/SpecialDownloadMediawiki.php
@@ -1,9 +1,9 @@
22 <?php
33
4 -class SpecialDownloadMediawiki extends SpecialPage {
 4+class SpecialDownloadMediaWiki extends SpecialPage {
55
66 public function __construct() {
7 - parent::__construct( 'DownloadMediawiki' );
 7+ parent::__construct( 'DownloadMediaWiki' );
88 }
99
1010 public function execute( $par ) {
Index: trunk/extensions/MWReleases/ui/SpecialReleaseManager.php
@@ -25,7 +25,9 @@
2626 switch( $params[0] ) {
2727 case 'edit':
2828 if( isset( $params[1] ) ) {
29 - if( $wgRequest->wasPosted() ) $this->postEdit( $params[1], $wgRequest );
 29+ if( $wgRequest->wasPosted() ) {
 30+ $this->postEdit( $params[1], $wgRequest );
 31+ }
3032 $this->showEdit( $params[1] );
3133 }
3234 break;
@@ -39,7 +41,9 @@
4042 }
4143 }
4244 case 'add':
43 - if( $wgRequest->wasPosted() ) $this->postAdd( $wgRequest );
 45+ if( $wgRequest->wasPosted() ) {
 46+ $this->postAdd( $wgRequest );
 47+ }
4448 $this->showAdd();
4549 break;
4650 default:
@@ -58,8 +62,10 @@
5963 ) . Html::element( 'hr' ) . Html::closeElement( 'div' ) .
6064 Html::openElement( 'table', array( 'class' => 'wikitable plainlinks sortable' ) ) .
6165 Html::openElement( 'tr' );
62 - foreach( MediawikiRelease::getFieldNames() as $field ) {
63 - if( $field == 'id' ) continue;
 66+ foreach( MediaWikiRelease::getFieldNames() as $field ) {
 67+ if( $field == 'id' ) {
 68+ continue;
 69+ }
6470 $h .= Html::element( 'th', array(), wfMsg( "mwr-field-$field" ) );
6571 }
6672 $h .= Html::element( 'th', array(), 'edit/del' ) . Html::closeElement( 'tr' );
@@ -70,7 +76,7 @@
7177 $this->out->addHTML( $h );
7278 }
7379
74 - private function formatReleaseForTable( MediawikiRelease $rel ) {
 80+ private function formatReleaseForTable( MediaWikiRelease $rel ) {
7581 global $wgLang;
7682 $branchUrl = $this->skin->makeExternalLink( $rel->getBranchUrl(), $rel->getBranch () );
7783 $tagUrl = $this->skin->makeExternalLink( $rel->getTagUrl(), $rel->getTag() );
@@ -106,7 +112,7 @@
107113 }
108114
109115 private function showEdit( $versionId ) {
110 -
 116+
111117 }
112118
113119 private function postEdit( $versionId, $wgRequest ) {
@@ -117,10 +123,10 @@
118124 $this->out->addWikiMsg( 'releasemanager-doesnotexist' );
119125 return;
120126 } else {
121 - $submitUrl = $this->getTitleFor( 'ReleaseManager', "delete/$versionId" )->getFullUrl();
 127+ $submitUrl = $this->getTitleFor( 'ReleaseManager', "delete/$versionId" )->getFullURL();
122128 $this->out->addWikiMsg( 'releasemanager-delete-confirm' );
123129 $h = Html::openElement( 'form', array( 'action' => $submitUrl,
124 - 'method' => 'POST' ) ) .
 130+ 'method' => 'post' ) ) .
125131 Html::input( 'submit', wfMsg( 'submit' ), 'submit' ) .
126132 Html::closeElement( 'form' );
127133 $this->out->addHTML( $h );

Status & tagging log