From d4cc6c399d12927541efd62c3836a86588b7a9be Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 12 Feb 2022 20:09:31 +0100 Subject: More indentation and format if statements. --- includes/admin/views/_concerts_table.php | 258 ++++++++++++++++--------------- 1 file changed, 134 insertions(+), 124 deletions(-) diff --git a/includes/admin/views/_concerts_table.php b/includes/admin/views/_concerts_table.php index 0302111..4a9c658 100644 --- a/includes/admin/views/_concerts_table.php +++ b/includes/admin/views/_concerts_table.php @@ -26,7 +26,7 @@ if (!class_exists("GiglogAdmin_ConcertsTable")) public function render(): string { return $this->render_filters() - . $this->render_concerts_table(); + . $this->render_concerts_table(); } private function render_concerts_table() : string @@ -139,48 +139,58 @@ if (!class_exists("GiglogAdmin_ConcertsTable")) if (current_user_can('administrator')) { $content .= '' - . $this->adminactions($concert) - . ''; + . $this->adminactions($concert) + . ''; } } $content .= ''; $lastType = $concert->venue()->city(); } + $content .= ''; $content.='
'; $content.=''; - if($page_no > 1){ $content.= "First Page - "; } - if($page_no <= 1){ $content .=" "; } - else $content.= " Previous "; + + if($page_no > 1) { + $content.= "First Page - "; + } + + if($page_no <= 1) { + $content .=" "; + } + else { + $content.= " Previous "; + } + $content.=''; $content.='
Page '.$page_no.' of '.$total_no_of_pages.'
'; $content.=''; - if($page_no >= $total_no_of_pages){ $content .=" ";} - if($page_no < $total_no_of_pages) { $content .= ' Next - ';} - if($page_no < $total_no_of_pages){ - $content .= "Last Page ";} - - $content.=''; - $content.='
'; - + if($page_no >= $total_no_of_pages) { + $content .= ""; + } - // + if($page_no < $total_no_of_pages) { + $content .= 'Next - '; + $content .= "Last Page"; + } + $content.=''; + $content.=''; - //from main form that includes filters - $content .= '

'; + //from main form that includes filters + $content .= '

'; - // return the table - return $content; - } + // return the table + return $content; + } - private function render_filters() : string - { - $cty = filter_input(INPUT_POST, 'selectcity', FILTER_SANITIZE_SPECIAL_CHARS); + private function render_filters() : string + { + $cty = filter_input(INPUT_POST, 'selectcity', FILTER_SANITIZE_SPECIAL_CHARS); - $select = '

FILTER DATA: ' + $select = '

FILTER DATA: ' . \EternalTerror\ViewHelpers\select_field( "selectcity", array_map(fn($city) => [$city, $city], GiglogAdmin_Venue::all_cities()), @@ -188,104 +198,104 @@ if (!class_exists("GiglogAdmin_ConcertsTable")) "Select city..."); - if ( !empty($cty) ) { - //second drop down for venue - $select .= \EternalTerror\ViewHelpers\select_field( - "selectvenue", - array_map( - fn($venue) => [$venue->id(), $venue->name()], - GiglogAdmin_Venue::venues_in_city($cty) - ), - filter_input(INPUT_POST, 'selectvenue', FILTER_SANITIZE_SPECIAL_CHARS), - "Select venue..."); - } - - $select.=' Filter by month: '; - $select.= ''; - - if(is_admin()) { - //option to select own concerts only - $select .= ''; - - } - //NOTE that I remvoed

and mvoed them up to render_concerts_table function - $select .= ''; - - return $select; - } + if ( !empty($cty) ) { + //second drop down for venue + $select .= \EternalTerror\ViewHelpers\select_field( + "selectvenue", + array_map( + fn($venue) => [$venue->id(), $venue->name()], + GiglogAdmin_Venue::venues_in_city($cty) + ), + filter_input(INPUT_POST, 'selectvenue', FILTER_SANITIZE_SPECIAL_CHARS), + "Select venue..."); + } - private function adminactions( GiglogAdmin_Concert $concert ) : string - { - return - '
' - . '' - . \EternalTerror\ViewHelpers\select_field( - 'selectstatus', - array_map(fn($i) => [ $i, self::STATUS_LABELS[$i] ], range(1, count(self::STATUS_LABELS) - 1)), - $concert->status()) - . '' - . '' - . '
'; - } - - /** - * Display a mark on the concert if it is new. - * I.e. imported/created within the last ten days. - * - * @return null|string - */ - private function mark_new_concert(GiglogAdmin_Concert $concert) : string - { - $now = new DateTime(); - $new_entry = $now->diff($concert->created())->days <= 10; - if ($new_entry) { - return 'NEW'; - } - else { - return ''; - } - } - - private function assign_role_for_user_form(string $role, GiglogAdmin_Concert $concert) : ?string - { - $roles = $concert->roles(); - $assigned_user = array_key_exists($role, $roles) ? $roles[$role] : NULL; - - //first check if current slot is taken by current user - if ( $assigned_user == $this->username ) { - $f = '
' - . ' ' - . ' ' - . ' ' - . '
'; - } - elseif ( $assigned_user ) { //check if slot is taken by another user - $f = 'Taken' - . '
Taken by ' . $assigned_user . '
'; - } - elseif ( array_search($this->username, $roles) ) { - // other slots for this concert are taken by user - $f = '-'; - } - else { //not taken by anyone - $f = '
' - . ' ' - . ' ' - . ' ' - . '
'; - } - - return $f; - } - } - } + $select.=' Filter by month: '; + $select.= ''; + + if(is_admin()) { + //option to select own concerts only + $select .= ''; + + } + //NOTE that I remvoed

and mvoed them up to render_concerts_table function + $select .= ''; + + return $select; + } + + private function adminactions( GiglogAdmin_Concert $concert ) : string + { + return + '
' + . '' + . \EternalTerror\ViewHelpers\select_field( + 'selectstatus', + array_map(fn($i) => [ $i, self::STATUS_LABELS[$i] ], range(1, count(self::STATUS_LABELS) - 1)), + $concert->status()) + . '' + . '' + . '
'; + } + + /** + * Display a mark on the concert if it is new. + * I.e. imported/created within the last ten days. + * + * @return null|string + */ + private function mark_new_concert(GiglogAdmin_Concert $concert) : string + { + $now = new DateTime(); + $new_entry = $now->diff($concert->created())->days <= 10; + if ($new_entry) { + return 'NEW'; + } + else { + return ''; + } + } + + private function assign_role_for_user_form(string $role, GiglogAdmin_Concert $concert) : ?string + { + $roles = $concert->roles(); + $assigned_user = array_key_exists($role, $roles) ? $roles[$role] : NULL; + + //first check if current slot is taken by current user + if ( $assigned_user == $this->username ) { + $f = '
' + . ' ' + . ' ' + . ' ' + . '
'; + } + elseif ( $assigned_user ) { //check if slot is taken by another user + $f = 'Taken' + . '
Taken by ' . $assigned_user . '
'; + } + elseif ( array_search($this->username, $roles) ) { + // other slots for this concert are taken by user + $f = '-'; + } + else { //not taken by anyone + $f = '
' + . ' ' + . ' ' + . ' ' + . '
'; + } + + return $f; + } + } +} -- cgit v1.2.3