news, upload, comment, and tag_list now respond to PostListBuildingEvents rather than PageRequestEvent(index)
git-svn-id: file:///home/shish/svn/shimmie2/trunk@318 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
91f1ae986a
commit
73c437758a
@ -91,7 +91,8 @@ class CommentList extends Extension {
|
||||
$this->build_page($event->get_arg(1));
|
||||
}
|
||||
}
|
||||
if(is_a($event, 'PageRequestEvent') && ($event->page_name == "index")) {
|
||||
|
||||
if(is_a($event, 'PostListBuildingEvent')) {
|
||||
global $config;
|
||||
if($config->get_int("comment_count") > 0) {
|
||||
$event->page->add_block(new Block("Comments", $this->build_recent_comments(), "left"));
|
||||
|
@ -1,5 +1,15 @@
|
||||
<?php
|
||||
|
||||
class PostListBuildingEvent extends Event {
|
||||
var $page = null;
|
||||
var $search_terms = null;
|
||||
|
||||
public function PostListBuildingEvent($page, $search) {
|
||||
$this->page = $page;
|
||||
$this->search_terms = $search;
|
||||
}
|
||||
}
|
||||
|
||||
class Index extends Extension {
|
||||
var $theme;
|
||||
|
||||
@ -40,6 +50,8 @@ class Index extends Extension {
|
||||
$total_pages = $database->count_pages($search_terms);
|
||||
$count = $config->get_int('index_width') * $config->get_int('index_height');
|
||||
$images = $database->get_images(($page_number-1)*$count, $count, $search_terms);
|
||||
|
||||
send_event(new PostListBuildingEvent($event->page, $search_terms));
|
||||
|
||||
$this->theme->set_page($page_number, $total_pages, $search_terms);
|
||||
$this->theme->display_page($event->page, $images);
|
||||
|
@ -6,12 +6,13 @@ class News extends Extension {
|
||||
public function receive_event($event) {
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object("news", "NewsTheme");
|
||||
|
||||
if(is_a($event, 'PageRequestEvent') && ($event->page_name == "index")) {
|
||||
if(is_a($event, 'PostListBuildingEvent')) {
|
||||
global $config;
|
||||
if(strlen($config->get_string("news_text")) > 0) {
|
||||
$this->theme->display_news($event->page, $config->get_string("news_text"));
|
||||
}
|
||||
}
|
||||
|
||||
if(is_a($event, 'SetupBuildingEvent')) {
|
||||
$sb = new SetupBlock("News");
|
||||
$sb->add_longtext_option("news_text");
|
||||
|
@ -35,15 +35,15 @@ class TagList extends Extension {
|
||||
}
|
||||
$this->theme->display_page($page);
|
||||
}
|
||||
if(is_a($event, 'PageRequestEvent') && ($event->page_name == "index")) {
|
||||
|
||||
if(is_a($event, 'PostListBuildingEvent')) {
|
||||
global $config;
|
||||
global $page;
|
||||
if($config->get_int('tag_list_length') > 0) {
|
||||
if(isset($_GET['search'])) {
|
||||
$this->add_refine_block($page, tag_explode($_GET['search']));
|
||||
if(!is_null($event->search_terms)) {
|
||||
$this->add_refine_block($event->page, $event->search_terms);
|
||||
}
|
||||
else {
|
||||
$this->add_popular_block($page);
|
||||
$this->add_popular_block($event->page);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,11 +13,12 @@ class Upload extends Extension {
|
||||
$config->set_default_bool('upload_anon', false);
|
||||
}
|
||||
|
||||
if(is_a($event, 'PageRequestEvent') && ($event->page_name == "index")) {
|
||||
if(is_a($event, 'PostListBuildingEvent')) {
|
||||
if($this->can_upload()) {
|
||||
$this->theme->display_block($event->page);
|
||||
}
|
||||
}
|
||||
|
||||
if(is_a($event, 'PageRequestEvent') && ($event->page_name == "upload")) {
|
||||
if($this->can_upload()) {
|
||||
global $page;
|
||||
|
Loading…
x
Reference in New Issue
Block a user