more misc work
git-svn-id: file:///home/shish/svn/shimmie2/trunk@514 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
c30fee9f0b
commit
5b6ca92d4f
@ -15,11 +15,12 @@ class Ratings extends Extension {
|
|||||||
|
|
||||||
if(is_a($event, 'InitExtEvent')) {
|
if(is_a($event, 'InitExtEvent')) {
|
||||||
global $config;
|
global $config;
|
||||||
if($config->get_int("ext_ratings_version") < 1) {
|
if($config->get_int("ext_ratings_version") < 2) {
|
||||||
$this->install();
|
$this->install();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# TODO: ImageEditorBuildingEvent
|
||||||
if(is_a($event, 'PageRequestEvent') && $event->page_name == "rating" &&
|
if(is_a($event, 'PageRequestEvent') && $event->page_name == "rating" &&
|
||||||
$event->get_arg(0) == "set" && $event->user->is_admin() &&
|
$event->get_arg(0) == "set" && $event->user->is_admin() &&
|
||||||
isset($_POST['rating']) && isset($_POST['image_id'])) {
|
isset($_POST['rating']) && isset($_POST['image_id'])) {
|
||||||
@ -31,7 +32,7 @@ class Ratings extends Extension {
|
|||||||
if(is_a($event, 'DisplayingImageEvent')) {
|
if(is_a($event, 'DisplayingImageEvent')) {
|
||||||
global $user;
|
global $user;
|
||||||
if($user->is_admin()) {
|
if($user->is_admin()) {
|
||||||
$this->theme->display_rater($event->page, $event->image->id);
|
$this->theme->display_rater($event->page, $event->image->id, $event->image->rating);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -39,12 +40,18 @@ class Ratings extends Extension {
|
|||||||
private function install() {
|
private function install() {
|
||||||
global $database;
|
global $database;
|
||||||
global $config;
|
global $config;
|
||||||
$database->Execute("ALTER TABLE images
|
|
||||||
ADD COLUMN rating ENUM('s', 'q', 'e') NOT NULL DEFAULT 'q'
|
if($config->get_int("ext_ratings_version") < 1) {
|
||||||
)");
|
$database->Execute("ALTER TABLE images ADD COLUMN rating ENUM('s', 'q', 'e') NOT NULL DEFAULT 'q'");
|
||||||
$config->set_int("ext_ratings_version", 1);
|
$config->set_int("ext_ratings_version", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($config->get_int("ext_ratings_version") < 2) {
|
||||||
|
$database->Execute("CREATE INDEX images__rating ON images(rating)");
|
||||||
|
$config->set_int("ext_ratings_version", 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function set_rating($image_id, $rating) {
|
private function set_rating($image_id, $rating) {
|
||||||
global $database;
|
global $database;
|
||||||
$database->Execute("UPDATE images SET rating=? WHERE id=?", array($rating, $image_id));
|
$database->Execute("UPDATE images SET rating=? WHERE id=?", array($rating, $image_id));
|
||||||
|
@ -1,18 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class RatingsTheme extends Themelet {
|
class RatingsTheme extends Themelet {
|
||||||
public function display_rater($page, $image_id) {
|
public function display_rater($page, $image_id, $rating) {
|
||||||
$i_image_id = int_escape($image_id);
|
$i_image_id = int_escape($image_id);
|
||||||
|
$s_checked = $rating == 's' ? " checked" : "";
|
||||||
|
$q_checked = $rating == 'q' ? " checked" : "";
|
||||||
|
$e_checked = $rating == 'e' ? " checked" : "";
|
||||||
$html = "
|
$html = "
|
||||||
<form action='".make_link("rating/set")."' method='POST'>
|
<form action='".make_link("rating/set")."' method='POST'>
|
||||||
<input type='hidden' name='image_id' value='$i_image_id' />
|
<input type='hidden' name='image_id' value='$i_image_id' />
|
||||||
<input type='radio' name='rating' value='s' id='s'><label for='s'>Safe</label>
|
<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'><label for='q'>Questionable</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'><label for='e'>Explicit</label>
|
<input type='radio' name='rating' value='e' id='e'$e_checked><label for='e'>Explicit</label>
|
||||||
<input type='submit' value='Set' />
|
<input type='submit' value='Set' />
|
||||||
</form>
|
</form>
|
||||||
";
|
";
|
||||||
$page->add_block(new Block(null, $html, "main", 45));
|
$page->add_block(new Block(null, $html, "main", 7));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user