From 1966379c5699100a8134c89c911be0a5e85b0a63 Mon Sep 17 00:00:00 2001 From: Shaswat Ganisshan Date: Fri, 8 Mar 2024 18:06:41 -0500 Subject: [PATCH 1/2] Created JSON Schema to print Notices --- tools/docker-dev/unity-web-portal | 1 + webroot/api/notices/index.php | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) create mode 160000 tools/docker-dev/unity-web-portal diff --git a/tools/docker-dev/unity-web-portal b/tools/docker-dev/unity-web-portal new file mode 160000 index 0000000..7087b78 --- /dev/null +++ b/tools/docker-dev/unity-web-portal @@ -0,0 +1 @@ +Subproject commit 7087b78718a64185ea1ebaf615f4a8b395f39267 diff --git a/webroot/api/notices/index.php b/webroot/api/notices/index.php index 07b8a20..e8c5576 100644 --- a/webroot/api/notices/index.php +++ b/webroot/api/notices/index.php @@ -11,14 +11,15 @@ } $notices = $SQL->getNotices(); +$jsonArray = []; foreach ($notices as $notice) { - echo $notice["title"] . "\r\n"; - echo date('m-d-Y', strtotime($notice["date"])) . "\r\n"; - - $lineArr = explode("\r\n", wordwrap($notice["message"], $CHAR_WRAP)); - foreach ($lineArr as $line) { - echo $line; - } - - echo "\r\n\r\n"; + $formattedNotice = [ + "title" => $notice["title"], + "date" => date('m-d-Y', strtotime($notice["date"])), + "message" => wordwrap($notice["message"], $CHAR_WRAP) + ]; + $jsonArray[] = $formattedNotice; } + +$jsonOutput = json_encode($jsonArray, JSON_PRETTY_PRINT); +echo $jsonOutput; From 98d6b4568ff9f725a05820674a9469ecf6534860 Mon Sep 17 00:00:00 2001 From: Shaswat Ganisshan Date: Thu, 30 May 2024 22:19:19 -0400 Subject: [PATCH 2/2] removed wordwrap --- webroot/api/notices/index.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/webroot/api/notices/index.php b/webroot/api/notices/index.php index e8c5576..3ccdbb8 100644 --- a/webroot/api/notices/index.php +++ b/webroot/api/notices/index.php @@ -4,19 +4,13 @@ require_once "../../../resources/autoload.php"; -if (isset($_GET["line_wrap"])) { - $CHAR_WRAP = $_GET["line_wrap"]; -} else { - $CHAR_WRAP = 80; -} - $notices = $SQL->getNotices(); $jsonArray = []; foreach ($notices as $notice) { $formattedNotice = [ "title" => $notice["title"], "date" => date('m-d-Y', strtotime($notice["date"])), - "message" => wordwrap($notice["message"], $CHAR_WRAP) + "message" => $notice["message"] ]; $jsonArray[] = $formattedNotice; }