add TagTermParseEvent for parsing tags during tagging
This commit is contained in:
parent
711ad775da
commit
b7778b54c9
@ -479,15 +479,9 @@ class Image {
|
|||||||
$this->delete_tags_from_image();
|
$this->delete_tags_from_image();
|
||||||
// insert each new tags
|
// insert each new tags
|
||||||
foreach($tags as $tag) {
|
foreach($tags as $tag) {
|
||||||
if(preg_match("/^source[=|:](.*)$/i", $tag, $matches)) {
|
$ttpe = new TagTermParseEvent($tag, $this->id);
|
||||||
$this->set_source($matches[1]);
|
send_event($ttpe);
|
||||||
continue;
|
if($ttpe->is_metatag()) {
|
||||||
}
|
|
||||||
if(preg_match("/^pool[=|:](.*)$/i", $tag, $matches)) {
|
|
||||||
if(class_exists("Pools")) {
|
|
||||||
$pls = new Pools();
|
|
||||||
$pls->add_post_from_tag($matches[1], $this->id);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,6 +315,16 @@ class Pools extends Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onTagTermParse(TagTermParseEvent $event) {
|
||||||
|
$matches = array();
|
||||||
|
|
||||||
|
if(preg_match("/^pool[=|:](.*)$/i", $event->term, $matches)) {
|
||||||
|
$this->add_post_from_tag($matches[1], $event->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($matches)) $event->metatag = true;
|
||||||
|
}
|
||||||
|
|
||||||
public function add_post_from_tag(/*str*/ $poolTag, /*int*/ $imageID){
|
public function add_post_from_tag(/*str*/ $poolTag, /*int*/ $imageID){
|
||||||
$poolTag = str_replace("_", " ", $poolTag);
|
$poolTag = str_replace("_", " ", $poolTag);
|
||||||
//First check if pool tag is a title
|
//First check if pool tag is a title
|
||||||
|
@ -72,6 +72,25 @@ class LockSetEvent extends Event {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TagTermParseEvent:
|
||||||
|
* Signal that a tag term needs parsing
|
||||||
|
*/
|
||||||
|
class TagTermParseEvent extends Event {
|
||||||
|
var $term = null;
|
||||||
|
var $id = null;
|
||||||
|
var $metatag = false;
|
||||||
|
|
||||||
|
public function TagTermParseEvent($term, $id) {
|
||||||
|
$this->term = $term;
|
||||||
|
$this->id = $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function is_metatag() {
|
||||||
|
return $this->metatag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class TagEdit extends Extension {
|
class TagEdit extends Extension {
|
||||||
public function onPageRequest(PageRequestEvent $event) {
|
public function onPageRequest(PageRequestEvent $event) {
|
||||||
global $user, $page;
|
global $user, $page;
|
||||||
@ -169,6 +188,15 @@ class TagEdit extends Extension {
|
|||||||
$event->add_part($this->theme->get_lock_editor_html($event->image), 42);
|
$event->add_part($this->theme->get_lock_editor_html($event->image), 42);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onTagTermParse(TagTermParseEvent $event) {
|
||||||
|
$matches = array();
|
||||||
|
|
||||||
|
if(preg_match("/^source[=|:](.*)$/i", $event->term, $matches)) {
|
||||||
|
send_event(new SourceSetEvent(Image::by_id($event->id), $matches[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($matches)) $event->metatag = true;
|
||||||
|
}
|
||||||
|
|
||||||
private function can_tag(Image $image) {
|
private function can_tag(Image $image) {
|
||||||
global $config, $user;
|
global $config, $user;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user