[pmwiki-users] FASTData change request

The Editor editor at fast.st
Wed Sep 27 09:47:17 CDT 2006


On 9/27/06, Crisses <crisses at kinhost.org> wrote:
>
> I added a wrapper to config.php that parasites off of your Data function so
> that I (theoretically) wouldn't have to hack your script.
>
>
> function Simile () {
> global $pagename, $DataKey, $ScriptUrl, $data, $MessagesFmt;
>
> // save data that will be changed
> $hold_pagename = $pagename;
> // split up data from simile on form
> $similes = explode("\n", $_POST['Simile']);
> foreach ($similes as $value) {
> if ((trim($value)) == "") continue;
> $simile = explode(" ", $value);
> $firstfour="$simile[0] $simile[1] $simile[2] $simile[3]";
> // create new page title(s)
> // Simile/BookTitle:AuthorName:FirstFourWordsOf
> $newpage = $_POST['Work'] . ":" . $_POST['Author'] . ":" . $firstfour;
> $pagename = MakePageName("Simile.HomePage", $newpage);
> // add new pages to wiki
> Data();
> }
> // reset data that changed
>
> $pagename = $hold_pagename;
> }
> $HandleActions['simile'] = 'Simile';
>
> As it stands it only adds the first page sent to it.  Everything up to the
> call to Data works just fine -- it iterates through, creates new page names,
> etc.
>
> I think I need a flag for Data() that will stop it from ending the script
> execution and return control to the wrapper script. That allows Data to be a
> usable hook for similar recipes to mine.  i.e.
>
> your definition:
> function Data() {
> ...
> }
> becomes your definition:
> function Data($flag=0) {
> ...
> // check flag & if set, stop function execution; return control to the
> calling program
> if ($flag) { break; }
>
> //this is the end of the processing, so now you can refresh the page, and
> return the user to the browser
> // this will only execute if $flag=0 or $flag is unset by the calling
> program
> // i.e. this is what you're doing now, after the page is created, but before
> you refresh the page since that makes your script stop anything else from
> running
>
> }
>
> this change won't break anything already running using the Data function,
> but will allow more wrappers to use it. :)
>
>
>
> Crisses

Wow, that's cool.  I really think the FAST Data recipe is a nice
interface for working with forms, that could be used in many ways.
I'm happy to make the change.  The line that says

if ($flag) { break; }

should be added just before the final } of the function.  Correct?  Of
course, I may call it $dataflag!  I'll add it to the next revision.

Cheers,
Caveman




More information about the pmwiki-users mailing list