From 1c8667a1d6e56ac359b18b4b364296d12b2e41a0 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 29 May 2021 13:59:03 +0200 Subject: Make AdminPage a proper object. --- includes/admin/views/giglog_admin_page.php | 57 ++++++++++++++++++------------ 1 file changed, 34 insertions(+), 23 deletions(-) (limited to 'includes') diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index c1887dc..c2c84e9 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -9,7 +9,18 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { require_once __DIR__ . '/../../venue.php'; class GiglogAdmin_AdminPage { - static function render_html(): void { + public function __construct() + { + } + + public static function render_html() : void + { + $page = new self(); + $page->render_page(); + } + + public function render_page() : void + { ?>

Giglog Admin

@@ -28,15 +39,15 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { what the accreditation status is. You will get personal message if this is really close to the concert date.

-

-

+

get_filters() ?>

+

get_concerts() ?>

user_login; @@ -62,7 +73,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { } - static function get_filters() : string + private function get_filters() : string { $cty = filter_input(INPUT_POST, 'selectcity', FILTER_SANITIZE_SPECIAL_CHARS); @@ -95,7 +106,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { return $select; } - static function editforms(): string + private function editforms(): string { $cid = filter_input(INPUT_POST, "cid"); $editing = filter_input(INPUT_POST, "edit") == "EDIT"; @@ -110,7 +121,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { .'
CONCERT DETAILS

' .'' .'
' - .'' . GiglogAdmin_AdminPage::get_venue_selector($c->venue()) . '
' + .'' . $this->get_venue_selector($c->venue()) . '
' .'
' .'
' .'
' @@ -123,10 +134,10 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { $content.='
'; $content.='
ASSIGNMENT DETAILS

' - .''.GiglogAdmin_AdminPage::get_user($c->id(),'photo1').'
' - .''.GiglogAdmin_AdminPage::get_user($c->id(),'photo2').'
' - .''.GiglogAdmin_AdminPage::get_user($c->id(),'rev1').'
' - .''.GiglogAdmin_AdminPage::get_user($c->id(),'rev2').'
'; + .''.$this->get_user($c->id(),'photo1').'
' + .''.$this->get_user($c->id(),'photo2').'
' + .''.$this->get_user($c->id(),'rev1').'
' + .''.$this->get_user($c->id(),'rev2').'
'; $content.='
'; $content.='
VENUE DETAILS

' @@ -138,7 +149,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { return $content; } - static function adminactions( int $concert_id ) : string + private function adminactions( int $concert_id ) : string { global $wpdb; $query = "SELECT id,wpgs_name from wpg_pressstatus" ; @@ -160,7 +171,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { /** * @return null|string */ - static function getpublishstatus(int $concert_id) + private function getpublishstatus(int $concert_id) { global $wpdb; $date1 = new DateTime("now"); @@ -177,7 +188,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { } - static function get_concerts(): string + private function get_concerts(): string { $hf_user = wp_get_current_user(); $hf_username = $hf_user->user_login; @@ -237,17 +248,17 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { //$content .= DATE_FORMAT($fdate,'%d.%b.%Y'); $content .= '' .$newformat. ''; - $content .= ''.GiglogAdmin_AdminPage::getpublishstatus($row->id ).''; - $content .= ''.GiglogAdmin_AdminPage::returnuser('photo1', $row->id ).''; - $content .= ''.GiglogAdmin_AdminPage::returnuser('photo2', $row->id ).''; - $content .= ''.GiglogAdmin_AdminPage::returnuser('rev1', $row->id ).''; - $content .= ''.GiglogAdmin_AdminPage::returnuser('rev2', $row->id ).''; + $content .= ''.$this->getpublishstatus($row->id ).''; + $content .= ''.$this->returnuser('photo1', $row->id ).''; + $content .= ''.$this->returnuser('photo2', $row->id ).''; + $content .= ''.$this->returnuser('rev1', $row->id ).''; + $content .= ''.$this->returnuser('rev2', $row->id ).''; $content .= ''.$row -> wpgs_name.''; if (current_user_can('administrator')) { $content .= '' - . GiglogAdmin_AdminPage::adminactions($row->id) + . $this->adminactions($row->id) . ''; } $content .= ''; @@ -294,7 +305,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { } //handling the admin drop down menu - if(isset($_POST['selectstatus']) && $_POST['edit']!="EDIT" && !empty($_POST['cid'])) + if(isset($_POST['selectstatus']) && (isset($_POST['edit']) && $_POST['edit']!="EDIT") && !empty($_POST['cid'])) { $usql = "UPDATE wpg_concertlogs SET wpgcl_status=".$_POST['selectstatus']." WHERE wpgcl_concertid=".$_POST['cid']; $uresults = $wpdb->get_results($usql); @@ -384,7 +395,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { wp_mail( $to, $subject, $body, $headers ); } - static function returnuser(string $p1, ?int $c) : ?string + private function returnuser(string $p1, ?int $c) : ?string { $hf_user = wp_get_current_user(); $hf_username = $hf_user->user_login; -- cgit v1.2.3