From af9328f5585a8ab38ae4044e4b8c11d874b6e99c Mon Sep 17 00:00:00 2001 From: msquare Date: Wed, 9 Nov 2016 18:05:00 +0100 Subject: split angeltype about view into different methods --- includes/view/AngelTypes_view.php | 50 ++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 19 deletions(-) (limited to 'includes/view/AngelTypes_view.php') diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php index dbeabe95..db21efda 100644 --- a/includes/view/AngelTypes_view.php +++ b/includes/view/AngelTypes_view.php @@ -260,6 +260,36 @@ function AngelTypes_list_view($angeltypes, $admin_angeltypes) { ]); } +/** + * Renders the about info for an angeltype. + */ +function AngelTypes_about_view_angeltype($angeltype) { + $html = '

' . $angeltype['name'] . '

'; + + if (isset($angeltype['user_angeltype_id'])) { + $buttons = []; + if ($angeltype['user_angeltype_id'] != null) { + $buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'], _("leave"), 'cancel'); + } else { + $buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add'); + } + $html .= buttons($buttons); + } + + if ($angeltype['restricted']) { + $html .= info(_("This angeltype is restricted by double-opt-in by a team coordinator. Please show up at the according introduction meetings."), true); + } + if ($angeltype['description'] != "") { + $html .= '
' . $parsedown->parse($angeltype['description']) . '
'; + } + $html .= '
'; + + return $html; +} + +/** + * Renders a site that contains every angeltype and its description, basically as an overview of the needed help types. + */ function AngelTypes_about_view($angeltypes, $user_logged_in) { global $faq_url; @@ -275,25 +305,7 @@ function AngelTypes_about_view($angeltypes, $user_logged_in) { ]; $parsedown = new Parsedown(); foreach ($angeltypes as $angeltype) { - $content[] = '

' . $angeltype['name'] . '

'; - - if (isset($angeltype['user_angeltype_id'])) { - $buttons = []; - if ($angeltype['user_angeltype_id'] != null) { - $buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'], _("leave"), 'cancel'); - } else { - $buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add'); - } - $content[] = buttons($buttons); - } - - if ($angeltype['restricted']) { - $content[] = info(_("This angeltype is restricted by double-opt-in by a team coordinator. Please show up at the according introduction meetings."), true); - } - if ($angeltype['description'] != "") { - $content[] = '
' . $parsedown->parse($angeltype['description']) . '
'; - } - $content[] = '
'; + $content[] = AngelTypes_about_view_angeltype($angeltype); } return page_with_title(_("Teams/Job description"), $content); -- cgit v1.2.3-54-g00ecf