artist/comment/numeric_score metatags now work using :
also updated docs
This commit is contained in:
parent
7d49e21792
commit
325da11119
@ -45,7 +45,7 @@ class Artists extends Extension {
|
||||
|
||||
public function onSearchTermParse(SearchTermParseEvent $event) {
|
||||
$matches = array();
|
||||
if(preg_match("/^author=(.*)$/", $event->term, $matches)) {
|
||||
if(preg_match("/^author[=|:](.*)$/", $event->term, $matches)) {
|
||||
$char = $matches[1];
|
||||
$event->add_querylet(new Querylet("Author = :author_char", array("author_char"=>$char)));
|
||||
}
|
||||
|
@ -262,12 +262,12 @@ class CommentList extends Extension {
|
||||
|
||||
public function onSearchTermParse(SearchTermParseEvent $event) {
|
||||
$matches = array();
|
||||
if(preg_match("/comments(<|>|<=|>=|=)(\d+)/", $event->term, $matches)) {
|
||||
$cmp = $matches[1];
|
||||
if(preg_match("/^comments([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+)$/", $event->term, $matches)) {
|
||||
$cmp = ltrim($matches[1], ":") ?: "=";
|
||||
$comments = $matches[2];
|
||||
$event->add_querylet(new Querylet("images.id IN (SELECT DISTINCT image_id FROM comments GROUP BY image_id HAVING count(image_id) $cmp $comments)"));
|
||||
}
|
||||
else if(preg_match("/commented_by=(.*)/i", $event->term, $matches)) {
|
||||
else if(preg_match("/^commented_by[=|:](.*)$/i", $event->term, $matches)) {
|
||||
global $database;
|
||||
$user = User::by_name($matches[1]);
|
||||
if(!is_null($user)) {
|
||||
@ -279,7 +279,7 @@ class CommentList extends Extension {
|
||||
|
||||
$event->add_querylet(new Querylet("images.id IN (SELECT image_id FROM comments WHERE owner_id = $user_id)"));
|
||||
}
|
||||
else if(preg_match("/commented_by_userid=([0-9]+)/i", $event->term, $matches)) {
|
||||
else if(preg_match("/^commented_by_userno[=|:]([0-9]+)$/i", $event->term, $matches)) {
|
||||
$user_id = int_escape($matches[1]);
|
||||
$event->add_querylet(new Querylet("images.id IN (SELECT image_id FROM comments WHERE owner_id = $user_id)"));
|
||||
}
|
||||
|
@ -105,6 +105,8 @@
|
||||
* <li>score (=, <, >, <=, >=) number -- seach by score
|
||||
* <li>upvoted_by=Username -- search for a user's likes
|
||||
* <li>downvoted_by=Username -- search for a user's dislikes
|
||||
* <li>upvoted_by_id=UserID -- search for a user's likes by user ID
|
||||
* <li>downvoted_by_id=UserID -- search for a user's dislikes by user ID
|
||||
* </ul>
|
||||
* <li>Image Rating
|
||||
* <ul>
|
||||
@ -122,6 +124,16 @@
|
||||
* <li>notes_by=Username -- search for a notes created by username
|
||||
* <li>notes_by_userno=UserID -- search for a notes created by userID
|
||||
* </ul>
|
||||
* <li>Artists
|
||||
* <ul>
|
||||
* <li>author=ArtistName -- search for images by artist
|
||||
* </ul>
|
||||
* <li>Image Comments
|
||||
* <ul>
|
||||
* <li>comments (=, <, >, <=, >=) number -- search for images by number of comments
|
||||
* <li>commented_by=Username -- search for a user's comments by username
|
||||
* <li>commented_by_userno=UserID -- search for a user's comments by userID
|
||||
* </ul>
|
||||
* </ul>
|
||||
*/
|
||||
|
||||
|
@ -217,12 +217,12 @@ class NumericScore extends Extension {
|
||||
|
||||
public function onSearchTermParse(SearchTermParseEvent $event) {
|
||||
$matches = array();
|
||||
if(preg_match("/^score(<|<=|=|>=|>)(-?\d+)$/", $event->term, $matches)) {
|
||||
$cmp = $matches[1];
|
||||
if(preg_match("/^score([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(-?\d+)$/", $event->term, $matches)) {
|
||||
$cmp = ltrim($matches[1], ":") ?: "=";
|
||||
$score = $matches[2];
|
||||
$event->add_querylet(new Querylet("numeric_score $cmp $score"));
|
||||
}
|
||||
if(preg_match("/^upvoted_by=(.*)$/", $event->term, $matches)) {
|
||||
if(preg_match("/^upvoted_by[=|:](.*)$/", $event->term, $matches)) {
|
||||
$duser = User::by_name($matches[1]);
|
||||
if(is_null($duser)) {
|
||||
throw new SearchTermParseException(
|
||||
@ -232,7 +232,7 @@ class NumericScore extends Extension {
|
||||
"images.id in (SELECT image_id FROM numeric_score_votes WHERE user_id=:ns_user_id AND score=1)",
|
||||
array("ns_user_id"=>$duser->id)));
|
||||
}
|
||||
if(preg_match("/^downvoted_by=(.*)$/", $event->term, $matches)) {
|
||||
if(preg_match("/^downvoted_by[=|:](.*)$/", $event->term, $matches)) {
|
||||
$duser = User::by_name($matches[1]);
|
||||
if(is_null($duser)) {
|
||||
throw new SearchTermParseException(
|
||||
@ -242,13 +242,13 @@ class NumericScore extends Extension {
|
||||
"images.id in (SELECT image_id FROM numeric_score_votes WHERE user_id=:ns_user_id AND score=-1)",
|
||||
array("ns_user_id"=>$duser->id)));
|
||||
}
|
||||
if(preg_match("/^upvoted_by_id=(\d+)$/", $event->term, $matches)) {
|
||||
if(preg_match("/^upvoted_by_id[=|:](\d+)$/", $event->term, $matches)) {
|
||||
$iid = int_escape($matches[1]);
|
||||
$event->add_querylet(new Querylet(
|
||||
"images.id in (SELECT image_id FROM numeric_score_votes WHERE user_id=:ns_user_id AND score=1)",
|
||||
array("ns_user_id"=>$iid)));
|
||||
}
|
||||
if(preg_match("/^downvoted_by_id=(\d+)$/", $event->term, $matches)) {
|
||||
if(preg_match("/^downvoted_by_id[=|:](\d+)$/", $event->term, $matches)) {
|
||||
$iid = int_escape($matches[1]);
|
||||
$event->add_querylet(new Querylet(
|
||||
"images.id in (SELECT image_id FROM numeric_score_votes WHERE user_id=:ns_user_id AND score=-1)",
|
||||
|
Loading…
x
Reference in New Issue
Block a user