User:Rob st

From MediaWiki.org
Jump to: navigation, search

Find me on Twitter.

Contents

[edit] "Bugfixing" Extensions

[edit] Extension:Todo_Tasks

[edit] Solution for empty Special:Tasklist-Page

The basic issue is that the extension only displays Tasks assgined to the $fullname of a user. So I modified the code in TodoTasks_body.php around line 299 of the original file to:

  1. $wgOut->addWikiText(sprintf(wfMsgTL('tasklistbyname'), $fullname));
    
  2. /* Show Todo items assigned to full name */
    
  3. $wgOut->addWikiText("<dpl> uses=Template:Todo\n notuses=Template:Status Legend\n include={Todo}.dpl\n includematch=/${fullname}/i\n </dpl>");
    
  4. /* Show Todo items assgigned to username */
    
  5. $wgOut->addWikiText("<dpl> uses=Template:Todo\n notuses=Template:Status Legend\n include={Todo}.dpl\n includematch=/${username}/i\n </dpl>");
    
  6.  
    
  7. /* Show tasks in progress */
    
  8. $wgOut->addWikiText(sprintf(wfMsgTL('tasklistbynameinprogress'), $fullname));
    
  9. /* Show in-progress items assigned to full name */
    
  10. $wgOut->addWikiText("<dpl> uses=Template:InProgress\n notuses=Template:Status Legend\n include={InProgress}.dpl\n includematch=/${fullname}/i\n </dpl>"); 
    
  11. /* Show in-progress items assgigned to username */
    
  12. $wgOut->addWikiText("<dpl> uses=Template:InProgress\n notuses=Template:Status Legend\n include={InProgress}.dpl\n includematch=/${username}/i\n </dpl>");
    

I guess that could be handled prettier, if you would change somthing around line 289 ff., where the extension checks for the names.

  1.         foreach ($u as $user) {
    
  2.             if (!$user) {
    
  3.                 $user = $wgUser;
    
  4.             }
    
  5.             $username = $user->getName();
    
  6.             $fullname = $user->getRealName();
    
  7.             // FIXME: Notice Undefined offset: 1 in extensions\TodoTasks\SpecialTaskList_body.php on line 306
    
  8.             // If GetRealName does not contain one or more spaces.
    
  9.             list ($firstname, $lastname) = preg_split('/ /', $fullname);
    

But I am not that deep into PHP.

[edit] Solution for redirecting to homepage when displaying projects in Special:TaskListByProject

The problem seems to be a wrong FORM-method call, which is changed as follows:

In the TodoTasks_body.php, you'll find at the end (around line 353 of the original file):

  1.         function ValidProjectsForm() {
    
  2.                 global $wgOut;
    
  3.  
    
  4.                 $titleObj = SpecialPage::getTitleFor( "TaskListByProject" );
    
  5.                 $kiaction = $titleObj->getLocalUrl();
    
  6.  
    
  7.                 $validprojects = preg_split('/\s*\*\s*/', getValidProjects(), -1, PREG_SPLIT_NO_EMPTY);
    
  8.  
    
  9.                 if( $validprojects ) {
    
  10.                         $wgOut->addHTML("<FORM ACTION=\"{$kiaction}\" METHOD=GET><LABEL FOR=project>" .
    
  11.                         wfMsgTL('tasklistchooseproj') . "</LABEL>");
    
  12.                         $wgOut->addHTML("<select name=project>");
    
  13.  
    
  14.                         foreach ($validprojects as $vp) {
    
  15.                                 $wgOut->addHTML("<option value=\"$vp\">$vp</option>");
    
  16.                         }
    
  17.  
    
  18.                         $wgOut->addHTML("</select><INPUT TYPE=submit VALUE='" . wfMsgTL('tasklistprojdisp') . "'></FORM>");
    
  19.                 }
    
  20.         }
    

Just change the form method from GET to POST in line 362 (highlighted above) to:

  1.                         $wgOut->addHTML("<FORM ACTION=\"{$kiaction}\" METHOD=POST><LABEL FOR=project>" .
    
Personal tools
Namespaces

Variants
Actions
Navigation
Support
Download
Development
Communication
Print/export
Toolbox