start of requestcontext work

git-svn-id: file:///home/shish/svn/shimmie2/trunk@753 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish 2008-04-04 12:07:38 +00:00
parent c88ec5fe54
commit df8efa475e
4 changed files with 29 additions and 9 deletions

View file

@ -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) {

View file

@ -0,0 +1,11 @@
<?php
/*
* The context for a request, should be used instead of global variables
*/
class RequestContext {
var $database;
var $config;
var $user;
var $page;
}
?>

View file

@ -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() {

View file

@ -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();