From 4e143e9f050d5754c865621d4ec6268ceaf77fb3 Mon Sep 17 00:00:00 2001 From: shish Date: Sat, 6 Sep 2008 17:05:21 +0000 Subject: [PATCH] gah, inconsistent naming git-svn-id: file:///home/shish/svn/shimmie2/trunk@1021 7f39781d-f577-437e-ae19-be835c7a54ca --- contrib/image_hash_ban/main.php | 4 ++-- core/event.class.php | 40 ++++++++++++++++----------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/contrib/image_hash_ban/main.php b/contrib/image_hash_ban/main.php index 69494af5..854ecbff 100644 --- a/contrib/image_hash_ban/main.php +++ b/contrib/image_hash_ban/main.php @@ -30,7 +30,7 @@ class AddImageHashBanEvent extends Event { } } // }}} -class Image_Hash_Ban implements Extension { +class ImageBan implements Extension { var $theme; 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 ?> diff --git a/core/event.class.php b/core/event.class.php index 9cb021d2..75071d14 100644 --- a/core/event.class.php +++ b/core/event.class.php @@ -118,37 +118,32 @@ class InitExtEvent extends Event {} /* * 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 - * $page_name="view" and $args=array("42"); + * TODO: up to date docs * * Used for initial page generation triggers */ class PageRequestEvent extends Event { - var $context, $page_name, $args, $page, $user; + var $args; + var $arg_count; - public function PageRequestEvent($context, $page_name, $args) { - $this->context = $context; - $this->page_name = $page_name; + var $part_count; + + public function __construct(RequestContext $context, $args) { + parent::__construct($context); $this->args = $args; - $this->page = $context->page; - $this->user = $context->user; + $this->arg_count = count($args); } public function page_matches($name) { $parts = explode("/", $name); - - if(count($parts) > count($this->args)) { + $this->part_count = count($parts); + + if($this->part_count > $this->arg_count) { return false; } - for($i=0; $ipart_count; $i++) { if($parts[$i] != $this->args[$i]) { return false; } @@ -157,13 +152,18 @@ class PageRequestEvent extends Event { return true; } - 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() { - return isset($this->args) ? count($this->args) : 0; + return $this->arg_count; } }