northside

theme 2

Oct 17th, 2012
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.99 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Copy and paste this to events/table.php in your template to customize
  5. */
  6.  
  7. global $sp_ecp;
  8.  
  9. // in an events cat
  10. if ( is_tax( $sp_ecp->get_event_taxonomy() ) ) {
  11. $cat = get_term_by( 'slug', get_query_var('term'), $sp_ecp->get_event_taxonomy() );
  12. $eventCat = (int) $cat->term_id;
  13. $eventPosts = sp_get_events( array( 'eventCat' => $eventCat, 'time_order' => 'ASC' ) );
  14. } // not in a cat
  15. else {
  16. $eventPosts = sp_get_events(array( 'time_order' => 'ASC' ));
  17. }
  18.  
  19.  
  20. $daysInMonth = isset($date) ? date("t", $date) : date("t");
  21. $startOfWeek = get_option( 'start_of_week', 0 );
  22. list( $year, $month ) = split( '-', $sp_ecp->date );
  23. $date = mktime(12, 0, 0, $month, 1, $year); // 1st day of month as unix stamp
  24. $rawOffset = date("w", $date) - $startOfWeek;
  25. $offset = ( $rawOffset < 0 ) ? $rawOffset + 7 : $rawOffset; // month begins on day x
  26. $rows = 1;
  27. $monthView = sp_sort_by_month( $eventPosts, $sp_ecp->date );
  28.  
  29. ?>
  30. <table class="tec-calendar" id="big">
  31. <thead>
  32. <tr>
  33. <?php //$sp_ecp->log($sp_ecp->daysOfWeekShort);
  34. for( $n = $startOfWeek; $n < count($sp_ecp->daysOfWeek) + $startOfWeek; $n++ ) {
  35. $dayOfWeek = ( $n >= 7 ) ? $n - 7 : $n;
  36.  
  37. echo '<th id="tec-' . strtolower($sp_ecp->daysOfWeek[$dayOfWeek]) . '" abbr="' . $sp_ecp->daysOfWeek[$dayOfWeek] . '">' . $sp_ecp->daysOfWeekShort[$dayOfWeek] . '</th>';
  38. }
  39. ?>
  40. </tr>
  41. </thead>
  42.  
  43. <tbody>
  44. <tr>
  45. <?php
  46. // skip last month
  47. for( $i = 1; $i <= $offset; $i++ ){
  48. echo "<td class='tec-othermonth'></td>";
  49. }
  50. // output this month
  51. for( $day = 1; $day <= date("t", $date); $day++ ) {
  52. if( ($day + $offset - 1) % 7 == 0 && $day != 1) {
  53. echo "</tr>\n\t<tr>";
  54. $rows++;
  55. }
  56.  
  57. // Var'ng up days, months and years
  58. $current_day = date_i18n( 'd' );
  59. $current_month = date_i18n( 'm' );
  60. $current_year = date_i18n( 'Y' );
  61.  
  62. if ( $current_month == $month && $current_year == $year) {
  63. // Past, Present, Future class
  64. if ($current_day == $day ) {
  65. $ppf = ' tec-present';
  66. } elseif ($current_day > $day) {
  67. $ppf = ' tec-past';
  68. } elseif ($current_day < $day) {
  69. $ppf = ' tec-future';
  70. }
  71. } elseif ( $current_month > $month && $current_year == $year || $current_year > $year ) {
  72. $ppf = ' tec-past';
  73. } elseif ( $current_month < $month && $current_year == $year || $current_year < $year ) {
  74. $ppf = ' tec-future';
  75. } else { $ppf = false; }
  76.  
  77. echo "<td class='tec-thismonth" . $ppf . "'>" . display_day_title( $day, $monthView ) . "\n";
  78. echo display_day( $day, $monthView );
  79. echo "</td>";
  80. }
  81. // skip next month
  82. while( ($day + $offset) <= $rows * 7)
  83. {
  84. echo "<td class='tec-othermonth'></td>";
  85. $day++;
  86. }
  87. ?>
  88. </tr>
  89. </tbody>
  90. </table>
  91. <?php
  92.  
  93. function display_day_title( $day, $monthView ) {
  94. $return = "<div class='daynum tec-event' id='daynum_$day'>";
  95.  
  96. $return .= $day;
  97. $return .= "<div id='tooltip_day_$day' class='tec-tooltip' style='display:none;'>";
  98. for( $i = 0; $i < count( $monthView[$day] ); $i++ ) {
  99. $post = $monthView[$day][$i];
  100. setup_postdata( $post );
  101. $return .= '<h5 class="tec-event-title">' . get_the_title() . '</h5>';
  102. }
  103. $return .= '<span class="tec-arrow"></span>';
  104. $return .= '</div>';
  105.  
  106. $return .= "</div>";
  107. return $return;
  108. }
  109.  
  110. function display_day( $day, $monthView ) {
  111. global $post;
  112. $output = '';
  113. $posts_per_page = get_option( 'posts_per_page' );
  114. for ( $i = 0; $i < count( $monthView[$day] ); $i++ ) {
  115. $post = $monthView[$day][$i];
  116. setup_postdata( $post );
  117. $eventId = $post->ID.'-'.$day;
  118. $start = sp_get_start_date( $post->ID );
  119. $end = sp_get_end_date( $post->ID );
  120. $cost = sp_get_cost( $post->ID );
  121. $address = sp_get_address( $post->ID );
  122. $city = sp_get_city( $post->ID );
  123. $state = sp_get_state( $post->ID );
  124. $province = sp_get_province( $post->ID );
  125. $country = sp_get_country( $post->ID );
  126. ?>
  127. <div id='event_<?php echo $eventId; ?>' <?php post_class('tec-event') ?>>
  128. <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
  129. <div id='tooltip_<?php echo $eventId; ?>' class="tec-tooltip" style="display:none;">
  130. <h5 class="tec-event-title"><?php the_title();?></h5>
  131. <div class="tec-event-body">
  132. <?php if ( !sp_get_all_day($post->ID) ) : ?>
  133. <div class="tec-event-date">
  134. <?php if ( !empty( $start ) ) echo $start; ?>
  135. <?php if ( !empty( $end ) && $start !== $end ) echo " – " . $end . '<br />'; ?>
  136. </div>
  137. <?php endif; ?>
  138. <?php if ( function_exists('has_post_thumbnail') && has_post_thumbnail() ) { ?>
  139. <div class="tec-event-thumb"><?php the_post_thumbnail( array(75,75));?></div>
  140. <?php } ?>
  141. <?php echo has_excerpt() ? Events_Calendar_Pro::truncate(get_the_excerpt(), 60) : Events_Calendar_Pro::truncate(get_the_content(), 30); ?>
  142.  
  143. </div>
  144. <span class="tec-arrow"></span>
  145. </div>
  146. </div>
  147. <?php
  148. if( $i < count( $monthView[$day] ) - 1 ) {
  149. echo "<hr />";
  150. }
  151. }
  152. }
Advertisement
Add Comment
Please, Sign In to add comment