Extension talk:Tasks Extension

From MediaWiki.org

Jump to: navigation, search
The following discussion has been transferred from meta.wikimedia.org.
Any user names refer to users of that site, who are not necessarily users of MediaWiki.org (even if they share the same username).

Contents

[edit] Difficulty

Great extension, lots of possibilities...Unfortunately, the parser removes the namespace when creating links on the task list. Is there a way to fix this so that the links work for pages in namespaces other than (main)? 154.20.86.196 05:01, 10 November 2005 (UTC)

Seconded.
71.67.100.211 04:32, 13 December 2005 (UTC)
This is now fixed Iubito 16:03, 10 February 2006 (UTC)

--132.183.202.242 19:11, 14 February 2006 (UTC) : Great Extension, but the script doesn't extract the owner correctly, if you edit a dot (.) at the end of a task line. Can you please fix this, or provide a corrected example.

[edit] A Couple of Things

Great extension. Very handy, I especially like the special page. I have two comments / requests:

  1. Call me the ugly American, but a way to change the date format to American month-day-year would be nice.
  2. Expand it a bit with due date, and then connect it with your - equally good - Events extension

Thanks

Aran Deltac no longer maintain/support his extensions :( I upgraded this one to version 0.4 for my needs. Not sure I'll need events extension... Iubito 16:03, 10 February 2006 (UTC)


[edit] How to get this working with MediaWiki 1.5.6?

Is there a small Tutorial or something like that? Thanks in advance

Carsten

Thanks to google cache, I found the instructions written by Aran Deltac before he changed his website. I've just written them to Tasks Extension with some fixes. Hope this help ! Iubito 16:05, 10 February 2006 (UTC)

[edit] How assigned a task ?

How to assign a task to a given user ? I've understand it's possible, but haven't understand how to do it.

It's probably basic, but i can't find the way....

(french) Comment faire pour assigner une tâche à un utilisateur. J'ai cru comprendre que cela était possible, mais je ne trouve pas la bonne façon de saisir....

Paul FABING

Add "(User)" at the end of a task line
Ajoute « (Utilisateur) » à la fin d'une ligne
--82.255.247.96 06:11, 27 February 2006 (UTC)

Mais bon sang mais c'est bien sûr !! Merci 82.227.68.218 21:51, 2 March 2006 (UTC)


[edit] Kudos

--Metasim 14:09, 3 March 2006 (UTC)

Thanks a bunch for bringing this to MediaWiki!! Great work!

[edit] How do I put a <tasks> tag in a template?

I'd like to create a template that creates tasks but it does not work. <tasks> [{{{4}}}] {{{5}}} ({{{6}}}) </tasks> Thanks! -David

[edit] Compatibility with Calendar Extension:

Nice extension, Iubito! I added a little code to savetasks(), specifically:

...
	# Rebuild the $tasks_buffer array (in case we're on a <calendar> page)
	clearTasks();
	$content = array(); $tags = array(); $params = array();

	Parser::extractTagsAndParams( 'tasks', $text, $content, $tags, $params );
	foreach($tags as $marker => $markerVal)
		tasksHook( $content[$marker], $params[$marker] );
...

and added the $user and $text incoming parameters to saveTasks(). This was to solve a problem where the "Calendar" extension is rendering (and parsing) text from other pages (which may contain tasks). saveTasks() was then saving repeats of the tasks in the 'tasks' table, attributing them to the page that contained the "calendar" call. This modification maintains attribution to just the page being edited. martin - at - ac6rm.net

[edit] Error

--68.186.119.215 08:51, 3 April 2006 (UTC)

I am getting the following error thrown at me once for each task listed on a page:


Notice: Undefined index: hidden in /var/www/vhosts/forgestudios.com/httpdocs/dev/extensions/Tasks.php on line 44

So for example, if I have


<tasks>
[ ] Regular task (Owner User)
[1] High priority task.
[2] Medium priority task.
[3] Low priority task (Owner User)
[!] Urgent task.
[x] Closed task.
</tasks>

I will have the following php errors:


Notice: Undefined index: hidden in /var/www/vhosts/forgestudios.com/httpdocs/dev/extensions/Tasks.php on line 44

Notice: Undefined index: hidden in /var/www/vhosts/forgestudios.com/httpdocs/dev/extensions/Tasks.php on line 44

Notice: Undefined index: hidden in /var/www/vhosts/forgestudios.com/httpdocs/dev/extensions/Tasks.php on line 44

Notice: Undefined index: hidden in /var/www/vhosts/forgestudios.com/httpdocs/dev/extensions/Tasks.php on line 44

Notice: Undefined index: hidden in /var/www/vhosts/forgestudios.com/httpdocs/dev/extensions/Tasks.php on line 44

Notice: Undefined index: hidden in /var/www/vhosts/forgestudios.com/httpdocs/dev/extensions/Tasks.php on line 44


I am using the tabbed menu mod, but it is not in a template, nor am I using it on any page with the tasks. Other than that, it is a completely clean install. Any help would be appreciated. Thank you.

I've fixed that - I added an isset() to the Tasks.php. 88.108.59.121

[edit] Fixed with isset()

Could you show me an example of how you were able to fix that?

[edit] Error

When i include Tasks i got an error message

UNIQ63....

All my <anything></antyhing> are replaced by this error


I am suffering from the same thing - using this extension would 'scrap' all other extensions relying on <tags></tags> which is a shame because it is such a valuable extension 82.31.216.212 02:07, 5 July 2006 (UTC)

[edit] MediaWiki 1.6.7 support

I replaced some functions with this code to make the extension work with MediaWiki 1.6.7 :

extensions/Tasks.php

-----------------------------------------------#
# Purpose   : HTML format a task.
function formatTask( $status, $summary, $owner='', $page='' ) {
        global $wgOut, $wgScriptPath;
        $imgTitle = 'Regular task'; $alt = '[ ]';
        $output = '<img src="'.$wgScriptPath.'/images/task';
        switch ($status) {
                case 'x': $output .= '_done'; $alt = '[x]'; $imgTitle = 'Closed task'; break;
                case '!': $output .= '_alert'; $alt = '[!]'; $imgTitle = 'Urgent task'; break;
                case '1': $output .= '_1'; $alt = '[1]'; $imgTitle = 'High priority task'; break;
                case '2': $output .= '_2'; $alt = '[2]'; $imgTitle = 'Medium priority task'; break;
                case '3': $output .= '_3'; $alt = '[3]'; $imgTitle = 'Low priority task'; break;
        }
        $output .= '.png" width="13" height="13" alt="'.$alt.'" title="'.$imgTitle.'" /> ';

        if ($owner) { $summary .= ' ([[User:'.$owner.'|'.$owner.']])'; }
        if ($page) { $summary = "[[:$page]]: ".$summary; }

        // parse() cannot be called recursively, so we need to create a new Parser
        global $wgTitle;
        $localParser = new Parser();
        $options = ParserOptions::newFromUser( $wgUser );
        $out = $localParser->parse($summary, $wgTitle, $options, false);
        $output .= $out->getText().'<br />';

        return $output;
}


#-----------------------------------------------#
# Purpose   : Used after a page is saved to first delete
#             all tasks and then save the new ones created
#             in the tasks buffer.
# Parameters: article, The article object.
# rev: 2006-03-12: <calendar> extension will cause double-logging of
# tasks rendered on a sub-page.  "Rebuild" section prevents this.
function saveTasks( $article, $user, $text ) {

        global $tasks_buffer;
        global $wgOut;
        $page_id = $article->getID();
        $dbr =& wfGetDB( DB_MASTER );
        # Delete all tasks for this page.
        $dbr->delete(
                'tasks',
                array( 'page_id' => $page_id )
        );

        # Rebuild the $tasks_buffer array (in case we're on a <calendar> page)
        clearTasks();
        $matches = array();
        $elements[] = 'tasks';

        $text = Parser::extractTagsAndParams( $elements, $text, $matches );
        foreach( $matches as $marker => $data ) {
                list( $element, $content, $params, $tag ) = $data;
                tasksHook( $content, $params );
        }

        # Re-insert all tasks that were created when parsing this page.
        foreach ($tasks_buffer as $task) {
                $task['page_id'] = $page_id;
                $dbr->insert(
                        'tasks',
                        $task
                );
        }
        return 1;
}

[edit] It doesn't work for me

I don't remember the error message, 'cause I've tried a lot of things, but this didn't work for me.

As it's a parser extension, there is a 3rd parameter &$parser I add to tasksHook (and then to formatTask). It work in the articles. But the special page doesn't work anymore, 'cause it doesn't know this $parser. It only knows $wgParser which doesn't have mOptions and then fails... :'(

--Iubito 21:20, 6 July 2006 (UTC)

[edit] A local parser

It's not a good idea the local parser, because it has not the other extension registered (my summary contain <anotherextensiontag></anotherextensiontag> and it costs some ms each time to create it.

After a big headache and a lot of help from TimStarling on IRC, I've the solution. I update the article.

--Iubito 07:03, 7 July 2006 (UTC)

[edit] Multiple tasks in one page

I got a problem when putting <tasks></tasks> in more than one place on my page. i.e:

<tasks>[x] foo</tasks>
== foo ==
* <tasks>[1] bar</tasks>
* <tasks>[2] foo</tasks>
=== bar ===
<tasks>
 [x] foo
 [1] foo
 [2] foo
 [3] foo
</tasks>

Someone could please help me?

Ponsfrilus 13:49, 10 July 2006 (UTC)
What output do you get? I get the same tasks repeating below, which is not the desired output.
Same problem here. Add clearTasks(); after the global $tasks_buffer; statement in the tasksHook function.
Hackerssidekick 08:11, 19 July 2006 (UTC)
I'm getting the same behavior, every time I enter a new tasks block it displays all the tasks up to that point from the whole page.--TheChin! 18:11, 4 August 2006 (UTC)

[edit] where to find older versions

where can i find older versions of the script, so i can use it with older mediawiki versions?

Look at the history of the page --82.248.126.211 19:04, 16 July 2006 (UTC)


[edit] screenshot request

This is better before spending time to install .... mailto:sancelot@free.fr

Yes, please post a screenshot or running demo on a wiki.

[edit] A few comments

The version numbers should be the same for Tasks.php and Special:Tasks.php, since an overall version # is listed at the top of the page.

In MW 1.6.7 the parameters don't seem to have any effect because arg_string passed to execute is empty. Try using wgRequest instead of this parameter, it's more inline with what MW does.

--Tderouin 20:51, 21 August 2006 (UTC)

[edit] Works for MediaWiki 1.7.1 - with a couple mods

A few things I needed to do a few things to get it working in MediaWiki 1.7.1.

First, I followed the comments above in MediaWiki 1.6.7 support comment above. Copying and pasteing the revised functions.

Second, in extensions/Tasks.php I modified the function as below:


#-----------------------------------------------#
function saveTasks( $article, $user, $text ) {

        global $tasks_buffer;
        global $wgOut;
        $page_id = $article->getID();

        $dbr =& wfGetDB( DB_MASTER );
        # Delete all tasks for this page.
        $dbr->delete(
                'tasks',
                array( 'page_id' => $page_id )
        );

        # Rebuild the $tasks_buffer array (in case we're on a <calendar> page)
	# Updated parameter values and return values for extractTagsAndParams function. 
	# The lines below work with Wiki 1.7.1
        clearTasks();
        $matches = array(); $tags = array(); $params = array();
        $element = 'tasks';
        $text = Parser::extractTagsAndParams( $element, $text, $matches, $tags, $params );
        foreach( $matches as $marker => $data ) {
				$content = $data;
				addToTaskBuffer($content);
        }

        # Re-insert all tasks that were created when parsing this page.
        foreach ($tasks_buffer as $task) {
                $task['page_id'] = $page_id;
                $dbr->insert(
                        'tasks',
                        $task
                );
        }
        return 1;
}

As mentioned in my code comments, I am not sure at what version MediaWiki cahnged the extractTagsAndParams function. I do know that I need to update this section to get the information for saving to the database in MediaWiki 1.7.1.

Now it seems to work fine. Please comment if anyone finds a better solution. I suppose one should do a little error checking here for MediaWiki version number and return the correct value no matter what version, but who has the time. :)

Robin

[edit] Use of Special:Tasks as a template

I would like to use lists of tasks as a template:

{{Special:Task}}

But it do not work. It work for me on Newpages:

{{Special:Newpages/10}}

[edit] Could not make it work with version 1.67

I have used the latest Tasks.php and SpecialTasks.php and the versions 0.51 with MediaWiki. I cannot save the tasks. I just get usual text and no formatted out put when I try to save anything with the tasks tag. The database is not getting populated either. The special page comes out empty as a result. Any ideas?

In addition following the modifications through the history and discussions is kind of confusing. Please post separately working versions for various versions of MediaWiki.

[edit] Duplicated tasks

I ran into an small bug where a page with multiple tasks would have task duplication.

The following code

<tasks>
[ ] a
[ ] b
</tasks>

<tasks>
[ ] c
[ ] d
[ ] e
</tasks>

would produce the output

[ ] a
[ ] b

[ ] a
[ ] b
[ ] c
[ ] d
[ ] e

To fix it I clear the task buffer by inserting

$tasks_buffer = array();

to line 30 which is just before the call to addToTaskBuffer($content) in the tasksHook function.

--Superjodash 19:15, 11 January 2007 (UTC)

[edit] Hidden Attribute ignored

working with MW 1.6.9, the extesnsion works except for the hidden parameter which seems to be ingnored (Aran originally put it at my request), the system doesn't seem to update the the hidden field in the database correctly, it is always 'n', if you set the value in the database to 'y' then it is ignored and the tasks still appear on the article page. (The idea was that hidden tasks don't appear on the article page but do in the special:tsks page), any help ?


