aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjwangen <jwangen>2002-10-22 09:04:50 +0000
committerjwangen <jwangen>2002-10-22 09:04:50 +0000
commit03d379ba9fc75b390cdc5395ab5ec477701bbacc (patch)
tree683bb2b60d75539028d32d512a6bb8505d8445c3
parent2023c16a35593c9397e8789bfde995fccfc47156 (diff)
downloadphpicalendar-03d379ba9fc75b390cdc5395ab5ec477701bbacc.tar.gz
phpicalendar-03d379ba9fc75b390cdc5395ab5ec477701bbacc.tar.bz2
phpicalendar-03d379ba9fc75b390cdc5395ab5ec477701bbacc.zip
Added search.php. Not done but close. Minor tweaks to the parser.
-rw-r--r--functions/ical_parser.php164
-rw-r--r--search.php141
2 files changed, 219 insertions, 86 deletions
diff --git a/functions/ical_parser.php b/functions/ical_parser.php
index a62f09d..d695c61 100644
--- a/functions/ical_parser.php
+++ b/functions/ical_parser.php
@@ -140,6 +140,12 @@ if ($parse_file) {
}
}
+ // Handling regular events
+ if ((isset($start_time) && $start_time != '') && (!isset($allday_start) || $allday_start == '')) {
+ $nbrOfOverlaps = checkOverlap($start_date, $start_time, $end_time);
+ $master_array[($start_date)][($hour.$minute)][] = array ('event_start' => $start_time, 'event_text' => $summary, 'event_end' => $end_time, 'event_length' => $length, 'event_overlap' => $nbrOfOverlaps, 'description' => $description);
+ }
+
// Handling of the recurring events, RRULE
// jared-2002.10.17, Commented this line out, replacing it with another. Not sure why the $allday_written var was
// implemented. This var in this "if" broke all recurring all-day event support (ie, only the first occurrence would show up)
@@ -165,74 +171,73 @@ if ($parse_file) {
}
//print_r($rrule_array);
foreach ($rrule_array as $key => $val) {
- if ($key == 'FREQ') {
- switch ($val) {
- case 'YEARLY': $freq_type = 'year'; break;
- case 'MONTHLY': $freq_type = 'month'; break;
- case 'WEEKLY': $freq_type = 'week'; break;
- case 'DAILY': $freq_type = 'day'; break;
- case 'HOURLY': $freq_type = 'hour'; break;
- case 'MINUTELY': $freq_type = 'minute'; break;
- case 'SECONDLY': $freq_type = 'second'; break;
- }
- } elseif ($key == 'COUNT') {
- $count = $val;
-
- } elseif ($key == 'UNTIL') {
- $until = ereg_replace('T', '', $val);
- $until = ereg_replace('Z', '', $val);
- ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})', $until, $regs);
- $year = $regs[1];
- $month = $regs[2];
- $day = $regs[3];
- $until = mktime(0,0,0,$month,$day,$year);
- $until = strtotime('-1 day', $until);
- } elseif ($key == 'INTERVAL') {
- $number = $val;
-
- } elseif ($key == 'BYSECOND') {
- $bysecond = $val;
- $bysecond = split (',', $bysecond);
-
- } elseif ($key == 'BYMINUTE') {
- $byminute = $val;
- $byminute = split (',', $byminute);
-
- } elseif ($key == 'BYHOUR') {
- $byhour = $val;
- $byhour = split (',', $byhour);
-
- } elseif ($key == 'BYDAY') {
- $byday = $val;
- $byday = split (',', $byday);
- #echo "<pre>";
- #print_r ($byday);
- #echo "</pre>";
-
- } elseif ($key == 'BYMONTHDAY') {
- $bymonthday = $val;
- $bymonthday = split (',', $bymonthday);
- //print_r ($bymonthday);
-
- } elseif ($key == 'BYYEARDAY') {
- $byyearday = $val;
- $byyearday = split (',', $byyearday);
-
- } elseif ($key == 'BYWEEKNO') {
- $byweekno = $val;
- $byweekno = split (',', $byweekno);
-
- } elseif ($key == 'BYMONTH') {
- $bymonth = $val;
- $bymonth = split (',', $bymonth);
-
- } elseif ($key == 'BYSETPOS') {
- $bysetpos = $val;
-
- } elseif ($key == 'WKST') {
- $wkst = $val;
-
- } elseif ($key == 'END') {
+ switch($key) {
+ case 'FREQ':
+ switch ($val) {
+ case 'YEARLY': $freq_type = 'year'; break;
+ case 'MONTHLY': $freq_type = 'month'; break;
+ case 'WEEKLY': $freq_type = 'week'; break;
+ case 'DAILY': $freq_type = 'day'; break;
+ case 'HOURLY': $freq_type = 'hour'; break;
+ case 'MINUTELY': $freq_type = 'minute'; break;
+ case 'SECONDLY': $freq_type = 'second'; break;
+ }
+ break;
+ case 'COUNT':
+ $count = $val;
+ break;
+ case 'UNTIL':
+ $until = ereg_replace('T', '', $val);
+ $until = ereg_replace('Z', '', $val);
+ ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})', $until, $regs);
+ $year = $regs[1];
+ $month = $regs[2];
+ $day = $regs[3];
+ $until = mktime(0,0,0,$month,$day,$year);
+ $until = strtotime('-1 day', $until);
+ break;
+ case 'INTERVAL':
+ $number = $val;
+ break;
+ case 'BYSECOND':
+ $bysecond = $val;
+ $bysecond = split (',', $bysecond);
+ break;
+ case 'BYMINUTE':
+ $byminute = $val;
+ $byminute = split (',', $byminute);
+ break;
+ case 'BYHOUR':
+ $byhour = $val;
+ $byhour = split (',', $byhour);
+ break;
+ case 'BYDAY':
+ $byday = $val;
+ $byday = split (',', $byday);
+ break;
+ case 'BYMONTHDAY':
+ $bymonthday = $val;
+ $bymonthday = split (',', $bymonthday);
+ break;
+ case 'BYYEARDAY':
+ $byyearday = $val;
+ $byyearday = split (',', $byyearday);
+ break;
+ case 'BYWEEKNO':
+ $byweekno = $val;
+ $byweekno = split (',', $byweekno);
+ break;
+ case 'BYMONTH':
+ $bymonth = $val;
+ $bymonth = split (',', $bymonth);
+ break;
+ case 'BYSETPOS':
+ $bysetpos = $val;
+ break;
+ case 'WKST':
+ $wkst = $val;
+ break;
+ case 'END':
// again, $parse_to_year is set to January 10 of the upcoming year
$parse_to_year_time = mktime(0,0,0,1,10,($this_year + 1));
@@ -276,7 +281,7 @@ if ($parse_file) {
case 'DAILY':
$next_date_time = $next_range_time;
$recur_data[] = $next_date_time;
- break;
+ break;
case 'WEEKLY':
if (is_array($byday)) {
// loop through the days on which this event happens
@@ -288,7 +293,7 @@ if ($parse_file) {
$recur_data[] = $next_date_time;
}
}
- break;
+ break;
case 'MONTHLY':
$next_range_time = strtotime(date('Y-m-01', $next_range_time));
// month has two cases, either $bymonthday or $byday
@@ -314,7 +319,7 @@ if ($parse_file) {
$recur_data[] = $next_date_time;
}
}
- break;
+ break;
case 'YEARLY':
if (!isset($bymonth)) $bymonth[] = date('m', $start_date_time);
foreach($bymonth as $month) {
@@ -334,7 +339,7 @@ if ($parse_file) {
}
$recur_data[] = $next_date_time;
}
- break;
+ break;
default:
// anything else we need to end the loop
$next_range_time = $end_range_time + 100;
@@ -362,9 +367,7 @@ if ($parse_file) {
$start_time2 = strtotime('+1 day', $start_time2);
}
} else {
-// check for overlapping events
$nbrOfOverlaps = checkOverlap($recur_data_date, $start_time, $end_time);
-// writes to $master array here
$master_array[($recur_data_date)][($hour.$minute)][] = array ('event_start' => $start_time, 'event_text' => $summary, 'event_end' => $end_time, 'event_length' => $length, 'event_overlap' => $nbrOfOverlaps, 'description' => $description);
}
}
@@ -377,19 +380,8 @@ if ($parse_file) {
}
}
- // Let's write all the data to the master array
- if ((isset($start_time) && $start_time != '') && (!isset($allday_start) || $allday_start == '')) {
-// check for overlapping events
- $nbrOfOverlaps = checkOverlap($start_date, $start_time, $end_time);
-
-// writes to $master array here
- $master_array[($start_date)][($hour.$minute)][] = array ('event_start' => $start_time, 'event_text' => $summary, 'event_end' => $end_time, 'event_length' => $length, 'event_overlap' => $nbrOfOverlaps, 'description' => $description);
- }
-
+
-
-
-
} elseif (stristr($line, "BEGIN:VALARM")) {
$valarm_set = TRUE;
} elseif (stristr($line, "END:VALARM")) {
diff --git a/search.php b/search.php
new file mode 100644
index 0000000..24ade80
--- /dev/null
+++ b/search.php
@@ -0,0 +1,141 @@
+<?php
+
+include('./functions/ical_parser.php');
+
+$search_string = 'final';
+$search_arr = explode(' ', $search_string);
+
+function array_in($string,$arr) {
+ foreach($arr as $s) {
+ if (eregi($s,$string) == false) {
+ return false;
+ }
+ }
+ return true;
+}
+function search($find_arr) {
+ global $master_array;
+ if (isset($master_array) && is_array($master_array)) {
+ foreach($master_array as $date_key => $date) {
+ if (is_array($date)) {
+ foreach($date as $time_key => $time) {
+ if (is_array($time)) {
+ foreach ($time as $event_key => $event) {
+ if (is_array($event)) {
+ if (array_in($event['description'],$find_arr) || array_in($event['event_text'],$find_arr)) {
+ $tmp_arr = $event;
+ $tmp_arr['date'] = $date_key;
+ $retarr[] = $tmp_arr;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return $retarr;
+}
+
+$the_arr = search($search_arr);
+
+?>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8">
+ <title><?php echo "$calendar_name - $display_month"; ?></title>
+ <link rel="stylesheet" type="text/css" href="styles/<?php echo "$style_sheet/default.css"; ?>">
+ <?php include "functions/event.js"; ?>
+</head>
+<body>
+<center>
+<table border="0" width="737" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" class="calborder">
+ <tr>
+ <td align="left" valign="top" width="1%" class="sideback"><?php echo "<a class=\"psf\" href=\"month.php?cal=$cal&getdate=$prev_day\"><img src=\"styles/$style_sheet/left_arrows.gif\" alt=\"right\" border=\"0\" align=\"left\"></a>"; ?></td>
+ <td align="center" class="sideback"><font class="G10B"><b><?php print (localizeDate ($dateFormat_day, strtotime($getdate))); ?></b></font></td>
+ <td align="right" valign="top" width="1%" class="sideback"><?php echo "<a class=\"psf\" href=\"month.php?cal=$cal&getdate=$next_day\"><img src=\"styles/$style_sheet/right_arrows.gif\" alt=\"right\" border=\"0\" align=\"right\"></a>"; ?></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img src="images/spacer.gif" width="1" height="5"></td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <table border="0" cellspacing="0" cellpadding="0" width="100%">
+ <tr>
+ <td align="center" valign="top">
+ <table width="100%" border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td align="left" valign="top" width="160" class="montheventtop"><?php echo "<img src=\"images/spacer.gif\" alt=\"right\" width=\"16\" height=\"20\" border=\"0\" align=\"left\"></a>"; ?></td>
+ <td align="center" class="montheventtop" width="417" nowrap><font class="G10BOLD"><?php echo "Search Results"; ?></font></td>
+ <td align="right" valign="top" width="160" class="montheventtop"><?php echo "<img src=\"images/spacer.gif\" alt=\"right\" width=\"16\" height=\"20\" border=\"0\" align=\"right\"></a>"; ?></td>
+ </tr>
+ <tr>
+ <td colspan="3" height="1"></td>
+ </tr>
+ <?php
+ // Iterate the search results
+ if (is_array($the_arr)) {
+ foreach($the_arr as $val) {
+ $dayofmonth = strtotime ($val['date']);
+ $dayofmonth = localizeDate ($dateFormat_week_list, $dayofmonth);
+ $i = 0;
+ if ($getdate == $val['date']) {
+ $fontclass="class=\"G10BOLD\"";
+ } else {
+ $fontclass="class=\"G10B\"";
+ }
+ if ($val["event_text"]) {
+ $event_text = stripslashes(urldecode($val["event_text"]));
+ $event_text2 = addslashes($val["event_text"]);
+ $event_text2 = str_replace("\"", "&quot;", $event_text2);
+ $event_text2 = urlencode($event_text2);
+ $description = addslashes($val["description"]);
+ $description = str_replace("\"", "&quot;", $description);
+ $event_start = $val["event_start"];
+ $event_end = $val["event_end"];
+ $event_start = date ($timeFormat, strtotime ("$event_start"));
+ $event_end = date ($timeFormat, strtotime ("$event_end"));
+ $event_text = str_replace ("<br>", "", $event_text);
+ $event_start2 = $event_start;
+ if (strlen($event_text) > 70) {
+ $event_text = substr("$event_text", 0, 65);
+ $event_text = $event_text . "...";
+ }
+ if (!$val["event_start"]) {
+ $event_start = "$all_day_lang";
+ $event_start2 = '';
+ $event_end = '';
+ }
+ echo "<tr>\n";
+ echo "<td width =\"160\" class=\"montheventline\" nowrap><font $fontclass>&nbsp;<a class=\"psf\" href=\"day.php?cal=$cal&getdate=$key\">$dayofmonth</a></font> <font class=\"V9G\">($event_start)</font></td>\n";
+ echo "<td colspan=\"2\">\n";
+ echo "&nbsp;<a class=\"psf\" href=\"javascript:openEventInfo('$event_text2', '$calendar_name', '$event_start2', '$event_end', '$description')\"><font class=\"G10B\">$event_text</font></a>\n";
+ echo "</td>\n";
+ echo "</tr>\n";
+ }
+ }
+ } else {
+ echo "<tr>\n";
+ echo "<td colspan=\"3\" align=\"center\">No results found</td>\n";
+ echo "</tr>\n";
+ }
+
+ ?>
+ </table>
+ </td>
+ </tr>
+ </table>
+
+
+ </td>
+ </tr>
+</table>
+
+<br>
+<?php echo '<font class="V9"><br>'.$powered_by_lang.' <a class="psf" href="http://phpicalendar.sourceforge.net/">PHP iCalendar '.$version_lang.'</a></font>'; ?>
+</center>
+</body>
+</html>

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