gah, inconsistent naming

git-svn-id: file:///home/shish/svn/shimmie2/trunk@1021 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish 2008-09-06 17:05:21 +00:00
parent f8f7470e61
commit 4e143e9f05
2 changed files with 22 additions and 22 deletions

View File

@ -30,7 +30,7 @@ class AddImageHashBanEvent extends Event {
} }
} }
// }}} // }}}
class Image_Hash_Ban implements Extension { class ImageBan implements Extension {
var $theme; var $theme;
public function receive_event(Event $event) { public function receive_event(Event $event) {
@ -140,5 +140,5 @@ class Image_Hash_Ban implements Extension {
} }
} }
add_event_listener(new Image_Hash_Ban(), 30); // in before resolution limit plugin add_event_listener(new ImageBan(), 30); // in before resolution limit plugin
?> ?>

View File

@ -118,37 +118,32 @@ class InitExtEvent extends Event {}
/* /*
* PageRequestEvent: * PageRequestEvent:
* $page_name -- the main name of the page, eg "post"
* $args -- the arguments, eg "list"
* $page -- a page object to add things to
* $user -- the user requesting the page
* get_arg(int)
* count_args()
* *
* User requests /view/42 -> an event is generated with * TODO: up to date docs
* $page_name="view" and $args=array("42");
* *
* Used for initial page generation triggers * Used for initial page generation triggers
*/ */
class PageRequestEvent extends Event { class PageRequestEvent extends Event {
var $context, $page_name, $args, $page, $user; var $args;
var $arg_count;
public function PageRequestEvent($context, $page_name, $args) { var $part_count;
$this->context = $context;
$this->page_name = $page_name; public function __construct(RequestContext $context, $args) {
parent::__construct($context);
$this->args = $args; $this->args = $args;
$this->page = $context->page; $this->arg_count = count($args);
$this->user = $context->user;
} }
public function page_matches($name) { public function page_matches($name) {
$parts = explode("/", $name); $parts = explode("/", $name);
$this->part_count = count($parts);
if(count($parts) > count($this->args)) { if($this->part_count > $this->arg_count) {
return false; return false;
} }
for($i=0; $i<count($parts); $i++) { for($i=0; $i<$this->part_count; $i++) {
if($parts[$i] != $this->args[$i]) { if($parts[$i] != $this->args[$i]) {
return false; return false;
} }
@ -157,13 +152,18 @@ class PageRequestEvent extends Event {
return true; return true;
} }
public function get_arg($n) { public function get_arg($n) {
return isset($this->args[$n]) ? $this->args[$n] : null; $offset = $this->part_count + $n;
if($offset >= 0 && $offset < $this->arg_count) {
return $this->args[$offset];
}
else {
return null;
}
} }
public function count_args() { public function count_args() {
return isset($this->args) ? count($this->args) : 0; return $this->arg_count;
} }
} }