[edit] Notice: Undefined offset

At the Special:Tasks page the following error is thrown in the header of the page:

Notice: Undefined offset: 1 in /home/httpd/vhosts/lalal.nl/httpsdocs/wiki/includes/SpecialTasks.php on line 48
Notice: Undefined index: limit in /home/httpd/vhosts/lalal.nl/httpsdocs/wiki/includes/SpecialTasks.php on line 53
Notice: Undefined index: owner in /home/httpd/vhosts/lalal.nl/httpsdocs/wiki/includes/SpecialTasks.php on line 56
Notice: Undefined index: status in /home/httpd/vhosts/lalal.nl/httpsdocs/wiki/includes/SpecialTasks.php on line 62
Notice: Undefined index: owner in /home/httpd/vhosts/lalal.nl/httpsdocs/wiki/includes/SpecialTasks.php on line 65
Notice: Undefined index: hidden in /home/httpd/vhosts/lalal.nl/httpsdocs/wiki/includes/SpecialTasks.php on line 68
Notice: Undefined index: owner in /home/httpd/vhosts/lalal.nl/httpsdocs/wiki/includes/SpecialTasks.php on line 82

I followed the instructions carefully, so I have no idea of what went wrong. Any ideas? Thnx in advance!
--83.85.174.37 13:18, 11 February 2007 (UTC)

