Guest User

Untitled

a guest
Nov 28th, 2011
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.22 KB | None | 0 0
  1. <?php
  2. /**
  3. * This file outputs the actual days of the month in the TEC calendar view
  4. *
  5. * You can customize this view by putting a replacement file of the same name (table.php) in the events/ directory of your theme.
  6. */
  7.  
  8. // Don't load directly
  9. if ( !defined('ABSPATH') ) { die('-1'); }
  10.  
  11. $tribe_ecp = TribeEvents::instance();
  12.  
  13. // in an events cat
  14. if ( is_tax( $tribe_ecp->get_event_taxonomy() ) ) {
  15. $cat = get_term_by( 'slug', get_query_var('term'), $tribe_ecp->get_event_taxonomy() );
  16. $eventCat = (int) $cat->term_id;
  17. $eventPosts = tribe_get_events( array( 'eventCat' => $eventCat, 'time_order' => 'ASC', 'eventDisplay'=>'month' ) );
  18. } // not in a cat
  19. else {
  20. $eventPosts = tribe_get_events(array( 'eventDisplay'=>'month' ));
  21. }
  22.  
  23.  
  24. $daysInMonth = isset($date) ? date("t", $date) : date("t");
  25. $startOfWeek = get_option( 'start_of_week', 0 );
  26. list( $year, $month ) = split( '-', $tribe_ecp->date );
  27. $date = mktime(12, 0, 0, $month, 1, $year); // 1st day of month as unix stamp
  28. $rawOffset = date("w", $date) - $startOfWeek;
  29. $offset = ( $rawOffset < 0 ) ? $rawOffset + 7 : $rawOffset; // month begins on day x
  30. $rows = 1;
  31.  
  32. $monthView = tribe_sort_by_month( $eventPosts, $tribe_ecp->date );
  33.  
  34. ?>
  35. <table class="tribe-events-calendar" id="big">
  36. <thead>
  37. <tr>
  38. <?php
  39. for( $n = $startOfWeek; $n < count($tribe_ecp->daysOfWeek) + $startOfWeek; $n++ ) {
  40. $dayOfWeek = ( $n >= 7 ) ? $n - 7 : $n;
  41.  
  42. echo '<th id="tribe-events-' . strtolower($tribe_ecp->daysOfWeek[$dayOfWeek]) . '" abbr="' . $tribe_ecp->daysOfWeek[$dayOfWeek] . '">' . $tribe_ecp->daysOfWeekShort[$dayOfWeek] . '</th>';
  43. }
  44. ?>
  45. </tr>
  46. </thead>
  47.  
  48. <tbody>
  49. <tr>
  50. <?php
  51. // skip last month
  52. for( $i = 1; $i <= $offset; $i++ ){
  53. echo "<td class='tribe-events-othermonth'></td>";
  54. }
  55. // output this month
  56. for( $day = 1; $day <= date("t", intval($date)); $day++ ) {
  57. if( ($day + $offset - 1) % 7 == 0 && $day != 1) {
  58. echo "</tr>\n\t<tr>";
  59. $rows++;
  60. }
  61.  
  62. // Var'ng up days, months and years
  63. $current_day = date_i18n( 'd' );
  64. $current_month = date_i18n( 'm' );
  65. $current_year = date_i18n( 'Y' );
  66. $date = "$year-$month-$day";
  67.  
  68. if ( $current_month == $month && $current_year == $year) {
  69. // Past, Present, Future class
  70. if ($current_day == $day ) {
  71. $ppf = ' tribe-events-present';
  72. } elseif ($current_day > $day) {
  73. $ppf = ' tribe-events-past';
  74. } elseif ($current_day < $day) {
  75. $ppf = ' tribe-events-future';
  76. }
  77. } elseif ( $current_month > $month && $current_year == $year || $current_year > $year ) {
  78. $ppf = ' tribe-events-past';
  79. } elseif ( $current_month < $month && $current_year == $year || $current_year < $year ) {
  80. $ppf = ' tribe-events-future';
  81. } else { $ppf = false; }
  82.  
  83. echo "<td class='tribe-events-thismonth" . $ppf . "'>" . display_day_title( $day, $monthView, $date ) . "\n";
  84. echo display_day( $day, $monthView );
  85. echo "</td>";
  86. }
  87. // skip next month
  88. while( ($day + $offset) <= $rows * 7)
  89. {
  90. echo "<td class='tribe-events-othermonth'></td>";
  91. $day++;
  92. }
  93. ?>
  94. </tr>
  95. </tbody>
  96. </table>
  97. <?php
  98.  
  99. function display_day_title( $day, $monthView, $date ) {
  100. $return = "<div class='daynum tribe-events-event' id='daynum_$day'>";
  101.  
  102. if( function_exists('tribe_get_linked_day') ) {
  103. $return .= tribe_get_linked_day($date, $day); // premium
  104. } else {
  105. $return .= $day;
  106. }
  107. $return .= "<div id='tooltip_day_$day' class='tribe-events-tooltip' style='display:none;'>";
  108. for( $i = 0; $i < count( $monthView[$day] ); $i++ ) {
  109. $post = $monthView[$day][$i];
  110. setup_postdata( $post );
  111. $return .= '<h5 class="tribe-events-event-title">' . get_the_title() . '</h5>';
  112. }
  113. $return .= '<span class="tribe-events-arrow"></span>';
  114. $return .= '</div>';
  115.  
  116. $return .= "</div>";
  117. return $return;
  118. }
  119.  
  120. function display_day( $day, $monthView ) {
  121. global $post;
  122. $output = '';
  123. $posts_per_page = get_option( 'posts_per_page' );
  124. for ( $i = 0; $i < count( $monthView[$day] ); $i++ ) {
  125. $post = $monthView[$day][$i];
  126. setup_postdata( $post );
  127. $eventId = $post->ID.'-'.$day;
  128. $start = tribe_get_start_date( $post->ID );
  129. $end = tribe_get_end_date( $post->ID );
  130. $cost = tribe_get_cost( $post->ID );
  131. $address = tribe_get_address( $post->ID );
  132. $city = tribe_get_city( $post->ID );
  133. $state = tribe_get_state( $post->ID );
  134. $province = tribe_get_province( $post->ID );
  135. $country = tribe_get_country( $post->ID );
  136. ?>
  137. <div id='event_<?php echo $eventId; ?>' <?php post_class('tribe-events-event tribe-events-real-event') ?>>
  138. <a href="<?php tribe_event_link(); ?>"><?php the_title(); ?></a><br/>
  139. <?php if(get_post_meta($e->ID, 'EventAllDay', true) == 'yes') { ?>
  140. <?php } else { ?>
  141. <span style="font-size:9px; color:#15244D;"><?php echo tribe_get_start_date( null, false, "g:ia" ); ?></span>
  142. <?php } ?>
  143. <div id='tooltip_<?php echo $eventId; ?>' class="tribe-events-tooltip" style="display:none;">
  144. <h5 class="tribe-events-event-title"><?php the_title();?></h5>
  145. <div class="tribe-events-event-body">
  146. <?php echo has_excerpt() ? TribeEvents::truncate($post->post_excerpt) : TribeEvents::truncate(get_the_content(), 30); ?>
  147. <div class="tribe-events-event-date">
  148. <?php if ( !empty( $start ) ) echo $start; ?>
  149. <?php if ( !empty( $end ) && $start !== $end ) {
  150. $start_as_ts = (int)strtotime( $start );
  151. $end_as_ts = (int)strtotime( $end );
  152. if ( date_i18n( 'Y-m-d', $start_as_ts ) == date_i18n( 'Y-m-d', $end_as_ts ) ) {
  153. $time_format = get_option( 'time_format', 'g:i a' );
  154. echo " - " . date_i18n( $time_format, $end_as_ts );
  155. } else {
  156. echo " – " . $end . '<br />';
  157. }
  158. } ?>
  159. </div>
  160. <?php if ( function_exists('has_post_thumbnail') && has_post_thumbnail() ) { ?>
  161. <div class="tribe-events-event-thumb"><?php the_post_thumbnail( array(75,75));?></div>
  162. <?php } ?>
  163.  
  164. </div>
  165. <span class="tribe-events-arrow"></span>
  166. </div>
  167. </div>
  168. <?php
  169. if( $i < count( $monthView[$day] ) - 1 ) {
  170. echo "<hr />";
  171. }
  172. }
  173. }
  174. ?>
  175.  
  176.  
Advertisement
Add Comment
Please, Sign In to add comment