1<?php
2
3function list_jumps() {
4	global $phpiCal_config, $lang, $cal;
5	$calName = join(',', array_map("getCalendarName", split(',', $cal)));
6	$today = date('Ymd', time() + $phpiCal_config->second_offset);
7	$return = '<option value="#">'.$lang['l_jump'].'</option>';
8	$return .= '<option value="day.php?cal='.$calName.'&amp;getdate='.$today.'">'.$lang['l_goday'].'</option>';
9	$return .= '<option value="week.php?cal='.$calName.'&amp;getdate='.$today.'">'.$lang['l_goweek'].'</option>';
10	$return .= '<option value="month.php?cal='.$calName.'&amp;getdate='.$today.'">'.$lang['l_gomonth'].'</option>';
11	$return .= '<option value="year.php?cal='.$calName.'&amp;getdate='.$today.'">'.$lang['l_goyear'].'</option>';
12	return $return;
13}
14
15function list_calcolors() {
16	global $phpiCal_config, $master_array;
17	$return = '';
18	$i = 1;
19	if (is_array($master_array['-3'])) {
20		foreach ($master_array['-3'] as $key => $val) {
21			if ($i > $phpiCal_config->unique_colors) $i = 1;
22			$val = str_replace ("\,", ",", $val);
23			$return .= '<img src="templates/'.$phpiCal_config->template.'/images/monthdot_'.$i.'.gif" alt="" /> '.$val.'<br />';
24			$i++;
25		}
26	}
27	return $return;
28}
29
30function list_months() {
31	global $getdate, $this_year, $cal, $dateFormat_month;
32	$month_time 	= strtotime("$this_year-01-01");
33	$getdate_month 	= date("m", strtotime($getdate));
34	$return = '';
35	for ($i=0; $i<12; $i++) {
36		$monthdate 		= date ("Ymd", $month_time);
37		$month_month 	= date("m", $month_time);
38		$select_month 	= localizeDate($dateFormat_month, $month_time);
39		if ($month_month == $getdate_month) {
40			$return .= "<option value=\"month.php?cal=$cal&amp;getdate=$monthdate\" selected=\"selected\">$select_month</option>\n";
41		} else {
42			$return .= "<option value=\"month.php?cal=$cal&amp;getdate=$monthdate\">$select_month</option>\n";
43		}
44		$month_time = strtotime ("+1 month", $month_time);
45	}
46	return $return;
47}
48
49
50function list_years() {
51	global $getdate, $this_year, $cal, $phpiCal_config;
52	$year_time = strtotime($getdate);
53	$return = '';
54	for ($i=0; $i < $phpiCal_config->num_years; $i++) {
55		$offset = $phpiCal_config->num_years - $i;
56		$prev_time = strtotime("-$offset year", $year_time);
57		$prev_date = date("Ymd", $prev_time);
58		$prev_year = date("Y", $prev_time);
59		$return .= "<option value=\"year.php?cal=$cal&amp;getdate=$prev_date\">$prev_year</option>\n";
60	}
61
62	$getdate_date = date("Ymd", $year_time);
63	$getdate_year = date("Y", $year_time);
64	$return .= "<option value=\"year.php?cal=$cal&amp;getdate=$getdate_date\" selected=\"selected\">$getdate_year</option>\n";
65
66	for ($i=0; $i < $phpiCal_config->num_years; $i++) {
67		$offset = $i + 1;
68		$next_time = strtotime("+$offset year", $year_time);
69		$next_date = date("Ymd", $next_time);
70		$next_year = date("Y", $next_time);
71		$return .=  "<option value=\"year.php?cal=$cal&amp;getdate=$next_date\">$next_year</option>\n";
72	}
73
74	return $return;
75}
76
77
78function list_weeks() {
79	global $getdate, $this_year, $cal, $dateFormat_week_jump, $phpiCal_config;
80	ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $getdate, $day_array2);
81	$this_day 			= $day_array2[3];
82	$this_month 		= $day_array2[2];
83	$this_year 			= $day_array2[1];
84	$check_week 		= strtotime($getdate);
85	$start_week_time 	= strtotime(dateOfWeek(date("Ymd", strtotime("$this_year-01-01")), $phpiCal_config->week_start_day));
86	$end_week_time 		= $start_week_time + (6 * 25 * 60 * 60);
87	$return = '';
88
89	do {
90		$weekdate 		= date ("Ymd", $start_week_time);
91		$select_week1 	= localizeDate($dateFormat_week_jump, $start_week_time);
92		$select_week2 	= localizeDate($dateFormat_week_jump, $end_week_time);
93
94		if (($check_week >= $start_week_time) && ($check_week <= $end_week_time)) {
95			$return .= "<option value=\"week.php?cal=$cal&amp;getdate=$weekdate\" selected=\"selected\">$select_week1 - $select_week2</option>\n";
96		} else {
97			$return .= "<option value=\"week.php?cal=$cal&amp;getdate=$weekdate\">$select_week1 - $select_week2</option>\n";
98		}
99		$start_week_time =  strtotime ("+1 week", $start_week_time);
100		$end_week_time = $start_week_time + (6 * 25 * 60 * 60);
101	} while (date("Y", $start_week_time) <= $this_year);
102
103	return $return;
104}
105
106function list_languages() {
107	global $getdate, $cal, $current_view;
108	$return = '';
109	$dir_handle = @opendir(BASE.'languages/');
110	$tmp_pref_language = urlencode(ucfirst($language));
111	while ($file = readdir($dir_handle)) {
112		if (substr($file, -8) == ".inc.php") {
113			$language_tmp = urlencode(ucfirst(substr($file, 0, -8)));
114			if ($language_tmp == $tmp_pref_language) {
115				$return .= "<option value=\"$current_view.php?chlang=$language_tmp\" selected=\"selected\">in $language_tmp</option>\n";
116			} else {
117				$return .= "<option value=\"$current_view.php?chlang=$language_tmp\">in $language_tmp</option>\n";
118			}
119		}
120	}
121	closedir($dir_handle);
122
123	return $return;
124}
125
126
127?>
128