- /**
- * Checks wether given array entry matches
- *
- * @param $entryArray Array with the entries to find
- * @return $matches Wether the entry matches or not
- */
- public function ifEntryMatches (array $entryArray) {
- // First nothing matches and nothing is counted
- $matches = false;
- $counted = 0;
-
- // Walk through all entries
- foreach ($entryArray as $key => $entry) {
- // Then walk through all search criteria
- foreach ($this->searchCriteria as $criteriaKey => $criteriaValue) {
- // Is the element found and does it match?
- if (($key == $criteriaKey) && ($criteriaValue == $entry)) {
- // Then count this one up
- $counted++;
- } // END - if
+ // 'default' check
+ $isMatching = ((!is_null($searchDefault)) && ($searchDefault == $value));
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __LINE__ . ']: getCriteriaElement(' . $key . ')[' . gettype($searchDefault) . ']=' . $searchDefault . ',isMatching=' . intval($isMatching));
+
+ // Get 'choice' search value (can be NULL or $separator-separated string)
+ $searchChoice = $this->getCriteriaChoiceElemnent($key);
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __LINE__ . ']: getCriteriaChoiceElement(' . $key . ')[' . gettype($searchChoice) . ']=' . print_r($searchChoice, TRUE));
+
+ // 'choice' check
+ if ((is_array($searchChoice)) && (count($valueArray) == 1)) {
+ // $value is a single-search value, so use in_array()
+ $isMatching = ((($isMatching === TRUE) || (is_null($searchDefault))) && ((is_null($searchChoice)) || ((is_array($searchChoice)) && (in_array($value, $searchChoice)))));
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __LINE__ . ']: getCriteriaChoiceElement(' . $key . ')[]=' . gettype($searchChoice) . ',value=' . $value . ',isMatching=' . intval($isMatching) . ' - SINGLE-MATCH');
+ } elseif ((is_array($searchChoice)) && (count($valueArray) > 1)) {
+ // $value is choice-search value, so check all entries
+ $isMatching = ((is_null($searchDefault)) || ($isMatching === TRUE));
+ $idx = 0;
+ foreach ($valueArray as $idx => $match) {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __LINE__ . ']: match=' . $match . ',count(searchChoice)=' . count($searchChoice));
+
+ // Is it found? (one is okay)
+ $isMatching = (($isMatching === TRUE) && (in_array($match, $searchChoice)));
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __LINE__ . ']: match=' . $match . ',isMatching=' . intval($isMatching));