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
This commit is contained in:
parent
051389606e
commit
797e644c1f
@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,14 +6,19 @@ class NumericScoreTheme extends Themelet {
|
||||
$i_score = int_escape($image->numeric_score);
|
||||
|
||||
$html = "
|
||||
<tr>
|
||||
<td>Score ($i_score)</td>
|
||||
<td>
|
||||
<input type='radio' name='numeric_score' value='u' id='u'><label for='u'>Up</label>
|
||||
<input type='radio' name='numeric_score' value='n' id='n' checked><label for='n'>Keep</label>
|
||||
<input type='radio' name='numeric_score' value='d' id='d'><label for='d'>Down</label>
|
||||
</td>
|
||||
</tr>
|
||||
Current Score: $i_score
|
||||
|
||||
<p><form action='".make_link("numeric_score_vote")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='$i_image_id'>
|
||||
<input type='hidden' name='vote' value='up'>
|
||||
<input type='submit' value='Vote Up'>
|
||||
</form>
|
||||
|
||||
<p><form action='".make_link("numeric_score_vote")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='$i_image_id'>
|
||||
<input type='hidden' name='vote' value='down'>
|
||||
<input type='submit' value='Vote Down'>
|
||||
</form>
|
||||
";
|
||||
return $html;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user