diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2008-12-01 22:47:36 -0500 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2008-12-01 22:47:36 -0500 |
commit | d268703d693c8f785e0f1e80a2480230c9327703 (patch) | |
tree | 7799d11e0b76638353d306467d05f9ace38e9da7 | |
parent | d55318eaed51af23b59fc60de58b55070c48d0b9 (diff) |
add init, last_modified to actions
darcs-hash:20081202034736-5ed1f-e096ab5e9a77d2bb74c949659966d400cbc9a149.gz
-rw-r--r-- | index.php | 1 | ||||
-rw-r--r-- | lib/action.php | 36 |
2 files changed, 35 insertions, 2 deletions
@@ -52,6 +52,7 @@ if (file_exists($actionfile)) { } $config['db']['database'] = $mirror; } + call_user_func(array($action_obj, 'init'), $_REQUEST); call_user_func(array($action_obj, 'handle'), $_REQUEST); } else { common_user_error(_('Unknown action')); diff --git a/lib/action.php b/lib/action.php index c0229cf75..ba4fc71fb 100644 --- a/lib/action.php +++ b/lib/action.php @@ -26,6 +26,19 @@ class Action { // lawsuit function Action() { } + # For initializing members of the class + + function init($argarray) { + $this->args =& common_copy_args($argarray); + } + + # For comparison with If-Last-Modified + # If not applicable, return NULL + + function last_modified() { + return NULL; + } + function is_readonly() { return false; } @@ -43,8 +56,27 @@ class Action { // lawsuit return (is_string($arg)) ? trim($arg) : $arg; } - function handle($argarray) { - $this->args =& common_copy_args($argarray); + # Note: argarray ignored, since it's now passed in in init() + + function handle($argarray=NULL) { + + $lm = $this->last_modified(); + + if ($lm) { + header('Last-Modified: ' . date(DATE_RFC822, $dt)); + $if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE']; + if ($if_modified_since) { + $ims = strtotime($if_modified_since); + if ($lm <= $ims) { + $if_none_match = $_SERVER['HTTP_IF_NONE_MATCH']; + if ($if_none_match) { + header('304 Not Modified'); + # Better way to do this? + exit(0); + } + } + } + } } function boolean($key, $def=false) { |