r49621 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49620‎ | r49621 | r49622 >
Date:08:29, 18 April 2009
Author:siebrand
Status:deferred
Tags:
Comment:
* add FIXMEs
* update extension description
* fix indentation, remove trailing whitespace, stylize.php
Modified paths:
  • /trunk/extensions/SemanticTasks/ST_CheckForReminders.php (modified) (history)
  • /trunk/extensions/SemanticTasks/ST_Notify_Assignment.php (modified) (history)
  • /trunk/extensions/SemanticTasks/SemanticTasks.i18n.php (modified) (history)
  • /trunk/extensions/SemanticTasks/SemanticTasks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticTasks/SemanticTasks.php
@@ -1,36 +1,38 @@
22 <?php
33
4 -###
 4+#
55 # This is the path to your installation of SemanticTasks as
66 # seen from the web. Change it if required ($wgScriptPath is the
77 # path to the base directory of your wiki). No final slash.
8 -##
 8+# #
99 $stScriptPath = $wgScriptPath . '/extensions/SemanticTasks';
10 -##
 10+#
1111
12 -###
 12+#
1313 # This is the path to your installation of SemanticTasks as
1414 # seen on your local filesystem. Used against some PHP file path
1515 # issues.
16 -##
 16+#
1717 $stIP = $IP . '/extensions/SemanticTasks';
18 -##
 18+#
1919
20 -#Informations
 20+# Informations
2121 $wgExtensionCredits['parserhook'][] = array(
2222 'name' => 'SemanticTasks',
23 - 'author' => 'Steren Giannini',
 23+ 'author' => 'Steren Giannini',
2424 'version' => '1.1.1',
25 - 'url' => 'http://www.creativecommons.org', //FIXME: URL should point to a page about this extension
26 - 'description' => 'Email notifications for assigned or updated tasks.',
 25+ 'url' => 'http://www.creativecommons.org', // FIXME: URL should point to a page about this extension
 26+ 'description' => 'E-mail notifications for assigned or updated tasks',
2727 'descriptionmsg' => 'semantictasks-desc',
2828 );
2929
30 -//Do st_SetupExtension after the mediawiki setup, AND after SemanticMediaWiki setup
 30+// Do st_SetupExtension after the mediawiki setup, AND after SemanticMediaWiki setup
 31+// FIXME: only hook added is ArticleSaveComplete. There appears to be no need for this.
3132 $wgExtensionFunctions[] = 'st_SetupExtension';
3233
33 -//i18n
 34+// i18n
3435 $wgExtensionMessagesFiles['SemanticTasks'] = dirname( __FILE__ ) . '/SemanticTasks.i18n.php';
3536
 37+// FIXME: Use $wgAutoloadClasses
3638 // ST_Notify_Assignment.php
3739 require_once( $stIP . "/ST_Notify_Assignment.php" );
Index: trunk/extensions/SemanticTasks/ST_CheckForReminders.php
@@ -2,7 +2,7 @@
33 # (C) 2008 Steren Giannini
44 # Licensed under the GNU GPLv2 (or later).
55
6 -$IP = realpath( dirname( __FILE__ ) . "/../..");
 6+$IP = realpath( dirname( __FILE__ ) . "/../.." );
77 require_once( "$IP/maintenance/commandLine.inc" );
88
99 global $smwgIP;
@@ -11,7 +11,7 @@
1212 global $stIP;
1313 require_once( $stIP . '/ST_Notify_Assignment.php' );
1414
15 -//Let's send reminders
 15+// Let's send reminders
