WordPress.org

Plugin Directory

Changeset 648376


Ignore:
Timestamp:
01/05/13 16:28:04 (16 months ago)
Author:
joedolson
Message:

Bug fixes: upcoming events, print stylesheet, weekly view

Location:
my-calendar/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • my-calendar/trunk/date-utilities.php

    r624321 r648376  
    4040// true if dates are the same 
    4141function my_calendar_date_equal($early,$late) { 
    42     $firstdate = strtotime($early); 
    43     $lastdate = strtotime($late); 
    44     if ($early == $late) { 
     42    // convert full datetime to date only 
     43    $firstdate = strtotime( date( 'Y-m-d',strtotime($early) ) ); 
     44    $lastdate = strtotime( date( 'Y-m-d',strtotime($late) ) ); 
     45    if ($firstdate == $lastdate) { 
    4546        return true; 
    4647    } else { 
     
    4849    }    
    4950} 
    50  
     51// test whether two dates are day-consecutive 
     52function mc_dates_consecutive( $current, $last_date ) { 
     53    if ( strtotime( $last_date.'+ 1 day' ) == strtotime( $current ) ) { return true; } else { return false; } 
     54} 
    5155// Function to compare time in event objects 
    5256function my_calendar_time_cmp($a, $b) { 
     
    8084} 
    8185 
    82 function my_calendar_timediff_cmp($a, $b) { 
    83     $event_dt_a = strtotime($a->occur_begin); 
    84     $event_dt_b = strtotime($b->occur_begin); 
     86function my_calendar_timediff_cmp( $a, $b ) { 
     87    $a = $a.date(' H:i:s',current_time( 'timestamp' ) ); 
     88    $b = $b.date(' H:i:s',current_time( 'timestamp' ) ); 
     89    $event_dt_a = strtotime($a); 
     90    $event_dt_b = strtotime($b); 
    8591    $diff_a = jd_date_diff_precise($event_dt_a); 
    8692    $diff_b = jd_date_diff_precise($event_dt_b); 
  • my-calendar/trunk/lang/my-calendar-it_IT.po

    r634216 r648376  
    33msgid "" 
    44msgstr "" 
    5 "PO-Revision-Date: 2012-12-04 20:59:20+0000\n" 
     5"PO-Revision-Date: 2012-12-10 18:27:50+0000\n" 
    66"MIME-Version: 1.0\n" 
    77"Content-Type: text/plain; charset=UTF-8\n" 
     
    1313#: my-calendar-event-manager.php:467 
    1414msgid "Edit events" 
    15 msgstr "" 
     15msgstr "Modifica gli eventi" 
    1616 
    1717#: my-calendar-event-manager.php:1270 
    1818msgid "The time field must either be blank or be entered in the format hh:mm am/pm" 
    19 msgstr "" 
     19msgstr "Il campo \"ora\" può essere lasciato vuoto o utilizzato nel formato hh:mm am/pm" 
    2020 
    2121#: my-calendar-event-manager.php:1277 
    2222msgid "The end time field must either be blank or be entered in the format hh:mm am/pm" 
    23 msgstr "" 
     23msgstr "Il campo \"orario finale\" può essere lasciato vuoto o utilizzato nel formato hh:mm am/pm" 
    2424 
    2525#: my-calendar-help.php:13 
    2626msgid "Shortcodes" 
    27 msgstr "" 
     27msgstr "Shortcode" 
    2828 
    2929#: my-calendar-help.php:14 
    3030msgid "Icons" 
    31 msgstr "" 
     31msgstr "Icone" 
    3232 
    3333#: my-calendar-help.php:15 
    3434msgid "Styles" 
    35 msgstr "" 
     35msgstr "Stili" 
    3636 
    3737#: my-calendar-help.php:16 
     
    4141#: my-calendar-help.php:17 
    4242msgid "Support Form" 
    43 msgstr "" 
     43msgstr "Modulo per il supporto" 
    4444 
    4545#: my-calendar-help.php:26 my-calendar.php:153 
    4646msgid "Getting Started" 
    47 msgstr "" 
     47msgstr "Introduzione" 
    4848 
    4949#: my-calendar-help.php:29 
    5050msgid "Although the My Calendar plug-in is very complicated in terms of what can be customized, the basic usage is quite simple." 
    51 msgstr "" 
     51msgstr "Anche se il plug-in My Calendar plug-in è molto complesso nella sua completa personalizzazione, l'uso di base è molto semplice." 
    5252 
    5353#: my-calendar-help.php:32 
    5454msgid "Add the My Calendar shortcode (<code>[my_calendar]</code>) to a page." 
    55 msgstr "" 
     55msgstr "Aggiungi il shortcode My Calendar (<code>[my_calendar]</code>) ad una pagina." 
    5656 
    5757#: my-calendar-help.php:33 
  • my-calendar/trunk/my-calendar-core.php

    r634216 r648376  
    13211321    $wp_version = get_bloginfo('version'); 
    13221322    $home_url = home_url(); 
    1323     $wp_url = get_bloginfo('wpurl'); 
     1323    $wp_url = site_url(); 
    13241324    $language = get_bloginfo('language'); 
    13251325    $charset = get_bloginfo('charset'); 
  • my-calendar/trunk/my-calendar-events.php

    r627944 r648376  
    1414    if ( $before > 0 ) { 
    1515        $before = $before + 5; 
    16         $events1 = $mcdb->get_results("SELECT *  
     16        $events1 = $mcdb->get_results("SELECT *, UNIX_TIMESTAMP(occur_begin) AS ts_occur_begin, UNIX_TIMESTAMP(occur_end) AS ts_occur_end  
    1717        FROM " . MY_CALENDAR_EVENTS_TABLE . "  
    1818        JOIN " . MY_CALENDAR_TABLE . "  
     
    2323    } else { $events1 = array(); } 
    2424    if ( $today == 'yes' ) { 
    25         $events3 = $mcdb->get_results("SELECT *  
     25        $events3 = $mcdb->get_results("SELECT *, UNIX_TIMESTAMP(occur_begin) AS ts_occur_begin, UNIX_TIMESTAMP(occur_end) AS ts_occur_end  
    2626        FROM " . MY_CALENDAR_EVENTS_TABLE . "  
    2727        JOIN " . MY_CALENDAR_TABLE . "  
     
    3535    if ( $after > 0 ) { 
    3636        $after = $after + 5; 
    37         $events2 = $mcdb->get_results("SELECT *  
     37        $events2 = $mcdb->get_results("SELECT *, UNIX_TIMESTAMP(occur_begin) AS ts_occur_begin, UNIX_TIMESTAMP(occur_end) AS ts_occur_end  
    3838        FROM " . MY_CALENDAR_EVENTS_TABLE . "  
    3939        JOIN " . MY_CALENDAR_TABLE . "  
     
    6060    if ( $before > 0 ) { 
    6161        $before = $before + 5; 
    62         $events1 = $mcdb->get_results("SELECT *  
     62        $events1 = $mcdb->get_results("SELECT * 
    6363        FROM " . MY_CALENDAR_EVENTS_TABLE . "  
    6464        JOIN " . MY_CALENDAR_TABLE . "  
     
    101101    if ( get_option( 'mc_remote' ) == 'true' && function_exists('mc_remote_db') ) { $mcdb = mc_remote_db(); } 
    102102    if ( $cat_id ) { $cat = "WHERE event_category = $cat_id AND event_approved = 1"; } else { $cat = 'WHERE event_approved = 1'; } 
    103     $events = $mcdb->get_results("SELECT * FROM " .  MY_CALENDAR_EVENTS_TABLE . " JOIN " . MY_CALENDAR_TABLE . " ON (event_id=occur_event_id) JOIN " . MY_CALENDAR_CATEGORIES_TABLE . " ON (event_category=category_id) $cat ORDER BY event_added DESC LIMIT 0,30" ); 
     103    $events = $mcdb->get_results("SELECT *, UNIX_TIMESTAMP(occur_begin) AS ts_occur_begin, UNIX_TIMESTAMP(occur_end) AS ts_occur_end FROM " .  MY_CALENDAR_EVENTS_TABLE . " JOIN " . MY_CALENDAR_TABLE . " ON (event_id=occur_event_id) JOIN " . MY_CALENDAR_CATEGORIES_TABLE . " ON (event_category=category_id) $cat ORDER BY event_added DESC LIMIT 0,30" ); 
    104104    foreach ( array_keys($events) as $key ) { 
    105105        $event =& $events[$key];     
     
    124124    $mcdb = $wpdb; 
    125125    if ( get_option( 'mc_remote' ) == 'true' && function_exists('mc_remote_db') ) { $mcdb = mc_remote_db(); } 
    126     $event = $mcdb->get_row("SELECT * FROM " .  MY_CALENDAR_EVENTS_TABLE . " JOIN " . MY_CALENDAR_TABLE . " ON (event_id=occur_event_id) JOIN " . MY_CALENDAR_CATEGORIES_TABLE . " ON (event_category=category_id) WHERE occur_id=$id"); 
     126    $event = $mcdb->get_row("SELECT *, UNIX_TIMESTAMP(occur_begin) AS ts_occur_begin, UNIX_TIMESTAMP(occur_end) AS ts_occur_end FROM " .  MY_CALENDAR_EVENTS_TABLE . " JOIN " . MY_CALENDAR_TABLE . " ON (event_id=occur_event_id) JOIN " . MY_CALENDAR_CATEGORIES_TABLE . " ON (event_category=category_id) WHERE occur_id=$id"); 
    127127    $date = date('Y-m-d',strtotime($event->occur_begin) ); 
    128128    if ( $type == 'object' ) { 
     
    173173    $limit_string = "event_flagged <> 1 AND event_approved = 1"; 
    174174 
    175     $event_query = "SELECT *  
     175    $event_query = "SELECT *, UNIX_TIMESTAMP(occur_begin) AS ts_occur_begin, UNIX_TIMESTAMP(occur_end) AS ts_occur_end  
    176176                    FROM " . MY_CALENDAR_EVENTS_TABLE . "  
    177177                    JOIN " . MY_CALENDAR_TABLE . " 
  • my-calendar/trunk/my-calendar-limits.php

    r630179 r648376  
    199199     $user_settings = get_option('mc_user_settings'); 
    200200     $limit_string = ""; 
    201      if ( get_option('mc_user_settings_enabled') == 'true' && $user_settings['my_calendar_location_default']['enabled'] == 'on' || isset($_GET['loc']) && isset($_GET['ltype']) || ( $ltype !='' && $lvalue != '' )  ) { 
     201     if ( ( get_option('mc_user_settings_enabled') == 'true' && isset( $user_settings['my_calendar_location_default']['enabled'] ) && $user_settings['my_calendar_location_default']['enabled'] == 'on' ) || isset($_GET['loc']) && isset($_GET['ltype']) || ( $ltype !='' && $lvalue != '' )  ) { 
    202202        if ( !isset($_GET['loc']) && !isset($_GET['ltype']) ) { 
    203203            if (  $ltype == '' && $lvalue == '' ) { 
  • my-calendar/trunk/my-calendar-output.php

    r634216 r648376  
    421421 
    422422function my_calendar_print() { 
    423 global $wp_plugin_url; 
     423$wp_plugin_url = plugin_dir_url( __FILE__ ); 
    424424$category=(isset($_GET['mcat']))?$_GET['mcat']:''; // these are all sanitized elsewhere 
    425425$time=(isset($_GET['time']))?$_GET['time']:'month'; 
     
    449449    $stylesheet = get_stylesheet_directory_uri() . '/mc-print.css'; 
    450450} else { 
    451     $stylesheet = $wp_plugin_url."/my-calendar/mc-print.css"; 
     451    $stylesheet = $wp_plugin_url."mc-print.css"; 
    452452} 
    453453echo " 
     
    635635            $c_year = (int) $_GET['yr']; 
    636636        } else { 
    637             $c_year = date("Y",time()+($offset));            
     637            if ( $time == 'week' && date('j', current_time( 'timestamp' ) ) <= 6 && date('n', current_time( 'timestamp' ) ) == 1 ) { 
     638                $c_year = ( date("Y",current_time( 'timestamp' ) ) )-1; 
     639            } else { 
     640                $c_year = date("Y",current_time( 'timestamp' ) ); 
     641            }            
    638642        } 
    639643        // Years get funny if we exceed 3000, so we use this check 
     
    13551359            get_currentuserinfo(); 
    13561360            $current_settings = get_user_meta( $user_ID, 'my_calendar_user_settings', true ); 
    1357             $tz = $current_settings['my_calendar_tz_default']; 
     1361            $tz = ( isset($current_settings['my_calendar_tz_default'] ) )?$current_settings['my_calendar_tz_default']:''; 
    13581362        } else { 
    13591363            $tz = ''; 
  • my-calendar/trunk/my-calendar-templates.php

    r634216 r648376  
    1111            if ( strpos( $template, "{".$key ) !== false ) { 
    1212                if ($type != 'list') { 
    13                     if ( $key == 'link' && $value == '') { $value = ( get_option('mc_uri') != '' )?get_option('mc_uri'):get_bloginfo('url'); } 
     13                    if ( $key == 'link' && $value == '') { $value = ( get_option('mc_uri') != '' )?get_option('mc_uri'):home_url(); } 
    1414                    if ( $key != 'guid') { $value = htmlentities($value); } 
    1515                } 
     
    124124    $date_format = ( get_option('mc_date_format') != '' )?get_option('mc_date_format'):get_option('date_format');    
    125125    $dateid = $event->occur_id; 
    126     $month_date = date('dS',strtotime( $event->occur_begin ) ); 
    127     $day_name = date_i18n('l',strtotime($event->occur_begin)); 
     126    $month_date = date( 'dS',strtotime( $event->occur_begin ) ); 
     127    $day_name = date_i18n( 'l',strtotime( $event->occur_begin ) ); 
    128128    $week_number = mc_ordinal( week_of_month( date('j',strtotime($event->occur_begin) ) ) +1 ); 
    129129    $id = $event->event_id; 
     
    164164    $details['repeats'] = $event->event_repeats; 
    165165    $real_end_date = $event->occur_end; 
    166     $date = date_i18n( $date_format,strtotime( $event->occur_begin ) ); 
     166    //$date = date_i18n( $date_format,strtotime( $event->occur_begin ) ); 
     167    $date = date_i18n( $date_format, $event->ts_occur_begin ); 
    167168    $date_end = date_i18n( $date_format,strtotime($real_end_date) ); 
    168169    $details['image'] = ( $event->event_image != '' )?"<img src='$event->event_image' alt='' class='mc-image' />":''; 
    169     $details['time'] = ( date( 'H:i:s', strtotime($event->occur_begin) ) == '00:00:00' )?get_option( 'mc_notime_text' ):date(get_option('mc_time_format'),strtotime($event->occur_begin)); 
     170    //$details['time'] = ( date( 'H:i:s', strtotime($event->occur_begin) ) == '00:00:00' )?get_option( 'mc_notime_text' ):date(get_option('mc_time_format'),strtotime($event->occur_begin)); 
     171    $details['time'] = ( date( 'H:i:s', $event->ts_occur_begin ) == '00:00:00' )?get_option( 'mc_notime_text' ):date(get_option('mc_time_format'), $event->ts_occur_begin ); 
    170172    $endtime = ( date( 'H:i:s', strtotime($event->occur_end) ) == '00:00:00')?'23:59:00':date( 'H:i:s',strtotime($event->occur_end) );   
    171173    $details['endtime'] = ( $event->occur_end == $event->occur_begin || $event->event_hide_end == 1 )?'':date_i18n( get_option('mc_time_format'),strtotime( $endtime )); 
     
    178180    } else { 
    179181        $details['usertime'] = $details['time']; 
    180         $details['endusertime'] = ( $details['time'] == $details['endtime'] )?'':$details['endtime'];        
    181     } 
    182  
     182        $details['endusertime'] = ( $details['time'] == $details['endtime'] )?'':$details['endtime']; 
     183    } 
    183184    $offset = get_option('gmt_offset'); // reset offset in hours 
    184185    $os = strtotime($event->occur_begin); 
  • my-calendar/trunk/my-calendar-widgets.php

    r634216 r648376  
    309309            } 
    310310            $i = 0; 
     311            $last_item = ''; 
    311312            foreach ( reverse_array($temp_array, true, $order) as $details ) { 
     313                $item = jd_draw_template($details,$template); 
    312314                if ( $i < $skip && $skip != 0 ) { 
    313315                    $i++; 
    314316                } else { 
    315                     $output .= "<li>".jd_draw_template($details,$template)."</li>";        
    316                 } 
     317                    $output .= ( $item == $last_item )?'':"<li>$item</li>";        
     318                } 
     319                $last_item = $item; 
    317320            } 
    318321    } else { 
     
    351354                } 
    352355            } 
    353         $output .= mc_produce_upcoming_events( $event_array,$template,'list',$order,$skip,$before, $after ); 
     356        $output .= mc_produce_upcoming_events( $event_array,$template,'list',$order,$skip,$before, $after, $show_today ); 
    354357    } 
    355358    if ($output != '') { 
     
    364367  $mcdb = $wpdb; 
    365368  if ( get_option( 'mc_remote' ) == 'true' && function_exists('mc_remote_db') ) { $mcdb = mc_remote_db(); } 
    366  
    367 $group_id = (int) $group_id; 
     369    $group_id = (int) $group_id; 
    368370    $sql = "SELECT event_begin, event_time, event_end, event_endtime FROM ".my_calendar_table()." WHERE event_group_id = $group_id ORDER BY event_begin ASC"; 
    369371    $dates = $mcdb->get_results( $sql ); 
     
    374376    return array( $begin, $end ); 
    375377} 
    376 // make this function time-sensitive, not date-sensitive. 
    377 function mc_produce_upcoming_events($events,$template,$type='list',$order='asc',$skip=0,$before, $after, $hash=false) { 
     378// function generates the list of upcoming events by event 
     379function mc_produce_upcoming_events($events,$template,$type='list',$order='asc',$skip=0,$before, $after, $hash=false, $show_today='yes') { 
    378380    // $events has +5 before and +5 after if those values are non-zero. 
    379381    // $events equals array of events based on before/after queries. Nothing has been skipped, order is not set, holidays are removed. 
    380         $output = '';$near_events = $temp_array = array();$past = $future = 1; 
    381         $offset = (60*60*get_option('gmt_offset')); 
    382         $today = date('Y',time()+($offset)).'-'.date('m',time()+($offset)).'-'.date('d',time()+($offset));       
    383          @usort( $e, "my_calendar_timediff_cmp" );// sort all events by proximity to current date 
    384          $count = count($events); 
    385          $skip = false; 
    386          $group = array(); 
    387          $spans = array(); 
    388          $extra = 0; 
    389             $i = 0;  
    390             // create near_events array 
    391             $last_event = 0; 
    392             if ( is_array( $events ) ) { 
    393             foreach ( $events as $k=>$event ) { 
    394                 if ( $i < $count ) { 
    395                     if ( is_array( $event ) ) { 
    396                         foreach ( $event as $e ) { 
    397                             if ( $e->category_private == 1 && !is_user_logged_in() ) { 
    398                             } else { 
    399                             // if the beginning of an event is after the current time, it is in the future 
    400                                 $beginning = $e->occur_begin; 
    401                                 $date = date('Y-m-d', strtotime($beginning)); 
    402                             // if the end of an event is before the current time, it is in the past. 
    403                             if ( date('H:i:s',strtotime($e->occur_end) ) == '00:00:00' ) { $endtime = date('H:i:s',strtotime($e->occur_begin) ); } else { $endtime = date('H:i:s',strtotime($e->occur_end) ); } 
    404                                 $end = $e->occur_end; 
    405                                 // store span time in an array to avoid repeating database query 
    406                                 if ( $e->event_span == 1 && ( !isset($spans[ $e->occur_group_id ]) ) ) { 
    407                                     // this is a multi-day event: treat each event as if it spanned the entire range of the group. 
    408                                     $span_time = mc_span_time($e->occur_group_id); 
    409                                     $beginning = $span_time[0]; 
    410                                     $end = $span_time[1]; 
    411                                     $spans[ $e->occur_group_id ] = $span_time; 
    412                                 } else if  ( $e->event_span == 1 && ( isset($spans[ $e->occur_group_id ]) ) ) { 
    413                                     $span_time = $spans[ $e->occur_group_id ]; 
    414                                     $beginning = $span_time[0]; 
    415                                     $end = $span_time[1]; 
     382    $output = '';$near_events = $temp_array = array();$past = $future = 1; 
     383    $now = current_time( 'timestamp' ); 
     384    $today = date('Y',$now).'-'.date('m',$now).'-'.date('d',$now);       
     385    @uksort( $events, "my_calendar_timediff_cmp" );// sort all events by proximity to current date 
     386    $count = count($events); 
     387    $skip = false; 
     388    $group = array(); 
     389    $spans = array(); 
     390    $last_date = $today; 
     391    $extra = 0; 
     392    $i = 0;  
     393    // create near_events array 
     394    $last_event = 0; 
     395    if ( is_array( $events ) ) { 
     396        foreach ( $events as $k=>$event ) { 
     397            if ( $i < $count ) { 
     398                if ( is_array( $event ) ) { 
     399                    foreach ( $event as $e ) { 
     400                        if ( $e->category_private == 1 && !is_user_logged_in() ) { 
     401                        } else { 
     402                            $beginning = $e->occur_begin; 
     403                            $end = $e->occur_end; 
     404                            // store span time in an array to avoid repeating database query 
     405                            if ( $e->event_span == 1 && ( !isset($spans[ $e->occur_group_id ]) ) ) { 
     406                                // this is a multi-day event: treat each event as if it spanned the entire range of the group. 
     407                                $span_time = mc_span_time($e->occur_group_id); 
     408                                $beginning = $span_time[0]; 
     409                                $end = $span_time[1]; 
     410                                $spans[ $e->occur_group_id ] = $span_time; 
     411                            } else if  ( $e->event_span == 1 && ( isset($spans[ $e->occur_group_id ]) ) ) { 
     412                                $span_time = $spans[ $e->occur_group_id ]; 
     413                                $beginning = $span_time[0]; 
     414                                $end = $span_time[1]; 
     415                            } 
     416                            $current = date('Y-m-d H:i:00',current_time( 'timestamp' ) ); 
     417                            if ( $e ) {  
     418                                // if a multi-day event, show only once. 
     419                                if ( $e->occur_group_id != 0 && $e->event_span == 1 && in_array( $e->occur_group_id, $group ) ) {  
     420                                    $skip = true;  
     421                                } else {  
     422                                    $group[] = $e->occur_group_id; $skip=false;  
    416423                                } 
    417                                 $current = date('Y-m-d H:i',time()+$offset); 
    418                                 if ( $e ) {  
    419                                     // if a multi-day event, show only once. 
    420                                     if ( $e->occur_group_id != 0 && $e->event_span == 1 && in_array( $e->occur_group_id, $group ) ) {  
    421                                         $skip = true;  
    422                                     } else {  
    423                                         $group[] = $e->occur_group_id; $skip=false;  
     424                                // end multi-day reduction 
     425                                if ( !$skip ) { 
     426                                    // with this code, I *expected* weekly recurring event with no intervening events to not display correctly...but it does. Not sure why. 
     427                                    $same_event = ( $e->occur_id == $last_event )?true:false; 
     428                                    if ( $show_today == 'yes' && my_calendar_date_equal( $beginning, $current ) ) { 
     429                                        $near_events[] = $e; 
     430                                    } else if ( ( $past<=$before && $future<=$after ) ) { 
     431                                        $near_events[] = $e; // if neither limit is reached, split off freely 
     432                                    } else if ( $past <= $before && ( my_calendar_date_comp( $beginning,$current ) ) ) { 
     433                                        $near_events[] = $e; // split off another past event 
     434                                    } else if ( $future <= $after && ( !my_calendar_date_comp( $end,$current ) ) ) { 
     435                                        $near_events[] = $e; // split off another future event 
    424436                                    } 
    425                                     // end multi-day reduction 
    426                                     if ( !$skip ) { 
    427                                         // with this code, I *expected* weekly recurring event with no intervening events to not display correctly...but it does. Not sure why. 
    428                                         $same_event = ( $e->event_id == $last_event )?true:false; 
    429                                         if ( ( $past<=$before && $future<=$after ) ) { 
    430                                             $near_events[] = $e; // if neither limit is reached, split off freely 
    431                                         } else if ( $past <= $before && ( my_calendar_date_comp( $beginning,$current ) ) ) { 
    432                                             $near_events[] = $e; // split off another past event 
    433                                         } else if ( $future <= $after && ( !my_calendar_date_comp( $end,$current ) ) ) { 
    434                                             $near_events[] = $e; // split off another future event 
    435                                         }  
    436                                         if ( my_calendar_date_comp( $beginning,$current ) ) {    
    437                                             if ( !$same_event ) { $past++; } else { $past; $extra++; } 
    438                                         } else if ( my_calendar_date_equal( $beginning,$current ) ) {   
    439                                             $present = 1; 
    440                                         } else {  
    441                                             if ( !$same_event ) { $future++;  } else { $future; $extra++; } 
    442                                         } 
    443                                         $last_event = $e->event_id; 
     437                                    if ( my_calendar_date_comp( $beginning,$current ) ) {    
     438                                        if ( !$same_event ) { $past++; } else { $extra++; } 
     439                                    } else if ( my_calendar_date_equal( $beginning,$current ) ) {   
     440                                        $present = 1; 
     441                                        if ( $show_today == 'yes' ) { $extra++; } 
     442                                    } else { 
     443                                        if ( !$same_event ) { $future++;  } else { $extra++; } 
    444444                                    } 
    445                                     if ($past > $before && $future > $after) { 
    446                                         break; 
    447                                     } 
     445                                    $last_event = $e->occur_id; 
     446                                    $last_date = $beginning; 
     447                                } 
     448                                if ( $past > $before && $future > $after && $show_today != 'yes' ) { 
     449                                    break; 
    448450                                } 
    449451                            } 
     
    452454                } 
    453455            } 
    454             $e = false; 
    455             } 
    456         $events = $near_events; 
    457         @usort( $events, "my_calendar_datetime_cmp" ); // sort split events by date 
    458         // If more items in the list than there should be (possible, due to handling of current-day's events), pop off. 
    459         $intended = $before + $after + $extra; 
    460         $actual = count($events); 
    461         if ( $actual > $intended ) { 
    462             for ( $i=0;$i<($actual-$intended);$i++ ) { 
    463                 array_pop($events); 
    464             } 
    465         } 
    466         if ( is_array( $events ) ) { 
    467             foreach( array_keys($events) as $key ) { 
    468                 $event =& $events[$key]; 
    469                 //echo $event->event_title . " " . $event->event_group_id."<br />"; 
    470                 $event_details = event_as_array( $event ); 
    471                     if ( get_option( 'mc_event_approve' ) == 'true' ) { 
    472                         if ( $event->event_approved != 0 ) { $temp_array[] = $event_details; } 
    473                     } else { 
    474                         $temp_array[] = $event_details; 
     456        } 
     457        $e = false; 
     458    } 
     459    $events = $near_events;      
     460    @usort( $events, "my_calendar_datetime_cmp" ); // sort split events by date 
     461    // If more items in the list than there should be (possible, due to handling of current-day's events), pop off. 
     462    $intended = $before + $after + $extra; 
     463    $actual = count($events); 
     464    if ( $actual > $intended ) { 
     465        for ( $i=0;$i<($actual-$intended);$i++ ) { 
     466            array_pop($events); 
     467        } 
     468    } 
     469    if ( is_array( $events ) ) { 
     470        foreach( array_keys($events) as $key ) { 
     471            $event =& $events[$key]; 
     472            //echo $event->event_title . " " . $event->event_group_id."<br />"; 
     473            $event_details = event_as_array( $event ); 
     474                if ( get_option( 'mc_event_approve' ) == 'true' ) { 
     475                    if ( $event->event_approved != 0 ) { $temp_array[] = $event_details; } 
     476                } else { 
     477                    $temp_array[] = $event_details; 
     478                } 
     479        } 
     480        $i = 0; 
     481        $groups = array(); 
     482        $skips = array(); 
     483         
     484        foreach( reverse_array($temp_array, true, $order) as $details ) { 
     485            if ( !in_array( $details['group'], $groups ) ) { 
     486                $date = date('Y-m-d',strtotime($details['dtstart'])); 
     487                $class = (my_calendar_date_comp( $date,$today )===true)?"past-event":"future-event"; 
     488                if ( my_calendar_date_equal( $date,$today ) ) { 
     489                    $class = "today"; 
     490                } 
     491                if ( $details['event_span'] == 1 ) { 
     492                    $class = "multiday"; 
     493                } 
     494                if ($type == 'list') { 
     495                    $prepend = "\n<li class=\"$class\">"; 
     496                    $append = "</li>\n"; 
     497                } else { 
     498                    $prepend = $append = ''; 
     499                } 
     500                if ( $i < $skip && $skip != 0 ) { 
     501                    $i++; 
     502                } else { 
     503                    if ( !in_array( $details['dateid'], $skips ) ) { 
     504                        $output .= apply_filters('mc_event_upcoming',"$prepend".jd_draw_template($details,$template,$type)."$append",$event);      
     505                        $skips[] = $details['dateid']; 
    475506                    } 
    476             } 
    477             $i = 0; 
    478             $groups = array(); 
    479             $skips = array(); 
    480              
    481             foreach( reverse_array($temp_array, true, $order) as $details ) { 
    482                 if ( !in_array( $details['group'], $groups ) ) { 
    483                     $date = date('Y-m-d',strtotime($details['dtstart'])); 
    484                     $class = (my_calendar_date_comp( $date,$today )===true)?"past-event":"future-event"; 
    485                     if ( my_calendar_date_equal( $date,$today ) ) { 
    486                         $class = "today"; 
    487                     } 
    488                     if ( $details['event_span'] == 1 ) { 
    489                         $class = "multiday"; 
    490                     } 
    491                     if ($type == 'list') { 
    492                         $prepend = "\n<li class=\"$class\">"; 
    493                         $append = "</li>\n"; 
    494                     } else { 
    495                         $prepend = $append = ''; 
    496                     } 
    497                     if ( $i < $skip && $skip != 0 ) { 
    498                         $i++; 
    499                     } else { 
    500                         if ( !in_array( $details['dateid'], $skips ) ) { 
    501                             $output .= apply_filters('mc_event_upcoming',"$prepend".jd_draw_template($details,$template,$type)."$append",$event);      
    502                             $skips[] = $details['dateid']; 
    503                         } 
    504                     } 
    505                     if ( $details['event_span'] == 1 ) { 
    506                         $groups[] = $details['group']; 
    507                     } 
    508                 } 
    509             } 
    510         } else { 
    511             $output .= ''; 
    512         } 
     507                } 
     508                if ( $details['event_span'] == 1 ) { 
     509                    $groups[] = $details['group']; 
     510                } 
     511            } 
     512        } 
     513    } else { 
     514        $output .= ''; 
     515    } 
    513516    return $output; 
    514517} 
     
    524527    if ( get_option( 'mc_remote' ) == 'true' && function_exists('mc_remote_db') ) { $mcdb = mc_remote_db(); } 
    525528    $output = ''; 
    526     $offset = (60*60*get_option('gmt_offset'));   
    527529    // This function cannot be called unless calendar is up to date 
    528530    check_my_calendar(); 
     
    534536    $no_event_text = ($substitute == '')?$defaults['today']['text']:$substitute; 
    535537 
    536     $from = $to = date( 'Y-m-d',time()+$offset ); 
     538    $from = $to = date( 'Y-m-d', current_time( 'timestamp' ) ); 
    537539    $events = my_calendar_grab_events($from, $to,$category,'','','upcoming',$author, $host); 
    538540    $header = "<ul id='todays-events'>"; 
     
    553555            if ( !in_array( $event->event_group_id, $groups ) ) {    
    554556                $event_details = event_as_array($event); 
    555                 $date = date_i18n(get_option('mc_date_format'),time()+$offset); 
     557                $date = date_i18n(get_option('mc_date_format'), current_time( 'timestamp' ) ); 
    556558 
    557559                $this_event = ''; 
     
    582584            $return = stripcslashes( $no_event_text ); 
    583585        } 
    584         $time =  strtotime( date( 'Y-m-d H:m:s',time()+$offset ) ) - strtotime( date( 'Y-m-d',time()+$offset ) ); 
     586        $time =  strtotime( date( 'Y-m-d H:m:s', current_time( 'timestamp' ) ) ) - strtotime( date( 'Y-m-d', current_time( 'timestamp' ) ) ); 
    585587        $time_remaining = 24*60*60 - $time; 
    586588        $todays_cache[$category] = ($caching)?$return:''; 
  • my-calendar/trunk/my-calendar.php

    r634688 r648376  
    66Author: Joseph C Dolson 
    77Author URI: http://www.joedolson.com 
    8 Version: 2.1.3 
     8Version: 2.1.4 
    99*/ 
    1010/*  Copyright 2009-2012  Joe Dolson (email : joe@joedolson.com) 
     
    2525*/ 
    2626global $mc_version, $wpdb; 
    27 $mc_version = '2.1.3'; 
     27$mc_version = '2.1.4'; 
    2828 
    2929// Define the tables used in My Calendar 
     
    146146            <h3><strong><?php _e('Support This Plug-in','my-calendar'); ?></strong></h3> 
    147147            <div class="inside resources"> 
     148                <p> 
     149                <a href="https://twitter.com/intent/tweet?screen_name=joedolson&text=My%20Calendar%20is%20great%20-%20Thanks!" class="twitter-mention-button" data-size="large" data-related="joedolson">Tweet to @joedolson</a> 
     150                <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> 
     151                </p> 
    148152                <p class="mcbuy"><img src="<?php echo plugins_url('my-calendar/images/guide.png'); ?>" alt="My Calendar User's Guide" class="alignleft" /><?php _e('Help me help you:','my-calendar'); ?> <a href="http://www.joedolson.com/articles/my-calendar/users-guide/" rel="external"><?php _e("Buy the My Calendar User's Guide",'my-calendar'); ?></a></p> 
    149153                <p><?php _e('<strong>Or make a donation today!</strong> Every donation counts - donate $2, $10, or $100 and help me keep this plug-in running!','my-calendar'); ?></p> 
     
    361365if ( !function_exists( 'admin_url' ) ) { 
    362366    function admin_url() { 
    363         return get_bloginfo('wpurl').'/wp-admin/'; 
     367        return site_url().'/wp-admin/'; 
    364368    } 
    365369} 
  • my-calendar/trunk/readme.txt

    r634688 r648376  
    6060Translator Credits (in no particular order)*: 
    6161 
    62 [Ale Gonzalez](http://60rpm.tv/i), [Outshine Solutions](http://outshinesolutions.com), [Jakob Smith](http://www.omkalfatring.dk/),, [globus2008](http://wordpress.org/support/profile/globus2008), Frederic Escallier, Luud Heck, Wim Strijbos, [Daisuke Abe](http://www.alter-ego.jp/), [Alex](http://blog.sotvoril.ru/), Mehmet Ko&ccedil;ali, Uwe Jonas, Florian Edelmann, Efva Nyberg, [Sabir Musta](http://mustaphasabir.altervista.org), Massimo Sgobino, Leonardo Kfoury, Alexandre Carvalho, Amir Khalilnejad, [Aurelio De Rosa](http://www.audero.it/), Bayram Dede, Dani Locasati, Dario Nunez, Dirk Ginader, Evren Erten, Fl&aacute;vio Pereira, Francois-Xavier Benard, [Gianni Diurno](http://www.gidibao.net), Giksi, Heinz Ochsner,  Kazuyuki Kumai, Liam Boogar, Maks, Mano, Massimo Sgobino, Mohsen Aghaei, Oscar, [Rashid Niamat](http://niamatmediagroup.nl/), Stefan Wikstrom, Thomas Meyer, Vedar Ozdemir, [Vikas Arora](http://www.wiznicworld.com), [Miriam de Paula](http://wpmidia.com.br), [Miriam de Paula](http://wpmidia.com.br), [HostUCan](http://www.hostucan.com), [Alex Alexandrov](http://www.webhostingrating.com), [Alyona Lompar](http://www.webhostinggeeks.com), [David Gil P&eacute;rez](http://www.sohelet.com), [Burkov Boris](http://chernobog.ru), [Raivo Ratsep](http://raivoratsep.com), [Jibo](http://jibo.ro), [Rasmus Himmelstrup](http://seoanalyst.dk), [kndb](http://blog.layer8.sh/) 
     62[Ale Gonzalez](http://60rpm.tv/i), [Outshine Solutions](http://outshinesolutions.com), [Jakob Smith](http://www.omkalfatring.dk/),, [globus2008](http://wordpress.org/support/profile/globus2008), Frederic Escallier, Luud Heck, Wim Strijbos, [Daisuke Abe](http://www.alter-ego.jp/), [Alex](http://blog.sotvoril.ru/), Mehmet Ko&ccedil;ali, Uwe Jonas, Florian Edelmann, Efva Nyberg, [Sabir Musta](http://mustaphasabir.altervista.org), Massimo Sgobino, Leonardo Kfoury, Alexandre Carvalho, Amir Khalilnejad, [Aurelio De Rosa](http://www.audero.it/), Bayram Dede, Dani Locasati, Dario Nunez, Dirk Ginader, Evren Erten, Fl&aacute;vio Pereira, Francois-Xavier Benard, [Gianni Diurno](http://www.gidibao.net), Giksi, Heinz Ochsner,  Kazuyuki Kumai, Liam Boogar, Maks, Mano, Massimo Sgobino, Mohsen Aghaei, Oscar, [Rashid Niamat](http://niamatmediagroup.nl/), Stefan Wikstrom, Thomas Meyer, Vedar Ozdemir, [Vikas Arora](http://www.wiznicworld.com), [Miriam de Paula](http://wpmidia.com.br), [HostUCan](http://www.hostucan.com), [Alex Alexandrov](http://www.webhostingrating.com), [Alyona Lompar](http://www.webhostinggeeks.com), [David Gil P&eacute;rez](http://www.sohelet.com), [Burkov Boris](http://chernobog.ru), [Raivo Ratsep](http://raivoratsep.com), [Jibo](http://jibo.ro), [Rasmus Himmelstrup](http://seoanalyst.dk), [kndb](http://blog.layer8.sh/) 
    6363 
    6464* Translators may not have contributed to this plug-in; but have contributed to my [translation repository](http://translate.joedolson.com). 
     
    8585 
    8686== Changelog == 
     87 
     88= 2.1.4 = 
     89 
     90* Bug fix: weekly view when crossing years jumped to next year 
     91* Bug fix: Upcoming events sorting fix 
     92* Bug fix: Upcoming events count fix 
     93* Bug fix: print stylesheet directory fix. 
    8794 
    8895= 2.1.3 = 
Note: See TracChangeset for help on using the changeset viewer.