diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2018-10-28 19:56:27 +0100 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2018-10-28 19:56:27 +0100 |
commit | e17392e46259e6f2e012017987cf7c31c171488f (patch) | |
tree | 72b61b63e32819e81433e8df6f14dc92b0e3a604 /w/class/controllerart.php | |
parent | a91c916248f967da2d4218b575e665242b7c975b (diff) | |
download | wcms-e17392e46259e6f2e012017987cf7c31c171488f.tar.gz wcms-e17392e46259e6f2e012017987cf7c31c171488f.zip |
abstract config NWY
Diffstat (limited to 'w/class/controllerart.php')
-rw-r--r-- | w/class/controllerart.php | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/w/class/controllerart.php b/w/class/controllerart.php index 8754a20..301c9ab 100644 --- a/w/class/controllerart.php +++ b/w/class/controllerart.php @@ -9,9 +9,6 @@ class Controllerart extends Controllerdb public function __construct($id) { parent::__construct(); - - //echo '<h1>Article</h1>'; - //echo $id; $this->art = new Art2(['id' => $id]); } @@ -20,12 +17,10 @@ class Controllerart extends Controllerdb { if($this->artmanager->exist($this->art->id())) { $this->art = $this->artmanager->get($this->art); - //var_dump($this->art); $this->art->autotaglistupdate($this->artmanager->taglist($this->artmanager->getlister(['id', 'title', 'description', 'tag']), $this->art->autotaglist())); return true; } else { - echo '<h3>Article does not exist yet.</h3>'; return false; } } @@ -33,28 +28,32 @@ class Controllerart extends Controllerdb public function read() { - if($this->importart()) { - if($this->user->level() >= $this->art->secure()) { - $datas = $this->art->templaterender(['id', 'title', 'description', 'javascript', 'html', 'header', 'nav', 'aside', 'section', 'footer']); - echo $this->templates->render('reader', $datas); - } else { - echo '<h3>Not enought right to see the article</h3>'; - } + $artexist = $this->importart(); + $display = $this->user->level() >= $this->art->secure(); + $cancreate = $this->user->cancreate(); - } + $this->showtemplate('read', ['art' => $this->art, 'artexist' => $artexist, 'display' => $display, 'cancreate' => $cancreate]); + } public function edit() { - echo '<h2>Edit</h2>'; - if($this->importart()) { - // vue edit art + if($this->importart() && $this->user->canedit()) { + $this->showtemplate('edit', ['art' => $this->art, 'artexist' => true]); + } else { + $this->redirect('?id=' . $this->art->id()); } } + public function log() + { + $this->importart(); + var_dump($this->art); + } + public function add() { echo '<h2>Add</h2>'; @@ -70,15 +69,20 @@ class Controllerart extends Controllerdb $this->artmanager->delete($this->art); } - public function update($id, $redir= "home") + public function update() { - echo '<h2>Update</h2>'; - $this->art = new Art2($_POST); - $this->art->updatelinkfrom(); - $this->art->autotaglistcalc($this->artmanager->taglist($this->artmanagergetlister(['id', 'title', 'tag']), $this->art->autotaglist())); + + if($this->importart()) { + $this->art->hydrate($_POST); + } + + // $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'); + } |