aboutsummaryrefslogtreecommitdiff
path: root/app/class/Opt.php
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2020-01-29 03:03:53 +0100
committervincent-peugnet <v.peugnet@free.fr>2020-01-29 03:03:53 +0100
commitcc73b11de5d9185825e058d1914d65bb8703077d (patch)
treece300b83bf8e5d0b6f1586242f1cd4d34ed9faf8 /app/class/Opt.php
parent64ac1605b6fe8e997134dd57cc30f30b99ebc076 (diff)
downloadwcms-cc73b11de5d9185825e058d1914d65bb8703077d.tar.gz
wcms-cc73b11de5d9185825e058d1914d65bb8703077d.zip
refactor : opt getadress
Diffstat (limited to 'app/class/Opt.php')
-rw-r--r--app/class/Opt.php42
1 files changed, 16 insertions, 26 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));
}
/**