r79716 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79715‎ | r79716 | r79717 >
Date:13:05, 6 January 2011
Author:ialex
Status:deferred
Tags:
Comment:
Some more updates:
* removed calls to wfLoadExtensionMessages()
* changed usage of SkinTemplateTabs hook to SkinTemplateNavigation
* fixed one E_STRICT
Modified paths:
  • /trunk/extensions/Tasks/Tasks.body.php (modified) (history)
  • /trunk/extensions/Tasks/Tasks.hooks.php (modified) (history)
  • /trunk/extensions/Tasks/Tasks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Tasks/Tasks.body.php
@@ -49,7 +49,7 @@
5050 return $key;
5151 }
5252 }
53 -
 53+
5454 /**
5555 * Returns the text key for a given task type constant
5656 * @param $num numeric key
@@ -62,14 +62,12 @@
6363 }
6464 return $this->task_types[$num];
6565 }
66 -
 66+
6767 /**
6868 * Updates task_types and creation_tasks from wfMsg
6969 * @fixme Provide localized display names for user's UI language
7070 */
7171 function update_types() { # Checked for HTML and MySQL insertion attacks
72 - wfLoadExtensionMessages('Tasks');
73 -
7472 # task type numeric key, text key, localized text
7573 $this->task_types = array();
7674 $s = wfMsgForContent( 'tasks_task_types' );
@@ -179,7 +177,7 @@
180178 $tg[$t->task_type] = $t->task_status;
181179 }
182180 }
183 -
 181+
184182 foreach( array_keys( $this->task_types ) as $a ) {
185183 if( $exists == $this->is_creation_task( $a ) ) {
186184 # Creation task and existence exclude each other
@@ -222,7 +220,7 @@
223221 }
224222 return $out;
225223 }
226 -
 224+
227225 /**
228226 * Adds a new task
229227 */
@@ -249,7 +247,7 @@
250248 'task_timestamp' => $dbw->timestamp()
251249 ) );
252250 }
253 -
 251+
254252 /**
255253 * For a list of tasks, get a single table row
256254 * This function is heavy on output!
@@ -257,7 +255,7 @@
258256 function get_task_table_row( &$task, &$title, $show_page = false, $returnto = '' ) { # Checked for HTML and MySQL insertion attacks
259257 global $wgContLang, $wgUser, $wgTasksNamespace, $wgExtraNamespaces;
260258 $out = '';
261 - $sk =& $wgUser->getSkin();
 259+ $sk = $wgUser->getSkin();
262260 $ct = $wgContLang->timeanddate( $task->task_timestamp ); # Time object from string of digits
263261 $cu = Title::makeTitleSafe( NS_USER, $task->task_user_text ); # Safe user name
264262 $comment = htmlspecialchars( $task->task_comment ); # Safe user comment, no HTML allowed
@@ -355,7 +353,7 @@
356354 if( $wgUser->isAllowed( 'delete' ) ) {
357355 $txt[] = $sk->makeLinkObj( $title, wfMsgHTML( 'tasks_delete' ), "action=tasks&mode=delete&taskid={$tid}{$returnto}" );
358356 }
359 -
 357+
360358 if( count( $txt ) > 0 ) {
361359 $out .= '<br />' . implode( ' - ', $txt );
362360 }
@@ -364,7 +362,7 @@
365363 $tdp = $this->get_task_discussion_page( $task );
366364 $out .= '<br />' . $sk->makeLinkObj( $tdp, wfMsgHTML('tasks_discussion_page_link') );
367365 $out .= '</td></tr>' ;
368 -
 366+
369367 # Transclude comments page, if wanted
370368 if( $wgUser->getOption( 'show_task_comments' ) ) {
371369 if( $this->pagemode == 'search' || $this->pagemode == 'tasks_of_page' ) {
@@ -375,7 +373,7 @@
376374 }
377375
378376 /**
379 - * Returns the
 377+ * Returns the
380378 * @param Title $title of task page to load
381379 * @param int $col_compensator Number of table columns to span
382380 * @return string HTML table row, or empty string
@@ -417,12 +415,12 @@
418416 }
419417
420418 $out = "<h2>" . wfMsgHTML( 'tasks_existing_header' ) . "</h2>\n" .
421 - "<table border='1' cellspacing='1' cellpadding='2'>" .
 419+ "<table border='1' cellspacing='1' cellpadding='2'>" .
422420 "<tr>" . self::getTableHeader() . "</tr>" .
423421 $out . "</table>";
424422 return $out;
425423 }
426 -
 424+
427425 /**
428426 * Checks if there's a "mode" set in the URL of the current page
429427 * (performs changes on tasks, like assigning or closing them)
@@ -532,7 +530,7 @@
533531
534532 return $out;
535533 }
536 -
 534+
537535 /**
538536 * Returns the number for the status
539537 * @param string $status key
@@ -547,7 +545,7 @@
548546 # Invalid status
549547 return 0;
550548 }
551 -
 549+
552550 /**
553551 * Changes the status of a task, performs some associated cleanup, and logs the action
554552 */
@@ -589,8 +587,8 @@
590588 $log = new LogPage( 'tasks' );
591589 $log->addEntry( 'tasks', $title, $act );
592590 }
593 -
594 -
 591+
 592+
