From cc73b11de5d9185825e058d1914d65bb8703077d Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Wed, 29 Jan 2020 03:03:53 +0100 Subject: refactor : opt getadress --- app/class/Opt.php | 42 ++++++++++++++++-------------------------- app/view/templates/home.php | 25 +++++++++++++------------ 2 files changed, 29 insertions(+), 38 deletions(-) diff --git a/app/class/Opt.php b/app/class/Opt.php index 60dfb65..426328f 100644 --- a/app/class/Opt.php +++ b/app/class/Opt.php @@ -9,7 +9,7 @@ class Opt extends Item protected $tagfilter = []; protected $tagcompare = 'AND'; protected $authorfilter = []; - protected $authorcompare = 'OR'; + protected $authorcompare = 'AND'; protected $secure = 4; protected $linkto = ['min' => '0', 'max' => '0']; protected $linkfrom = ['min' => '0', 'max' => '0']; @@ -85,34 +85,24 @@ class Opt extends Item } } - public function getadress(string $sortby = '') + public function getadress() { - if ($this->sortby === $sortby) { - $order = $this->order * -1; - } else { - $order = $this->order; - } - if(empty($sortby)) { - $sortby = $this->sortby; - } - $adress = '?sortby=' . $sortby; - $adress .= '&order=' . $order; - $adress .= '&secure=' . $this->secure; - $adress .= '&tagcompare=' . $this->tagcompare; - foreach ($this->tagfilter as $tag) { - $adress .= '&tagfilter[]=' . $tag; - } - $adress .= '&authorcompare=' . $this->authorcompare; - foreach ($this->authorfilter as $author) { - $adress .= '&authorfilter[]=' . $author; - } - if ($this->invert == 1) { - $adress .= '&invert=1'; + $object = $this->drylist(['sortby', 'order', 'secure', 'tagfilter', 'tagcompare', 'authorcompare', 'author', 'invert', 'limit']); + $object['submit'] = 'filter'; + + return '?' . urldecode(http_build_query($object)); + } + + public function sortbyorder($sortby = "") + { + $object = $this->drylist(['sortby', 'order', 'secure', 'tagfilter', 'tagcompare', 'authorcompare', 'author', 'invert', 'limit']); + if(!empty($sortby)) { + $object['sortby'] = $sortby; } - $adress.= '&limit=' .$this->limit; - $adress .= '&submit=filter'; + $object['order'] = $object['order'] * -1; + $object['submit'] = 'filter'; - return $adress; + return '?' . urldecode(http_build_query($object)); } /** diff --git a/app/view/templates/home.php b/app/view/templates/home.php index 7aa3e69..73a00eb 100644 --- a/app/view/templates/home.php +++ b/app/view/templates/home.php @@ -37,7 +37,7 @@ issupereditor()) { ?>x - id + id edit see del @@ -45,40 +45,41 @@ dl - tag + tag - title + title summary - to + to - from + from - last modification + last modification - date of creation + date of creation - date + date - privacy + privacy - visit + visit - edit + edit - aff + aff -- cgit v1.2.3