From 952c7892f3ac7bfadf8419062e44ff1af66ecc57 Mon Sep 17 00:00:00 2001 From: Bot Date: Mon, 25 Dec 2017 23:12:52 +0100 Subject: Formatting & Docstrings --- includes/view/AngelTypes_view.php | 85 ++++++++------- includes/view/EventConfig_view.php | 11 +- includes/view/PublicDashboard_view.php | 28 +++-- includes/view/Rooms_view.php | 38 ++++--- includes/view/ShiftCalendarLane.php | 2 + includes/view/ShiftCalendarRenderer.php | 16 ++- includes/view/ShiftCalendarShiftRenderer.php | 44 ++++++-- includes/view/ShiftEntry_view.php | 153 +++++++++++++++++---------- includes/view/Shifts_view.php | 19 +++- includes/view/UserAngelTypes_view.php | 18 +++- includes/view/UserDriverLicenses_view.php | 6 +- includes/view/UserHintsRenderer.php | 4 +- includes/view/User_view.php | 110 +++++++++++++------ 13 files changed, 354 insertions(+), 180 deletions(-) (limited to 'includes/view') diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php index a5c10a38..6cefbb24 100644 --- a/includes/view/AngelTypes_view.php +++ b/includes/view/AngelTypes_view.php @@ -1,7 +1,8 @@ ' . ($angeltype['restricted'] ? glyph('lock') : '') . $angeltype['name'] . ''; + return '' + . ($angeltype['restricted'] ? glyph('lock') : '') . $angeltype['name'] + . ''; } /** @@ -92,7 +95,10 @@ function AngelType_edit_view($angeltype, $supporter_mode) ? form_info(_('No Self Sign Up'), $angeltype['no_self_signup'] ? _('Yes') : _('No')) : form_checkbox('no_self_signup', _('No Self Sign Up'), $angeltype['no_self_signup']), $supporter_mode - ? form_info(_('Requires driver license'), $angeltype['requires_driver_license'] ? _('Yes') : _('No')) + ? form_info(_('Requires driver license'), + $angeltype['requires_driver_license'] + ? _('Yes') + : _('No')) : form_checkbox( 'requires_driver_license', _('Requires driver license'), @@ -133,7 +139,10 @@ function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, ]; if ($angeltype['requires_driver_license']) { - $buttons[] = button(user_driver_license_edit_link($user), glyph('road') . _('my driving license')); + $buttons[] = button( + user_driver_license_edit_link($user), + glyph('road') . _('my driving license') + ); } if ($user_angeltype == null) { @@ -336,45 +345,45 @@ function AngelType_view( AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user), msg(), tabs([ - _('Info') => AngelType_view_info( + _('Info') => AngelType_view_info( $angeltype, $members, $admin_user_angeltypes, $admin_angeltypes, $supporter - ), + ), _('Shifts') => AngelType_view_shifts( $angeltype, $shiftsFilterRenderer, $shiftCalendarRenderer - ) - ], $tab) + ) + ], $tab) ]); } /** - * @param Angeltype $angeltype - * @param ShiftsFilterRenderer $shiftsFilterRenderer + * @param array $angeltype + * @param ShiftsFilterRenderer $shiftsFilterRenderer * @param ShiftCalendarRenderer $shiftCalendarRenderer * @return string HTML */ function AngelType_view_shifts($angeltype, $shiftsFilterRenderer, $shiftCalendarRenderer) { - $shifts = $shiftsFilterRenderer->render(page_link_to('angeltypes', [ - 'action' => 'view', + $shifts = $shiftsFilterRenderer->render(page_link_to('angeltypes', [ + 'action' => 'view', 'angeltype_id' => $angeltype['id'] ])); $shifts .= $shiftCalendarRenderer->render(); - + return div('first', $shifts); } /** - * @param Angeltype $angeltype + * @param array $angeltype * @param array $members - * @param bool $admin_user_angeltypes - * @param bool $admin_angeltypes - * @param bool $supporter + * @param bool $admin_user_angeltypes + * @param bool $admin_angeltypes + * @param bool $supporter * @return string HTML */ function AngelType_view_info( @@ -385,29 +394,29 @@ function AngelType_view_info( $supporter ) { $info = []; - if(AngelType_has_contact_info($angeltype)) { + if (AngelType_has_contact_info($angeltype)) { $info[] = AngelTypes_render_contact_info($angeltype); } - + $info[] = '

' . _('Description') . '

'; $parsedown = new Parsedown(); if ($angeltype['description'] != '') { $info[] = '
' . $parsedown->parse($angeltype['description']) . '
'; } - + list($supporters, $members_confirmed, $members_unconfirmed) = AngelType_view_members( $angeltype, $members, $admin_user_angeltypes, $admin_angeltypes - ); + ); $table_headers = AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes); - + if (count($supporters) > 0) { $info[] = '

