From 94881f499b82a1b7b8e32139ad0919f84793ce08 Mon Sep 17 00:00:00 2001 From: Andreas Date: Wed, 18 Sep 2019 18:03:21 +0200 Subject: [PATCH] fleshing out json output feature --- dev_mvc/controller/MVCController.php | 3 +++ dev_mvc/controller/TestUtils.php | 7 ++++++- dev_mvc/index.php | 6 ++---- dev_mvc/model/testactions/model_createdb.php | 3 +-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/dev_mvc/controller/MVCController.php b/dev_mvc/controller/MVCController.php index d21c76d..e496d16 100644 --- a/dev_mvc/controller/MVCController.php +++ b/dev_mvc/controller/MVCController.php @@ -67,8 +67,11 @@ class MVCController{ //check if testaction is valid if(file_exists($this->testaction)){ + + echo('"output": ['); //execute testaction include_once($this->testaction); + echo("]"); } } diff --git a/dev_mvc/controller/TestUtils.php b/dev_mvc/controller/TestUtils.php index a73bc51..2aa3812 100644 --- a/dev_mvc/controller/TestUtils.php +++ b/dev_mvc/controller/TestUtils.php @@ -4,11 +4,16 @@ class TestUtils{ public static $log = []; public static $status; - public static function log($output, $status = "OK"){ + public static function log($output, $status = "OK",$addComma = false){ $loginput = []; $loginput['message'] = $output; $loginput['status'] = $status; echo(json_encode($loginput)); + if($addComma){ + echo(','); + } + echo("\n"); + return; } public static function returnLog(){ echo(json_encode(self::$log)); diff --git a/dev_mvc/index.php b/dev_mvc/index.php index c40b3ed..b6bf263 100644 --- a/dev_mvc/index.php +++ b/dev_mvc/index.php @@ -1,8 +1,5 @@ executeModel(); if(!isset($_POST['testaction'])){ include_once("./view/content_pagetemplate.php"); } + ?> \ No newline at end of file diff --git a/dev_mvc/model/testactions/model_createdb.php b/dev_mvc/model/testactions/model_createdb.php index de2787e..77e0906 100644 --- a/dev_mvc/model/testactions/model_createdb.php +++ b/dev_mvc/model/testactions/model_createdb.php @@ -1,5 +1,5 @@