aboutsummaryrefslogtreecommitdiff
path: root/app/class
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2020-02-12 20:20:06 +0100
committervincent-peugnet <v.peugnet@free.fr>2020-02-12 20:20:06 +0100
commit0893f20446a6645c5f928f2cb41f688a9fc5fcf1 (patch)
tree41724d5567d70e360eb432c9c9413365be16772e /app/class
parente32f2f1749c691f6c778261a8f8d300573895345 (diff)
downloadwcms-0893f20446a6645c5f928f2cb41f688a9fc5fcf1.tar.gz
wcms-0893f20446a6645c5f928f2cb41f688a9fc5fcf1.zip
refactoring home>desktop, fix #47
Diffstat (limited to 'app/class')
-rw-r--r--app/class/Controllerhome.php67
-rw-r--r--app/class/Routes.php1
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'],