' . _('Supporters') . '

'; $info[] = table($table_headers, $supporters); } - + if (count($members_confirmed) > 0) { $members_confirmed[] = [ 'Nick' => _('Sum'), @@ -415,7 +424,7 @@ function AngelType_view_info( 'actions' => '' ]; } - + if (count($members_unconfirmed) > 0) { $members_unconfirmed[] = [ 'Nick' => _('Sum'), @@ -423,7 +432,7 @@ function AngelType_view_info( 'actions' => '' ]; } - + $info[] = '

' . _('Members') . '

'; if ($admin_user_angeltypes) { $info[] = buttons([ @@ -431,45 +440,45 @@ function AngelType_view_info( page_link_to( 'user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']] - ), + ), _('Add'), 'add' - ) + ) ]); } $info[] = table($table_headers, $members_confirmed); - + if ($admin_user_angeltypes && $angeltype['restricted'] && count($members_unconfirmed) > 0) { $info[] = '

' . _('Unconfirmed') . '

'; $info[] = buttons([ button( page_link_to('user_angeltypes', ['action' => 'confirm_all', 'angeltype_id' => $angeltype['id']]), glyph('ok') . _('confirm all') - ), + ), button( page_link_to('user_angeltypes', ['action' => 'delete_all', 'angeltype_id' => $angeltype['id']]), glyph('remove') . _('deny all') - ) + ) ]); $info[] = table($table_headers, $members_unconfirmed); } - + return join($info); } /** * Renders the contact info - * - * @param Anteltype $angeltype + * + * @param array $angeltype * @return string HTML */ function AngelTypes_render_contact_info($angeltype) { return heading(_('Contact'), 3) . description([ - _('Name') => $angeltype['contact_name'], - _('DECT') => $angeltype['contact_dect'], - _('E-Mail') => $angeltype['contact_email'] - ]); + _('Name') => $angeltype['contact_name'], + _('DECT') => $angeltype['contact_dect'], + _('E-Mail') => $angeltype['contact_email'] + ]); } /** @@ -511,7 +520,7 @@ function AngelTypes_about_view_angeltype($angeltype) $html = '

' . $angeltype['name'] . '