595593 /**
596594 * Returns the list of active tasks for this page, for display in the sidebar
597595 */
@@ -692,9 +690,9 @@
693691 $dbw->update( 'tasks',
694692 array( 'task_page_title' => $new_title->getPrefixedDBkey() ), # SET
695693 array( 'task_page_title' => $old_title->getPrefixedDBkey() ), # WHERE
696 - __METHOD__ );
 694+ __METHOD__ );
697695 }
698 -
 696+
699697 /**
700698 * THIS IS THE MAIN FUNCTION FOR THE TAB-BASED INTERFACE
701699 */
@@ -747,7 +745,7 @@
748746 }
749747 return false;
750748 }
751 -
 749+
752750 /**
753751 * Confirm that the given redirect page is local to this site
754752 * FIXME: this can still pass you anywhere on the domain,
@@ -806,7 +804,7 @@
807805 . '</form>';
808806 return $out;
809807 }
810 -
 808+
811809 /**
812810 * Returns the exisiting tasks for a single page
813811 */
@@ -857,7 +855,7 @@
858856 krsort( $ret );
859857 return $ret;
860858 }
861 -
 859+
862860 /**
863861 * Special page main function
864862 */
@@ -868,7 +866,7 @@
869867 $mode = trim( $wgRequest->getVal( 'mode' ) );
870868 $skin = $wgUser->getSkin();
871869 $dbr = wfGetDB( DB_SLAVE );
872 -
 870+
