Added tag_count: support to post searching
This commit is contained in:
parent
ac78f3b4b8
commit
a80050b70e
3 changed files with 12 additions and 1 deletions
1
TODO
1
TODO
|
@ -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
|
||||||
|
|
|
@ -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()
|
||||||
{
|
{
|
||||||
|
|
|
@ -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));
|
||||||
|
|
Loading…
Reference in a new issue