01122: {[foxdelrange button]} and {[foxdelline button]} does not work

Summary: {[foxdelrange button]} and {[foxdelline button]} does not work
Created: 2009-07-22 16:12
Status: Open
Category: Cookbook
Assigned:
Priority: 3
Version: 2.2.2
OS: Linux/Apache/5.2

Description: Using the following template with Fox, the generated PmWiki markup is not correct

#foxbegin#
{[foxdelrange button]}
Some text...
#foxend#

There are two problems:

 - str_replace() is called two times on the same string
 - Markup() regexp does not recognize the " button" argument to "foxdelrange"

The same is true for "foxdelline".

The following patch fixes it:

diff --git a/cookbook/fox/fox.php b/cookbook/fox/fox.php
index 06ff05d..2566760 100644
--- a/cookbook/fox/fox.php
+++ b/cookbook/fox/fox.php
@@ -1121,14 +1121,7 @@ function FoxTemplateEngine( $pn, $template, $fx, $targ, $linekeyseed=NULL, $call
                if (preg_match("/\\{\\[foxdel([^]]+)FullName\\}\\s*\\]\\}/", $entry)) continue;
                $linekey = $linekeyseed.'b'.$index;
                //adding linekey + pagename to any foxdelete markup for unique id
-               // Add linekey to delete button for line delete
-               $entry = str_replace( '{[foxdelline button', "{[foxdelline button $linekey {\$FullName} ", $entry );
-               // Add linekey to delete link for line delete
-               $entry = str_replace( '{[foxdelline', "{[foxdelline $linekey {\$FullName} ", $entry  );
-               // Add linekey to delete button for range delete
-               $entry = str_replace( '{[foxdelrange button', "{[foxdelrange button $linekey {\$FullName} ", $entry );
-               // Add linekey to delete link for range delete
-               $entry = str_replace( '{[foxdelrange', "{[foxdelrange $linekey {\$FullName} ", $entry );
+               $entry = ereg_replace( '\{\[foxdel(line|range)( button)?', "\\0 $linekey {\$FullName} ", $entry );
                //Add line-key to delete range begin marker
                $entry = str_replace( '#foxbegin#', "#foxbegin $linekey#", $entry );
                // Add line-key to delete range end marker
@@ -1794,4 +1787,4 @@ function InputDefault2($pagename, $type, $args) {
        return '';
 } //}}}

-///EOF
\ No newline at end of file
+///EOF
diff --git a/cookbook/fox/foxdelete.php b/cookbook/fox/foxdelete.php
index 68ba6be..5c51b5d 100644
--- a/cookbook/fox/foxdelete.php
+++ b/cookbook/fox/foxdelete.php
@@ -49,11 +49,11 @@ function FoxHandleDelete($pagename) {
 } //}}}


-Markup('foxdelete','directives','/\{\[foxdel(line|range) ?(|button)\\s*(.*?)\\s*\]}/e',
-               "Keep(FoxDeleteMarkup(\$pagename, '$1', '$2', PSS('$3') ))");
+Markup('foxdelete','directives','/\{\[foxdel(?:line|range) (button)?\s*(.+)\s*\]\}/e',
+               "Keep(FoxDeleteMarkup(\$pagename, '$1', PSS('$2') ))");
 # Creates the HTML code for delete links {[foxdelline]}, {[foxdelrange]}
 # and delete buttons {[foxdelline button]} and {[foxdelrange button]}
-function FoxDeleteMarkup($pagename, $range, $type, $args) {    
+function FoxDeleteMarkup($pagename, $type, $args) {    
        global $ScriptUrl, $EnablePathInfo, $EnableFoxDeleteMsg, $FoxDeleteMsg, $FoxDeleteSummaryMsg;
        SDV($EnableFoxDeleteMsg, false); //set to true to enable post delete confirmation
        SDV($FoxDeleteMsg, '$[Please confirm: Do you want to delete this post?]');