Index: trunk/extensions/SemanticTasks/SemanticTasks.php |
— | — | @@ -1,36 +1,38 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -### |
| 4 | +# |
5 | 5 | # This is the path to your installation of SemanticTasks as |
6 | 6 | # seen from the web. Change it if required ($wgScriptPath is the |
7 | 7 | # path to the base directory of your wiki). No final slash. |
8 | | -## |
| 8 | +# # |
9 | 9 | $stScriptPath = $wgScriptPath . '/extensions/SemanticTasks'; |
10 | | -## |
| 10 | +# |
11 | 11 | |
12 | | -### |
| 12 | +# |
13 | 13 | # This is the path to your installation of SemanticTasks as |
14 | 14 | # seen on your local filesystem. Used against some PHP file path |
15 | 15 | # issues. |
16 | | -## |
| 16 | +# |
17 | 17 | $stIP = $IP . '/extensions/SemanticTasks'; |
18 | | -## |
| 18 | +# |
19 | 19 | |
20 | | -#Informations |
| 20 | +# Informations |
21 | 21 | $wgExtensionCredits['parserhook'][] = array( |
22 | 22 | 'name' => 'SemanticTasks', |
23 | | - 'author' => 'Steren Giannini', |
| 23 | + 'author' => 'Steren Giannini', |
24 | 24 | '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', |
27 | 27 | 'descriptionmsg' => 'semantictasks-desc', |
28 | 28 | ); |
29 | 29 | |
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. |
31 | 32 | $wgExtensionFunctions[] = 'st_SetupExtension'; |
32 | 33 | |
33 | | -//i18n |
| 34 | +// i18n |
34 | 35 | $wgExtensionMessagesFiles['SemanticTasks'] = dirname( __FILE__ ) . '/SemanticTasks.i18n.php'; |
35 | 36 | |
| 37 | +// FIXME: Use $wgAutoloadClasses |
36 | 38 | // ST_Notify_Assignment.php |
37 | 39 | require_once( $stIP . "/ST_Notify_Assignment.php" ); |
Index: trunk/extensions/SemanticTasks/ST_CheckForReminders.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | # (C) 2008 Steren Giannini |
4 | 4 | # Licensed under the GNU GPLv2 (or later). |
5 | 5 | |
6 | | -$IP = realpath( dirname( __FILE__ ) . "/../.."); |
| 6 | +$IP = realpath( dirname( __FILE__ ) . "/../.." ); |
7 | 7 | require_once( "$IP/maintenance/commandLine.inc" ); |
8 | 8 | |
9 | 9 | global $smwgIP; |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | global $stIP; |
13 | 13 | require_once( $stIP . '/ST_Notify_Assignment.php' ); |
14 | 14 | |
15 | | -//Let's send reminders |
| 15 | +// Let's send reminders |
16 | 16 | fnRemindAssignees( 'http://teamspace.creativecommons.org/' ); |
17 | 17 | |
18 | 18 | print( "ST check for reminders\n" ); |
Index: trunk/extensions/SemanticTasks/ST_Notify_Assignment.php |
— | — | @@ -3,19 +3,19 @@ |
4 | 4 | # Licensed under the GNU GPLv2 (or later). |
5 | 5 | function fnMailAssignees_updated_task( $article, $current_user, $text, $summary, $minoredit, $watchthis, $sectionanchor, $flags, $revision ) { |
6 | 6 | if ( !$minoredit ) { |
7 | | - //i18n |
| 7 | + // i18n |
8 | 8 | wfLoadExtensionMessages( 'SemanticTasks' ); |
9 | 9 | |
10 | | - //Grab the wiki name |
| 10 | + // Grab the wiki name |
11 | 11 | global $wgSitename; |
12 | 12 | |
13 | | - //Get the revision count to determine if new article |
| 13 | + // Get the revision count to determine if new article |
14 | 14 | $rev = $article->estimateRevisionCount(); |
15 | 15 | |
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 ); |
18 | 18 | } 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 ); |
20 | 20 | } |
21 | 21 | } |
22 | 22 | return TRUE; |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | function fnMailAssignees( $article, $user, $pre_title, $message, $display_diff, $display_text ) { |
26 | 26 | $title = $article->getTitle(); |
27 | 27 | |
28 | | - //Send notifications to assignees and ccs |
| 28 | + // Send notifications to assignees and ccs |
29 | 29 | fnMailNotification( 'Assigned to', $article, $user, $pre_title, $message, $display_diff, $display_text ); |
30 | 30 | fnMailNotification( 'Carbon copy', $article, $user, $pre_title, $message, $display_diff, $display_text ); |
31 | 31 | return TRUE; |
— | — | @@ -37,18 +37,18 @@ |
38 | 38 | function fnMailNotification( $query_word, $article, $user, $pre_title, $message, $display_diff, $display_text ) { |
39 | 39 | $title = $article->getTitle(); |
40 | 40 | |
41 | | - //get the result of the query "[[$title]][[$query_word::+]]" |
| 41 | + // get the result of the query "[[$title]][[$query_word::+]]" |
42 | 42 | $properties_to_display = array(); |
43 | 43 | $properties_to_display[0] = $query_word; |
44 | 44 | $results = st_get_query_results( "[[$title]][[$query_word::+]]", $properties_to_display, false ); |
45 | 45 | |
46 | | - //In theory, there is only one row |
| 46 | + // In theory, there is only one row |
47 | 47 | while ( $row = $results->getNext() ) { |
48 | 48 | $task_assignees = $row[0]; |
49 | 49 | } |
50 | 50 | |
51 | | - //If not any row, do nothing |
52 | | - if( empty( $task_assignees ) ) { |
| 51 | + // If not any row, do nothing |
| 52 | + if ( empty( $task_assignees ) ) { |
53 | 53 | return FALSE; |
54 | 54 | } |
55 | 55 | |
— | — | @@ -63,18 +63,18 @@ |
64 | 64 | $assignee_user_name = explode( ":", $assignee_username ); |
65 | 65 | $assignee_name = $assignee_user_name[1]; |
66 | 66 | $body = wfMsg( $message , $assignee_name , $title ) . $link; |
67 | | - if( $display_text ){ |
| 67 | + if ( $display_text ) { |
68 | 68 | $body .= "\n \n" . wfMsg( 'semantictasks-text-message' ) . "\n" . $article->getContent() ; |
69 | 69 | } |
70 | | - if( $display_diff){ |
| 70 | + if ( $display_diff ) { |
71 | 71 | $body .= "\n \n" . wfMsg( 'semantictasks-diff-message' ) . "\n" . st_generateDiffBody_txt( $title ); |
72 | 72 | } |
73 | 73 | |
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 ); |
76 | 76 | |
77 | 77 | $assignee = User::newFromName( $assignee_name ); |
78 | | - //if assignee is the current user, do nothing |
| 78 | + // if assignee is the current user, do nothing |
79 | 79 | if ( $assignee->getID() != $user->getID() ) { |
80 | 80 | $assignee_mail = new MailAddress( $assignee->getEmail(), $assignee_name ); |
81 | 81 | $user_mailer->send( $assignee_mail, $from, $subject, $body ); |
— | — | @@ -92,16 +92,16 @@ |
93 | 93 | function st_generateDiffBody_txt( $title ) { |
94 | 94 | $revision = Revision::newFromTitle( $title, 0 ); |
95 | 95 | $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: |
97 | 97 | global $wgContLang; |
98 | 98 | $diff->loadText(); |
99 | 99 | $otext = str_replace( "\r\n", "\n", $diff->mOldtext ); |
100 | 100 | $ntext = str_replace( "\r\n", "\n", $diff->mNewtext ); |
101 | 101 | $ota = explode( "\n", $wgContLang->segmentForDiff( $otext ) ); |
102 | 102 | $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 |
104 | 104 | $diffs = new Diff( $ota, $nta ); |
105 | | - //And we ask for a txt formatted diff |
| 105 | + // And we ask for a txt formatted diff |
106 | 106 | $formatter = new UnifiedDiffFormatter(); |
107 | 107 | $diff_text = $wgContLang->unsegmentForDiff( $formatter->format( $diffs ) ); |
108 | 108 | return $diff_text; |
— | — | @@ -116,10 +116,10 @@ |
117 | 117 | * @return TODO |
118 | 118 | */ |
119 | 119 | function st_get_query_results( $query_string, $properties_to_display, $display_title ) { |
120 | | - //i18n |
| 120 | + // i18n |
121 | 121 | wfLoadExtensionMessages( 'SemanticTasks' ); |
122 | 122 | |
123 | | - //We use the Semantic Media Wiki Processor |
| 123 | + // We use the Semantic Media Wiki Processor |
124 | 124 | global $smwgIP; |
125 | 125 | include_once( $smwgIP . "/includes/SMW_QueryProcessor.php" ); |
126 | 126 | |
— | — | @@ -129,14 +129,14 @@ |
130 | 130 | $printlabel = ""; |
131 | 131 | $printouts = array(); |
132 | 132 | |
133 | | - //add the page name to the printouts |
134 | | - if( $display_title ) { |
| 133 | + // add the page name to the printouts |
| 134 | + if ( $display_title ) { |
135 | 135 | $to_push = new SMWPrintRequest( SMWPrintRequest::PRINT_THIS, $printlabel ); |
136 | 136 | array_push( $printouts, $to_push ); |
137 | 137 | } |
138 | 138 | |
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 ) { |
141 | 141 | if ( class_exists( 'SMWPropertyValue' ) ) { // SMW 1.4 |
142 | 142 | $to_push = new SMWPrintRequest( SMWPrintRequest::PRINT_PROP, $printlabel, SMWPropertyValue::makeProperty( $property ) ); |
143 | 143 | } else { |
— | — | @@ -151,7 +151,6 @@ |
152 | 152 | return $results; |
153 | 153 | } |
154 | 154 | |
155 | | - |
156 | 155 | function fnRemindAssignees( $wiki_url ) { |
157 | 156 | global $wgSitename, $wgServer; |
158 | 157 | |
— | — | @@ -164,7 +163,7 @@ |
165 | 164 | $properties_to_display = array( 'Reminder at', 'Assigned to', 'Target date' ); |
166 | 165 | |
167 | 166 | $results = st_get_query_results( $query_string, $properties_to_display, true ); |
168 | | - if( empty( $results ) ) { |
| 167 | + if ( empty( $results ) ) { |
169 | 168 | return FALSE; |
170 | 169 | } |
171 | 170 | |
— | — | @@ -173,9 +172,9 @@ |
174 | 173 | while ( $row = $results->getNext() ) { |
175 | 174 | $task_name = $row[0]->getNextObject()->getTitle(); |
176 | 175 | $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 |
180 | 179 | $link = $wiki_url . $task_name->getPartialURL(); |
181 | 180 | |
182 | 181 | $target_date = $row[3]->getNextObject(); |
— | — | @@ -186,7 +185,7 @@ |
187 | 186 | $date = new DateTime( $today ); |
188 | 187 | $date->modify( "+$remind_me_in day" ); |
189 | 188 | |
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' ) ) { |
191 | 190 | while ( $task_assignee = $row[2]->getNextObject() ) { |
192 | 191 | $assignee_username = $task_assignee->getTitle(); |
193 | 192 | $assignee_user_name = explode( ":", $assignee_username ); |
Index: trunk/extensions/SemanticTasks/SemanticTasks.i18n.php |
— | — | @@ -10,43 +10,42 @@ |
11 | 11 | * @author Steren Giannini |
12 | 12 | */ |
13 | 13 | $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, |
18 | 18 | |
19 | 19 | The task \"$2\" has just been assigned to you", |
20 | | - 'semantictasks-updatedtoyou-msg' => "Hello $1, |
| 20 | + 'semantictasks-updatedtoyou-msg' => "Hello $1, |
21 | 21 | |
22 | 22 | 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, |
25 | 25 | |
26 | 26 | Just to remind you that the task \"$2\" ends in $3 {{PLURAL:$3|day|days}}. |
27 | 27 | |
28 | 28 | $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:", |
31 | 31 | ); |
32 | 32 | |
33 | 33 | /** French (Français) |
34 | 34 | */ |
35 | 35 | $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, |
39 | 39 | |
40 | 40 | La tâche \"$2\" vous a été assignée.", |
41 | | - 'semantictasks-updatedtoyou-msg' => "Bonjour $1, |
| 41 | + 'semantictasks-updatedtoyou-msg' => "Bonjour $1, |
42 | 42 | |
43 | 43 | 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 | + |
47 | 47 | N'oubliez pas que la tâche \"$2\" se termine dans $3 jours. |
48 | 48 | |
49 | 49 | $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 :", |
52 | 52 | ); |
53 | | - |