From c07dc2e0abe0f387096ccdc9c0e427c37713e226 Mon Sep 17 00:00:00 2001 From: Daku Date: Thu, 16 Jan 2014 03:28:23 +0000 Subject: [PATCH] use resolve_aliases rather than resolve_alias --- core/imageboard.pack.php | 41 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index 0bf145e9..6d5cd1cd 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -666,6 +666,8 @@ class Image { } } + $terms = Tag::resolve_aliases($terms); + // parse the words that are searched for into // various types of querylet foreach($terms as $term) { @@ -678,15 +680,6 @@ class Image { continue; } - $aliases = explode(" ", Tag::resolve_alias($term)); - $found = array_search($term, $aliases); - if($found !== false){ - unset($aliases[$found]); - }else{ - $term = array_shift($aliases); - } - foreach($aliases as $alias) array_push($terms, $alias); - $stpe = new SearchTermParseEvent($term, $terms); send_event($stpe); if($stpe->is_querylet_set()) { @@ -834,6 +827,8 @@ class Image { } } + $terms = Tag::resolve_aliases($terms); + reset($terms); // rewind to first element in array. // turn each term into a specific type of querylet @@ -843,15 +838,6 @@ class Image { $negative = true; $term = substr($term, 1); } - - $aliases = explode(" ", Tag::resolve_alias($term)); - $found = array_search($term, $aliases); - if($found !== false){ - unset($aliases[$found]); - }else{ - $term = array_shift($aliases); - } - foreach($aliases as $alias) array_push($terms, $alias); $stpe = new SearchTermParseEvent($term, $terms); send_event($stpe); @@ -1099,11 +1085,22 @@ class Tag { assert(is_array($tags)); $new = array(); - foreach($tags as $tag) { - $new_set = explode(' ', Tag::resolve_alias($tag)); - foreach($new_set as $new_one) { - $new[] = $new_one; + + $i = 0; + $tag_count = count($tags); + while($i<$tag_count) { + $aliases = explode(' ', Tag::resolve_alias($tags[$i])); + foreach($aliases as $alias){ + if(!in_array($alias, $new)){ + if($tags[$i] == $alias){ + $new[] = $alias; + }elseif(!in_array($alias, $tags)){ + $tags[] = $alias; + $tag_count++; + } + } } + $i++; } $new = array_iunique($new); // remove any duplicate tags