From cb6f0e8c3f2abe2bf895320a58a466c7a766dbf9 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Mon, 10 Feb 2020 10:59:49 +0100 Subject: deep search bar close #53 --- app/class/Controllerhome.php | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'app/class/Controllerhome.php') diff --git a/app/class/Controllerhome.php b/app/class/Controllerhome.php index c7d1792..2fa06fb 100644 --- a/app/class/Controllerhome.php +++ b/app/class/Controllerhome.php @@ -22,7 +22,7 @@ class Controllerhome extends Controllerpage public function desktop() { - if ($this->user->isvisitor() && Config::homepage() === 'redirect' && Config::homeredirect() !== null) { + if ($this->user->isvisitor() && Config::homepage() === 'redirect' && !empty(Config::homeredirect())) { $this->routedirect('pageread/', ['page' => Config::homeredirect()]); } else { @@ -30,13 +30,30 @@ class Controllerhome extends Controllerpage $table = $this->modelhome->getlister(); $this->opt = $this->modelhome->optinit($table); - $colors = new Colors($this->opt->taglist()); + $vars['colors'] = new Colors($this->opt->taglist()); + if (!isset($_GET['search'])) { + $searchopt = ['title' => 1, 'description' => 1, 'content' => 1, 'other' => 0]; + } else { + $searchopt['title'] = $_GET['title'] ?? 0; + $searchopt['description'] = $_GET['description'] ?? 0; + $searchopt['content'] = $_GET['content'] ?? 0; + $searchopt['other'] = $_GET['other'] ?? 0; - $table2 = $this->modelhome->table2($table, $this->opt); + } + $regex = $_GET['search'] ?? ''; + + $vars['table2'] = $this->modelhome->table2($table, $this->opt, $regex , $searchopt); + + $vars['columns'] = $this->modelhome->setcolumns($this->user->columns()); - $columns = $this->modelhome->setcolumns($this->user->columns()); + $vars['faviconlist'] = $this->mediamanager->listfavicon(); + $vars['thumbnaillist'] = $this->mediamanager->listthumbnail(); + $vars['editorlist'] = $this->usermanager->getlisterbylevel(2, '>='); + $vars['user'] = $this->user; + $vars['opt'] = $this->opt; + $vars['deepsearch'] = $regex; + $vars['searchopt'] = $searchopt; - $vars = ['user' => $this->user, 'table2' => $table2, 'opt' => $this->opt, 'columns' => $columns, 'faviconlist' => $this->mediamanager->listfavicon(), 'thumbnaillist' => $this->mediamanager->listthumbnail(), 'editorlist' => $this->usermanager->getlisterbylevel(2, '>='), 'colors' => $colors]; $vars['footer'] = ['version' => getversion(), 'total' => count($table), 'database' => Config::pagetable()]; if (isset($_POST['query']) && $this->user->iseditor()) { -- cgit v1.2.3