Index: trunk/extensions/Todo/TodoForm.php |
— | — | @@ -1,16 +1,16 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -if( !defined( 'MEDIAWIKI' ) ) |
| 4 | +if ( !defined( 'MEDIAWIKI' ) ) |
5 | 5 | die(); |
6 | 6 | |
7 | 7 | class TodoTemplate extends QuickTemplate { |
8 | 8 | function execute() { |
9 | 9 | 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( " |
15 | 15 | <style type=\"text/css\"> |
16 | 16 | .mwTodoNewForm { |
17 | 17 | border: solid 1px #ccc; |
— | — | @@ -22,15 +22,15 @@ |
23 | 23 | .mwTodoTitle { |
24 | 24 | font-weight: bold; |
25 | 25 | } |
26 | | -</style>"); |
| 26 | +</style>" ); |
27 | 27 | ?> |
28 | | -<script type="text/javascript" src="<?php $this->text('script') ?>"></script> |
| 28 | +<script type="text/javascript" src="<?php $this->text( 'script' ) ?>"></script> |
29 | 29 | |
30 | | -<form action="<?php $this->text('action') ?>" method="post"> |
| 30 | +<form action="<?php $this->text( 'action' ) ?>" method="post"> |
31 | 31 | <input type="hidden" name="wpNewItem" value="1" /> |
32 | 32 | <p> |
33 | 33 | <?php |
34 | | -$wgOut->addHTML(" |
| 34 | +$wgOut->addHTML( " |
35 | 35 | <div class=\"mwTodoNewForm\"> |
36 | 36 | <label for=\"wpSummary\">{$todosummary}</label> |
37 | 37 | <br /> |
Index: trunk/extensions/Todo/SpecialTodo.i18n.php |
— | — | @@ -36,8 +36,10 @@ |
37 | 37 | 'todo-new-item' => 'New item', |
38 | 38 | 'todo-issue-summary' => 'Issue summary:', |
39 | 39 | '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:', |
41 | 41 | 'todo-form-submit' => 'Submit query', |
| 42 | + 'right-todo' => 'Have todo list', |
| 43 | + 'right-todosubmit' => 'Restrict user\'s todo list right', |
42 | 44 | ); |
43 | 45 | |
44 | 46 | /** Message documentation (Message documentation) |
Index: trunk/extensions/Todo/SpecialTodo.php |
— | — | @@ -1,5 +1,4 @@ |
2 | 2 | <?php |
3 | | - |
4 | 3 | /* |
5 | 4 | CREATE TABLE todolist ( |
6 | 5 | todo_id INT AUTO_INCREMENT, |
— | — | @@ -20,17 +19,17 @@ |
21 | 20 | $wgExtensionCredits['other'][] = array( |
22 | 21 | 'path' => __FILE__, |
23 | 22 | 'name' => 'Todo', |
24 | | - 'version' => '0.2', |
| 23 | + 'version' => '0.3', |
25 | 24 | 'url' => 'http://www.mediawiki.org/wiki/Extension:Todo', |
26 | 25 | 'description' => 'Experimental personal todo list extension', |
27 | | - 'author' => 'Brion Vibber, Bertrand Grondin', |
| 26 | + 'author' => array( 'Brion Vibber', 'Bertrand Grondin' ), |
28 | 27 | 'descriptionmsg' => 'todo-desc', |
29 | 28 | ); |
30 | 29 | |
31 | 30 | $wgExtensionFunctions[] = 'todoSetup'; |
32 | 31 | $wgHooks['SkinTemplateTabs'][] = 'todoAddTab'; |
33 | 32 | |
34 | | -$dir = dirname(__FILE__) . '/'; |
| 33 | +$dir = dirname( __FILE__ ) . '/'; |
35 | 34 | $wgExtensionMessagesFiles['todoAddTab'] = $dir . 'SpecialTodo.i18n.php'; |
36 | 35 | |
37 | 36 | // Creates a group of users who can have todo lists |
— | — | @@ -43,11 +42,13 @@ |
44 | 43 | $wgAvailableRights[] = 'todo'; |
45 | 44 | $wgAvailableRights[] = 'todosubmit'; |
46 | 45 | |
| 46 | +// FIXME: use $wgSpecialPages and delay message loading |
47 | 47 | function todoSetup() { |
48 | 48 | wfLoadExtensionMessages( 'todoAddTab' ); |
49 | 49 | SpecialPage::addPage( new SpecialPage( 'Todo' ) ); |
50 | 50 | } |
51 | 51 | |
| 52 | +// FIXME: use class file(s) to delay loading |
52 | 53 | /** |
53 | 54 | * Add a 'todo' tab on user pages |
54 | 55 | * @param SkinTemplate $skin |
— | — | @@ -56,10 +57,10 @@ |
57 | 58 | */ |
58 | 59 | function todoAddTab( &$skin, &$actions ) { |
59 | 60 | global $wgTitle; |
60 | | - if( $wgTitle->getNamespace() == NS_USER || $wgTitle->getNamespace() == NS_USER_TALK ) { |
| 61 | + if ( $wgTitle->getNamespace() == NS_USER || $wgTitle->getNamespace() == NS_USER_TALK ) { |
61 | 62 | $title = Title::makeTitle( NS_SPECIAL, 'Todo/' . $wgTitle->getText() ); |
62 | 63 | $actions['todo'] = array( |
63 | | - 'text' => wfMsg('todo-tab'), |
| 64 | + 'text' => wfMsg( 'todo-tab' ), |
64 | 65 | 'href' => $title->getLocalUrl() ); |
65 | 66 | } |
66 | 67 | return true; |
— | — | @@ -69,20 +70,20 @@ |
70 | 71 | * Entry-point function for Special:Todo |
71 | 72 | * @param mixed $par Will contain username to view on |
72 | 73 | */ |
73 | | -function wfSpecialTodo( $par=null ) { |
74 | | - if( is_null( $par ) || $par == '' ) { |
| 74 | +function wfSpecialTodo( $par = null ) { |
| 75 | + if ( is_null( $par ) || $par == '' ) { |
75 | 76 | global $wgUser; |
76 | 77 | $user = $wgUser; |
77 | 78 | } else { |
78 | 79 | $user = User::newFromName( $par ); |
79 | 80 | } |
80 | | - if( is_null( $user ) || !$user->isAllowed( 'todo' ) ) { |
| 81 | + if ( is_null( $user ) || !$user->isAllowed( 'todo' ) ) { |
81 | 82 | global $wgOut; |
82 | | - $wgOut->fatalError( wfMsgHtml('todo-user-invalide') ); |
| 83 | + $wgOut->fatalError( wfMsgHtml( 'todo-user-invalide' ) ); |
83 | 84 | } else { |
84 | 85 | global $wgRequest; |
85 | 86 | $todo = new TodoForm( $user ); |
86 | | - if( $wgRequest->wasPosted() ) { |
| 87 | + if ( $wgRequest->wasPosted() ) { |
87 | 88 | $todo->submit( $wgRequest ); |
88 | 89 | } else { |
89 | 90 | $todo->show(); |
— | — | @@ -97,9 +98,9 @@ |
98 | 99 | } |
99 | 100 | |
100 | 101 | function submit( $request ) { |
101 | | - if( $request->getVal( 'wpNewItem' ) ) { |
| 102 | + if ( $request->getVal( 'wpNewItem' ) ) { |
102 | 103 | $this->submitNew( $request ); |
103 | | - } elseif( $request->getVal( 'wpUpdateField' ) ) { |
| 104 | + } elseif ( $request->getVal( 'wpUpdateField' ) ) { |
104 | 105 | $this->submitUpdate( $request ); |
105 | 106 | } |
106 | 107 | $this->showError( $result ); |
— | — | @@ -118,13 +119,13 @@ |
119 | 120 | function submitUpdate( $request ) { |
120 | 121 | $id = $request->getInt( 'wpItem' ); |
121 | 122 | $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' ) ); |
124 | 125 | } |
125 | 126 | |
126 | 127 | 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' ) ); |
129 | 130 | } |
130 | 131 | |
131 | 132 | switch( $request->getVal( 'wpUpdateField' ) ) { |
— | — | @@ -144,19 +145,19 @@ |
145 | 146 | |
146 | 147 | function show() { |
147 | 148 | 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() ) ); |
149 | 150 | |
150 | 151 | |
151 | | - $wgOut->addWikiText( "== ".wfMsg('todo-new-item')." ==\n" ); |
| 152 | + $wgOut->addWikiText( "== " . wfMsg( 'todo-new-item' ) . " ==\n" ); |
152 | 153 | |
153 | | - require_once ('TodoForm.php'); |
| 154 | + require_once ( 'TodoForm.php' ); |
154 | 155 | $form = new TodoTemplate(); |
155 | 156 | $form->set( 'action', $this->self->getLocalUrl( 'action=submit' ) ); |
156 | 157 | $form->set( 'script', "$wgScriptPath/extensions/Todo/todo.js" ); |
157 | 158 | $wgOut->addTemplate( $form ); |
158 | 159 | |
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" ); |
161 | 162 | $list = new TodoList( $this->target ); |
162 | 163 | $list->show(); |
163 | 164 | } |
— | — | @@ -164,7 +165,7 @@ |
165 | 166 | |
166 | 167 | function showError( $result ) { |
167 | 168 | global $wgOut; |
168 | | - if( WikiError::isError( $result ) ) { |
| 169 | + if ( WikiError::isError( $result ) ) { |
169 | 170 | $wgOut->addHTML( '<p class="error">' . |
170 | 171 | htmlspecialcahrs( $result->getMessage() ) . |
171 | 172 | "</p>\n" ); |
— | — | @@ -190,7 +191,7 @@ |
191 | 192 | array( 'ORDER BY' => 'todo_owner,todo_status,todo_queue,todo_timestamp DESC' ) ); |
192 | 193 | |
193 | 194 | $this->items = array(); |
194 | | - while( $row = $dbr->fetchObject( $result ) ) { |
| 195 | + while ( $row = $dbr->fetchObject( $result ) ) { |
195 | 196 | $item = new TodoItem( $row ); |
196 | 197 | $this->items[$item->queue][] = $item; |
197 | 198 | } |
— | — | @@ -203,18 +204,18 @@ |
204 | 205 | $queues = array_keys( $this->items ); |
205 | 206 | usort( $queues, array( 'TodoList', 'queueSort' ) ); |
206 | 207 | |
207 | | - if( count( $queues ) == 0 ) { |
208 | | - $wgOut->addWikiText( wfMsg('todo-no-item')); |
| 208 | + if ( count( $queues ) == 0 ) { |
| 209 | + $wgOut->addWikiText( wfMsg( 'todo-no-item' ) ); |
209 | 210 | return; |
210 | 211 | } |
211 | 212 | |
212 | 213 | $wgOut->addHTML( "<table>\n<tr>" ); |
213 | | - foreach( $queues as $queue ) { |
| 214 | + foreach ( $queues as $queue ) { |
214 | 215 | $wgOut->addHTML( Xml::element( 'th', null, $queue ) ); |
215 | 216 | } |
216 | 217 | $wgOut->addHTML( "</tr>\n<tr>\n" ); |
217 | 218 | |
218 | | - foreach( $queues as $queue ) { |
| 219 | + foreach ( $queues as $queue ) { |
219 | 220 | $wgOut->addHTML( "<td valign='top'>\n<table border='1'>\n" ); |
220 | 221 | $this->showQueue( $queue, $queues ); |
221 | 222 | $wgOut->addHTML( "</table>\n</td>\n" ); |
— | — | @@ -231,13 +232,13 @@ |
232 | 233 | */ |
233 | 234 | function queueSort( $a, $b ) { |
234 | 235 | $new = wfMsgForContent( 'todo-new-queue' ); |
235 | | - if( $a == $b ) { |
| 236 | + if ( $a == $b ) { |
236 | 237 | return 0; |
237 | 238 | } |
238 | | - if( $a == $new ) { |
239 | | - return -1; |
| 239 | + if ( $a == $new ) { |
| 240 | + return - 1; |
240 | 241 | } |
241 | | - if( $b == $new ) { |
| 242 | + if ( $b == $new ) { |
242 | 243 | return 1; |
243 | 244 | } |
244 | 245 | return strcmp( $a, $b ); |
— | — | @@ -245,7 +246,7 @@ |
246 | 247 | |
247 | 248 | function showQueue( $queue, $queues ) { |
248 | 249 | global $wgOut; |
249 | | - foreach( $this->items[$queue] as $item ) { |
| 250 | + foreach ( $this->items[$queue] as $item ) { |
250 | 251 | $wgOut->addHTML( "<tr><td><div>" ); |
251 | 252 | $item->show( $queues ); |
252 | 253 | $wgOut->addHTML( "</div></td></tr>\n" ); |
— | — | @@ -275,7 +276,7 @@ |
276 | 277 | '*', |
277 | 278 | array( 'todo_id' => intval( $id ) ), |
278 | 279 | 'TodoForm::loadFromId' ); |
279 | | - if( $row ) { |
| 280 | + if ( $row ) { |
280 | 281 | return new TodoItem( $row ); |
281 | 282 | } else { |
282 | 283 | return null; |
— | — | @@ -359,11 +360,11 @@ |
360 | 361 | "<br />\n" . |
361 | 362 | Xml::element( 'input', array( |
362 | 363 | 'type' => 'submit', |
363 | | - 'value' => wfMsg('todo-list-change') ) ) . |
| 364 | + 'value' => wfMsg( 'todo-list-change' ) ) ) . |
364 | 365 | " " . |
365 | 366 | Xml::element( 'input', array( |
366 | 367 | 'type' => 'button', |
367 | | - 'value' => wfMsg('todo-list-cancel'), |
| 368 | + 'value' => wfMsg( 'todo-list-cancel' ), |
368 | 369 | 'onclick' => "todoEdit{$capField}($id,false)" ) ) . |
369 | 370 | "</form></div>\n"; |
370 | 371 | } |
— | — | @@ -388,18 +389,18 @@ |
389 | 390 | |
390 | 391 | function buildMoveSelector( $queues ) { |
391 | 392 | $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 ) { |
394 | 395 | $out .= Xml::element( 'option', |
395 | 396 | array( 'value' => '', 'selected' => 'selected' ), |
396 | | - wfMsgHtml('todo-move-queue') ); |
| 397 | + wfMsgHtml( 'todo-move-queue' ) ); |
397 | 398 | } else { |
398 | 399 | $out .= Xml::element( 'option', |
399 | 400 | array( 'value' => $queue ), |
400 | 401 | $queue ); |
401 | 402 | } |
402 | 403 | } |
403 | | - $out .= "<option value='+' />".wfMsgHtml('todo-add-queue')."</option>\n"; |
| 404 | + $out .= "<option value='+' />" . wfMsgHtml( 'todo-add-queue' ) . "</option>\n"; |
404 | 405 | $out .= "</select>"; |
405 | 406 | return $out; |
406 | 407 | } |
— | — | @@ -435,7 +436,7 @@ |
436 | 437 | function close( $comment, $sendMail ) { |
437 | 438 | $this->status = 'closed'; |
438 | 439 | $this->updateRecord( array( 'todo_status' => 'closed' ) ); |
439 | | - if( $sendMail && $this->email ) { |
| 440 | + if ( $sendMail && $this->email ) { |
440 | 441 | $this->sendConfirmationMail( $comment ); |
441 | 442 | } |
442 | 443 | } |
— | — | @@ -449,8 +450,8 @@ |
450 | 451 | global $wgContLang; |
451 | 452 | |
452 | 453 | $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' ) ); |
455 | 456 | } |
456 | 457 | |
457 | 458 | $sender = new MailAddress( $owner ); |