From f9e577352dd31f2846c3a340a1de82dd73961568 Mon Sep 17 00:00:00 2001 From: Philip Häusler Date: Sat, 23 Aug 2014 19:15:10 +0200 Subject: remove html templates --- includes/pages/admin_questions.php | 52 +++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 20 deletions(-) (limited to 'includes/pages/admin_questions.php') diff --git a/includes/pages/admin_questions.php b/includes/pages/admin_questions.php index 8bdde714..1b4b9970 100644 --- a/includes/pages/admin_questions.php +++ b/includes/pages/admin_questions.php @@ -20,24 +20,26 @@ function admin_questions() { global $user; if (! isset($_REQUEST['action'])) { - $open_questions = ""; + $unanswered_questions_table = array(); $questions = sql_select("SELECT * FROM `Questions` WHERE `AID` IS NULL"); foreach ($questions as $question) { $user_source = User($question['UID']); if ($user_source === false) engelsystem_error("Unable to load user."); - $open_questions .= template_render('../templates/admin_question_unanswered.html', array( - 'question_nick' => User_Nick_render($user_source), - 'question_id' => $question['QID'], - 'link' => page_link_to("admin_questions"), - 'question' => str_replace("\n", '
', $question['Question']) - )); + $unanswered_questions_table[] = array( + 'from' => User_Nick_render($user_source), + 'question' => str_replace("\n", "
", $question['Question']), + 'answer' => form(array( + form_textarea('answer', _("Answer"), ''), + form_submit('submit', _("Save")) + ), page_link_to('admin_questions') . '&action=answer&id=' . $question['QID']), + 'actions' => button(page_link_to("admin_questions") . '&action=delete&id=' . $question['QID'], _("delete"), 'btn-xs') + ); } - $answered_questions = ""; + $answered_questions_table = array(); $questions = sql_select("SELECT * FROM `Questions` WHERE NOT `AID` IS NULL"); - foreach ($questions as $question) { $user_source = User($question['UID']); if ($user_source === false) @@ -46,21 +48,31 @@ function admin_questions() { $answer_user_source = User($question['AID']); if ($answer_user_source === false) engelsystem_error("Unable to load user."); - - $answered_questions .= template_render('../templates/admin_question_answered.html', array( - 'question_id' => $question['QID'], - 'question_nick' => User_Nick_render($user_source), + $answered_questions_table[] = array( + 'from' => User_Nick_render($user_source), 'question' => str_replace("\n", "
", $question['Question']), - 'answer_nick' => User_Nick_render($answer_user_source), + 'answered_by' => User_Nick_render($answer_user_source), 'answer' => str_replace("\n", "
", $question['Answer']), - 'link' => page_link_to("admin_questions") - )); + 'actions' => button(page_link_to("admin_questions") . '&action=delete&id=' . $question['QID'], _("delete"), 'btn-xs') + ); } - return template_render('../templates/admin_questions.html', array( - 'link' => page_link_to("admin_questions"), - 'open_questions' => $open_questions, - 'answered_questions' => $answered_questions + return page_with_title(admin_questions_title(), array( + '

' . _("Unanswered questions") . '

', + table(array( + 'from' => _("From"), + 'question' => _("Question"), + 'answer' => _("Answer"), + 'actions' => '' + ), $unanswered_questions_table), + '

' . _("Answered questions") . '

', + table(array( + 'from' => _("From"), + 'question' => _("Question"), + 'answered_by' => _("Answered by"), + 'answer' => _("Answer"), + 'actions' => '' + ), $answered_questions_table) )); } else { switch ($_REQUEST['action']) { -- cgit v1.2.3-54-g00ecf