diff -r 000000000000 -r 03b0d1493584 web/wp-content/plugins/gigs-calendar/gigs-calendar.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/wp-content/plugins/gigs-calendar/gigs-calendar.php Wed Dec 23 17:55:33 2009 +0000 @@ -0,0 +1,917 @@ + + + + + = 2.5 ) { + ?> + + + + + + __('Gigs', $gcd), + 'archive' => __('Archive', $gcd), + 'venues' => __('Venues', $gcd), + 'tours' => __('Tours', $gcd), + 'settings' => __('Settings', $gcd), + 'feedback' => __('Feedback/Bugs', $gcd), + 'credits' => __('Credits', $gcd), + ); + + foreach ( $pages as $key => $name ) { + $pages[$key] = array('name'=>$name, 'key'=>$key, 'url'=>$folder . $key . '.ajax.php'); + } + + if ( $options['admin-only-settings'] && !current_user_can('administrator') ) { + unset($pages['settings']); + } + + $pages = apply_filters('gigCal_pages', $pages); + ?> + +
+

+ +
+
+
+ +
+ +
+ +
+
+ + sortTours(); + foreach ( $tours as $tour ) { + dtc_gigs::generateList(array( + 'caption'=> $is_archive ? __('Upcoming shows', $gcd) : '', + 'dateFormat' => 'short', + 'tour' => $tour, + )); + } + dtc_gigs::generateList(array( + 'caption'=> '
' . __('Other shows', $gcd) . '
', + 'dateFormat' => 'short', + 'tour' => -1, + )); + } else { + dtc_gigs::generateList(array( + 'caption'=> $is_archive ? __('Upcoming shows', $gcd) : '', + 'dateFormat' => 'short', + )); + } + } + if ( !empty($options['archive']) && is_page($options['archive']) ) { + if ( $options['tours-display'] ) { + $t = new tour(); + $tours = $t->sortTours(); + foreach ( $tours as $tour ) { + dtc_gigs::generateList(array( + 'upcoming'=>false, + 'caption'=> $is_archive ? __('Upcoming shows', $gcd) : '', + 'dateFormat' => 'short', + 'tour' => $tour, + )); + } + dtc_gigs::generateList(array( + 'upcoming'=>false, + 'caption'=> '
' . __('Other shows', $gcd) . '
', + 'dateFormat' => 'short', + 'tour' => -1, + )); + } else { + dtc_gigs::generateList(array( + 'upcoming'=>false, + 'caption'=> $is_parent ? __('Past show archive', $gcd) : '', + 'dateFormat' => 'archive', + )); + } + } + + dtcGigs::loadTemplate('rss'); + dtcGigs::loadTemplate('attribution'); + $out = ob_get_clean(); + if ( $options['calendar-position'] == 'bottom' ) { + $out = '
' . $in . '
' . $out; + } else { + $out .= '
' . $in . '
'; + } + } else { + $g = new gig(); + if ( $g->getByPostID($post->ID) ) { + $data = array( + 'g' => $g, + 'v' => $g->getVenue(), + 'p' => $g->getPerformances(), + 'image_folder' => dtc_gigs::get_url() . 'images/', + 'tags' => $g->getTags(), + 'tags_slugs' => $g->getTags(true), + 'custom' => $g->getCustom(), + ); + ob_start(); + dtcGigs::loadTemplate('gig-post', null, $data); + $out = ob_get_clean(); + + $out = '
' . $in . '
' . $out; + } else { + $out = $in; + } + } + if ( preg_match_all('~\[gig-cal ?(.*?)\]~', $out, $matches) ) { + $matches[0] = array_unique($matches[0]); + foreach ( $matches[0] as $key => $match ) { + $args = array(); + parse_str(str_replace(' ', '&', $matches[1][$key]), $args); + $args['upcoming'] = (strpos($matches[1][$key], 'archive') !== FALSE) ? false : true; + $args['return'] = true; + $out = str_replace($match, dtc_gigs::generateList($args), $out); + } + } + return $out; + } + + function upgrade() { + global $wpdb; + + if ( isset($wpdb->charset) && !empty($wpdb->charset) ) { + $charset = ' DEFAULT CHARSET=' . $wpdb->charset; + } elseif ( defined(DB_CHARSET) && DB_CHARSET != '' ) { + $charset = ' DEFAULT CHARSET=' . DB_CHARSET; + } else { + $charset = ''; + } + + $queries = array( + array( // 1 + ' + CREATE TABLE IF NOT EXISTS `' . TABLE_VENUES . '` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , + `name` VARCHAR( 255 ) NOT NULL , + `address` TEXT NOT NULL , + `city` VARCHAR( 255 ) NOT NULL , + `state` VARCHAR( 255 ) NOT NULL , + `country` VARCHAR( 255 ) NOT NULL , + `postalCode` VARCHAR( 255 ) NOT NULL , + `contact` VARCHAR( 255 ) NOT NULL , + `phone` VARCHAR( 255 ) NOT NULL , + `email` VARCHAR( 255 ) NOT NULL , + `link` VARCHAR( 255 ) NOT NULL , + `notes` TEXT NOT NULL , + `private` TINYINT NOT NULL , + `apiID` INT UNSIGNED NOT NULL , + `deleted` TINYINT NOT NULL + ) ' . $charset . ' + ', ' + CREATE TABLE IF NOT EXISTS `' . TABLE_GIGS . '` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , + `venueID` INT UNSIGNED NOT NULL , + `date` DATE NOT NULL , + `notes` TEXT NOT NULL, + `postID` BIGINT UNSIGNED NOT NULL + ) ' . $charset . ' + ', ' + CREATE TABLE IF NOT EXISTS `' . TABLE_PERFORMANCES . '` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , + `gigID` INT UNSIGNED NOT NULL , + `time` TIME NULL , + `link` VARCHAR( 255 ) NOT NULL , + `shortNotes` VARCHAR( 255 ) NOT NULL , + `ages` VARCHAR( 255 ) NOT NULL + ) ' . $charset . ' + ' + ), array( // 2 + 'ALTER TABLE `' . TABLE_VENUES . '` ADD `customMap` VARCHAR( 255 ) NOT NULL', + 'ALTER TABLE `' . TABLE_GIGS . '` ADD `eventName` VARCHAR( 255 ) NOT NULL', + ), array( // 3 + ' + CREATE TABLE `' . TABLE_TOURS . '` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , + `name` VARCHAR( 255 ) NOT NULL , + `notes` MEDIUMTEXT NOT NULL , + `pos` INT UNSIGNED NOT NULL + ) ' . $charset . ' + ', ' + ALTER TABLE `' . TABLE_GIGS . '` ADD `tour_id` INT UNSIGNED NULL + ', + ), + + + + ); + for ( $i = (int) get_option('gig_db_version'); $i < (int) DTC_GIGS_DB_VERSION; $i++) { + if ( isset($queries[$i]) ) { + foreach ( $queries[$i] as $q ) { + $wpdb->query($q); + } + } + } + + if ( count($wpdb->get_results('show tables like "' . GIGS_DB_PREFIX . 'gigs_%"')) != 4 ) { + update_option("gig_db_version", -1); + } else { + update_option("gig_db_version", (int) DTC_GIGS_DB_VERSION); + } + } + + + function hide_posts($where) { + $o = get_option('gigs-calendar'); + if ( 0 < (int) get_option('gig_db_version') && $o['post-filtering'] ) { + global $wp_the_query; + global $wp_query; + global $wp_actions; + global $wpdb; + if ( in_array('get_sidebar', $wp_actions) ) { + $where .= ' AND ID NOT IN (SELECT postID FROM ' . TABLE_GIGS . ')'; + } elseif ( (is_single() || (function_exists('is_tag') && is_tag())) ) { + return $where; + } elseif ( (!is_category() || $wp_the_query->query_vars['cat'] != $o['category']) || defined('gigs-query-mod')) { + $where .= ' AND ID NOT IN (SELECT postID FROM ' . TABLE_GIGS . ')'; + } + } + return $where; + } + + function hide_archives($where) { + $o = get_option('gigs-calendar'); + if ( $o['post-filtering'] ) { + global $wpdb; + return $where . ' AND ID NOT IN (SELECT postID FROM ' . TABLE_GIGS . ')'; + } + } + + + function post_nav($where) { + $o = get_option('gigs-calendar'); + if ( 0 < (int) get_option('gig_db_version') && $o['post-filtering'] ) { + global $wp_the_query, $include_folder, $wpdb, $wp_version; + + include_once 'gigs-classes.php'; + + $wtq = $wp_the_query; + $g = new gig(); + + $table = ''; // This will let me support versions < 2.3 + if ( (float) $wp_version >= 2.3 ) { + $table = 'p.'; + } + + if ( $wtq->is_single && $wpdb->get_var('SELECT COUNT(*) FROM ' . TABLE_GIGS . ' WHERE postID = ' . $wtq->post->ID) ) { // Is a gig + $where .= ' AND ' . $table . 'ID IN (SELECT postID FROM ' . TABLE_GIGS . ')'; + } else { + $where .= ' AND ' . $table . 'ID NOT IN (SELECT postID FROM ' . TABLE_GIGS . ')'; + } + } + return $where; + } + + function widget_upcoming($args) { + extract($args); + $o = get_option('gigs-calendar'); + if ( !isset($o['widget']['upcoming']) ) $o['widget']['upcoming'] = array(); + ?> + + + true, + 'limit'=>$o['widget']['upcoming']['length'], + 'template'=>'upcoming-widget', + ), + $o['widget']['upcoming'] + )); + ?> + + 'City', + 'country' => 'Country', + 'venue' => 'Venue', + 'eventName' => 'Event Name', + ); + + ?> +

