diff --git a/core/database.class.php b/core/database.class.php index 0f249ed6..2287a03c 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -256,6 +256,11 @@ class Database { $this->execute("UPDATE tags SET count = count + 1 WHERE tag = ?", array($tag)); } } + + public function set_source($image_id, $source) { + if(empty($source)) $source = null; + $this->execute("UPDATE images SET source=? WHERE id=?", array($source, $image_id)); + } // }}} // images {{{ public function get_images($start, $limit, $tags=array()) { diff --git a/core/events/sourceset.event.php b/core/events/sourceset.event.php new file mode 100644 index 00000000..ddd99463 --- /dev/null +++ b/core/events/sourceset.event.php @@ -0,0 +1,17 @@ +image_id = $image_id; + $this->source = $source; + } +} +?> diff --git a/ext/tag_edit/main.php b/ext/tag_edit/main.php index 6facc918..e5d374f3 100644 --- a/ext/tag_edit/main.php +++ b/ext/tag_edit/main.php @@ -14,6 +14,7 @@ class TagEdit extends Extension { $i_image_id = int_escape($_POST['image_id']); $query = $_POST['query']; send_event(new TagSetEvent($i_image_id, $_POST['tags'])); + send_event(new SourceSetEvent($i_image_id, $_POST['source'])); $page->set_mode("redirect"); $page->set_redirect(make_link("post/view/$i_image_id", $query)); } @@ -32,15 +33,16 @@ class TagEdit extends Extension { } } - if(is_a($event, 'DisplayingImageEvent')) { - $this->theme->display_editor($event->page, $event->image); - } - if(is_a($event, 'TagSetEvent')) { global $database; $database->set_tags($event->image_id, $event->tags); } + if(is_a($event, 'SourceSetEvent')) { + global $database; + $database->set_source($event->image_id, $event->source); + } + if(is_a($event, 'ImageDeletionEvent')) { global $database; $database->delete_tags_from_image($event->image->id); diff --git a/ext/tag_edit/theme.php b/ext/tag_edit/theme.php index f1db4312..236d6009 100644 --- a/ext/tag_edit/theme.php +++ b/ext/tag_edit/theme.php @@ -1,40 +1,6 @@ get_tag_list() - */ - public function display_editor($page, $image) { - global $database; - - 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); - - $html = " -
- "; - - $page->add_block(new Block(null, $html, "main", 5)); - } - /* * Display a form which links to tag_edit/replace with POST[search] * and POST[replace] set appropriately diff --git a/ext/view/theme.php b/ext/view/theme.php index 2d7295ed..6665a1e5 100644 --- a/ext/view/theme.php +++ b/ext/view/theme.php @@ -13,7 +13,6 @@ class ViewTheme extends Themelet { } - var $pin = null; private function build_pin($image_id) { @@ -82,8 +81,36 @@ class ViewTheme extends Themelet { $html .= " (source)"; } } + + + global $config; + global $user; + if($config->get_bool("tag_edit_anon") || ($user->id != $config->get_int("anon_id"))) { + $html .= " (edit)"; + + 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); + + $html .= " +".$this->build_pin($image->id); - + return $html; } } diff --git a/themes/danbooru/style.css b/themes/danbooru/style.css index 2870631c..24812430 100644 --- a/themes/danbooru/style.css +++ b/themes/danbooru/style.css @@ -50,10 +50,8 @@ TD { border-top: none; } #body SELECT {width: 150px;} -/* -TD INPUT {width: 100%;} -TD SELECT {width: 100%;} -*/ +TD>INPUT {width: 100%;} +TD>SELECT {width: 100%;} #footer { clear: both; diff --git a/themes/danbooru/view.theme.php b/themes/danbooru/view.theme.php index 41329a56..ce93d864 100644 --- a/themes/danbooru/view.theme.php +++ b/themes/danbooru/view.theme.php @@ -87,6 +87,31 @@ class ViewTheme extends Themelet { $html .= " (source)"; } } + + global $config; + global $user; + if($config->get_bool("tag_edit_anon") || ($user->id != $config->get_int("anon_id"))) { + $html .= " (edit)"; + + 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); + + $html .= " +