split angeltype about view into different methods

This commit is contained in:
msquare 2016-11-09 18:05:00 +01:00
parent 0ba0ce207d
commit af9328f558
1 changed files with 31 additions and 19 deletions

View File

@ -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 = '<h2>' . $angeltype['name'] . '</h2>';
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 .= '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
}
$html .= '<hr />';
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) { function AngelTypes_about_view($angeltypes, $user_logged_in) {
global $faq_url; global $faq_url;
@ -275,25 +305,7 @@ function AngelTypes_about_view($angeltypes, $user_logged_in) {
]; ];
$parsedown = new Parsedown(); $parsedown = new Parsedown();
foreach ($angeltypes as $angeltype) { foreach ($angeltypes as $angeltype) {
$content[] = '<h2>' . $angeltype['name'] . '</h2>'; $content[] = AngelTypes_about_view_angeltype($angeltype);
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[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
}
$content[] = '<hr />';
} }
return page_with_title(_("Teams/Job description"), $content); return page_with_title(_("Teams/Job description"), $content);