aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2019-01-29 13:39:28 +0100
committervincent-peugnet <v.peugnet@free.fr>2019-01-29 13:39:28 +0100
commit5e1ca86211da0439003303cf3e0741edf31bced4 (patch)
tree99fb2548f6eab18b510c9e5850af2459b05d1401 /app
parentbd2ddfda3a922766ea2165963f2b2386066deeb2 (diff)
downloadwcms-5e1ca86211da0439003303cf3e0741edf31bced4.tar.gz
wcms-5e1ca86211da0439003303cf3e0741edf31bced4.zip
home redirect
Diffstat (limited to 'app')
-rw-r--r--app/class/config.php28
-rw-r--r--app/class/controllerconnect.php2
-rw-r--r--app/class/controllerhome.php25
-rw-r--r--app/class/model.php3
-rw-r--r--app/view/templates/admin.php32
-rw-r--r--app/view/templates/connect.php6
6 files changed, 84 insertions, 12 deletions
diff --git a/app/class/config.php b/app/class/config.php
index 39c8f12..00c03ae 100644
--- a/app/class/config.php
+++ b/app/class/config.php
@@ -20,6 +20,8 @@ abstract class Config
protected static $internallinkblank = false;
protected static $reccursiverender = true;
protected static $defaultprivacy = 0;
+ protected static $homepage = 'default';
+ protected static $homeredirect = null;
// _______________________________________ F U N _______________________________________
@@ -156,6 +158,16 @@ abstract class Config
return self::$defaultprivacy;
}
+ public static function homepage()
+ {
+ return self::$homepage;
+ }
+
+ public static function homeredirect()
+ {
+ return self::$homeredirect;
+ }
+
// __________________________________________ S E T ______________________________________
@@ -268,6 +280,22 @@ abstract class Config
self::$defaultprivacy = $defaultprivacy;
}
}
+
+ public static function sethomepage($homepage)
+ {
+ if(in_array($homepage, Model::HOMEPAGE)) {
+ self::$homepage = $homepage;
+ }
+ }
+
+ public static function sethomeredirect($homeredirect)
+ {
+ if(is_string($homeredirect) && strlen($homeredirect) > 0) {
+ self::$homeredirect = idclean($homeredirect);
+ } else {
+ self::$homeredirect = null;
+ }
+ }
diff --git a/app/class/controllerconnect.php b/app/class/controllerconnect.php
index d6aa7a2..fb43d4c 100644
--- a/app/class/controllerconnect.php
+++ b/app/class/controllerconnect.php
@@ -23,7 +23,7 @@ class Controllerconnect extends Controller
$artupdate['route'] = 'artedit';
$artupdate['id'] = $_SESSION['artupdate']['id'];
} else {
- $artupdate = [$route = 'home'];
+ $artupdate = ['route' => 'home'];
}
$this->showtemplate('connect', $artupdate);
}
diff --git a/app/class/controllerhome.php b/app/class/controllerhome.php
index cc2850f..043ac3e 100644
--- a/app/class/controllerhome.php
+++ b/app/class/controllerhome.php
@@ -16,17 +16,22 @@ class Controllerhome extends Controller
public function desktop()
{
+ if($this->user->isvisitor() && Config::homepage() === 'redirect' && Config::homeredirect() !== null) {
+ $this->routedirect('artread/', ['art' => Config::homeredirect()]);
+ } else {
- $table = $this->modelhome->getlister();
- $this->opt = $this->modelhome->optinit($table);
-
- $table2 = $this->modelhome->table2($table, $this->opt);
-
- $columns = $this->modelhome->setcolumns($this->user->columns());
-
- $this->showtemplate('home', ['user' => $this->user, 'table2' => $table2, 'opt' =>$this->opt, 'columns' => $columns]);
-
-
+
+ $table = $this->modelhome->getlister();
+ $this->opt = $this->modelhome->optinit($table);
+
+ $table2 = $this->modelhome->table2($table, $this->opt);
+
+ $columns = $this->modelhome->setcolumns($this->user->columns());
+
+ $this->showtemplate('home', ['user' => $this->user, 'table2' => $table2, 'opt' =>$this->opt, 'columns' => $columns]);
+
+
+ }
}
public function columns()
diff --git a/app/class/model.php b/app/class/model.php
index 779fb46..c8f251f 100644
--- a/app/class/model.php
+++ b/app/class/model.php
@@ -30,6 +30,9 @@ abstract class Model
const RENDER_CLASS_ORIGIN = false;
const RENDER_EMPTY_ELEMENT = false;
+ /** CONFIG OPTIONS */
+ const HOMEPAGE = ['default', 'search', 'redirect'];
+
public static function dirtopath($dir)
{
$basepath = '';
diff --git a/app/view/templates/admin.php b/app/view/templates/admin.php
index 605063b..bd37464 100644
--- a/app/view/templates/admin.php
+++ b/app/view/templates/admin.php
@@ -16,6 +16,38 @@
<input type="submit" value="Update configuration">
+ <h2>Home page</h2>
+
+ <p>Here you can set the home-page view for visitors.</p>
+
+ <div class="radio">
+ <input type="radio" name="homepage" value="default" id="default" <?= Config::homepage() === 'default' ? 'checked' : '' ?>>
+ <label for="default">default</label>
+ </div>
+
+ <div class="radio">
+ <input type="radio" name="homepage" value="search" id="searchbar" <?= Config::homepage() === 'search' ? 'checked' : '' ?>>
+ <label for="searchbar">search bar</label>
+ </div>
+
+ <div class="radio">
+ <input type="radio" name="homepage" value="redirect" id="redirect" <?= Config::homepage() === 'redirect' ? 'checked' : '' ?>>
+ <label for="redirect">redirect to page</label>
+ </div>
+
+ <select name="homeredirect" id="homeredirect">
+ <option value="" <?= Config::homeredirect() === null ? 'selected' : '' ?>>--select page to redirect--</option>
+
+ <?php
+ foreach ($artlist as $art) {
+ ?>
+ <option value="<?= $art ?>" <?= Config::homeredirect() === $art ? 'selected' : '' ?>><?= $art ?></option>
+ <?php
+ }
+
+
+ ?>
+ </select>
<h2>Page creation</h2>
diff --git a/app/view/templates/connect.php b/app/view/templates/connect.php
index 5d7ee5c..608a557 100644
--- a/app/view/templates/connect.php
+++ b/app/view/templates/connect.php
@@ -15,7 +15,11 @@
<form action="<?= $this->url('log') ?>" method="post">
<input type="hidden" name="route" value="<?= $route ?>">
-<input type="hidden" name="id" value="<?= $id ?>">
+<?php
+if(in_array($route, ['artedit', 'artread', 'artread/'])) {
+ echo '<input type="hidden" name="id" value="'. $id .'">';
+}
+?>
<input type="password" name="pass" id="loginpass" placeholder="password">
<input name="log" type="submit" value="login">
</form>