[pmwiki-devel] RFC: Configurable redirect in PmForm

DaveG pmwiki at solidgone.com
Fri Apr 2 21:46:47 CDT 2010



On 4/2/2010 4:47 AM, Petko Yotov wrote:
> On Thursday 01 April 2010 05:13:10, DaveG wrote :
>> In PmForm HandlePmForm(), a Redirect() is performed at the end of
>> processing. This prohibits additional cookbook processing after PmForm.
>> Specifically it means that any Ajax oriented PmForm requests are not
>> possible.
>
> A while ago I tinkered with an Ajax webapp and I used this line :
>
>    if(@$_GET['ajax']>'') $EnableRedirect = 0;
>
> The JavaScript sends the PmForm with an additional parameter "&ajax=1". This
> blocks the redirects and sends a HTML page and the JavaScript program can
> parse it and decide what to do.
Also a reasonable solution, except Redirect performs an output which 
interferes with ajax handling (but doesn't prohibit it):
   echo "<a href='$pageurl'>Redirect to $pageurl</a>";

and then does an "exit;" which prohibits post-PmForm processing.

I suspect changing that behavior will have impacts beyond the initial 
proposal.


>> My proposal is below, although I'm open to any change that allows
>> re-directing to a cookbook defined function.
>
> Alternatively, you can write/clone your own MyHandlePmForm() without the
> redirect, and use $HandleActions['pmform'] = 'MyHandlePmForm';
True, but then I'm replicating PmForm, which is a little 'smelly'.


>> Change to PmForm, last line in HandlePmForm() from:
>>     Redirect($pagename, '{$PageUrl}?pmform=success');
>>
>> To:
>>     $PmFormRedirect('success');
>>
>>
>> And the addition of a function:
>>     function PmFormRedirect($msg){
>>     global $pagename;
>>       Redirect($pagename, '{$PageUrl}?pmform='.$msg);
>>     }
>>
>> And at the start of PmForm, the initialization of the new variable:
>>      SDV($PmFormRedirect,'PmFormRedirect');
>
> It might be more something like this :
>    SDV($PmFormRedirectFunction,'Redirect');
>    $PmFormRedirectFunction($pagename, '{$PageUrl}?pmform=success');
Agreed.


  ~ ~ Dave



More information about the pmwiki-devel mailing list