Advertisement
Guest User

table.php

a guest
Oct 23rd, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.41 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  
  5. * This file outputs the actual days of the month in the TEC calendar view
  6.  
  7. *
  8.  
  9. * You can customize this view by putting a replacement file of the same name (table.php) in the events/ directory of your theme.
  10.  
  11. */
  12.  
  13.  
  14.  
  15. //Calendar dates (qartulad-Shi, dekembershi, septembershi) for inclusion in POEDIT
  16. __('January','holidayge');
  17. __('February','holidayge');
  18. __('March','holidayge');
  19. __('April','holidayge');
  20. __('May','holidayge');
  21. __('June','holidayge');
  22. __('July','holidayge');
  23. __('August','holidayge');
  24. __('September','holidayge');
  25. __('October','holidayge');
  26. __('November','holidayge');
  27. __('December','holidayge');
  28.  
  29.  
  30.  
  31. // Don't load directly
  32. if ( !defined('ABSPATH') ) { die('-1'); }
  33.  
  34.  
  35.  
  36. $tribe_ecp = TribeEvents::instance();
  37.  
  38. /*
  39. if(isset($myCity)){
  40. $eventCat=get_category_id($myCity);
  41. $eventPosts = tribe_get_events( array( 'eventCat' => $eventCat, 'time_order' => 'ASC', 'eventDisplay'=>'month' ) );
  42. }*/
  43.  
  44. // in an events cat
  45.  
  46. if ( is_tax( $tribe_ecp->get_event_taxonomy() ) ) {
  47.  
  48.     $cat = get_term_by( 'slug', get_query_var('term'), $tribe_ecp->get_event_taxonomy() );
  49.  
  50.     $eventCat = (int) $cat->term_id;
  51.  
  52.     $eventPosts = tribe_get_events( array( 'eventCat' => $eventCat, 'time_order' => 'ASC', 'eventDisplay'=>'month' ) );
  53.  
  54. }
  55.  
  56.  
  57. // not in a cat
  58.  
  59. else {
  60.  
  61.     $eventPosts = tribe_get_events(array( 'eventDisplay'=>'month' ));
  62.  
  63. }
  64.  
  65.  
  66.  
  67.  
  68.  
  69. $daysInMonth = isset($date) ? date("t", $date) : date("t");
  70.  
  71. $startOfWeek = get_option( 'start_of_week', 0 );
  72.  
  73. list( $year, $month ) = split( '-', $tribe_ecp->date );
  74.  
  75. $date = mktime(12, 0, 0, $month, 1, $year); // 1st day of month as unix stamp
  76.  
  77. $rawOffset = date("w", $date) - $startOfWeek;
  78.  
  79. $offset = ( $rawOffset < 0 ) ? $rawOffset + 7 : $rawOffset; // month begins on day x
  80.  
  81. $rows = 1;
  82.  
  83.  
  84.  
  85. $monthView = tribe_sort_by_month( $eventPosts, $tribe_ecp->date );
  86.  
  87.  
  88.  
  89. ?>
  90.  
  91. <table class="tribe-events-calendar" id="big">
  92.  
  93.     <thead>
  94.  
  95.             <tr>
  96.  
  97.                 <?php
  98.  
  99.                 for( $n = $startOfWeek; $n < count($tribe_ecp->daysOfWeek) + $startOfWeek; $n++ ) {
  100.  
  101.                     $dayOfWeek = ( $n >= 7 ) ? $n - 7 : $n;
  102.  
  103.                    
  104.  
  105.                     echo '<th id="tribe-events-' . strtolower($tribe_ecp->daysOfWeek[$dayOfWeek]) . '" abbr="' . $tribe_ecp->daysOfWeek[$dayOfWeek] . '">' . $tribe_ecp->daysOfWeekShort[$dayOfWeek] . '</th>';
  106.  
  107.                 }
  108.  
  109.                 ?>
  110.  
  111.             </tr>
  112.  
  113.     </thead>
  114.  
  115.  
  116.  
  117.     <tbody>
  118.  
  119.         <tr>
  120.  
  121.         <?php
  122.  
  123.             // skip last month
  124.  
  125.             for( $i = 1; $i <= $offset; $i++ ){
  126.  
  127.                 echo "<td class='tribe-events-othermonth'></td>";
  128.  
  129.             }
  130.  
  131.             // output this month
  132.  
  133.          $days_in_month = date("t", intval($date));
  134.  
  135.             for( $day = 1; $day <= $days_in_month; $day++ ) {
  136.  
  137.                 if( ($day + $offset - 1) % 7 == 0 && $day != 1) {
  138.  
  139.                     echo "</tr>\n\t<tr>";
  140.  
  141.                     $rows++;
  142.  
  143.                 }
  144.  
  145.            
  146.  
  147.                 // Var'ng up days, months and years
  148.  
  149.                 $current_day = date_i18n( 'd' );
  150.  
  151.                 $current_month = date_i18n( 'm' );
  152.  
  153.                 $current_year = date_i18n( 'Y' );
  154.  
  155.             $date = "$year-$month-$day";
  156.  
  157.                
  158.  
  159.                 if ( $current_month == $month && $current_year == $year) {
  160.  
  161.                     // Past, Present, Future class
  162.  
  163.                     if ($current_day == $day ) {
  164.  
  165.                         $ppf = ' tribe-events-present';
  166.  
  167.                     } elseif ($current_day > $day) {
  168.  
  169.                         $ppf = ' tribe-events-past';
  170.  
  171.                     } elseif ($current_day < $day) {
  172.  
  173.                         $ppf = ' tribe-events-future';
  174.  
  175.                     }
  176.  
  177.                 } elseif ( $current_month > $month && $current_year == $year || $current_year > $year ) {
  178.  
  179.                     $ppf = ' tribe-events-past';
  180.  
  181.                 } elseif ( $current_month < $month && $current_year == $year || $current_year < $year ) {
  182.  
  183.                     $ppf = ' tribe-events-future';
  184.  
  185.                 } else { $ppf = false; }
  186.  
  187.                
  188.  
  189.                 echo "<td class='tribe-events-thismonth" . $ppf . "'>" . display_day_title( $day, $monthView, $date ) . "\n";
  190.  
  191.                 echo display_day( $day, $monthView );
  192.  
  193.                 echo "</td>";
  194.  
  195.             }
  196.  
  197.             // skip next month
  198.  
  199.             while( ($day + $offset) <= $rows * 7)
  200.  
  201.             {
  202.  
  203.                 echo "<td class='tribe-events-othermonth'></td>";
  204.  
  205.                 $day++;
  206.  
  207.             }
  208.  
  209.         ?>
  210.  
  211.         </tr>
  212.  
  213.     </tbody>
  214.  
  215. </table>
  216.  
  217.                            
  218. <?php
  219.  
  220.  
  221.  
  222. function display_day_title( $day, $monthView, $date ) {
  223.  
  224.     $return = "<div class='daynum tribe-events-event' id='daynum_$day'>";
  225.  
  226.     if( function_exists('tribe_get_linked_day') && count( $monthView[$day] ) > 0 ) {
  227.  
  228.         $return .= '<span class="calendar-see-more">&rarr;</span>';
  229.  
  230.         $return .= tribe_get_linked_day($date, $day); // premium
  231.  
  232.     } else {
  233.  
  234.         $return .= $day;
  235.  
  236.     }
  237.  
  238.     $return .= "<div id='tooltip_day_$day' class='tribe-events-tooltip' style='display:none;'>";
  239.  
  240.     for( $i = 0; $i < count( $monthView[$day] ); $i++ ) {
  241.  
  242.         $post = $monthView[$day][$i];
  243.  
  244.         setup_postdata( $post );
  245.  
  246.         $return .= '<h5 class="tribe-events-event-title">' . get_the_title() . '</h5>';
  247.  
  248.     }
  249.  
  250.     $return .= '<span class="tribe-events-arrow"></span>';
  251.  
  252.     $return .= '</div>';
  253.  
  254.  
  255.  
  256.     $return .= "</div>";
  257.  
  258.     return $return;
  259.  
  260. }
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273. function display_day( $day, $monthView ) {
  274.     global $post;
  275.     $output = '';
  276.     $posts_per_page = tribe_get_option( 'postsPerPage', 10 );
  277.     if (tribe_is_month()) { $postsPerCell = 6; } else { $postsPerCell = 4; }
  278.  
  279.  
  280.     if (count($monthView[$day]) < $postsPerCell)
  281.         $postsPerCell = count($monthView[$day]);
  282.  
  283.     for ( $i = 0; $i < $postsPerCell; $i++ ) {
  284.         $post = $monthView[$day][$i];
  285.         setup_postdata( $post );
  286.         $eventId    = $post->ID.'-'.$day;
  287.         $start      = tribe_get_start_date( $post->ID, false, 'U' );
  288.         $end        = tribe_get_end_date( $post->ID, false, 'U' );
  289.         $cost       = tribe_get_cost( $post->ID );
  290.         ?>
  291.         <div id='event_<?php echo $eventId; ?>' <?php post_class('tribe-events-event tribe-events-real-event') ?>>
  292.             <a href="<?php tribe_event_link(); ?>"><?php the_title(); ?></a>
  293.             <div id='tooltip_<?php echo $eventId; ?>' class="tribe-events-tooltip" style="display:none;">
  294.                 <h5 class="tribe-events-event-title"><?php the_title();?></h5>
  295.                 <div class="tribe-events-event-body">
  296.                     <div class="tribe-events-event-date">
  297.                         <?php if ( !empty( $start ) )   echo date_i18n( get_option('date_format', 'F j, Y'), $start);
  298.                         if ( !tribe_get_event_meta($post->ID, '_EventAllDay', true) )
  299.                             echo ' ' . date_i18n( get_option('time_format', 'g:i a'), $start); ?>
  300.                         <?php if ( !empty( $end )  && $start !== $end ) {
  301.                             if ( date_i18n( 'Y-m-d', $start ) == date_i18n( 'Y-m-d', $end ) ) {
  302.                                 $time_format = get_option( 'time_format', 'g:i a' );
  303.                                 if ( !tribe_get_event_meta($post->ID, '_EventAllDay', true) )
  304.                                     echo " – " . date_i18n( $time_format, $end );
  305.                             } else {
  306.                                 echo " – " . date_i18n( get_option('date_format', 'F j, Y'), $end);
  307.                                 if ( !tribe_get_event_meta($post->ID, '_EventAllDay', true) )
  308.                                     echo ' ' . date_i18n( get_option('time_format', 'g:i a'), $end) . '<br />';
  309.                             }
  310.                         } ?>
  311.                     </div>
  312.  
  313.                     <p><?php echo has_excerpt() ? TribeEvents::truncate($post->post_excerpt) : TribeEvents::truncate(get_the_content(), 30); ?></p>
  314.  
  315.                     <span class="tribe-events-interested"><?php comments_number( '0', '1', '%' ); ?> <?php _e('interested so far','holidayge'); ?></span>
  316.  
  317.                 </div>
  318.                 <span class="tribe-events-arrow"></span>
  319.             </div>
  320.         </div>
  321.         <?php
  322.     }
  323.    
  324.  
  325.     //more link should start here
  326.     if (count($monthView[$day]) > $postsPerCell) {
  327.        
  328.         $date = date_i18n(get_option('date_format', 'F j, Y'), $start);
  329.             echo '<span class="calendar-see-more-incell">';
  330.             echo tribe_get_linked_day ($date, __('More...','holidayge'));
  331.             echo '</span>';
  332.     }
  333.  
  334.  
  335. }
  336.  
  337.  
  338.  
  339. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement