From a850841dbc99ed2a816cc397647c4d271dc8b2f6 Mon Sep 17 00:00:00 2001
From: Viktor Pedersen <viktor@dsv.su.se>
Date: Wed, 8 Sep 2021 10:26:59 +0200
Subject: [PATCH] testing search function

---
 include/SearchPage.php | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/include/SearchPage.php b/include/SearchPage.php
index f274721..39bafda 100644
--- a/include/SearchPage.php
+++ b/include/SearchPage.php
@@ -102,20 +102,22 @@ class SearchPage extends Page {
         $items = get_items($type);
         $sanitizedItems = array();
         foreach($items as $item) {
-            $mustMatch = $item->matches($mustMatchArray);
+            // $mustMatch = $item->matches($mustMatchArray);
 
-            if($mustMatch) {
-                $sanitizedItems[] = array($item, $mustMatch);
+
+            $mustMatchCheck = array();
+            foreach($mustMatchArray as $mustMatchTerm) {
+                $mustMatch = $item->matches($mustMatchTerm);
+                if ($mustMatch) {
+                    $mustMatchCheck[] = True;
+                } else {
+                    $mustMatchCheck[] = False;
+                }
             }
 
-            // $mustIncludeCheck = array();
-            // foreach($mustIncludeArray as $mustIncludeTerm) {
-            //     if ($item->matches($mustIncludeTerm)) {
-            //         $mustIncludeCheck[] = True;
-            //     } else {
-            //         $mustIncludeCheck[] = False;
-            //     }
-            // }
+            if(in_array(False, $mustMatchCheck, True) === False) {
+                $sanitizedItems[] = array($item, $mustMatch);
+            }
 
             // $mustExcludeCheck = array();
             // foreach($mustExcludeArray as $mustExcludeTerm) {
@@ -144,7 +146,7 @@ class SearchPage extends Page {
 
         foreach($sanitizedItems as $sanitizedItem) {
             print('DEBUG $sanitizedItem: ');
-            var_dump($sanitizedItem);
+            var_dump($sanitizedItem;
             print('<br><br>');
         }