From 20c44426207b8f58fd8ef1145b509913371b2901 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Sat, 30 Mar 2019 20:44:55 +0100 Subject: new feature : upload json as page --- app/class/controllerart.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'app/class/controllerart.php') diff --git a/app/class/controllerart.php b/app/class/controllerart.php index 4d7b1be..ce742a1 100644 --- a/app/class/controllerart.php +++ b/app/class/controllerart.php @@ -241,6 +241,29 @@ class Controllerart extends Controller } } + /** + * Import page and save it into the database + */ + public function upload() + { + $art = $this->artmanager->getfromfile(); + + if(!empty($_POST['id'])) { + $art->setid(idclean($_POST['id'])); + } + + if($_POST['datecreation']) { + $art->setdatecreation($this->now); + } + + if($art !== false) { + if($_POST['erase'] || $this->artmanager->get($art) === false) { + $this->artmanager->add($art); + } + } + $this->routedirect('home'); + } + public function delete($id) { $this->setart($id, 'artdelete'); -- cgit v1.2.3