diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index de659e3a..ebe01158 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -623,6 +623,18 @@ class Image { } } + /** + * Send list of metatags to be parsed. + * + * @param [] $metatags + */ + public function parse_metatags(/*arr*/ $metatags, $image_id) { + foreach($metatags as $tag) { + $ttpe = new TagTermParseEvent($tag, $image_id, TRUE); + send_event($ttpe); + } + } + /** * Delete this image from the database and disk */ diff --git a/ext/numeric_score/main.php b/ext/numeric_score/main.php index b7efed34..9286e7e2 100644 --- a/ext/numeric_score/main.php +++ b/ext/numeric_score/main.php @@ -258,7 +258,7 @@ class NumericScore extends Extension { public function onTagTermParse(TagTermParseEvent $event) { $matches = array(); - if(preg_match("/^vote[=|:](up|down|remove)$/", $event->term, $matches)) { + if(preg_match("/^vote[=|:](up|down|remove)$/", $event->term, $matches) && $event->parse) { global $user; $score = ($matches[1] == "up" ? 1 : ($matches[1] == "down" ? -1 : 0)); if(!$user->is_anonymous()) { diff --git a/ext/relatationships/main.php b/ext/relatationships/main.php index 6cd1a7b0..8ecc6991 100644 --- a/ext/relatationships/main.php +++ b/ext/relatationships/main.php @@ -58,7 +58,7 @@ class Relationships extends Extension { public function onTagTermParse(TagTermParseEvent $event) { $matches = array(); - if(preg_match("/^parent[=|:]([0-9]+|none)$/", $event->term, $matches)) { + if(preg_match("/^parent[=|:]([0-9]+|none)$/", $event->term, $matches) && $event->parse) { $parentID = $matches[1]; if($parentID == "none" || $parentID == "0"){ @@ -67,7 +67,7 @@ class Relationships extends Extension { $this->set_parent($event->id, $parentID); } } - else if(preg_match("/^child[=|:]([0-9]+)$/", $event->term, $matches)) { + else if(preg_match("/^child[=|:]([0-9]+)$/", $event->term, $matches) && $event->parse) { $childID = $matches[1]; $this->set_child($event->id, $childID); diff --git a/ext/tag_edit/main.php b/ext/tag_edit/main.php index 09d86ba1..918a0111 100644 --- a/ext/tag_edit/main.php +++ b/ext/tag_edit/main.php @@ -110,8 +110,7 @@ class TagSetEvent extends Event { $tag_array = Tag::resolve_aliases($tag_array); foreach($tag_array as $tag) { - //TODO: Parsing metatags BEFORE set_tags is sent seems like a bad idea? - $ttpe = new TagTermParseEvent($tag, $image->id); + $ttpe = new TagTermParseEvent($tag, $this->image->id, FALSE); //Only check for metatags, don't parse. Parsing is done after set_tags. send_event($ttpe); //seperate tags from metatags @@ -152,14 +151,17 @@ class LockSetEvent extends Event { * Signal that a tag term needs parsing */ class TagTermParseEvent extends Event { - var $term = null; - var $id = null; + public $term = NULL; //tag + public $id = NULL; //image_id /** @var bool */ - public $metatag = false; + public $metatag = FALSE; + /** @var bool */ + public $parse = TRUE; //marks the tag to be parsed, and not just checked if valid metatag - public function __construct($term, $id) { - $this->term = $term; - $this->id = $id; + public function __construct($term, $id, $parse) { + $this->term = $term; + $this->id = $id; + $this->parse = $parse; } /** @@ -236,6 +238,7 @@ class TagEdit extends Extension { if($user->can("edit_image_tag") && (!$event->image->is_locked() || $user->can("edit_image_lock"))) { $event->image->set_tags($event->tags); } + $event->image->parse_metatags($event->metatags, $event->image->id); } public function onSourceSet(SourceSetEvent $event) { @@ -278,7 +281,7 @@ class TagEdit extends Extension { public function onTagTermParse(TagTermParseEvent $event) { $matches = array(); - if(preg_match("/^source[=|:](.*)$/i", $event->term, $matches)) { + if(preg_match("/^source[=|:](.*)$/i", $event->term, $matches) && $event->parse) { $source = ($matches[1] !== "none" ? $matches[1] : null); send_event(new SourceSetEvent(Image::by_id($event->id), $source)); }