Search queries: added search by likes/dislikes
This commit is contained in:
parent
6e9a18c0ae
commit
95b2eec461
2 changed files with 38 additions and 0 deletions
|
@ -29,6 +29,7 @@ You can use your keyboard to navigate around the site. There are a few shortcuts
|
||||||
- having specific ID: [search]id:1,2,3,8[/search]
|
- having specific ID: [search]id:1,2,3,8[/search]
|
||||||
- having ID no less than specified value: [search]idmin:28[/search]
|
- having ID no less than specified value: [search]idmin:28[/search]
|
||||||
- by content type: [search]type:img[/search], [search]type:swf[/search], [search]type:yt[/search] (images, flash files and YouTube videos, respectively)
|
- by content type: [search]type:img[/search], [search]type:swf[/search], [search]type:yt[/search] (images, flash files and YouTube videos, respectively)
|
||||||
|
- scored up/down by currently logged in user: [search]special:likes[/search] and [search]special:dislikes[/search]
|
||||||
|
|
||||||
You can combine tags and negate any of them for interesting results. [search]sea -favmin:8 type:swf submit:Pirate[/search] will show you **flash files** tagged as **sea**, that were **liked by seven people** at most, uploaded by user **Pirate**.
|
You can combine tags and negate any of them for interesting results. [search]sea -favmin:8 type:swf submit:Pirate[/search] will show you **flash files** tagged as **sea**, that were **liked by seven people** at most, uploaded by user **Pirate**.
|
||||||
|
|
||||||
|
|
|
@ -131,6 +131,43 @@ class Model_Post_QueryBuilder implements AbstractQueryBuilder
|
||||||
$dbQuery->addSql('comment_count <= ?')->put(intval($val));
|
$dbQuery->addSql('comment_count <= ?')->put(intval($val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static function filterTokenSpecial($dbQuery, $val)
|
||||||
|
{
|
||||||
|
$context = \Chibi\Registry::getContext();
|
||||||
|
|
||||||
|
switch (strtolower($val))
|
||||||
|
{
|
||||||
|
case 'liked':
|
||||||
|
case 'likes':
|
||||||
|
$dbQuery
|
||||||
|
->exists()
|
||||||
|
->open()
|
||||||
|
->select('1')
|
||||||
|
->from('postscore')
|
||||||
|
->where('post_id = post.id')
|
||||||
|
->and('score > 0')
|
||||||
|
->and('user_id = ?')->put($context->user->id)
|
||||||
|
->close();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'disliked':
|
||||||
|
case 'dislikes':
|
||||||
|
$dbQuery
|
||||||
|
->exists()
|
||||||
|
->open()
|
||||||
|
->select('1')
|
||||||
|
->from('postscore')
|
||||||
|
->where('post_id = post.id')
|
||||||
|
->and('score < 0')
|
||||||
|
->and('user_id = ?')->put($context->user->id)
|
||||||
|
->close();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new SimpleException('Unknown special "' . $val . '"');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected static function filterTokenType($dbQuery, $val)
|
protected static function filterTokenType($dbQuery, $val)
|
||||||
{
|
{
|
||||||
switch (strtolower($val))
|
switch (strtolower($val))
|
||||||
|
|
Loading…
Reference in a new issue