Added various option support to post searching
This commit is contained in:
parent
cc22f3c0ba
commit
e43f3b54d7
4 changed files with 31 additions and 5 deletions
5
TODO
5
TODO
|
@ -6,13 +6,8 @@ everything related to posts:
|
||||||
- better thumbnail loading
|
- better thumbnail loading
|
||||||
- comment count
|
- comment count
|
||||||
- search filters
|
- search filters
|
||||||
- comment:rr-
|
|
||||||
- comment_count: 3..5
|
|
||||||
- file_size:3K..5M
|
- file_size:3K..5M
|
||||||
- image_size:huge/large/medium/small
|
- image_size:huge/large/medium/small
|
||||||
- search order
|
|
||||||
- order:comment_count
|
|
||||||
- order:comment_time
|
|
||||||
|
|
||||||
- single post view
|
- single post view
|
||||||
- previous and next post (difficult)
|
- previous and next post (difficult)
|
||||||
|
|
|
@ -116,6 +116,12 @@ class PostDao extends AbstractDao implements ICrudDao
|
||||||
$query->innerJoin('users favoritedBy ON favoritedBy.id = _fav.userId');
|
$query->innerJoin('users favoritedBy ON favoritedBy.id = _fav.userId');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
elseif ($requirement->getType() === \Szurubooru\SearchServices\Filters\PostFilter::REQUIREMENT_COMMENT)
|
||||||
|
{
|
||||||
|
$query->innerJoin('comments _comment ON _comment.postId = posts.id');
|
||||||
|
$query->innerJoin('users commentedBy ON commentedBy.id = _comment.userId');
|
||||||
|
}
|
||||||
|
|
||||||
elseif ($requirement->getType() === \Szurubooru\SearchServices\Filters\PostFilter::REQUIREMENT_UPLOADER)
|
elseif ($requirement->getType() === \Szurubooru\SearchServices\Filters\PostFilter::REQUIREMENT_UPLOADER)
|
||||||
{
|
{
|
||||||
$query->innerJoin('users uploader ON uploader.id = userId');
|
$query->innerJoin('users uploader ON uploader.id = userId');
|
||||||
|
|
|
@ -10,6 +10,9 @@ class PostFilter extends BasicFilter implements IFilter
|
||||||
const ORDER_SCORE = 'score';
|
const ORDER_SCORE = 'score';
|
||||||
const ORDER_LAST_EDIT_TIME = 'lastEditTime';
|
const ORDER_LAST_EDIT_TIME = 'lastEditTime';
|
||||||
const ORDER_FILE_SIZE = 'originalFileSize';
|
const ORDER_FILE_SIZE = 'originalFileSize';
|
||||||
|
const ORDER_LAST_COMMENT_TIME = 'lastCommentTime';
|
||||||
|
const ORDER_LAST_FAV_TIME = 'lastFavTime';
|
||||||
|
const ORDER_LAST_FEATURE_TIME = 'lastFeatureTime';
|
||||||
|
|
||||||
const REQUIREMENT_TAG = 'tag';
|
const REQUIREMENT_TAG = 'tag';
|
||||||
const REQUIREMENT_ID = 'id';
|
const REQUIREMENT_ID = 'id';
|
||||||
|
@ -21,6 +24,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 = 'favoritedBy.name';
|
const REQUIREMENT_FAVORITE = 'favoritedBy.name';
|
||||||
|
const REQUIREMENT_COMMENT = 'commentedBy.name';
|
||||||
const REQUIREMENT_TYPE = 'contentType';
|
const REQUIREMENT_TYPE = 'contentType';
|
||||||
const REQUIREMENT_USER_SCORE = 'userScore';
|
const REQUIREMENT_USER_SCORE = 'userScore';
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,9 @@ class PostSearchParser extends AbstractSearchParser
|
||||||
elseif ($token->getKey() === 'type')
|
elseif ($token->getKey() === 'type')
|
||||||
$this->addTypeRequirement($filter, $token);
|
$this->addTypeRequirement($filter, $token);
|
||||||
|
|
||||||
|
elseif ($token->getKey() === 'comment')
|
||||||
|
$this->addCommentRequirement($filter, $token);
|
||||||
|
|
||||||
elseif ($token->getKey() === 'special' and $token->getValue() === 'liked' and $this->authService->isLoggedIn())
|
elseif ($token->getKey() === 'special' and $token->getValue() === 'liked' and $this->authService->isLoggedIn())
|
||||||
$this->addUserScoreRequirement($filter, $this->authService->getLoggedInUser()->getName(), 1, $token->isNegated());
|
$this->addUserScoreRequirement($filter, $this->authService->getLoggedInUser()->getName(), 1, $token->isNegated());
|
||||||
|
|
||||||
|
@ -100,6 +103,15 @@ class PostSearchParser extends AbstractSearchParser
|
||||||
elseif ($token === 'random')
|
elseif ($token === 'random')
|
||||||
return \Szurubooru\SearchServices\Filters\PostFilter::ORDER_RANDOM;
|
return \Szurubooru\SearchServices\Filters\PostFilter::ORDER_RANDOM;
|
||||||
|
|
||||||
|
elseif ($token === 'feature_time')
|
||||||
|
return \Szurubooru\SearchServices\Filters\PostFilter::ORDER_LAST_FEATURE_TIME;
|
||||||
|
|
||||||
|
elseif ($token === 'comment_time')
|
||||||
|
return \Szurubooru\SearchServices\Filters\PostFilter::ORDER_LAST_COMMENT_TIME;
|
||||||
|
|
||||||
|
elseif ($token === 'fav_time')
|
||||||
|
return \Szurubooru\SearchServices\Filters\PostFilter::ORDER_LAST_FAV_TIME;
|
||||||
|
|
||||||
throw new \BadMethodCallException('Not supported');
|
throw new \BadMethodCallException('Not supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,6 +233,15 @@ class PostSearchParser extends AbstractSearchParser
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function addCommentRequirement($filter, $token)
|
||||||
|
{
|
||||||
|
$this->addRequirementFromToken(
|
||||||
|
$filter,
|
||||||
|
$token,
|
||||||
|
\Szurubooru\SearchServices\Filters\PostFilter::REQUIREMENT_COMMENT,
|
||||||
|
self::ALLOW_COMPOSITE);
|
||||||
|
}
|
||||||
|
|
||||||
private function addUserScoreRequirement($filter, $userName, $score, $isNegated)
|
private function addUserScoreRequirement($filter, $userName, $score, $isNegated)
|
||||||
{
|
{
|
||||||
$tokenValue = new \Szurubooru\SearchServices\Requirements\RequirementCompositeValue();
|
$tokenValue = new \Szurubooru\SearchServices\Requirements\RequirementCompositeValue();
|
||||||
|
|
Loading…
Reference in a new issue