From e16e0b2644172f098956f6c970e86581e2e758c1 Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Tue, 3 Dec 2019 20:09:45 +0100 Subject: Migrate Question usages --- includes/view/Questions_view.php | 51 +++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 16 deletions(-) (limited to 'includes/view') diff --git a/includes/view/Questions_view.php b/includes/view/Questions_view.php index 4d57edf9..a4c3a452 100644 --- a/includes/view/Questions_view.php +++ b/includes/view/Questions_view.php @@ -1,27 +1,46 @@ 'delete', 'id' => $question['QID']])); - $question['Question'] = nl2br(htmlspecialchars($question['Question'])); - } + $open_questions = array_map( + static function (Question $question): array { + return [ + 'actions' => form( + [ + form_submit('submit', __('delete'), 'btn-default btn-xs') + ], + page_link_to('user_questions', ['action' => 'delete', 'id' => $question->id]) + ), + 'Question' => nl2br(htmlspecialchars($question->text)), + ]; + }, + $open_questions + ); - foreach ($answered_questions as &$question) { - $question['Question'] = nl2br(htmlspecialchars($question['Question'])); - $question['Answer'] = nl2br(htmlspecialchars($question['Answer'])); - $question['actions'] = form([ - form_submit('submit', __('delete'), 'btn-default btn-xs') - ], page_link_to('user_questions', ['action' => 'delete', 'id' => $question['QID']])); - } + $answered_questions = array_map( + static function (Question $question): array { + return [ + 'Question' => nl2br(htmlspecialchars($question->text)), + 'Answer' => nl2br(htmlspecialchars($question->answer)), + 'answer_user' => User_Nick_render($question->answerer), + 'actions' => form( + [ + form_submit('submit', __('delete'), 'btn-default btn-xs') + ], + page_link_to('user_questions', ['action' => 'delete', 'id' => $question->id]) + ), + ]; + }, + $answered_questions + ); return page_with_title(questions_title(), [ msg(), -- cgit v1.2.3-54-g00ecf