home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / calendar-2010-08-23.tar.gz / calendar-2010-08-23.tar / calendar / functions / list_icals.php < prev    next >
PHP Script  |  2003-10-12  |  2KB  |  71 lines

  1. <?php
  2. if ($display_ical_list == "yes") {
  3.  
  4.     // start of <select> tag
  5.     if (isset($getdate)) {
  6.         $query="&getdate=$getdate";
  7.     } else {
  8.         $query="";
  9.     }    
  10.     // open file
  11.     $dir_handle = @opendir($calendar_path) or die(error(sprintf($error_path_lang, $calendar_path), $cal_filename));
  12.     
  13.     // empty the filelist array
  14.     $filelist = array();
  15.  
  16.     // build the <option> tags
  17.     while (false != ($file = readdir($dir_handle))) {
  18.         if (preg_match("/^[^.].+\.ics$/", $file)) {
  19.             array_push($filelist, $file);
  20.         }
  21.     }
  22.     natcasesort($filelist);
  23.     foreach ($filelist as $file) {
  24.         
  25.         // $cal_filename is the filename of the calendar without .ics
  26.         // $cal is a urlencoded version of $cal_filename
  27.         // $cal_displayname is $cal_filename with occurrences of "32" replaced with " "
  28.         $cal_filename_tmp = substr($file,0,-4);
  29.         $cal_tmp = urlencode($cal_filename_tmp);
  30.         $cal_displayname_tmp = str_replace("32", " ", $cal_filename_tmp);
  31.         if (!in_array($cal_filename_tmp, $blacklisted_cals)) {
  32.             if ($cal_tmp == $cal) {
  33.                 print "<option value=\"$current_view.php?cal=$cal_tmp&getdate=$getdate\" selected>$cal_displayname_tmp $calendar_lang</option>";
  34.             } else {
  35.                 print "<option value=\"$current_view.php?cal=$cal_tmp&getdate=$getdate\">$cal_displayname_tmp $calendar_lang</option>";    
  36.             }
  37.         }    
  38.     }            
  39.  
  40.     // option to open all (non-web) calenders together
  41.     if ($cal == $ALL_CALENDARS_COMBINED) {
  42.         print "<option value=\"$current_view.php?cal=$ALL_CALENDARS_COMBINED&getdate=$getdate\" selected>$all_cal_comb_lang</option>";
  43.     } else {
  44.         print "<option value=\"$current_view.php?cal=$ALL_CALENDARS_COMBINED&getdate=$getdate\">$all_cal_comb_lang</option>";
  45.     }
  46.         
  47.     foreach($list_webcals as $cal_tmp) {
  48.         if ($cal_tmp != '') {
  49.             $cal_displayname_tmp = basename($cal_tmp);
  50.             $cal_displayname_tmp = str_replace("32", " ", $cal_displayname_tmp);
  51.             $cal_displayname_tmp = substr($cal_displayname_tmp,0,-4);
  52.             $cal_encoded_tmp = urlencode($cal_tmp);
  53.             if ($cal_tmp == $cal_httpPrefix || $cal_tmp == $cal_webcalPrefix) {
  54.                 print "<option value=\"$current_view.php?cal=$cal_encoded_tmp&getdate=$getdate\" selected>$cal_displayname_tmp Webcal</option>";
  55.             } else {
  56.                 print "<option value=\"$current_view.php?cal=$cal_encoded_tmp&getdate=$getdate\">$cal_displayname_tmp Webcal</option>";    
  57.             }        
  58.         }
  59.     }
  60.  
  61.     // close file
  62.     closedir($dir_handle);
  63.     
  64.     // finish <select>
  65.     print "</select>";
  66.     
  67. }
  68.  
  69.  
  70. ?>    
  71.