1616 fnRemindAssignees( 'http://teamspace.creativecommons.org/' );
1717
1818 print( "ST check for reminders\n" );
Index: trunk/extensions/SemanticTasks/ST_Notify_Assignment.php
@@ -3,19 +3,19 @@
44 # Licensed under the GNU GPLv2 (or later).
55 function fnMailAssignees_updated_task( $article, $current_user, $text, $summary, $minoredit, $watchthis, $sectionanchor, $flags, $revision ) {
66 if ( !$minoredit ) {
7 - //i18n
 7+ // i18n
88 wfLoadExtensionMessages( 'SemanticTasks' );
99
10 - //Grab the wiki name
 10+ // Grab the wiki name
1111 global $wgSitename;
1212
13 - //Get the revision count to determine if new article
 13+ // Get the revision count to determine if new article
1414 $rev = $article->estimateRevisionCount();
1515
16 - if( $rev == 1 ) {
17 - fnMailAssignees( $article, $current_user, '['.$wgSitename.'] '. wfMsg( 'semantictasks-newtask' ), 'semantictasks-assignedtoyou-msg', /*diff?*/ false, /*Page text*/ true );
 16+ if ( $rev == 1 ) {
 17+ fnMailAssignees( $article, $current_user, '[' . $wgSitename . '] ' . wfMsg( 'semantictasks-newtask' ), 'semantictasks-assignedtoyou-msg', /*diff?*/ false, /*Page text*/ true );
1818 } else {
19 - fnMailAssignees( $article, $current_user, '['.$wgSitename.'] '. wfMsg( 'semantictasks-taskupdated' ), 'semantictasks-updatedtoyou-msg', /*diff?*/ true, /*Page text*/ false );
 19+ fnMailAssignees( $article, $current_user, '[' . $wgSitename . '] ' . wfMsg( 'semantictasks-taskupdated' ), 'semantictasks-updatedtoyou-msg', /*diff?*/ true, /*Page text*/ false );
2020 }
2121 }
2222 return TRUE;
@@ -24,7 +24,7 @@
2525 function fnMailAssignees( $article, $user, $pre_title, $message, $display_diff, $display_text ) {
2626 $title = $article->getTitle();
2727
28 - //Send notifications to assignees and ccs
 28+ // Send notifications to assignees and ccs
2929 fnMailNotification( 'Assigned to', $article, $user, $pre_title, $message, $display_diff, $display_text );
3030 fnMailNotification( 'Carbon copy', $article, $user, $pre_title, $message, $display_diff, $display_text );
3131 return TRUE;
@@ -37,18 +37,18 @@
3838 function fnMailNotification( $query_word, $article, $user, $pre_title, $message, $display_diff, $display_text ) {
3939 $title = $article->getTitle();
4040
41 - //get the result of the query "[[$title]][[$query_word::+]]"
 41+ // get the result of the query "[[$title]][[$query_word::+]]"
4242 $properties_to_display = array();
4343 $properties_to_display[0] = $query_word;
4444 $results = st_get_query_results( "[[$title]][[$query_word::+]]", $properties_to_display, false );
4545
46 - //In theory, there is only one row
 46+ // In theory, there is only one row
4747 while ( $row = $results->getNext() ) {
4848 $task_assignees = $row[0];
4949 }
5050
51 - //If not any row, do nothing
52 - if( empty( $task_assignees ) ) {
 51+ // If not any row, do nothing
 52+ if ( empty( $task_assignees ) ) {
5353 return FALSE;
5454 }
5555
@@ -63,18 +63,18 @@
6464 $assignee_user_name = explode( ":", $assignee_username );
6565 $assignee_name = $assignee_user_name[1];
6666 $body = wfMsg( $message , $assignee_name , $title ) . $link;
67 - if( $display_text ){
 67+ if ( $display_text ) {
6868 $body .= "\n \n" . wfMsg( 'semantictasks-text-message' ) . "\n" . $article->getContent() ;
6969 }
70 - if( $display_diff){
 70+ if ( $display_diff ) {
7171 $body .= "\n \n" . wfMsg( 'semantictasks-diff-message' ) . "\n" . st_generateDiffBody_txt( $title );
7272 }
7373
74 - //TEST: uncomment this for test mode (Writes body in testFile)
75 - //st_WriteTestFile( $body );
 74+ // TEST: uncomment this for test mode (Writes body in testFile)
 75+ // st_WriteTestFile( $body );
7676
7777 $assignee = User::newFromName( $assignee_name );
78 - //if assignee is the current user, do nothing
 78+ // if assignee is the current user, do nothing
7979 if ( $assignee->getID() != $user->getID() ) {
8080 $assignee_mail = new MailAddress( $assignee->getEmail(), $assignee_name );
8181 $user_mailer->send( $assignee_mail, $from, $subject, $body );
@@ -92,16 +92,16 @@
9393 function st_generateDiffBody_txt( $title ) {
9494 $revision = Revision::newFromTitle( $title, 0 );
9595 $diff = new DifferenceEngine( $title, $revision->getId(), 'prev' );
96 - //The getDiffBody() method generates html, so let's generate the txt diff manualy:
 96+ // The getDiffBody() method generates html, so let's generate the txt diff manualy:
9797 global $wgContLang;
9898 $diff->loadText();
9999 $otext = str_replace( "\r\n", "\n", $diff->mOldtext );
100100 $ntext = str_replace( "\r\n", "\n", $diff->mNewtext );
101101 $ota = explode( "\n", $wgContLang->segmentForDiff( $otext ) );
102102 $nta = explode( "\n", $wgContLang->segmentForDiff( $ntext ) );
103 - //We use here the php diff engine included in MediaWiki
 103+ // We use here the php diff engine included in MediaWiki
104104 $diffs = new Diff( $ota, $nta );
105 - //And we ask for a txt formatted diff
 105+ // And we ask for a txt formatted diff
106106 $formatter = new UnifiedDiffFormatter();
107107 $diff_text = $wgContLang->unsegmentForDiff( $formatter->format( $diffs ) );
108108 return $diff_text;
@@ -116,10 +116,10 @@
117117 * @return TODO
118118 */
119119 function st_get_query_results( $query_string, $properties_to_display, $display_title ) {
120 - //i18n
 120+ // i18n
121121 wfLoadExtensionMessages( 'SemanticTasks' );
122122
123 - //We use the Semantic Media Wiki Processor
 123+ // We use the Semantic Media Wiki Processor
124124 global $smwgIP;
125125 include_once( $smwgIP . "/includes/SMW_QueryProcessor.php" );
126126
@@ -129,14 +129,14 @@
130130 $printlabel = "";
131131 $printouts = array();
132132
133 - //add the page name to the printouts
134 - if( $display_title ) {
 133+ // add the page name to the printouts
 134+ if ( $display_title ) {
135135 $to_push = new SMWPrintRequest( SMWPrintRequest::PRINT_THIS, $printlabel );
136136 array_push( $printouts, $to_push );
137137 }
138138
139 - //Push the properties to display in the printout array.
140 - foreach( $properties_to_display as $property ) {
 139+ // Push the properties to display in the printout array.
 140+ foreach ( $properties_to_display as $property ) {
141141 if ( class_exists( 'SMWPropertyValue' ) ) { // SMW 1.4
142142 $to_push = new SMWPrintRequest( SMWPrintRequest::PRINT_PROP, $printlabel, SMWPropertyValue::makeProperty( $property ) );
143143 } else {
@@ -151,7 +151,6 @@
152152 return $results;
153153 }
154154
155 -
156155 function fnRemindAssignees( $wiki_url ) {
157156 global $wgSitename, $wgServer;
158157
@@ -164,7 +163,7 @@
165164 $properties_to_display = array( 'Reminder at', 'Assigned to', 'Target date' );
166165
167166 $results = st_get_query_results( $query_string, $properties_to_display, true );
168 - if( empty( $results ) ) {
 167+ if ( empty( $results ) ) {
169168 return FALSE;
170169 }
171170
@@ -173,9 +172,9 @@
174173 while ( $row = $results->getNext() ) {
175174 $task_name = $row[0]->getNextObject()->getTitle();
176175 $subject = '[' . $wgSitename . '] ' . wfMsg( 'semantictasks-reminder' ) . $task_name;
177 - //The following doesn't work, maybe because we use a cron job.
178 - //$link = $task_name->escapeFullURL();
179 - //So let's do it manually
 176+ // The following doesn't work, maybe because we use a cron job.
 177+ // $link = $task_name->escapeFullURL();
 178+ // So let's do it manually
180179 $link = $wiki_url . $task_name->getPartialURL();
181180
182181 $target_date = $row[3]->getNextObject();
@@ -186,7 +185,7 @@
187186 $date = new DateTime( $today );
188187 $date->modify( "+$remind_me_in day" );
189188
190 - if( $tg_date-> format( 'F d Y' ) == $date-> format( 'F d Y' ) ) {
 189+ if ( $tg_date-> format( 'F d Y' ) == $date-> format( 'F d Y' ) ) {
191190 while ( $task_assignee = $row[2]->getNextObject() ) {
192191 $assignee_username = $task_assignee->getTitle();
193192 $assignee_user_name = explode( ":", $assignee_username );
Index: trunk/extensions/SemanticTasks/SemanticTasks.i18n.php
@@ -10,43 +10,42 @@
1111 * @author Steren Giannini
1212 */
1313 $messages['en'] = array(
14 - 'semantictasks-desc' => 'Email notifications for assigned or updated tasks',
15 - 'semantictasks-newtask' => 'New task:',
16 - 'semantictasks-taskupdated' => 'Task updated:',
17 - 'semantictasks-assignedtoyou-msg' => "Hello $1,
 14+ 'semantictasks-desc' => 'E-mail notifications for assigned or updated tasks',
 15+ 'semantictasks-newtask' => 'New task:',
 16+ 'semantictasks-taskupdated' => 'Task updated:',
 17+ 'semantictasks-assignedtoyou-msg' => "Hello $1,
1818
1919 The task \"$2\" has just been assigned to you",
20 - 'semantictasks-updatedtoyou-msg' => "Hello $1,
 20+ 'semantictasks-updatedtoyou-msg' => "Hello $1,
2121
2222 The task \"$2\" has just been updated.",
23 - 'semantictasks-reminder' => 'Reminder:',
24 - 'semantictasks-reminder-message' => "Hello $1,
 23+ 'semantictasks-reminder' => 'Reminder:',
 24+ 'semantictasks-reminder-message' => "Hello $1,
2525
2626 Just to remind you that the task \"$2\" ends in $3 {{PLURAL:$3|day|days}}.
2727
2828 $4",
29 - 'semantictasks-text-message' => "Here is the task description:",
30 - 'semantictasks-diff-message' => "Here are the differences:",
 29+ 'semantictasks-text-message' => "Here is the task description:",
 30+ 'semantictasks-diff-message' => "Here are the differences:",
3131 );
3232
3333 /** French (Français)
3434 */
3535 $messages['fr'] = array(
36 - 'semantictasks-newtask' => 'Nouvelle tâche :',
37 - 'semantictasks-taskupdated' => 'Tâche mise à jour :',
38 - 'semantictasks-assignedtoyou-msg' => "Bonjour $1,
 36+ 'semantictasks-newtask' => 'Nouvelle tâche :',
 37+ 'semantictasks-taskupdated' => 'Tâche mise à jour :',
 38+ 'semantictasks-assignedtoyou-msg' => "Bonjour $1,
3939
4040 La tâche \"$2\" vous a été assignée.",
41 - 'semantictasks-updatedtoyou-msg' => "Bonjour $1,
 41+ 'semantictasks-updatedtoyou-msg' => "Bonjour $1,
4242
4343 La tâche \"$2\" a été mise à jour.",
44 - 'semantictasks-reminder' => 'Rappel :',
45 - 'reminder-message' => "Bonjour $1,
46 -
 44+ 'semantictasks-reminder' => 'Rappel :',
 45+ 'reminder-message' => "Bonjour $1,
 46+
4747 N'oubliez pas que la tâche \"$2\" se termine dans $3 jours.
4848
4949 $4",
50 - 'semantictasks-text-message' => "Voici la description de la tâche :",
51 - 'semantictasks-diff-message' => "Les différences sont listées ci-dessous :",
 50+ 'semantictasks-text-message' => "Voici la description de la tâche :",
 51+ 'semantictasks-diff-message' => "Les différences sont listées ci-dessous :",
5252 );
53 -

Status & tagging log