From 797e644c1f2fbda7222e5f503d5d628b2554b6f3 Mon Sep 17 00:00:00 2001 From: shish Date: Mon, 21 Jul 2008 15:16:48 +0000 Subject: [PATCH] actually, this works better as a block of it's own... git-svn-id: file:///home/shish/svn/shimmie2/trunk@916 7f39781d-f577-437e-ae19-be835c7a54ca --- contrib/numeric_score/main.php | 19 ++++++++++++++++--- contrib/numeric_score/theme.php | 21 +++++++++++++-------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/contrib/numeric_score/main.php b/contrib/numeric_score/main.php index 32291f39..896472a9 100644 --- a/contrib/numeric_score/main.php +++ b/contrib/numeric_score/main.php @@ -29,11 +29,24 @@ class NumericScore extends Extension { } } - if(is_a($event, 'ImageInfoBoxBuildingEvent')) { + if(is_a($event, 'DisplayingImageEvent')) { global $user; - global $config; if(!$user->is_anonymous()) { - $event->add_part($this->theme->get_voter_html($event->image)); + $html = $this->theme->get_voter_html($event->image); + $event->page->add_block(new Block("Image Score", $html, "left", 20)); + } + } + + if(is_a($event, 'PageRequestEvent') && ($event->page_name == "numeric_score_vote")) { + if(!$event->user->is_anonymous()) { + $image_id = int_escape($_POST['image_id']); + $char = $_POST['vote']; + $score = 0; + if($char == "up") $score = 1; + else if($char == "down") $score = -1; + if($score != 0) send_event(new NumericScoreSetEvent($image_id, $event->user, $score)); + $event->page->set_mode("redirect"); + $event->page->set_redirect(make_link("post/view/$image_id")); } } diff --git a/contrib/numeric_score/theme.php b/contrib/numeric_score/theme.php index 3a621a33..07d9645e 100644 --- a/contrib/numeric_score/theme.php +++ b/contrib/numeric_score/theme.php @@ -6,14 +6,19 @@ class NumericScoreTheme extends Themelet { $i_score = int_escape($image->numeric_score); $html = " - - Score ($i_score) - - - - - - + Current Score: $i_score + +

+ + + +
+ +

+ + + +
"; return $html; }