diff options
| author | Max Kremmel <xing@synapse.plus.com> | 2005-08-24 22:39:37 +0000 |
|---|---|---|
| committer | Max Kremmel <xing@synapse.plus.com> | 2005-08-24 22:39:37 +0000 |
| commit | d7a67c1be8e4c00bc0d520e299c84908ab8ab05b (patch) | |
| tree | 1d17acff5b8b9a014fd2a351beb61002171d0f48 | |
| parent | c60e390fab690dd692c61012b45d55a0fa152114 (diff) | |
| download | calendar-d7a67c1be8e4c00bc0d520e299c84908ab8ab05b.tar.gz calendar-d7a67c1be8e4c00bc0d520e299c84908ab8ab05b.tar.bz2 calendar-d7a67c1be8e4c00bc0d520e299c84908ab8ab05b.zip | |
add calendar admin page and admin menu
calendar time shift hopefully working now
week_offset defined as constant now
user preferences override defaults set by admin
| -rw-r--r-- | Calendar.php | 33 | ||||
| -rw-r--r-- | admin/admin_calendar_inc.php | 31 | ||||
| -rw-r--r-- | index.php | 13 | ||||
| -rw-r--r-- | modules/mod_calendar.php | 9 | ||||
| -rw-r--r-- | templates/admin_calendar.tpl | 39 | ||||
| -rw-r--r-- | templates/calendar.tpl | 20 | ||||
| -rw-r--r-- | templates/calendar_box.tpl | 4 | ||||
| -rw-r--r-- | templates/calendar_preferences_inc.tpl | 1 | ||||
| -rw-r--r-- | templates/menu_calendar_admin.tpl | 5 |
9 files changed, 113 insertions, 42 deletions
diff --git a/Calendar.php b/Calendar.php index 693c0d3..80ccb0d 100644 --- a/Calendar.php +++ b/Calendar.php @@ -1,12 +1,16 @@ <?php /** - * @version $Header: /cvsroot/bitweaver/_bit_calendar/Calendar.php,v 1.14 2005/08/24 20:34:22 squareing Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_calendar/Calendar.php,v 1.15 2005/08/24 22:39:37 squareing Exp $ * @package calendar */ /** * @package calendar */ + +// set week offset - start with a day other than monday +define( 'WEEK_OFFSET', !empty( $gBitUser->mUserPrefs['week_offset'] ) ? $gBitUser->mUserPrefs['week_offset'] : $gBitSystem->getPreference( 'week_offset', 0 ) ); + class Calendar extends LibertyContent { function Calendar() { @@ -50,8 +54,7 @@ class Calendar extends LibertyContent { $view_start = adodb_mktime( 0, 0, 0, $month, 1, $year ); $view_end = adodb_mktime( 0, 0, 0, $month + 1, 1, $year ) - 1; } elseif( $pDateHash['view_mode'] == 'week') { - $wd = adodb_date( 'w', $pDateHash['focus_date'] ); - $wd += $gBitSystem->getPreference( 'week_offset', 1 ); + $wd = adodb_date( 'w', $pDateHash['focus_date'] ) + WEEK_OFFSET; // if we are moving out from the selected week, move us back in if( $wd > 7 ) { $wd -= 7; @@ -109,21 +112,22 @@ class Calendar extends LibertyContent { } function buildDay( $pDateHash ) { - global $gBitSystem; + global $gBitSystem, $gBitUser; $year = adodb_date( 'Y', $pDateHash['focus_date'] ); $month = adodb_date( 'm', $pDateHash['focus_date'] ); $day = adodb_date( 'd', $pDateHash['focus_date'] ); $ret = array(); if( $pDateHash['view_mode'] == 'day' ) { - // calculations in preparation of custom dayview range setting - // all that needs to be done is adjust start and stop times accordingly - $start_time = $pDateHash['focus_date']; - $stop_time = adodb_mktime( 0, 0, 0, $month, $day + 1, $year ); + // calculare what the visible day view range is + $day_start = isset( $gBitUser->mUserPrefs['day_start'] ) ? $gBitUser->mUserPrefs['day_start'] : $gBitSystem->getPreference( 'day_start', 0 ); + $day_end = isset( $gBitUser->mUserPrefs['day_end'] ) ? $gBitUser->mUserPrefs['day_end'] : $gBitSystem->getPreference( 'day_end', 0 ); + $start_time = $pDateHash['focus_date'] + ( 60 * 60 * $day_start ); + $stop_time = adodb_mktime( 0, 0, 0, $month, $day + 1, $year ) - ( 60 * 60 * ( 24 - $day_end ) ); $hours_count = ( $stop_time - $start_time ) / ( 60 * 60 ); // allow for custom time intervals - $hour_fraction = $gBitSystem->getPreference( 'hour_fraction', 1 ); + $hour_fraction = !empty( $gBitUser->mUserPrefs['hour_fraction'] ) ? $gBitUser->mUserPrefs['hour_fraction'] : $gBitSystem->getPreference( 'hour_fraction', 1 ); $row_count = $hours_count * $hour_fraction; $hour = adodb_strftime( '%H', $start_time ) - 1; $mins = 0; @@ -175,9 +179,6 @@ class Calendar extends LibertyContent { $focus = adodb_getdate( $pDateHash['focus_date'] ); - // set week offset - start with a day other than monday - $week_offset = $gBitSystem->getPreference( 'week_offset', 0 ); - $prev_month_end = adodb_mktime( 0, 0, 0, $focus['mon'], 0, $focus['year'] ); $next_month_begin = adodb_mktime( 0, 0, 0, $focus['mon'] + 1, 1, $focus['year'] ); @@ -190,8 +191,8 @@ class Calendar extends LibertyContent { // Start the first row with the final day( s ) of the previous month. $week = array(); - $month_begin = adodb_mktime( 0, 0, 0, $focus['mon'], $week_offset, $focus['year'] ); - $month_begin_day_of_week = adodb_dow( $focus['year'], $focus['mon'], $week_offset ); + $month_begin = adodb_mktime( 0, 0, 0, $focus['mon'], WEEK_OFFSET, $focus['year'] ); + $month_begin_day_of_week = adodb_dow( $focus['year'], $focus['mon'], WEEK_OFFSET ); $days_in_prev_month = $this->daysInMonth( $prev_month, $prev_month_year ); // Fill out the first row with the last day( s ) of the previous month. @@ -218,13 +219,13 @@ class Calendar extends LibertyContent { for( $j = 1; $day_of_week < 7; $j++, $day_of_week++ ) { $week[]['day'] = adodb_mktime( 0, 0, 0, $focus['mon'] + 1, $j, $focus['year'] ); } - $calendar[adodb_woy( $focus['year'], $focus['mon'], $i + 7 + $week_offset )] = $week; + $calendar[adodb_woy( $focus['year'], $focus['mon'], $i + 7 + WEEK_OFFSET )] = $week; // this week number has to be calculated, since the cal start can be configured $week_num = adodb_woy( $focus['year'], $focus['mon'], $focus['mday'] ); // this is needed to display the correct week. - if( ( $focus['wday'] + $week_offset ) > 7 ) { + if( ( $focus['wday'] + WEEK_OFFSET ) > 7 ) { $week_num++; } diff --git a/admin/admin_calendar_inc.php b/admin/admin_calendar_inc.php new file mode 100644 index 0000000..13a935c --- /dev/null +++ b/admin/admin_calendar_inc.php @@ -0,0 +1,31 @@ +<?php +$hourValues = array( 1, 2, 3, 4, 6, 12 ); +$hourOutput = array( 60, 30, 20, 15, 10, 5 ); +$gBitSmarty->assign( 'hourValues', $hourValues ); +$gBitSmarty->assign( 'hourOutput', $hourOutput ); + +$firstDayValues = array( 0, 6, 5, 4, 3, 2, 1 ); +$firstDayOutput = array( tra( "Monday" ), tra( "Tuesday" ), tra( "Wednesday" ), tra( "Thursday" ), tra( "Friday" ), tra( "Saturday" ), tra( "Sunday" ) ); +$gBitSmarty->assign( 'firstDayValues', $firstDayValues ); +$gBitSmarty->assign( 'firstDayOutput', $firstDayOutput ); + +$dayStart = range( 0, 12 ); +$gBitSmarty->assign( 'dayStart', $dayStart ); +$dayEnd = range( 24, 13 ); +$gBitSmarty->assign( 'dayEnd', $dayEnd ); + +$calendarValues = array( + 'week_offset', + 'hour_fraction', + 'day_start', + 'day_end', +); + +// this function only exists if it's been included by the index.php page. if +// it's been included from anywhere else, we don't execute this section +if( function_exists( 'simple_set_value' ) && $gBitUser->isAdmin() && !empty( $_REQUEST['calendar_submit'] ) ) { + foreach( $calendarValues as $item ) { + simple_set_value( $item, CALENDAR_PKG_NAME ); + } +} +?> @@ -1,6 +1,6 @@ <?php -// $Header: /cvsroot/bitweaver/_bit_calendar/index.php,v 1.26 2005/08/22 11:59:32 lsces Exp $ +// $Header: /cvsroot/bitweaver/_bit_calendar/index.php,v 1.27 2005/08/24 22:39:37 squareing Exp $ // Copyright( c ) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. // All Rights Reserved. See copyright.txt for details and a complete list of authors. @@ -116,17 +116,14 @@ $dayNames = array( ); // 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 ); - } +for( $i = 0; $i < WEEK_OFFSET; $i++ ) { + $pop = array_pop( $dayNames ); + array_unshift( $dayNames, $pop ); } $gBitSmarty->assign( 'dayNames', $dayNames ); // TODO: make this a pref -$gBitSmarty->assign( 'trunc', 12 ); +$gBitSmarty->assign( 'trunc', $gBitSystem->getPreference( 'title_truncate', 12 ) ); $gBitSystem->display( 'bitpackage:calendar/calendar.tpl' ); ?> diff --git a/modules/mod_calendar.php b/modules/mod_calendar.php index 01d7e06..cc7840c 100644 --- a/modules/mod_calendar.php +++ b/modules/mod_calendar.php @@ -30,12 +30,9 @@ $dayNames = array( ); // 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 ); - } +for( $i = 0; $i < WEEK_OFFSET; $i++ ) { + $pop = array_pop( $dayNames ); + array_unshift( $dayNames, $pop ); } $gBitSmarty->assign( 'dayNames', $dayNames ); diff --git a/templates/admin_calendar.tpl b/templates/admin_calendar.tpl new file mode 100644 index 0000000..587cad7 --- /dev/null +++ b/templates/admin_calendar.tpl @@ -0,0 +1,39 @@ +{strip} +{if !$settings} + {assign var=settings value=$gBitSystemPrefs} +{/if} + +{form legend="Calendar Settings"} + <input type="hidden" name="page" value="{$page}" /> + <div class="row"> + {formlabel label="First day of Week" for="week_offset"} + {forminput} + {html_options name=week_offset output=$firstDayOutput values=$firstDayValues selected=`$settings.week_offset` id=week_offset} + {formhelp note="Set the first day of the week."} + {/forminput} + </div> + + <div class="row"> + {formlabel label="Time Blocks" for="hour_fraction"} + {forminput} + {html_options name=hour_fraction output=$hourOutput values=$hourValues selected=`$settings.hour_fraction` id=hour_fraction} {tr}minutes{/tr} + {formhelp note="Set the timeblocks for the day view."} + {/forminput} + </div> + + <div class="row"> + {formlabel label="Day View times" for="day_start"} + {forminput} + {tr}from{/tr} + {html_options name=day_start output=$dayStart values=$dayStart selected=`$settings.day_start` id=day_start} + {tr}to{/tr} + {html_options name=day_end output=$dayEnd values=$dayEnd selected=`$settings.day_end` id=day_start} + {formhelp note="Pick the start and end time of your day view."} + {/forminput} + </div> + + <div class="row submit"> + <input type="submit" name="calendar_submit" value="{tr}Change preferences{/tr}" /> + </div> +{/form} +{/strip} diff --git a/templates/calendar.tpl b/templates/calendar.tpl index ce5e27d..2ebca3f 100644 --- a/templates/calendar.tpl +++ b/templates/calendar.tpl @@ -1,4 +1,4 @@ -{* $Header: /cvsroot/bitweaver/_bit_calendar/templates/calendar.tpl,v 1.23 2005/08/22 18:46:53 squareing Exp $ *} +{* $Header: /cvsroot/bitweaver/_bit_calendar/templates/calendar.tpl,v 1.24 2005/08/24 22:39:37 squareing Exp $ *} {strip} {if !$gBitSystem->isFeatureActive( 'feature_helppopup' )} @@ -19,7 +19,7 @@ {include file="bitpackage:calendar/calendar_nav_inc.tpl"} <table class="data caltable {$smarty.session.calendar.view_mode}"> - <caption>{tr}Selection: {$navigation.focus_date|bit_long_date}{/tr}</caption> + <caption>{tr}Selection: {$navigation.focus_date|date_format}{/tr}</caption> {if $smarty.session.calendar.view_mode eq 'day'} <tr> <th style="width:5%;">{tr}Time{/tr}</th> @@ -27,12 +27,12 @@ </tr> {foreach item=t from=$calDay} <tr class="{cycle values="odd,even"}"> - <td style="text-align:right; vertical-align:top; padding-right:15px;">{$t.time|bit_date_format:"%H:%M"}</td> + <td style="text-align:right; vertical-align:top; padding-right:15px;">{$t.time|date_format:"%H:%M"}</td> <td> {foreach from=$t.items item=item} {assign var=over value=$item.over} <div class="cal cal{$item.content_type_guid}"> - {$item.last_modified|bit_date_format:"%R"}: + {$item.last_modified|date_format:"%H:%M"}: <a href="{$smarty.const.BIT_ROOT_URL}index.php?content_id={$item.content_id}" {popup fullhtml="1" sticky="1" timeout="2500" text=$over|escape:"javascript"|escape:"html"}> {$item.title|default:"..."} </a> @@ -44,17 +44,17 @@ {else} <tr> <th style="width:2%;"></th> - {foreach from=$dayNames item=name} - <th style="width:14%">{$name}</th> + {foreach from=$dayNames item=dayName} + <th style="width:14%">{$dayName}</th> {/foreach} </tr> {foreach from=$calMonth key=week_num item=week} <tr style="height:6em;"> - <th>{$week_num}</th> + <th><a href="{$smarty.const.CALENDAR_PKG_URL}index.php?view_mode=week&todate={$week.6.day}">{$week_num}</a></th> {foreach from=$week item=day} {if $smarty.session.calendar.view_mode eq "month"} - {if $day.day|bit_date_format:"%m" eq $navigation.focus_month} + {if $day.day|date_format:"%m" eq $navigation.focus_month} {cycle values="odd,even" print=false advance=false} {else} {cycle values="notmonth" print=false advance=false} @@ -64,9 +64,9 @@ {/if} <td class="calday {if $day.day eq $navigation.focus_date}current{/if} {cycle}" style="vertical-align:top;"> - {if $day.day|bit_date_format:"%m" eq $navigation.focus_month or $smarty.session.calendar.view_mode eq "week"} + {if $day.day|date_format:"%m" eq $navigation.focus_month or $smarty.session.calendar.view_mode eq "week"} <div class="calnumber"> - <a href="{$smarty.const.CALENDAR_PKG_URL}index.php?todate={$day.day}&{$url_string}">{$day.day|bit_date_format:"%d"}</a> + <a href="{$smarty.const.CALENDAR_PKG_URL}index.php?view_mode=day&todate={$day.day}&{$url_string}">{$day.day|date_format:"%d"}</a> </div> {* - Cell Content - *} diff --git a/templates/calendar_box.tpl b/templates/calendar_box.tpl index 20f71e1..72215e6 100644 --- a/templates/calendar_box.tpl +++ b/templates/calendar_box.tpl @@ -4,9 +4,9 @@ {tr}Content Type{/tr}: {$cellHash.content_description} <small> <br /> - {tr}First created by {displayname login=$cellHash.creator_user real_name=$cellHash.creator_real_name}<br /> on {$cellHash.created|bit_short_datetime}{/tr} + {tr}First created by {displayname login=$cellHash.creator_user real_name=$cellHash.creator_real_name}<br /> on {$cellHash.created|date_format:"%Y-%m-%d - %H:%M"}{/tr} <br /> - {tr}Last modified by {displayname login=$cellHash.modifier_user real_name=$cellHash.modifier_real_name}<br /> on {$cellHash.last_modified|bit_short_datetime}{/tr} + {tr}Last modified by {displayname login=$cellHash.modifier_user real_name=$cellHash.modifier_real_name}<br /> on {$cellHash.last_modified|date_format:"%Y-%m-%d - %H:%M"}{/tr} </small> </div> </div> diff --git a/templates/calendar_preferences_inc.tpl b/templates/calendar_preferences_inc.tpl new file mode 100644 index 0000000..a98d94a --- /dev/null +++ b/templates/calendar_preferences_inc.tpl @@ -0,0 +1 @@ +{include file='bitpackage:calendar/admin_calendar.tpl'} diff --git a/templates/menu_calendar_admin.tpl b/templates/menu_calendar_admin.tpl new file mode 100644 index 0000000..291ecc1 --- /dev/null +++ b/templates/menu_calendar_admin.tpl @@ -0,0 +1,5 @@ +{strip} +<ul> + <li><a class="item" href="{$smarty.const.KERNEL_PKG_URL}admin/index.php?page=calendar">{tr}Calendar Settings{/tr}</a></li> +</ul> +{/strip} |
