From 325da1111913ccbbe5824c2d1e5cd7b6a5937b8f Mon Sep 17 00:00:00 2001 From: Daku Date: Mon, 13 Jan 2014 09:13:56 +0000 Subject: [PATCH] artist/comment/numeric_score metatags now work using : also updated docs --- ext/artists/main.php | 2 +- ext/comment/main.php | 8 ++++---- ext/index/main.php | 12 ++++++++++++ ext/numeric_score/main.php | 12 ++++++------ 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/ext/artists/main.php b/ext/artists/main.php index d426d512..984b12af 100644 --- a/ext/artists/main.php +++ b/ext/artists/main.php @@ -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))); } diff --git a/ext/comment/main.php b/ext/comment/main.php index 48d4f013..1c472626 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -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)")); } diff --git a/ext/index/main.php b/ext/index/main.php index 45f71f02..bd4f3e30 100644 --- a/ext/index/main.php +++ b/ext/index/main.php @@ -105,6 +105,8 @@ *
  • score (=, <, >, <=, >=) number -- seach by score *
  • upvoted_by=Username -- search for a user's likes *
  • downvoted_by=Username -- search for a user's dislikes + *
  • upvoted_by_id=UserID -- search for a user's likes by user ID + *
  • downvoted_by_id=UserID -- search for a user's dislikes by user ID * *
  • Image Rating * + *
  • Artists + * + *
  • Image Comments + * * */ diff --git a/ext/numeric_score/main.php b/ext/numeric_score/main.php index 9cf21ab3..2da74577 100644 --- a/ext/numeric_score/main.php +++ b/ext/numeric_score/main.php @@ -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)",