r50750 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50749‎ | r50750 | r50751 >
Date:20:27, 18 May 2009
Author:siebrand
Status:deferred
Tags:
Comment:
* add right- messages
* make array of 'author' in extension credits
* remove trailing whitespace, update indentation, stylize.php
* bump version
Modified paths:
  • /trunk/extensions/Todo/SpecialTodo.i18n.php (modified) (history)
  • /trunk/extensions/Todo/SpecialTodo.php (modified) (history)
  • /trunk/extensions/Todo/TodoForm.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Todo/TodoForm.php
@@ -1,16 +1,16 @@
22 <?php
33
4 -if( !defined( 'MEDIAWIKI' ) )
 4+if ( !defined( 'MEDIAWIKI' ) )
55 die();
66
77 class TodoTemplate extends QuickTemplate {
88 function execute() {
99 global $wgOut, $tododetail, $todosummary, $todoemail, $todosubmit;
10 - $todosummary = wfMsg('todo-issue-summary');
11 - $tododetail=wfMsg('todo-form-details');
12 - $todoemail=wfMsg('todo-form-email');
13 - $todosubmit=wfMsg('todo-form-submit');
14 - $wgOut->addHTML("
 10+ $todosummary = wfMsg( 'todo-issue-summary' );
 11+ $tododetail = wfMsg( 'todo-form-details' );
 12+ $todoemail = wfMsg( 'todo-form-email' );
 13+ $todosubmit = wfMsg( 'todo-form-submit' );
 14+ $wgOut->addHTML( "
1515 <style type=\"text/css\">
1616 .mwTodoNewForm {
1717 border: solid 1px #ccc;
@@ -22,15 +22,15 @@
2323 .mwTodoTitle {
2424 font-weight: bold;
2525 }
26 -</style>");
 26+</style>" );
2727 ?>
28 -<script type="text/javascript" src="<?php $this->text('script') ?>"></script>
 28+<script type="text/javascript" src="<?php $this->text( 'script' ) ?>"></script>
2929
30 -<form action="<?php $this->text('action') ?>" method="post">
 30+<form action="<?php $this->text( 'action' ) ?>" method="post">
3131 <input type="hidden" name="wpNewItem" value="1" />
3232 <p>
3333 <?php
34 -$wgOut->addHTML("
 34+$wgOut->addHTML( "
3535 <div class=\"mwTodoNewForm\">
3636 <label for=\"wpSummary\">{$todosummary}</label>
3737 <br />
Index: trunk/extensions/Todo/SpecialTodo.i18n.php
@@ -36,8 +36,10 @@
3737 'todo-new-item' => 'New item',
3838 'todo-issue-summary' => 'Issue summary:',
3939 'todo-form-details' => 'Details:',
40 - 'todo-form-email' => 'To receive notification by e-mail when the item is closed, type your address here:',
 40+ 'todo-form-email' => 'To receive notification by e-mail when the item is closed, provide your address:',
4141 'todo-form-submit' => 'Submit query',
 42+ 'right-todo' => 'Have todo list',
 43+ 'right-todosubmit' => 'Restrict user\'s todo list right',
4244 );
4345
4446 /** Message documentation (Message documentation)
Index: trunk/extensions/Todo/SpecialTodo.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 /*
54 CREATE TABLE todolist (
65 todo_id INT AUTO_INCREMENT,
@@ -20,17 +19,17 @@
2120 $wgExtensionCredits['other'][] = array(
2221 'path' => __FILE__,
2322 'name' => 'Todo',
24 - 'version' => '0.2',
 23+ 'version' => '0.3',
2524 'url' => 'http://www.mediawiki.org/wiki/Extension:Todo',
2625 'description' => 'Experimental personal todo list extension',
27 - 'author' => 'Brion Vibber, Bertrand Grondin',
 26+ 'author' => array( 'Brion Vibber', 'Bertrand Grondin' ),
2827 'descriptionmsg' => 'todo-desc',
2928 );
3029
3130 $wgExtensionFunctions[] = 'todoSetup';
3231 $wgHooks['SkinTemplateTabs'][] = 'todoAddTab';
3332
34 -$dir = dirname(__FILE__) . '/';
 33+$dir = dirname( __FILE__ ) . '/';
3534 $wgExtensionMessagesFiles['todoAddTab'] = $dir . 'SpecialTodo.i18n.php';
3635
3736 // Creates a group of users who can have todo lists
@@ -43,11 +42,13 @@
4443 $wgAvailableRights[] = 'todo';
4544 $wgAvailableRights[] = 'todosubmit';
4645
 46+// FIXME: use $wgSpecialPages and delay message loading
4747 function todoSetup() {
4848 wfLoadExtensionMessages( 'todoAddTab' );
4949 SpecialPage::addPage( new SpecialPage( 'Todo' ) );
5050 }
5151
 52+// FIXME: use class file(s) to delay loading
5253 /**
5354 * Add a 'todo' tab on user pages
5455 * @param SkinTemplate $skin
@@ -56,10 +57,10 @@
5758 */
5859 function todoAddTab( &$skin, &$actions ) {
5960 global $wgTitle;
60 - if( $wgTitle->getNamespace() == NS_USER || $wgTitle->getNamespace() == NS_USER_TALK ) {
 61+ if ( $wgTitle->getNamespace() == NS_USER || $wgTitle->getNamespace() == NS_USER_TALK ) {
6162 $title = Title::makeTitle( NS_SPECIAL, 'Todo/' . $wgTitle->getText() );
6263 $actions['todo'] = array(
63 - 'text' => wfMsg('todo-tab'),
 64+ 'text' => wfMsg( 'todo-tab' ),
6465 'href' => $title->getLocalUrl() );
6566 }
6667 return true;
@@ -69,20 +70,20 @@
7071 * Entry-point function for Special:Todo
7172 * @param mixed $par Will contain username to view on
7273 */
73 -function wfSpecialTodo( $par=null ) {
74 - if( is_null( $par ) || $par == '' ) {
 74+function wfSpecialTodo( $par = null ) {
 75+ if ( is_null( $par ) || $par == '' ) {
7576 global $wgUser;
7677 $user = $wgUser;
7778 } else {
7879 $user = User::newFromName( $par );
7980 }
80 - if( is_null( $user ) || !$user->isAllowed( 'todo' ) ) {
 81+ if ( is_null( $user ) || !$user->isAllowed( 'todo' ) ) {
8182 global $wgOut;
82 - $wgOut->fatalError( wfMsgHtml('todo-user-invalide') );
 83+ $wgOut->fatalError( wfMsgHtml( 'todo-user-invalide' ) );
8384 } else {
8485 global $wgRequest;
8586 $todo = new TodoForm( $user );
86 - if( $wgRequest->wasPosted() ) {
 87+ if ( $wgRequest->wasPosted() ) {
8788 $todo->submit( $wgRequest );
8889 } else {
8990 $todo->show();
@@ -97,9 +98,9 @@
9899 }
99100
100101 function submit( $request ) {
101 - if( $request->getVal( 'wpNewItem' ) ) {
 102+ if ( $request->getVal( 'wpNewItem' ) ) {
102103 $this->submitNew( $request );
103 - } elseif( $request->getVal( 'wpUpdateField' ) ) {
 104+ } elseif ( $request->getVal( 'wpUpdateField' ) ) {
104105 $this->submitUpdate( $request );
105106 }
106107 $this->showError( $result );
@@ -118,13 +119,13 @@
119120 function submitUpdate( $request ) {
120121 $id = $request->getInt( 'wpItem' );
121122 $item = TodoItem::loadFromId( $id );
122 - if( is_null( $item ) ) {
123 - return new WikiError( wfMsgHtml('todo-invalid-item') );
 123+ if ( is_null( $item ) ) {
 124+ return new WikiError( wfMsgHtml( 'todo-invalid-item' ) );
124125 }
125126
126127 global $wgUser;
127 - if( $item->owner != $wgUser->getId() ) {
128 - return new WikiError( wfMsgHtml('todo-update-else-item') );
 128+ if ( $item->owner != $wgUser->getId() ) {
 129+ return new WikiError( wfMsgHtml( 'todo-update-else-item' ) );
129130 }
130131
131132 switch( $request->getVal( 'wpUpdateField' ) ) {
@@ -144,19 +145,19 @@
145146
146147 function show() {
147148 global $wgOut, $IP, $wgUser, $wgScriptPath;
148 - $wgOut->setPageTitle( wfMsgHtml('todo-list-for', $this->target->getName() ) );
 149+ $wgOut->setPageTitle( wfMsgHtml( 'todo-list-for', $this->target->getName() ) );
149150
150151
151 - $wgOut->addWikiText( "== ".wfMsg('todo-new-item')." ==\n" );
 152+ $wgOut->addWikiText( "== " . wfMsg( 'todo-new-item' ) . " ==\n" );
152153
153 - require_once ('TodoForm.php');
 154+ require_once ( 'TodoForm.php' );
154155 $form = new TodoTemplate();
155156 $form->set( 'action', $this->self->getLocalUrl( 'action=submit' ) );
156157 $form->set( 'script', "$wgScriptPath/extensions/Todo/todo.js" );
157158 $wgOut->addTemplate( $form );
158159
159 - if( $wgUser->getName() == $this->target->getName() ) {
160 - $wgOut->addWikiText( "== ". wfMsg('todo-item-list') ." ==\n" );
 160+ if ( $wgUser->getName() == $this->target->getName() ) {
 161+ $wgOut->addWikiText( "== " . wfMsg( 'todo-item-list' ) . " ==\n" );
161162 $list = new TodoList( $this->target );
162163 $list->show();
163164 }
@@ -164,7 +165,7 @@
165166
166167 function showError( $result ) {
167168 global $wgOut;
168 - if( WikiError::isError( $result ) ) {
 169+ if ( WikiError::isError( $result ) ) {
169170 $wgOut->addHTML( '<p class="error">' .
170171 htmlspecialcahrs( $result->getMessage() ) .
171172 "</p>\n" );
@@ -190,7 +191,7 @@
191192 array( 'ORDER BY' => 'todo_owner,todo_status,todo_queue,todo_timestamp DESC' ) );
192193
193194 $this->items = array();
194 - while( $row = $dbr->fetchObject( $result ) ) {
 195+ while ( $row = $dbr->fetchObject( $result ) ) {
195196 $item = new TodoItem( $row );
196197 $this->items[$item->queue][] = $item;
197198 }
@@ -203,18 +204,18 @@
204205 $queues = array_keys( $this->items );
205206 usort( $queues, array( 'TodoList', 'queueSort' ) );
206207
207 - if( count( $queues ) == 0 ) {
208 - $wgOut->addWikiText( wfMsg('todo-no-item'));
 208+ if ( count( $queues ) == 0 ) {
 209+ $wgOut->addWikiText( wfMsg( 'todo-no-item' ) );
209210 return;
210211 }
211212
212213 $wgOut->addHTML( "<table>\n<tr>" );
213 - foreach( $queues as $queue ) {
 214+ foreach ( $queues as $queue ) {
214215 $wgOut->addHTML( Xml::element( 'th', null, $queue ) );
215216 }
216217 $wgOut->addHTML( "</tr>\n<tr>\n" );
217218
218 - foreach( $queues as $queue ) {
 219+ foreach ( $queues as $queue ) {
219220 $wgOut->addHTML( "<td valign='top'>\n<table border='1'>\n" );
220221 $this->showQueue( $queue, $queues );
221222 $wgOut->addHTML( "</table>\n</td>\n" );
@@ -231,13 +232,13 @@
232233 */
233234 function queueSort( $a, $b ) {
234235 $new = wfMsgForContent( 'todo-new-queue' );
235 - if( $a == $b ) {
 236+ if ( $a == $b ) {
236237 return 0;
237238 }
238 - if( $a == $new ) {
239 - return -1;
 239+ if ( $a == $new ) {
 240+ return - 1;
240241 }
241 - if( $b == $new ) {
 242+ if ( $b == $new ) {
242243 return 1;
243244 }
244245 return strcmp( $a, $b );
@@ -245,7 +246,7 @@
246247
247248 function showQueue( $queue, $queues ) {
248249 global $wgOut;
249 - foreach( $this->items[$queue] as $item ) {
 250+ foreach ( $this->items[$queue] as $item ) {
250251 $wgOut->addHTML( "<tr><td><div>" );
251252 $item->show( $queues );
252253 $wgOut->addHTML( "</div></td></tr>\n" );
@@ -275,7 +276,7 @@
276277 '*',
277278 array( 'todo_id' => intval( $id ) ),
278279 'TodoForm::loadFromId' );
279 - if( $row ) {
 280+ if ( $row ) {
280281 return new TodoItem( $row );
281282 } else {
282283 return null;
@@ -359,11 +360,11 @@
360361 "<br />\n" .
361362 Xml::element( 'input', array(
362363 'type' => 'submit',
363 - 'value' => wfMsg('todo-list-change') ) ) .
 364+ 'value' => wfMsg( 'todo-list-change' ) ) ) .
364365 " " .
365366 Xml::element( 'input', array(
366367 'type' => 'button',
367 - 'value' => wfMsg('todo-list-cancel'),
 368+ 'value' => wfMsg( 'todo-list-cancel' ),
368369 'onclick' => "todoEdit{$capField}($id,false)" ) ) .
369370 "</form></div>\n";
370371 }
@@ -388,18 +389,18 @@
389390
390391 function buildMoveSelector( $queues ) {
391392 $out = "<select name='wpQueue' id='mwTodoQueue" . $this->id . "' onchange='todoMoveQueue(" . $this->id . ")'>";
392 - foreach( $queues as $queue ) {
393 - if( $queue == $this->queue ) {
 393+ foreach ( $queues as $queue ) {
 394+ if ( $queue == $this->queue ) {
394395 $out .= Xml::element( 'option',
395396 array( 'value' => '', 'selected' => 'selected' ),
396 - wfMsgHtml('todo-move-queue') );
 397+ wfMsgHtml( 'todo-move-queue' ) );
397398 } else {
398399 $out .= Xml::element( 'option',
399400 array( 'value' => $queue ),
400401 $queue );
401402 }
402403 }
403 - $out .= "<option value='+' />".wfMsgHtml('todo-add-queue')."</option>\n";
 404+ $out .= "<option value='+' />" . wfMsgHtml( 'todo-add-queue' ) . "</option>\n";
404405 $out .= "</select>";
405406 return $out;
406407 }
@@ -435,7 +436,7 @@
436437 function close( $comment, $sendMail ) {
437438 $this->status = 'closed';
438439 $this->updateRecord( array( 'todo_status' => 'closed' ) );
439 - if( $sendMail && $this->email ) {
 440+ if ( $sendMail && $this->email ) {
440441 $this->sendConfirmationMail( $comment );
441442 }
442443 }
@@ -449,8 +450,8 @@
450451 global $wgContLang;
451452
452453 $owner = User::newFromId( $this->owner );
453 - if( is_null( $owner ) ) {
454 - return new WikiError( wfMsgHtml('todo-invalid-owner') );
 454+ if ( is_null( $owner ) ) {
 455+ return new WikiError( wfMsgHtml( 'todo-invalid-owner' ) );
455456 }
456457
457458 $sender = new MailAddress( $owner );

Status & tagging log