aboutsummaryrefslogtreecommitdiff
path: root/w/class/controllerart.php
diff options
context:
space:
mode:
Diffstat (limited to 'w/class/controllerart.php')
-rw-r--r--w/class/controllerart.php41
1 files changed, 34 insertions, 7 deletions
diff --git a/w/class/controllerart.php b/w/class/controllerart.php
index 340e8e5..4abc572 100644
--- a/w/class/controllerart.php
+++ b/w/class/controllerart.php
@@ -5,16 +5,17 @@ class Controllerart extends Controllerdb
/** @var Art2 */
protected $art;
protected $artmanager;
- protected $renderengine;
-
+ protected $renderengine;
+
public function __construct($id)
{
parent::__construct();
-
-
+
+
$this->art = new Art2(['id' => $id]);
$this->artmanager = new Modelart();
$this->renderengine = new Modelrender();
+
}
public function importart()
@@ -31,14 +32,40 @@ class Controllerart extends Controllerdb
public function read()
{
+ $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
+
$artexist = $this->importart();
- $display = $this->user->level() >= $this->art->secure();
+ $canread = $this->user->level() >= $this->art->secure();
$cancreate = $this->user->cancreate();
+ $alerts = ['alertnotexist' => 'This page does not exist yet', 'alertprivate' => 'You cannot see this page'];
+ $body = '';
+ $head = '';
+
+
+ if ($artexist) {
+
+ if ($this->art->daterender() < $this->art->datemodif()) {
+ $body = $this->renderengine->renderbody($this->art);
+ $this->art->setrender($body);
+ $this->art->setdaterender($now);
+ $this->artmanager->update($this->art);
+ } else {
+ $body = $this->art->render();
+ }
+
+ $head = $this->renderengine->renderhead($this->art);
+
+ $this->art->addaffcount();
+ $this->artmanager->update($this->art);
+
+ }
+
+
+ $data = array_merge($alerts, ['art' => $this->art, 'artexist' => $artexist, 'canread' => $canread, 'cancreate' => $cancreate, 'readernav' => true, 'body' => $body, 'head' => $head]);
- $renderbody = $this->renderengine->render($this->art);
- //$this->showtemplate('read', ['art' => $this->art, 'artexist' => $artexist, 'display' => $display, 'cancreate' => $cancreate]);
+ $this->showtemplate('read', $data);