aboutsummaryrefslogtreecommitdiff
path: root/app/class/Controllerhome.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/class/Controllerhome.php')
-rw-r--r--app/class/Controllerhome.php67
1 files changed, 45 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
*/