2013-01-31 08:00:19 +00:00
< ?
$Concerts = '' ;
ob_start ();
$ArtistEvents = LastFM :: get_artist_events ( $ArtistID , $Name );
$Hidden = false ;
if ( $ArtistEvents === false ) { // Something went wrong
echo '<br />An error occurred when retrieving concert info.<br />' ;
} elseif ( ! isset ( $ArtistEvents [ 'events' ][ 'event' ])) { // No upcoming events
echo '<br />This artist has no upcoming concerts.<br />' ;
$Hidden = true ;
} else {
echo '<ul>' ;
if ( isset ( $ArtistEvents [ 'events' ][ 'event' ][ 0 ])) { // Multiple events
foreach ( $ArtistEvents [ 'events' ][ 'event' ] as $Event ) {
make_concert_link ( $Event );
}
} else { // Single event
2015-01-28 08:00:26 +00:00
make_concert_link ( $ArtistEvents [ 'events' ][ 'event' ], $Name );
2013-01-31 08:00:19 +00:00
}
echo '</ul>' ;
}
$Concerts .= ob_get_clean ();
?>
2013-01-02 08:00:26 +00:00
< div class = " box " >
2013-01-16 08:00:31 +00:00
< div id = " concerts " class = " head " >
< a href = " # " >& uarr ; </ a >& nbsp ; < strong > Upcoming concerts </ strong >
2013-06-17 08:01:02 +00:00
< a href = " # " class = " brackets " onclick = " $ ('#concertsbody').gtoggle(); return false; " > Toggle </ a >
2013-01-16 08:00:31 +00:00
</ div >
2013-04-17 08:00:58 +00:00
< div id = " concertsbody " < ? = $Hidden ? ' class="hidden"' : '' ?> >
2013-01-31 08:00:19 +00:00
< ? = $Concerts ?>
2013-01-02 08:00:26 +00:00
</ div >
</ div >
< ?
2015-01-28 08:00:26 +00:00
function make_concert_link ( $Event , $Name ) {
2013-01-02 08:00:26 +00:00
// The event doesn't have a start date (this should never happen)
2013-04-17 08:00:58 +00:00
if ( $Event [ 'startDate' ] == '' ) {
2013-01-02 08:00:26 +00:00
return ;
}
$Date = get_date_title ( $Event [ 'startDate' ]);
2013-05-21 08:01:09 +00:00
$ConcertTitle = $Date . ' - ' . $Event [ 'venue' ][ 'name' ] . ' at ' .
2013-01-02 08:00:26 +00:00
$Event [ 'venue' ][ 'location' ][ 'city' ] . ', ' . $Event [ 'venue' ][ 'location' ][ 'country' ];
2013-05-21 08:01:09 +00:00
$Concert = " <a href= \" " . $Event [ 'url' ] . " \" > $ConcertTitle </a> " ;
2013-01-02 08:00:26 +00:00
?>
< form class = " hidden " action = " " id = " concert<?= $Event['id'] ?> " method = " post " >
2013-04-17 08:00:58 +00:00
< input type = " hidden " name = " action " value = " concert_thread " />
2015-01-28 08:00:26 +00:00
< input type = " hidden " name = " concert_title " value = " <?='[Concert] ' . $Event['artists'] ['artist'] . " - $ConcertTitle " ?> " />
2013-04-17 08:00:58 +00:00
< input type = " hidden " name = " concert_id " value = " <?= $Event['id'] ?> " />
< input type = " hidden " name = " concert_template " value = " <?=get_concert_post_template( $Name , $Event )?> " />
2013-01-02 08:00:26 +00:00
</ form >
2013-02-09 08:01:01 +00:00
< li >< ? = $Concert ?> - <a href="#" class="brackets" onclick="$('#concert<?=$Event['id']?>').raw().submit(); return false;">Go to thread</a></li>
2013-01-02 08:00:26 +00:00
< ?
}
2013-04-17 08:00:58 +00:00
function get_concert_post_template ( $Artist , $Event ) {
$With = '' ;
$EventTitle = '' ;
$Location = '' ;
$Directions = '' ;
$Website = '' ;
2013-01-02 08:00:26 +00:00
if ( ! empty ( $Event [ 'venue' ][ 'website' ])) {
2013-04-17 08:00:58 +00:00
$Url = $Event [ 'venue' ][ 'website' ];
2013-01-02 08:00:26 +00:00
if ( strpos ( $Url , '://' ) === false ) {
$Url = 'http://' . $Url ;
}
$EventTitle = " [url= " . $Event [ 'venue' ][ 'website' ] . " ] " . $Event [ 'venue' ][ 'name' ] . " [/url] " ;
} else {
$EventTitle = $Event [ 'venue' ][ 'name' ];
}
if ( ! empty ( $Event [ 'venue' ][ 'location' ][ 'street' ]) && ! empty ( $Event [ 'venue' ][ 'location' ][ 'street' ]) && ! empty ( $Event [ 'venue' ][ 'location' ][ 'street' ])) {
$Location = $Event [ 'venue' ][ 'location' ][ 'street' ] . " \n " . $Event [ 'venue' ][ 'location' ][ 'city' ] . " , " . $Event [ 'venue' ][ 'location' ][ 'country' ];
}
if ( ! empty ( $Event [ 'venue' ][ 'name' ]) && ! empty ( $Event [ 'venue' ][ 'city' ])) {
$Directions = " [b]Directions:[/b] [url=https://maps.google.com/maps?f=q&q= " . urlencode ( $Event [ 'venue' ][ 'name' ] . " , " . $Event [ 'venue' ][ 'location' ][ 'city' ]) . " &ie=UTF8&om=1&iwloc=addr]Show on Map[/url] " ;
}
if ( ! empty ( $Event [ 'venue' ][ 'website' ])) {
2013-04-17 08:00:58 +00:00
$Url = $Event [ 'venue' ][ 'website' ];
2013-01-02 08:00:26 +00:00
if ( strpos ( $Url , '://' ) === false ) {
$Url = 'http://' . $Url ;
}
2015-01-28 08:00:26 +00:00
$Website = '[b]Website:[/b] ' . $Url ;
2013-01-02 08:00:26 +00:00
}
2013-07-17 08:00:52 +00:00
if ( isset ( $Event [ 'artists' ][ 'artist' ]) && ( count ( $Event [ 'artists' ][ 'artist' ]) === 1 && strtolower ( $Event [ 'artists' ][ 'artist' ][ 1 ]) == strtolower ( $Artist ))) {
2013-01-02 08:00:26 +00:00
$i = 0 ;
$j = count ( $Event [ 'artists' ][ 'artist' ]) - 1 ;
foreach ( $Event [ 'artists' ][ 'artist' ] as $WithArtist ) {
2013-07-17 08:00:52 +00:00
if ( $i === $j ) {
2013-01-02 08:00:26 +00:00
$With .= " and [artist] " . $WithArtist . " [/artist] " ;
} elseif ( $i == 0 ) {
$With .= " [artist] " . $WithArtist . " [/artist] " ;
} else {
$With .= " , [artist] " . $WithArtist . " [/artist] " ;
}
$i ++ ;
}
}
return " [align=center][size=6][artist] " . $Artist . " [/artist] at " . $EventTitle . " [/size]
2013-07-17 08:00:52 +00:00
[ size = 4 ] $With
2013-01-02 08:00:26 +00:00
[ b ] " . get_date_post( $Event['startDate'] ) . " [ / b ][ / size ]
2013-07-17 08:00:52 +00:00
[ size = 3 ] $Location " . " [ / align ]
2013-01-02 08:00:26 +00:00
2013-07-17 08:00:52 +00:00
$Directions
$Website
2013-01-02 08:00:26 +00:00
[ b ] Last . fm Listing : [ / b ] [ url = " . $Event['venue'] ['url'] . " ] Visit Last . fm [ / url ]
[ align = center ] . . . . . . . . . . [ / align ] " ;
}
2013-04-17 08:00:58 +00:00
function get_date_title ( $Str ) {
2013-01-02 08:00:26 +00:00
$Exploded = explode ( ' ' , $Str );
2013-04-17 08:00:58 +00:00
$Date = $Exploded [ 2 ] . ' ' . $Exploded [ 1 ] . ', ' . $Exploded [ 3 ];
2013-01-02 08:00:26 +00:00
return $Date ;
}
2013-04-17 08:00:58 +00:00
function get_date_post ( $Str ) {
2013-01-02 08:00:26 +00:00
$Exploded = explode ( ' ' , $Str );
2013-04-17 08:00:58 +00:00
$Date = $Exploded [ 2 ] . ' ' . $Exploded [ 1 ] . ', ' . $Exploded [ 3 ] . ' (' . rtrim ( $Exploded [ 0 ], ',' ) . ')' ;
2013-01-02 08:00:26 +00:00
return $Date ;
}
?>