Index: trunk/extensions/TodoTasks/SpecialTaskList_body.php |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | static $messagesLoaded = false; |
6 | 6 | if ($messagesLoaded) return; |
7 | 7 | $messagesLoaded = true; |
8 | | - wfLoadExtensionMessages('TaskList'); |
| 8 | + wfLoadExtensionMessages('TaskList'); |
9 | 9 | } |
10 | 10 | |
11 | 11 | function wfMsgTL($key) { |
— | — | @@ -13,10 +13,10 @@ |
14 | 14 | } |
15 | 15 | |
16 | 16 | function wfTodoParserFunction_Setup() { |
17 | | - global $wgParser; |
| 17 | + global $wgParser; |
18 | 18 | |
19 | | - # Set a function hook associating the "example" magic word with our function |
20 | | - $wgParser->setFunctionHook( 'todo', 'wfTodoParserFunction_Render' ); |
| 19 | + # Set a function hook associating the "example" magic word with our function |
| 20 | + $wgParser->setFunctionHook( 'todo', 'wfTodoParserFunction_Render' ); |
21 | 21 | |
22 | 22 | return true; |
23 | 23 | } |
— | — | @@ -71,18 +71,18 @@ |
72 | 72 | } |
73 | 73 | |
74 | 74 | function getValidProjects() { |
75 | | - global $wgOut; |
| 75 | + global $wgOut; |
76 | 76 | |
77 | | - $ProjPageTitle = Title::newFromText ('TodoTasksValidProjects', NS_MEDIAWIKI) ; |
78 | | - if ($ProjPageTitle == NULL) { |
79 | | - $wgOut->addWikiText(wfMsgTL('tasklistnoprojects')); |
80 | | - return; |
81 | | - } |
82 | | - return Revision::newFromTitle($ProjPageTitle)->getText(); |
| 77 | + $validProjects = wfMsgForContentNoTrans( 'todoTasksValidProjects' ); |
| 78 | + if ( $validProjects == '' ) { |
| 79 | + $wgOut->addWikiText( wfMsg( 'tasklistnoprojects' ) ); |
| 80 | + return; |
| 81 | + } |
| 82 | + return $validProjects; |
83 | 83 | } |
84 | 84 | |
85 | 85 | function validateProject($projlist, $proj) { |
86 | | - |
| 86 | + |
87 | 87 | $validprojects = preg_split('/\s*\*\s*/', $projlist, -1, PREG_SPLIT_NO_EMPTY); |
88 | 88 | foreach ($validprojects as $vp) { |
89 | 89 | if (preg_match("/^$proj$/i", $vp)) |
— | — | @@ -221,8 +221,8 @@ |
222 | 222 | (todo) # template may be a TODO |
223 | 223 | | # or |
224 | 224 | (action item) # template may be an ACTION ITEM |
225 | | - ) |
226 | | - \s* # the template name may have trailing spaces |
| 225 | + ) |
| 226 | + \s* # the template name may have trailing spaces |
227 | 227 | \| # the pipe to indicate template parameter #1 (task description) |
228 | 228 | ( # capture the template parameter in $4; this string is comprized of |
229 | 229 | [^|]*? # a possible sequence of non pipe characters |
— | — | @@ -311,7 +311,7 @@ |
312 | 312 | list ($firstname, $lastname) = preg_split('/ /', $fullname); |
313 | 313 | |
314 | 314 | $wgOut->addWikiText(sprintf(wfMsgTL('tasklistbyname'), $fullname)); |
315 | | - $wgOut->addWikiText("<dpl> uses=Template:Todo\n notuses=Template:Status Legend\n include={Todo}.dpl\n |
| 315 | + $wgOut->addWikiText("<dpl> uses=Template:Todo\n notuses=Template:Status Legend\n include={Todo}.dpl\n |
316 | 316 | includematch=/${fullname}/i\n </dpl>"); |
317 | 317 | } |
318 | 318 | } |
— | — | @@ -319,65 +319,75 @@ |
320 | 320 | |
321 | 321 | class TaskListByProject extends SpecialPage |
322 | 322 | { |
323 | | - function TaskListByProject() { |
324 | | - SpecialPage::SpecialPage("TaskListByProject"); |
325 | | - self::loadMessages(); |
326 | | - return true; |
327 | | - } |
| 323 | + public function __construct() { |
| 324 | + parent::__construct( 'TaskListByProject' ); |
| 325 | + SpecialPage::SpecialPage("TaskListByProject"); |
| 326 | + self::loadMessages(); |
| 327 | + return true; |
| 328 | + } |
328 | 329 | |
329 | 330 | function loadMessages() { |
330 | 331 | TaskListLoadMessages(); |
331 | 332 | return true; |
332 | 333 | } |
333 | 334 | |
334 | | - function execute($proj) { |
335 | | - global $wgRequest, $wgOut; |
| 335 | + function execute($proj) { |
| 336 | + global $wgRequest, $wgOut, $wgUseProjects; |
336 | 337 | |
337 | | - $this->setHeaders(); |
338 | | - $wgOut->setPagetitle(wfMsgTL('tasklistbyproject')); |
| 338 | + $this->setHeaders(); |
339 | 339 | |
340 | | - $project = ''; |
| 340 | + if ( !$wgUseProjects ) { |
| 341 | + $wgOut->showErrorPage( 'tasklistbyproject', 'tasklistnowguseprojects' ); |
| 342 | + return; |
| 343 | + } |
341 | 344 | |
342 | | - if (isset($proj)) { |
343 | | - $proj = str_replace('+', ' ', $proj); |
344 | | - $validProjects = getValidProjects(); |
345 | | - $project = validateProject($validProjects, $proj); |
346 | | - if ($project == wfMsgTL('tasklistunknownproject')) { |
347 | | - $wgOut->addWikiText(sprintf(wfMsgTL('tasklistbyprojectbad'), $proj)); |
348 | | - self::ValidProjectsForm(); |
349 | | - return; |
350 | | - } |
351 | | - } |
| 345 | + $wgOut->setPagetitle(wfMsgTL('tasklistbyproject')); |
352 | 346 | |
353 | | - self::ValidProjectsForm(); |
| 347 | + $project = ''; |
354 | 348 | |
355 | | - if ($project == '') |
356 | | - $project = $wgRequest->getVal('project'); |
357 | | - if ($project) { |
358 | | - $wgOut->addWikiText("----"); |
359 | | - $wgOut->addWikiText(sprintf(wfMsgTL('tasklistbyprojname'), $project)); |
360 | | - $dpl = "<dpl>\n uses=Template:Todo \n notuses=Template:Status Legend \n include={Todo}.dpl \n"; |
361 | | - $dpl .= 'includematch=/project\s*=\s*([^\x2c]*\x2c)*\s*' . $project . '\s*(\x2c[^\x2c]*\s*)*$/i'; |
362 | | - $dpl .= "\n </dpl>"; |
363 | | - $wgOut->addWikiText($dpl); |
364 | | - } |
365 | | - } |
| 349 | + if (isset($proj)) { |
| 350 | + $proj = str_replace('+', ' ', $proj); |
| 351 | + $validProjects = getValidProjects(); |
| 352 | + $project = validateProject($validProjects, $proj); |
| 353 | + if ($project == wfMsgTL('tasklistunknownproject')) { |
| 354 | + $wgOut->addWikiText(sprintf(wfMsgTL('tasklistbyprojectbad'), $proj)); |
| 355 | + self::ValidProjectsForm(); |
| 356 | + return; |
| 357 | + } |
| 358 | + } |
366 | 359 | |
367 | | - function ValidProjectsForm() { |
368 | | - global $wgOut; |
| 360 | + self::ValidProjectsForm(); |
369 | 361 | |
370 | | - $titleObj = SpecialPage::getTitleFor( "TaskListByProject" ); |
371 | | - $kiaction = $titleObj->getLocalUrl(); |
372 | | - $wgOut->addHTML("<FORM ACTION=\"{$kiaction}\" METHOD=GET><LABEL FOR=project>" . |
373 | | - wfMsgTL('tasklistchooseproj') . "</LABEL>"); |
374 | | - $wgOut->addHTML("<select name=project>"); |
| 362 | + if ($project == '') |
| 363 | + $project = $wgRequest->getVal('project'); |
| 364 | + if ($project) { |
| 365 | + $wgOut->addWikiText("----"); |
| 366 | + $wgOut->addWikiText(sprintf(wfMsgTL('tasklistbyprojname'), $project)); |
| 367 | + $dpl = "<dpl>\n uses=Template:Todo \n notuses=Template:Status Legend \n include={Todo}.dpl \n"; |
| 368 | + $dpl .= 'includematch=/project\s*=\s*([^\x2c]*\x2c)*\s*' . $project . '\s*(\x2c[^\x2c]*\s*)*$/i'; |
| 369 | + $dpl .= "\n </dpl>"; |
| 370 | + $wgOut->addWikiText($dpl); |
| 371 | + } |
| 372 | + } |
375 | 373 | |
376 | | - $validprojects = preg_split('/\s*\*\s*/', getValidProjects(), -1, PREG_SPLIT_NO_EMPTY); |
377 | | - foreach ($validprojects as $vp) |
378 | | - $wgOut->addHTML("<option value=\"$vp\">$vp</option>"); |
| 374 | + function ValidProjectsForm() { |
| 375 | + global $wgOut; |
379 | 376 | |
380 | | - $wgOut->addHTML("</select><INPUT TYPE=submit VALUE='" . wfMsgTL('tasklistprojdisp') . "'></FORM>"); |
381 | | - } |
| 377 | + $titleObj = SpecialPage::getTitleFor( "TaskListByProject" ); |
| 378 | + $kiaction = $titleObj->getLocalUrl(); |
| 379 | + |
| 380 | + $validprojects = preg_split('/\s*\*\s*/', getValidProjects(), -1, PREG_SPLIT_NO_EMPTY); |
| 381 | + |
| 382 | + if( $validprojects ) { |
| 383 | + $wgOut->addHTML("<FORM ACTION=\"{$kiaction}\" METHOD=GET><LABEL FOR=project>" . |
| 384 | + wfMsgTL('tasklistchooseproj') . "</LABEL>"); |
| 385 | + $wgOut->addHTML("<select name=project>"); |
| 386 | + |
| 387 | + foreach ($validprojects as $vp) { |
| 388 | + $wgOut->addHTML("<option value=\"$vp\">$vp</option>"); |
| 389 | + } |
| 390 | + |
| 391 | + $wgOut->addHTML("</select><INPUT TYPE=submit VALUE='" . wfMsgTL('tasklistprojdisp') . "'></FORM>"); |
| 392 | + } |
| 393 | + } |
382 | 394 | } |
383 | | - |
384 | | -?> |
Index: trunk/extensions/TodoTasks/SpecialTaskList.i18n.php |
— | — | @@ -23,6 +23,7 @@ |
24 | 24 | 'tasklistchooseproj' => 'Select project:', |
25 | 25 | 'tasklistprojdisp' => 'Display', |
26 | 26 | 'tasklistbyname' => '== Todo list for %s ==', |
| 27 | + 'tasklistnowguseprojects' => 'You have set $wgUseProjects to "false" and cannot use this page.', |
27 | 28 | 'tasklistnoprojects' => "Error: It looks like you enabled '''\$wgUseProjects''', but did not create [[MediaWiki:TodoTasksValidProjects]]. See [http://www.mediawiki.org/wiki/Extension:Todo_Tasks#Step_8 Installation Instructions] for more details.", |
28 | 29 | 'tasklistemailbody' => ", |
29 | 30 | |
— | — | @@ -31,6 +32,7 @@ |
32 | 33 | To see your complete Task List go to %s. |
33 | 34 | |
34 | 35 | Your friendly %s notification system", |
| 36 | + 'todoTasksValidProjects' => '', # Do not translate this message. |
35 | 37 | ); |
36 | 38 | |
37 | 39 | /** Message documentation (Message documentation) |