Tag Editor to simpleext
This commit is contained in:
parent
eedfc5e6b4
commit
5c2140a028
2 changed files with 72 additions and 71 deletions
|
@ -56,13 +56,9 @@ class LockSetEvent extends Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
class TagEdit implements Extension {
|
class TagEdit implements Extension {
|
||||||
var $theme;
|
public function onPageRequest($event) {
|
||||||
|
global $user, $page;
|
||||||
public function receive_event(Event $event) {
|
if($event->page_matches("tag_edit")) {
|
||||||
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")) {
|
|
||||||
if($event->get_arg(0) == "replace") {
|
if($event->get_arg(0) == "replace") {
|
||||||
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'];
|
||||||
|
@ -73,8 +69,10 @@ class TagEdit implements Extension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($event instanceof ImageInfoSetEvent) {
|
public function onImageInfoSet($event) {
|
||||||
|
global $user;
|
||||||
if($this->can_tag($event->image)) {
|
if($this->can_tag($event->image)) {
|
||||||
send_event(new TagSetEvent($event->image, $_POST['tag_edit__tags']));
|
send_event(new TagSetEvent($event->image, $_POST['tag_edit__tags']));
|
||||||
if($this->can_source($event->image)) {
|
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()) {
|
if($user->is_admin() || !$event->image->is_locked()) {
|
||||||
$event->image->set_tags($event->tags);
|
$event->image->set_tags($event->tags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($event instanceof SourceSetEvent) {
|
public function onSourceSet($event) {
|
||||||
|
global $user;
|
||||||
if($user->is_admin() || !$event->image->is_locked()) {
|
if($user->is_admin() || !$event->image->is_locked()) {
|
||||||
$event->image->set_source($event->source);
|
$event->image->set_source($event->source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($event instanceof LockSetEvent) {
|
public function onLockSet($event) {
|
||||||
|
global $user;
|
||||||
if($user->is_admin()) {
|
if($user->is_admin()) {
|
||||||
$event->image->set_locked($event->locked);
|
$event->image->set_locked($event->locked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($event instanceof ImageDeletionEvent) {
|
public function onImageDeletion($event) {
|
||||||
$event->image->delete_tags_from_image();
|
$event->image->delete_tags_from_image();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($event instanceof AdminBuildingEvent) {
|
public function onAdminBuilding($event) {
|
||||||
$this->theme->display_mass_editor($page);
|
$this->theme->display_mass_editor();
|
||||||
}
|
}
|
||||||
|
|
||||||
// When an alias is added, oldtag becomes inaccessable
|
// When an alias is added, oldtag becomes inaccessable
|
||||||
if($event instanceof AddAliasEvent) {
|
public function onAddAlias($event) {
|
||||||
$this->mass_tag_edit($event->oldtag, $event->newtag);
|
$this->mass_tag_edit($event->oldtag, $event->newtag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($event instanceof ImageInfoBoxBuildingEvent) {
|
public function onImageInfoBoxBuilding($event) {
|
||||||
|
global $user;
|
||||||
if($this->can_tag($event->image)) {
|
if($this->can_tag($event->image)) {
|
||||||
$event->add_part($this->theme->get_tag_editor_html($event->image), 40);
|
$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 = 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: ");
|
||||||
$sb->add_bool_option("source_edit_anon", "<br>Allow anonymous source editing: ");
|
$sb->add_bool_option("source_edit_anon", "<br>Allow anonymous source editing: ");
|
||||||
$event->panel->add_block($sb);
|
$event->panel->add_block($sb);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private function can_tag($image) {
|
private function can_tag($image) {
|
||||||
|
@ -198,5 +199,4 @@ class TagEdit implements Extension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_event_listener(new TagEdit());
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -5,7 +5,8 @@ class TagEditTheme extends Themelet {
|
||||||
* Display a form which links to tag_edit/replace with POST[search]
|
* Display a form which links to tag_edit/replace with POST[search]
|
||||||
* and POST[replace] set appropriately
|
* and POST[replace] set appropriately
|
||||||
*/
|
*/
|
||||||
public function display_mass_editor(Page $page) {
|
public function display_mass_editor() {
|
||||||
|
global $page;
|
||||||
$html = "
|
$html = "
|
||||||
".make_form(make_link("tag_edit/replace"))."
|
".make_form(make_link("tag_edit/replace"))."
|
||||||
<table style='width: 300px;'>
|
<table style='width: 300px;'>
|
||||||
|
|
Reference in a new issue