[pmwiki-devel] New adddeleteline2 redirect-args feature (not the same as previous email)

Martin Fick mogulguy at yahoo.com
Mon Jan 1 01:22:38 CST 2007


Nils,

Along with the patch in the previous email, I have
gone one step further and added another small feature:
the ability to pass arguments to the page which
receives the redirect.  This probably seems a little
strange (that's why I didn't include it in the
previous email,) but it makes the previous patch even
more useful.  This patch can be used to redirect to a
'confirmation page' which can show you the details of
what you just pasted.  You can see an example of this
here:

http://www.theficks.name/test/adddeleteline/pmwiki.php?n=RedirectArgs.Form

But, what makes this particularly nice is the ability
to make a generic page that can follow any trail and
add any text to each page on the trail.  Both the
trail and the text can be selected by a form!  You can
see this demonstrated here:

http://www.theficks.name/test/adddeleteline/pmwiki.php?n=RedirectArgs.TrailForm

Again, the patch is inline.  This patch is to be
applied after the redirect patch from the previous
email.

Thanks,

-Martin




*** adddeleteline2.redirect.php Sun Dec 31 19:59:55
2006
--- adddeleteline2.redirect-args.php    Sun Dec 31
23:53:48 2006
***************
*** 1,6 ****
  <?php

! $AdlVersion = '2.0.2+redirect, 12.31.2006';

  /*
     Adds markup to add lines using a form and delete
lines from a wiki page.
--- 1,6 ----
  <?php

! $AdlVersion = '2.0.2+redirect-args, 12.31.2006';

  /*
     Adds markup to add lines using a form and delete
lines from a wiki page.
***************
*** 34,47 ****

     New Features in this version:

!    This version adds a redirect feature which allows
a page to return to
!    the original form page immedeately after adding
text to a page.  To use
!    this feature, simply include a (potentially
hidden) parameter in your
!    form named: 'redirect_to' and set its value to
the page you want to
!    return to after adding text (probably
{$FullName}.)
!
!    After being redirected, the page variable
{$?redirect_from} will be set
!    to the page to which you have just added text to.
   */


--- 34,47 ----

     New Features in this version:

!    In addition to all the features of the redirect
patch, this
!    version adds support for redirect arguments. 
This is an array
!    of arguments, redirect_arg[], which will be added
to the query
!    string when redirecting after adding lines to a
page.  Simply
!    define these as parameters in your form somewhere
and they will
!    be available as page variables,
{$?redirect_arg[key]}, to
!    whatever page you define as the redirect page
with the
!    'redirect_to' parameter.
   */


***************
*** 78,83 ****
--- 78,85 ----

 
Markup('redirect_from','begin','/{\\$\\?redirect_from}/e',
         "''.\$_GET['redirect_from']");
+
Markup('redirect_arg[]','begin','/{\\$\\?redirect_arg\\[(.*?)\\]}/e',
+        "''.\$_GET['redirect_arg'][PSS('$1')]");

  SDV($HTMLStylesFmt['adddeleteline2'],'
  .adldeletebutton {
***************
*** 183,188 ****
--- 185,193 ----
      SDV($RedirectDelay,0);
      $url = FmtPageName('$PageUrl', $to);
      $args = "?redirect_from=". $_REQUEST['n'];
+     $rargs= $_REQUEST['redirect_arg'];
+     foreach((array)$rargs as $rarg => $v)
+         $args .= "&redirect_arg[$rarg]=$v";
      header("Location: $url$args");
      echo "<html><head>
           <meta http-equiv='Refresh'
Content='$RedirectDelay; URL=$url$args' />
***************
*** 205,210 ****
--- 210,216 ----
      $addstring =
preg_replace('/\\\\n/',"\n",$addstring);  # replace \n
by newlines
      $addstring =
preg_replace('/\{date\:(.*?)\}/e',"date(PSS('$1'))",$addstring);
 # replace {date:fmt}
      $addstring =
preg_replace('/\{strftime\:(.*?)\}/e',"strftime(PSS('$1'))",$addstring);
 # replace {strftime:fmt}
+     $addstring =
preg_replace('/\{(.*?)\[(.*?)\]\}/e',"stripmagic(\$_POST[PSS('$1')][PSS('$2')])",$addstring);
 # replace {name[key]} fields
      $addstring =
preg_replace('/\{(.*?)\}/e',"stripmagic(\$_POST[PSS('$1')])",$addstring);
 # replace {name} fields
      $linekey = md5(microtime().$addstring);
      $addstring = str_replace('(:adl delete:)',"(:adl
delete $linekey $pagename:)",$addstring);  # Add
linekey to delete statements




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the pmwiki-devel mailing list