aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChad Little <clittle@users.sourceforge.net>2004-01-31 07:07:37 +0000
committerChad Little <clittle@users.sourceforge.net>2004-01-31 07:07:37 +0000
commitc143f2891418cb0f0ae0f80f7d2d58e69879a722 (patch)
tree334840b988d61e27d5ae3ab1b9ee29a2cf0bdd0a
parent90f43e0c205d2e511bb0255fa20d422d15cffc64 (diff)
downloadphpicalendar-c143f2891418cb0f0ae0f80f7d2d58e69879a722.tar.gz
phpicalendar-c143f2891418cb0f0ae0f80f7d2d58e69879a722.tar.bz2
phpicalendar-c143f2891418cb0f0ae0f80f7d2d58e69879a722.zip
Many many changes. Faster templating.
-rw-r--r--functions/date_functions.php15
-rw-r--r--functions/template.php212
-rw-r--r--month.php5
-rw-r--r--preferences.php2
-rw-r--r--templates/default/header.tpl2
-rw-r--r--templates/default/month.tpl4
-rw-r--r--templates/default/month_large.tpl37
7 files changed, 130 insertions, 147 deletions
diff --git a/functions/date_functions.php b/functions/date_functions.php
index 72b9a9c..02cfa77 100644
--- a/functions/date_functions.php
+++ b/functions/date_functions.php
@@ -195,21 +195,22 @@ function openevent($calendar_name, $start, $end, $arr, $lines, $wrap, $pre_text,
$escaped_end = addslashes($end);
// fix for URL-length bug in IE: populate and submit a hidden form on click
static $popup_data_index = 0;
-echo <<<END
+$return = "
- <script language="Javascript" type="text/javascript"><!--
+ <script language=\"Javascript\" type=\"text/javascript\"><!--
var eventData = new EventData('$escaped_event', '$escaped_calendar', '$escaped_start', '$escaped_end', '$description', '$status', '$location', '$organizer', '$attendee', '$url');
document.popup_data[$popup_data_index] = eventData;
- // --></script>
+ // --></script>";
-END;
- echo '<a class="'.$link_class.'" href="#" onclick="openEventWindow('.$popup_data_index.'); return false;">';
+ $return .= '<a class="'.$link_class.'" href="#" onclick="openEventWindow('.$popup_data_index.'); return false;">';
$popup_data_index++;
} else {
- echo '<a class="'.$link_class.'" href="'.$res[1].'">';
+ $return .= '<a class="'.$link_class.'" href="'.$res[1].'">';
}
- echo $pre_text.$event_text.$post_text.'</a>'."\n";
+ $return .= $pre_text.$event_text.$post_text.'</a>'."\n";
}
+
+ return $return;
}
diff --git a/functions/template.php b/functions/template.php
index ca214da..856d926 100644
--- a/functions/template.php
+++ b/functions/template.php
@@ -2,98 +2,111 @@
//print_r($master_array);
-function draw_month($template, $offset = '+0', $type) {
- global $getdate, $master_array, $this_year, $this_month, $dateFormat_month, $week_start_day, $cal, $minical_view, $daysofweekreallyshort_lang, $daysofweek_lang;
- ob_start();
- include($template);
- $template = ob_get_contents();
- ob_end_clean();
- preg_match("!<\!-- loop weekday on -->(.*)<\!-- loop weekday off -->!is", $template, $match1);
- preg_match("!<\!-- loop monthdays on -->(.*)<\!-- loop monthdays off -->!is", $template, $match2);
- preg_match("!<\!-- loop monthweeks on -->(.*)<\!-- loop monthdays on -->!is", $template, $match6);
- preg_match("!<\!-- loop monthdays off -->(.*)<\!-- loop monthweeks off -->!is", $template, $match7);
-
- $loop_wd = trim($match1[1]);
- $loop_md = trim($match2[1]);
- $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, $fake_getdate_time);
- if ($type == 'small') {
- $type = $daysofweekreallyshort_lang;
- } elseif ($type == 'medium') {
- $type = $daysofweekshort_lang;
- } elseif ($type == 'large') {
- $type = $daysofweek_lang;
- }
-
- for ($i=0; $i<7; $i++) {
- $day_num = date("w", $start_day);
- $weekday = $type[$day_num];
- $start_day = strtotime("+1 day", $start_day);
- $loop_tmp = str_replace('{LOOP_WEEKDAY}', $weekday, $loop_wd);
- $weekday_loop .= $loop_tmp;
- }
-
- $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;
-
- do {
- if ($i == 0) $middle .= $startweek; $i++;
- $temp_middle = $loop_md;
- $switch = array('notthismonth' => '', 'istoday' => '', 'ismonth' => '', 'noevent' => '', 'anyevent' => '', 'allday' => '', 'event_title' => '', 'cal' => $cal, 'minical_view' => $minical_view);
- $check_month = date ("m", $start_day);
- $daylink = date ("Ymd", $start_day);
- $switch['day'] = date ("j", $start_day);
- $switch['daylink'] = date ("Ymd", $start_day);
- $switch['notthismonth'] = ($check_month != $minical_month) ? 'set' : '';
- $switch['istoday'] = ($switch['daylink'] == $getdate) ? 'set' : '';
- $switch['ismonth'] = (($switch['istoday'] == '') && ($switch['notthismonth'] == '')) ? 'set' : '';
- if (isset($master_array[$daylink]['-1'])) {
- $switch['anyevent'] = 'set';
- $switch['allday'] = 'set';
- //$switch['event_title'] = $master_array[$daylink]['-1']['0']['event_text'];
- //print_r ($master_array[$daylink]['-1']);
- } elseif (isset($master_array[$daylink])) {
- $switch['anyevent'] = 'set';
- } else {
- $switch['noevent'] = 'set';
- }
+
+
+class Page {
+ var $page;
+ function draw_month($template, $offset = '+0', $type) {
+ global $getdate, $master_array, $this_year, $this_month, $dateFormat_month, $week_start_day, $cal, $minical_view, $daysofweekreallyshort_lang, $daysofweek_lang, $timeFormat_small, $timeFormat;
+ preg_match("!<\!-- loop weekday on -->(.*)<\!-- loop weekday off -->!is", $template, $match1);
+ preg_match("!<\!-- loop monthdays on -->(.*)<\!-- loop monthdays off -->!is", $template, $match2);
+ preg_match("!<\!-- loop monthweeks on -->(.*)<\!-- loop monthdays on -->!is", $template, $match6);
+ preg_match("!<\!-- loop monthdays off -->(.*)<\!-- loop monthweeks off -->!is", $template, $match7);
- foreach ($switch as $tag => $data) {
- if (!$data) {
- $temp_middle = eregi_replace('<!-- switch ' . $tag . ' on -->(.*)<!-- switch ' . $tag . ' off -->', '', $temp_middle);
- } else {
- $temp_middle = eregi_replace('{' . $tag . '}', $data, $temp_middle);
- }
+ $loop_wd = trim($match1[1]);
+ $loop_md = trim($match2[1]);
+ $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, $fake_getdate_time);
+ if ($type == 'small') {
+ $type = $daysofweekreallyshort_lang;
+ } elseif ($type == 'medium') {
+ $type = $daysofweekshort_lang;
+ } elseif ($type == 'large') {
+ $type = $daysofweek_lang;
}
- $middle .= $temp_middle;
- $start_day = strtotime("+1 day", $start_day);
- if ($i == 7) {
- $i = 0;
- $middle .= $endweek;
- $checkagain = date ("m", $start_day);
- if ($checkagain != $minical_month) $whole_month = FALSE;
+ for ($i=0; $i<7; $i++) {
+ $day_num = date("w", $start_day);
+ $weekday = $type[$day_num];
+ $start_day = strtotime("+1 day", $start_day);
+ $loop_tmp = str_replace('{LOOP_WEEKDAY}', $weekday, $loop_wd);
+ $weekday_loop .= $loop_tmp;
}
- } while ($whole_month == TRUE);
-
- $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);
+
+ $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;
+
+ do {
+ if ($i == 0) $middle .= $startweek; $i++;
+ $temp_middle = $loop_md;
+ $switch = array('notthismonth' => '', 'istoday' => '', 'ismonth' => '', 'noevent' => '', 'anyevent' => '', 'allday' => '', 'cal' => $cal, 'minical_view' => $minical_view);
+ $check_month = date ("m", $start_day);
+ $daylink = date ("Ymd", $start_day);
+ $switch['day'] = date ("j", $start_day);
+ $switch['daylink'] = date ("Ymd", $start_day);
+ $switch['notthismonth'] = ($check_month != $minical_month) ? 'set' : '';
+ $switch['istoday'] = ($switch['daylink'] == $getdate) ? 'set' : '';
+ $switch['ismonth'] = (($switch['istoday'] == '') && ($switch['notthismonth'] == '')) ? 'set' : '';
+ if ($master_array[$daylink]) {
+ $switch['anyevent'] = 'set';
+ foreach ($master_array[$daylink] as $event_times) {
+ foreach ($event_times as $val) {
+ $event_calno = $val['calnumber'];
+ $event_calna = $val['calname'];
+ $event_url = $val['url'];
+ if (!isset($val['event_start'])) {
+ $switch['allday'] .= '<div align="left" class="V10">';
+ $switch['allday'] .= openevent($event_calna, '', '', $val, $month_event_lines, 15, '', '', 'psf', $event_url);
+ $switch['allday'] .= '</div>';
+ } else {
+ $event_start = $val['start_unixtime'];
+ $event_end = (isset($val['display_end'])) ? $val['display_end'] : $val["event_end"];
+ $event_start = date($timeFormat, $val['start_unixtime']);
+ $start2 = date($timeFormat_small, $val['start_unixtime']);
+ $event_end = date($timeFormat, @strtotime ($event_end));
+ $switch['event'] .= '<div align="left" class="V9">';
+ $switch['event'] .= openevent($event_calna, $event_start, $event_end, $val, $month_event_lines, 10, "$start2 ", '', 'ps3', $event_url);
+ $switch['event'] .= '</div>';
+ }
+ }
+ }
+ }
+
+ foreach ($switch as $tag => $data) {
+ if (!$data) {
+ $temp_middle = ereg_replace('<!-- switch ' . $tag . ' on -->(.*)<!-- switch ' . $tag . ' off -->', '', $temp_middle);
+ } else {
+ $temp_middle = str_replace('{' . strtoupper($tag) . '}', $data, $temp_middle);
+ }
+ }
+ $middle .= $temp_middle;
+
+ $start_day = strtotime("+1 day", $start_day);
+ if ($i == 7) {
+ $i = 0;
+ $middle .= $endweek;
+ $checkagain = date ("m", $start_day);
+ if ($checkagain != $minical_month) $whole_month = FALSE;
+ }
+ } while ($whole_month == TRUE);
+
+ $return = preg_replace('!<\!-- loop weekday on -->(.*)<\!-- loop weekday off -->!is', $weekday_loop, $template);
+ $return = ereg_replace('<!-- loop monthweeks on -->(.*)<!-- loop monthweeks off -->', $middle, $return);
+ $return = str_replace('{MONTH_TITLE}', $month_title, $return);
+
+ return $return;
+
+ }
- return $return;
-}
-
-class Page {
- var $page;
function Page($template = 'std.tpl') {
if (file_exists($template))
$this->page = join('', file($template));
@@ -118,33 +131,27 @@ class Page {
// This removes any unfilled tags
if ($data == '') {
- $this->page = eregi_replace('<!-- switch ' . $tag . ' on -->(.*)<!-- switch ' . $tag . ' off -->', '', $this->page);
+ $this->page = ereg_replace('<!-- switch ' . $tag . ' on -->(.*)<!-- switch ' . $tag . ' off -->', '', $this->page);
}
// This replaces any tags
- $this->page = eregi_replace('{' . $tag . '}', $data, $this->page);
+ $this->page = str_replace('{' . strtoupper($tag) . '}', $data, $this->page);
}
else
die('No tags designated for replacement.');
}
- function replace_langs($langs = array()) {
- foreach ($langs as $tag => $data) {
- $this->page = eregi_replace('{' . $tag . '}', $data, $this->page);
- }
- }
-
function output() {
- global $template;
+ global $template, $php_started, $lang;
// Small month builder
preg_match_all ('!(\{MONTH_SMALL\|[+|-][0-9]\})!is', $this->page, $match);
if (sizeof($match) > 0) {
+ $template_file = $this->parse('templates/'.$template.'/month_small.tpl');
foreach ($match[1] as $key => $val) {
- $template_file = 'templates/'.$template.'/month_small.tpl';
$offset = str_replace('}', '', $val);
$offset = str_replace('{MONTH_SMALL|', '', $offset);
- $data = draw_month($template_file, $offset, 'small');
+ $data = $this->draw_month($template_file, $offset, 'small');
$this->page = str_replace($val, $data, $this->page);
}
}
@@ -152,14 +159,21 @@ class Page {
// Small month builder
preg_match_all ('!(\{MONTH_LARGE\|[+|-][0-9]\})!is', $this->page, $match);
if (sizeof($match) > 0) {
+ $template_file = $this->parse('templates/'.$template.'/month_large.tpl');
foreach ($match[1] as $key => $val) {
- $template_file = 'templates/'.$template.'/month_large.tpl';
$offset = str_replace('}', '', $val);
$offset = str_replace('{MONTH_LARGE|', '', $offset);
- $data = draw_month($template_file, $offset, 'large');
+ $data = $this->draw_month($template_file, $offset, 'large');
$this->page = str_replace($val, $data, $this->page);
}
}
+ foreach ($lang as $tag => $data) {
+ $this->page = str_replace('{' . strtoupper($tag) . '}', $data, $this->page);
+ }
+
+ $php_ended = getmicrotime();
+ $generated = number_format(($php_ended-$php_started),3);
+ echo $generated;
print($this->page);
}
}
diff --git a/month.php b/month.php
index c3207b1..b87d662 100644
--- a/month.php
+++ b/month.php
@@ -44,9 +44,6 @@ $list_years = list_years();
$list_months = list_months();
$list_weeks = list_weeks();
-$php_ended = getmicrotime();
-$generated = number_format(($php_ended-$php_started),3);
-
$page = new Page(BASE.'templates/'.$template.'/month.tpl');
$page->replace_tags(array(
@@ -76,8 +73,6 @@ $page->replace_tags(array(
));
-$page->replace_langs($lang);
-
$page->output();
diff --git a/preferences.php b/preferences.php
index 402716e..6520331 100644
--- a/preferences.php
+++ b/preferences.php
@@ -156,8 +156,6 @@ $page->replace_tags(array(
));
-$page->replace_langs($lang);
-
$page->output();
?>
diff --git a/templates/default/header.tpl b/templates/default/header.tpl
index 7707874..9f680e1 100644
--- a/templates/default/header.tpl
+++ b/templates/default/header.tpl
@@ -9,7 +9,7 @@
<link rel="alternate" type="application/rss+xml" title="RSS" href="{DEFAULT_VIEW}/rss/rss.php?cal={CAL}&amp;rssview={CURRENT_VIEW}">
<!-- switch rss_available off -->
<!-- switch todo_available on -->
- {TODO_JS}
+ {TODO_JS}
<!-- switch todo_available off -->
</head>
<body> \ No newline at end of file
diff --git a/templates/default/month.tpl b/templates/default/month.tpl
index c33987d..dc24b50 100644
--- a/templates/default/month.tpl
+++ b/templates/default/month.tpl
@@ -55,7 +55,7 @@
<table width="100%" cellspacing="1" cellpadding="4" border="0">
<!-- loop showbottomevents_odd on -->
<tr align="left" valign="top">
- <td width="155" class="G10B" nowrap>
+ <td width="170" nowrap>
<a class="psf" href="{CAL}&amp;getdate={DAYLINK}">{START_DATE}</a> <font class="V9G">({START_TIME})</font>
</td>
<td>
@@ -65,7 +65,7 @@
<!-- loop showbottomevents_odd off -->
<!-- loop showbottomevents_even on -->
<tr align="left" valign="top">
- <td width="155" class="G10B" nowrap bgcolor="#EEEEEE">
+ <td width="170" nowrap bgcolor="#EEEEEE">
<a class="psf" href="{CAL}&amp;getdate={DAYLINK}">{START_DATE}</a> <font class="V9G">({START_TIME})</font>
</td>
<td bgcolor="#EEEEEE">
diff --git a/templates/default/month_large.tpl b/templates/default/month_large.tpl
index 0290a1d..7e63d0a 100644
--- a/templates/default/month_large.tpl
+++ b/templates/default/month_large.tpl
@@ -13,23 +13,14 @@
<!-- loop monthdays on -->
<!-- switch notthismonth on -->
<td valign="top" align="left" class="monthoff" width="105" height="105">
-
<div align="right">
<a class="psf" href="day.php?cal={CAL}&amp;getdate={DAYLINK}"><font class="G10G">{DAY}</font></a>
</div>
<!-- switch allday on -->
- <div align="left">
- <div align="center" class="V10">
- {JS_OPEN_EVENT} <a class="psf" href="#" onclick="openEventWindow({EVENT_NUMBER}); return false;">{EVENT_TITLE}</a>
- </div>
- </div>
+ {ALLDAY}
<!-- switch allday off -->
<!-- switch event on -->
- <div align="left">
- <div align="left" class="V9">
- &nbsp; {JS_OPEN_EVENT} <a class="ps3" href="#" onclick="openEventWindow({EVENT_NUMBER}); return false;">{EVENT_TIME} {EVENT_TITLE}</a>
- </div>
- </div>
+ {EVENT}
<!-- switch event off -->
</td>
@@ -40,18 +31,10 @@
<a class="psf" href="day.php?cal={CAL}&amp;getdate={DAYLINK}">{DAY}</a>
</div>
<!-- switch allday on -->
- <div align="left">
- <div align="center" class="V10">
- {JS_OPEN_EVENT} <a class="ps3" href="#" onclick="openEventWindow({EVENT_NUMBER}); return false;">{EVENT_TITLE}</a>
- </div>
- </div>
+ {ALLDAY}
<!-- switch allday off -->
<!-- switch event on -->
- <div align="left">
- <div align="left" class="V9">
- &nbsp; {JS_OPEN_EVENT} <a class="ps3" href="#" onclick="openEventWindow({EVENT_NUMBER}); return false;">{EVENT_TIME} {EVENT_TITLE}</a>
- </div>
- </div>
+ {EVENT}
<!-- switch event off -->
</td>
<!-- switch istoday off -->
@@ -61,18 +44,10 @@
<a class="psf" href="day.php?cal={CAL}&amp;getdate={DAYLINK}">{DAY}</a>
</div>
<!-- switch allday on -->
- <div align="left">
- <div align="left" class="V9">
- {JS_OPEN_EVENT} <a class="ps3" href="#" onclick="openEventWindow({EVENT_NUMBER}); return false;">{EVENT_TITLE}</a>
- </div>
- </div>
+ {ALLDAY}
<!-- switch allday off -->
<!-- switch event on -->
- <div align="left">
- <div align="left" class="V9">
- &nbsp; {JS_OPEN_EVENT} <a class="ps3" href="#" onclick="openEventWindow({EVENT_NUMBER}); return false;">{EVENT_TIME} {EVENT_TITLE}</a>
- </div>
- </div>
+ {EVENT}
<!-- switch event off -->
</td>
<!-- switch ismonth off -->

© 2014-2024 Faster IT GmbH | imprint | privacy policy