From c1c507168d5b369702e089b139ba404b461172d2 Mon Sep 17 00:00:00 2001 From: condor2 Date: Sun, 28 Jul 2024 10:24:18 +0300 Subject: [PATCH] Work-around admin category filters --- upload/admin/model/catalog/category.php | 9 +++++++-- upload/admin/view/template/catalog/category_list.tpl | 2 -- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/upload/admin/model/catalog/category.php b/upload/admin/model/catalog/category.php index b5019e73..1d51f0c3 100644 --- a/upload/admin/model/catalog/category.php +++ b/upload/admin/model/catalog/category.php @@ -223,11 +223,16 @@ public function getCategories(array $data = []): array { if (!empty($data['filter_name'])) { $implode = []; + // Decode HTML entities and replace non-breaking spaces with regular spaces + $filterName = str_replace("\xC2\xA0", ' ', html_entity_decode($data['filter_name'], ENT_QUOTES, 'UTF-8')); + // split category path, clear > symbols and extra spaces - $words = explode(' ', trim(preg_replace('/\s+/', ' ', str_ireplace([' > ', ' > '], ' ', $data['filter_name'])))); + $cleanedFilterName = trim(preg_replace('/\s+/', ' ', str_ireplace([' > ', ' > '], ' ', $filterName))); + $words = explode(' ', $cleanedFilterName); foreach ($words as $word) { - $implode[] = "LCASE(`name`) LIKE '" . $this->db->escape('%' . utf8_strtolower($word) . '%') . "'"; + $escapedWord = $this->db->escape('%' . utf8_strtolower($word) . '%'); + $implode[] = "LCASE(`name`) LIKE '" . $escapedWord . "'"; } if ($implode) { diff --git a/upload/admin/view/template/catalog/category_list.tpl b/upload/admin/view/template/catalog/category_list.tpl index 38f7f807..7cab1f86 100644 --- a/upload/admin/view/template/catalog/category_list.tpl +++ b/upload/admin/view/template/catalog/category_list.tpl @@ -38,8 +38,6 @@ - -