Added tag_count: support to post searching

This commit is contained in:
Marcin Kurczewski 2014-09-30 15:16:56 +02:00
parent ac78f3b4b8
commit a80050b70e
3 changed files with 12 additions and 1 deletions

1
TODO
View file

@ -17,7 +17,6 @@ everything related to posts:
- fav:rr- - fav:rr-
- fav_count:3..5 - fav_count:3..5
- score:3..5 - score:3..5
- tag_count:3..5
- file_size:3K..5M - file_size:3K..5M
- image_size:huge/large/medium/small - image_size:huge/large/medium/small
- type:img/flash/yt/video - type:img/flash/yt/video

View file

@ -14,6 +14,7 @@ class PostFilter extends BasicFilter implements IFilter
const REQUIREMENT_ID = 'id'; const REQUIREMENT_ID = 'id';
const REQUIREMENT_DATE = 'uploadTime'; const REQUIREMENT_DATE = 'uploadTime';
const REQUIREMENT_HASH = 'name'; const REQUIREMENT_HASH = 'name';
const REQUIREMENT_TAG_COUNT = 'tagCount';
public function __construct() public function __construct()
{ {

View file

@ -28,6 +28,9 @@ class PostSearchParser extends AbstractSearchParser
elseif ($token->getKey() === 'date') elseif ($token->getKey() === 'date')
$this->addDateRequirement($filter, $token); $this->addDateRequirement($filter, $token);
elseif ($token->getKey() === 'tag_count')
$this->addTagCountRequirement($filter, $token);
else else
throw new \BadMethodCallException('Not supported'); throw new \BadMethodCallException('Not supported');
} }
@ -100,6 +103,14 @@ class PostSearchParser extends AbstractSearchParser
$filter->addRequirement($requirement); $filter->addRequirement($requirement);
} }
private function addTagCountRequirement($filter, $token)
{
$requirement = new \Szurubooru\SearchServices\Requirements\Requirement();
$requirement->setType(\Szurubooru\SearchServices\Filters\PostFilter::REQUIREMENT_TAG_COUNT);
$requirement->setValue($this->createRequirementValue($token->getValue(), self::ALLOW_COMPOSITE | self::ALLOW_RANGES));
$filter->addRequirement($requirement);
}
private function dateToTime($value) private function dateToTime($value)
{ {
$value = strtolower(trim($value)); $value = strtolower(trim($value));