Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created JSON Schema to print Notices #103

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tools/docker-dev/unity-web-portal
Submodule unity-web-portal added at 7087b7
19 changes: 10 additions & 9 deletions webroot/api/notices/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to wordwrap in JSON output since that will be handled by whatever is calling the API. Just add the message body directly here.

Suggested change
"message" => wordwrap($notice["message"], $CHAR_WRAP)
"message" => $notice["message"]

Also remove any entries of $CHAR_WRAP from the rest of the file.

];
$jsonArray[] = $formattedNotice;
}

$jsonOutput = json_encode($jsonArray, JSON_PRETTY_PRINT);
echo $jsonOutput;
Loading