testing search function

This commit is contained in:
Viktor Pedersen 2021-09-08 11:34:10 +02:00
parent fa765dde5e
commit b8ba31fc70

@ -68,7 +68,6 @@ class SearchPage extends Page {
foreach($terms as $key => $term) { foreach($terms as $key => $term) {
foreach($term as $value => $parsedTerm) { foreach($term as $value => $parsedTerm) {
switch ($parsedTerm[0]) { switch ($parsedTerm[0]) {
case "+": case "+":
if (!array_key_exists($key, $mustMatchArray)) { if (!array_key_exists($key, $mustMatchArray)) {
@ -102,16 +101,16 @@ class SearchPage extends Page {
$items = get_items($type); $items = get_items($type);
$sanitizedItems = array(); $sanitizedItems = array();
foreach($items as $item) { foreach($items as $item) {
$mustMatch = $item->matches($mustMatchArray, True); $result = $item->matches($mustMatchArray);
if($mustMatch) { if($result) {
$sanitizedItems[] = array($item, $mustMatch); $sanitizedItems[] = array($item, $result);
} }
// $mustMatchCheck = array(); // $mustMatchCheck = array();
// foreach($mustMatchArray as $mustMatchTerm) { // foreach($mustMatchArray as $mustMatchTerm) {
// $matchResult = $item->matches($mustMatchTerm); // $matchResult = $item->matches($mustMatchTerm);
// if ($matchResult) { // if($matchResult) {
// $mustMatchCheck[] = True; // $mustMatchCheck[] = True;
// } else { // } else {
// $mustMatchCheck[] = False; // $mustMatchCheck[] = False;
@ -125,7 +124,7 @@ class SearchPage extends Page {
// $mustExcludeCheck = array(); // $mustExcludeCheck = array();
// foreach($mustExcludeArray as $mustExcludeTerm) { // foreach($mustExcludeArray as $mustExcludeTerm) {
// if ($item->matches($mustExcludeTerm)) { // if($item->matches($mustExcludeTerm)) {
// $mustExcludeCheck[] = False; // $mustExcludeCheck[] = False;
// } else { // } else {
// $mustExcludeCheck[] = True; // $mustExcludeCheck[] = True;
@ -133,7 +132,7 @@ class SearchPage extends Page {
// } // }
// if (in_array(False, $mustIncludeCheck, True) === False) { // if (in_array(False, $mustIncludeCheck, True) === False) {
// if (in_array(False, $mustExcludeCheck, True) === True) { // if(in_array(False, $mustExcludeCheck, True) === True) {
// // === IF TRUE DO NOTHING === // // === IF TRUE DO NOTHING ===
@ -152,10 +151,22 @@ class SearchPage extends Page {
print('DEBUG $sanitizedItem: '); print('DEBUG $sanitizedItem: ');
var_dump($sanitizedItem); var_dump($sanitizedItem);
print('<br><br>'); print('<br><br>');
}
$out = array(); // if($sanitizedItem->matches($cannotMatchArray)) {
return $out;
// // === IF TRUE DO NOTHING ===
// }
// else {
// $result = $sanitizedItem->matches($mayMatchArray);
// if($result) {
// $out[] = array($sanitizedItem, $result);
// }
// }
// }
return array();
// return $out;
} }
private function translate_terms($terms) { private function translate_terms($terms) {