+ +

+

+ +

+

+ date() function syntax', $gcd) ?> +

+

+ +

+

+ +

+

+ +

+

+ +

+ __('Next Gig', $gcd)); + ?> + + + true, + 'limit'=>1, + 'template'=>'next-widget', + )); + ?> + + __('Next Gig', $gcd), + ); + + if ( !isset($o['widget']['next']) ) { + $o['widget']['next'] = array(); + } + + $o['widget']['next'] = array_merge($defaults, $o['widget']['next']); + + if ( isset($_POST['gigs_next_title']) ) { + $o['widget']['next']['title'] = !empty($_POST['gigs_next_title']) ? $_POST['gigs_next_title'] : $defaults['title']; + print_r($o['widget']); + update_option('gigs-calendar', $o); + } + + ?> +

+ +

+ true, + 'limit' => false, + 'tour' => false, + 'template' => 'gigs-list', + 'dateFormat' => ($args['upcoming'] === false ? 'archive' : 'short'), + 'force' => false, + 'year' => null, + 'month' => null, + 'caption' => null, + ); + + + $args = is_array($args) ? array_merge($defaults, $args) : $defaults; + extract($args); + + $listFields = array( + 'city' => __('City', $gcd), + 'country' => __('Country', $gcd), + 'venue' => __('Venue', $gcd), + 'eventName' => __('Event', $gcd), + 'date' => __('Date', $gcd), + 'time' => __('Time', $gcd), + 'shortNotes' => __('Notes', $gcd), + 'tickets' => __('Tickets', $gcd), + 'map' => __('Map', $gcd), + ); + + $show_fields = $options['gigs-table-show']; + if ( !$upcoming && in_array( 'tickets', $show_fields ) ) { + unset( $show_fields[array_search('tickets', $show_fields)] ); + } + + $gig_ids = array(); + if ( is_null($year) && is_null($month) ) { + $gigs = $wpdb->get_results(' + SELECT + *, + g.notes as gigNotes, + v.notes as venueNotes, + g.id as gigID, + v.link as venueLink + FROM + `' . TABLE_GIGS . '` AS g + LEFT JOIN + `' . TABLE_VENUES . '` AS v ON ( g.venueID = v.id ) + WHERE + `date` ' . ($upcoming ? '>=' : '<=') . ' CURDATE() + ' . (($tour && $tour != -1) ? ' AND tour_id = ' . (int) $tour : '') . ' + ' . ($tour == -1 ? ' AND tour_id is null' : '') . ' + ORDER BY + `date` ' . ($upcoming ? 'ASC' : 'DESC') . ' + ' . ( !empty($limit) ? ' LIMIT ' . $limit : '' ) . ' + + '); + } else { + $gigs = $wpdb->get_results(' + SELECT + *, + g.notes as gigNotes, + v.notes as venueNotes, + g.id as gigID, + v.link as venueLink + FROM + `' . TABLE_GIGS . '` AS g + LEFT JOIN + `' . TABLE_VENUES . '` AS v ON ( g.venueID = v.id ) + WHERE + 1=1 + ' . ( !is_null($year) ? 'AND YEAR(`date`) = ' . (int) $year : '' ) . ' + ' . ( !is_null($month) ? 'AND MONTH(`date`) = ' . (int) $month : '' ) . ' + ' . (($tour && $tour != -1) ? ' AND tour_id = ' . (int) $tour : '') . ' + ' . ($tour == -1 ? ' AND tour_id is null' : '') . ' + ORDER BY + `date` ' . ($upcoming ? 'ASC' : 'DESC') . ' + ' . ( !empty($limit) ? ' LIMIT ' . $limit : '' ) . ' + + '); + } + + if ( $tour !== false && $tour !== "false" ) { + if ( !count($gigs) && !$options['tours-empty'] && !$force ) { + return ''; + } + if ( $t != -1 && empty($caption) ) { + $t = new tour($tour); + $caption = '
' . $t->name . '
' . $t->notes . '
'; + } + } + + + $performances = $wpdb->get_results(' + SELECT + p.* + FROM + `' . TABLE_GIGS . '` AS g + LEFT JOIN + `' . TABLE_PERFORMANCES . '` AS p ON ( g.id = p.gigID ) + ORDER BY + `time` ASC + '); + + foreach ( $gigs as $key => $g ) { + if ( empty($g->venueID) ) { + $g->mapLink = false; + } else { + $g->mapLink = dtcGigs::mapLink($g); + } + $g->cityState = $g->city . ( empty($g->state) ? '' : ', ' . $g->state ); + $g->cityStateCountry = $g->city . ( empty($g->state) ? '' : ', ' . $g->state ) . ( empty($g->country) ? '' : ', ' . $g->country ); + $g->cityCountry = $g->city . ( empty($g->country) ? '' : ', ' . $g->country ); + $g->permalink = get_permalink($g->postID); + $g->shortDate = dtcGigs::dateFormat($g->date, 'short'); + $g->longDate = dtcGigs::dateFormat($g->date, 'long'); + $g->archiveDate = dtcGigs::dateFormat($g->date, 'archive'); + $g->mysqlDate = $g->date; + $g->date = dtcGigs::dateFormat($g->date, $dateFormat); + $g->id = $g->gigID; + $g->id = $g->gigID; + $g->performances = array(); + $g->tags_slugs = array(); + $g->tags = function_exists('wp_get_post_tags') ? wp_get_post_tags($g->postID) : array(); + $gig_ids[$g->gigID] = $key; + foreach ( $g->tags as $tagkey => $tag ) { + $g->tags[$tagkey] = $tag->name; + $g->tags_slugs[$tagkey] = 'gc-' . $tag->slug; + } + $g->custom = get_post_custom($g->postID); + $gigs[$key] = $g; + } + + foreach ( $performances as $p ) { + $p->time_12h = dtcGigs::timeFormat($p->time, '12h'); + $p->time_24h = dtcGigs::timeFormat($p->time, '24h'); + $p->time = dtcGigs::timeFormat($p->time); + + if ( isset($gigs[$gig_ids[$p->gigID]]) ) { + $gigs[$gig_ids[$p->gigID]]->performances[] = $p; + } + } + + if ( is_file(dirname(__FILE__) . '/templates/' . $options['template'] . '/' . $template . '.php') ) { + include(dirname(__FILE__) . '/templates/' . $options['template'] . '/' . $template . '.php'); + } elseif ( is_file(ABSPATH . 'wp-content/gigs-templates/' . $options['template'] . '/' . $template . '.php') ) { + include(ABSPATH . 'wp-content/gigs-templates/' . $options['template'] . '/' . $template . '.php'); + } else { + include(dirname(__FILE__) . '/templates/' . 'basic/' . $template . '.php'); + } + $result = ob_get_clean(); + if ( $return ) return $result; + else echo $result; + } + + function upcomingList($args = array()) { + // This method has been depriciated. Stop using it! + global $include_folder; + $o = get_option('gigs-calendar'); + $defaults = array( + "length" => 5, + "dateFormat" => 'M j', + 'dateFormatYear' => 'M j, Y', + 'link' => array('city'), + 'return' => false, + ); + + + $args = array_merge($defaults, $args); + + include_once 'gigs-classes.php'; + $g = new gig(); + $g->search('`date` >= CURDATE()', '`date` ASC'); + + $count = 0; + if ( $g->_count ) : + + ?> + + +
+ get_var('SELECT COUNT(*) FROM ' . TABLE_GIGS . ' WHERE postID = ' . (int) $id ) ) { + wp_publish_post($id); + } else { + _future_post_hook($id, $post); + } + } + } + + + + add_action('init', array('dtc_gigs', 'setup_future_hook')); + add_action('admin_menu', array('dtc_gigs', 'add_admin_page')); + + //add_filter('the_posts', array('dtc_gigs', 'test')); + + if ( 4.1 <= mysql_get_server_info() ) { + add_filter('posts_where', array('dtc_gigs', 'hide_posts')); + add_filter('get_next_post_where', array('dtc_gigs', 'post_nav')); + add_filter('get_previous_post_where', array('dtc_gigs', 'post_nav')); + add_filter('getarchives_where', array('dtc_gigs', 'hide_archives')); + } else { + + } + + add_filter('the_content', array('dtc_gigs', 'display')); + + add_action('plugins_loaded', array('dtc_gigs', 'init')); + + + if ( $_GET['page'] == 'gigs' ) : + // If not WP > 2.6, we'll need to include some custom scripts. + $folder = dtc_gigs::get_url(); + if ( (float) $wp_version < 2.6 ) { + wp_deregister_script('jquery'); + wp_deregister_script('interface'); + wp_deregister_script('jquery-form'); + wp_enqueue_script('jquery', $folder . 'js/jquery.js', array(), '1.2.6'); + wp_enqueue_script('jquery-form', $folder . 'js/jquery.form.js', array(), '2.02'); + wp_enqueue_script('jquery-ui-core', $folder . 'js/ui.core.js', array(), '1.5'); + wp_enqueue_script('jquery-ui-sortable', $folder . 'js/ui.sortable.js', array(), '1.5'); + } else { + wp_enqueue_script('jquery'); + wp_enqueue_script('jquery-form'); + wp_enqueue_script('jquery-ui-core'); + wp_enqueue_script('jquery-ui-sortable'); + } + wp_enqueue_script('jquery-ui-datepicker', $folder . 'js/ui.datepicker.min.js', array(), '1.5'); + wp_enqueue_script('jquery-tooltip', $folder . 'js/jquery.tooltip.min.js', array(), '1.2'); + + add_action('admin_head', array('dtc_gigs', 'admin_css')); + + if ( get_option('gig_db_version') != DTC_GIGS_DB_VERSION ) { + dtc_gigs::upgrade(); + } + + endif; + + add_action('wp_head', array('dtc_gigs', 'display_css')); +else: + require_once $include_folder . '/ajaxSetup.php'; +endif; + +?>