add support for using : as a metatag seperator + updated docs

This commit is contained in:
Daku
2014-01-02 14:00:24 +00:00
parent 85880804d2
commit 25c286b71f
7 changed files with 61 additions and 49 deletions

View File

@@ -210,16 +210,16 @@ class Notes extends Extension {
*/
public function onSearchTermParse(SearchTermParseEvent $event) {
$matches = array();
if(preg_match("/note=(.*)/i", $event->term, $matches)) {
if(preg_match("/^note[=|:](.*)$/i", $event->term, $matches)) {
$notes = int_escape($matches[1]);
$event->add_querylet(new Querylet("images.id IN (SELECT image_id FROM notes WHERE note = $notes)"));
}
else if(preg_match("/notes(<|>|<=|>=|=)(\d+)/", $event->term, $matches)) {
$cmp = $matches[1];
else if(preg_match("/^notes([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+)%/", $event->term, $matches)) {
$cmp = ltrim($matches[1], ":") ?: "=";
$notes = $matches[2];
$event->add_querylet(new Querylet("images.id IN (SELECT id FROM images WHERE notes $cmp $notes)"));
}
else if(preg_match("/notes_by=(.*)/i", $event->term, $matches)) {
else if(preg_match("/^notes_by[=|:](.*)$/i", $event->term, $matches)) {
global $database;
$user = User::by_name($matches[1]);
if(!is_null($user)) {
@@ -231,7 +231,7 @@ class Notes extends Extension {
$event->add_querylet(new Querylet("images.id IN (SELECT image_id FROM notes WHERE user_id = $user_id)"));
}
else if(preg_match("/notes_by_userno=([0-9]+)/i", $event->term, $matches)) {
else if(preg_match("/^notes_by_userno[=|:](\d+)$/i", $event->term, $matches)) {
$user_id = int_escape($matches[1]);
$event->add_querylet(new Querylet("images.id IN (SELECT image_id FROM notes WHERE user_id = $user_id)"));
}