diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/class/Opt.php | 42 | ||||
-rw-r--r-- | 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 @@ <thead> <tr> <?php if($user->issupereditor()) { ?><th id="checkall" class="hidephone">x</th> <?php } ?> - <th><a href="<?= $opt->getadress('id') ?>">id</a></th> + <th><a href="<?= $opt->sortbyorder('id') ?>">id</a></th> <th>edit</th> <th>see</th> <th class="delete" title="delete page">del</th> @@ -45,40 +45,41 @@ <th class="download hidephone" title="download page as json">dl</th> <?php } if ($columns['tag']) { ?> - <th class="tag"><a href="<?= $opt->getadress('tag') ?>">tag</a></th> + <th class="tag"><a href="<?= $opt->sortbyorder('tag') ?>">tag</a></th> <?php } if ($columns['title']) { ?> - <th class="title"><a href="<?= $opt->getadress('title') ?>">title</a></th> + <th class="title"><a href="<?= $opt->sortbyorder('title') ?>">title</a></th> <?php } if ($columns['description']) { ?> <th class="summary">summary</th> <?php } if ($columns['linkto']) { ?> - <th class="linkto"><a href="<?= $opt->getadress('linkto') ?>">to</a></th> + <th class="linkto"><a href="<?= $opt->sortbyorder('linkto') ?>">to</a></th> <?php } if ($columns['linkfrom']) { ?> - <th class="linkfrom"><a href="<?= $opt->getadress('linkfrom') ?>">from</a></th> + <th class="linkfrom"><a href="<?= $opt->sortbyorder('linkfrom') ?>">from</a></th> <?php } if ($columns['datemodif']) { ?> - <th class="datemodif"><a href="<?= $opt->getadress('datemodif') ?>">last modification</a></th> + <th class="datemodif"><a href="<?= $opt->sortbyorder('datemodif') ?>">last modification</a></th> <?php } if ($columns['datecreation']) { ?> - <th class="datecreation"><a href="<?= $opt->getadress('datecreation') ?>">date of creation</a></th> + <th class="datecreation"><a href="<?= $opt->sortbyorder('datecreation') ?>">date of creation</a></th> <?php } if ($columns['date']) { ?> - <th class="date"><a href="<?= $opt->getadress('date') ?>">date</a></th> + <th class="date"><a href="<?= $opt->sortbyorder('date') ?>">date</a></th> <?php } if ($columns['secure']) { ?> - <th class="secure"><a href="<?= $opt->getadress('secure') ?>">privacy</a></th> + <th class="secure"><a href="<?= $opt->sortbyorder('secure') ?>">privacy</a></th> <?php } + if ($columns['visitcount']) { ?> - <th class="visitcount"><a href="<?= $opt->getadress('visitcount') ?>">visit</a></th> + <th class="visitcount"><a href="<?= $opt->sortbyorder('visitcount') ?>">visit</a></th> <?php } if ($columns['editcount']) { ?> - <th class="editcount"><a href="<?= $opt->getadress('editcount') ?>">edit</a></th> + <th class="editcount"><a href="<?= $opt->sortbyorder('editcount') ?>">edit</a></th> <?php } if ($columns['affcount']) { ?> - <th class="affcount"><a href="<?= $opt->getadress('affcount') ?>">aff</a></th> + <th class="affcount"><a href="<?= $opt->sortbyorder('affcount') ?>">aff</a></th> <?php } ?> </tr> </thead> |