I discovered I've the problem too. I think it's due to a recent version of MW. I'll check what happen.
--Iubito 07:17, 13 February 2007 (UTC)
Solved !
In SpecialTasks.php, when there is
if ($args['...'])
, replace by
if (isset($args['...']))
and also, line 44 :
	# Parse arguments.
	$args = array();
	if ($args_string != '') {
		foreach (explode('&',$args_string) as $pair) {
			$pair = explode('=',$pair);
			$args[$pair[0]] = $pair[1];
		}
	}
(I encapsulate the foreach in the if)
--Iubito 04:17, 22 February 2007 (UTC)

[edit] "My Tasks"-link in personal toolbar

Just wanted to throw in that we have edited ./includes/SkinTemplate.php ~ line 523 on our wiki, like this:

# "My Tasks"
$href = self::makeSpecialUrl( 'Tasks' );
$personal_urls['mytasks'] = array(
'text' => wfMsg( 'mytasks' ),
'href' => $href."/owner=".$this->username,
'active' => ( $href == $pageurl )
);

in order to get a "My Tasks" link for every user in their personal toolbar, which links to Special:Tasks/owner=Username. I thought some of you might like that too. Mutante 10:21, 20 May 2007 (UTC)

Oh, and you need to put something like "my tasks" into MediaWiki:mytasks, too.

