Beispiel #1
0
 /**
  * Add week view to the views selector in the tribe events bar.
  *
  * @param array $views The current array of views registered to the tribe bar.
  *
  * @return array The views registered with week view added.
  */
 public function setup_weekview_in_bar($views)
 {
     $views[] = array('displaying' => 'week', 'anchor' => __('Week', 'tribe-events-calendar-pro'), 'event_bar_hook' => 'tribe_events_week_before_template', 'url' => tribe_get_week_permalink());
     return $views;
 }
Beispiel #2
0
 /**
  * Get next week permalink by provided date (7 days offset)
  *
  * @uses tribe_get_week_permalink
  * @param string $week
  * @param bool $is_current
  * @return string $permalink
  * @since 3.0
  */
 function tribe_get_next_week_permalink($week = null)
 {
     $week = !empty($week) ? $week : tribe_get_first_week_day();
     $week = date('Y-m-d', strtotime($week . ' +1 week'));
     return apply_filters('tribe_get_next_week_permalink', tribe_get_week_permalink($week));
 }
Beispiel #3
0
 /**
  * Add header attributes for week view
  *
  * @return string
  * @see 'tribe_events_header_attributes'
  * */
 public function header_attributes($attrs, $current_view)
 {
     global $wp_query;
     $attrs['data-view'] = 'week';
     $attrs['data-startofweek'] = get_option('start_of_week');
     $attrs['data-baseurl'] = tribe_get_week_permalink(null, false);
     $attrs['data-date'] = date('Y-m-d', strtotime($wp_query->get('start_date')));
     return apply_filters('tribe_events_pro_header_attributes', $attrs, $current_view);
 }
Beispiel #4
0
 /**
  * Add header attributes for week view
  *
  * @return string
  * @since  3.0
  * @author tim@imaginesimplicty.com
  * */
 function header_attributes($attrs, $current_view)
 {
     switch ($current_view) {
         case 'week-all-day':
             $attrs['data-hour'] = 'all-day';
             unset($attrs['data-title']);
             break;
         case 'week-hourly':
             $event = self::get_hourly_event();
             $daily_mins = 1440;
             $data_hour = 0;
             $data_min = 0;
             if ($event->days_between > 0) {
                 if (in_array($event->ID, self::$daily_span_ids) && date('Y-m-d', strtotime($event->EventEndDate)) == self::get_current_date()) {
                     // if the event is longer than a day we want to account for that with an offset for the ending time
                     $duration = abs((strtotime(self::get_current_date()) - strtotime($event->EventEndDate)) / 60);
                     $event_span_index = array_search($event->ID, self::$daily_span_ids);
                     unset(self::$daily_span_ids[$event_span_index]);
                 } else {
                     if (in_array($event->ID, self::$daily_span_ids) && date('Y-m-d', strtotime($event->EventEndDate)) > self::get_current_date() || date('Y-m-d', strtotime($event->EventStartDate)) < date('Y-m-d', strtotime(self::$start_of_week_date))) {
                         // if there is a day in between start/end we just want to fill the spacer with the total mins in the day.
                         $duration = $daily_mins;
                     } else {
                         self::$daily_span_ids[] = $event->ID;
                         // if the event is longer than a day we want to account for that with an offset
                         $duration = $daily_mins - abs((strtotime(self::get_current_date()) - strtotime($event->EventStartDate)) / 60);
                         $data_hour = date('G', strtotime($event->EventStartDate));
                         $data_min = date('i', strtotime($event->EventStartDate));
                     }
                 }
             } else {
                 // for a default event continue as everything is normal
                 $remaining_minutes_in_day = $daily_mins - abs((strtotime(self::get_current_date()) - strtotime($event->EventStartDate)) / 60);
                 $duration = $event->EventDuration / 60;
                 if ($duration > $remaining_minutes_in_day) {
                     // this will happen in the case of a multi-day event that extends beyond the end of the week
                     $duration = $remaining_minutes_in_day;
                 }
                 $data_hour = date('G', strtotime($event->EventStartDate));
                 $data_min = date('i', strtotime($event->EventStartDate));
             }
             $attrs['data-duration'] = abs($duration);
             $attrs['data-hour'] = $data_hour;
             $attrs['data-min'] = $data_min;
             unset($attrs['data-title']);
             break;
         case 'week-header':
             global $wp_query;
             $current_week = $wp_query->get('start_date');
             $attrs['data-view'] = 'week';
             $attrs['data-startofweek'] = get_option('start_of_week');
             $attrs['data-baseurl'] = tribe_get_week_permalink(null, false);
             $attrs['data-date'] = Date('Y-m-d', strtotime($current_week));
             break;
     }
     return apply_filters('tribe_events_pro_header_attributes', $attrs, $current_view);
 }
