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 / week.php < prev    next >
PHP Script  |  2003-10-12  |  17KB  |  368 lines

  1. <?php
  2.  
  3. $current_view = "week";
  4. define('BASE', './');
  5. include(BASE.'functions/ical_parser.php');
  6. if ($minical_view == "current") $minical_view = "week";
  7.  
  8. $starttime             = "0500";
  9. $weekstart             = 1;
  10. $unix_time             = strtotime($getdate);
  11. $thisday2             = localizeDate($dateFormat_week_list, $unix_time);
  12. $today_today         = date('Ymd', strtotime("now + $second_offset seconds")); 
  13. $next_week             = date("Ymd", strtotime("+1 week",  $unix_time));
  14. $prev_week             = date("Ymd", strtotime("-1 week",  $unix_time));
  15. $tomorrows_date     = date( "Ymd", strtotime("+1 day",  $unix_time));
  16. $yesterdays_date     = date( "Ymd", strtotime("-1 day",  $unix_time));
  17. $start_week_time     = strtotime(dateOfWeek($getdate, $week_start_day));
  18. $end_week_time         = $start_week_time + (6 * 25 * 60 * 60);
  19. $start_week         = localizeDate($dateFormat_week, $start_week_time);
  20. $end_week             = localizeDate($dateFormat_week, $end_week_time);
  21. $display_date         = "$start_week - $end_week";
  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. $dayborder = 0;
  30. $thisdate = $start_week_time;
  31. for ($i=0;$i<7;$i++) {
  32.     $thisday = date("Ymd", $thisdate);
  33.     $nbrGridCols[$thisday] = 1;
  34.     if (isset($master_array[$thisday])) {
  35.         foreach($master_array[($thisday)] as $ovlKey => $ovlValue) {
  36.             if ($ovlKey != "-1") {
  37.                 foreach($ovlValue as $ovl2Value) {
  38.                     $nbrGridCols[($thisday)] = kgv($nbrGridCols[($thisday)], ($ovl2Value["event_overlap"] + 1));
  39.                 }
  40.             }
  41.         } 
  42.     }
  43.     $thisdate = ($thisdate + (25 * 60 * 60));
  44. }
  45. include (BASE.'includes/header.inc.php'); 
  46.  
  47. ?>
  48.  
  49. <center>
  50. <table border="0" width="720" cellspacing="0" cellpadding="0">
  51.     <tr>
  52.         <td width="540" valign="top">
  53.             <table width="540" border="0" cellspacing="0" cellpadding="0" class="calborder">
  54.                 <tr>
  55.                     <td align="center" valign="middle">
  56.                         <table width="100%" border="0" cellspacing="0" cellpadding="0">
  57.                             <tr>
  58.                                 <td align="left" width="120" class="navback"> </td>
  59.                                 <td class="navback">
  60.                                     <table width="100%" border="0" cellspacing="0" cellpadding="0">
  61.                                         <tr>
  62.                                             <td align="right" width="40%" class="navback"><?php echo "<a class=\"psf\" href=\"week.php?cal=$cal&getdate=$prev_week\"><img src=\"styles/$style_sheet/left_day.gif\" alt=\"[$last_week_lang]\" border=\"0\" align=\"right\"></a>"; ?></td>
  63.                                             <td align="center" width="20%" class="navback" nowrap valign="middle"><font class="H20"><?php echo $display_date; ?></font></td>
  64.                                             <td align="left" width="40%" class="navback"><?php echo "<a class=\"psf\" href=\"week.php?cal=$cal&getdate=$next_week\"><img src=\"styles/$style_sheet/right_day.gif\" alt=\"[$next_week_lang]\" border=\"0\" align=\"left\"></a>"; ?></td>
  65.                                         </tr>
  66.                                     </table>
  67.                                 </td>
  68.                                 <td align="right" width="120" class="navback">    
  69.                                     <table width="120" border="0" cellpadding="0" cellspacing="0">
  70.                                         <tr>
  71.                                             <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>'; ?>
  72.                                             <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>'; ?>
  73.                                             <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>'; ?>
  74.                                             <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>'; ?>
  75.                                         </tr>
  76.                                     </table>
  77.                                 </td>
  78.                             </tr>
  79.                         </table>
  80.                     </td>
  81.                 </tr>
  82.                 <tr>
  83.                     <td>
  84.                         <table width="100%" border="0" cellspacing="0" cellpadding="0" class="G10B">                  
  85.                             <tr>
  86.                                 <td align="center" valign="top">
  87.                                     <table width="100%" border="0" cellspacing="0" cellpadding="0">
  88.                                         <tr>
  89.                                             <td width="60"><img src="images/spacer.gif" width="60" height="1" alt=" "></td>
  90.                                             <td width="1"></td>
  91.                                             <?php
  92.                                             $thisdate = $start_week_time;
  93.                                             $i = 0;
  94.                                             do {
  95.                                                 $thisday = date("Ymd", $thisdate);
  96.                                                 $colWidth = round(70 / $nbrGridCols[$thisday]);
  97.                                                 for ($j=0;$j < $nbrGridCols[$thisday];$j++) {
  98.                                                     echo "<td width=\"" . $colWidth . "\"><img src=\"images/spacer.gif\" width=\"" . $colWidth . "\" height=\"1\" alt=\" \"></td>\n";
  99.                                                 }
  100.                                                 $thisdate = ($thisdate + (25 * 60 * 60));
  101.                                                 $i++;
  102.                                             } while ($i < 7);
  103.                                             ?>
  104.                                         </tr>
  105.                                         <?php
  106.                                         
  107.                                         // print out the day names here
  108.                                         echo "<tr>";
  109.                                         $thisdate = $start_week_time;
  110.                                         $i = 0;
  111.                                         echo "<td class=\"dateback\" width=\"60\"><img src=\"images/spacer.gif\" width=\"1\" height=\"12\" alt=\" \"></td>";
  112.                                         echo "<td class=\"dateback\" width=\"1\"></td>";
  113.                                         do {
  114.                                             $thisday = date("Ymd", $thisdate);
  115.                                             $thisday3 = localizeDate($dateFormat_week_list, $thisdate);
  116.                                             echo "<td width=\"70\" colspan=\"" . $nbrGridCols[$thisday] . "\" valign=\"top\" align=\"center\" class=\"dateback\">\n";
  117.                                             echo "<font class=\"V9\"><a class=\"psf\" href=\"day.php?cal=$cal&getdate=$thisday\">$thisday3</a></font>\n";
  118.                                             echo "</td>\n";
  119.                                             $thisdate = ($thisdate + (25 * 60 * 60));
  120.                                             $i++;
  121.                                         } while ($i < 7);
  122.                                         echo "</tr>";
  123.                                         ?>
  124.                                         <tr>
  125.                                             <td width="60"><img src="images/spacer.gif" width="60" height="1" alt=" "></td>
  126.                                             <td width="1"></td>
  127.                                             <?php
  128.                                             $thisdate = $start_week_time;
  129.                                             $i = 0;
  130.                                             do {
  131.                                                 $thisday = date("Ymd", $thisdate);
  132.                                                 $colWidth = round(70 / $nbrGridCols[$thisday]);
  133.                                                 for ($j=0;$j < $nbrGridCols[$thisday];$j++) {
  134.                                                     echo "<td width=\"" . $colWidth . "\"><img src=\"images/spacer.gif\" width=\"" . $colWidth . "\" height=\"1\" alt=\" \"></td>\n";
  135.                                                 }
  136.                                                 $thisdate = ($thisdate + (25 * 60 * 60));
  137.                                                 $i++;
  138.                                             } while ($i < 7);
  139.                                             ?>
  140.                                         </tr>
  141.                                         <?php
  142.                                         // The all day events returned here.
  143.                                         $allday_events_this_week = false;
  144.                                         $thisdate = $start_week_time;
  145.                                         for ($i=0;$i<7;$i++) {
  146.                                             $thisday = date("Ymd", $thisdate);
  147.                                             if (isset($master_array[($thisday)]["-1"])) {
  148.                                                 $allday_events_this_week = true;
  149.                                                 break;
  150.                                             }
  151.                                             $thisdate = ($thisdate + (25 * 60 * 60));
  152.                                         }
  153.                                         if ($allday_events_this_week) {
  154.                                             $thisdate = $start_week_time;
  155.                                             $i = 0;
  156.                                             echo "<tr>\n";
  157.                                             echo "<td class=\"dateback\" colspan=\"2\"></td>";
  158.                                             do {
  159.                                                 $thisday = date("Ymd", $thisdate);
  160.                                                 echo "<td class=\"dateback\" height=\"20\" colspan=\"" . $nbrGridCols[$thisday] . "\" valign=\"bottom\">\n";
  161.                                                 if (isset($master_array[($thisday)]["-1"])) {
  162.                                                     echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"4\" class=\"V9\">\n";
  163.                                                       foreach($master_array[($thisday)]["-1"] as $allday) {
  164.                                                         echo "<tr>\n";
  165.                                                         $event_calno  = $allday['calnumber'];
  166.                                                          if ($event_calno < 1) $event_calno=1;
  167.                                                         if ($event_calno > 7) $event_calno=7;
  168.                                                          echo '<td valign="top" align="center" class="eventbg_'.$event_calno.'">';
  169.                                                         openevent("$calendar_name",
  170.                                                         "",
  171.                                                           "",
  172.                                                           $allday,
  173.                                                           $allday_week_lines,
  174.                                                           12,
  175.                                                           '<font color="#ffffff">',
  176.                                                           "</font>",
  177.                                                           "psf");
  178.                                                         echo "</td></tr>\n";
  179.                                                       }
  180.                                                   echo "</table>\n";
  181.                                                 }
  182.                                                 echo "</td>\n";
  183.                                                 $thisdate = ($thisdate + (25 * 60 * 60));
  184.                                                 $i++;
  185.                                               } while ($i < 7);
  186.                                             echo "</tr>\n";
  187.                                         }
  188.                                             // $master_array[($getdate)]["$day_time"]
  189.                                             
  190.                                             $thisdate = $start_week_time;
  191.                                             for ($i=0;$i<7;$i++) {
  192.                                                 $thisday = date("Ymd", $thisdate);
  193.                                                 $event_length[$thisday] = array ();
  194.                                                 $thisdate = ($thisdate + (25 * 60 * 60));
  195.                                             }
  196.                                             foreach ($day_array as $key) {
  197.                                                 $cal_time = $key;    
  198.                                                 ereg('([0-9]{2})([0-9]{2})', $key, $regs_tmp);
  199.                                                 $key = mktime($regs_tmp[1],$regs_tmp[2],0,$this_month,$this_day,$this_year);
  200.                                                 $key = date ($timeFormat, $key);
  201.                                                                                     
  202.             
  203.                                                 if (ereg("([0-9]{1,2}):00", $key)) {
  204.                                                     echo "<tr>\n";
  205.                                                     echo "<td rowspan=\"" . (60 / $gridLength) . "\" align=\"center\" valign=\"top\" width=\"60\" class=\"timeborder\">$key</td>\n";
  206.                                                     echo "<td width=\"1\" height=\"" . $gridLength . "\"></td>\n";
  207.                                                 } elseif("$cal_time" == "$day_start") {
  208.                                                     $size_tmp = 60 - (int)substr($cal_time,2,2);
  209.                                                     echo "<tr>\n";
  210.                                                     echo "<td rowspan=\"" . ($size_tmp / $gridLength) . "\" align=\"center\" valign=\"top\" width=\"60\" class=\"timeborder\">$key</td>\n";
  211.                                                     echo "<td width=\"1\" height=\"" . $gridLength . "\"></td>\n";
  212.                                                 } else {
  213.             
  214.                                                     echo "<tr>\n";
  215.                                                     echo "<td width=\"1\" height=\"" . $gridLength . "\"></td>\n";
  216.                                                 }
  217.                                                 
  218.                                                 // initialize $thisdate again
  219.                                                 $thisdate = $start_week_time;
  220.                                                 
  221.                                                 // loop this part 7 times, one for each day
  222.                                                 
  223.                                                 for ($week_loop=0; $week_loop<7; $week_loop++) {
  224.                                                     $thisday = date("Ymd", $thisdate);
  225.                                                     $dayborder = 0;
  226.                                                     unset($this_time_arr);
  227.                                                     if (isset($master_array[$thisday][$cal_time]) && sizeof($master_array[$thisday][$cal_time]) > 0) {
  228.                                                         $this_time_arr = $master_array[$thisday][$cal_time];
  229.                                                     }
  230.                                                         
  231.                                                     if ("$day_start" == "$cal_time" && isset($master_array[$thisday]) && is_array($master_array[$thisday])) {
  232.                                                         foreach($master_array[$thisday] as $time_key => $time_arr) {
  233.                                                             if ((int)$time_key < (int)$cal_time && is_array($time_arr) && $time_key != '-1') {
  234.                                                                 foreach($time_arr as $event_tmp) {
  235.                                                                     if ((int)$event_tmp['event_end'] > (int)$cal_time) {
  236.                                                                         $this_time_arr[] = $event_tmp;
  237.                                                                     }
  238.                                                                 }
  239.                                                             } else {
  240.                                                                 break;
  241.                                                             }
  242.                                                         }
  243.                                                     }
  244.                                                     
  245.                                                     
  246.                                                     // check for eventstart 
  247.                                                     if (isset($this_time_arr) && sizeof($this_time_arr) > 0) {
  248.                                                         foreach ($this_time_arr as $eventKey => $loopevent) {
  249.                                                             $drawEvent = drawEventTimes ($cal_time, $loopevent["event_end"]);
  250.                                                             $j = 0;
  251.                                                             while (isset($event_length[$thisday][$j])) {
  252.                                                                 if ($event_length[$thisday][$j]["state"] == "ended") {
  253.                                                                     $event_length[$thisday][$j] = array ("length" => ($drawEvent["draw_length"] / $gridLength), "key" => $eventKey, "overlap" => $loopevent["event_overlap"],"state" => "begin");
  254.                                                                     break;
  255.                                                                 }
  256.                                                                 $j++;
  257.                                                             }
  258.                                                             if ($j == sizeof($event_length[$thisday])) {
  259.                                                                 array_push ($event_length[$thisday], array ("length" => ($drawEvent["draw_length"] / $gridLength), "key" => $eventKey, "overlap" => $loopevent["event_overlap"],"state" => "begin"));
  260.                                                             }
  261.                                                         }
  262.                                                     }
  263.             
  264.                                                     if (sizeof($event_length[$thisday]) == 0) {
  265.                                                         if ($dayborder == 0) {
  266.                                                             $class = " class=\"weekborder\"";
  267.                                                             $dayborder++;
  268.                                                         } else {
  269.                                                             $class = "";
  270.                                                             $dayborder = 0;
  271.                                                         }
  272.                                                         
  273.                                                         echo "<td bgcolor=\"#ffffff\" colspan=\"" . $nbrGridCols[$thisday] . "\" $class> </td>\n";
  274.                                                         
  275.                                                     } else {
  276.                                                         $emptyWidth = $nbrGridCols[$thisday];
  277.                                                         for ($i=0;$i<sizeof($event_length[$thisday]);$i++) {
  278.                                                         
  279.                                                         //echo $this_time_arr[($event_length[$thisday][$i]["key"])]["event_text"] . " ind: " . $i . " / anz: " . $event_length[$thisday][$i]["overlap"] . " = " . eventWidth($i,$event_length[$thisday][$i]["overlap"]) . "<br />";
  280.                                                             $drawWidth = $nbrGridCols[$thisday] / ($event_length[$thisday][$i]["overlap"] + 1);
  281.                                                             $emptyWidth = $emptyWidth - $drawWidth;
  282.                                                             switch ($event_length[$thisday][$i]["state"]) {
  283.                                                                 case "begin":
  284.                                                                     $event_length[$thisday][$i]["state"] = "started";
  285.                                                                     $event_start     = $this_time_arr[($event_length[$thisday][$i]["key"])]["start_unixtime"];
  286.                                                                     $event_start     = date ($timeFormat, $event_start);
  287.                                                                     $event_calno  = $this_time_arr[($event_length[$thisday][$i]['key'])]['calnumber'];
  288.                                                                     $event_status    = strtolower($this_time_arr[($event_length[$thisday][$i]['key'])]['status']);
  289.                                                                       if ($event_calno < 1) $event_calno = 1;
  290.                                                                       if ($event_calno > 7) $event_calno = 7;
  291.                                                                     echo '<td rowspan="' . $event_length[$thisday][$i]['length'] . '" colspan="' . $drawWidth . '" align="left" valign="top" class="eventbg2week_'.$event_calno.'">'."\n";
  292.                                                                     echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
  293.                                                                     echo "<tr>\n";
  294.                                                                     echo "<td class=\"eventborder\"><font class=\"V10WB\"><b>$event_start</b></font></td>\n";
  295.                                                                     if ($event_status != '') {
  296.                                                                         echo '<td class="eventborder" width="9" align="right" valign="center"><font class="eventfont">';
  297.                                                                         echo '<img src="images/'.$event_status.'.gif" width="9" height="9" alt="" border="0" hspace="0" vspace="0">';
  298.                                                                         echo "</font></td>\n";
  299.                                                                     }
  300.                                                                     echo "</tr>\n";
  301.                                                                     echo "<tr>\n";
  302.                                                                     echo "<td colspan=\"2\">\n";
  303.                                                                     echo "<table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\">\n";
  304.                                                                     echo "<tr>\n";
  305.                                                                     echo '<td class="eventbg_'.$event_calno.'">';
  306.                                                                     $event_end    = $this_time_arr[($event_length[$thisday][$i]["key"])]["end_unixtime"];
  307.                                                                     $event_end         = date ($timeFormat, $event_end);
  308.                                                                     // Todo: keep track of where the event comes from, and indicate that to openevent instead of $ALL_CALENDARS_COMBINED
  309.                                                                     if ($cal == $ALL_CALENDARS_COMBINED) $calendar_name2=$cal; else $calendar_name2=$calendar_name;
  310.                                                                     openevent("$calendar_name2",
  311.                                                                           "$event_start",
  312.                                                                           "$event_end",
  313.                                                                           $this_time_arr[($event_length[$thisday][$i]["key"])],
  314.                                                                           $week_events_lines,
  315.                                                                           25,
  316.                                                                           "<font class=\"V10W\">",
  317.                                                                           "</font>",
  318.                                                                           "psf");
  319.                                                                     echo "</td></tr>\n";
  320.                                                                     echo "</table>\n";
  321.                                                                     echo "</td>\n";           
  322.                                                                     echo "</tr>\n";
  323.                                                                     echo "</table>\n";
  324.                                                                     echo "</td>\n";
  325.                                                                     break;
  326.                                                                 case "started":
  327.                                                                     break;
  328.                                                                 case "ended":
  329.                                                                     echo "<td bgcolor=\"#ffffff\" colspan=\"" . $drawWidth . "\" $class> </td>\n";
  330.                                                                     break;
  331.                                                             }
  332.                                                             $event_length[$thisday][$i]["length"]--;
  333.                                                             if ($event_length[$thisday][$i]["length"] == 0) {
  334.                                                                 $event_length[$thisday][$i]["state"] = "ended";
  335.                                                             }
  336.                                                         }
  337.                                                         //fill emtpy space on the right
  338.                                                         if ($emptyWidth > 0) {
  339.                                                             echo "<td bgcolor=\"#ffffff\" colspan=\"" . $emptyWidth . "\" $class> </td>\n";
  340.                                                         }
  341.                                                         while (isset($event_length[$thisday][(sizeof($event_length[$thisday]) - 1)]["state"]) && $event_length[$thisday][(sizeof($event_length[$thisday]) - 1)]["state"] == "ended") {
  342.                                                             array_pop($event_length[$thisday]);
  343.                                                         }
  344.                                                     }
  345.                                                     $thisdate = ($thisdate + (25 * 60 * 60));
  346.                                                 }
  347.                                                 echo "</tr>\n";
  348.                                             }
  349.             
  350.                                         ?>
  351.                                 </table>
  352.                             </td>
  353.                         </tr>
  354.                         </table>
  355.                     </td>
  356.                 </tr>
  357.             </table>
  358.         </td>
  359.         <td width="10"><img src="images/spacer.gif" width="10" height="1" alt=" "></td>
  360.         <td width="170" valign="top">
  361.             <?php include (BASE.'includes/sidebar.php'); ?>
  362.         </td>
  363.     </tr>
  364. </table>
  365. </center>
  366. <?php include (BASE.'includes/footer.inc.php'); ?>
  367.  
  368.