diff options
-rw-r--r-- | app/class/Controllerhome.php | 67 | ||||
-rw-r--r-- | app/class/Routes.php | 1 |
2 files changed, 46 insertions, 22 deletions
diff --git a/app/class/Controllerhome.php b/app/class/Controllerhome.php index 5a9110a..42ace87 100644 --- a/app/class/Controllerhome.php +++ b/app/class/Controllerhome.php @@ -27,23 +27,14 @@ class Controllerhome extends Controllerpage } else { - $table = $this->modelhome->getlister(); - $this->opt = $this->modelhome->optinit($table); + $pagelist = $this->modelhome->getlister(); + $this->opt = $this->modelhome->optinit($pagelist); $vars['colors'] = new Colors($this->opt->taglist()); - if (!isset($_GET['search'])) { - $searchopt = ['title' => 1, 'description' => 1, 'content' => 1, 'other' => 0, 'casesensitive' => 0]; - } else { - $searchopt['title'] = $_GET['title'] ?? 0; - $searchopt['description'] = $_GET['description'] ?? 0; - $searchopt['content'] = $_GET['content'] ?? 0; - $searchopt['other'] = $_GET['other'] ?? 0; - $searchopt['casesensitive'] = $_GET['case'] ?? 0; - } - $regex = $_GET['search'] ?? ''; + $deepsearch = $this->deepsearch(); - $vars['table2'] = $this->modelhome->table2($table, $this->opt, $regex , $searchopt); + $vars['table2'] = $this->modelhome->table2($pagelist, $this->opt, $deepsearch['regex'] , $deepsearch['searchopt']); $vars['columns'] = $this->modelhome->setcolumns($this->user->columns()); @@ -52,22 +43,49 @@ class Controllerhome extends Controllerpage $vars['editorlist'] = $this->usermanager->getlisterbylevel(2, '>='); $vars['user'] = $this->user; $vars['opt'] = $this->opt; - $vars['deepsearch'] = $regex; - $vars['searchopt'] = $searchopt; + $vars['deepsearch'] = $deepsearch['regex']; + $vars['searchopt'] = $deepsearch['searchopt']; - $vars['footer'] = ['version' => getversion(), 'total' => count($table), 'database' => Config::pagetable()]; + $vars['footer'] = ['version' => getversion(), 'total' => count($pagelist), 'database' => Config::pagetable()]; - if (isset($_POST['query']) && $this->user->iseditor()) { - $datas = array_merge($_POST, $_SESSION['opt']); - $this->optlist = $this->modelhome->Optlistinit($table); - $this->optlist->hydrate($datas); - $vars['optlist'] = $this->optlist; - } + $this->listquery($pagelist); + + $vars['optlist'] = $this->optlist ?? null; $this->showtemplate('home', $vars); } } + /** + * Look for GET deepsearch datas and transform it an array + * + * @return array containing `string $regex` and `array $searchopt` + */ + public function deepsearch() : array + { + if (!isset($_GET['search'])) { + $searchopt = ['title' => 1, 'description' => 1, 'content' => 1, 'other' => 0, 'casesensitive' => 0]; + } else { + $searchopt['title'] = $_GET['title'] ?? 0; + $searchopt['description'] = $_GET['description'] ?? 0; + $searchopt['content'] = $_GET['content'] ?? 0; + $searchopt['other'] = $_GET['other'] ?? 0; + $searchopt['casesensitive'] = $_GET['case'] ?? 0; + } + $regex = $_GET['search'] ?? ''; + return ['regex' => $regex, 'searchopt' => $searchopt]; + } + + public function listquery(array $pagelist) + { + if (isset($_POST['query']) && $this->user->iseditor()) { + $datas = array_merge($_POST, $_SESSION['opt']); + $this->optlist = $this->modelhome->Optlistinit($pagelist); + $this->optlist->hydrate($datas); + $vars['optlist'] = $this->optlist; + } + } + public function columns() { if (isset($_POST['columns']) && $this->user->iseditor()) { @@ -110,6 +128,11 @@ class Controllerhome extends Controllerpage } } + public function map() + { + + } + /** * Render every pages in the database */ diff --git a/app/class/Routes.php b/app/class/Routes.php index e71bf59..c538d78 100644 --- a/app/class/Routes.php +++ b/app/class/Routes.php @@ -19,6 +19,7 @@ class Routes $router->addRoutes([ ['GET', '/', 'Controllerhome#desktop', 'home'], ['POST', '/', 'Controllerhome#desktop', 'homequery'], + ['GET', '/map', 'Controllerhome#map', 'map'], ['POST', '/columns', 'Controllerhome#columns', 'homecolumns'], ['POST', '/colors', 'Controllerhome#colors', 'homecolors'], ['GET', '//renderall', 'Controllerhome#renderall', 'homerenderall'], |