[Pmwiki-users] IncludeAble hack needs help
Patrick R. Michaud
pmichaud at pobox.com
Sat Jun 14 10:02:28 CDT 2003
On Sat, Jun 14, 2003 at 08:49:18AM +0200, Joris wrote:
> I need some help with what happens after you hit the 'save' button, the
> wiki isn't displayed then. Also, I meight have done some stupid things.
> I invite everyone to take a look...
> The paragraph "After editing" describes the biggest problem in detail.
I modified the page itself, but just to reiterate it here--
Making the save (actually 'post') feature of pmwiki.php work when it's
embedded in another page is going to be really difficult to do. The
way pmwiki.php's post function works now is that it saves the file
to disk, then sends a Location: header to the browser to tell the
browser to load the updated page via a normal HTTP GET (instead of the HTTP
POST operation that the browser just did).
In theory pmwiki.php could just output the updated page contents at that
point, but this causes all sorts of problems with browser and ISP caches,
because hitting reload in the browser now causes the page to be re-posted
to the server, the page's URL is associated with the cached version of
the post, etc. So, it's better to just send the browser back a Location:
header that redirects it to the uploaded page, without actually sending
the page contents.
Unfortunately, this no longer works if pmwiki.php is embedded in another
php script, because if the other script has already output HTTP and
HTML headers, pmwiki.php has no way to tell the browser to reload the
page. So, you get the "headers already output" warning, or if you
comment out the Location: header, you get nothing.
The best solution I can come up with is to develop a "wrapper" script
that can be called when pmwiki.php is to be embedded in another
page. A user would do something like:
<?php include("embed-pmwiki.php"); ?>
at the very beginning of the embedding page. embed-pmwiki.php would
1. fix variable and path locations
2. include pmwiki.php
3. immediately handle various post requests (before the embedding
page can do any output)
4. defer all other actions (browse, diff, search) until later.
Then later in the embedding page when the user wants the wiki output,
they simply do something like <?php PmWiki(); ?> which will execute the
action that was deferred at the beginning of the embedding page.
More information about the pmwiki-users