Title<\/key>\s*?(.+?)<\/string>/i", $contents, $matches); if ($num_matches > 0) return $matches[1]; } } // At this point, just pull the name off the file. return str_replace(".ics", '', basename($cal_path)); } // This function prints out the calendars available to the user, for // selection. Should be enclosed within a , which // is not printed out by this function. // // $cals = The calendars (entire path, e.g. from availableCalendars). function display_ical_list($cals, $pick=FALSE) { global $cal, $ALL_CALENDARS_COMBINED, $current_view, $getdate, $calendar_lang, $all_cal_comb_lang, $cal_filelist, $cal_displaynames; // Print each calendar option. $return = ''; foreach ($cals as $cal_tmp) { // Format the calendar path for display. // // Only display the calendar name, replace all instances of "32" with " ", // and remove the .ics suffix. $cal_displayname_tmp = getCalendarName($cal_tmp); $cal_displayname_tmp = str_replace("32", " ", $cal_displayname_tmp); #overwrite the display name if we already have a real name if (is_numeric(array_search($cal_tmp, $cal_filelist))){ $cal_displayname_tmp = $cal_displaynames[array_search($cal_tmp,$cal_filelist)]; }else{ # pull the name from the $cal_tmp file $cal_tmp = str_replace('webcal://','http://',$cal_tmp); $ifile = @fopen($cal_tmp, "r"); if ($ifile == FALSE) exit(error($lang['l_error_cantopen'], $cal_tmp)); while (!feof($ifile)) { $line = fgets($ifile, 1024); $line = trim($line); if (ereg ("([^:]+):(.*)", $line, $regs)){ $field = $regs[1]; $data = $regs[2]; $property = $field; $prop_pos = strpos($property,';'); if ($prop_pos !== false) $property = substr($property,0,$prop_pos); $property = strtoupper($property); if ($property == "X-WR-CALNAME"){ $cal_displayname_tmp = $data; break; } } #stop reading if we find an event or timezone before there's a name if ($line == "BEGIN:VTIMEZONE" ||$line == "BEGIN:VEVENT") break; } } // If this is a webcal, add 'Webcal' to the display name. if (preg_match("/^(https?|webcal):\/\//i", $cal_tmp)) { $cal_displayname_tmp .= " Webcal"; } // Otherwise, remove all the path information, since that should // not be used to identify local calendars. Also add the calendar // label to the display name. else { // Strip path and .ics suffix. $cal_tmp = getCalendarName($cal_tmp); // Add calendar label. $cal_displayname_tmp .= " $calendar_lang"; } // Encode the calendar path. $cal_encoded_tmp = urlencode($cal_tmp); // Display the option. // // The submitted calendar will be encoded, and always use http:// // if it is a webcal. So that is how we perform the comparison when // trying to figure out if this is the selected calendar. if($pick) { if (in_array($cal_encoded_tmp, explode(",", $cal)) || count($cals) == count(explode(",", $cal))) { $return .= "\n"; } else { $return .= "\n"; } } else { $cal_httpPrefix_tmp = str_replace('webcal://', 'http://', $cal_tmp); if ($cal_httpPrefix_tmp == urldecode($cal)) { $return .= ""; } else { $return .= ""; } } } // option to open all (non-web) calenders together if (!$pick) { if ($cal == $ALL_CALENDARS_COMBINED) { $return .= ""; } else { $return .= ""; } } return $return; }