[edit] Can't sign tasks

As we work on Customer-related pages, we'd like to sign & date each task with ~~~~ to keep track of WHO/WHEN a task was assigned... But we just get plain signature signs.

<tasks> [ ] Do something ~~~~(fredt34) </tasks>

will do nothing.

TIA, --FredT34 13:19, 25 September 2007 (UTC)

[edit] Don't work with MediaWiki v1.11.0

The instructions don't parse in article... --201.52.31.55 00:27, 30 September 2007 (UTC)

Should work. Made a few changes : http://www.mediawiki.org/w/index.php?title=Extension%3ATasks_Extension&diff=173913&oldid=147662
--210.212.194.165 23:10, 13 March 2008 (UTC)

[edit] Hidden Attribute not effective

The 'hidden' attribute doesn't seem to hide the tasks on the article page.

Tarlachmoorhouse 12:49, 20 December 2007 (UTC)

[edit] MW1.12 Saving page with task causes Fatal error in Parser.php

Hello, On my mediawiki 1.12, when I save a page with a tasks, I get this error : Fatal error: Using $this when not in object context in /home/.../includes/Parser.php on line 563

The page is saved. I didn't tried to modify the task to see if it is changed or not.

The line 563 in Parser.php :

$marker = "$uniq_prefix-$element-" . sprintf('%08X', $n++) . $this->mMarkerSuffix;

