.
*/
if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) {
require_once __DIR__ . '/../../band.php';
require_once __DIR__ . '/../../concert.php';
require_once __DIR__ . '/../../venue.php';
class GiglogAdmin_ImportGigsPage {
static function render_html() {
?>
Import gigs
Import gig data from a tab separated data file.
Inserted the following:';
$newconcert= [];
$fo = new SplFileObject($file['tmp_name']);
foreach ($fo as $line) {
if ( empty($line) ) {
// Skip empty lines
continue;
}
$resultArray = explode("\t", $line);
$band = $resultArray[0];
$venue = $resultArray[1];
$condate = date('Y-m-d', strtotime($resultArray[2]));
$ticketlink = $resultArray[3];
$eventlink = $resultArray[4];
//first item in the row should be band $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];
$newconcert[0] = GiglogAdmin_Band::find_or_create($band);
if (is_numeric($venue))
$newconcert[1] = $venue;
else {
$newconcert[1] = GiglogAdmin_Venue::find_or_create($venue);
}
//not sure how to check dates, hopefully manual verification of files will take care of it
$cresults = GiglogAdmin_Concert::get($newconcert[0], $newconcert[1], $condate);
if ($cresults) {
$concertlist .= 'DUPLICATE ROW detected BAND ' . $band . ' with band ID ' . $newconcert[0];
$concertlist .= ', VENUE ' . $venue . ' with venue ID ' . $newconcert[1];
$concertlist .= ', CONCERTDATE ' . $condate;
$concertlist .= '
';
} else {
$newconcertid = GiglogAdmin_Band::create(
$newconcerts[0],
$newconcerts[1],
$condate,
$ticketlink,
$eventlink);
$concertlist .= 'BAND ' . $band . ' with band ID ' . $newconcert[0];
$concertlist .= ', VENUE ' . $venue . ' with venue ID ' . $newconcert[1];
$concertlist .= ', CONCERTDATE ' . $condate . ', Ticket LINK ' . $ticketlink . ', event LINK' . $eventlink;
$concertlist .= '
';
}
}
}
}
}