Skip to content

Commit

Permalink
AdvMD: be more lenient when filtering text, links (42217)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmitz-ilias committed Nov 6, 2024
1 parent ea5a41e commit d5579b7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
Expand All @@ -18,6 +16,8 @@
*
*********************************************************************/

declare(strict_types=1);

/**
* external link search bridge
* @author Stefan Meyer <[email protected]>
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
Expand All @@ -18,6 +16,8 @@
*
*********************************************************************/

declare(strict_types=1);

/**
* external link search bridge
* @author Stefan Meyer <[email protected]>
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit d5579b7

Please sign in to comment.