From: <cl...@us...> - 2003-06-30 22:48:29
|
Update of /cvsroot/phpicalendar/phpicalendar/functions In directory sc8-pr-cvs1:/tmp/cvs-serv28341/functions Modified Files: ical_parser.php init.inc.php list_icals.php overlapping_events.php Log Message: Multiple Calendar support. Index: ical_parser.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/ical_parser.php,v retrieving revision 1.91 retrieving revision 1.92 diff -C2 -d -r1.91 -r1.92 *** ical_parser.php 30 May 2003 00:45:20 -0000 1.91 --- ical_parser.php 30 Jun 2003 22:48:25 -0000 1.92 *************** *** 52,776 **** if ($parse_file) { ! // patch to speed up parser ! ! $ifile = fopen($filename, "r"); ! if ($ifile == FALSE) exit(error($error_invalidcal_lang, $filename)); ! $nextline = fgets($ifile, 1024); ! if (trim($nextline) != 'BEGIN:VCALENDAR') exit(error($error_invalidcal_lang, $filename)); ! ! // Set a value so we can check to make sure $master_array contains valid data [...1885 lines suppressed...] + + //If you want to see the values in the arrays, uncomment below. ! /* ! print '<pre>'; ! print_r($master_array); ! print_r($overlap_array); //print_r($day_array); //print_r($rrule); //print_r($recurrence_delete); ! print '</pre>'; ! */ ! ! // Set a calender name for all calenders combined ! if ($cal == 'all_calenders_combined971') { ! $calendar_name = $all_cal_comb_lang; ! } ?> Index: init.inc.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/init.inc.php,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** init.inc.php 30 May 2003 00:45:20 -0000 1.32 --- init.inc.php 30 Jun 2003 22:48:25 -0000 1.33 *************** *** 63,72 **** } else { if (isset($default_cal_check)) { ! $calcheck = $calendar_path.'/'.$default_cal_check.'.ics'; ! $calcheckopen = @fopen($calcheck, "r"); ! if ($calcheckopen == FALSE) { ! $cal_filename = $default_cal; } else { ! $cal_filename = $default_cal_check; } } else { --- 63,76 ---- } else { if (isset($default_cal_check)) { ! if ($default_cal_check != 'all_calenders_combined971') { ! $calcheck = $calendar_path.'/'.$default_cal_check.'.ics'; ! $calcheckopen = @fopen($calcheck, "r"); ! if ($calcheckopen == FALSE) { ! $cal_filename = $default_cal; ! } else { ! $cal_filename = $default_cal_check; ! } } else { ! $cal_filename = 'all_calenders_combined971'; } } else { *************** *** 92,105 **** } else { if (!isset($filename)) { ! $filename = $calendar_path.'/'.$cal_filename.'.ics'; ! if (true == false) { $dir_handle = @opendir($calendar_path) or die(error(sprintf($error_path_lang, $calendar_path), $cal_filename)); ! while ($file = readdir($dir_handle)) { ! if (substr($file, -4) == '.ics') { ! $cal = urlencode(substr($file, 0, -4)); ! $filename = $calendar_path.'/'.$file; ! break; } } } } --- 96,128 ---- } else { if (!isset($filename)) { ! // empty the filelist array ! $cal_filelist = array(); ! if ($cal == 'all_calenders_combined971') { // Create an array with the paths to all files to be combined ! // Note: code here is similar to code in list_icals.php ! // open directory $dir_handle = @opendir($calendar_path) or die(error(sprintf($error_path_lang, $calendar_path), $cal_filename)); ! ! ! // build the array ! while (false != ($file = readdir($dir_handle))) { ! if (substr($file, -4) == ".ics") { ! $file = $calendar_path.'/'.$file; ! array_push($cal_filelist, $file); } } + natcasesort($cal_filelist); + } else { // Handle a single file + $filename = $calendar_path.'/'.$cal_filename.'.ics'; + if (true == false) { + $dir_handle = @opendir($calendar_path) or die(error(sprintf($error_path_lang, $calendar_path), $cal_filename)); + while ($file = readdir($dir_handle)) { + if (substr($file, -4) == '.ics') { + $cal = urlencode(substr($file, 0, -4)); + $filename = $calendar_path.'/'.$file; + break; + } + } + } + array_push($cal_filelist, $filename); } } Index: list_icals.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/list_icals.php,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** list_icals.php 10 Mar 2003 18:27:10 -0000 1.12 --- list_icals.php 30 Jun 2003 22:48:25 -0000 1.13 *************** *** 36,42 **** } else { print "<option value=\"$current_view.php?cal=$cal_tmp\">$cal_displayname_tmp $calendar_lang</option>\n"; ! } } } foreach($list_webcals as $cal_tmp) { if ($cal_tmp != '') { --- 36,50 ---- } else { print "<option value=\"$current_view.php?cal=$cal_tmp\">$cal_displayname_tmp $calendar_lang</option>\n"; ! } } } + + // option to open all (non-web) calenders together + if ($cal == 'all_calenders_combined971') { + print "<option value=\"$current_view.php?cal=all_calenders_combined971\" selected>$all_cal_comb_lang</option>\n"; + } else { + print "<option value=\"$current_view.php?cal=all_calenders_combined971\">$all_cal_comb_lang</option>\n"; + } + foreach($list_webcals as $cal_tmp) { if ($cal_tmp != '') { *************** *** 52,57 **** } } ! ! // close file closedir($dir_handle); --- 60,64 ---- } } ! // close file closedir($dir_handle); Index: overlapping_events.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/overlapping_events.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** overlapping_events.php 29 May 2003 18:28:00 -0000 1.11 --- overlapping_events.php 30 Jun 2003 22:48:26 -0000 1.12 *************** *** 161,165 **** // drei 20021126: function for checking and removing overlapping events ! function removeOverlap($ol_start_date, $ol_start_time, $ol_key = 0) { global $master_array, $overlap_array; if (isset($overlap_array[$ol_start_date])) { --- 161,166 ---- // drei 20021126: function for checking and removing overlapping events ! //function removeOverlap($ol_start_date, $ol_start_time, $ol_key = 0) { ! function removeOverlap($ol_start_date, $ol_start_time, $ol_key) { global $master_array, $overlap_array; if (isset($overlap_array[$ol_start_date])) { *************** *** 167,171 **** $ol_end_time = $master_array[$ol_start_date][$ol_start_time][$ol_key]["event_end"]; foreach ($overlap_array[$ol_start_date] as $keyBlock => $blockId) { ! if (($blockId["blockStart"] <= $ol_start_time) or ($blockId["blockEnd"] >= $ol_start_time)) { foreach ($blockId["events"] as $keyEvent => $ol_event) { $master_array[$ol_start_date][$ol_event["time"]][$ol_event["key"]]["event_overlap"] -= 1; --- 168,173 ---- $ol_end_time = $master_array[$ol_start_date][$ol_start_time][$ol_key]["event_end"]; foreach ($overlap_array[$ol_start_date] as $keyBlock => $blockId) { ! // if (($blockId["blockStart"] <= $ol_start_time) or ($blockId["blockEnd"] >= $ol_start_time)) { ! if (($blockId["blockStart"] <= $ol_start_time) and ($blockId["blockEnd"] > $ol_start_time)) { foreach ($blockId["events"] as $keyEvent => $ol_event) { $master_array[$ol_start_date][$ol_event["time"]][$ol_event["key"]]["event_overlap"] -= 1; *************** *** 174,181 **** } } ! if ($blockId["maxOverlaps"] = 1) { unset ($overlap_array[$ol_start_date][$keyBlock]); } else { ! $blockId["maxOverlaps"] -= 1; } } --- 176,185 ---- } } ! if ($blockId["maxOverlaps"] == 1) { unset ($overlap_array[$ol_start_date][$keyBlock]); } else { ! $overlap_array[$ol_start_date][$keyBlock]["maxOverlaps"] -= 1; ! //$blockId["maxOverlaps"] -= 1; ! // SJBO: Shouldn't something be done with [overlapRanges] as well? } } |