Added type: support to post searching
This commit is contained in:
parent
d6bd82dc3e
commit
c021c9a1c0
4 changed files with 22 additions and 1 deletions
1
TODO
1
TODO
|
@ -12,7 +12,6 @@ everything related to posts:
|
||||||
- comment_count: 3..5
|
- comment_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
|
|
||||||
- special:liked
|
- special:liked
|
||||||
- special:disliked
|
- special:disliked
|
||||||
- special:fav
|
- special:fav
|
||||||
|
|
|
@ -75,6 +75,11 @@ class EnumHelper
|
||||||
return self::enumToString(self::$postTypeMap, $postType);
|
return self::enumToString(self::$postTypeMap, $postType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function postTypeFromString($postTypeString)
|
||||||
|
{
|
||||||
|
return self::stringToEnum(self::$postTypeMap, $postTypeString);
|
||||||
|
}
|
||||||
|
|
||||||
public static function snapshotTypeFromString($snapshotTypeString)
|
public static function snapshotTypeFromString($snapshotTypeString)
|
||||||
{
|
{
|
||||||
return self::stringToEnum(self::$snapshotTypeMap, $snapshotTypeString);
|
return self::stringToEnum(self::$snapshotTypeMap, $snapshotTypeString);
|
||||||
|
|
|
@ -20,6 +20,7 @@ class PostFilter extends BasicFilter implements IFilter
|
||||||
const REQUIREMENT_UPLOADER = 'uploader.name';
|
const REQUIREMENT_UPLOADER = 'uploader.name';
|
||||||
const REQUIREMENT_SAFETY = 'safety';
|
const REQUIREMENT_SAFETY = 'safety';
|
||||||
const REQUIREMENT_FAVORITE = 'favorite.name';
|
const REQUIREMENT_FAVORITE = 'favorite.name';
|
||||||
|
const REQUIREMENT_TYPE = 'contentType';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,6 +46,9 @@ class PostSearchParser extends AbstractSearchParser
|
||||||
elseif ($token->getKey() === 'fav')
|
elseif ($token->getKey() === 'fav')
|
||||||
$this->addFavRequirement($filter, $token);
|
$this->addFavRequirement($filter, $token);
|
||||||
|
|
||||||
|
elseif ($token->getKey() === 'type')
|
||||||
|
$this->addTypeRequirement($filter, $token);
|
||||||
|
|
||||||
else
|
else
|
||||||
throw new \BadMethodCallException('Not supported');
|
throw new \BadMethodCallException('Not supported');
|
||||||
}
|
}
|
||||||
|
@ -178,6 +181,19 @@ class PostSearchParser extends AbstractSearchParser
|
||||||
self::ALLOW_COMPOSITE);
|
self::ALLOW_COMPOSITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function addTypeRequirement($filter, $token)
|
||||||
|
{
|
||||||
|
$this->addRequirementFromToken(
|
||||||
|
$filter,
|
||||||
|
$token,
|
||||||
|
\Szurubooru\SearchServices\Filters\PostFilter::REQUIREMENT_TYPE,
|
||||||
|
self::ALLOW_COMPOSITE,
|
||||||
|
function ($value)
|
||||||
|
{
|
||||||
|
return \Szurubooru\Helpers\EnumHelper::postTypeFromSTring($value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private function dateToTime($value)
|
private function dateToTime($value)
|
||||||
{
|
{
|
||||||
$value = strtolower(trim($value));
|
$value = strtolower(trim($value));
|
||||||
|
|
Loading…
Reference in a new issue