From c5d786a1c72911e4352a6e40ea19aff98711d353 Mon Sep 17 00:00:00 2001 From: AndreaChirulescu Date: Sun, 27 Feb 2022 13:35:59 +0100 Subject: iCal file download fixes to generate one file per concert giglog import fixes to catch errors and ignore old concerts --- includes/admin/views/_concerts_table.php | 268 ++++++++++++++++--------------- 1 file changed, 136 insertions(+), 132 deletions(-) (limited to 'includes/admin/views/_concerts_table.php') diff --git a/includes/admin/views/_concerts_table.php b/includes/admin/views/_concerts_table.php index 8d38eab..066e14c 100644 --- a/includes/admin/views/_concerts_table.php +++ b/includes/admin/views/_concerts_table.php @@ -34,18 +34,21 @@ if (!class_exists("GiglogAdmin_ConcertsTable")) public function render(): string { return $this->render_filters() - . $this->render_concerts_table(); + . $this->render_concerts_table(); } private function render_concert_table_header() : string { - $content = - '
' - . '' - . ' '; + + + $content = '
CITYDATENAMEVENUE
'; + $content.= ' Note: the iCal link will download a file with extension .ical which can be used to add the event to your calendar. For convenience, we set all events with start time at 19:00 but please check the actual event for the correct time.'; + + $content.= ''; + $content.= ''; if (!is_admin()) { - $content .= ''; + $content .= ''; } else { $content .= ''; @@ -121,42 +124,42 @@ if (!class_exists("GiglogAdmin_ConcertsTable")) private function render_pagination() : string { $content = - '
' - . ''; + '
' + . ''; if($this->page_no > 1) { $content .= - '' - . '' - . 'First Page -' - . '' - . '' - . '' - . ' Previous'; + '' + . '' + . 'First Page -' + . '' + . '' + . '' + . ' Previous'; } $content .= '' - . '' - . 'Page ' . $this->page_no . ' of ' . $this->total_no_of_pages . '' - . ''; + . '' + . 'Page ' . $this->page_no . ' of ' . $this->total_no_of_pages . '' + . ''; $content .= ''; if ($this->page_no < $this->total_no_of_pages) { $content .= - '' - . '' - . 'Next - ' - . '' - . '' - . '' - . 'Last Page' - . ''; + '' + . '' + . 'Next - ' + . '' + . '' + . '' + . 'Last Page' + . ''; } $content .= - '' - . '
'; + '
' + . '
'; return $content; } @@ -209,10 +212,11 @@ if (!class_exists("GiglogAdmin_ConcertsTable")) if (current_user_can('administrator')) { $content .= ''; + . $this->adminactions($concert) + . ''; } } + $content .= ''; $content .= ''; $lastType = $concert->venue()->city(); } @@ -240,116 +244,116 @@ if (!class_exists("GiglogAdmin_ConcertsTable")) } $select .= ''; + . '" value="' . esc_attr( $val ) . '">'; } $cty = $this->get_filter('city'); $select .= \EternalTerror\ViewHelpers\select_field( - "city", - array_map(fn($city) => [$city, $city], GiglogAdmin_Venue::all_cities()), - $cty, - "Select city..."); - - - if ( !empty($cty) ) { - //second drop down for venue - $select .= \EternalTerror\ViewHelpers\select_field( - "venue", - array_map( - fn($venue) => [$venue->id(), $venue->name()], - GiglogAdmin_Venue::venues_in_city($cty) - ), - $this->get_filter('venue_id'), - "Select venue..."); - } - - $select .= \EternalTerror\ViewHelpers\select_field( - "month", - array_map( - fn($m) => [ $m, $wp_locale->get_month( $m ) ], - range( 1, 12 ) - ), - $this->get_filter('month'), - "Select month..."); - - $select.=''; - - if(is_admin()) { - //option to select own concerts only - $select .= 'get_filter( 'current_user' ) ) - . '>'; + "city", + array_map(fn($city) => [$city, $city], GiglogAdmin_Venue::all_cities()), + $cty, + "Select city..."); + + + if ( !empty($cty) ) { + //second drop down for venue + $select .= \EternalTerror\ViewHelpers\select_field( + "venue", + array_map( + fn($venue) => [$venue->id(), $venue->name()], + GiglogAdmin_Venue::venues_in_city($cty) + ), + $this->get_filter('venue_id'), + "Select venue..."); + } - } - //NOTE that I remvoed

and mvoed them up to render_concerts_table function - $select .= ''; + $select .= \EternalTerror\ViewHelpers\select_field( + "month", + array_map( + fn($m) => [ $m, $wp_locale->get_month( $m ) ], + range( 1, 12 ) + ), + $this->get_filter('month'), + "Select month..."); - return $select; - } + $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()) - . '' - . '' - . ''; - } + if(is_admin()) { + //option to select own concerts only + $select .= 'get_filter( 'current_user' ) ) + . '>'; - /** - * 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 ''; - } - } + } + //NOTE that I remvoed

and mvoed them up to render_concerts_table function + $select .= ''; - 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 $select; + } - return $f; - } - } -} + 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
CITYDATENAMEVENUEEVENTTICKETSEVENTTICKETSCalendarPHOTO1PHOTO2TEXT1TEXT2STATUS' - . $this->adminactions($concert) - . ' iCal