--Iubito 16:38, 26 March 2008 (UTC)

Bug opened : https://bugzilla.wikimedia.org/show_bug.cgi?id=13522
--Iubito 16:58, 26 March 2008 (UTC)
I get this for the PageProtectionPlus extension. I changed the class definition of the extensions' Parser to extend MW's Parser class. It didn't work, but at least the error went away.
 require_once('Parser.php');
 class XXXXxxxParser extends Parser
 {

where XXXXxxxx is the name of the Extension's parser definition. --Otheus 15:44, 10 July 2008 (UTC)

[edit] Using the extension on templates don't work correct

if you use <tasks> on a template, the link to the article is wrong (Namespace is ignored). --87.174.143.147 20:55, 3 May 2008 (UTC)

[edit] referring a deleted article crashes the special page

If you delete an article and run rebuild all, the specialpage:tasks crashes with the following error: 'Call to a member function getText() on a non-object in extensions\ToDo\SpecialTasks.php on line 100 Check against tab. page. Sorry i can't fix it, but a different sql solve the problem.

select p.* from page p, tasks t
where p.page_id=t.Page_id
.....


--87.174.143.147 20:55, 3 May 2008 (UTC)

[edit] image location / rewrite rules

hi, As my wiki uses short/nice urls, I use rewrite rules which only dont rewrite for urls starting with "/skins/". As i dont want to modifiy them I put the images in /skins/tasks/... I think this is generally a better place for system images. The images folder is only for wiki user uploaded stuff IMO. florian groovehunter 05:12, 1 July 2008 (UTC)

[edit] MW 1.12 Error

I am using MediaWiki 1.12 and after following the install instructions I am seeing the following error: 'Cannot modify header information - headers already sent by (output started at /var/www/mediawiki-1.12.0/extensions/Tasks.php:154) in /var/www/mediawiki-1.12.0/includes/WebResponse.php on line 10'. I am also using the following extensions: BreadCrumbs,ParserFunctions (Version 1.1.1), DiscussionThreading, New User Email Notification (Version 1.5.1) and NewUserMessage (Version 1.0.1, 2008-02-10). Any help would be greatly appreciated. --Timvaverchak 13:00, 22 July 2008 (UTC)

The problem is probably that you have an empty line at the end of Tasks.php ans SpecialTasks.php.
--Sébastien Grenier 16:20, 23 December 2008 (UTC)

[edit] In MW 1.13.3 some tasks not show

I have a list of 15 tasks like this:

<tasks>
[ ] 1
[ ] 2
[x] 3
[x] 4
[ ] 5
...
[ ] 14
[ ] 15
</tasks>

and I have only 12 tasks that show. Any ideas?

When I move some tasks, change the order, they appear.
I use a old version of Task.php (version 0.41.2), I've updated, but I got the Warning : cannot modify header information - headers already sent by (output started at /var/www/wiki/extensions/Tasks.php:154) in /var/www/wiki/includes/WebResponse.php on line 10
Everything is fine! I have empty line at the end of Tasks.php and SpecialTasks.php that cause the warning.
--Sébastien Grenier 16:21, 23 December 2008 (UTC)

To come back with my first problem, when someone type a NO-BREAK SPACE between [], like this [ ], Tasks extension will hide the line just like when you put a X like this [X]. Is there any way to avoid that? --Sébastien Grenier 18:07, 23 December 2008 (UTC)

[edit] Tidy + Tasks = too many paragraph tags!

I am using Tidy to to fix a different problem but not the Tasks Exctension os acting up. I get a bunch of extra paragraph tags around the task images. Anyone else have this issue? Can I get Tidy to ignore the Tasks? Can I turn off the tidy parsing inside the Tasks extension?

MW 1.11.0 Tasks 0.5.4

Thanks, Pete. --Mulciber 13:36, 19 February 2009 (UTC)

[edit] Is it possible to have the tasks show on the page you're creating them on?

The extension is working perfectly - however I would like to know if it's possible to have the tasks show up on the actual page I'm putting them on in addition to the Special:Tasks page. What I'm doing now is putting a To Do section at the bottom on multiple pages, and having to duplicate my tasks like this:

Task 1

Task 2

<tasks>

[ ]Task 1

[ ]Task 2

</tasks>

so I can see them on the regular page as well as the Special:Tasks page. Any way to avoid unnecessary duplication?

Thanks! 69.113.219.231 07:20, 1 November 2009 (UTC)