From 55ff224ac0bd6354ef21a37cf9175a836f92a389 Mon Sep 17 00:00:00 2001 From: Daku Date: Tue, 14 Jan 2014 06:27:12 +0000 Subject: [PATCH] added any/none options to the source/pool metatags --- ext/index/main.php | 14 +++++++++++--- ext/pools/main.php | 10 ++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ext/index/main.php b/ext/index/main.php index 0aadaf2b..4d41ed20 100644 --- a/ext/index/main.php +++ b/ext/index/main.php @@ -83,9 +83,11 @@ *
  • tags>=10 -- search for images with 10 or more tags *
  • tags<25 -- search for images with less than 25 tags * - *
  • source=url, eg + *
  • source=(URL, any, none) eg * *
  • order=(id, width, height, filesize, filename)_(ASC, DESC), eg * *
  • Pools * * @@ -323,7 +325,13 @@ class Index extends Extension { } else if(preg_match("/^(source)[=|:]([a-zA-Z0-9]*)$/i", $event->term, $matches)) { $source = strtolower($matches[2]); - $event->add_querylet(new Querylet('images.source LIKE :src', array("src"=>"%$source%"))); + + if(preg_match("/^(any|none)$/", $source)){ + $not = ($source == "any" ? "NOT" : ""); + $event->add_querylet(new Querylet("images.source IS $not NULL")); + }else{ + $event->add_querylet(new Querylet('images.source LIKE :src', array("src"=>"%$source%"))); + } } else if(preg_match("/^posted([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])([0-9-]*)$/", $event->term, $matches)) { $cmp = ltrim($matches[1], ":") ?: "="; diff --git a/ext/pools/main.php b/ext/pools/main.php index 8431a653..6bcd8760 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -295,9 +295,15 @@ class Pools extends Extension { public function onSearchTermParse(SearchTermParseEvent $event) { $matches = array(); - if(preg_match("/^pool[=|:]([0-9]+)$/", $event->term, $matches)) { + if(preg_match("/^pool[=|:]([0-9]+|any|none)$/", $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)")); + + if(preg_match("/^(any|none)$/", $poolID)){ + $not = ($poolID == "none" ? "NOT" : ""); + $event->add_querylet(new Querylet("images.id $not IN (SELECT DISTINCT image_id FROM pool_images)")); + }else{ + $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]);