Created
October 22, 2014 22:08
-
-
Save pjhoberman/7b0364ad33c088b5f164 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <? /* | |
| * Calendar view | |
| * Privacy of event? | |
| */ | |
| ?> | |
| <link rel="stylesheet" type="text/css" href="/wp-content/plugins/eventheaders/tablesorter/themes/blue/style.css"> | |
| <style type="text/css"> | |
| .event_preview { | |
| height: 200px; | |
| width: 200px; | |
| float: left; | |
| margin: 15px; | |
| overflow: hidden; | |
| } | |
| .event_preview img { | |
| max-height: 200px; | |
| max-width: 200px; | |
| } | |
| #all-events { | |
| font-size: 18px; | |
| } | |
| #all-events td { | |
| vertical-align: middle; | |
| margin-left: 5px; | |
| } | |
| #all-events .poster { | |
| /*max-height: 150px;*/ | |
| max-width: 150px; | |
| text-align: center; | |
| } | |
| #all-events .month-row { | |
| text-align: center; | |
| font-weight: bold; | |
| font-family: 'Sansita One', cursive; | |
| font-size: 32px; | |
| } | |
| h1#all-events { | |
| font-family: 'Sansita One', cursive; | |
| font-size: 48px; | |
| } | |
| </style> | |
| <?php include_once($_SERVER['DOCUMENT_ROOT'] . "/wp-content/scripts/nightout.php"); ?> | |
| <h1 id="all-events">All Events</h1> | |
| <?php | |
| $all_events = getAllEvents(); | |
| if( $all_events ){ | |
| ?> | |
| <table id="all-events""> | |
| <tbody> | |
| <? | |
| $allevents_month = 0; | |
| $allevents_year = 0; | |
| foreach($all_events as $key => $value) { | |
| $current_year = date("Y", strtotime($value -> start_time)); | |
| $current_month = date("n", strtotime($value -> start_time)); | |
| if($allevents_month === 0 || $allevents_month < $current_month || $allevents_year < $current_year) { | |
| ?> | |
| <tr><td colspan="3" class="month-row"><?= date("F Y", strtotime($value -> start_time)) ?></td></tr> | |
| <? | |
| $allevents_month = $current_month; | |
| $allevents_year = $current_year; | |
| } | |
| if($value -> subdomain === ""){ | |
| $subdomain = getSubdomain($value->url); | |
| } else { | |
| $subdomain = $value -> subdomain; | |
| } | |
| ?> | |
| <tr> | |
| <td> | |
| <? | |
| if ($value -> poster_url -> small !== "/defaults/posters/small.png" ) { | |
| ?> | |
| <a href="/event/<?= $subdomain ?>"> | |
| <img src="<?= $value -> poster_url -> small ?>" class="poster" /> | |
| </a> | |
| <? } ?> | |
| </td> | |
| <td> | |
| <a href="/event/<?= $subdomain ?>"> | |
| <?= $value -> title ?> | |
| </a> | |
| </td> | |
| <td> | |
| <?= date("F d, Y", strtotime($value -> start_time)) ?> | |
| </td> | |
| </tr> | |
| <?php | |
| } // foreach | |
| ?> | |
| </tbody> | |
| </table> | |
| <? | |
| } else { | |
| echo "The events aren't loading right now. Please try again later, or go check out what we're talking about on <a href='http://facebook.com/imbibedenver'>Facebook</a>."; | |
| } | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <? | |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/wp-content/scripts/nightout.php"); | |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/wp-content/scripts/bad_url_logger.php"); | |
| ?> | |
| <?php | |
| $this_event = getThisEvent($event_slug); | |
| if(!$this_event){ | |
| error_log('Bad URL Request: ' . $event_slug); | |
| // todo: load bad url template | |
| echo "This event could not be loaded. Please check the URL and try again."; | |
| log_bad_url("/event/$event_slug"); | |
| } else { | |
| if( $this_event -> subdomain === "" ){ | |
| if($this_event -> slug === "") { | |
| $subdomain = getSubdomain($this_event -> url); | |
| } else { | |
| $subdomain = $this_event -> slug; | |
| } | |
| } else { | |
| $subdomain = $this_event -> subdomain; | |
| } | |
| ?> | |
| <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/styles/event-details.css"> | |
| <?php | |
| // todo - probably make getter functions to ensure data exists and doesn't break site | |
| $start_time = strtotime($this_event -> start_time) + $this_event -> tz_offset; // plus 1 hour for dst | |
| $end_time = strtotime($this_event -> end_time) + $this_event -> tz_offset; // plus 1 hour for dst | |
| $address = $this_event -> addresses[0]; | |
| $event_details_json = array( | |
| "start_date" => array( | |
| "year" => date('Y', $start_time) * 1, | |
| "month" => date('n', $start_time) * 1, | |
| "day" => date('j', $start_time) * 1, | |
| "hour" => date('G', $start_time), | |
| "minute" => date('i', $start_time) * 1 | |
| ), | |
| "location" => array( | |
| "address" => $this_event -> addresses[0] -> street, | |
| "zip" => $this_event -> addresses[0] -> zip | |
| ) | |
| ); | |
| $price_range; | |
| function getPriceRange() { | |
| global $this_event, $price_range; | |
| if (!isset($price_range -> low )) { | |
| $temp_low = 1000000000; // start high | |
| $temp_high = 0; | |
| foreach ($this_event -> ticket_types as $key => $ticket_type) { | |
| if ($ticket_type -> cent_price < $temp_low) { | |
| $temp_low = $ticket_type -> cent_price; | |
| } | |
| if ($ticket_type -> cent_price > $temp_high) { | |
| $temp_high = $ticket_type -> cent_price; | |
| } | |
| } | |
| $price_range = array("low" => $temp_low, "high" => $temp_high); | |
| } | |
| return $price_range; | |
| } | |
| function formatPriceRange() { | |
| $range = getPriceRange(); | |
| $price_low = $range[low]; | |
| $price_high = $range[high]; | |
| $formatted = number_format($price_low / 100, 2); | |
| if ($price_high !== $price_low) { | |
| $formatted .= " - " . number_format($price_high / 100, 2); | |
| } | |
| return $formatted; | |
| } | |
| ?> | |
| <script type="text/javascript"> | |
| // move this to a script file | |
| var event_details = <?= json_encode($event_details_json) ?> | |
| function tick(start_date, today) { | |
| if(start_date < today){ | |
| var seconds = '0'; | |
| } else { | |
| var seconds = Math.floor((start_date-today) / 1000); | |
| } | |
| var days = Math.floor(seconds / 60 / 60 / 24); | |
| seconds -= days * 60 * 60 * 24; | |
| var hours = Math.floor(seconds / 60 / 60); | |
| seconds -= hours * 60 * 60; | |
| var minutes = Math.floor(seconds/ 60); | |
| seconds -= minutes * 60; | |
| if (days < 10) | |
| days = "0" + days; | |
| if (hours < 10) | |
| hours = "0" + hours; | |
| if (minutes < 10 ) | |
| minutes = "0" + minutes; | |
| if (seconds < 10 ) | |
| seconds = "0" + seconds; | |
| jQuery('#ticker_days').text(days); | |
| jQuery('#ticker_hours').text(hours); | |
| jQuery('#ticker_minutes').text(minutes); | |
| jQuery('#ticker_seconds').text(seconds); | |
| if(start_date >= today){ | |
| var new_date = new Date(start_date - 1000); | |
| var t = setTimeout(function(){ | |
| tick(new_date, today); | |
| }, 1000); | |
| } | |
| } | |
| function full_address(){ | |
| return event_details.location.address + ', ' + event_details.location.zip; | |
| } | |
| jQuery(document).ready(function(){ | |
| var today = new Date(); | |
| var start_date = new Date(event_details.start_date.year, event_details.start_date.month - 1, event_details.start_date.day, event_details.start_date.hour, event_details.start_date.minute, 0); | |
| tick(start_date, today); | |
| // kill sales if event is over | |
| if (start_date < today) { | |
| jQuery('#add-item-form').remove(); | |
| jQuery('#add-item-form').on('submit', function() { return false; }); // just to be safe | |
| jQuery('#too-late').show(); | |
| } | |
| }); | |
| </script> | |
| <?php | |
| // if($this_event) { ?> | |
| <!-- <div id="eventTitle"><?= $this_event -> title ?></div> | |
| <div id="eventStart"><?= $this_event -> start_time ?></div> | |
| <div id="eventEnd"><?= $this_event -> end_time ?></div> | |
| <div id="eventDescription"><?= $this_event -> description ?></div> | |
| <div id="eventPoster"><img src="<?= $this_event -> poster_url -> large ?>" /></div> | |
| <iframe id="ticketingEmbed" src="https://embed.nightout.com/events/<?= $subdomain ?>" height="600px" width="400px"></iframe> | |
| --> | |
| <?php // } else { ?> | |
| <!-- We couldn't find this event. Please try again. --> | |
| <?php //} ?> | |
| <div class="grid col-940" style="margin-top:-10px;"> | |
| <!-- Begin featured image --> | |
| <div class="image featured"> | |
| <? if ( isset($this_event -> header_image)) { ?> | |
| <img src="<?=$this_event -> header_image?>" /> | |
| <? } else { ?> | |
| <h1 id="event-title"><?= $this_event -> title ?></h1> | |
| <? } ?> | |
| </div> | |
| <!-- End product image --> | |
| </div> | |
| <div class="grid col-940"> | |
| <div class="description"> | |
| <span id="tag_line"></span> | |
| </div> | |
| <div class="details grid col-940"> | |
| <!-- WHEN --> | |
| <div class="when grid col-300"> | |
| <img src="/wp-content/imbibe-images/Calendar.png"> | |
| <span class="day-of-week" id="dow"><?= date( 'l', $start_time) ?></span><br> | |
| <span class="date" id="event_date"><?= date('F j, Y', $start_time) ?></span><br> | |
| <span class="time" id="event_time"><?= date('g:i a', $start_time) ?> - <?= date('g:i a', $end_time) ?></span> | |
| </div> | |
| <!-- WHERE --> | |
| <div class="where grid col-300"> | |
| <img src="/wp-content/imbibe-images/Map-pin.png"> | |
| <span class="location-name" id="location-name"><?= $this_event -> addresses[0] -> name ?></span><br> | |
| <span class="address" id="address"><?= $this_event -> addresses[0] -> street ?></span><br> | |
| <span class="citystate" id="citystate"><?= zipToCityState($this_event -> addresses[0] -> zip) ?></span> | |
| </div> | |
| <!-- PRICE --> | |
| <div class="pricing grid col-300 fit"> | |
| <img src="/wp-content/imbibe-images/dolla-sign.png"> | |
| <span class="price-title">Price</span><br> | |
| <span class="price-range" id="price-range"><?= formatPriceRange() ?></span> | |
| </div> | |
| <hr class="designed grid col-940"> | |
| </div> | |
| <div id="ticketing-small"> | |
| <h2>Get your tickets</h2> | |
| <iframe id="nightout-tickets-small" width="100%" height="620" frameborder="0" border="0" src="https://embed.nightout.com/events/<?= $subdomain ?>"></iframe> | |
| <div id="too-late" class="grid col-300"> | |
| <p>You snooze you lose! This event already happened, but we have plenty more parties for you. Sign up for our newsletter and never miss out again.</p> | |
| <form action="http://imbibedenver.us4.list-manage.com/subscribe/post?u=7ac95e8ad52ca60aca50afc48&id=396c7d3287" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" target="_blank"> | |
| <input type="email" value="" placeholder="Email Address" name="EMAIL" id="mail"><input type="submit" class="btn newsletter" value="Subscribe" name="subscribe" id="subscribe"> | |
| </form> | |
| </div> | |
| </div> | |
| <div id="event-details" class="grid col-460"> | |
| <? | |
| if ( !isset($this_event -> header_image)) { | |
| ?> | |
| <img src="<?= $this_event -> poster_url -> large ?>" /> | |
| <? } ?> | |
| <h2>Event Details</h2> | |
| <div id="event-details-content"> | |
| <?= $this_event -> description ?> <? // dangerous with html.. clean this? ?> | |
| </div> | |
| <div id="ticker"> | |
| <div id="ticker_days">00</div> | |
| <div id="ticker_hours">00</div> | |
| <div id="ticker_minutes">00</div> | |
| <div id="ticker_seconds">00</div><br> | |
| </div> | |
| </div> | |
| <div class="grid col-460 fit"> | |
| <div id="ticketing" > | |
| <h2>Get your tickets</h2> | |
| <iframe id="nightout-tickets" width="100%" height="450" frameborder="0" border="0" name="Big Dog Test Event" src="https://embed.nightout.com/events/<?= $subdomain ?>" style="margin-bottom: 50px;"></iframe> | |
| <div id="too-late" class="grid col-300"> | |
| <p>You snooze you lose! This event already happened, but we have plenty more parties for you. Sign up for our newsletter and never miss out again.</p> | |
| <form action="http://imbibedenver.us4.list-manage.com/subscribe/post?u=7ac95e8ad52ca60aca50afc48&id=396c7d3287" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" target="_blank"> | |
| <input type="email" value="" placeholder="Email Address" name="EMAIL" id="mail"><input type="submit" class="btn newsletter" value="Subscribe" name="subscribe" id="subscribe"> | |
| </form> | |
| </div> | |
| </div> | |
| <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> | |
| <script> | |
| var map; | |
| function initialize() { | |
| var mapOptions = { | |
| zoom: 12, | |
| mapTypeId: google.maps.MapTypeId.ROADMAP | |
| }; | |
| map = new google.maps.Map(document.getElementById('map-canvas'), | |
| mapOptions); | |
| geocoder = new google.maps.Geocoder(); | |
| //var latlng = new google.maps.LatLng({{product.metafields.evey.latitude}}, {{product.metafields.evey.longitude}}); | |
| geocoder.geocode( {'address': full_address()}, function(results, status) { | |
| // geocoder.geocode( {'latLng': latlng}, function(results, status) { | |
| if (status == google.maps.GeocoderStatus.OK) { | |
| //In this case it creates a marker, but you can get the lat and lng from the location.LatLng | |
| map.setCenter(results[0].geometry.location); | |
| var marker = new google.maps.Marker({ | |
| map: map, | |
| position: results[0].geometry.location | |
| }); | |
| } | |
| }); | |
| } | |
| google.maps.event.addDomListener(window, 'load', initialize); | |
| </script> | |
| <div id="map-canvas" style="height: 250px; width: 470px"></div> | |
| <!-- Begin social buttons --> | |
| <? // todo: most of these buttons don't work ?> | |
| <div class="social" style="margin-top:50px;"> | |
| <div id="social" class="clearfix span5 inner-left"> | |
| <p class="share-this"><strong>Share this event:</strong><br> | |
| <span style="font-size: 10px;">(no one likes to party alone)</span> | |
| </p> | |
| <div id="share-btns"> | |
| <div class="share-btn"> | |
| <a href="http://twitter.com/share?u=Check+out+this+event!+<?= $this_event -> title ?>:+<?= get_site_url() ?>/event/<?= $subdomain ?>" target="_blank"><img src="/wp-content/imbibe-images/Twitter.png"></a> | |
| </div> | |
| <div class="share-btn"> | |
| <a href="https://plus.google.com/share?url=<?= get_site_url() ?>/event/<?= $subdomain ?>" target="_blank"> | |
| <img src="/wp-content/imbibe-images/Google-Plus.png"> | |
| </a> | |
| <!-- <g:plusone size="medium" annotation="none"></g:plusone>--> | |
| </div> | |
| <div class="share-btn"> | |
| <a href="https://www.facebook.com/sharer/sharer.php?u=<?= get_site_url() ?>/event/<?= $subdomain ?>" target="_blank"><img src="/wp-content/imbibe-images/Facebook.png?1825"></a> | |
| </div> | |
| <div class="share-btn"> | |
| <a href="https://mail.google.com/mail/?view=cm&fs=1&tf=1&to=&su=Check+out+<?= $this_event -> title ?>&body=Check+out+this+event!%0D%0A%0D%0A<?= get_site_url() ?>/event/<?= $subdomain ?>" target="_blank"> | |
| <img src="/wp-content/imbibe-images/Email.png?1825"> | |
| </a> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script type="text/javascript"> | |
| (function() { | |
| var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; | |
| po.src = 'https://apis.google.com/js/plusone.js'; | |
| var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); | |
| })(); | |
| </script> | |
| </div> | |
| <!-- End social buttons --> | |
| </div> | |
| <?php } // end of bad url check if / else ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| include_once($_SERVER['DOCUMENT_ROOT'] . "/wp-content/scripts/phpfastcache/phpfastcache.php"); | |
| // cache docs -- http://www.phpfastcache.com/ | |
| function getEventURL($id) { | |
| // not currently in use | |
| global $api_url, $api_oauth_string; | |
| return $api_url . '/' . $id . $api_oauth_string . '&details=full'; | |
| } | |
| function getAllEvents() { | |
| global $api_all_events_url, $all_events; | |
| // check the live variables | |
| if(!isset($all_events)) { | |
| // check the cache | |
| $cache = phpFastCache(); | |
| if ($cache->get('all_events') !== null) { | |
| $all_events = $cache->get('all_events'); | |
| } else { | |
| $all_events = json_decode(file_get_contents($api_all_events_url)); | |
| } | |
| } | |
| return $all_events; | |
| } | |
| function slugToID($slug){ | |
| // not currently in use | |
| $all_events = getAllEvents(); | |
| foreach ($all_events as $key => $value) { | |
| if($value -> subdomain == $slug) { | |
| return $all_events[$key] -> id; | |
| } | |
| } | |
| return false; | |
| } | |
| function get_http_response_code($url) { | |
| // source: http://stackoverflow.com/questions/4358130/file-get-contents-when-url-doesnt-exist | |
| $headers = get_headers($url); | |
| return substr($headers[0], 9, 3); | |
| } | |
| function getThisEvent($slug){ | |
| // TODO - why is this being called three times per page | |
| global $api_url, $api_oauth_string; | |
| if($slug === "" || $slug == null) { | |
| return false; | |
| } | |
| // check the cache | |
| $cache = phpFastCache(); | |
| $this_event = $cache->get("event[$slug]"); | |
| if($this_event == null || isset($_GET['refresh'])){ | |
| $event_url = $api_url . '/' . $slug . $api_oauth_string . '&details=full'; | |
| if ( get_http_response_code($event_url) != "404" ) { | |
| $this_event = json_decode(file_get_contents($event_url)); | |
| $eventheader = getEventheader($slug); // special plugin outside of api | |
| if($eventheader != null) { | |
| $this_event -> header_image = $eventheader -> image_url; | |
| } | |
| $cache->set("event[$slug]", $this_event, 60 * 60 * 12); // set the cache for 12 hours | |
| return $this_event; | |
| } else { | |
| return false; | |
| } | |
| } else { | |
| return $cache->get("event[$slug]"); | |
| } | |
| } // getThisEvent | |
| function getEventheader($slug) { | |
| global $wpdb; | |
| $table = $wpdb->prefix . "eventheaders"; | |
| $record = $wpdb->get_row("SELECT * FROM $table WHERE slug = '$slug'"); | |
| return $record; | |
| } // getEventheader | |
| function zipToCityState($zip){ | |
| // uses ziptasticapi.com API. | |
| $ziptastic = json_decode(file_get_contents("http://ziptasticapi.com/" . $zip)); | |
| return ucfirst(strtolower($ziptastic -> city)) . ", " . $ziptastic -> state; | |
| } | |
| function getSubdomain($url) { | |
| $pattern = '/https:\/\/nightout.com\/events\/([\w-]*)\/tickets/'; | |
| preg_match($pattern, $url, $matches); | |
| return $matches[1]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment