From d5579b78cee950eee3a06c22370e1e861a6e80b0 Mon Sep 17 00:00:00 2001 From: Tim Schmitz Date: Wed, 6 Nov 2024 16:58:44 +0100 Subject: [PATCH] AdvMD: be more lenient when filtering text, links (42217) --- .../class.ilADTExternalLinkSearchBridgeSingle.php | 11 +++++++---- .../class.ilADTInternalLinkSearchBridgeSingle.php | 11 +++++++---- .../class.ilADTLocalizedTextSearchBridgeSingle.php | 6 ++++-- .../Types/Text/class.ilADTTextSearchBridgeSingle.php | 6 +++--- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/components/ILIAS/ADT/classes/Types/ExternalLink/class.ilADTExternalLinkSearchBridgeSingle.php b/components/ILIAS/ADT/classes/Types/ExternalLink/class.ilADTExternalLinkSearchBridgeSingle.php index aeeeb6a7f3f2..acb367430afa 100755 --- a/components/ILIAS/ADT/classes/Types/ExternalLink/class.ilADTExternalLinkSearchBridgeSingle.php +++ b/components/ILIAS/ADT/classes/Types/ExternalLink/class.ilADTExternalLinkSearchBridgeSingle.php @@ -1,7 +1,5 @@ @@ -146,9 +146,12 @@ public function getSQLCondition(string $a_element_id, int $mode = self::SQL_LIKE public function isInCondition(ilADT $a_adt): bool { if ($this->getADT()->getCopyOfDefinition()->isComparableTo($a_adt)) { + $search_term = strtolower(trim((string) $this->getADT()->getUrl())); + $title = strtolower(trim((string) $a_adt->getTitle())); + $url = strtolower(trim((string) $a_adt->getUrl())); return - strcasecmp(trim($this->getADT()->getUrl()), trim((string) $a_adt->getUrl())) === 0 || - strcasecmp(trim($this->getADT()->getUrl()), trim((string) $a_adt->getTitle())) === 0; + str_contains($title, $search_term) || + str_contains($url, $search_term); } return false; } diff --git a/components/ILIAS/ADT/classes/Types/InternalLink/class.ilADTInternalLinkSearchBridgeSingle.php b/components/ILIAS/ADT/classes/Types/InternalLink/class.ilADTInternalLinkSearchBridgeSingle.php index f18ee43e9af9..0a13403f86be 100755 --- a/components/ILIAS/ADT/classes/Types/InternalLink/class.ilADTInternalLinkSearchBridgeSingle.php +++ b/components/ILIAS/ADT/classes/Types/InternalLink/class.ilADTInternalLinkSearchBridgeSingle.php @@ -1,7 +1,5 @@ @@ -132,8 +132,11 @@ public function isInCondition(ilADT $a_adt): bool { if ($this->getADT()->getCopyOfDefinition()->isComparableTo($a_adt)) { $ref_id = $a_adt->getTargetRefId(); - $title = ilObject::_lookupTitle((int) ilObject::_lookupObjId((int) $ref_id)); - return strcasecmp($title, $this->getTitleQuery()) === 0; + $title = strtolower(trim( + ilObject::_lookupTitle((int) ilObject::_lookupObjId((int) $ref_id)) + )); + $query = strtolower(trim($this->getTitleQuery())); + return str_contains($title, $query); } return false; } diff --git a/components/ILIAS/ADT/classes/Types/LocalizedText/class.ilADTLocalizedTextSearchBridgeSingle.php b/components/ILIAS/ADT/classes/Types/LocalizedText/class.ilADTLocalizedTextSearchBridgeSingle.php index f9dc7c098229..d72f8d76b955 100755 --- a/components/ILIAS/ADT/classes/Types/LocalizedText/class.ilADTLocalizedTextSearchBridgeSingle.php +++ b/components/ILIAS/ADT/classes/Types/LocalizedText/class.ilADTLocalizedTextSearchBridgeSingle.php @@ -123,8 +123,10 @@ public function isInCondition(ilADT $a_adt): bool $a_adt->getTranslations() : [$a_adt->getTextForLanguage($a_adt->getCopyOfDefinition()->getDefaultLanguage())]; - foreach ($relevant_translation as $txt) { - if (str_contains(strtolower($txt), strtolower($this->getADT()->getText()))) { + foreach ($relevant_translation as $text) { + $search_term = strtolower(trim((string) $this->getADT()->getText())); + $text = strtolower(trim((string) $text)); + if (str_contains($text, $search_term)) { return true; } } diff --git a/components/ILIAS/ADT/classes/Types/Text/class.ilADTTextSearchBridgeSingle.php b/components/ILIAS/ADT/classes/Types/Text/class.ilADTTextSearchBridgeSingle.php index 16ee84cd21e3..1b177e6bc92b 100755 --- a/components/ILIAS/ADT/classes/Types/Text/class.ilADTTextSearchBridgeSingle.php +++ b/components/ILIAS/ADT/classes/Types/Text/class.ilADTTextSearchBridgeSingle.php @@ -139,9 +139,9 @@ public function getSQLCondition(string $a_element_id, int $mode = self::SQL_LIKE public function isInCondition(ilADT $a_adt): bool { if ($this->getADT()->getCopyOfDefinition()->isComparableTo($a_adt)) { - if (str_contains(strtolower($a_adt->getText()), strtolower($this->getADT()->getText()))) { - return true; - } + $search_term = strtolower(trim((string) $this->getADT()->getText())); + $text = strtolower(trim((string) $a_adt->getText())); + return str_contains($text, $search_term); } return false; }