diff options
Diffstat (limited to 'w/class/controllerart.php')
-rw-r--r-- | w/class/controllerart.php | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/w/class/controllerart.php b/w/class/controllerart.php index 064474a..340e8e5 100644 --- a/w/class/controllerart.php +++ b/w/class/controllerart.php @@ -4,19 +4,23 @@ class Controllerart extends Controllerdb { /** @var Art2 */ protected $art; - - - public function __construct($id) { - parent::__construct(); + protected $artmanager; + 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() { $art = $this->artmanager->get($this->art); - if($art !== false) { + if ($art !== false) { $this->art = $art; //$this->art->autotaglistupdate($this->artmanager->taglist($this->artmanager->getlister(['id', 'title', 'description', 'tag']), $this->art->autotaglist())); return true; @@ -32,20 +36,22 @@ class Controllerart extends Controllerdb $display = $this->user->level() >= $this->art->secure(); $cancreate = $this->user->cancreate(); - $this->showtemplate('read', ['art' => $this->art, 'artexist' => $artexist, 'display' => $display, 'cancreate' => $cancreate]); - + $renderbody = $this->renderengine->render($this->art); + + //$this->showtemplate('read', ['art' => $this->art, 'artexist' => $artexist, 'display' => $display, 'cancreate' => $cancreate]); + } public function edit() { - if($this->importart() && $this->user->canedit()) { + if ($this->importart() && $this->user->canedit()) { $this->showtemplate('edit', ['art' => $this->art, 'artexist' => true]); } else { $this->redirect('?id=' . $this->art->id()); } - + } public function log() @@ -63,25 +69,33 @@ class Controllerart extends Controllerdb public function delete() { - echo '<h2>Delete</h2>'; - $this->artmanager->delete($this->art); + if ($this->user->canedit() && $this->importart()) { + + if (isset($_POST['deleteconfirm']) && $_POST['deleteconfirm'] == true) { + $this->artmanager->delete($this->art); + $this->redirect('?id=' . $this->art->id()); + } else { + $this->showtemplate('delete', ['art' => $this->art, 'artexist' => true]); + } + } else { + $this->redirect('?id=' . $this->art->id()); + } } public function update() { - if($this->importart()) { + if ($this->importart() && $this->user->canedit()) { $this->art->hydrate($_POST); - } + $this->art->updateedited(); + $this->artmanager->update($this->art); - // $this->art->updatelinkfrom(); - // $this->art->autotaglistcalc($this->artmanager->taglist($this->artmanager->getlister(['id', 'title', 'tag']), $this->art->autotaglist())); - $this->artmanager->update($this->art); + } $this->redirect('?id=' . $this->art->id() . '&aff=edit'); - + } } |