From: <jo...@us...> - 2003-11-23 01:31:33
|
Update of /cvsroot/phpicalendar/phpicalendar/functions In directory sc8-pr-cvs1:/tmp/cvs-serv4586 Modified Files: list_icals.php Log Message: Fixed problems with the list_icals logic. Previous cvs update merged files incorrectly. Index: list_icals.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/list_icals.php,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** list_icals.php 22 Nov 2003 21:16:10 -0000 1.20 --- list_icals.php 23 Nov 2003 01:31:30 -0000 1.21 *************** *** 1,26 **** <?php if ($display_ical_list == "yes") { - // start of <select> tag echo "<select name=\"action\" class=\"query_style\" onChange=\"window.location=(this.options[this.selectedIndex].value+'"; if (isset($query)) echo $query; echo "');\">"; ! // open file ! $dir_handle = @opendir($calendar_path) or die(error(sprintf($error_path_lang, $calendar_path), $cal_filename)); ! ! // Grab all calendars. ! $filelist = availableCalendarNames($username, $password, $ALL_CALENDARS_COMBINED); ! foreach ($filelist as $file) { ! ! // $cal_filename is the filename of the calendar without .ics ! // $cal is a urlencoded version of $cal_filename ! // $cal_displayname is $cal_filename with occurrences of "32" replaced with " " ! $cal_filename_tmp = substr($file,0,-4); ! $cal_tmp = urlencode($cal_filename_tmp); ! $cal_displayname_tmp = str_replace("32", " ", $cal_filename_tmp); ! if ($cal_tmp == $cal) { ! print "<option value=\"$current_view.php?cal=$cal_tmp\" selected>$cal_displayname_tmp $calendar_lang</option>\n"; } else { ! print "<option value=\"$current_view.php?cal=$cal_tmp\">$cal_displayname_tmp $calendar_lang</option>\n"; } } --- 1,50 ---- <?php if ($display_ical_list == "yes") { // start of <select> tag echo "<select name=\"action\" class=\"query_style\" onChange=\"window.location=(this.options[this.selectedIndex].value+'"; if (isset($query)) echo $query; echo "');\">"; ! ! // Get all calendars. ! $all_cals = availableCalendars($username, $password, $ALL_CALENDARS_COMBINED); ! foreach ($all_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 = basename($cal_tmp); ! $cal_displayname_tmp = str_replace("32", " ", $cal_displayname_tmp); ! $cal_displayname_tmp = substr($cal_displayname_tmp, 0, -4); ! ! // 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 = basename($cal_tmp); ! $cal_tmp = substr($cal_tmp, 0, -4); ! ! // 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. ! $cal_httpPrefix_tmp = str_replace('webcal://', 'http://', $cal_tmp); ! if ($cal_httpPrefix_tmp == urldecode($cal)) { ! print "<option value=\"$current_view.php?cal=$cal_encoded_tmp&getdate=$getdate\" selected>$cal_displayname_tmp</option>"; } else { ! print "<option value=\"$current_view.php?cal=$cal_encoded_tmp&getdate=$getdate\">$cal_displayname_tmp</option>"; } } *************** *** 32,53 **** print "<option value=\"$current_view.php?cal=$ALL_CALENDARS_COMBINED&getdate=$getdate\">$all_cal_comb_lang</option>"; } - - foreach($list_webcals as $cal_tmp) { - if ($cal_tmp != '') { - $cal_displayname_tmp = basename($cal_tmp); - $cal_displayname_tmp = str_replace("32", " ", $cal_displayname_tmp); - $cal_displayname_tmp = substr($cal_displayname_tmp,0,-4); - $cal_encoded_tmp = urlencode($cal_tmp); - if ($cal_tmp == $cal_httpPrefix || $cal_tmp == $cal_webcalPrefix) { - print "<option value=\"$current_view.php?cal=$cal_encoded_tmp&getdate=$getdate\" selected>$cal_displayname_tmp Webcal</option>"; - } else { - print "<option value=\"$current_view.php?cal=$cal_encoded_tmp&getdate=$getdate\">$cal_displayname_tmp Webcal</option>"; - } - } - } // finish <select> print "</select>"; - } ?> --- 56,62 ---- |