Skip to content

Commit

Permalink
Work-around admin category filters
Browse files Browse the repository at this point in the history
  • Loading branch information
condor2 committed Jul 28, 2024
1 parent 2c57a2a commit c1c5071
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 7 additions & 2 deletions upload/admin/model/catalog/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions upload/admin/view/template/catalog/category_list.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
<input type="text" name="filter_name" value="<?php echo $filter_name; ?>" placeholder="<?php echo $entry_name; ?>" id="input-name" class="form-control" />
</div>
</div>


<div class="col-sm-6">
<div class="form-group">
<label class="control-label" for="input-status"><?php echo $entry_status; ?></label>
Expand Down

0 comments on commit c1c5071

Please sign in to comment.