Beispiel #5
0
 /**
  * Get next week permalink by provided date (7 days offset)
  *
  * @uses tribe_get_week_permalink
  *
  * @param string $week
  *
  * @return string $permalink
  * @todo move logic to week template class
  */
 function tribe_get_next_week_permalink($week = null)
 {
     $week = !empty($week) ? $week : tribe_get_first_week_day();
     if (PHP_INT_SIZE <= 4) {
         if (date('Y-m-d', strtotime($week)) > '2037-12-24') {
             throw new OverflowException(__('Date out of range.', 'tribe-events-calendar-pro'));
         }
     }
     $week = date('Y-m-d', strtotime($week . ' +1 week'));
     return apply_filters('tribe_get_next_week_permalink', tribe_get_week_permalink($week));
 }
Beispiel #6
0
 /**
  * Add header attributes for week view
  *
  * @return string
  * @since  3.0
  * @author tim@imaginesimplicty.com
  * */
 function header_attributes($attrs, $current_view)
 {
     switch ($current_view) {
         case 'week-all-day':
             $attrs['data-hour'] = 'all-day';
             unset($attrs['data-title']);
             break;
         case 'week-hourly':
             $event = self::get_hourly_event();
             $start_of_day_timestamp = self::get_rounded_beginning_of_day(self::get_current_date(), 'U');
             $end_of_day_timestamp = self::get_rounded_end_of_day(self::get_current_date(), 'U');
             $data_hour = date('G', $start_of_day_timestamp);
             $data_min = date('i', $start_of_day_timestamp);
             if (strtotime($event->EventStartDate) < $start_of_day_timestamp) {
                 if (strtotime($event->EventEndDate) > $end_of_day_timestamp) {
                     // if there is a day in between start/end we just want to fill the spacer with the total mins in the day.
                     $duration = ($end_of_day_timestamp - $start_of_day_timestamp) / 60;
                 } else {
                     $duration = (strtotime($event->EventEndDate) - $start_of_day_timestamp) / 60;
                 }
             } elseif (strtotime($event->EventEndDate) > $end_of_day_timestamp) {
                 // if the event is longer than a day we want to account for that with an offset
                 $duration = ($end_of_day_timestamp - strtotime($event->EventStartDate)) / 60;
                 $data_hour = date('G', strtotime($event->EventStartDate));
                 $data_min = date('i', strtotime($event->EventStartDate));
             } else {
                 // for a default event continue as everything is normal
                 $remaining_minutes_in_day = $end_of_day_timestamp - strtotime($event->EventStartDate) / 60;
                 $duration = get_post_meta($event->ID, '_EventDuration', TRUE) / 60;
                 if ($duration > $remaining_minutes_in_day) {
                     // this will happen in the case of a multi-day event that extends beyond the end of the week
                     $duration = $remaining_minutes_in_day;
                 }
                 $data_hour = date('G', strtotime($event->EventStartDate));
                 $data_min = date('i', strtotime($event->EventStartDate));
             }
             $attrs['data-duration'] = abs($duration);
             $attrs['data-hour'] = $data_hour;
             $attrs['data-min'] = $data_min;
             unset($attrs['data-title']);
             break;
         case 'week-header':
             global $wp_query;
             $current_week = $wp_query->get('start_date');
             $attrs['data-view'] = 'week';
             $attrs['data-startofweek'] = get_option('start_of_week');
             $attrs['data-baseurl'] = tribe_get_week_permalink(null, false);
             $attrs['data-date'] = Date('Y-m-d', strtotime($current_week));
             break;
     }
     return apply_filters('tribe_events_pro_header_attributes', $attrs, $current_view);
 }