diff options
author | fenner <fenner> | 2002-12-02 01:15:39 +0000 |
---|---|---|
committer | fenner <fenner> | 2002-12-02 01:15:39 +0000 |
commit | 477d20ee0494bcc59dcdbe53aa8ddf668fa8f9eb (patch) | |
tree | 723d1c23e899698da170bde06d69b9ea9215418d | |
parent | 38d5fc1d0fe541e85a6f0e1a94ee6ac71692e08a (diff) | |
download | phpicalendar-477d20ee0494bcc59dcdbe53aa8ddf668fa8f9eb.tar.gz phpicalendar-477d20ee0494bcc59dcdbe53aa8ddf668fa8f9eb.tar.bz2 phpicalendar-477d20ee0494bcc59dcdbe53aa8ddf668fa8f9eb.zip |
Sort the ical choices.
-rw-r--r-- | functions/list_icals.php | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/functions/list_icals.php b/functions/list_icals.php index 3dbf3d6..f06edb3 100644 --- a/functions/list_icals.php +++ b/functions/list_icals.php @@ -12,24 +12,31 @@ if ($display_ical_list == "yes") { // open file $dir_handle = @opendir($calendar_path) or die(error(sprintf($error_path_lang, $calendar_path), $cal_filename)); + // empty the filelist array + $filelist = array(); + // build the <option> tags - while ($file = readdir($dir_handle)) { + while (false != ($file = readdir($dir_handle))) { if (substr($file, -4) == ".ics") { - - // $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 (!in_array($cal_filename_tmp, $blacklisted_cals)) { - 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"; - } - } + array_push($filelist, $file); } + } + natcasesort($filelist); + 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 (!in_array($cal_filename_tmp, $blacklisted_cals)) { + 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"; + } + } } foreach($list_webcals as $cal_tmp) { if ($cal_tmp != '') { @@ -53,4 +60,4 @@ if ($display_ical_list == "yes") { print "</select>\n</form>"; } -?>
\ No newline at end of file +?> |