Tag Editor to simpleext

This commit is contained in:
Shish 2012-01-27 16:58:48 +00:00
parent eedfc5e6b4
commit 5c2140a028
2 changed files with 72 additions and 71 deletions

View file

@ -56,13 +56,9 @@ class LockSetEvent extends Event {
}
class TagEdit implements Extension {
var $theme;
public function receive_event(Event $event) {
global $config, $database, $page, $user;
if(is_null($this->theme)) $this->theme = get_theme_object($this);
if(($event instanceof PageRequestEvent) && $event->page_matches("tag_edit")) {
public function onPageRequest($event) {
global $user, $page;
if($event->page_matches("tag_edit")) {
if($event->get_arg(0) == "replace") {
if($user->is_admin() && isset($_POST['search']) && isset($_POST['replace'])) {
$search = $_POST['search'];
@ -73,8 +69,10 @@ class TagEdit implements Extension {
}
}
}
}
if($event instanceof ImageInfoSetEvent) {
public function onImageInfoSet($event) {
global $user;
if($this->can_tag($event->image)) {
send_event(new TagSetEvent($event->image, $_POST['tag_edit__tags']));
if($this->can_source($event->image)) {
@ -90,38 +88,42 @@ class TagEdit implements Extension {
}
}
if($event instanceof TagSetEvent) {
public function onTagSet($event) {
global $user;
if($user->is_admin() || !$event->image->is_locked()) {
$event->image->set_tags($event->tags);
}
}
if($event instanceof SourceSetEvent) {
public function onSourceSet($event) {
global $user;
if($user->is_admin() || !$event->image->is_locked()) {
$event->image->set_source($event->source);
}
}
if($event instanceof LockSetEvent) {
public function onLockSet($event) {
global $user;
if($user->is_admin()) {
$event->image->set_locked($event->locked);
}
}
if($event instanceof ImageDeletionEvent) {
public function onImageDeletion($event) {
$event->image->delete_tags_from_image();
}
if($event instanceof AdminBuildingEvent) {
$this->theme->display_mass_editor($page);
public function onAdminBuilding($event) {
$this->theme->display_mass_editor();
}
// When an alias is added, oldtag becomes inaccessable
if($event instanceof AddAliasEvent) {
public function onAddAlias($event) {
$this->mass_tag_edit($event->oldtag, $event->newtag);
}
if($event instanceof ImageInfoBoxBuildingEvent) {
public function onImageInfoBoxBuilding($event) {
global $user;
if($this->can_tag($event->image)) {
$event->add_part($this->theme->get_tag_editor_html($event->image), 40);
}
@ -133,13 +135,12 @@ class TagEdit implements Extension {
}
}
if($event instanceof SetupBuildingEvent) {
public function onSetupBuilding($event) {
$sb = new SetupBlock("Tag Editing");
$sb->add_bool_option("tag_edit_anon", "Allow anonymous tag editing: ");
$sb->add_bool_option("source_edit_anon", "<br>Allow anonymous source editing: ");
$event->panel->add_block($sb);
}
}
private function can_tag($image) {
@ -198,5 +199,4 @@ class TagEdit implements Extension {
}
}
}
add_event_listener(new TagEdit());
?>

View file

@ -5,7 +5,8 @@ class TagEditTheme extends Themelet {
* Display a form which links to tag_edit/replace with POST[search]
* and POST[replace] set appropriately
*/
public function display_mass_editor(Page $page) {
public function display_mass_editor() {
global $page;
$html = "
".make_form(make_link("tag_edit/replace"))."
<table style='width: 300px;'>