From f83b3a6860025dad7f0f81424ea4d8fbd3d93209 Mon Sep 17 00:00:00 2001 From: Miguel N Date: Fri, 29 Jan 2021 17:12:36 +0000 Subject: [PATCH] Updated linebreak processing --- app/Http/Controllers/ApplicationController.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/ApplicationController.php b/app/Http/Controllers/ApplicationController.php index e83bd90..3537a27 100755 --- a/app/Http/Controllers/ApplicationController.php +++ b/app/Http/Controllers/ApplicationController.php @@ -38,14 +38,14 @@ class ApplicationController extends Controller private function processOSLinebreaks(array $structuredResponses) { - $processedResponses = $structuredResponses; - - foreach ($structuredResponses as $responseKey => $response) + $processedResponses = $structuredResponses; + foreach ($structuredResponses as $field) { - // We can't use nl2br because it preserves the line breaks and doesn't include all line breaks used by other operating systems - $originalResponse = $response['response']; - $processedResponses[$responseKey]['response'] = str_replace(["\r\n", "\r", "\n"], "
", $originalResponse); - } + foreach($field as $fieldKey => $fieldData) + { + $originalResponse = $fieldData['response']; + $processedResponses['responses'][$fieldKey]['response'] = str_replace(["\r\n", "\r", "\n"], "
", $$ } + // We can't use nl2br because it preserves the line breaks and doesn't include all line breaks used by othe$ } return $processedResponses; } @@ -79,7 +79,7 @@ class ApplicationController extends Controller [ 'application' => $application, 'comments' => $application->comments, - 'structuredResponses' => json_decode($application->response->responseData, true), + 'structuredResponses' => $this->processOSLinebreaks(json_decode($application->response->responseData, true)), 'formStructure' => $application->response->form, 'vacancy' => $application->response->vacancy, 'canVote' => $this->canVote($application->votes),