summaryrefslogtreecommitdiffstats
path: root/includes/admin
diff options
context:
space:
mode:
Diffstat (limited to 'includes/admin')
-rw-r--r--includes/admin/helpfiles/instr_photog.php2
-rw-r--r--includes/admin/helpfiles/instr_reviewers.php2
-rw-r--r--includes/admin/helpfiles/instrunctions.php2
-rw-r--r--includes/admin/register_db_tables.php5
-rw-r--r--includes/admin/views/giglog_admin_page.php48
-rw-r--r--includes/admin/views/giglog_import_gigs.php40
6 files changed, 53 insertions, 46 deletions
diff --git a/includes/admin/helpfiles/instr_photog.php b/includes/admin/helpfiles/instr_photog.php
index 0750557..f661c5f 100644
--- a/includes/admin/helpfiles/instr_photog.php
+++ b/includes/admin/helpfiles/instr_photog.php
@@ -13,7 +13,7 @@ if ( !class_exists( 'Instructions_Photogs' ) ) {
- static function render_instr_photo_html() {
+ static function render_instr_photo_html(): void {
diff --git a/includes/admin/helpfiles/instr_reviewers.php b/includes/admin/helpfiles/instr_reviewers.php
index e00a432..3632980 100644
--- a/includes/admin/helpfiles/instr_reviewers.php
+++ b/includes/admin/helpfiles/instr_reviewers.php
@@ -9,7 +9,7 @@ if ( !class_exists( 'Instructions_Reviewers' ) ) {
class Instructions_Reviewers {
- static function render_instr_rev_html() {
+ static function render_instr_rev_html(): void {
?>
diff --git a/includes/admin/helpfiles/instrunctions.php b/includes/admin/helpfiles/instrunctions.php
index 49b77fe..b9c4d89 100644
--- a/includes/admin/helpfiles/instrunctions.php
+++ b/includes/admin/helpfiles/instrunctions.php
@@ -9,7 +9,7 @@ if ( !class_exists( 'Instructions_Page' ) ) {
class Instructions_Page {
- static function render_instr_html() {
+ static function render_instr_html(): void {
?>
diff --git a/includes/admin/register_db_tables.php b/includes/admin/register_db_tables.php
index 947be22..11223b3 100644
--- a/includes/admin/register_db_tables.php
+++ b/includes/admin/register_db_tables.php
@@ -5,7 +5,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
if (!function_exists('giglogadmin_populate_countries')) {
- function giglogadmin_populate_countries()
+ function giglogadmin_populate_countries(): void
{
global $wpdb;
$wpdb->query(
@@ -254,6 +254,9 @@ if (!function_exists('giglogadmin_populate_countries')) {
if ( !function_exists( "giglog_register_db_tables") )
{
+ /**
+ * @return void
+ */
function giglog_register_db_tables()
{
$db_version = get_option('giglogadmin_db_version');
diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php
index 3482ae2..9d9d759 100644
--- a/includes/admin/views/giglog_admin_page.php
+++ b/includes/admin/views/giglog_admin_page.php
@@ -9,7 +9,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
require_once __DIR__ . '/../../venue.php';
class GiglogAdmin_AdminPage {
- static function render_html() {
+ static function render_html(): void {
?>
<div class="wrap">
<h1>Giglog Admin</h1>
@@ -36,13 +36,17 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
echo(GiglogAdmin_AdminPage::editforms()); //not sure why it doesn't show without the echo?
}
- static function get_allvenues($invenue)
+ static function get_venue_selector( ?GiglogAdmin_Venue $invenue ): string
{
$select = '<select name="selectvenueadmin">';
$select .= '<option value="">Please Select..</option>';
foreach ( GiglogAdmin_Venue::all_venues() AS $venue ) {
- if($invenue==$venue ->id() ) $select .= '<option value="' . $venue -> id(). '" selected="selected">'.$venue->name();
- else $select .= '<option value="' . $venue->id() . '">'. $venue->name();
+ if($invenue && $invenue->id() == $venue->id() ) {
+ $select .= '<option value="' . $venue->id(). '" selected="selected">'.$venue->name();
+ }
+ else {
+ $select .= '<option value="' . $venue->id() . '">'. $venue->name();
+ }
$select .='</option>';
}
$select .= '</select>';
@@ -50,7 +54,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
}
- static function get_user($cid, $ctype)
+ static function get_user( ?int $cid, string $ctype): string
{
$hf_user = wp_get_current_user();
$hf_username = $hf_user->user_login;
@@ -75,7 +79,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
}
- static function get_filters()
+ static function get_filters(): string
{
$cities = array_merge(["ALL"], GiglogAdmin_Venue::all_cities());
$cty = filter_input( INPUT_POST, 'selectcity', FILTER_SANITIZE_SPECIAL_CHARS );
@@ -107,9 +111,9 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
|| $venue_list[0];
$select .= '<select name="selectvenue">';
- foreach ( $venue_list AS $venue ) {
- //below line returns an erorr which I haven't really figured out yet But filtering works. It doesn't keep the venue selected in the dropdown
- $select .= '<option value="' . $venue[0] . '"' . selected($venue[0], $selected_venue) . '>';
+
+ foreach ( $venue_list as $venue ) {
+ $select .= '<option value="' . $venue[0] . '"' . selected($venue, $selected_venue) . '>';
$select .= $venue[1] . '</option>';
}
$select .= '</select>';
@@ -125,13 +129,13 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
return $select;
}
- static function editforms()
+ static function editforms(): string
{
$cid = filter_input(INPUT_POST, "cid");
$editing = filter_input(INPUT_POST, "edit") == "EDIT";
if ($editing && !empty($cid)) //A bit overdoing with the checks if concert ID is empty both here and in find_cid. But based on that, things are NULL or not. Better ideas?
- $c = GiglogAdmin_Concert::find_cid($cid);
+ $c = GiglogAdmin_Concert::get($cid);
else
$c = new GiglogAdmin_Concert();
@@ -140,7 +144,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
.'<div class="concertitems"><strong>CONCERT DETAILS</strong><br><br><fieldset>'
.'<input type="hidden" name="pid" value="' .$c->id(). '" />'
.'<label for="cname">Concert Name:</label><textarea id="cname" name="cname" value="'.$c->cname().'">'.$c->cname().'</textarea><br>'
- .'<label for="venue">Venue:</label>'.GiglogAdmin_AdminPage::get_allvenues($c->venue()).'<br>'
+ .'<label for="venue">Venue:</label>' . GiglogAdmin_AdminPage::get_venue_selector($c->venue()) . '<br>'
.'<label for="cdate">Date:</label><input type="date" id="cdate" name="cdate" value="'.$c->cdate().'"><br>'
.'<label for="ticket">Tickets:</label><input type="text" id="ticket" name="ticket" value="'.$c->tickets().'"><br>'
.'<label for="eventurl">Event link:</label><input type="text" id="eventurl" name="eventurl" value="'.$c->eventlink().'"><br>'
@@ -168,7 +172,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
return $content;
}
- static function adminactions($concert_id)
+ static function adminactions( int $concert_id ) : string
{
global $wpdb;
$query = "SELECT id,wpgs_name from wpg_pressstatus" ;
@@ -193,7 +197,10 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
}
//function to calculate if the concert has been added in the past 10 days or before that and show a green NEW for the newest rows
- static function getpublishstatus($concert_id)
+ /**
+ * @return null|string
+ */
+ static function getpublishstatus(int $concert_id)
{
global $wpdb;
$date1 = new DateTime("now");
@@ -210,11 +217,11 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
}
- static function get_concerts()
+ static function get_concerts(): string
{
$hf_user = wp_get_current_user();
$hf_username = $hf_user->user_login;
- $roles = ( array ) $hf_user->roles;
+ $roles = $hf_user->roles;
global $wpdb;
$content = '<table class="assignit">';
@@ -293,6 +300,9 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
}
+ /**
+ * @return void
+ */
static function update()
{
global $wpdb;
@@ -372,7 +382,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
}
}
- static function assignconcert($p1, $c)
+ static function assignconcert($p1, $c): void
{
global $wpdb;
@@ -393,7 +403,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
wp_mail( $to, $subject, $body, $headers );
}
- static function unassignconcert($p1, $c)
+ static function unassignconcert($p1, $c): void
{
global $wpdb;
@@ -414,7 +424,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
wp_mail( $to, $subject, $body, $headers );
}
- static function returnuser($p1, $c)
+ static function returnuser(string $p1, ?int $c): string
{
global $wpdb;
$hf_user = wp_get_current_user();
diff --git a/includes/admin/views/giglog_import_gigs.php b/includes/admin/views/giglog_import_gigs.php
index 053f505..a8daa3f 100644
--- a/includes/admin/views/giglog_import_gigs.php
+++ b/includes/admin/views/giglog_import_gigs.php
@@ -12,7 +12,7 @@ if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) {
require_once __DIR__ . '/../../venue.php';
class GiglogAdmin_ImportGigsPage {
- static function render_html() {
+ static function render_html(): void {
?>
<div class="wrap">
<h1>Import gigs</h1>
@@ -27,7 +27,7 @@ if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) {
<?php
}
- static function submit_form() {
+ static function submit_form(): void {
if ('POST' === $_SERVER['REQUEST_METHOD'] && current_user_can('upload_files') && !empty($_FILES['giglog_import_file']['tmp_name'])) {
$nonce = $_POST['giglog_import_nonce'];
$valid_nonce = isset($nonce) && wp_verify_nonce($nonce);
@@ -42,14 +42,18 @@ if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) {
* tab character:
*
* 1. Concertname
- * 2. Venuename
+ * 2. Venuename or numeric venue id
* 3. Concert date
* 4. Ticket link
* 5. Event info link
*
* Empty lines are ignored.
+ *
+ * @return void
+ *
+ * @param ArrayAccess|array $file
*/
- static function process_upload($file) {
+ static function process_upload(array $file): void {
$newconcert= [];
$fo = new SplFileObject($file['tmp_name']);
@@ -61,31 +65,21 @@ if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) {
}
$resultArray = explode("\t", $line);
- $cname = trim($resultArray[0]);
+ $cname = trim($resultArray[0]);
$venue = trim($resultArray[1]);
- $condate = date('Y-m-d', strtotime($resultArray[2]));
- $ticketlink = trim($resultArray[3]);
- $eventlink = trim($resultArray[4]);
- //first item in the row should be concert name $resultArray[0]; second should be venue $resultArray[1]; third should be concert date $resultArray[2];
- //fourth item is ticketlink $resultArray[3]; fifth item is eventlink $resultArray[4];
-
-
- if (is_numeric($venue))
- $newconcert[1] = $venue;
+ if (is_numeric($venue)) {
+ $venue = GiglogAdmin_Venue::get($venue);
+ }
else {
- $v = GiglogAdmin_Venue::find_or_create($venue,'Oslo'); //phase 666 of the project should maybe consider both city and band country when creating concerts/importing files
- $newconcert[1] = $v->id();
+ $venue = GiglogAdmin_Venue::find_or_create($venue,'Oslo');
}
- //not sure how to check dates, hopefully manual verification of files will take care of it
+ $condate = date('Y-m-d', strtotime($resultArray[2]));
+ $ticketlink = trim($resultArray[3]);
+ $eventlink = trim($resultArray[4]);
- GiglogAdmin_Concert::create(
- $cname,
- $newconcert[1],
- $condate,
- $ticketlink,
- $eventlink);
+ GiglogAdmin_Concert::create($cname, $venue->id(), $condate, $ticketlink, $eventlink);
}
}
}