Add filter for i18n text columns
authorMarcel Werk <burntime@woltlab.com>
Thu, 7 Nov 2024 12:37:41 +0000 (13:37 +0100)
committerMarcel Werk <burntime@woltlab.com>
Tue, 12 Nov 2024 11:53:43 +0000 (12:53 +0100)
wcfsetup/install/files/lib/system/view/grid/filter/I18nTextFilter.class.php [new file with mode: 0644]

diff --git a/wcfsetup/install/files/lib/system/view/grid/filter/I18nTextFilter.class.php b/wcfsetup/install/files/lib/system/view/grid/filter/I18nTextFilter.class.php
new file mode 100644 (file)
index 0000000..4802d6f
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+
+namespace wcf\system\view\grid\filter;
+
+use wcf\data\DatabaseObjectList;
+use wcf\system\WCF;
+
+class I18nTextFilter extends TextFilter
+{
+    #[\Override]
+    public function applyFilter(DatabaseObjectList $list, string $id, string $value): void
+    {
+        $list->getConditionBuilder()->add("($id LIKE ? OR $id IN (SELECT languageItem FROM wcf1_language_item WHERE languageID = ? AND languageItemValue LIKE ?))", [
+            '%' . $value . '%',
+            WCF::getLanguage()->languageID,
+            '%' . $value . '%'
+        ]);
+    }
+}