Commit af4f6e7e771ddaccc9f8a51d19394088db47fdf5
1 parent
fa5cfc3b
Allow arbitrary query strings (string or dictionary) for redirects.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3487 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
21 additions
and
6 deletions
lib/dispatcher.inc.php
| @@ -16,22 +16,37 @@ class KTDispatcher { | @@ -16,22 +16,37 @@ class KTDispatcher { | ||
| 16 | $this->handleOutput($ret); | 16 | $this->handleOutput($ret); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | - function errorRedirectTo($event, $error_message) { | 19 | + function errorRedirectTo($event, $error_message, $sQuery = "") { |
| 20 | /* $method = 'do_main'; | 20 | /* $method = 'do_main'; |
| 21 | if (method_exists($this, 'do_' . $event)) { | 21 | if (method_exists($this, 'do_' . $event)) { |
| 22 | $method = 'do_' . $event; | 22 | $method = 'do_' . $event; |
| 23 | }*/ | 23 | }*/ |
| 24 | $_SESSION['KTErrorMessage'][] = $error_message; | 24 | $_SESSION['KTErrorMessage'][] = $error_message; |
| 25 | - exit(redirect($_SERVER["PHP_SELF"] . '?action=' . $event)); | 25 | + //exit(redirect($_SERVER["PHP_SELF"] . '?action=' . $event)); |
| 26 | + exit($this->redirectTo($event, $sQuery)); | ||
| 26 | //return $this->$method(); | 27 | //return $this->$method(); |
| 27 | } | 28 | } |
| 28 | 29 | ||
| 29 | - function redirectTo($event, $sQuery) { | ||
| 30 | - exit(redirect($_SERVER["PHP_SELF"] . '?action=' . $event . "&" . $sQuery)); | 30 | + function redirectTo($event, $sQuery = "") { |
| 31 | + if (is_array($sQuery)) { | ||
| 32 | + $sQuery['action'] = $event; | ||
| 33 | + $aQueryStrings = array(); | ||
| 34 | + foreach ($sQuery as $k => $v) { | ||
| 35 | + $aQueryStrings[] = urlencode($k) . "=" . urlencode($v); | ||
| 36 | + } | ||
| 37 | + $sQuery = "?" . join('&', $aQueryStrings); | ||
| 38 | + } else { | ||
| 39 | + if (!empty($sQuery)) { | ||
| 40 | + $sQuery = '?action=' . $event . '&' . $sQuery; | ||
| 41 | + } else { | ||
| 42 | + $sQuery = '?action=' . $event; | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | + exit(redirect($_SERVER["PHP_SELF"] . $sQuery)); | ||
| 31 | } | 46 | } |
| 32 | 47 | ||
| 33 | - function errorRedirectToMain($error_message) { | ||
| 34 | - return $this->errorRedirectTo('main', $error_message); | 48 | + function errorRedirectToMain($error_message, $sQuery = "") { |
| 49 | + return $this->errorRedirectTo('main', $error_message, $sQuery); | ||
| 35 | } | 50 | } |
| 36 | 51 | ||
| 37 | function handleOutput($sOutput) { | 52 | function handleOutput($sOutput) { |