From: <par...@us...> - 2010-04-15 18:39:34
|
Update of /cvsroot/phpicalendar/phpicalendar/functions In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv19694/functions Modified Files: calendar_functions.php Log Message: Additional performance improvement: Don't re-parse ICS files to get the calendar name Index: calendar_functions.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/calendar_functions.php,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** calendar_functions.php 7 Jul 2009 14:48:29 -0000 1.39 --- calendar_functions.php 15 Apr 2010 18:39:26 -0000 1.40 *************** *** 86,90 **** // we have to append '.ics' to the passed in calendar names. foreach ($cal_filename_local as $filename) { ! array_push($files, "$search_path/$filename".".ics"); } } --- 86,90 ---- // we have to append '.ics' to the passed in calendar names. foreach ($cal_filename_local as $filename) { ! array_push($files, "$search_path/$filename.ics"); } } *************** *** 176,180 **** // At this point, just pull the name off the file. ! return str_replace(".ics", '', basename($cal_path)); } --- 176,186 ---- // At this point, just pull the name off the file. ! $name = str_replace(".ics", '', basename($cal_path)); ! if ((substr($cal_path, 0, 7) == 'http://') || ! (substr($cal_path, 0, 8) == 'https://') || ! (substr($cal_path, 0, 9) == 'webcal://')) { ! $name = urldecode($name); ! } ! return $name; } *************** *** 185,189 **** // $cals = The calendars (entire path, e.g. from availableCalendars). function display_ical_list($cals, $pick=FALSE) { ! global $cal, $current_view, $getdate, $lang, $calendar_lang, $all_cal_comb_lang, $cal_filelist, $cal_displaynames, $list_webcals, $phpiCal_config; // Print each calendar option. $return = ''; --- 191,195 ---- // $cals = The calendars (entire path, e.g. from availableCalendars). function display_ical_list($cals, $pick=FALSE) { ! global $cal, $current_view, $getdate, $lang, $calendar_lang, $all_cal_comb_lang, $cal_filelist, $cal_displaynames, $list_webcals, $phpiCal_config, $master_array; // Print each calendar option. $return = ''; *************** *** 195,210 **** // 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_tmp2 = str_replace('webcal://','http://',$cal_tmp); ! ! $ifile = @fopen($cal_tmp2, "r"); if ($ifile == FALSE) exit(error($lang['l_error_cantopen'], $cal_tmp)); while (!feof($ifile)) { --- 201,226 ---- // Format the calendar path for display. // ! $cal_displayname_tmp = ''; ! $search_idx = array_search($cal_tmp, $cal_filelist); ! if (is_numeric($search_idx)) { ! $cal_displayname_tmp = $cal_displaynames[$search_idx]; ! } ! else if ((substr($cal_tmp, 0, 7) == 'http://') || ! (substr($cal_tmp, 0, 8) == 'https://') || ! (substr($cal_tmp, 0, 9) == 'webcal://')) { ! $cal_tmp2 = str_replace('webcal://', 'http://', $cal_tmp); ! $cal_tmp2 = str_replace('https://', 'http://', $cal_tmp2); ! $num = 1; ! foreach ($master_array[-4] as $master_cal) { ! if ($master_cal['filename'] == $cal_tmp2) { ! $cal_displayname_tmp = $master_array[-3][$num]; ! break; ! } ! $num++; ! } ! } ! else { # pull the name from the $cal_tmp file ! $ifile = @fopen($cal_tmp, 'r'); if ($ifile == FALSE) exit(error($lang['l_error_cantopen'], $cal_tmp)); while (!feof($ifile)) { *************** *** 226,230 **** if ($line == "BEGIN:VTIMEZONE" ||$line == "BEGIN:VEVENT") break; } ! } --- 242,252 ---- if ($line == "BEGIN:VTIMEZONE" ||$line == "BEGIN:VEVENT") break; } ! @fclose($ifile); ! } ! if (empty($cal_displayname_tmp)) { ! // 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); } |