From d03f482864098b03f496ab56aeaf0fa4697f68d6 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Wed, 6 Aug 2025 18:05:49 +0200 Subject: [PATCH] Template/Update (Part 9) * convert filter handler --- endpoints/filter/filter.php | 64 ++++++++++++++++++++++++ includes/ajaxHandler/filter.class.php | 71 --------------------------- static/js/filters.js | 4 +- 3 files changed, 66 insertions(+), 73 deletions(-) create mode 100644 endpoints/filter/filter.php delete mode 100644 includes/ajaxHandler/filter.class.php diff --git a/endpoints/filter/filter.php b/endpoints/filter/filter.php new file mode 100644 index 00000000..f6fdc23b --- /dev/null +++ b/endpoints/filter/filter.php @@ -0,0 +1,64 @@ +page, $catg] = explode('=', $pageParam); + else + $this->page = $pageParam; + + if ($catg !== null) + $this->catg = explode('.', $catg); + + $opts = ['parentCats' => $this->catg]; + + // so usually the page call is just the DBTypes file string with a plural 's' .. but then there are currencies + $fileStr = match ($this->page) + { + 'currencies' => 'currency', + default => substr($this->page, 0, -1) + }; + + // yes, the whole _POST! .. should the input fields be exposed and static so they can be evaluated via BaseResponse::initRequestData() ? + $this->filter = Type::newFilter($fileStr, $_POST, $opts); + } + + protected function generate() : void + { + $url = '?'.$this->page; + + $this->filter?->mergeCat($this->catg); + + if ($this->catg) + $url .= '='.implode('.', $this->catg); + + if ($x = $this->filter?->buildGETParam()) + $url .= '&filter='.$x; + + if ($this->filter?->error) + $_SESSION['error']['fi'] = $this->filter::class; + + // do get request + $this->redirectTo = $url; + } +} + +?> diff --git a/includes/ajaxHandler/filter.class.php b/includes/ajaxHandler/filter.class.php deleted file mode 100644 index 3f93f68c..00000000 --- a/includes/ajaxHandler/filter.class.php +++ /dev/null @@ -1,71 +0,0 @@ -page = $p[0]; - - if (isset($p[1])) - $this->cat[] = $p[1]; - - if (count($params) > 1) - for ($i = 1; $i < count($params); $i++) - $this->cat[] = $params[$i]; - - $opts = ['parentCats' => $this->cat]; - - // so usually the page call is just the DBTypes file string with a plural 's' .. but then there are currencies - $fileStr = match ($this->page) - { - 'currencies' => 'currency', - default => substr($this->page, 0, -1) - }; - - // yes, the whole _POST! .. should the input fields be exposed and static so they can be evaluated via BaseResponse::initRequestData() ? - $this->filter = Type::newFilter($fileStr, $_POST, $opts); - - // always this one - $this->handler = 'handleFilter'; - } - - protected function handleFilter() : string - { - $url = '?'.$this->page; - - $this->filter?->mergeCat($this->cat); - - if ($this->cat) - $url .= '='.implode('.', $this->cat); - - if ($x = $this->filter?->buildGETParam()) - $url .= '&filter='.$x; - - if ($this->filter?->error) - $_SESSION['error']['fi'] = get_class($this->filter); - - // do get request - return $url; - } -} - -?> diff --git a/static/js/filters.js b/static/js/filters.js index 670abd94..a09d5e6e 100644 --- a/static/js/filters.js +++ b/static/js/filters.js @@ -601,14 +601,14 @@ function fi_toggle() { // Set focus on first textbox d.firstChild.nodeValue = LANG.fihide; c = (c.parentNode.tagName == 'FORM' ? c.parentNode : $WH.gE(c, 'form')[0]); - c = c.elements.na ? c.elements.na: c.elements.ti; + c = c.elements.na ? c.elements.na : c.elements.ti; c.focus(); c.select(); } else { d.firstChild.nodeValue = LANG.fishow; } - d.className = 'disclosure-' + (b ? 'on': 'off'); + d.className = 'disclosure-' + (b ? 'on' : 'off'); return false; }