summaryrefslogtreecommitdiff
path: root/inc/actions.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2008-08-23 19:45:50 +0200
committerAndreas Gohr <andi@splitbrain.org>2008-08-23 19:45:50 +0200
commit69cd1e27fb44ad44b1d5222f3b7edafb95b59d65 (patch)
treec34f3ec21897cc6c5d52c6a70d9b99e23875b03a /inc/actions.php
parent1c548ebe50f04aa54d37336f12509de0e8c481ac (diff)
downloadrpg-69cd1e27fb44ad44b1d5222f3b7edafb95b59d65.tar.gz
rpg-69cd1e27fb44ad44b1d5222f3b7edafb95b59d65.tar.bz2
redirect on show/POST
Now a redirect is always done when the final action is show, but the reqeuest method is POST. This handles actions like cncel autmatically and ensures nice URLs are reinstated. A new event ACTION_SHOW_REDIRECT wraps the redirect. darcs-hash:20080823174550-7ad00-4969a9467b5bca12412507fd6b177088a1c5363f.gz
Diffstat (limited to 'inc/actions.php')
-rw-r--r--inc/actions.php28
1 files changed, 25 insertions, 3 deletions
diff --git a/inc/actions.php b/inc/actions.php
index 45c067657..529a031b3 100644
--- a/inc/actions.php
+++ b/inc/actions.php
@@ -25,6 +25,8 @@ function act_dispatch(){
global $lang;
global $conf;
+ $preact = $ACT;
+
// give plugins an opportunity to process the action
$evt = new Doku_Event('ACTION_ACT_PREPROCESS',$ACT);
if ($evt->advise_before()) {
@@ -127,6 +129,10 @@ function act_dispatch(){
$evt->advise_after();
unset($evt);
+ // when action 'show' and POST, do a redirect
+ if($ACT == 'show' && strtolower($_SERVER['REQUEST_METHOD']) == 'post'){
+ act_redirect($ID,$preact);
+ }
//call template FIXME: all needed vars available?
$headers[] = 'Content-Type: text/html; charset=utf-8';
@@ -300,9 +306,15 @@ function act_save($act){
//delete draft
act_draftdel($act);
+ session_write_close();
+ // when done, show page
+ return 'show';
+}
- $go = wl($ID,'',true);
+function act_redirect($id,$preact){
+ global $PRE;
+ global $TEXT;
//get section name when coming from section edit
if($PRE && preg_match('/^\s*==+([^=\n]+)/',$TEXT,$match)){
@@ -311,11 +323,21 @@ function act_save($act){
$title = str_replace(':','',cleanID($title));
$title = ltrim($title,'0123456789._-');
if(empty($title)) $title='section';
- $go .= '#'.$title;
}
+ $opts = array(
+ 'id' => $id,
+ 'fragment' => $title,
+ 'preact' => $preact
+ );
+ trigger_event('ACTION_SHOW_REDIRECT',$opts,'act_redirect_execute');
+}
+
+function act_redirect_execute($opts){
+ $go = wl($opts['id'],'',true);
+ if($opts['fragment']) $go .= '#'.$opts['fragment'];
+
//show it
- session_write_close();
header("Location: $go");
exit();
}