make rating use the new image metainfo editor api
git-svn-id: file:///home/shish/svn/shimmie2/trunk@727 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
d0483bcc2a
commit
499d752ca9
@ -34,25 +34,21 @@ class Ratings extends Extension {
|
||||
$config->set_default_string("ext_rating_user_privs", 'sq');
|
||||
}
|
||||
|
||||
# TODO: ImageEditorBuildingEvent
|
||||
global $user; // compat with stable
|
||||
if(is_a($event, 'PageRequestEvent') && $event->page_name == "rating" &&
|
||||
$event->get_arg(0) == "set" && $user->is_admin() &&
|
||||
isset($_POST['rating']) && isset($_POST['image_id'])) {
|
||||
$i_image_id = int_escape($_POST['image_id']);
|
||||
send_event(new RatingSetEvent($i_image_id, $user, $_POST['rating']));
|
||||
$event->page->set_mode("redirect");
|
||||
$event->page->set_redirect(make_link("post/view/".int_escape($_POST['image_id'])));
|
||||
}
|
||||
|
||||
if(is_a($event, 'RatingSetEvent')) {
|
||||
$this->set_rating($event->image_id, $event->rating);
|
||||
}
|
||||
|
||||
if(is_a($event, 'DisplayingImageEvent')) {
|
||||
if(is_a($event, 'ImageInfoBoxBuildingEvent')) {
|
||||
global $user;
|
||||
if($user->is_admin()) {
|
||||
$this->theme->display_rater($event->page, $event->image->id, $event->image->rating);
|
||||
$event->add_part($this->theme->get_rater_html($event->image->id, $event->image->rating), 80);
|
||||
}
|
||||
}
|
||||
|
||||
if(is_a($event, 'ImageInfoSetEvent')) {
|
||||
global $user;
|
||||
if($user->is_admin()) {
|
||||
send_event(new RatingSetEvent($event->image_id, $user, $_POST['rating']));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,21 +1,18 @@
|
||||
<?php
|
||||
|
||||
class RatingsTheme extends Themelet {
|
||||
public function display_rater($page, $image_id, $rating) {
|
||||
public function get_rater_html($image_id, $rating) {
|
||||
$i_image_id = int_escape($image_id);
|
||||
$s_checked = $rating == 's' ? " checked" : "";
|
||||
$q_checked = $rating == 'q' ? " checked" : "";
|
||||
$e_checked = $rating == 'e' ? " checked" : "";
|
||||
$html = "
|
||||
<form action='".make_link("rating/set")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='$i_image_id' />
|
||||
<input type='radio' name='rating' value='s' id='s'$s_checked><label for='s'>Safe</label>
|
||||
<input type='radio' name='rating' value='q' id='q'$q_checked><label for='q'>Questionable</label>
|
||||
<input type='radio' name='rating' value='e' id='e'$e_checked><label for='e'>Explicit</label>
|
||||
<input type='submit' value='Set' />
|
||||
</form>
|
||||
<input type='hidden' name='image_id' value='$i_image_id' />
|
||||
<input type='radio' name='rating' value='s' id='s'$s_checked><label for='s'>Safe</label>
|
||||
<input type='radio' name='rating' value='q' id='q'$q_checked><label for='q'>Questionable</label>
|
||||
<input type='radio' name='rating' value='e' id='e'$e_checked><label for='e'>Explicit</label>
|
||||
";
|
||||
$page->add_block(new Block(null, $html, "main", 7));
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function rating_to_name($rating) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user