Exemplo n.º 1
0
 /**
  * AJAX handler for the Map view
  */
 public function ajax_response()
 {
     $tribe_paged = !empty($_POST['tribe_paged']) ? $_POST['tribe_paged'] : 1;
     Tribe__Events__Query::init();
     $post_status = array('publish');
     if (is_user_logged_in()) {
         $post_status[] = 'private';
     }
     $defaults = array('post_type' => Tribe__Events__Main::POSTTYPE, 'posts_per_page' => tribe_get_option('postsPerPage', 10), 'paged' => $tribe_paged, 'post_status' => $post_status, 'eventDisplay' => 'map', 'tribe_geoloc' => true);
     $view_state = 'map';
     /* if past view */
     if (!empty($_POST['tribe_event_display']) && $_POST['tribe_event_display'] == 'past') {
         $view_state = 'past';
         $defaults['eventDisplay'] = 'past';
     }
     if (isset($_POST['tribe_event_category'])) {
         $defaults[Tribe__Events__Main::TAXONOMY] = $_POST['tribe_event_category'];
     }
     if (isset($_POST[Tribe__Events__Main::TAXONOMY])) {
         $defaults[Tribe__Events__Main::TAXONOMY] = $_POST[Tribe__Events__Main::TAXONOMY];
     }
     $query = Tribe__Events__Query::getEvents($defaults, true);
     $have_events = 0 < $query->found_posts;
     if ($have_events && Tribe__Events__Pro__Geo_Loc::instance()->is_geoloc_query()) {
         $lat = isset($_POST['tribe-bar-geoloc-lat']) ? $_POST['tribe-bar-geoloc-lat'] : 0;
         $lng = isset($_POST['tribe-bar-geoloc-lng']) ? $_POST['tribe-bar-geoloc-lng'] : 0;
         Tribe__Events__Pro__Geo_Loc::instance()->assign_distance_to_posts($query->posts, $lat, $lng);
     } elseif (!$have_events && isset($_POST['tribe-bar-geoloc'])) {
         Tribe__Events__Main::setNotice('event-search-no-results', sprintf(__('No results were found for events in or near <strong>"%s"</strong>.', 'tribe-events-calendar-pro'), esc_html($_POST['tribe-bar-geoloc'])));
     } elseif (!$have_events && isset($_POST['tribe_event_category'])) {
         Tribe__Events__Main::setNotice('events-not-found', sprintf(__('No matching events listed under %s. Please try viewing the full calendar for a complete list of events.', 'tribe-events-calendar'), esc_html($_POST['tribe_event_category'])));
     } elseif (!$have_events) {
         Tribe__Events__Main::setNotice('event-search-no-results', __('There were no results found.', 'tribe-events-calendar-pro'));
     }
     $response = array('html' => '', 'markers' => array(), 'success' => true, 'tribe_paged' => $tribe_paged, 'max_pages' => $query->max_num_pages, 'total_count' => $query->found_posts, 'view' => $view_state);
     // @TODO: clean this up / refactor the following conditional
     if ($have_events) {
         global $wp_query, $post;
         $data = $query->posts;
         $post = $query->posts[0];
         $wp_query = $query;
         Tribe__Events__Main::instance()->displaying = 'map';
         ob_start();
         tribe_get_view('pro/map/content');
         $response['html'] .= ob_get_clean();
         $response['markers'] = Tribe__Events__Pro__Geo_Loc::instance()->generate_markers($data);
     } else {
         global $wp_query;
         $wp_query = $query;
         Tribe__Events__Main::instance()->setDisplay();
         ob_start();
         tribe_get_view('pro/map/content');
         $response['html'] .= ob_get_clean();
     }
     $response = apply_filters('tribe_events_ajax_response', $response);
     header('Content-type: application/json');
     echo json_encode($response);
     exit;
 }
Exemplo n.º 2
0
 /**
  * Set up the notices for this template
  *
  * @return void
  **/
 public function set_notices()
 {
     parent::set_notices();
     $events_label_singular = tribe_get_event_label_singular();
     global $post;
     // Check if event has passed
     $gmt_offset = get_option('gmt_offset') >= '0' ? ' +' . get_option('gmt_offset') : " " . get_option('gmt_offset');
     $gmt_offset = str_replace(array('.25', '.5', '.75'), array(':15', ':30', ':45'), $gmt_offset);
     if (!tribe_is_showing_all() && strtotime(tribe_get_end_date($post, false, 'Y-m-d G:i') . $gmt_offset) <= time()) {
         Tribe__Events__Main::setNotice('event-past', sprintf(__('This %s has passed.', 'tribe-events-calendar'), strtolower($events_label_singular)));
     }
 }
