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/modelart.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'app/class/modelart.php') diff --git a/app/class/modelart.php b/app/class/modelart.php index e9d4b86..f5b4858 100644 --- a/app/class/modelart.php +++ b/app/class/modelart.php @@ -63,6 +63,31 @@ class Modelart extends Modeldb } } + /** + * Transform File to Art2 Oject + * + * @return false|Art2 + */ + public function getfromfile() + { + if(!isset($_FILES['pagefile']) || $_FILES['pagefile']['error'] > 0 ) return false; + + $ext = substr(strrchr($_FILES['pagefile']['name'],'.'),1); + if($ext !== 'json') return false; + + $files = $_FILES; + + $json = file_get_contents($_FILES['pagefile']['tmp_name']); + $pagedata = json_decode($json, true); + + if($pagedata === false) return false; + + $page = new Art2($pagedata); + + return $page; + + } + public function getartelement($id, $element) { if (in_array($element, Model::TEXT_ELEMENTS)) { -- cgit v1.2.3