One True Image Info Editor
git-svn-id: file:///home/shish/svn/shimmie2/trunk@616 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
078043b9bf
commit
614f11d910
8 changed files with 138 additions and 92 deletions
|
@ -51,14 +51,15 @@ class NumericScore extends Extension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_a($event, 'DisplayingImageEvent')) {
|
if(is_a($event, 'ImageInfoBoxBuildingEvent')) {
|
||||||
global $user;
|
global $user;
|
||||||
global $config;
|
global $config;
|
||||||
if(!$user->is_anonymous() || $config->get_bool("numeric_score_anon")) {
|
if(!$user->is_anonymous() || $config->get_bool("numeric_score_anon")) {
|
||||||
$this->theme->display_voter($event->page, $event->image->id, $event->image->numeric_score);
|
$event->add_part($this->theme->get_voter_html($event->image));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(is_a($event, 'ImageDeletionEvent')) {
|
if(is_a($event, 'ImageDeletionEvent')) {
|
||||||
global $database;
|
global $database;
|
||||||
$database->execute("DELETE FROM numeric_score_votes WHERE image_id=?", array($event->image->id));
|
$database->execute("DELETE FROM numeric_score_votes WHERE image_id=?", array($event->image->id));
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class NumericScoreTheme extends Themelet {
|
class NumericScoreTheme extends Themelet {
|
||||||
public function display_voter($page, $image_id, $score) {
|
public function get_voter_html($image) {
|
||||||
$i_image_id = int_escape($image_id);
|
$i_image_id = int_escape($image->id);
|
||||||
$i_score = int_escape($score);
|
$i_score = int_escape($image->numeric_score);
|
||||||
|
|
||||||
$html = "
|
$html = "
|
||||||
<table style='width: 400px;'>
|
<table style='width: 400px;'>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Current score is $i_score</td>
|
<td>Current score is $i_score</td>
|
||||||
<td>
|
<td>
|
||||||
|
<!--
|
||||||
<form action='".make_link("numeric_score/vote")."' method='POST'>
|
<form action='".make_link("numeric_score/vote")."' method='POST'>
|
||||||
<input type='hidden' name='image_id' value='$i_image_id' />
|
<input type='hidden' name='image_id' value='$i_image_id' />
|
||||||
<input type='hidden' name='score' value='1'>
|
<input type='hidden' name='score' value='1'>
|
||||||
|
@ -21,12 +22,12 @@ class NumericScoreTheme extends Themelet {
|
||||||
<input type='hidden' name='image_id' value='$i_image_id' />
|
<input type='hidden' name='image_id' value='$i_image_id' />
|
||||||
<input type='hidden' name='score' value='-1'>
|
<input type='hidden' name='score' value='-1'>
|
||||||
<input type='submit' value='Vote Down' />
|
<input type='submit' value='Vote Down' />
|
||||||
</form>
|
</form>-->
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
";
|
";
|
||||||
$page->add_block(new Block(null, $html, "main", 7));
|
return $html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,18 +31,21 @@ class TextScore extends Extension {
|
||||||
$config->set_default_bool("text_score_anon", true);
|
$config->set_default_bool("text_score_anon", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_a($event, 'PageRequestEvent') && $event->page_name == "text_score" &&
|
if(is_a($event, 'ImageInfoBoxBuildingEvent')) {
|
||||||
$event->get_arg(0) == "vote" &&
|
global $user;
|
||||||
isset($_POST['score']) && isset($_POST['image_id'])) {
|
global $config;
|
||||||
$i_score = int_escape($_POST['score']);
|
if(!$user->is_anonymous() || $config->get_bool("text_score_anon")) {
|
||||||
$i_image_id = int_escape($_POST['image_id']);
|
$event->add_part($this->theme->get_scorer_html($event->image));
|
||||||
|
}
|
||||||
if($i_score >= -2 || $i_score <= 2) {
|
|
||||||
send_event(new TextScoreSetEvent($i_image_id, $event->user, $i_score));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$event->page->set_mode("redirect");
|
if(is_a($event, 'ImageInfoSetEvent')) {
|
||||||
$event->page->set_redirect(make_link("post/view/$i_image_id"));
|
global $user;
|
||||||
|
$i_score = int_escape($_POST['text_score__score']);
|
||||||
|
|
||||||
|
if($i_score >= -2 || $i_score <= 2) {
|
||||||
|
send_event(new TextScoreSetEvent($event->image_id, $user, $i_score));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_a($event, 'TextScoreSetEvent')) {
|
if(is_a($event, 'TextScoreSetEvent')) {
|
||||||
|
@ -51,14 +54,6 @@ class TextScore extends Extension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_a($event, 'DisplayingImageEvent')) {
|
|
||||||
global $user;
|
|
||||||
global $config;
|
|
||||||
if(!$user->is_anonymous() || $config->get_bool("text_score_anon")) {
|
|
||||||
$this->theme->display_scorer($event->page, $event->image->id, $event->image->text_score);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(is_a($event, 'ImageDeletionEvent')) {
|
if(is_a($event, 'ImageDeletionEvent')) {
|
||||||
global $database;
|
global $database;
|
||||||
$database->execute("DELETE FROM text_score_votes WHERE image_id=?", array($event->image->id));
|
$database->execute("DELETE FROM text_score_votes WHERE image_id=?", array($event->image->id));
|
||||||
|
|
|
@ -1,23 +1,21 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class TextScoreTheme extends Themelet {
|
class TextScoreTheme extends Themelet {
|
||||||
public function display_scorer($page, $image_id, $score) {
|
public function get_scorer_html($image) {
|
||||||
$i_image_id = int_escape($image_id);
|
$i_image_id = int_escape($image->id);
|
||||||
|
|
||||||
$s_score = $this->score_to_name($score);
|
$s_score = $this->score_to_name($image->text_score);
|
||||||
$html = "
|
$html = "
|
||||||
Current score is \"$s_score\"
|
Current score is \"$s_score\"
|
||||||
<br><form action='".make_link("text_score/vote")."' method='POST'>
|
<br/>
|
||||||
<input type='hidden' name='image_id' value='$i_image_id' />
|
<input type='hidden' name='image_id' value='$i_image_id' />
|
||||||
<input type='radio' name='score' value='-2' id='-2'><label for='-2'>Delete</label>
|
<input type='radio' name='text_score__score' value='-2' id='-2'><label for='-2'>Delete</label>
|
||||||
<input type='radio' name='score' value='-1' id='-1'><label for='-1'>Bad</label>
|
<input type='radio' name='text_score__score' value='-1' id='-1'><label for='-1'>Bad</label>
|
||||||
<input type='radio' name='score' value='0' id='0' ><label for='0' >Ok</label>
|
<input type='radio' name='text_score__score' value='0' id='0' ><label for='0' >Ok</label>
|
||||||
<input type='radio' name='score' value='1' id='1' ><label for='1' >Good</label>
|
<input type='radio' name='text_score__score' value='1' id='1' ><label for='1' >Good</label>
|
||||||
<input type='radio' name='score' value='2' id='2' ><label for='2' >Favourite</label>
|
<input type='radio' name='text_score__score' value='2' id='2' ><label for='2' >Favourite</label>
|
||||||
<input type='submit' value='Vote' />
|
|
||||||
</form>
|
|
||||||
";
|
";
|
||||||
$page->add_block(new Block(null, $html, "main", 7));
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function score_to_name($score) {
|
public function score_to_name($score) {
|
||||||
|
|
|
@ -8,23 +8,7 @@ class TagEdit extends Extension {
|
||||||
|
|
||||||
if(is_a($event, 'PageRequestEvent') && ($event->page_name == "tag_edit")) {
|
if(is_a($event, 'PageRequestEvent') && ($event->page_name == "tag_edit")) {
|
||||||
global $page;
|
global $page;
|
||||||
if($event->get_arg(0) == "set") {
|
if($event->get_arg(0) == "replace") {
|
||||||
if($this->can_tag()) {
|
|
||||||
global $database;
|
|
||||||
$i_image_id = int_escape($_POST['image_id']);
|
|
||||||
$query = $_POST['query'];
|
|
||||||
send_event(new TagSetEvent($i_image_id, $_POST['tags']));
|
|
||||||
if($this->can_source()) {
|
|
||||||
send_event(new SourceSetEvent($i_image_id, $_POST['source']));
|
|
||||||
}
|
|
||||||
$page->set_mode("redirect");
|
|
||||||
$page->set_redirect(make_link("post/view/$i_image_id", $query));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$this->theme->display_error($event->page, "Error", "Anonymous tag editing is disabled");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if($event->get_arg(0) == "replace") {
|
|
||||||
global $user;
|
global $user;
|
||||||
if($user->is_admin() && isset($_POST['search']) && isset($_POST['replace'])) {
|
if($user->is_admin() && isset($_POST['search']) && isset($_POST['replace'])) {
|
||||||
$search = $_POST['search'];
|
$search = $_POST['search'];
|
||||||
|
@ -43,6 +27,19 @@ class TagEdit extends Extension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(is_a($event, 'ImageInfoSetEvent')) {
|
||||||
|
if($this->can_tag()) {
|
||||||
|
global $database;
|
||||||
|
send_event(new TagSetEvent($event->image_id, $_POST['tag_edit__tags']));
|
||||||
|
if($this->can_source()) {
|
||||||
|
send_event(new SourceSetEvent($event->image_id, $_POST['tag_edit__source']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->theme->display_error($event->page, "Error", "Anonymous tag editing is disabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(is_a($event, 'TagSetEvent')) {
|
if(is_a($event, 'TagSetEvent')) {
|
||||||
global $database;
|
global $database;
|
||||||
$database->set_tags($event->image_id, $event->tags);
|
$database->set_tags($event->image_id, $event->tags);
|
||||||
|
@ -67,6 +64,11 @@ class TagEdit extends Extension {
|
||||||
$this->mass_tag_edit($event->oldtag, $event->newtag);
|
$this->mass_tag_edit($event->oldtag, $event->newtag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(is_a($event, 'ImageInfoBoxBuildingEvent')) {
|
||||||
|
global $user;
|
||||||
|
$event->add_part($this->theme->get_editor_html($event->image, $user), 40);
|
||||||
|
}
|
||||||
|
|
||||||
if(is_a($event, 'SetupBuildingEvent')) {
|
if(is_a($event, 'SetupBuildingEvent')) {
|
||||||
$sb = new SetupBlock("Tag Editing");
|
$sb = new SetupBlock("Tag Editing");
|
||||||
$sb->add_bool_option("tag_edit_anon", "Allow anonymous tag editing: ");
|
$sb->add_bool_option("tag_edit_anon", "Allow anonymous tag editing: ");
|
||||||
|
|
|
@ -17,5 +17,30 @@ class TagEditTheme extends Themelet {
|
||||||
";
|
";
|
||||||
$page->add_block(new Block("Mass Tag Edit", $html));
|
$page->add_block(new Block("Mass Tag Edit", $html));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_editor_html($image, $user) {
|
||||||
|
$html = "";
|
||||||
|
|
||||||
|
|
||||||
|
global $config;
|
||||||
|
if($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) {
|
||||||
|
$h_tags = html_escape($image->get_tag_list());
|
||||||
|
$i_image_id = int_escape($image->id);
|
||||||
|
|
||||||
|
$source_edit = "";
|
||||||
|
if($config->get_bool("source_edit_anon") || !$user->is_anonymous()) {
|
||||||
|
$source_edit = "<tr><td>Source</td><td><input type='text' name='tag_edit__source' value='$h_source'></td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
$html .= "
|
||||||
|
<table style='width: 500px;'>
|
||||||
|
<tr><td width='50px'>Tags</td><td width='300px'><input type='text' name='tag_edit__tags' value='$h_tags'></td></tr>
|
||||||
|
$source_edit
|
||||||
|
</table>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,5 +1,29 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
class ImageInfoBoxBuildingEvent extends Event {
|
||||||
|
var $parts = array();
|
||||||
|
var $image;
|
||||||
|
var $user;
|
||||||
|
|
||||||
|
public function ImageInfoBoxBuildingEvent($image, $user) {
|
||||||
|
$this->image = $image;
|
||||||
|
$this->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function add_part($html, $position=50) {
|
||||||
|
while(isset($this->parts[$position])) $position++;
|
||||||
|
$this->parts[$position] = $html;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ImageInfoSetEvent extends Event {
|
||||||
|
var $image_id;
|
||||||
|
|
||||||
|
public function ImageInfoSetEvent($image_id) {
|
||||||
|
$this->image_id = int_escape($image_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ViewImage extends Extension {
|
class ViewImage extends Extension {
|
||||||
var $theme;
|
var $theme;
|
||||||
|
|
||||||
|
@ -20,8 +44,21 @@ class ViewImage extends Extension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(is_a($event, 'PageRequestEvent') && ($event->page_name == "post") && ($event->get_arg(0) == "set")) {
|
||||||
|
$image_id = int_escape($_POST['image_id']);
|
||||||
|
|
||||||
|
send_event(new ImageInfoSetEvent($image_id));
|
||||||
|
|
||||||
|
$query = $_POST['query'];
|
||||||
|
$event->page->set_mode("redirect");
|
||||||
|
$event->page->set_redirect(make_link("post/view/$image_id", $query));
|
||||||
|
}
|
||||||
|
|
||||||
if(is_a($event, 'DisplayingImageEvent')) {
|
if(is_a($event, 'DisplayingImageEvent')) {
|
||||||
$this->theme->display_page($event->page, $event->get_image());
|
$iibbe = new ImageInfoBoxBuildingEvent($event->get_image(), $event->user);
|
||||||
|
send_event($iibbe);
|
||||||
|
ksort($iibbe->parts);
|
||||||
|
$this->theme->display_page($event->page, $event->get_image(), $iibbe->parts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,13 @@ class ViewTheme extends Themelet {
|
||||||
/*
|
/*
|
||||||
* Build a page showing $image and some info about it
|
* Build a page showing $image and some info about it
|
||||||
*/
|
*/
|
||||||
public function display_page($page, $image) {
|
public function display_page($page, $image, $editor_parts) {
|
||||||
$page->set_title("Image {$image->id}: ".html_escape($image->get_tag_list()));
|
$page->set_title("Image {$image->id}: ".html_escape($image->get_tag_list()));
|
||||||
$page->set_heading(html_escape($image->get_tag_list()));
|
$page->set_heading(html_escape($image->get_tag_list()));
|
||||||
$page->add_block(new Block("Navigation", $this->build_navigation($image->id), "left", 0));
|
$page->add_block(new Block("Navigation", $this->build_navigation($image->id), "left", 0));
|
||||||
$page->add_block(new Block("Image", $this->build_image_view($image), "main", 0));
|
$page->add_block(new Block("Image", $this->build_image_view($image), "main", 0));
|
||||||
$page->add_block(new Block(null, $this->build_info($image), "main", 10));
|
$page->add_block(new Block(null, $this->build_info($image, $editor_parts), "main", 10));
|
||||||
|
$page->add_block(new Block(null, $this->build_pin($image->id), "main", 11));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,7 +61,7 @@ class ViewTheme extends Themelet {
|
||||||
return "<img id='main_image' src='$ilink'>";
|
return "<img id='main_image' src='$ilink'>";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function build_info($image) {
|
protected function build_info($image, $editor_parts) {
|
||||||
global $user;
|
global $user;
|
||||||
$owner = $image->get_owner();
|
$owner = $image->get_owner();
|
||||||
$h_owner = html_escape($owner->name);
|
$h_owner = html_escape($owner->name);
|
||||||
|
@ -70,6 +71,7 @@ class ViewTheme extends Themelet {
|
||||||
|
|
||||||
$html = "";
|
$html = "";
|
||||||
$html .= "<p>Uploaded by <a href='".make_link("user/$h_owner")."'>$h_owner</a>";
|
$html .= "<p>Uploaded by <a href='".make_link("user/$h_owner")."'>$h_owner</a>";
|
||||||
|
|
||||||
if($user->is_admin()) {
|
if($user->is_admin()) {
|
||||||
$html .= " ($h_ip)";
|
$html .= " ($h_ip)";
|
||||||
}
|
}
|
||||||
|
@ -81,41 +83,26 @@ class ViewTheme extends Themelet {
|
||||||
$html .= " (<a href='http://$h_source'>source</a>)";
|
$html .= " (<a href='http://$h_source'>source</a>)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$html .= " (<a href=\"javascript: toggle('imgdata')\">edit info</a>)";
|
||||||
|
|
||||||
|
|
||||||
global $config;
|
|
||||||
global $user;
|
|
||||||
if($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) {
|
|
||||||
$html .= " (<a href=\"javascript: toggle('imgdata')\">edit</a>)";
|
|
||||||
|
|
||||||
if(isset($_GET['search'])) {$h_query = "search=".url_escape($_GET['search']);}
|
if(isset($_GET['search'])) {$h_query = "search=".url_escape($_GET['search']);}
|
||||||
else {$h_query = "";}
|
else {$h_query = "";}
|
||||||
|
|
||||||
$h_tags = html_escape($image->get_tag_list());
|
|
||||||
$i_image_id = int_escape($image->id);
|
|
||||||
|
|
||||||
$source_edit = "";
|
|
||||||
if($config->get_bool("source_edit_anon") || !$user->is_anonymous()) {
|
|
||||||
$source_edit = "<tr><td>Source</td><td><input type='text' name='source' value='$h_source'></td></tr>";
|
|
||||||
}
|
|
||||||
|
|
||||||
$html .= "
|
$html .= "
|
||||||
<div id='imgdata'><form action='".make_link("tag_edit/set")."' method='POST'>
|
<div id='imgdata'>
|
||||||
<input type='hidden' name='image_id' value='$i_image_id'>
|
<form action='".make_link("post/set")."' method='POST'>
|
||||||
|
<input type='hidden' name='image_id' value='{$image->id}'>
|
||||||
<input type='hidden' name='query' value='$h_query'>
|
<input type='hidden' name='query' value='$h_query'>
|
||||||
<table style='width: 500px;'>
|
|
||||||
<tr><td width='50px'>Tags</td><td width='300px'><input type='text' name='tags' value='$h_tags'></td></tr>
|
|
||||||
$source_edit
|
|
||||||
<tr><td> </td><td><input type='submit' value='Set'></td></tr>
|
|
||||||
</table>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
";
|
";
|
||||||
|
foreach($editor_parts as $part) {
|
||||||
|
$html .= $part;
|
||||||
}
|
}
|
||||||
|
$html .= "
|
||||||
|
<input type='submit' value='Set'>
|
||||||
$html .= "<p>".$this->build_pin($image->id);
|
</div>
|
||||||
|
</form>
|
||||||
|
";
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue