[Comoblog-commit] comoblog/modules/mod_calendar mod_calendar.php,1.5,1.6
Status: Inactive
Brought to you by:
markwallis
|
From: Mark W. \(a. serialmonkey\) <mar...@us...> - 2005-10-08 13:27:49
|
Update of /cvsroot/comoblog/comoblog/modules/mod_calendar In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23582/modules/mod_calendar Modified Files: mod_calendar.php Log Message: RFE: 1280283 - Completed next/prev day with post functions in mod_calendar Index: mod_calendar.php =================================================================== RCS file: /cvsroot/comoblog/comoblog/modules/mod_calendar/mod_calendar.php,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- mod_calendar.php 7 Oct 2005 15:49:15 -0000 1.5 +++ mod_calendar.php 8 Oct 2005 13:27:41 -0000 1.6 @@ -95,31 +95,71 @@ $current_start = mktime (0,0,0,$current_date['mon'],$current_date['mday'],$current_date['year']); $current_date = getdate($current_start); +$valid_next = FALSE; +$valid_prev = FALSE; if (CFG_CALENDAR_BUTTON_CONFIG == "Skip One Day") { $next_timestamp = mktime (0,0,0,$current_date['mon'],$current_date['mday'] + 1,$current_date['year']); $prev_timestamp = mktime (0,0,0,$current_date['mon'],$current_date['mday'] - 1,$current_date['year']); + $valid_next = TRUE; + $valid_prev = TRUE; } else if (CFG_CALENDAR_BUTTON_CONFIG == "Skip One Month") { $next_timestamp = mktime (0,0,0,$current_date['mon'] + 1,$current_date['mday'],$current_date['year']); $prev_timestamp = mktime (0,0,0,$current_date['mon'] - 1,$current_date['mday'],$current_date['year']); + $valid_next = TRUE; + $valid_prev = TRUE; } else { + // Find prev day with posts + $currenttime = mktime(23,59,59,$current_date['mon'],$current_date['mday'] - 1,$current_date['year']); + $query = " + select post_added + from ".CFG_MYSQL_TABPREFIX."posts + where post_added <= '".$currenttime."' order by post_added desc limit 1"; + $res = mysql_query($query); + + if ($row = mysql_fetch_row($res)) { + $created_date = getdate($row[0]); + $prev_timestamp = mktime(0,0,0,$created_date['mon'], $created_date['mday'], $created_date['year']); + $valid_prev = TRUE; + } + + // Find next day with posts + $currenttime = mktime(0,0,0,$current_date['mon'],$current_date['mday']+1,$current_date['year']); + $query = " + select post_added + from ".CFG_MYSQL_TABPREFIX."posts + where post_added >= '".$currenttime."' order by post_added limit 1"; + $res = mysql_query($query); + if ($row = mysql_fetch_row($res)) { + $created_date = getdate($row[0]); + $next_timestamp = mktime(0,0,0,$created_date['mon'], $created_date['mday'], $created_date['year']); + $valid_next = TRUE; + } } -$pd = getdate($prev_timestamp); -if ($pd['mon'] < 10) $pd['mon'] = '0'.$pd['mon']; -if ($pd['mday'] < 10) $pd['mday'] = '0'.$pd['mday']; -$prev_date = $pd['year'].$pd['mon'].$pd['mday']; +if ($valid_prev) +{ + $pd = getdate($prev_timestamp); + if ($pd['mon'] < 10) $pd['mon'] = '0'.$pd['mon']; + if ($pd['mday'] < 10) $pd['mday'] = '0'.$pd['mday']; + $prev_date = $pd['year'].$pd['mon'].$pd['mday']; + $mod_calendar_tpl->assign ("PREV_DATE", $prev_date); +} -$nd = getdate($next_timestamp); -if ($nd['mon'] < 10) $nd['mon'] = '0'.$nd['mon']; -if ($nd['mday'] < 10) $nd['mday'] = '0'.$nd['mday']; -$next_date = $nd['year'].$nd['mon'].$nd['mday']; +if ($valid_next) +{ + $nd = getdate($next_timestamp); + if ($nd['mon'] < 10) $nd['mon'] = '0'.$nd['mon']; + if ($nd['mday'] < 10) $nd['mday'] = '0'.$nd['mday']; + $next_date = $nd['year'].$nd['mon'].$nd['mday']; + $mod_calendar_tpl->assign ("NEXT_DATE", $next_date); +} $today_timestamp = time(); $today_date = getdate($today_timestamp); @@ -127,13 +167,12 @@ $mod_calendar_tpl->assign ("CAL_DATE", strftime($CAL_DATE_FORMAT, $current_timestamp)); $mod_calendar_tpl->assign ("CURRENT_DATE", $current_date); -$mod_calendar_tpl->assign ("NEXT_DATE", $next_date); -$mod_calendar_tpl->assign ("PREV_DATE", $prev_date); $date = getdate(time()); -if ($current_start < mktime(0,0,0,$date['mon'],$date['mday'],$date['year'])) +if ($valid_next && $current_start < mktime(0,0,0,$date['mon'],$date['mday'],$date['year'])) $mod_calendar_tpl->parse("main.calendar.next"); - +if ($valid_prev) + $mod_calendar_tpl->parse("main.calendar.prev"); /////////////////////////////////////////////////////////////////////////////// // |