public function template($data = null, $show_poster = 0, $show_artist_poster = 0) { global $_wt_options; if (!$data) { $data = $this->data; } $db = $this->dbprepere; // get artist info $artist = new WT_Artist($data["event_artist_id"]); $artist_data = $artist->template($data); // get venue info $venue = new WT_Venue($data["event_venue_id"]); $venue_data = $venue->template($data); // get tour info if ($data["event_tour_id"] > 0) { $tour = new WT_Tour($data["event_tour_id"]); $tour_data = $tour->template($data); } $event_poster_id = $data["event_thumbnail"] ? $data["event_thumbnail"]["id"] : $this->get_thumbnail("event"); $event_poster = $db->media_out($event_poster_id); if ($data["event_on_sale"] == "0000-00-00") { $onsale = ""; } else { $onsale_date = strtotime($data["event_on_sale"]); if ($onsale_date < time()) { $onsale = ""; } else { $onsale = $data["event_on_sale"]; } } $opening = array(); $opening_array = array(); if (is_array($data["event_more_artists"])) { foreach ($data["event_more_artists"] as $a) { $opening[] = ucwords($a["name"]); $a["url"] = $db->link_out(wt_get_permalink("artist", $a["id"], array("%name%" => $a["name"]))); $opening_array[] = $a; } $opening = implode(", ", $opening); } $genre = $this->get_genre_tpl("event"); $google_map_str = wt_get_map_str($data); $tpl = array("show_comments" => $db->int_out($data["comment_status"]), "show_rsvp" => $db->int_out($data["rsvp_status"]), "show_gallery" => $db->int_out($data["gallery_status"]), "show_flickr" => $db->int_out($data["flickr_status"]), "date" => $db->date_display($data["event_start_date"]), "date_raw" => $data["event_start_date"], "genre" => implode(", ", $genre), "genre_array" => $genre, "artists" => $db->str_out($opening, 1), "artists_array" => $opening_array, "opening" => $db->str_out($data["event_opening_act"], 1), "onsale" => $onsale, "time" => $db->time_out($data["event_start_time"]), "end_date_raw" => $data["event_end_date"], "end_date" => $db->date_display($data["event_end_date"]), "end_time" => $db->time_out($data["event_end_time"]), "status" => $data["event_status"], "description" => $db->html_out($data["event_notes"]), "short_description" => $db->html_teaser_out($data["event_notes"]), "title" => $db->str_out($data["event_title"], 1), "type" => !empty($data["event_type"]) ? $db->str_out(ucwords($data["event_type"]), 1) : "", "artist" => $artist_data, "tour" => $tour_data, "venue" => $venue_data, "poster" => $event_poster, "tickets" => $db->link_out($data["tkts_url"]), "phone" => $db->str_out($data["tkts_phone"]), "admission" => $db->str_out($data["tkts_price"]), "comments" => $db->int_out($data["comment_count"]), "rsvp" => $db->int_out($data["rsvp_count"]), "url" => $db->link_out(wt_get_permalink("event", $data["event_id"], array("%date%" => $data["event_start_date"], "%name%" => $data["venue_name"]))), "machinetag" => $machinetag); return $tpl; }
public function tours($atts = null, $content = null, $code = "") { global $wpdb, $_wt_options; require_once WT_PLUGIN_PATH . 'admin/template.php'; require_once WT_PLUGIN_PATH . 'admin/handlers.php'; require_once WT_PLUGIN_PATH . 'dwoo/dwooAutoload.php'; $dwoo = new Dwoo(); # CONFIG PARAMS $attr = shortcode_atts(self::$tour_default, $atts); # TEMPLATE #ARTIST $artist_to_show = empty($attr["artist"]) ? 0 : explode(",", $attr["artist"]); #TOUR $tour_to_show = empty($attr["tour"]) ? 0 : explode(",", $attr["tour"]); #ORDER $order = strtolower($attr["order_by"]) == "name" ? "tour_name" : "tour_order"; #DIRECTION $direction = strtoupper($attr["direction"]) == "ASC" ? "ASC" : "DESC"; #START WITH $start_with = $attr["start_with"]; $theme_file_name = empty($attr["theme_file_name"]) ? 0 : $attr["theme_file_name"]; #TOUR $tours_to_show = empty($attr["tour"]) ? 0 : explode(",", $attr["tour"]); #EXCLUDE TOUR $tours_to_hide = empty($attr["exclude"]) ? 0 : explode(",", $attr["exclude"]); #ARTIST $artists_to_show = empty($attr["artist"]) ? 0 : explode(",", $attr["artist"]); #GENRE $genre_to_show = empty($attr["genre"]) ? 0 : explode(",", $attr["genre"]); #ORDER $order = strtolower($attr["order_by"]) == "name" ? "tour_name" : "tour_order"; #DIRECTION $direction = strtoupper($attr["direction"]) == "ASC" ? "ASC" : "DESC"; #START WITH $start_with = $attr["start_with"]; #TYPE $tour_genre = !empty($attr["genre"]) ? $attr["genre"] : 0; #LIMIT $limit = $attr["limit"] && is_numeric($attr["limit"]) ? " LIMIT {$attr['limit']} " : ""; $tours = 0; # GET RESULTS $conds = array(); $conds_str = ""; if (!empty($start_with)) { $conds[] = "UPPER(tour.tour_name) LIKE UPPER('{$start_with}%')"; } if ($tours_to_show) { $conds[] = $this->columns_sql("tour.tour_id", $tours_to_show); } if ($tours_to_hide) { $conds[] = $this->columns_sql("tour.tour_id", $tours_to_hide, null, "!="); } if ($tour_genre) { $conds_str .= " JOIN wp_wtr_attachment AS att ON tour.tour_id = att.attachment_target_id"; $conds[] = "att.attachment_target='tour'"; $conds[] = "att.attachment_type='genre'"; $conds[] = $this->columns_sql("att.attachment_info", $genre_to_show); } if (count($conds) > 0) { $conds_str .= " WHERE " . implode(" AND ", $conds); } $tours = $wpdb->get_results("SELECT * FROM " . WORDTOUR_TOUR . " as tour {$conds_str} GROUP BY tour.tour_id ORDER BY {$order} {$direction} {$limit}", "ARRAY_A"); if ($artists_to_show) { // get all ids of tour $tours_to_show = array(); foreach ($tours as $tour) { $tours_to_show[] = $tour["tour_id"]; } $conds = array(); $conds[] = $this->columns_sql("event.event_tour_id", $tours_to_show); $conds[] = $this->columns_sql("event.event_artist_id", $artists_to_show); if (count($conds) > 0) { $conds_str .= " WHERE " . implode(" AND ", $conds); } $artist_tours = $wpdb->get_results("SELECT event.event_tour_id FROM " . WORDTOUR_EVENTS . " as event {$conds_str}", "ARRAY_A"); $tours_to_show = array(); foreach ($artist_tours as $artist_tour) { $tours_to_show[] = $artist_tour["event_tour_id"]; } $tours_to_show = array_unique($tours_to_show); $new_tours = array(); foreach ($tours as $tour) { if (in_array($tour["tour_id"], $tours_to_show)) { $new_tours[] = $tour; } } $tours = $new_tours; } $tpl = array(); if ($tours) { foreach ($tours as $tour) { $t = new WT_Tour($tour["tour_id"]); $tpl["data"][] = $t->template($tour); } } else { $tpl["data"] = 0; } include WT_PLUGIN_PATH . 'theme/layout.renderer.php'; return $html; }