From ce256f5bf4a7a883243d063a89c628ddc92c8e76 Mon Sep 17 00:00:00 2001 From: Daku Date: Tue, 14 Jan 2014 06:12:34 +0000 Subject: [PATCH] added pool & pool_by_name search metatags --- ext/index/main.php | 13 +++++++++---- ext/pools/main.php | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ext/index/main.php b/ext/index/main.php index bd4f3e30..0aadaf2b 100644 --- a/ext/index/main.php +++ b/ext/index/main.php @@ -121,8 +121,8 @@ *
  • Notes * *
  • Artists * */ diff --git a/ext/pools/main.php b/ext/pools/main.php index 008838d3..8431a653 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -293,6 +293,22 @@ class Pools extends Extension { } } + public function onSearchTermParse(SearchTermParseEvent $event) { + $matches = array(); + if(preg_match("/^pool[=|:]([0-9]+)$/", $event->term, $matches)) { + $poolID = $matches[1]; + $event->add_querylet(new Querylet("images.id IN (SELECT DISTINCT image_id FROM pool_images WHERE pool_id = $poolID)")); + } + else if(preg_match("/^pool_by_name[=|:](.*)$/", $event->term, $matches)) { + $poolTitle = str_replace("_", " ", $matches[1]); + + $pool = $this->get_single_pool_from_title($poolTitle); + $poolID = 0; + if ($pool){ $poolID = $pool['id']; } + $event->add_querylet(new Querylet("images.id IN (SELECT DISTINCT image_id FROM pool_images WHERE pool_id = $poolID)")); + } + } + public function add_post_from_tag(/*str*/ $poolTag, /*int*/ $imageID){ $poolTag = str_replace("_", " ", $poolTag); //First check if pool tag is a title