move metatag parsing to after set_tags is sent, rather than before
This commit is contained in:
parent
b11041898b
commit
43d0a297b8
@ -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
|
* Delete this image from the database and disk
|
||||||
*/
|
*/
|
||||||
|
@ -258,7 +258,7 @@ class NumericScore extends Extension {
|
|||||||
public function onTagTermParse(TagTermParseEvent $event) {
|
public function onTagTermParse(TagTermParseEvent $event) {
|
||||||
$matches = array();
|
$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;
|
global $user;
|
||||||
$score = ($matches[1] == "up" ? 1 : ($matches[1] == "down" ? -1 : 0));
|
$score = ($matches[1] == "up" ? 1 : ($matches[1] == "down" ? -1 : 0));
|
||||||
if(!$user->is_anonymous()) {
|
if(!$user->is_anonymous()) {
|
||||||
|
@ -58,7 +58,7 @@ class Relationships extends Extension {
|
|||||||
public function onTagTermParse(TagTermParseEvent $event) {
|
public function onTagTermParse(TagTermParseEvent $event) {
|
||||||
$matches = array();
|
$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];
|
$parentID = $matches[1];
|
||||||
|
|
||||||
if($parentID == "none" || $parentID == "0"){
|
if($parentID == "none" || $parentID == "0"){
|
||||||
@ -67,7 +67,7 @@ class Relationships extends Extension {
|
|||||||
$this->set_parent($event->id, $parentID);
|
$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];
|
$childID = $matches[1];
|
||||||
|
|
||||||
$this->set_child($event->id, $childID);
|
$this->set_child($event->id, $childID);
|
||||||
|
@ -110,8 +110,7 @@ class TagSetEvent extends Event {
|
|||||||
$tag_array = Tag::resolve_aliases($tag_array);
|
$tag_array = Tag::resolve_aliases($tag_array);
|
||||||
|
|
||||||
foreach($tag_array as $tag) {
|
foreach($tag_array as $tag) {
|
||||||
//TODO: Parsing metatags BEFORE set_tags is sent seems like a bad idea?
|
$ttpe = new TagTermParseEvent($tag, $this->image->id, FALSE); //Only check for metatags, don't parse. Parsing is done after set_tags.
|
||||||
$ttpe = new TagTermParseEvent($tag, $image->id);
|
|
||||||
send_event($ttpe);
|
send_event($ttpe);
|
||||||
|
|
||||||
//seperate tags from metatags
|
//seperate tags from metatags
|
||||||
@ -152,14 +151,17 @@ class LockSetEvent extends Event {
|
|||||||
* Signal that a tag term needs parsing
|
* Signal that a tag term needs parsing
|
||||||
*/
|
*/
|
||||||
class TagTermParseEvent extends Event {
|
class TagTermParseEvent extends Event {
|
||||||
var $term = null;
|
public $term = NULL; //tag
|
||||||
var $id = null;
|
public $id = NULL; //image_id
|
||||||
/** @var bool */
|
/** @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) {
|
public function __construct($term, $id, $parse) {
|
||||||
$this->term = $term;
|
$this->term = $term;
|
||||||
$this->id = $id;
|
$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"))) {
|
if($user->can("edit_image_tag") && (!$event->image->is_locked() || $user->can("edit_image_lock"))) {
|
||||||
$event->image->set_tags($event->tags);
|
$event->image->set_tags($event->tags);
|
||||||
}
|
}
|
||||||
|
$event->image->parse_metatags($event->metatags, $event->image->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSourceSet(SourceSetEvent $event) {
|
public function onSourceSet(SourceSetEvent $event) {
|
||||||
@ -278,7 +281,7 @@ class TagEdit extends Extension {
|
|||||||
public function onTagTermParse(TagTermParseEvent $event) {
|
public function onTagTermParse(TagTermParseEvent $event) {
|
||||||
$matches = array();
|
$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);
|
$source = ($matches[1] !== "none" ? $matches[1] : null);
|
||||||
send_event(new SourceSetEvent(Image::by_id($event->id), $source));
|
send_event(new SourceSetEvent(Image::by_id($event->id), $source));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user