873871 # Assignments
874872 if( $wgUser->isLoggedIn() ) {
875873 if( $mode == 'myassignments' ) {
@@ -928,7 +926,7 @@
929927 $status_type = $_POST['status_type'];
930928 }
931929 $ascending = $wgRequest->getCheck( 'ascending' );
932 -
 930+
933931 $get_task_type = $wgRequest->getInt( 'task_type' , 0 ) ;
934932 if ( count ( $task_type ) == 0 && $get_task_type > 0 ) {
935933 $task_type = array() ;
@@ -957,7 +955,7 @@
958956 # No choice => search all
959957 $search_status = array_keys( $this->status_types );
960958 }
961 -
 959+
962960 $limit = intval( wfMsg( 'tasks_search_limit' ) );
963961 $offset = $wgRequest->getInt( 'offset', 0 );
964962 if( $wgRequest->getCheck( 'next' ) ) {
@@ -1058,7 +1056,7 @@
10591057 $this->setHeaders();
10601058 $wgOut->addHTML( $out );
10611059 }
1062 -
 1060+
10631061 /**
10641062 * Format an HTML checkbox
10651063 * @param string $name
Index: trunk/extensions/Tasks/Tasks.php
@@ -70,7 +70,7 @@
7171 $wgHooks['ArticleDeleteComplete'][] = 'TasksHooks::onArticleDeleteComplete';
7272 $wgHooks['ArticleInsertComplete'][] = 'TasksHooks::onArticleInsertComplete';
7373 $wgHooks['SkinTemplatePreventOtherActiveTabs'][] = 'TasksHooks::onSkinTemplatePreventOtherActiveTabs';
74 -$wgHooks['SkinTemplateTabs'][] = 'TasksHooks::onSkinTemplateTabs';
 74+$wgHooks['SkinTemplateNavigation'][] = 'TasksHooks::onSkinTemplateNavigation';
7575 $wgHooks['UnknownAction'][] = 'TasksHooks::onUnknownAction';
7676 $wgHooks['ParserTestTables'][] = 'TasksHooks::onParserTestTables';
7777 $wgHooks['LoadExtensionSchemaUpdates'][] = 'TasksHooks::onLoadExtensionSchemaUpdates';
Index: trunk/extensions/Tasks/Tasks.hooks.php
@@ -24,9 +24,9 @@
2525 self::headerSign( $title );
2626 return true;
2727 }
28 -
 28+
2929 $subtitle = '';
30 -
 30+
3131 if( ctype_digit( $title->getText() ) ) {
3232 // Page title format 'Task:123', suggested by Rowan Collins
3333 $taskid = intval( $title->getText() );
@@ -35,7 +35,6 @@
3636 return true;
3737 }
3838
39 - wfLoadExtensionMessages('Tasks');
4039 $st = new SpecialTasks();
4140 $task = '';
4241 $page_title = $st->get_title_from_task( $taskid, $task );
@@ -49,11 +48,11 @@
5049 $link1 = $sk->makeLinkObj( $page_title );
5150 $link2 = $sk->makeLinkObj( $page_title, wfMsgHTML( 'tasks_here' ), 'action=tasks' );
5251 $subtitle .= '<div id="task_header">' . wfMsgForContent( 'tasks_discussion_page_for', $link1, $link2 ) . "</div>\n" ;
53 - $subtitle .= '<table border="1" cellspacing="1" cellpadding="2" id="task_header_table">' .
 52+ $subtitle .= '<table border="1" cellspacing="1" cellpadding="2" id="task_header_table">' .
5453 '<tr>' . SpecialTasks::getTableHeader( false ) . "</tr>\n";
5554 $subtitle .= $st->get_task_table_row( $task, $page_title, false, $returnto );
5655 $subtitle .= "</table>\n";
57 -
 56+
5857 $subtitle = $wgOut->getSubtitle() . '<br />' . $subtitle;
5958 $wgOut->setSubtitle( $subtitle );
6059 return true;
@@ -74,14 +73,13 @@
7574 return true;
7675 }
7776
78 - wfLoadExtensionMessages('Tasks');
7977 $st = new SpecialTasks();
8078 $tasks = $st->get_open_task_list( $title, true );
8179 if( count( $tasks ) == 0 ) {
82 - # No tasks
 80+ # No tasks
8381 return true;
8482 }
85 -
 83+
8684 $out = '';
8785 $max = 0;
8886 foreach( $tasks as $task ) {
@@ -105,10 +103,10 @@
106104 # Nothing for you to see here, please move along
107105 return;
108106 }
109 -
 107+
110108 // Wiki-safe output
111109 $out = $wgOut->parse( '<div id="task_sign">' . $max_msg . '</div>' );
112 -
 110+
113111 $subtitle = $wgOut->getSubtitle() . '<br />' . $out;
114112 $wgOut->setSubtitle( $subtitle );
115113 }
@@ -126,12 +124,11 @@
127125 # No special pages please
128126 return true;
129127 }
130 -
131 - wfLoadExtensionMessages('Tasks');
 128+
132129 $st = new SpecialTasks;
133130 $tasks = $st->get_open_task_list( $wgTitle, true );
134131 if( count( $tasks ) == 0 ) {
135 - # No tasks
 132+ # No tasks
136133 return true;
137134 }
138135
@@ -160,7 +157,7 @@
161158 }
162159 ?></li>
163160 <?php
164 -
 161+
165162 }
166163 return true;
167164 }
@@ -174,8 +171,6 @@
175172 return false;
176173 }
177174
178 - wfLoadExtensionMessages('Tasks');
179 -
180175 $st = new SpecialTasks;
181176 $st->rename_tasks_page( $old_title, $new_title );
182177 return false;
@@ -187,7 +182,6 @@
188183 */
189184 public static function onArticleDeleteComplete( &$article, &$user, $reason ) { # Checked for HTML and MySQL insertion attacks
190185 # return false ; # Uncomment this line to prevent deletion of tasks upon deletion of article
191 - wfLoadExtensionMessages('Tasks');
192186 $t = $article->getTitle();
193187 if( $t->isTalkPage() ) {
194188 # No tasks for talk pages, no need to bother the database...
@@ -214,16 +208,15 @@
215209 */
216210 public static function onArticleInsertComplete( &$article, &$user, $text, $summary, $isminor, $watchthis, $something ) { # Checked for HTML and MySQL insertion attacks
217211 global $wgUser;
218 - wfLoadExtensionMessages('Tasks');
219212 $t = $article->getTitle();
220213 if( $t->isTalkPage() ) {
221214 # No tasks for talk pages, no need to bother the database...
222215 return false;
223216 }
224 -
 217+
225218 $st = new SpecialTasks;
226219 $tasks = $st->get_tasks_for_page( $t, true );
227 -
 220+
228221 # Mark creation tasks as closed
229222 foreach( $tasks as $task ) {
230223 if( !$st->is_creation_task( $task->task_type ) ) {
@@ -236,13 +229,13 @@
237230 }
238231 $st->change_task_status( $task->task_id, MW_TASK_CLOSED );
239232 $st->set_new_article_id( $t );
240 -
 233+
241234 $id = $t->getArticleId();
242235 # Nothing more to do
243236 break;
244237 }
245 -
246 - # OPTIONALLY create a new task
 238+
 239+ # OPTIONALLY create a new task
247240 $on_create = $st->get_task_num( wfMsgForContent( 'tasks_event_on_creation' ) );
248241 $on_create_anon = $st->get_task_num( wfMsgForContent( 'tasks_event_on_creation_anon' ) );
249242 $add_task = MW_TASK_INVALID;
@@ -255,7 +248,7 @@
256249 $comment = htmlspecialchars( wfMsgForContent( 'tasks_on_creation_comment' ) );
257250 $st->add_new_task( $t, $comment, $add_task ) ;
258251 }
259 -
 252+
260253 return false;
261254 }
262255
@@ -275,7 +268,7 @@
276269 * @param array $content_actions
277270 * @return bool true to continue running other hooks, false to abort operation
278271 */
279 - public static function onSkinTemplateTabs( $skin, &$content_actions ) { # Checked for HTML and MySQL insertion attacks
 272+ public static function onSkinTemplateNavigation( $skin, &$content_actions ) { # Checked for HTML and MySQL insertion attacks
280273 global $wgTitle, $wgRequest;
281274
282275 if( $wgTitle->isTalkPage() ) {
@@ -287,8 +280,7 @@
288281 return true;
289282 }
290283
291 - wfLoadExtensionMessages('Tasks');
292 - $content_actions['tasks'] = array(
 284+ $content_actions['actions']['tasks'] = array(
293285 'class' => ($wgRequest->getVal( 'action', 'view' ) == 'tasks') ? 'selected' : false,
294286 'text' => wfMsgHTML('tasks_tab'),
295287 'href' => $wgTitle->getLocalUrl( 'action=tasks' )
@@ -304,9 +296,7 @@
305297 # Not my kind of action!
306298 return true;
307299 }
308 -
309 - wfLoadExtensionMessages('Tasks');
310 -
 300+
311301 $t = new SpecialTasks;
312302 return $t->page_management( $article->getTitle() );
313303 }

Status & tagging log