bug searching in search function
This commit is contained in:
parent
5414ba7da1
commit
f1a731c859
include
@ -143,11 +143,9 @@ class Product extends Entity {
|
||||
}
|
||||
} else if($field == 'tag') {
|
||||
foreach($this->get_tags() as $tag) {
|
||||
if(match($values, $tag)) {
|
||||
if(!array_key_exists('tags', $matches)) {
|
||||
$matches['tags'] = array();
|
||||
}
|
||||
$matches['tags'][] = $tag;
|
||||
$match = match($values, $tag, $matchAll);
|
||||
if($match) {
|
||||
$matches['tags'] = $tag;
|
||||
break;
|
||||
} else {
|
||||
if($matchAll) {
|
||||
|
@ -253,16 +253,19 @@ function suggest_content($fieldname) {
|
||||
return $out;
|
||||
}
|
||||
|
||||
function match($searchterms, $subject) {
|
||||
function match($searchterms, $subject, $matchAll=false) {
|
||||
$out = array();
|
||||
if(!is_array($searchterms)) {
|
||||
$searchterms = array($searchterms);
|
||||
}
|
||||
foreach($searchterms as $term) {
|
||||
if(fnmatch('*'.$term.'*', $subject, FNM_CASEFOLD)) {
|
||||
return true;
|
||||
$out[] = $term;
|
||||
} else if($matchAll) {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return $out;
|
||||
}
|
||||
|
||||
function format_date($date) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user