diff --git a/contrib/numeric_score/main.php b/contrib/numeric_score/main.php
index f50587d3..ca8aba57 100644
--- a/contrib/numeric_score/main.php
+++ b/contrib/numeric_score/main.php
@@ -51,14 +51,15 @@ class NumericScore extends Extension {
}
}
- if(is_a($event, 'DisplayingImageEvent')) {
+ if(is_a($event, 'ImageInfoBoxBuildingEvent')) {
global $user;
global $config;
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')) {
global $database;
$database->execute("DELETE FROM numeric_score_votes WHERE image_id=?", array($event->image->id));
diff --git a/contrib/numeric_score/theme.php b/contrib/numeric_score/theme.php
index 80f7c61c..fbe45fd7 100644
--- a/contrib/numeric_score/theme.php
+++ b/contrib/numeric_score/theme.php
@@ -1,15 +1,16 @@
id);
+ $i_score = int_escape($image->numeric_score);
$html = "
Current score is $i_score |
+
|
";
- $page->add_block(new Block(null, $html, "main", 7));
+ return $html;
}
}
diff --git a/contrib/text_score/main.php b/contrib/text_score/main.php
index 77c05d60..55aaaebe 100644
--- a/contrib/text_score/main.php
+++ b/contrib/text_score/main.php
@@ -30,35 +30,30 @@ class TextScore extends Extension {
}
$config->set_default_bool("text_score_anon", true);
}
-
- if(is_a($event, 'PageRequestEvent') && $event->page_name == "text_score" &&
- $event->get_arg(0) == "vote" &&
- isset($_POST['score']) && isset($_POST['image_id'])) {
- $i_score = int_escape($_POST['score']);
- $i_image_id = int_escape($_POST['image_id']);
-
- if($i_score >= -2 || $i_score <= 2) {
- send_event(new TextScoreSetEvent($i_image_id, $event->user, $i_score));
+
+ if(is_a($event, 'ImageInfoBoxBuildingEvent')) {
+ global $user;
+ global $config;
+ if(!$user->is_anonymous() || $config->get_bool("text_score_anon")) {
+ $event->add_part($this->theme->get_scorer_html($event->image));
}
-
- $event->page->set_mode("redirect");
- $event->page->set_redirect(make_link("post/view/$i_image_id"));
}
+ if(is_a($event, 'ImageInfoSetEvent')) {
+ 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(!$event->user->is_anonymous() || $config->get_bool("text_score_anon")) {
$this->add_vote($event->image_id, $event->user->id, $event->score);
}
}
- 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')) {
global $database;
$database->execute("DELETE FROM text_score_votes WHERE image_id=?", array($event->image->id));
diff --git a/contrib/text_score/theme.php b/contrib/text_score/theme.php
index 30e5b70c..5e61d3a2 100644
--- a/contrib/text_score/theme.php
+++ b/contrib/text_score/theme.php
@@ -1,23 +1,21 @@
id);
- $s_score = $this->score_to_name($score);
+ $s_score = $this->score_to_name($image->text_score);
$html = "
Current score is \"$s_score\"
-
+
+
+
+
+
+
+
";
- $page->add_block(new Block(null, $html, "main", 7));
+ return $html;
}
public function score_to_name($score) {
diff --git a/ext/tag_edit/main.php b/ext/tag_edit/main.php
index dcf941d0..5e703c7d 100644
--- a/ext/tag_edit/main.php
+++ b/ext/tag_edit/main.php
@@ -8,23 +8,7 @@ class TagEdit extends Extension {
if(is_a($event, 'PageRequestEvent') && ($event->page_name == "tag_edit")) {
global $page;
- if($event->get_arg(0) == "set") {
- 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") {
+ if($event->get_arg(0) == "replace") {
global $user;
if($user->is_admin() && isset($_POST['search']) && isset($_POST['replace'])) {
$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')) {
global $database;
$database->set_tags($event->image_id, $event->tags);
@@ -67,6 +64,11 @@ class TagEdit extends Extension {
$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')) {
$sb = new SetupBlock("Tag Editing");
$sb->add_bool_option("tag_edit_anon", "Allow anonymous tag editing: ");
diff --git a/ext/tag_edit/theme.php b/ext/tag_edit/theme.php
index 236d6009..b835ca7f 100644
--- a/ext/tag_edit/theme.php
+++ b/ext/tag_edit/theme.php
@@ -17,5 +17,30 @@ class TagEditTheme extends Themelet {
";
$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 = "Source | |
";
+ }
+
+ $html .= "
+
+ ";
+ }
+
+ return $html;
+ }
}
?>
diff --git a/ext/view/main.php b/ext/view/main.php
index c10e592e..154b9d8b 100644
--- a/ext/view/main.php
+++ b/ext/view/main.php
@@ -1,5 +1,29 @@
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 {
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')) {
- $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);
}
}
}
diff --git a/ext/view/theme.php b/ext/view/theme.php
index f9c4f4d1..9e79d398 100644
--- a/ext/view/theme.php
+++ b/ext/view/theme.php
@@ -4,12 +4,13 @@ class ViewTheme extends Themelet {
/*
* 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_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("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 "";
}
- protected function build_info($image) {
+ protected function build_info($image, $editor_parts) {
global $user;
$owner = $image->get_owner();
$h_owner = html_escape($owner->name);
@@ -70,6 +71,7 @@ class ViewTheme extends Themelet {
$html = "";
$html .= "Uploaded by $h_owner";
+
if($user->is_admin()) {
$html .= " ($h_ip)";
}
@@ -81,41 +83,26 @@ class ViewTheme extends Themelet {
$html .= " (source)";
}
}
+ $html .= " (edit info)";
- global $config;
- global $user;
- if($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) {
- $html .= " (edit)";
+ if(isset($_GET['search'])) {$h_query = "search=".url_escape($_GET['search']);}
+ else {$h_query = "";}
- if(isset($_GET['search'])) {$h_query = "search=".url_escape($_GET['search']);}
- 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 = "
Source | |
";
- }
-
- $html .= "
-
- ";
+ $html .= "
+
+
+ ";
return $html;
}
}