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 / month.php < prev    next >
PHP Script  |  2003-10-12  |  9KB  |  240 lines

  1. <?php 
  2.  
  3. $current_view = "month";
  4. define('BASE', './');
  5. include(BASE.'functions/ical_parser.php');
  6. if ($minical_view == 'current') $minical_view = 'month';
  7.  
  8. ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $getdate, $day_array2);
  9. $this_day                 = $day_array2[3]; 
  10. $this_month             = $day_array2[2];
  11. $this_year                 = $day_array2[1];
  12.  
  13. $unix_time                 = strtotime($getdate);
  14. $today_today             = date('Ymd', strtotime("now + $second_offset seconds")); 
  15. $tomorrows_date         = date( "Ymd", strtotime("+1 day",  $unix_time));
  16. $yesterdays_date         = date( "Ymd", strtotime("-1 day",  $unix_time));
  17.  
  18. // find out next month
  19. $next_month_month         = ($this_month+1 == '13') ? '1' : ($this_month+1);
  20. $next_month_day         = $this_day;
  21. $next_month_year         = ($next_month_month == '1') ? ($this_year+1) : $this_year;
  22. while (!checkdate($next_month_month,$next_month_day,$next_month_year)) $next_month_day--;
  23. $next_month_time         = mktime(0,0,0,$next_month_month,$next_month_day,$next_month_year);
  24.  
  25. // find out last month
  26. $prev_month_month         = ($this_month-1 == '0') ? '12' : ($this_month-1);
  27. $prev_month_day         = $this_day;
  28. $prev_month_year         = ($prev_month_month == '12') ? ($this_year-1) : $this_year;
  29. while (!checkdate($prev_month_month,$prev_month_day,$prev_month_year)) $prev_month_day--;
  30. $prev_month_time         = mktime(0,0,0,$prev_month_month,$prev_month_day,$prev_month_year);
  31.  
  32. $next_month             = date("Ymd", $next_month_time);
  33. $prev_month             = date("Ymd", $prev_month_time);
  34. $display_date             = localizeDate ($dateFormat_month, $unix_time);
  35. $parse_month             = date ("Ym", $unix_time);
  36. $first_of_month         = $this_year.$this_month."01";
  37. $start_month_day         = dateOfWeek($first_of_month, $week_start_day);
  38. $thisday2                 = localizeDate($dateFormat_week_list, $unix_time);
  39. $num_of_events2             = 0;
  40.  
  41. include (BASE.'includes/header.inc.php'); 
  42.  
  43. ?>
  44. <center>
  45. <table width="735" border="0" cellspacing="0" cellpadding="0" class="calborder">
  46.     <tr>
  47.         <td align="center" valign="middle" bgcolor="white">
  48.             <table width="100%" border="0" cellspacing="0" cellpadding="0">
  49.                   <tr>
  50.                       <td align="left" width="120" class="navback"> </td>
  51.                       <td class="navback">
  52.                           <table width="100%" border="0" cellspacing="0" cellpadding="0">
  53.                               <tr>
  54.                                 <td align="right" width="40%" class="navback"><?php echo "<a class=\"psf\" href=\"month.php?cal=$cal&getdate=$prev_month\"><img src=\"styles/$style_sheet/left_day.gif\" alt=\"[$last_month_lang]\" border=\"0\" align=\"right\"></a>"; ?></td>
  55.                                 <td align="center" width="20%" class="navback" nowrap valign="middle"><font class="H20"><?php echo $display_date; ?></font></td>
  56.                                   <td align="left" width="40%" class="navback"><?php echo "<a class=\"psf\" href=\"month.php?cal=$cal&getdate=$next_month\"><img src=\"styles/$style_sheet/right_day.gif\" alt=\"[$next_month_lang]\" border=\"0\" align=\"left\"></a>"; ?></td>
  57.                               </tr>
  58.                           </table>
  59.                       </td>
  60.                       <td align="right" width="120" class="navback">    
  61.                           <table width="120" border="0" cellpadding="0" cellspacing="0">
  62.                             <tr>
  63.                                 <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>'; ?>
  64.                                 <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>'; ?>
  65.                                 <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>'; ?>
  66.                                 <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>'; ?>
  67.                             </tr>
  68.                         </table>
  69.                     </td>
  70.                   </tr>
  71.               </table>
  72.         </td>
  73.     </tr>
  74.     <tr>
  75.         <td align="center" valign="top">
  76.             <table width="100%" border="0" cellspacing="1" cellpadding="2" class="monthback">
  77.                 <tr>
  78.                     <?php
  79.                         // loops through 7 times, starts with $week_start_day
  80.                         $start_day = strtotime($week_start_day);
  81.                         for ($i=0; $i<7; $i++) {
  82.                             $day_num = date("w", $start_day);
  83.                             $day = $daysofweek_lang[$day_num];
  84.                             echo '<td valign="top" width="105" height="12" class="dateback"><center class="V9BOLD">'.$day.'</center></td>';
  85.                             $start_day = strtotime("+1 day", $start_day);
  86.                         }
  87.                     ?>    
  88.                 </tr>
  89.                 <tr>    
  90.                 <?php      
  91.                     $sunday         = strtotime("$start_month_day");
  92.                     $i                 = 0;
  93.                     $whole_month     = TRUE;
  94.                     do {
  95.                         $day             = date ("j", $sunday);
  96.                         $daylink         = date ("Ymd", $sunday);
  97.                         $check_month     = date ("m", $sunday);
  98.                         if ($check_month != $this_month) {
  99.                             $day        = '<font class="G10G">'.$day.'</font>';
  100.                             $bgclass    = 'class="monthoff"';
  101.                         } else {
  102.                             if ($today_today == $daylink) {
  103.                                 $bgclass = 'class="monthon"';
  104.                             } else {
  105.                                 $bgclass = 'class="monthreg"';
  106.                             }
  107.                         }
  108.                         if ($i == 0) echo '<tr height="105">';
  109.                         if (isset($master_array[("$daylink")])) {
  110.                             echo '<td valign="top" align="left" '.$bgclass.' width="105" height="105">';
  111.                             echo '<div align="right"><font class="G10"><a class="psf" href="day.php?cal='.$cal.'&getdate='.$daylink.'">'.$day.'</a></font></div>';
  112.                             echo '<div align="left">';
  113.                             if ($master_array[("$daylink")]) {
  114.                                 foreach ($master_array[("$daylink")] as $event_times) {
  115.                                     foreach ($event_times as $val) {
  116.                                         $num_of_events2++;
  117.                                         if (!isset($val["event_start"])) {
  118.                                             echo '<div align="center" class="V10">';
  119.                                             openevent("$calendar_name", "", "", $val, $month_event_lines,
  120.                                             15,
  121.                                             "<i>",
  122.                                             "</i>",
  123.                                             "psf");
  124.                                             echo '</div>';
  125.                                         } else {    
  126.                                             echo '<div align="left" class="V9"> ';
  127.                                             $event_start = @$val["event_start"];
  128.                                             $event_end   = @$val["event_end"];
  129.                                             $event_start = date($timeFormat, @strtotime ("$event_start"));
  130.                                             $start2         = date($timeFormat_small,@strtotime("$event_start"));
  131.                                             $event_end   = date($timeFormat, @strtotime ("$event_end"));
  132.                                             @openevent("$calendar_name",
  133.                                             "$event_start",
  134.                                             "$event_end",
  135.                                             $val,
  136.                                             $month_event_lines,
  137.                                             11,
  138.                                             "$start2 ",
  139.                                             "",
  140.                                             "ps3");
  141.                                             echo '</div>';
  142.                                         }
  143.                                     }
  144.                                 }
  145.                             }
  146.                             echo '</td>';
  147.                         } else {
  148.                             echo '<td align="center" valign="top" '.$bgclass.' width="105" height="105">';
  149.                             echo '<div align="right"><font class="G10"><a class="psf" href="day.php?cal='.$cal.'&getdate='.$daylink.'">'.$day.'</a></font></div>';
  150.                             echo '</td>';
  151.                         }
  152.                         $sunday = strtotime("+1 day", $sunday); 
  153.                         $i++;
  154.                         if ($i == 7) { 
  155.                             echo '</tr>';
  156.                             $i = 0;
  157.                             $checkagain = date ("m", $sunday);
  158.                             if ($checkagain != $this_month) $whole_month = FALSE;    
  159.                         }
  160.                     } while ($whole_month == TRUE);
  161.                 ?>
  162.             </table>
  163.         </td>
  164.     </tr>
  165. </table>
  166. <?php include (BASE.'includes/calendar_nav.php'); ?>
  167. <?php if (($this_months_events == "yes") && ($num_of_events2 > 0)) { ?>    
  168. <br>
  169.             <table width="737" border="0" cellspacing="0" cellpadding="3" class="calborder">
  170.                 <tr>
  171.                     <td colspan="3" align="center" class="sideback" nowrap><div style="height: 16px;" class="G10BOLD"><?php echo "$this_months_lang"; ?></div></td>
  172.                 </tr>
  173.                 <?php    
  174.                     $first_time = TRUE;
  175.                     // Iterate the entire master array
  176.                     foreach($master_array as $key => $val) {
  177.                         
  178.                         // Pull out only this months
  179.                         ereg ("([0-9]{6})([0-9]{2})", $key, $regs);
  180.                         if ($regs[1] == $parse_month) {
  181.                             $dayofmonth = strtotime ($key);
  182.                             $dayofmonth = localizeDate ($dateFormat_week_list, $dayofmonth);
  183.                             $i = 0;
  184.                             if ($today_today == $key) {
  185.                                 $fontclass="G10BOLD";
  186.                             } else {
  187.                                 $fontclass="G10B";
  188.                             }
  189.                             
  190.                             // Pull out each day
  191.                             foreach ($val as $new_val) {
  192.                                 
  193.                                 // Pull out each time
  194.                                 foreach ($new_val as $new_key2 => $new_val2) {
  195.                                 if ($new_val2["event_text"]) {    
  196.                                     if (isset($new_val2["event_start"])) {
  197.                                         $event_start     = $new_val2["event_start"];
  198.                                         $event_end         = $new_val2["event_end"];
  199.                                         $event_start     = date ($timeFormat, strtotime ("$event_start"));
  200.                                         $event_end         = date ($timeFormat, strtotime ("$event_end"));
  201.                                         $event_start2    = $event_start;
  202.                                     } else {
  203.                                         $event_start = "$all_day_lang";
  204.                                         $event_start2 = '';
  205.                                         $event_end = '';                                                    
  206.                                     }
  207.         
  208.                                     echo "<tr align=\"left\" valign=\"top\">\n";
  209.                                     echo "<td width =\"155\" class=\"$fontclass\" nowrap><a class=\"psf\" href=\"day.php?cal=$cal&getdate=$key\">$dayofmonth</a> <font class=\"V9G\">($event_start)</font></td>\n";
  210.                                     if ($first_time == TRUE) {
  211.                                         echo "<td width=\"5\" class=\"montheventline\" rowspan=\"$num_of_events2\"></td>";
  212.                                         $first_time = FALSE;
  213.                                     }
  214.                                     echo "<td>\n";
  215.                                     openevent("$calendar_name",
  216.                                     "$event_start",
  217.                                     "$event_end",
  218.                                     $new_val2,
  219.                                     0,
  220.                                     65,
  221.                                     "<font class=\"G10B\">",
  222.                                     "</font>",
  223.                                     "psf");
  224.                                     echo "</td>\n";
  225.                                     echo "</tr>\n";
  226.                                 }
  227.  
  228.                                 }
  229.                             }
  230.                         }
  231.                     }
  232.                 
  233.                 ?>
  234.             </table>        
  235. <?php } ?>
  236. </center>
  237. <?php include (BASE.'includes/footer.inc.php'); ?>
  238.  
  239.  
  240.