summaryrefslogtreecommitdiffstats
path: root/includes/admin/views/giglog_import_gigs.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/admin/views/giglog_import_gigs.php')
-rw-r--r--includes/admin/views/giglog_import_gigs.php112
1 files changed, 50 insertions, 62 deletions
diff --git a/includes/admin/views/giglog_import_gigs.php b/includes/admin/views/giglog_import_gigs.php
index 7cf4009..ed6f978 100644
--- a/includes/admin/views/giglog_import_gigs.php
+++ b/includes/admin/views/giglog_import_gigs.php
@@ -38,26 +38,23 @@ if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) {
}
/**
- * Imports concert data from a file with tab separated values.
- *
- * The file must contain the following columns each separated by _one_
- * tab character:
- *
- * 1. Concertname
- * 2. Venuename or numeric venue id
- * 3. Concert date
- * 4. Ticket link
- * 5. Event info link
- *
- * Empty lines are ignored.
- *
- * @return void
- *
- * @param array<int, mixed>
- */
-
-
-
+ * Imports concert data from a file with tab separated values.
+ *
+ * The file must contain the following columns each separated by _one_
+ * tab character:
+ *
+ * 1. Concertname
+ * 2. Venuename or numeric venue id
+ * 3. Concert date
+ * 4. Ticket link
+ * 5. Event info link
+ *
+ * Empty lines are ignored.
+ *
+ * @return void
+ *
+ * @param array<mixed>
+ */
static function process_upload(array $file): void {
global $wpdb;
$newconcert= [];
@@ -86,66 +83,57 @@ if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) {
continue;
}
-
-
else {
- if (empty(trim($resultArray[0])))
- { $importerrors.= 'Row '.$rid.' is missing concert name!'."<br>";
+ if (empty(trim($resultArray[0]))) {
+ $importerrors.= 'Row '.$rid.' is missing concert name!'."<br>";
continue;
}
- else if (empty(trim($resultArray[1])))
- { $importerrors.= 'Row '.$rid.' is missing venue name!'."<br>";
+ elseif (empty(trim($resultArray[1]))) {
+ $importerrors.= 'Row '.$rid.' is missing venue name!'."<br>";
continue;
}
-
- else if (empty(trim($resultArray[2])))
- { $importerrors.= 'Row '.$rid.' is missing city name!' ."<br>";
+ elseif (empty(trim($resultArray[2]))) {
+ $importerrors.= 'Row '.$rid.' is missing city name!' ."<br>";
continue;
}
-
else {
$condate = date('Y-m-d', strtotime($resultArray[3]));
- if ($condate<date("Y-m-d"))
- {$importerrors.= 'Row '.$rid.' has date in the past!' .$resultArray[3]."<br>";
- continue; }
+ if ($condate<date("Y-m-d")) {
+ $importerrors.= 'Row '.$rid.' has date in the past!' .$resultArray[3]."<br>";
+ continue;
+ }
+ else {
+ $cname = trim($resultArray[0]);
+ $venue = trim($resultArray[1]);
+ if (is_numeric($venue)) {
+ $venue = GiglogAdmin_Venue::get($venue);
+ }
else {
+ $venue = GiglogAdmin_Venue::find_or_create($venue,trim($resultArray[2]));
+ }
+ $ticketlink = trim($resultArray[4]);
+ $eventlink = trim($resultArray[5]);
- $cname = trim($resultArray[0]);
- $venue = trim($resultArray[1]);
-
-
- if (is_numeric($venue)) {
- $venue = GiglogAdmin_Venue::get($venue);
- }
- else {
- $venue = GiglogAdmin_Venue::find_or_create($venue,trim($resultArray[2]));
- }
-
-
- $ticketlink = trim($resultArray[4]);
- $eventlink = trim($resultArray[5]);
-
- try {
- GiglogAdmin_Concert::create($cname, $venue->id(), $condate, $ticketlink, $eventlink);
-
- }
-
-
- catch(Exception $e) {
- $importerrors.= 'Row '.$rid.' is duplicate (or failed due unknown error)!'."<br>";
- }
+ try {
+ GiglogAdmin_Concert::create($cname, $venue->id(), $condate, $ticketlink, $eventlink);
+ }
+ catch(Exception $e) {
+ $importerrors.= 'Row '.$rid.' is duplicate (or failed due unknown error)!'."<br>";
}
}
-
}
-
-
}
}
- if (!empty($importerrors)) echo ($importerrors);
- else echo ('All rows imported ok');
+ }
+
+ if (!empty($importerrors)) {
+ echo ($importerrors);
+ }
+ else {
+ echo ('All rows imported ok');
}
}
}
+}