'; - if(AngelType_has_contact_info($angeltype)) { + if (AngelType_has_contact_info($angeltype)) { $html .= AngelTypes_render_contact_info($angeltype); } diff --git a/includes/view/EventConfig_view.php b/includes/view/EventConfig_view.php index 2b092962..25c4b225 100644 --- a/includes/view/EventConfig_view.php +++ b/includes/view/EventConfig_view.php @@ -73,7 +73,11 @@ function EventConfig_info($event_config) } // Event name, start+end date are set - if ($event_config['event_name'] != null && $event_config['event_start_date'] != null && $event_config['event_end_date'] != null) { + if ( + $event_config['event_name'] != null + && $event_config['event_start_date'] != null + && $event_config['event_end_date'] != null + ) { return sprintf( _('%s, from %s to %s'), $event_config['event_name'], @@ -134,7 +138,10 @@ function EventConfig_edit_view( form_text('event_name', _('Event Name'), $event_name), form_info('', _('Event Name is shown on the start page.')), form_textarea('event_welcome_msg', _('Event Welcome Message'), $event_welcome_msg), - form_info('', _('Welcome message is shown after successful registration. You can use markdown.')) + form_info( + '', + _('Welcome message is shown after successful registration. You can use markdown.') + ) ]), div('col-md-3 col-xs-6', [ form_date('buildup_start_date', _('Buildup date'), $buildup_start_date), diff --git a/includes/view/PublicDashboard_view.php b/includes/view/PublicDashboard_view.php index 30f63d63..b4064294 100644 --- a/includes/view/PublicDashboard_view.php +++ b/includes/view/PublicDashboard_view.php @@ -2,6 +2,10 @@ /** * Public dashboard (formerly known as angel news hub) + * + * @param array $stats + * @param array[] $free_shifts + * @return string */ function public_dashboard_view($stats, $free_shifts) { @@ -9,7 +13,7 @@ function public_dashboard_view($stats, $free_shifts) if (count($free_shifts) > 0) { $shift_panels = []; foreach ($free_shifts as $shift) { - $shift_panels[] = public_dashborad_shift_render($shift); + $shift_panels[] = public_dashboard_shift_render($shift); } $needed_angels = div('first', [ div('col-md-12', [ @@ -18,6 +22,7 @@ function public_dashboard_view($stats, $free_shifts) join($shift_panels) ]); } + return page([ div('public-dashboard', [ div('first', [ @@ -48,23 +53,29 @@ function public_dashboard_view($stats, $free_shifts) /** * Renders a single shift panel for a dashboard shift with needed angels + * + * @param array $shift + * @return string */ -function public_dashborad_shift_render($shift) +function public_dashboard_shift_render($shift) { $panel_body = glyph('time') . $shift['start'] . ' - ' . $shift['end']; $panel_body .= ' (' . $shift['duration'] . ' h)'; - + $panel_body .= '
' . glyph('tasks') . $shift['shifttype_name']; - if (! empty($shift['title'])) { + if (!empty($shift['title'])) { $panel_body .= ' (' . $shift['title'] . ')'; } - + $panel_body .= '
' . glyph('map-marker') . $shift['room_name']; - + foreach ($shift['needed_angels'] as $needed_angels) { - $panel_body .= '
' . glyph('user') . '' . $needed_angels['need'] . ' × ' . $needed_angels['angeltype_name'] . ''; + $panel_body .= '
' . glyph('user') + . '' + . $needed_angels['need'] . ' × ' . $needed_angels['angeltype_name'] + . ''; } - + return div('col-md-3', [ div('dashboard-panel panel panel-' . $shift['style'], [ div('panel-body', [ @@ -74,4 +85,3 @@ function public_dashborad_shift_render($shift) ]) ]); } -?> diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php index 1e8ae4d2..4cd4d8fe 100644 --- a/includes/view/Rooms_view.php +++ b/includes/view/Rooms_view.php @@ -1,49 +1,55 @@ ' . _('Description') . ''; $parsedown = new Parsedown(); $description .= '
' . $parsedown->parse($room['description']) . '
'; } - + $tabs = []; - if (! empty($room['map_url'])) { - $tabs[_('Map')] = '
'; + if (!empty($room['map_url'])) { + $tabs[_('Map')] = sprintf( + '
' + . '' + . '
', + $room['map_url'] + ); } - + $tabs[_('Shifts')] = div('first', [ $shiftsFilterRenderer->render(page_link_to('rooms', [ - 'action' => 'view', + 'action' => 'view', 'room_id' => $room['RID'] ])), $shiftCalendarRenderer->render() ]); - + $selected_tab = 0; $request = request(); if ($request->has('shifts_filter_day')) { $selected_tab = count($tabs) - 1; } - + return page_with_title(glyph('map-marker') . $room['Name'], [ $assignNotice, $description, @@ -53,14 +59,16 @@ function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalen /** * - * @param array $room + * @param array $room * @return string */ function Room_name_render($room) { global $privileges; + if (in_array('view_rooms', $privileges)) { return '' . glyph('map-marker') . $room['Name'] . ''; } + return glyph('map-marker') . $room['Name']; } diff --git a/includes/view/ShiftCalendarLane.php b/includes/view/ShiftCalendarLane.php index fd4c6f06..d28b85e7 100644 --- a/includes/view/ShiftCalendarLane.php +++ b/includes/view/ShiftCalendarLane.php @@ -48,6 +48,7 @@ class ShiftCalendarLane $this->shifts[] = $shift; return; } + throw new Exception('Unable to add shift to shift calendar lane.'); } @@ -65,6 +66,7 @@ class ShiftCalendarLane return false; } } + return true; } diff --git a/includes/view/ShiftCalendarRenderer.php b/includes/view/ShiftCalendarRenderer.php index 40642947..98f40d49 100644 --- a/includes/view/ShiftCalendarRenderer.php +++ b/includes/view/ShiftCalendarRenderer.php @@ -267,7 +267,10 @@ class ShiftCalendarRenderer $start_time = $shift['start']; } } - return ShiftCalendarRenderer::SECONDS_PER_ROW * floor(($start_time - ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW); + return ShiftCalendarRenderer::SECONDS_PER_ROW * floor( + ($start_time - ShiftCalendarRenderer::TIME_MARGIN) + / ShiftCalendarRenderer::SECONDS_PER_ROW + ); } /** @@ -282,7 +285,11 @@ class ShiftCalendarRenderer $end_time = $shift['end']; } } - return ShiftCalendarRenderer::SECONDS_PER_ROW * ceil(($end_time + ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW); + + return ShiftCalendarRenderer::SECONDS_PER_ROW * ceil( + ($end_time + ShiftCalendarRenderer::TIME_MARGIN) + / ShiftCalendarRenderer::SECONDS_PER_ROW + ); } /** @@ -290,7 +297,10 @@ class ShiftCalendarRenderer */ private function calcBlocksPerSlot() { - return ceil(($this->getLastBlockEndTime() - $this->getFirstBlockStartTime()) / ShiftCalendarRenderer::SECONDS_PER_ROW); + return ceil( + ($this->getLastBlockEndTime() - $this->getFirstBlockStartTime()) + / ShiftCalendarRenderer::SECONDS_PER_ROW + ); } /** diff --git a/includes/view/ShiftCalendarShiftRenderer.php b/includes/view/ShiftCalendarShiftRenderer.php index 2940306d..8bfb18ea 100644 --- a/includes/view/ShiftCalendarShiftRenderer.php +++ b/includes/view/ShiftCalendarShiftRenderer.php @@ -33,10 +33,14 @@ class ShiftCalendarShiftRenderer $blocks = ceil(($shift['end'] - $shift['start']) / ShiftCalendarRenderer::SECONDS_PER_ROW); $blocks = max(1, $blocks); + return [ $blocks, div( - 'shift panel panel-' . $class . '" style="height: ' . ($blocks * ShiftCalendarRenderer::BLOCK_HEIGHT - ShiftCalendarRenderer::MARGIN) . 'px"', + 'shift panel panel-' . $class . '" ' + . 'style="height: ' + . ($blocks * ShiftCalendarRenderer::BLOCK_HEIGHT - ShiftCalendarRenderer::MARGIN) + . 'px"', [ $this->renderShiftHead($shift), div('panel-body', [ @@ -127,9 +131,9 @@ class ShiftCalendarShiftRenderer if (in_array('user_shifts_admin', $privileges)) { $html .= '
  • '; $html .= button(shift_entry_create_link_admin($shift), - glyph('plus') . _('Add more angels'), - 'btn-xs' - ); + glyph('plus') . _('Add more angels'), + 'btn-xs' + ); $html .= '
  • '; } if ($html != '') { @@ -138,6 +142,7 @@ class ShiftCalendarShiftRenderer '' ]; } + return [ $shift_signup_state, '' @@ -161,7 +166,15 @@ class ShiftCalendarShiftRenderer $style = $entry['freeloaded'] ? ' text-decoration: line-through;' : ''; $entry_list[] = '' . User_Nick_render($entry) . ''; } - $shift_signup_state = Shift_signup_allowed($user, $shift, $angeltype, null, null, $angeltype, $shift_entries); + $shift_signup_state = Shift_signup_allowed( + $user, + $shift, + $angeltype, + null, + null, + $angeltype, + $shift_entries + ); $inner_text = sprintf( ngettext('%d helper needed', '%d helpers needed', $shift_signup_state->getFreeEntries()), $shift_signup_state->getFreeEntries() @@ -181,12 +194,12 @@ class ShiftCalendarShiftRenderer _('Sign up'), 'btn-xs btn-primary' ); break; - + case ShiftSignupState::SHIFT_ENDED: // No link and add a text hint, when the shift ended $entry_list[] = $inner_text . ' (' . _('ended') . ')'; break; - + case ShiftSignupState::NOT_ARRIVED: // No link and add a text hint, when the shift ended $entry_list[] = $inner_text . ' (' . _('please arrive for signup') . ')'; @@ -200,7 +213,10 @@ class ShiftCalendarShiftRenderer // Add link to join the angeltype first $entry_list[] = $inner_text . '
    ' . button( - page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]), + page_link_to( + 'user_angeltypes', + ['action' => 'add', 'angeltype_id' => $angeltype['id']] + ), sprintf(_('Become %s'), $angeltype['name']), 'btn-xs' ); @@ -241,8 +257,16 @@ class ShiftCalendarShiftRenderer $header_buttons = ''; if (in_array('admin_shifts', $privileges)) { $header_buttons = '
    ' . table_buttons([ - button(page_link_to('user_shifts', ['edit_shift' => $shift['SID']]), glyph('edit'), 'btn-xs'), - button(page_link_to('user_shifts', ['delete_shift' => $shift['SID']]), glyph('trash'), 'btn-xs') + button( + page_link_to('user_shifts', ['edit_shift' => $shift['SID']]), + glyph('edit'), + 'btn-xs' + ), + button( + page_link_to('user_shifts', ['delete_shift' => $shift['SID']]), + glyph('trash'), + 'btn-xs' + ) ]) . '
    '; } $shift_heading = date('H:i', $shift['start']) . ' ‐ ' diff --git a/includes/view/ShiftEntry_view.php b/includes/view/ShiftEntry_view.php index da99e9d8..1b646557 100644 --- a/includes/view/ShiftEntry_view.php +++ b/includes/view/ShiftEntry_view.php @@ -13,7 +13,14 @@ function ShiftEntry_delete_view_admin($shiftEntry, $shift, $angeltype, $signoff_user) { return page_with_title(ShiftEntry_delete_title(), [ - info(sprintf(_('Do you want to sign off %s from shift %s from %s to %s as %s?'), User_Nick_render($signoff_user), $shift['name'], date('Y-m-d H:i', $shift['start']), date('Y-m-d H:i', $shift['end']), $angeltype['name']), true), + info(sprintf( + _('Do you want to sign off %s from shift %s from %s to %s as %s?'), + User_Nick_render($signoff_user), + $shift['name'], + date('Y-m-d H:i', $shift['start']), + date('Y-m-d H:i', $shift['end']), + $angeltype['name'] + ), true), buttons([ button(user_link($signoff_user), glyph('remove') . _('cancel')), button(shift_entry_delete_link($shiftEntry, [ @@ -26,17 +33,23 @@ function ShiftEntry_delete_view_admin($shiftEntry, $shift, $angeltype, $signoff_ /** * Sign off from a shift, asking for ack. * - * @param array $shiftEntry - * @param array $shift - * @param array $angeltype - * @param array $signoff_user + * @param array $shiftEntry + * @param array $shift + * @param array $angeltype + * @param array $signoff_user * * @return string HTML */ function ShiftEntry_delete_view($shiftEntry, $shift, $angeltype, $signoff_user) { return page_with_title(ShiftEntry_delete_title(), [ - info(sprintf(_('Do you want to sign off from your shift %s from %s to %s as %s?'), $shift['name'], date('Y-m-d H:i', $shift['start']), date('Y-m-d H:i', $shift['end']), $angeltype['name']), true), + info(sprintf( + _('Do you want to sign off from your shift %s from %s to %s as %s?'), + $shift['name'], + date('Y-m-d H:i', $shift['start']), + date('Y-m-d H:i', $shift['end']), + $angeltype['name'] + ), true), buttons([ button(user_link($signoff_user), glyph('remove') . _('cancel')), button(shift_entry_delete_link($shiftEntry, [ @@ -57,65 +70,76 @@ function ShiftEntry_delete_title() /** * Admin puts user into shift. * - * @param array $shift - * @param array $room - * @param array $angeltype - * @param array $angeltypes_select - * @param array $signup_user - * @param array $users_select + * @param array $shift + * @param array $room + * @param array $angeltype + * @param array $angeltypes_select + * @param array $signup_user + * @param array $users_select + * @return string */ function ShiftEntry_create_view_admin($shift, $room, $angeltype, $angeltypes_select, $signup_user, $users_select) { - return page_with_title(ShiftEntry_create_title() . ': ' . $shift['name'] . ' %c', [ - Shift_view_header($shift, $room), - info(_('Do you want to sign up the following user for this shift?'), true), - form([ - form_select('angeltype_id', _('Angeltype'), $angeltypes_select, $angeltype['id']), - form_select('user_id', _('User'), $users_select, $signup_user['UID']), - form_submit('submit', glyph('ok') . _('Save')) - ]) - ]); + return page_with_title( + ShiftEntry_create_title() . ': ' . $shift['name'] + . ' %c', + [ + Shift_view_header($shift, $room), + info(_('Do you want to sign up the following user for this shift?'), true), + form([ + form_select('angeltype_id', _('Angeltype'), $angeltypes_select, $angeltype['id']), + form_select('user_id', _('User'), $users_select, $signup_user['UID']), + form_submit('submit', glyph('ok') . _('Save')) + ]) + ]); } /** * Supporter puts user into shift. * - * @param array $shift - * @param array $room - * @param array $angeltype - * @param array $signup_user - * @param array $users_select + * @param array $shift + * @param array $room + * @param array $angeltype + * @param array $signup_user + * @param array $users_select + * @return string */ function ShiftEntry_create_view_supporter($shift, $room, $angeltype, $signup_user, $users_select) { - return page_with_title(ShiftEntry_create_title() . ': ' . $shift['name'] . ' %c', [ - Shift_view_header($shift, $room), - info(sprintf(_('Do you want to sign up the following user for this shift as %s?'), AngelType_name_render($angeltype)), true), - form([ - form_select('user_id', _('User'), $users_select, $signup_user['UID']), - form_submit('submit', glyph('ok') . _('Save')) - ]) - ]); + return page_with_title(ShiftEntry_create_title() . ': ' . $shift['name'] + . ' %c', + [ + Shift_view_header($shift, $room), + info(sprintf(_('Do you want to sign up the following user for this shift as %s?'), + AngelType_name_render($angeltype)), true), + form([ + form_select('user_id', _('User'), $users_select, $signup_user['UID']), + form_submit('submit', glyph('ok') . _('Save')) + ]) + ]); } /** * User joining a shift. - * - * @param array $shift - * @param array $room - * @param array $angeltype + * + * @param array $shift + * @param array $room + * @param array $angeltype * @param string $comment + * @return string */ function ShiftEntry_create_view_user($shift, $room, $angeltype, $comment) { - return page_with_title(ShiftEntry_create_title() . ': ' . $shift['name'] . ' %c', [ - Shift_view_header($shift, $room), - info(sprintf(_('Do you want to sign up for this shift as %s?'), AngelType_name_render($angeltype)), true), - form([ - form_textarea('comment', _('Comment (for your eyes only):'), $comment), - form_submit('submit', glyph('ok') . _('Save')) - ]) - ]); + return page_with_title(ShiftEntry_create_title() . ': ' . $shift['name'] + . ' %c', + [ + Shift_view_header($shift, $room), + info(sprintf(_('Do you want to sign up for this shift as %s?'), AngelType_name_render($angeltype)), true), + form([ + form_textarea('comment', _('Comment (for your eyes only):'), $comment), + form_submit('submit', glyph('ok') . _('Save')) + ]) + ]); } /** @@ -129,24 +153,37 @@ function ShiftEntry_create_title() /** * Display form for adding/editing a shift entry. * - * @param string $angel - * @param string $date - * @param string $location - * @param string $title - * @param string $type - * @param string $comment - * @param bool $freeloaded - * @param string $freeload_comment - * @param bool $user_admin_shifts + * @param string $angel + * @param string $date + * @param string $location + * @param string $title + * @param string $type + * @param string $comment + * @param bool $freeloaded + * @param string $freeload_comment + * @param bool $user_admin_shifts * @return string */ -function ShiftEntry_edit_view($angel, $date, $location, $title, $type, $comment, $freeloaded, $freeload_comment, $user_admin_shifts = false) -{ +function ShiftEntry_edit_view( + $angel, + $date, + $location, + $title, + $type, + $comment, + $freeloaded, + $freeload_comment, + $user_admin_shifts = false +) { $freeload_form = []; if ($user_admin_shifts) { $freeload_form = [ form_checkbox('freeloaded', _('Freeloaded'), $freeloaded), - form_textarea('freeload_comment', _('Freeload comment (Only for shift coordination):'), $freeload_comment) + form_textarea( + 'freeload_comment', + _('Freeload comment (Only for shift coordination):'), + $freeload_comment + ) ]; } return page_with_title(_('Edit shift entry'), [ diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php index 0b71b77b..7fc56d1d 100644 --- a/includes/view/Shifts_view.php +++ b/includes/view/Shifts_view.php @@ -4,17 +4,21 @@ use Engelsystem\ShiftSignupState; /** * Renders the basic shift view header. - * + * * @param array $shift * @param array $room - * * @return string HTML */ -function Shift_view_header($shift, $room) { +function Shift_view_header($shift, $room) +{ return div('row', [ div('col-sm-3 col-xs-6', [ '

    ' . _('Title') . '

    ', - '

    ' . ($shift['URL'] != '' ? '' . $shift['title'] . '' : $shift['title']) . '

    ' + '

    ' + . ($shift['URL'] != '' + ? '' . $shift['title'] . '' + : $shift['title']) + . '

    ' ]), div('col-sm-3 col-xs-6', [ '

    ' . _('Start') . '

    ', @@ -237,6 +241,11 @@ function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angelty function shift_length($shift) { $length = floor(($shift['end'] - $shift['start']) / (60 * 60)) . ':'; - $length .= str_pad((($shift['end'] - $shift['start']) % (60 * 60)) / 60, 2, '0', STR_PAD_LEFT) . 'h'; + $length .= str_pad( + (($shift['end'] - $shift['start']) % (60 * 60)) / 60, + 2, + '0', + STR_PAD_LEFT + ) . 'h'; return $length; } diff --git a/includes/view/UserAngelTypes_view.php b/includes/view/UserAngelTypes_view.php index c46c1ee1..1f802de4 100644 --- a/includes/view/UserAngelTypes_view.php +++ b/includes/view/UserAngelTypes_view.php @@ -97,7 +97,11 @@ function UserAngelType_confirm_view($user_angeltype, $user, $angeltype) { return page_with_title(_('Confirm angeltype for user'), [ msg(), - info(sprintf(_('Do you really want to confirm %s for %s?'), User_Nick_render($user), $angeltype['name']), true), + info(sprintf( + _('Do you really want to confirm %s for %s?'), + User_Nick_render($user), + $angeltype['name'] + ), true), buttons([ button(angeltype_link($angeltype['id']), glyph('remove') . _('cancel')), button( @@ -122,7 +126,11 @@ function UserAngelType_delete_view($user_angeltype, $user, $angeltype) { return page_with_title(_('Remove angeltype'), [ msg(), - info(sprintf(_('Do you really want to delete %s from %s?'), User_Nick_render($user), $angeltype['name']), true), + info(sprintf( + _('Do you really want to delete %s from %s?'), + User_Nick_render($user), + $angeltype['name'] + ), true), buttons([ button(angeltype_link($angeltype['id']), glyph('remove') . _('cancel')), button( @@ -174,7 +182,11 @@ function UserAngelType_join_view($user, $angeltype) { return page_with_title(sprintf(_('Become a %s'), $angeltype['name']), [ msg(), - info(sprintf(_('Do you really want to add %s to %s?'), User_Nick_render($user), $angeltype['name']), true), + info(sprintf( + _('Do you really want to add %s to %s?'), + User_Nick_render($user), + $angeltype['name'] + ), true), buttons([ button(angeltype_link($angeltype['id']), glyph('remove') . _('cancel')), button( diff --git a/includes/view/UserDriverLicenses_view.php b/includes/view/UserDriverLicenses_view.php index 5eacf456..b92f5f07 100644 --- a/includes/view/UserDriverLicenses_view.php +++ b/includes/view/UserDriverLicenses_view.php @@ -42,7 +42,11 @@ function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver _('Truck 12,5t'), $user_driver_license['has_license_12_5t_truck'] ), - form_checkbox('has_license_forklift', _('Forklift'), $user_driver_license['has_license_forklift']) + form_checkbox( + 'has_license_forklift', + _('Forklift'), + $user_driver_license['has_license_forklift'] + ) ]) ], 'driving_license'), form_submit('submit', _('Save')) diff --git a/includes/view/UserHintsRenderer.php b/includes/view/UserHintsRenderer.php index aac8ecfd..a2bc62f9 100644 --- a/includes/view/UserHintsRenderer.php +++ b/includes/view/UserHintsRenderer.php @@ -20,7 +20,9 @@ class UserHintsRenderer $hint_class = $this->important ? 'danger' : 'info'; $glyphicon = $this->important ? 'warning-sign' : 'info-sign'; - return toolbar_popover($glyphicon . ' text-' . $hint_class, '', $this->hints, 'bg-' . $hint_class); + return toolbar_popover( + $glyphicon . ' text-' . $hint_class, '', $this->hints, 'bg-' . $hint_class + ); } return ''; diff --git a/includes/view/User_view.php b/includes/view/User_view.php index 5aec1962..c9530307 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -105,6 +105,7 @@ function User_registration_success_view($event_welcome_message) { $parsedown = new Parsedown(); $event_welcome_message = $parsedown->text($event_welcome_message); + return page_with_title(_('Registration successful'), [ msg(), div('row', [ @@ -171,7 +172,10 @@ function User_edit_vouchers_view($user) buttons([ button(user_link($user), glyph('chevron-left') . _('back')) ]), - info(sprintf(_('Angel should receive at least %d vouchers.'), User_get_eligable_voucher_count($user)), true), + info(sprintf( + _('Angel should receive at least %d vouchers.'), + User_get_eligable_voucher_count($user) + ), true), form( [ form_spinner('vouchers', _('Number of vouchers given out'), $user['got_voucher']), @@ -269,10 +273,10 @@ function Users_table_header_link($column, $label, $order_by) */ function User_shift_state_render($user) { - if(!$user['Gekommen']) { + if (!$user['Gekommen']) { return ''; } - + $upcoming_shifts = ShiftEntries_upcoming_for_user($user); if (empty($upcoming_shifts)) { @@ -283,16 +287,25 @@ function User_shift_state_render($user) if ($nextShift['start'] > time()) { if ($nextShift['start'] - time() > 3600) { - return '' . _('Next shift %c') . ''; + return '' + . _('Next shift %c') + . ''; } - return '' . _('Next shift %c') . ''; + return '' + . _('Next shift %c') + . ''; } $halfway = ($nextShift['start'] + $nextShift['end']) / 2; if (time() < $halfway) { - return '' . _('Shift starts %c') . ''; + return '' + . _('Shift starts %c') + . ''; } - return '' . _('Shift ends %c') . ''; + + return '' + . _('Shift ends %c') + . ''; } /** @@ -344,14 +357,15 @@ function User_view_myshift($shift, $user_source, $its_me) 'shift_info' => $shift_info, 'comment' => '' ]; - - if($its_me) { + + if ($its_me) { $myshift['comment'] = $shift['Comment']; } if ($shift['freeloaded']) { if (in_array('user_shifts_admin', $privileges)) { - $myshift['comment'] .= '

    ' . _('Freeloaded') . ': ' . $shift['freeload_comment'] . '

    '; + $myshift['comment'] .= '
    ' + . '

    ' . _('Freeloaded') . ': ' . $shift['freeload_comment'] . '

    '; } else { $myshift['comment'] .= '

    ' . _('Freeloaded') . '

    '; } @@ -432,7 +446,9 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel $myshifts_table = User_view_myshifts($shifts, $user_source, $its_me); return page_with_title( - ' ' . htmlspecialchars($user_source['Nick']) . ' ' . $user_name . '', + ' ' + . htmlspecialchars($user_source['Nick']) + . ' ' . $user_name . '', [ msg(), div('row space-top', [ @@ -451,10 +467,16 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel _('arrived') ) : '', $admin_user_privilege ? button( - page_link_to('users', ['action' => 'edit_vouchers', 'user_id' => $user_source['UID']]), + page_link_to( + 'users', + ['action' => 'edit_vouchers', 'user_id' => $user_source['UID']] + ), glyph('cutlery') . _('Edit vouchers') ) : '', - $its_me ? button(page_link_to('user_settings'), glyph('list-alt') . _('Settings')) : '', + $its_me ? button( + page_link_to('user_settings'), + glyph('list-alt') . _('Settings') + ) : '', $its_me ? button( page_link_to('ical', ['key' => $user_source['api_key']]), glyph('calendar') . _('iCal Export') @@ -487,7 +509,10 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel 'comment' => _('Comment'), 'actions' => _('Action') ], $myshifts_table) : '', - $its_me ? info(glyph('info-sign') . _('Your night shifts between 2 and 8 am count twice.'), true) : '', + $its_me ? info( + glyph('info-sign') . _('Your night shifts between 2 and 8 am count twice.'), + true + ) : '', $its_me && count($shifts) == 0 ? error(sprintf( _('Go to the shifts table to sign yourself up for some shifts.'), @@ -499,10 +524,16 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel } /** - * Render the state section of user view. + * Render the state section of user view + * + * @param bool $admin_user_privilege + * @param bool $freeloader + * @param array $user_source + * @return string */ -function User_view_state($admin_user_privilege, $freeloader, $user_source) { - if($admin_user_privilege) { +function User_view_state($admin_user_privilege, $freeloader, $user_source) +{ + if ($admin_user_privilege) { $state = User_view_state_admin($freeloader, $user_source); } else { $state = User_view_state_user($user_source); @@ -516,45 +547,54 @@ function User_view_state($admin_user_privilege, $freeloader, $user_source) { /** * Render the state section of user view for users. + * + * @param array $user_source + * @return array */ -function User_view_state_user($user_source) { +function User_view_state_user($user_source) +{ $state = [ User_shift_state_render($user_source) ]; - - if($user_source['Gekommen']) { + + if ($user_source['Gekommen']) { $state[] = '' . glyph('home') . _('Arrived') . ''; } else { $state[] = '' . _('Not arrived') . ''; } - + return $state; } /** * Render the state section of user view for admins. + * + * @param bool $freeloader + * @param array $user_source + * @return array */ -function User_view_state_admin($freeloader, $user_source) { +function User_view_state_admin($freeloader, $user_source) +{ $state = []; - - if($freeloader) { + + if ($freeloader) { $state[] = '' . glyph('exclamation-sign') . _('Freeloader') . ''; } - + $state[] = User_shift_state_render($user_source); - - if($user_source['Gekommen']) { + + if ($user_source['Gekommen']) { $state[] = '' . glyph('home') . sprintf(_('Arrived at %s'), date('Y-m-d', $user_source['arrival_date'])) . ''; - if($user_source['force_active']) { + if ($user_source['force_active']) { $state[] = '' . _('Active (forced)') . ''; - } elseif($user_source['Aktiv']) { + } elseif ($user_source['Aktiv']) { $state[] = '' . _('Active') . ''; } - if($user_source['Tshirt']) { + if ($user_source['Tshirt']) { $state[] = '' . _('T-Shirt') . ''; } } else { @@ -562,15 +602,15 @@ function User_view_state_admin($freeloader, $user_source) { . sprintf(_('Not arrived (Planned: %s)'), date('Y-m-d', $user_source['planned_arrival_date'])) . ''; } - - if($user_source['got_voucher'] > 0) { + + if ($user_source['got_voucher'] > 0) { $state[] = '' . glyph('cutlery') . sprintf( ngettext('Got %s voucher', 'Got %s vouchers', $user_source['got_voucher']), $user_source['got_voucher'] - ) - . ''; + ) + . ''; } else { $state[] = '' . _('Got no vouchers') . ''; } @@ -731,7 +771,7 @@ function render_user_arrived_hint() if ($user['Gekommen'] == 0) { $event_config = EventConfig(); - if(!is_null($event_config) + if (!is_null($event_config) && !is_null($event_config['buildup_start_date']) && time() > $event_config['buildup_start_date']) { return _('You are not marked as arrived. Please go to heaven\'s desk, get your angel badge and/or tell them that you arrived already.'); -- cgit v1.2.3-70-g09d2