From 06d0591af5f2c9e0ce1c4269c55a503e9956759d Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 22 Feb 2022 21:53:00 +0100 Subject: Some cleanup in render_concerts_table --- includes/admin/views/_concerts_table.php | 56 +++++++++++++------------------- 1 file changed, 23 insertions(+), 33 deletions(-) (limited to 'includes') diff --git a/includes/admin/views/_concerts_table.php b/includes/admin/views/_concerts_table.php index 8ecd616..e9598e1 100644 --- a/includes/admin/views/_concerts_table.php +++ b/includes/admin/views/_concerts_table.php @@ -158,58 +158,48 @@ if (!class_exists("GiglogAdmin_ConcertsTable")) private function render_concerts_table() : string { - //pagination. Change value as needed - $concerts = $this->get_concerts(); - $lastType = ''; + $last_city = ''; $content = $this->render_concert_table_header(); - foreach ( $concerts AS $concert ) { - $content .= ''; - - if ($lastType != '' && $lastType != $concert->venue()->city()) { - $content .= '' . $concert->venue()->city() . ''; - } + foreach ( $concerts as $concert ) { + $content .= ''; - if ($lastType == '' ) { - $content .= '' . $concert->venue()->city() . ''; + if ($last_city != $concert->venue()->city()) { + $content .= $concert->venue()->city(); } - if ($lastType != '' && $lastType == $concert->venue()->city()) { - $content .= ''; - } + $content .= ''; - $fdate = strtotime($concert->cdate()); - $newformat = date('d.M.Y',$fdate); - //$content .= DATE_FORMAT($fdate,'%d.%b.%Y'); - $content .= '' . $newformat . ''; - $content .= ''. $concert->cname() . ''; - $content .= '' . $concert->venue()->name() . ''; - if(!is_admin()){ - $content .= 'Link'; - $content .= 'Tickets'; + $content .= + "" . date( 'd.M.Y', strtotime( $concert->cdate() ) ) . "" + . "{$concert->cname()}" + . "{$concert->venue()->name()}"; - } - else { + if( is_admin() ) { $content .= '' . $this->mark_new_concert($concert) . ''; - $content .= '' . $this->assign_role_for_user_form('photo1', $concert) . ''; - $content .= '' . $this->assign_role_for_user_form('photo2', $concert) . ''; - $content .= '' . $this->assign_role_for_user_form('rev1', $concert) . ''; - $content .= '' . $this->assign_role_for_user_form('rev2', $concert) . ''; + foreach ( [ 'photo1', 'photo2', 'rev1', 'rev2' ] as $role ) { + $content .= '' + . $this->assign_role_for_user_form( $role, $concert ) + . ''; + } $content .= '' . self::STATUS_LABELS[$concert->status()] . ''; if (current_user_can('administrator')) { - $content .= '' - . $this->adminactions($concert) - . ''; + $content .= "{$this->adminactions( $concert )}"; } } + else { + $content .= "eventlink()}\">Link"; + $content .= "tickets()}\">Tickets"; + } + $content .= ''; - $lastType = $concert->venue()->city(); + $last_city = $concert->venue()->city(); } $content .= ''; -- cgit v1.2.3