diff -r 000000000000 -r 03b0d1493584 web/wp-content/plugins/future-posts-calendar/future_calendar.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/wp-content/plugins/future-posts-calendar/future_calendar.php Wed Dec 23 17:55:33 2009 +0000 @@ -0,0 +1,277 @@ + +
+ + +
+ 'Future Posts'); + $options = (array) get_option('widget_fut_posts'); + + foreach ( $defaults as $key => $value ) + if ( !isset($options[$key]) ) + $options[$key] = $defaults[$key]; + + echo $before_widget . $before_title . $title . $after_title; + fcal_get_future_posts(0); + echo $after_widget; + } + + + register_sidebar_widget('Future Posts', 'widget_fut_posts'); + register_widget_control('Future Posts', 'widget_fut_posts_control'); +} + +// Delay plugin execution to ensure Dynamic Sidebar has a chance to load first +add_action('widgets_init', 'widget_fut_posts_init'); + + +function future_post_sidebar(){ + $title = __('Future Post','fcal'); + echo '
' . '

' . $title . '

'; + fcal_get_future_posts(); + echo '
'; +} + +function fcal_javascript(){ + echo ' + + '; +} + + +function get_future_calendar_html(){ +global $wp_version; + + if($wp_version < 2.5){ + echo '
'; + echo '

'.__('Future Post Dates','fcal').'

'; + echo '
'; + fcal_get_future_posts(); + echo '
'; + }else{ + echo '
'; + echo '

'.__('Future Post Dates','fcal').'

'; + fcal_get_future_posts(); + echo '
'; + + } + +} + +function fcal_get_future_posts($onclick = 1){ +global $wpdb, $wp_locale; + + $thisyear = gmdate('Y', current_time('timestamp')); + $thismonth = gmdate('m', current_time('timestamp')); + + // Quick check. If we have no posts at all, abort! + if ( !$posts ) { + $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'future' ORDER BY post_date DESC LIMIT 1"); + if ( !$gotsome ){ + get_future_calendar($thismonth,$thisyear,$onclick); + return; + } + } + + get_future_calendar($thismonth,$thisyear,$onclick); + + //Technically thismonth is really nextmonth, but no reason to be technical about it + //But if thismonth is 12 then we need to reset it, and add a year otherwise we will be checking + // out the 13th month of this year. + if($thismonth == 12){ + $thismonth = 0; + $thisyear +=1; + } + // Get months this year and next with at least one post + $future = $wpdb->get_results("SELECT + DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year + FROM $wpdb->posts + WHERE post_date >'$thisyear-".($thismonth+1)."-01' + AND post_type = 'post' AND post_status = 'future' + ORDER BY post_date ASC"); + + foreach($future as $now){ + get_future_calendar($now->month,$now->year); + } +} + + +// Calendar Output... +function get_future_calendar( $thismonth ='', $thisyear='', $onclick=1, $initial=true ) { + global $wpdb, $timedifference, $wp_locale; + $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); + + // week_begins = 0 stands for Sunday + $week_begins = intval(get_option('start_of_week')); + $add_hours = intval(get_option('gmt_offset')); + $add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours)); + + echo ' + + + '; + + $myweek = array(); + + for ( $wdcount=0; $wdcount<=6; $wdcount++ ) { + $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7); + } + + foreach ( $myweek as $wd ) { + $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); + echo "\n\t\t"; + } + + echo ' + + + + '; + + // Get days with posts + $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) + FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth' + AND YEAR(post_date) = '$thisyear' + AND post_type = 'post' AND post_status = 'future' + AND post_date > '" . current_time('mysql') . '\'', ARRAY_N); + if ( $dayswithposts ) { + foreach ( $dayswithposts as $daywith ) { + $daywithpost[] = $daywith[0]; + } + } else { + $daywithpost = array(); + } + + + + if ( strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') ) + $ak_title_separator = "\n"; + else + $ak_title_separator = ', '; + + $ak_titles_for_day = array(); + //sets the Density Thermometer + $ak_posts_for_day = array(); + + $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom " + ."FROM $wpdb->posts " + ."WHERE YEAR(post_date) = '$thisyear' " + ."AND MONTH(post_date) = '$thismonth' " + ."AND post_date > '".current_time('mysql')."' " + ."AND post_type = 'post' AND post_status = 'future'" + ); + if ( $ak_post_titles ) { + foreach ( $ak_post_titles as $ak_post_title ) { + if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) ) + $ak_titles_for_day['day_'.$ak_post_title->dom] = ''; + if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one + $ak_titles_for_day["$ak_post_title->dom"] = str_replace('"', '"', wptexturize($ak_post_title->post_title)); + else + $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . str_replace('"', '"', wptexturize($ak_post_title->post_title)); + + $ak_posts_for_day["$ak_post_title->dom"] +=1; + + } + } + + + // See how much we should pad in the beginning + $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins); + if ( 0 != $pad ) { echo "\n\t\t".''; } + + //Determines the Density Thermometer colors + $thermo = Array( "#BDFFBE", "#7AFFDE", "#2FEEFF", "#108BFF", "#0E72FF" ); + + + $daysinmonth = intval(date('t', $unixmonth)); + for ( $day = 1; $day <= $daysinmonth; ++$day ) { + if ( isset($newrow) && $newrow ) + echo "\n\t\n\t\n\t\t"; + $newrow = false; + + if ( $day == gmdate('j', (time() + (get_option('gmt_offset') * 3600))) && $thismonth == gmdate('m', time()+(get_option('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time()+(get_option('gmt_offset') * 3600)) ) + echo ''; + + echo "\n\t\n\t\n\t
' . $wp_locale->get_month($thismonth) . ' ' . $thisyear . '
$day_name
 
'; + else + echo ''; + + if($onclick == 1){ + $onclick1 = 'onclick="fcal_set_date('.$day.','.($thismonth-1).','.$thisyear.')"'; + } + + // any posts on that day? + if ( in_array($day, $daywithpost) ) { + //Outputs the Density Thermometer along with the day... + echo ' 
"; +} +?>