start of requestcontext work
git-svn-id: file:///home/shish/svn/shimmie2/trunk@753 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
c88ec5fe54
commit
df8efa475e
4 changed files with 29 additions and 9 deletions
|
@ -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) {
|
||||
|
|
11
core/requestcontext.class.php
Normal file
11
core/requestcontext.class.php
Normal 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;
|
||||
}
|
||||
?>
|
|
@ -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() {
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
||||
|
|
Reference in a new issue