if a filter is two words, combine the two words into one if there is no match on the separates and search again

pull/2/head
Squidly271 2017-08-17 21:09:15 -04:00
parent 3d6054a30c
commit dd7f3136f2
3 changed files with 24 additions and 1 deletions

View File

@ -1126,7 +1126,7 @@ case 'get_content':
if ( $category && ! preg_match($category,$template['Category'])) { continue; }
if ($filter) {
if (preg_match("#$filter#i", $template['Name']) || preg_match("#$filter#i", $template['Author']) || preg_match("#$filter#i", $template['Description']) || preg_match("#$filter#i", $template['RepoName'])) {
if ( filterMatch($filter,array($template['Name'],$template['Author'],$template['Description'],$template['RepoName'])) ) {
$template['Description'] = highlight($filter, $template['Description']);
$template['Author'] = highlight($filter, $template['Author']);
$template['Name'] = highlight($filter, $template['Name']);

View File

@ -612,6 +612,29 @@ function create_ini_file($settings,$mode=false) {
return $iniFile;
}
#######################################################
# #
# Function used to determine if a search term matches #
# #
#######################################################
function filterMatch($filter,$searchArray) {
foreach ($searchArray as $search) {
if ( preg_match("#$filter#i",$search) ) {
return true;
}
}
if ( strpos($filter," ") ) {
$filter = str_replace(" ","",$filter);
foreach ($searchArray as $search) {
if ( preg_match("#$filter#i",$search) ) {
return true;
}
}
}
return false;
}
############################################################################
# #
# Function to convert a template's associative tags to static numeric tags #