From df8efa475ee7b61a45a17641e3480c0758f67bad Mon Sep 17 00:00:00 2001 From: shish Date: Fri, 4 Apr 2008 12:07:38 +0000 Subject: [PATCH] start of requestcontext work git-svn-id: file:///home/shish/svn/shimmie2/trunk@753 7f39781d-f577-437e-ae19-be835c7a54ca --- core/event.class.php | 14 +++++++++----- core/requestcontext.class.php | 11 +++++++++++ core/util.inc.php | 4 ++-- index.php | 9 +++++++-- 4 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 core/requestcontext.class.php diff --git a/core/event.class.php b/core/event.class.php index 2715d6d5..870091e5 100644 --- a/core/event.class.php +++ b/core/event.class.php @@ -115,7 +115,10 @@ class ImageDeletionEvent extends Event { * A wake-up call for extensions */ class InitExtEvent extends Event { - public function InitExtEvent() { + var $context; + + public function InitExtEvent($context) { + $this->context = $context; } } @@ -135,13 +138,14 @@ class InitExtEvent extends Event { * Used for initial page generation triggers */ class PageRequestEvent extends Event { - var $page_name, $args, $page, $user; + var $context, $page_name, $args, $page, $user; - public function PageRequestEvent($page_name, $args, $page, $user) { + public function PageRequestEvent($context, $page_name, $args) { + $this->context = $context; $this->page_name = $page_name; $this->args = $args; - $this->page = $page; - $this->user = $user; + $this->page = $context->page; + $this->user = $context->user; } public function get_arg($n) { diff --git a/core/requestcontext.class.php b/core/requestcontext.class.php new file mode 100644 index 00000000..8d5123d7 --- /dev/null +++ b/core/requestcontext.class.php @@ -0,0 +1,11 @@ + diff --git a/core/util.inc.php b/core/util.inc.php index a84d8981..2fcc32fb 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -442,7 +442,7 @@ function _get_query_parts() { return $parts; } -function _get_page_request($page, $user) { +function _get_page_request($context) { global $config; $args = _get_query_parts(); @@ -460,7 +460,7 @@ function _get_page_request($page, $user) { $args = array_slice($args, 1); } - return new PageRequestEvent($page_name, $args, $page, $user); + return new PageRequestEvent($context, $page_name, $args); } function _get_user() { diff --git a/index.php b/index.php index 6684ba38..06c737fa 100644 --- a/index.php +++ b/index.php @@ -68,8 +68,13 @@ if($custom_themelets) { // start the page generation waterfall $page = new Page(); $user = _get_user(); -send_event(new InitExtEvent()); -send_event(_get_page_request($page, $user)); +$context = new RequestContext(); +$context->page = $page; +$context->user = $user; +$context->database = $database; +$context->config = $config; +send_event(new InitExtEvent($context)); +send_event(_get_page_request($context)); $page->display();