diff options
author | Jim Hu <jimhu@users.sourceforge.net> | 2008-12-31 07:14:34 +0000 |
---|---|---|
committer | Jim Hu <jimhu@users.sourceforge.net> | 2008-12-31 07:14:34 +0000 |
commit | 891159af439013fb1efd7c36799640ca30633f4a (patch) | |
tree | 93eed619c43d9c73aaea9a06cb21d833c1e5dddd | |
parent | 14bb051462a6614ef58ff066bc4bebd568c7808a (diff) | |
download | phpicalendar-891159af439013fb1efd7c36799640ca30633f4a.tar.gz phpicalendar-891159af439013fb1efd7c36799640ca30633f4a.tar.bz2 phpicalendar-891159af439013fb1efd7c36799640ca30633f4a.zip |
timeFormat select in preferences (feature request 1401779)
-rw-r--r-- | functions/init/configs.php | 18 | ||||
-rw-r--r-- | languages/bulgarian.inc.php | 4 | ||||
-rw-r--r-- | languages/english.inc.php | 1 | ||||
-rw-r--r-- | preferences.php | 58 | ||||
-rw-r--r-- | templates/default/preferences.tpl | 5 |
5 files changed, 71 insertions, 15 deletions
diff --git a/functions/init/configs.php b/functions/init/configs.php index f3028b1..d47f367 100644 --- a/functions/init/configs.php +++ b/functions/init/configs.php @@ -27,7 +27,6 @@ $phpiCal_config->setProperty('gridLength', $g); if ($phpiCal_config->cookie_uri == '') { $phpiCal_config->setProperty('cookie_uri', $_SERVER['SERVER_NAME'].substr($_SERVER['PHP_SELF'],0,strpos($_SERVER['PHP_SELF'], '/')) ); if ($phpiCal_config->cookie_uri == 'localhost') $phpiCal_config->setProperty('cookie_uri', ''); -; } $cookie_name = 'phpicalendar_'.basename($phpiCal_config->default_path); if (isset($_COOKIE[$cookie_name]) && !isset($_POST['unset'])) { @@ -55,6 +54,23 @@ if (is_file($lang_file)) { include_once($lang_file); } +if (isset($phpicalendar['cookie_timeformat']) && $phpicalendar['cookie_timeformat'] !=''){ + $timeFormat = $phpicalendar['cookie_timeformat']; +echo "here $timeFormat<pre>";print_r($phpicalendar); + switch($timeFormat){ + case 'h:i': + case 'h:i A': + $timeFormat_small = 'h:i'; + break; + case 'G:i': + case 'H:i': + $timeFormat_small = 'G:i'; + break; + default: + $timeFormat_small = 'g:i'; + } +} + $template = $phpiCal_config->template; $fillTime = $phpiCal_config->day_start; diff --git a/languages/bulgarian.inc.php b/languages/bulgarian.inc.php index da83212..647f8c2 100644 --- a/languages/bulgarian.inc.php +++ b/languages/bulgarian.inc.php @@ -166,8 +166,8 @@ $monthsofyear_lang = array ('Януари','Февруари','Март','Ап $monthsofyearshort_lang = array ('Яну','Фев','Мар','Апр','Май','Юни','Юли','Авг','Сеп','Окт','Ное','Дек'); // For time formatting, check out: http://www.php.net/manual/en/function.date.php -$timeFormat = 'G:I'; -$timeFormat_small = 'G:I'; +$timeFormat = 'G:i'; +$timeFormat_small = 'G:i'; // For date formatting, see note below $dateFormat_day = '%A, %e %B'; diff --git a/languages/english.inc.php b/languages/english.inc.php index 0db4bbe..b85f6a5 100644 --- a/languages/english.inc.php +++ b/languages/english.inc.php @@ -73,6 +73,7 @@ $lang['l_select_view'] = 'Select your default view'; $lang['l_select_time'] = 'Select your default start time'; $lang['l_select_timezone'] = 'Select your default timezone'; $lang['l_select_endtime'] = 'Select your default end time'; +$lang['l_select_timeformat']= 'Select your default time format (AM/PM)'; $lang['l_select_day'] = 'Select your default start day of week'; $lang['l_select_style'] = 'Select your default style'; $lang['l_set_prefs'] = 'Set preferences'; diff --git a/preferences.php b/preferences.php index eb0f17a..73a9624 100644 --- a/preferences.php +++ b/preferences.php @@ -29,10 +29,22 @@ if ($action == 'setcookie') { $cookie_style = $_POST['cookie_style']; $cookie_startday = $_POST['cookie_startday']; $cookie_time = $_POST['cookie_time']; + $cookie_timeformat = $_POST['cookie_timeformat']; $cookie_endtime = $_POST['cookie_endtime']; $cookie_timezone = $_POST['cookie_timezone']; $cookie_unset = @$_POST['unset']; - $the_cookie = array ("cookie_language" => "$cookie_language", "cookie_calendar" => "$cookie_calendar", "cookie_view" => "$cookie_view", "cookie_startday" => "$cookie_startday", "cookie_style" => "$cookie_style", "cookie_time" => "$cookie_time","cookie_endtime" => "$cookie_endtime", "cookie_cpath"=>"$cookie_cpath", "cookie_timezone"=>"$cookie_timezone"); + $the_cookie = array ( + "cookie_language" => "$cookie_language", + "cookie_calendar" => "$cookie_calendar", + "cookie_view" => "$cookie_view", + "cookie_startday" => "$cookie_startday", + "cookie_style" => "$cookie_style", + "cookie_time" => "$cookie_time", + "cookie_endtime" => "$cookie_endtime", + "cookie_timeformat" => "$cookie_timeformat", + "cookie_cpath" => "$cookie_cpath", + "cookie_timezone" => "$cookie_timezone" + ); $the_cookie = serialize($the_cookie); if ($cookie_unset) { setcookie("$cookie_name","$the_cookie",time()-(60*60*24*7) ,"/","$phpiCal_config->cookie_uri",0); @@ -59,22 +71,24 @@ if (isset($_COOKIE[$cookie_name])) { $cookie_startday = $phpicalendar['cookie_startday']; $cookie_time = $phpicalendar['cookie_time']; $cookie_endtime = $phpicalendar['cookie_endtime']; + $cookie_timeformat = $phpicalendar['cookie_timeformat']; $cookie_timezone = $phpicalendar['cookie_timezone']; if ($cookie_unset) { - unset ($cookie_language, $cookie_calendar, $cookie_view, $cookie_style,$cookie_startday); + unset ($cookie_language, $cookie_calendar, $cookie_view, $cookie_style, $cookie_startday, $cookie_time, $cookie_endtime, $cookie_timeformat, $cookie_timezone); } } if ((!isset($_COOKIE[$cookie_name])) || ($cookie_unset)) { # No cookie set -> use defaults from config file. - $cookie_language = ucfirst($language); - $cookie_calendar = $phpiCal_config->default_cal; - $cookie_view = $phpiCal_config->default_view; - $cookie_style = $phpiCal_config->template; - $cookie_startday = $phpiCal_config->week_start_day; - $cookie_time = $phpiCal_config->day_start; - $cookie_endtime = $phpiCal_config->day_end; - $cookie_timezone = $phpiCal_config->timezone; + $cookie_language = ucfirst($language); + $cookie_calendar = $phpiCal_config->default_cal; + $cookie_view = $phpiCal_config->default_view; + $cookie_style = $phpiCal_config->template; + $cookie_startday = $phpiCal_config->week_start_day; + $cookie_time = $phpiCal_config->day_start; + $cookie_endtime = $phpiCal_config->day_end; + $cookie_timeformat = $timeFormat; + $cookie_timezone = $phpiCal_config->timezone; } if ($action == 'setcookie') { @@ -108,8 +122,8 @@ $calendar_select = display_ical_list(availableCalendars($username, $password, $p $calendar_select .="<option value=\"$phpiCal_config->ALL_CALENDARS_COMBINED\">$all_cal_comb_lang</option>"; $calendar_select = str_replace("<option value=\"$cookie_calendar\">","<option value=\"$cookie_calendar\" selected='selected'>",$calendar_select); // select for dayview -$view_select = ($phpiCal_config->default_view == 'day') ? '<option value="day" selected="selected">{L_DAY}</option>' : '<option value="day">{L_DAY}</option>'; -$view_select .= ($phpiCal_config->default_view == 'week') ? '<option value="week" selected="selected">{L_WEEK}</option>' : '<option value="week">{L_WEEK}</option>'; +$view_select = ($phpiCal_config->default_view == 'day' ) ? '<option value="day" selected="selected">{L_DAY}</option>' : '<option value="day">{L_DAY}</option>'; +$view_select .= ($phpiCal_config->default_view == 'week' ) ? '<option value="week" selected="selected">{L_WEEK}</option>' : '<option value="week">{L_WEEK}</option>'; $view_select .= ($phpiCal_config->default_view == 'month') ? '<option value="month" selected="selected">{L_MONTH}</option>' : '<option value="month">{L_MONTH}</option>'; // select for time @@ -132,6 +146,24 @@ for ($i = 000; $i <= 2400; $i += 100) { } $endtime_select .= ">$s</option>\n"; } +$timeformat_arr = array( + 'g:i', + 'h:i', + 'g:i A', + 'h:i A', + 'G:i', + 'H:i', +); +$example_time = strtotime("19700101 08:00:00"); +$timeformat_select = ''; +foreach ($timeformat_arr as $i => $s) { + $s = date($timeformat_arr[$i], $example_time)."/".date($timeformat_arr[$i], ($example_time + 12*60*60)); + $timeformat_select .= '<option value="'.$timeformat_arr[$i].'"'; + if ($timeformat_arr[$i] == $cookie_timeformat) { + $timeformat_select .= ' selected="selected"'; + } + $timeformat_select .= ">$s</option>\n"; +} // select for day of week $i=0; @@ -237,6 +269,7 @@ $page->replace_tags(array( 'view_select' => $view_select, 'time_select' => $time_select, 'endtime_select' => $endtime_select, + 'timeformat_select' => $timeformat_select, 'startday_select' => $startday_select, 'style_select' => $style_select, 'display_date' => $lang['l_preferences'], @@ -248,6 +281,7 @@ $page->replace_tags(array( 'l_select_time' => $lang['l_select_time'], 'l_select_timezone' => $lang['l_select_timezone'], 'l_select_endtime' => $lang['l_select_endtime'], + 'l_select_timeformat'=> $lang['l_select_timeformat'], 'l_select_day' => $lang['l_select_day'], 'l_select_cal' => $lang['l_select_cal'], 'l_select_style' => $lang['l_select_style'], diff --git a/templates/default/preferences.tpl b/templates/default/preferences.tpl index 51fc37c..3d4500b 100644 --- a/templates/default/preferences.tpl +++ b/templates/default/preferences.tpl @@ -69,6 +69,11 @@ <td><select name="cookie_endtime" class="query_style">{ENDTIME_SELECT}</select></td> </tr> <tr align="left" valign="top"> + <td nowrap="nowrap">{L_SELECT_TIMEFORMAT}:</td> + <td><img src="images/spacer.gif" alt=" " width="20" height="1" border="0" /></td> + <td><select name="cookie_timeformat" class="query_style">{TIMEFORMAT_SELECT}</select></td> + </tr> + <tr align="left" valign="top"> <td nowrap="nowrap">{L_SELECT_DAY}:</td> <td><img src="images/spacer.gif" alt=" " width="20" height="1" border="0" /></td> <td><select name="cookie_startday" class="query_style">{STARTDAY_SELECT}</select></td> |