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 / day.php < prev    next >
PHP Script  |  2003-10-12  |  13KB  |  313 lines

  1. <?php
  2. if (isset($HTTP_GET_VARS['jumpto_day'])) {
  3.     $jumpto_day_time = strtotime($HTTP_GET_VARS['jumpto_day']);
  4.     if ($jumpto_day_time == -1) {
  5.         $getdate = date('Ymd', strtotime("now + $second_offset seconds"));
  6.     } else {
  7.         $getdate = date('Ymd', $jumpto_day_time);
  8.     }
  9. }
  10. define('BASE', './');
  11. $current_view = 'day';
  12. include(BASE.'functions/ical_parser.php');
  13. if ($minical_view == 'current') $minical_view = 'day';
  14.  
  15. $starttime = '0500';
  16. $weekstart = 1;
  17. $unix_time = strtotime($getdate);
  18. $today_today = date('Ymd', strtotime("now + $second_offset seconds")); 
  19. $tomorrows_date = date( 'Ymd', strtotime('+1 day',  $unix_time));
  20. $yesterdays_date = date( 'Ymd', strtotime('-1 day',  $unix_time));
  21. $display_date = localizeDate($dateFormat_day, $unix_time);
  22.  
  23. // For the side months
  24. ereg ('([0-9]{4})([0-9]{2})([0-9]{2})', $getdate, $day_array2);
  25. $this_day = $day_array2[3]; 
  26. $this_month = $day_array2[2];
  27. $this_year = $day_array2[1];
  28.  
  29. $parse_month = date ('Ym', $unix_time);
  30. $thisday2 = localizeDate($dateFormat_week_list, $unix_time);
  31. $start_week_time = strtotime(dateOfWeek($getdate, $week_start_day));
  32.  
  33. $dayborder = 0;
  34.  
  35. $nbrGridCols = 1;
  36. if (isset($master_array[($getdate)])) {
  37.     foreach($master_array[($getdate)] as $ovlKey => $ovlValue) {
  38.         if ($ovlKey != '-1') {
  39.             foreach($ovlValue as $ovl2Value) {
  40.                 $nbrGridCols = kgv($nbrGridCols, ($ovl2Value['event_overlap'] + 1));
  41.             }
  42.         }
  43.     } 
  44. }
  45. include (BASE.'includes/header.inc.php'); 
  46.  
  47. ?>
  48. <center>
  49. <table border="0" width="700" cellspacing="0" cellpadding="0">
  50.     <tr>
  51.         <td width="520" valign="top">
  52. <table width="520" border="0" cellspacing="0" cellpadding="0" class="calborder">
  53.     <tr>
  54.          <td align="center" valign="middle">
  55.               <table width="100%" border="0" cellspacing="0" cellpadding="0">
  56.                   <tr>
  57.                       <td align="left" width="120" class="navback"> </td>
  58.                       <td class="navback">
  59.                           <table width="100%" border="0" cellspacing="0" cellpadding="0">
  60.                               <tr>
  61.                                 <td align="right" width="40%" class="navback"><?php echo '<a class="psf" href="day.php?cal='.$cal.'&getdate='.$yesterdays_date.'"><img src="styles/'.$style_sheet.'/left_day.gif" alt="['.$last_day_lang.']" border="0" align="right"></a>'; ?></td>
  62.                                 <td align="center" width="20%" class="navback" nowrap valign="middle"><font class="H20"><?php echo $display_date; ?></font></td>
  63.                                   <td align="left" width="40%" class="navback"><?php echo '<a class="psf" href="day.php?cal='.$cal.'&getdate='.$tomorrows_date.'"><img src="styles/'.$style_sheet.'/right_day.gif" alt="['.$next_day_lang.']" border="0" align="left"></a>'; ?></td>
  64.                               </tr>
  65.                           </table>
  66.                       </td>
  67.                       <td align="right" width="120" class="navback">    
  68.                           <table width="120" border="0" cellpadding="0" cellspacing="0">
  69.                             <tr>
  70.                                 <td><?php echo '<a class="psf" href="day.php?cal='.$cal.'&getdate='.$getdate.'"><img src="styles/'.$style_sheet.'/day_on.gif" alt="'.$day_view_lang.'" border="0"></a></td>'; ?>
  71.                                 <td><?php echo '<a class="psf" href="week.php?cal='.$cal.'&getdate='.$getdate.'"><img src="styles/'.$style_sheet.'/week_on.gif" alt="'.$week_view_lang.'" border="0"></a></td>'; ?>
  72.                                 <td><?php echo '<a class="psf" href="month.php?cal='.$cal.'&getdate='.$getdate.'"><img src="styles/'.$style_sheet.'/month_on.gif" alt="'.$month_view_lang.'" border="0"></a></td>'; ?>
  73.                                 <td><?php echo '<a class="psf" href="year.php?cal='.$cal.'&getdate='.$getdate.'"><img src="styles/'.$style_sheet.'/year_on.gif" alt="'.$year_view_lang.'" border="0"></a></td>'; ?>
  74.                             </tr>
  75.                         </table>
  76.                     </td>
  77.                   </tr>
  78.               </table>
  79.           </td>
  80.     </tr>
  81.     <tr>
  82.         <td>
  83.               <table width="100%" border="0" cellspacing="0" cellpadding="0" class="G10B">    
  84.                 <?php
  85.                     // The all day events returned here.
  86.                     if (isset($master_array[($getdate)]['-1'])) {
  87.                        echo "<tr>\n";
  88.                        echo '<td colspan="3" height="24">'."\n";
  89.                        echo '<table width="100%" border="0" cellspacing="1" cellpadding="4">'."\n";
  90.                        foreach($master_array[($getdate)]['-1'] as $allday) {
  91.                          echo "<tr>\n";
  92.                          $event_calno  = $allday['calnumber'];
  93.                          if ($event_calno < 1) $event_calno=1;
  94.                          if ($event_calno > 7) $event_calno=7;
  95.                          echo '<td valign="top" align="center" class="eventbg_'.$event_calno.'">';
  96.                          openevent("$calendar_name",
  97.                                "",
  98.                                "",
  99.                                $allday,
  100.                                0,
  101.                                "",
  102.                                '<font color="#ffffff"><i>',
  103.                                "</i></font>",
  104.                                "psf");
  105.                          echo "</td>\n</tr>\n";
  106.                        }
  107.                        echo '</table>'."\n";
  108.                        echo '</td>'."\n";
  109.                        echo '</tr>'."\n";
  110.                     }
  111.                     if ($daysofweek_dayview == 'yes') {
  112.                 ?>
  113.  
  114.         <tr>    
  115.             <td>
  116.                   <table width="100%" border="0" cellspacing="0" cellpadding="0">
  117.                   <?php
  118.                       echo '<tr><td colspan="7"><img src="images/spacer.gif" width="70" height="1" alt=" "></td></tr>';
  119.                     echo "<tr>";
  120.                     $thisdate = $start_week_time;
  121.                     $start_day = strtotime($week_start_day);
  122.                     $i = 0;
  123.                     do {
  124.                         $day_num = date("w", $start_day);
  125.                         $day = $daysofweek_lang[$day_num];
  126.                         $thisday = date("Ymd", $thisdate);
  127.                         echo "<td width=\"74\" valign=\"top\" align=\"center\" class=\"dateback\">\n";
  128.                         echo "<font class=\"V9\"><a class=\"psf\" href=\"day.php?cal=$cal&getdate=$thisday\">$day</a></font>\n";
  129.                         echo "</td>\n";
  130.                         $start_day = strtotime("+1 day", $start_day);
  131.                         $thisdate = strtotime("+1 day", $thisdate);
  132.                         $i++;
  133.                     } while ($i < 7);
  134.                     echo '</tr>';            
  135.                       echo '</table>';
  136.                       echo '</td>';
  137.                       echo '</tr>';
  138.                       }
  139.                       ?>
  140.                   
  141.                   <tr>
  142.                     <td align="center" valign="top" colspan="3">
  143.                         <table width="100%" border="0" cellspacing="0" cellpadding="0">
  144.                             <tr>
  145.                                 <td width="60"><img src="images/spacer.gif" width="60" height="1" alt=" "></td>
  146.                                 <td width="1"></td>
  147.                                 <?php for ($m=0;$m < $nbrGridCols;$m++) { 
  148.                                     echo '<td><img src="images/spacer.gif" width="' . (520 / $nbrGridCols) . '" height="1" alt=" "></td>';
  149.                                 } ?>
  150.                             </tr>
  151.                             <?php
  152.                                 // $master_array[($getdate)][$day_time]
  153.                                 $event_length = array ();
  154.                                 $border = 0;
  155.                                 foreach ($day_array as $key) {
  156.                                     ereg('([0-9]{2})([0-9]{2})', $key, $regs_tmp);
  157.                                     $cal_time = $key;
  158.                                     $key = mktime($regs_tmp[1],$regs_tmp[2],0,$this_month,$this_day,$this_year);
  159.                                     $key = date ($timeFormat, $key);
  160.                                     unset($this_time_arr);
  161.                                     
  162.                                     // add events that overlap the start time
  163.                                     if (isset($master_array[$getdate][$cal_time]) && sizeof($master_array[$getdate][$cal_time]) > 0) {
  164.                                         $this_time_arr = $master_array[$getdate][$cal_time];
  165.                                     }
  166.                                     
  167.                                     // add events that overlap $day_start instead of cutting them out completely
  168.                                     if ("$day_start" == "$cal_time" && isset($master_array[$getdate])) {
  169.                                         foreach($master_array[$getdate] as $time_key => $time_arr) {
  170.                                             if ((int)$time_key < (int)$cal_time && is_array($time_arr) && $time_key != '-1') {
  171.                                                 foreach($time_arr as $event_tmp) {
  172.                                                     if ((int)$event_tmp['event_end'] > (int)$cal_time) {
  173.                                                         $this_time_arr[] = $event_tmp;
  174.                                                     }
  175.                                                 }
  176.                                             } else {
  177.                                                 break;
  178.                                             }
  179.                                         }
  180.                                     }                                                                        
  181.                                     
  182.                                     // check for eventstart 
  183.                                     if (isset($this_time_arr) && sizeof($this_time_arr) > 0) {
  184.                                         foreach ($this_time_arr as $eventKey => $loopevent) {
  185.                                             $drawEvent = drawEventTimes ($cal_time, $loopevent['event_end']);
  186.                                             $j = 0;
  187.                                             while (isset($event_length[$j])) {
  188.                                                 if ($event_length[$j]['state'] == 'ended') {
  189.                                                     $event_length[$j] = array ('length' => ($drawEvent['draw_length'] / $gridLength), 'key' => $eventKey, 'overlap' => $loopevent['event_overlap'],'state' => 'begin');
  190.                                                     break;
  191.                                                 }
  192.                                                 $j++;
  193.                                             }
  194.                                             if ($j == sizeof($event_length)) {
  195.                                                 array_push ($event_length, array ('length' => ($drawEvent['draw_length'] / $gridLength), 'key' => $eventKey, 'overlap' => $loopevent['event_overlap'],'state' => 'begin'));
  196.                                             }
  197.                                         }
  198.                                     }
  199.                                     if (ereg('([0-9]{1,2}):00', $key)) {
  200.                                         echo '<tr>'."\n";
  201.                                         echo '<td rowspan="' . (60 / $gridLength) . '" align="center" valign="top" width="60" class="timeborder">'.$key.'</td>'."\n";
  202.                                         echo '<td width="1" height="' . $gridLength . '"></td>'."\n";
  203.                                     } elseif("$cal_time" == "$day_start") {
  204.                                         $size_tmp = 60 - (int)substr($cal_time,2,2);
  205.                                         echo "<tr>\n";
  206.                                         echo "<td rowspan=\"" . ($size_tmp / $gridLength) . "\" align=\"center\" valign=\"top\" width=\"60\" class=\"timeborder\">$key</td>\n";
  207.                                         echo "<td width=\"1\" height=\"" . $gridLength . "\"></td>\n";
  208.                                     } else {
  209.                                         echo '<tr>'."\n";
  210.                                         echo '<td width="1" height="' . $gridLength . '"></td>'."\n";
  211.                                     }
  212.                                     if ($dayborder == 0) {
  213.                                         $class = ' class="dayborder"';
  214.                                         $dayborder++;
  215.                                     } else {
  216.                                         $class = ' class="dayborder2"';
  217.                                         $dayborder = 0;
  218.                                     }
  219.                                     if (sizeof($event_length) == 0) {
  220.                                         echo '<td bgcolor="#ffffff" colspan="' . $nbrGridCols . '" '.$class.'> </td>'."\n";
  221.                                         
  222.                                     } else {
  223.                                         $emptyWidth = $nbrGridCols;
  224.                                         for ($i=0;$i<sizeof($event_length);$i++) {
  225.                                             $drawWidth = $nbrGridCols / ($event_length[$i]['overlap'] + 1);
  226.                                             $emptyWidth = $emptyWidth - $drawWidth;
  227.                                             switch ($event_length[$i]['state']) {
  228.                                                 case 'begin':
  229.                                                   $event_length[$i]['state'] = 'started';
  230.                                                   $event_start     = strtotime ($this_time_arr[($event_length[$i]['key'])]['event_start']);
  231.                                                   $event_end    = strtotime ($this_time_arr[($event_length[$i]['key'])]['event_end']);
  232.                                                   $event_start     = date ($timeFormat, $event_start);
  233.                                                   $event_end    = date ($timeFormat, $event_end);
  234.                                                   $event_calno  = $this_time_arr[($event_length[$i]['key'])]['calnumber'];
  235.                                                   $event_status = strtolower($this_time_arr[($event_length[$i]['key'])]['status']);
  236.                                                   if ($event_calno < 1) $event_calno = 1;
  237.                                                   if ($event_calno > 7) $event_calno = 7;
  238.                                 
  239.                                                   echo '<td rowspan="' . $event_length[$i]['length'] . '" colspan="' . $drawWidth . '" align="left" valign="top" class="eventbg2_'.$event_calno.'">'."\n";
  240.                                                   echo '<table width="100%" border="0" cellspacing="0" cellpadding="2">'."\n";
  241.                                                   echo '<tr>'."\n";
  242.                                                   echo '<td class="eventborder"><font class="eventfont"><b>'.$event_start.'</b> - '.$event_end.'</font></td>'."\n";
  243.                                                   if ($event_status != '') {
  244.                                                       echo '<td class="eventborder" width="9" align="right" valign="center"><font class="eventfont">';
  245.                                                       echo '<img src="images/'.$event_status.'.gif" width="9" height="9" alt="" border="0" hspace="0" vspace="0">';
  246.                                                       echo '</font></td>'."\n";
  247.                                                   }
  248.                                                   echo '</tr>'."\n";
  249.                                                   echo '<tr>'."\n";
  250.                                                   echo '<td colspan="2">'."\n";
  251.                                                   echo '<table width="100%" border="0" cellpadding="1" cellspacing="0">'."\n";
  252.                                                   echo '<tr>'."\n";
  253.                                                   echo '<td class="eventbg_'.$event_calno.'">';
  254.                                                   // Todo: keep track of where the event comes from, and indicate that to openevent instead of $ALL_CALENDARS_COMBINED
  255.                                                   if ($cal == $ALL_CALENDARS_COMBINED) $calendar_name2=$cal; else $calendar_name2=$calendar_name;
  256.                                                     openevent("$calendar_name2",
  257.                                                   "$event_start",
  258.                                                   "$event_end",
  259.                                                   $this_time_arr[($event_length[$i]['key'])],
  260.                                                   "",
  261.                                                   0,
  262.                                                   "<font class=\"eventfont\">",
  263.                                                   "</font>",
  264.                                                   "psf");
  265.                                                   echo '</td></tr>'."\n";
  266.                                                   echo '</table>'."\n";
  267.                                                   echo '</td>'."\n";           
  268.                                                   echo '</tr>'."\n";
  269.                                                   echo '</table>'."\n";
  270.                                                   echo '</td>'."\n";
  271.                                                   break;
  272.                                                 case 'started':
  273.                                                     break;
  274.                                                 case 'ended':
  275.                                                     echo '<td bgcolor="#ffffff" colspan="' . $drawWidth . '" ' . $class . '> </td>'."\n";
  276.                                                     break;
  277.                                             }
  278.                                             $event_length[$i]['length']--;
  279.                                             if ($event_length[$i]['length'] == 0) {
  280.                                                 $event_length[$i]['state'] = 'ended';
  281.                                             }
  282.                                         }
  283.                                         //fill emtpy space on the right
  284.                                         if ($emptyWidth > 0) {
  285.                                             echo '<td bgcolor="#ffffff" colspan="' . $emptyWidth . '" ' . $class . '> </td>'."\n";
  286.                                         }
  287.                                         while (isset($event_length[(sizeof($event_length) - 1)]) && $event_length[(sizeof($event_length) - 1)]['state'] == 'ended') {
  288.                                             array_pop($event_length);
  289.                                         }
  290.                                         
  291.                                     }
  292.                                     echo '</tr>'."\n";
  293.                                 }
  294.                                 
  295.                             ?>
  296.                     </table>
  297.                 </td>
  298.                </tr>
  299.             </table>
  300.         </td>
  301.     </tr>
  302. </table>
  303. </td>
  304.         <td width="10"><img src="images/spacer.gif" width="10" height="1" alt=" "></td>
  305.         <td width="170" valign="top">
  306.             <?php include (BASE.'includes/sidebar.php'); ?>
  307.         </td>
  308.     </tr>
  309. </table>
  310. </center>
  311. <?php include (BASE.'includes/footer.inc.php'); ?>
  312.  
  313.