diff options
author | Chad Little <clittle@users.sourceforge.net> | 2004-01-30 05:19:21 +0000 |
---|---|---|
committer | Chad Little <clittle@users.sourceforge.net> | 2004-01-30 05:19:21 +0000 |
commit | 93650f0d9811512ded7c21cd7a0a67b3cc14b732 (patch) | |
tree | 703ad787d1d44c75581023c043c33fffc0f3ff23 /functions | |
parent | 7dd9656474919d73208e1894a6553a0d2ae24af9 (diff) | |
download | phpicalendar-93650f0d9811512ded7c21cd7a0a67b3cc14b732.tar.gz phpicalendar-93650f0d9811512ded7c21cd7a0a67b3cc14b732.tar.bz2 phpicalendar-93650f0d9811512ded7c21cd7a0a67b3cc14b732.zip |
Consolidated lists into functions in one file.
Diffstat (limited to 'functions')
-rw-r--r-- | functions/ical_parser.php | 1 | ||||
-rw-r--r-- | functions/list_languages.php | 20 | ||||
-rw-r--r-- | functions/list_months.php | 22 | ||||
-rw-r--r-- | functions/list_weeks.php | 33 | ||||
-rw-r--r-- | functions/list_years.php | 31 | ||||
-rw-r--r-- | functions/template.php | 23 |
6 files changed, 14 insertions, 116 deletions
diff --git a/functions/ical_parser.php b/functions/ical_parser.php index 937e3b4..4f974e0 100644 --- a/functions/ical_parser.php +++ b/functions/ical_parser.php @@ -6,6 +6,7 @@ include_once(BASE.'functions/date_functions.php'); include_once(BASE.'functions/draw_functions.php'); include_once(BASE.'functions/overlapping_events.php'); include_once(BASE.'functions/timezones.php'); +include_once(BASE.'functions/list_functions.php'); $fillTime = $day_start; $day_array = array (); diff --git a/functions/list_languages.php b/functions/list_languages.php deleted file mode 100644 index d54bdf9..0000000 --- a/functions/list_languages.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php - -print "<form>\n<select name=\"action\" class=\"query_style\">\n"; -$dir_handle = @opendir(BASE.'languages/'); -$tmp_pref_language = urlencode(ucfirst($language)); -while ($file = readdir($dir_handle)) { - if (substr($file, -8) == ".inc.php") { - $language_tmp = urlencode(ucfirst(substr($file, 0, -8))); - if ($language_tmp == $tmp_pref_language) { - print "<option value=\"$current_view.php?chlang=$language_tmp\" selected>in $language_tmp</option>\n"; - } else { - print "<option value=\"$current_view.php?chlang=$language_tmp\">in $language_tmp</option>\n"; - } - } -} - -closedir($dir_handle); -print "</select>\n</form>\n"; - -?>
\ No newline at end of file diff --git a/functions/list_months.php b/functions/list_months.php deleted file mode 100644 index a6bfb74..0000000 --- a/functions/list_months.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php -print "<select name=\"action\" class=\"query_style\" onChange=\"window.location=(this.options[this.selectedIndex].value);\">\n"; -$month_time = strtotime("$this_year-01-01"); -$getdate_month = date("m", strtotime($getdate)); - -// echo "$this_day, $this_year"; -// build the <option> tags -for ($i=0; $i<12; $i++) { - $monthdate = date ("Ymd", $month_time); - $month_month = date("m", $month_time); - $select_month = localizeDate($dateFormat_month, $month_time); - if ($month_month == $getdate_month) { - print "<option value=\"month.php?cal=$cal&getdate=$monthdate\" selected>$select_month</option>\n"; - } else { - print "<option value=\"month.php?cal=$cal&getdate=$monthdate\">$select_month</option>\n"; - } - $month_time = strtotime ("+1 month", $month_time); -} - -// finish <select> -print "</select>"; -?>
\ No newline at end of file diff --git a/functions/list_weeks.php b/functions/list_weeks.php deleted file mode 100644 index 4de03d8..0000000 --- a/functions/list_weeks.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php - - -ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $getdate, $day_array2); -$this_day = $day_array2[3]; -$this_month = $day_array2[2]; -$this_year = $day_array2[1]; - -$check_week = strtotime($getdate); - -$start_week_time = strtotime(dateOfWeek(date("Ymd", strtotime("$this_year-01-01")), $week_start_day)); -$end_week_time = $start_week_time + (6 * 25 * 60 * 60); - -print "<select name=\"action\" class=\"query_style\" onChange=\"window.location=(this.options[this.selectedIndex].value);\">\n"; - -// build the <option> tags -do { - $weekdate = date ("Ymd", $start_week_time); - $select_week1 = localizeDate($dateFormat_week_jump, $start_week_time); - $select_week2 = localizeDate($dateFormat_week_jump, $end_week_time); - - if (($check_week >= $start_week_time) && ($check_week <= $end_week_time)) { - print "<option value=\"week.php?cal=$cal&getdate=$weekdate\" selected>$select_week1 - $select_week2</option>\n"; - } else { - print "<option value=\"week.php?cal=$cal&getdate=$weekdate\">$select_week1 - $select_week2</option>\n"; - } - $start_week_time = strtotime ("+1 week", $start_week_time); - $end_week_time = $start_week_time + (6 * 25 * 60 * 60); -} while (date("Y", $start_week_time) <= $this_year); - -// finish <select> -print "</select>"; -?>
\ No newline at end of file diff --git a/functions/list_years.php b/functions/list_years.php deleted file mode 100644 index 7b9c8de..0000000 --- a/functions/list_years.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php - -$year_time = strtotime($getdate); -print "<select name=\"action\" class=\"query_style\" onChange=\"window.location=(this.options[this.selectedIndex].value);\">\n"; - -// Print the previous year options. -for ($i=0; $i < $num_years; $i++) { - $offset = $num_years - $i; - $prev_time = strtotime("-$offset year", $year_time); - $prev_date = date("Ymd", $prev_time); - $prev_year = date("Y", $prev_time); - print "<option value=\"year.php?cal=$cal&getdate=$prev_date\">$prev_year</option>\n"; -} - -// Print the current year option. -$getdate_date = date("Ymd", $year_time); -$getdate_year = date("Y", $year_time); -print "<option value=\"year.php?cal=$cal&getdate=$getdate_date\" selected>$getdate_year</option>\n"; - -// Print the next year options. -for ($i=0; $i < $num_years; $i++) { - $offset = $i + 1; - $next_time = strtotime("+$offset year", $year_time); - $next_date = date("Ymd", $next_time); - $next_year = date("Y", $next_time); - print "<option value=\"year.php?cal=$cal&getdate=$next_date\">$next_year</option>\n"; -} - -// finish <select> -print "</select>"; -?> diff --git a/functions/template.php b/functions/template.php index f191011..c791eca 100644 --- a/functions/template.php +++ b/functions/template.php @@ -1,6 +1,7 @@ <?php function draw_month($template, $offset = '+0') { + global $getdate, $this_year, $this_month, $dateFormat_month, $week_start_day, $cal, $minical_view, $daysofweekreallyshort_lang; ob_start(); include($template); $template = ob_get_contents(); @@ -21,8 +22,9 @@ function draw_month($template, $offset = '+0') { $startweek = trim($match6[1]); $endweek = trim($match7[1]); $fake_getdate_time = strtotime($this_year.'-'.$this_month.'-15'); + $fake_getdate_time = strtotime("$offset month", $fake_getdate_time); $start_day = strtotime($week_start_day); - $month_title = localizeDate ($dateFormat_month, strtotime($getdate)); + $month_title = localizeDate ($dateFormat_month, $fake_getdate_time); for ($i=0; $i<7; $i++) { $day_num = date("w", $start_day); @@ -32,27 +34,26 @@ function draw_month($template, $offset = '+0') { $weekday_loop .= $loop_tmp; } - $minical_time = $fake_getdate_time; - $minical_month = date("m", $minical_time); - $minical_year = date("Y", $minical_time); + $minical_month = date("m", $fake_getdate_time); + $minical_year = date("Y", $fake_getdate_time); $first_of_month = $minical_year.$minical_month."01"; $start_day = strtotime(dateOfWeek($first_of_month, $week_start_day)); $i = 0; $whole_month = TRUE; $to_replace = array('{DAY}', '{CAL}', '{DAYLINK}', '{MINICAL_VIEW}'); - do { if ($i == 0) $middle .= $startweek; $day = date ("j", $start_day); $daylink = date ("Ymd", $start_day); $check_month = date ("m", $start_day); + $replace_with = array($day, $cal, $daylink, $minical_view); if ($check_month != $minical_month) { - $middle .= str_replace($to_replace, array($day, $cal, $daylink, $minical_view) , $notthismonth); + $middle .= str_replace($to_replace, $replace_with, $notthismonth); } elseif (isset($master_array[$daylink]) && ($check_month == $minical_month)) { - $middle .= str_replace($to_replace, array($day, $cal, $daylink, $minical_view) , $isevent); + $middle .= str_replace($to_replace, $replace_with, $isevent); } else { - $middle .= str_replace($to_replace, array($day, $cal, $daylink, $minical_view) , $notevent); + $middle .= str_replace($to_replace, $replace_with, $notevent); } $start_day = strtotime("+1 day", $start_day); @@ -68,6 +69,7 @@ function draw_month($template, $offset = '+0') { $return = eregi_replace('<!-- loop weekday on -->(.*)<!-- loop weekday off -->', $weekday_loop, $template); $return = eregi_replace('<!-- loop monthweeks on -->(.*)<!-- loop monthweeks off -->', $middle, $return); + $return = str_replace('{MONTH_TITLE}', $month_title, $return); return $return; @@ -117,13 +119,14 @@ class Page { } function output() { + global $template; preg_match_all ('!(\{MONTH_SMALL\|[+|-][0-9]\})!is', $this->page, $match); if (sizeof($match) > 0) { foreach ($match[1] as $key => $val) { - $template = 'templates/default/month_small.tpl'; + $template_file = 'templates/'.$template.'/month_small.tpl'; $offset = str_replace('}', '', $val); $offset = str_replace('{MONTH_SMALL|', '', $offset); - $data = draw_month($template, $offset); + $data = draw_month($template_file, $offset); $this->page = str_replace($val, $data, $this->page); } } |