From 2bba57e8de29a3cd12eaf268885d867cb59df2d6 Mon Sep 17 00:00:00 2001 From: rr- Date: Fri, 19 Feb 2016 09:44:46 +0100 Subject: [PATCH] Added image_{width,height,area} search syntax --- public_html/templates/help.tpl | 3 +++ src/Search/Filters/PostFilter.php | 3 +++ .../ParserConfigs/PostSearchParserConfig.php | 15 +++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/public_html/templates/help.tpl b/public_html/templates/help.tpl index 54a2565f..9015c56e 100644 --- a/public_html/templates/help.tpl +++ b/public_html/templates/help.tpl @@ -123,6 +123,9 @@ {search: 'date:2000-01-01', description: 'posted on January 1st, 2000'}, {search: 'id:1', description: 'having specific post ID'}, {search: 'name:hash', description: 'having specific post name (hash in full URLs)'}, + {search: 'image_width:100..', description: 'being at least 100 pixels wide'}, + {search: 'image_height:100..', description: 'being at least 100 pixels tall'}, + {search: 'image_area:10000..', description: 'having at least 10000 pixels'}, {search: 'type:image', description: 'only image posts'}, {search: 'type:flash', description: 'only Flash posts'}, {search: 'type:youtube', description: 'only Youtube posts'}, diff --git a/src/Search/Filters/PostFilter.php b/src/Search/Filters/PostFilter.php index 1494aa34..aa62def8 100644 --- a/src/Search/Filters/PostFilter.php +++ b/src/Search/Filters/PostFilter.php @@ -35,6 +35,9 @@ class PostFilter extends BasicFilter implements IFilter const REQUIREMENT_TYPE = 'posts.contentType'; const REQUIREMENT_USER_SCORE = 'posts.userScore'; const REQUIREMENT_TUMBLEWEED = 'tumbleweed'; + const REQUIREMENT_IMAGE_WIDTH = 'posts.imageWidth'; + const REQUIREMENT_IMAGE_HEIGHT = 'posts.imageHeight'; + const REQUIREMENT_IMAGE_AREA = 'posts.imageWidth*posts.imageHeight'; public function __construct() { diff --git a/src/Search/ParserConfigs/PostSearchParserConfig.php b/src/Search/ParserConfigs/PostSearchParserConfig.php index 252bbcae..82a6296d 100644 --- a/src/Search/ParserConfigs/PostSearchParserConfig.php +++ b/src/Search/ParserConfigs/PostSearchParserConfig.php @@ -175,6 +175,21 @@ class PostSearchParserConfig extends AbstractSearchParserConfig $requirement->setNegated($token->isNegated()); return $requirement; }); + + $this->defineNamedTokenParser( + PostFilter::REQUIREMENT_IMAGE_WIDTH, + ['image_width', 'posts'], + self::ALLOW_COMPOSITE | self::ALLOW_RANGE); + + $this->defineNamedTokenParser( + PostFilter::REQUIREMENT_IMAGE_HEIGHT, + ['image_height', 'posts'], + self::ALLOW_COMPOSITE | self::ALLOW_RANGE); + + $this->defineNamedTokenParser( + PostFilter::REQUIREMENT_IMAGE_AREA, + ['image_area', 'posts'], + self::ALLOW_COMPOSITE | self::ALLOW_RANGE); } public function createFilter()