diff options
| author | Max Kremmel <xing@synapse.plus.com> | 2005-08-21 11:59:26 +0000 |
|---|---|---|
| committer | Max Kremmel <xing@synapse.plus.com> | 2005-08-21 11:59:26 +0000 |
| commit | f0a51ae92c7b47cd637a9fa17f768cb494fac222 (patch) | |
| tree | a7a3269ab512e1d422c358a8cc869b1a34c400b1 /modules | |
| parent | 1b63a16645062a86ca6a9ca52f57d762c8e40c53 (diff) | |
| download | calendar-f0a51ae92c7b47cd637a9fa17f768cb494fac222.tar.gz calendar-f0a51ae92c7b47cd637a9fa17f768cb494fac222.tar.bz2 calendar-f0a51ae92c7b47cd637a9fa17f768cb494fac222.zip | |
commit to get everything up to date
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/mod_calendar.php | 43 | ||||
| -rw-r--r-- | modules/mod_calendar.tpl | 55 |
2 files changed, 96 insertions, 2 deletions
diff --git a/modules/mod_calendar.php b/modules/mod_calendar.php index b23dd30..1e93e0a 100644 --- a/modules/mod_calendar.php +++ b/modules/mod_calendar.php @@ -1,3 +1,44 @@ <?php -$gBitSmarty->assign( "todate", !empty( $_SESSION['calendar_focus_date'] ) ? $_SESSION['calendar_focus_date'] : date() ); +include_once( CALENDAR_PKG_PATH.'Calendar.php' ); +$cal = new Calendar(); + +// set up the todate +if( !empty( $_REQUEST["todate"] ) ) { + // clean up todate. who knows where this has come from + $_SESSION['calendar']['focus_date'] = $_REQUEST['todate'] = mktime( 0, 0, 0, date( 'm', $_REQUEST['todate'] ), date( 'd', $_REQUEST['todate'] ), date( 'Y', $_REQUEST['todate'] ) ); +} elseif( !empty( $_SESSION['calendar']['focus_date'] ) ) { + $_REQUEST["todate"] = $_SESSION['calendar']['focus_date']; +} else { + $_SESSION['calendar']['focus_date'] = mktime( 0, 0, 0, date( 'm' ), date( 'd' ), date( 'Y' ) ); + $_REQUEST["todate"] = $_SESSION['calendar']['focus_date']; +} + +$calHash = array( + 'focus_date' => $_SESSION['calendar']['focus_date'], + 'view_mode' => 'month', +); + +// set up daynames for the calendar +$dayNames = array( + tra( "Mon" ), + tra( "Tue" ), + tra( "Wed" ), + tra( "Thu" ), + tra( "Fri" ), + tra( "Sat" ), + tra( "Sun" ), +); + +// depending on what day we want to view first, we need to adjust the dayNames array +$week_offset = $gBitSystem->getPreference( 'week_offset', 1 ); +if( !empty( $week_offset ) ) { + for( $i = 0; $i < $week_offset; $i++ ) { + $pop = array_pop( $dayNames ); + array_unshift( $dayNames, $pop ); + } +} +$gBitSmarty->assign( 'dayNames', $dayNames ); + +$gBitSmarty->assign( 'modCalNavigation', $cal->buildCalendarNavigation( $calHash ) ); +$gBitSmarty->assign( 'modCalMonth', $calMonth = $cal->buildCalendar( $calHash ) ); ?> diff --git a/modules/mod_calendar.tpl b/modules/mod_calendar.tpl index 51ee10f..837acd5 100644 --- a/modules/mod_calendar.tpl +++ b/modules/mod_calendar.tpl @@ -1,3 +1,56 @@ {bitmodule title="$moduleTitle" name="calendar"} - {calendar todate=$todate} + <table> + <caption>{$modCalNavigation.focus_date|date_format:"%B"}</caption> + <tr> + <td style="text-align:left;"> + <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?todate={$navigation.before.month}&{$url_string}" title="{$navigation.before.month|bit_long_date}">«{tr}m{/tr}</a><br /> + </td> + <td style="text-align:left;"> + <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?todate={$navigation.before.year}&{$url_string}" title="{$navigation.before.year|bit_long_date}">«{tr}y{/tr}</a> + </td> + + <td colspan="3" style="text-align:center;"> + <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?todate={$smarty.now}&{$url_string}" title="{$smarty.now|bit_long_date}">{tr}Today{/tr}</a> + </td> + + <td style="text-align:right;"> + <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?todate={$navigation.after.month}&{$url_string}" title="{$navigation.after.month|bit_long_date}">{tr}m{/tr}»</a><br /> + </td> + <td style="text-align:right;"> + <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?todate={$navigation.after.year}&{$url_string}" title="{$navigation.after.year|bit_long_date}">{tr}y{/tr}»</a> + </td> + </tr> + + <tr> + {foreach from=$dayNames item=name} + <th width="14%">{$name}</th> + {/foreach} + </tr> + + {foreach from=$modCalMonth key=week_num item=week} + <tr> + {foreach from=$week item=day} + {if $smarty.session.calendar.view_mode eq "month"} + {if $day.day|date_format:"%m" eq $modCalNavigation.focus_month} + {cycle values="odd,even" print=false advance=false} + {else} + {cycle values="notmonth" print=false advance=false} + {/if} + {else} + {cycle values="odd,even" print=false advance=false} + {/if} + + <td class="{cycle}" style="text-align:right;"> + {if $day.day|date_format:"%m" eq $modCalNavigation.focus_month or $smarty.session.calendar.view_mode eq "week"} + {if $day.day eq $modCalNavigation.focus_date}<strong>{/if} + <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?todate={$day.day}&{$url_string}">{$day.day|date_format:"%d"}</a> + {if $day.day eq $modCalNavigation.focus_date}</strong>{/if} + {else} + + {/if} + </td> + {/foreach} + </tr> + {/foreach} + </table> {/bitmodule} |