Exemplo n.º 3
0
 /**
  * Returns the requested date as a Y-m (yyyy-mm) formatted string.
  *
  * If the requested date is invalid (such as 1984-25) the current month is returned instead and
  * an appropriate notice presented to the user.
  *
  * @return string
  */
 protected function requested_date()
 {
     // We expect the date to be Y-m (yyyy-mm) format, ie year and date only
     $date = isset(self::$args['eventDate']) ? self::$args['eventDate'] : tribe_get_month_view_date();
     // Test and return unmodified if valid
     if (false !== strtotime($date . '-01')) {
         return $date;
     } else {
         Tribe__Events__Main::setNotice('requested-date-invalid', sprintf(__('The requested date "%s" was not valid &ndash; showing the current month instead', 'tribe-events-calendar'), esc_html($date)));
         return date_i18n('Y-m');
     }
 }
Exemplo n.º 4
0
 /**
  * Display the text that shows when there were no events found on this view
  *
  * @return void
  */
 protected function nothing_found_notice()
 {
     list($search_term, $tax_term, $geographic_term) = $this->get_search_terms();
     if (!empty($search_term)) {
         Tribe__Events__Main::setNotice('event-search-no-results', sprintf(__('There were no results found for <strong>"%s"</strong> this week. Try searching another week.', 'tribe-events-calendar-pro'), esc_html($search_term)));
     } elseif (!empty($geographic_term)) {
         Tribe__Events__Main::setNotice('event-search-no-results', sprintf(__('No results were found for events in or near <strong>"%s"</strong> this week. Try searching another week.', 'tribe-events-calendar-pro'), esc_html($geographic_term)));
     } elseif (!empty($tax_term)) {
         Tribe__Events__Main::setNotice('events-not-found', sprintf(__('No matching events listed under %s. Please try viewing the full calendar for a complete list of events.', 'tribe-events-calendar'), $tax_term));
     } else {
         Tribe__Events__Main::setNotice('event-search-no-results', __('No results were found for this week. Try searching another week.', 'tribe-events-calendar-pro'));
     }
 }
Exemplo n.º 5
0
 protected function nothing_found_notice()
 {
     $events_label_plural = tribe_get_event_label_plural();
     list($search_term, $tax_term, $geographic_term) = $this->get_search_terms();
     if (empty($search_term) && empty($geographic_term) && !empty($tax_term)) {
         Tribe__Events__Main::setNotice('events-not-found', sprintf(__('No matching %s listed under %s scheduled for <strong>%s</strong>. Please try another day.', 'tribe-events-calendar'), strtolower($events_label_plural), $tax_term, date_i18n(tribe_get_date_format(true), strtotime(get_query_var('eventDate')))));
     } elseif (empty($search_term) && empty($geographic_term)) {
         Tribe__Events__Main::setNotice('events-not-found', sprintf(__('No %s scheduled for <strong>%s</strong>. Please try another day.', 'tribe-events-calendar'), strtolower($events_label_plural), date_i18n(tribe_get_date_format(true), strtotime(get_query_var('eventDate')))));
     } else {
         parent::nothing_found_notice();
     }
 }
Exemplo n.º 6
0
 /**
  * Sets an appropriate no results found message. This may be overridden in child classes.
  */
 protected function nothing_found_notice()
 {
     $events_label_plural = strtolower(tribe_get_event_label_plural());
     list($search_term, $tax_term, $geographic_term) = $this->get_search_terms();
     $tribe = Tribe__Events__Main::instance();
     if (!empty($search_term)) {
         Tribe__Events__Main::setNotice('event-search-no-results', sprintf(__('There were no results found for <strong>"%s"</strong>.', 'the-events-calendar'), esc_html($search_term)));
     } elseif (!empty($geographic_term)) {
         Tribe__Events__Main::setNotice('event-search-no-results', sprintf(__('No results were found for %1$s in or near <strong>"%2$s"</strong>.', 'the-events-calendar'), $events_label_plural, esc_html($geographic_term)));
     } elseif (!empty($tax_term) && tribe_is_upcoming() && date('Y-m-d') === date('Y-m-d', strtotime($tribe->date))) {
         Tribe__Events__Main::setNotice('events-not-found', sprintf(__('No upcoming %1$s listed under %2$s. Check out upcoming %3$s for this category or view the full calendar.', 'the-events-calendar'), $events_label_plural, $tax_term, $events_label_plural));
     } elseif (!empty($tax_term) && tribe_is_upcoming()) {
         Tribe__Events__Main::setNotice('events-not-found', sprintf(__('No matching %1$s listed under %2$s. Please try viewing the full calendar for a complete list of %3$s.', 'the-events-calendar'), $events_label_plural, $tax_term, $events_label_plural));
     } elseif (!empty($tax_term) && tribe_is_past()) {
         Tribe__Events__Main::setNotice('events-past-not-found', sprintf(__('No previous %s ', 'the-events-calendar'), $events_label_plural));
     } elseif (!empty($tax_term)) {
         Tribe__Events__Main::setNotice('events-not-found', sprintf(__('No matching %1$s listed under %2$s. Please try viewing the full calendar for a complete list of %3$s.', 'the-events-calendar'), $events_label_plural, $tax_term, $events_label_plural));
     } else {
         Tribe__Events__Main::setNotice('event-search-no-results', __('There were no results found.', 'the-events-calendar'));
     }
 }