From 87681f8c0dc138820f0b9615c6ece0c0fc69c90a Mon Sep 17 00:00:00 2001 From: rr- Date: Fri, 19 Feb 2016 09:53:26 +0100 Subject: [PATCH] Added file_size search syntax --- public_html/templates/help.tpl | 1 + src/Search/Filters/PostFilter.php | 1 + src/Search/ParserConfigs/PostSearchParserConfig.php | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/public_html/templates/help.tpl b/public_html/templates/help.tpl index e804e765..58e56a4a 100644 --- a/public_html/templates/help.tpl +++ b/public_html/templates/help.tpl @@ -123,6 +123,7 @@ {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: 'file_size:100..', description: 'having at least 100 bytes'}, {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'}, diff --git a/src/Search/Filters/PostFilter.php b/src/Search/Filters/PostFilter.php index ade8fce8..f839c3eb 100644 --- a/src/Search/Filters/PostFilter.php +++ b/src/Search/Filters/PostFilter.php @@ -38,6 +38,7 @@ class PostFilter extends BasicFilter implements IFilter const REQUIREMENT_TYPE = 'posts.contentType'; const REQUIREMENT_USER_SCORE = 'posts.userScore'; const REQUIREMENT_TUMBLEWEED = 'tumbleweed'; + const REQUIREMENT_FILE_SIZE = 'posts.originalFileSize'; const REQUIREMENT_IMAGE_WIDTH = 'posts.imageWidth'; const REQUIREMENT_IMAGE_HEIGHT = 'posts.imageHeight'; const REQUIREMENT_IMAGE_AREA = 'posts.imageWidth*posts.imageHeight'; diff --git a/src/Search/ParserConfigs/PostSearchParserConfig.php b/src/Search/ParserConfigs/PostSearchParserConfig.php index f577cca1..cafbc642 100644 --- a/src/Search/ParserConfigs/PostSearchParserConfig.php +++ b/src/Search/ParserConfigs/PostSearchParserConfig.php @@ -179,6 +179,11 @@ class PostSearchParserConfig extends AbstractSearchParserConfig return $requirement; }); + $this->defineNamedTokenParser( + PostFilter::REQUIREMENT_FILE_SIZE, + ['file_size'], + self::ALLOW_COMPOSITE | self::ALLOW_RANGE); + $this->defineNamedTokenParser( PostFilter::REQUIREMENT_IMAGE_WIDTH, ['image_width', 'width'],