Exemple #1
0
 /**
  * Sets up an array of $days based on the current query, that can be used in the calendar loop
  *
  * @return void
  **/
 public function setup_view()
 {
     if ($this->use_cache && $this->html_cache->get() !== false) {
         return;
     }
     $requested_date = $this->requested_date();
     $first_grid_date = $this->calculate_first_cell_date($requested_date);
     $final_grid_date = $this->calculate_final_cell_date($requested_date);
     $days = array();
     $this->setup_tribe_bar_args();
     $this->current_day_vals();
     self::$hide_upcoming_ids = Tribe__Events__Query::getHideFromUpcomingEvents();
     self::get_daily_counts($first_grid_date, $final_grid_date);
     $date = $first_grid_date;
     // Start with the first grid date
     $empty = new WP_Query();
     // Use for empty days
     // Populate complete date range including leading/trailing days from adjacent months
     while ($date <= $final_grid_date) {
         $day = (int) substr($date, -2);
         $total_events = !empty(self::$event_daily_counts[$date]) ? self::$event_daily_counts[$date] : 0;
         $prev_month = (int) substr($date, 5, 2) < (int) substr($requested_date, 5, 2);
         $next_month = (int) substr($date, 5, 2) > (int) substr($requested_date, 5, 2);
         $month_type = self::CURRENT_MONTH;
         if ($prev_month) {
             $month_type = self::PREVIOUS_MONTH;
         }
         if ($next_month) {
             $month_type = self::NEXT_MONTH;
         }
         $days[] = array('daynum' => $day, 'date' => $date, 'events' => $total_events ? self::get_daily_events($date) : $empty, 'total_events' => $total_events, 'view_more' => self::view_more_link($date, self::$tribe_bar_args), 'month' => $month_type);
         // Record the indicies marking the portion of the array relating to the current month
         if (!isset($this->current_month_begins) && self::CURRENT_MONTH === $month_type) {
             $this->current_month_begins = count($days) - 1;
         }
         if (isset($this->current_month_begins) && !isset($this->current_month_ends) && self::CURRENT_MONTH !== $month_type) {
             $this->current_month_ends = count($days) - 1;
         }
         // Advance forward one day
         $date = date(Tribe__Events__Date_Utils::DBDATEFORMAT, strtotime("{$date} +1 day"));
     }
     // If the month ended without bleeding into the next month, our current_month_ends property may not be set
     if (!isset($this->current_month_ends)) {
         $this->current_month_ends = count($days) - 1;
     }
     // store set of found days for use in calendar loop functions
     self::$calendar_days = $days;
 }