Difference between revisions of "Issue:Includematch parameter regexp issue"
(New page: {{Issue |Type = Bug |Extension = DPL |Version = 1.4.7 |Description = includematch parameter does not work with complex regexp |Status = open }} == Problem == I have...) |
|||
(8 intermediate revisions by 2 users not shown) | |||
Line 4: | Line 4: | ||
|Version = 1.4.7 | |Version = 1.4.7 | ||
|Description = includematch parameter does not work with complex regexp | |Description = includematch parameter does not work with complex regexp | ||
− | |Status = | + | |Status = closed |
}} | }} | ||
Line 66: | Line 66: | ||
== Reply == | == Reply == | ||
+ | The <tt>includematch</tt> parameter uses the comma as a separator. Each comma delimited token is matched against its corresponding parameter from the <tt>include</tt> statement. The first comma in your argument is taken as a separator and then DPL complains about a missing trailing "/" in "/project\s*=\s*([^" which is quite reasonable, isn´t it? | ||
+ | |||
+ | You can use '\x2c' within a php regexp for a comma (as 2c is the ASCII hex code of a comma). Rewrite your expression using \x2c for each comma. | ||
+ | |||
+ | [[User:Gero|Gero]] 18:32, 12 October 2007 (CEST) | ||
+ | |||
+ | :: Thank you! That was exactly the problem. In case you were not aware yet, I wanted to point out that I am using the DPL extension in my [http://www.mediawiki.org/wiki/Extension:Todo_Tasks Todo Tasks] MW extension. Feel free to take a look at that and forward any comments you may have about it. --[[User:Gri6507|Gri6507]] 22:15, 12 October 2007 (CEST) | ||
+ | |||
+ | :::Always glad to help ;-). Maybe you want to add that link (with a short description) to the newly opened [[DPL:Gallery|Gallery of Best Practice]]? Is there a public '''demonstration site''' for your extension? If not I could offer to install it here and you could install demo samples. This would also make sure that the latest versions of Todo_Tasks and DPL always work together ... | ||
+ | |||
+ | :::[[User:Gero|Gero]] 08:55, 13 October 2007 (CEST) | ||
+ | |||
+ | :::: As my MW extension implies, it is geared towards the corporate world. I am aware of a couple of companies using the extension, but all run their wikis behind a firewall, making them inaccessible from the outside world. I would be very happy if I could use this site as a demo for the extension! If you have the time and desire, please install [http://www.mediawiki.org/wiki/Extension:Todo_Tasks Todo Tasks] here. Hopefully the instructions are clear, but if you have any questions, please let me know. Then, I could create a few sample tasks for demonstration purposes. --[[User:Gri6507|Gri6507]] 16:14, 13 October 2007 (CEST) |
Latest revision as of 17:49, 24 November 2007
Description: | includematch parameter does not work with complex regexp |
Extension / Version: | DPL / 1.4.7 |
Type / Status: | Bug / closed |
Problem
I have the following templates: Template:Todo with the following code
Do task for project {{{project}}}
where the project= option is a comma separated list of projects to which this particular TODO is associated with (see below for valid variations of project option). I also have the following template Template:Todo.dpl with the following code
<includeonly> * {{{1}}} </includeonly>
I want to write a DPL query to display only the tasks assigned to a particular project (let's call it myproj).
I tried doing the following
<dpl> uses=Template:Todo include={Todo}.dpl includematch=/project\s*=\s*([^,]*,)*\s*myproj\s*(,[^,]*\s*)*$/i </dpl>
However, when I view a page with this DPL code, I get a LOT of error messages similar to Warning: preg_match() [function.preg-match]: No ending delimiter '/' found in /export/www/html/npdwiki/extensions/DynamicPageList/DynamicPageList2Include.php on line 429 and the results are not correct: the query does not display any matches.
The following PHP code demonstrates the application of this template to match against several valid and invalid options for project= parameter.
<?php $test = array(); array_push($test, "project=myproj"); array_push($test, "project = myproj"); array_push($test, "project = blah, myproj"); array_push($test, "project=blah , myproj"); array_push($test, "project = blah blah blah , myproj "); array_push($test, "project = myproj, blah blah"); array_push($test, "project = blah , myproj , blah"); array_push($test, "project = myproj two"); array_push($test, "project = blah, myproj two, blha"); array_push($test, "project = myproj ,myproj two"); array_push($test, "project = myproj two , myproj"); foreach ($test as $t) { print "testing '$t' ==> "; if (preg_match('/project\s*=\s*([^,]*,)*\s*myproj\s*(,[^,]*\s*)*$/i', $t)) print "match \n"; else print "NOT matching\n"; } ?>
- --Gri6507 16:05, 12 October 2007 (CEST)
Reply
The includematch parameter uses the comma as a separator. Each comma delimited token is matched against its corresponding parameter from the include statement. The first comma in your argument is taken as a separator and then DPL complains about a missing trailing "/" in "/project\s*=\s*([^" which is quite reasonable, isn´t it?
You can use '\x2c' within a php regexp for a comma (as 2c is the ASCII hex code of a comma). Rewrite your expression using \x2c for each comma.
Gero 18:32, 12 October 2007 (CEST)
- Thank you! That was exactly the problem. In case you were not aware yet, I wanted to point out that I am using the DPL extension in my Todo Tasks MW extension. Feel free to take a look at that and forward any comments you may have about it. --Gri6507 22:15, 12 October 2007 (CEST)
- Always glad to help ;-). Maybe you want to add that link (with a short description) to the newly opened Gallery of Best Practice? Is there a public demonstration site for your extension? If not I could offer to install it here and you could install demo samples. This would also make sure that the latest versions of Todo_Tasks and DPL always work together ...
- Gero 08:55, 13 October 2007 (CEST)
- As my MW extension implies, it is geared towards the corporate world. I am aware of a couple of companies using the extension, but all run their wikis behind a firewall, making them inaccessible from the outside world. I would be very happy if I could use this site as a demo for the extension! If you have the time and desire, please install Todo Tasks here. Hopefully the instructions are clear, but if you have any questions, please let me know. Then, I could create a few sample tasks for demonstration purposes. --Gri6507 16:14, 13 October 2007 (CEST)