• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

calendar/classes/class.ilMiniCal.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         |       Dateplaner Modul                                                      |                                                                                                 
00006         +-----------------------------------------------------------------------------+
00007         | Copyright (c) 2005 ILIAS open source                                        |
00008         |                                                                             |
00009         | This program is free software; you can redistribute it and/or               |
00010         | modify it under the terms of the GNU General Public License                 |
00011         | as published by the Free Software Foundation; either version 2              |
00012         | of the License, or (at your option) any later version.                      |
00013         |                                                                             |
00014         | This program is distributed in the hope that it will be useful,             |
00015         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00016         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00017         | GNU General Public License for more details.                                |
00018         |                                                                             |
00019         | You should have received a copy of the GNU General Public License           |
00020         | along with this program; if not, write to the Free Software                 |
00021         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00022         +-----------------------------------------------------------------------------+
00023 
00024 */
00025 
00026 
00027 // get ilias conectivity 
00028 
00029 class ilMiniCal {
00030         
00031 
00032         var $ilias;
00033         var $tpl;
00034         var $lng;
00035 
00036         var $cal_month; // private variable containing the month that will be displayed
00037         var $cal_year;
00038         var $cal;
00039 
00040         
00041         function ilMiniCal()
00042         {
00043                 global $ilias, $tpl, $lng;
00044 
00045                 $this->ilias =& $ilias;
00046                 $this->tpl = & $tpl;
00047                 $this->lng =& $lng;
00048         }
00049 
00050         
00051         function show($month, $year)
00052         {
00053         
00054                 $cal_month = $month;
00055                 $cal_year = $year;
00056                 $cal_day = date(j);
00057         
00058                 $lastday                = strftime("%d", mktime (0,0,0,$cal_month,0,$cal_year));        // was last month's last day the 30rd, 31st, ...?
00059                 // the %u option fails on windows (see bug 1624)
00060                 $firstday               = strftime ("%w", mktime(0,0,0,$cal_month,1,$cal_year)) - 2;    // which day is this month's first day ? (Monday,...)
00061                 if ($firstday == -2)
00062                 {
00063                         $firstday = 5;
00064                 }
00065 
00066                 $startday = $lastday - $firstday;
00067         
00068                 if ($lastday != 31 || $cal_month == "8" || $cal_month == "1")
00069                 {
00070                         $days_in_month = 31;                            // decide how many days the actual month has
00071                 }
00072                 else
00073                 {       
00074                         if ($cal_month != 02)
00075                         {
00076                                 $days_in_month = 30;
00077                         }
00078                         else
00079                         {
00080                                 if ($cal_year % 4 == 0)
00081                                 {
00082                                         $days_in_month = 29;            // decide we're about to display a leap year and need to adjust the number of days
00083                                 }       
00084                                 else
00085                                 {
00086                                         $days_in_month = 28;
00087                                 }
00088                         }
00089         
00090                 }
00091                 $next = $cal_year + 1;
00092                 $last = $cal_year - 1;
00093                 $next_ts = mktime (0,0,0,$cal_month,1,$next);                   // timestamps for displaying day views for next and last year button
00094                 $last_ts = mktime (0,0,0,$cal_month,1,$last);
00095         
00096                 // beginning of html-code for table     
00097                 $cal = "<table tableborder='1' rules='none' frame='box' bgcolor='#FFFFFF' style='margin-right: 10px;'><tr><td class=\"il_CalNextMonth\">".
00098                         "<a href=\"dateplaner.php?app=".$_GET["app"]."&month=$cal_month&year=$last&timestamp=$last_ts\">".
00099                         " < </a></td> <td align=\"center\" class=\"il_CalMonth\" colspan=\"6\">".
00100                         $this->lng->txt("short_".$cal_month)." $cal_year </td><td class=\"il_CalNextMonth\"> <a href=\"dateplaner.php?app=".
00101                         $_GET["app"]."&month=$cal_month&year=$next&timestamp=$next_ts\"> > </a> </td></tr>\n";
00102                 $cal = $cal."<tr><td></td>";
00103                 for($i = 1; $i <= 12; $i++)
00104                 {
00105                         if ($i <= 9)
00106                         {
00107                                 $tmp = "0".$i;          // standardizes content of $tmp to two digits representing months
00108                         }
00109                         else
00110                         {       
00111                                 $tmp = $i;
00112                         }
00113                         $ts = mktime (0,0,0,$tmp,1,$cal_year);          // create timestamps to enable dayviews for months in actual year
00114                         $cal = $cal."<td class=\"il_CalShortMonth\"><a href=\"dateplaner.php?app=".$_GET["app"]."&month=".$tmp."&year=".$cal_year."&timestamp=".$ts."\">".$this->lng->txt("short_".$tmp)."</td>";
00115                         if ($i == 6) $cal = $cal."<td></td></tr> \n <tr><td></td>";
00116                         
00117                 }
00118                 $cal = $cal."<td></td></tr> \n ";
00119                 // html code for displaying days of week using ilias lng-module
00120                 $cal = $cal."<tr bgcolor='#AAAAAA'><td class=\"il_CalShortDayOfWeek\">".$this->lng->txt("wk_short").
00121                         "</td><td class=\"il_CalShortDayOfWeek\">".$this->lng->txt("Mo_short")."</td><td class=\"il_CalShortDayOfWeek\">".$this->lng->txt("Tu_short").
00122                         "</td><td class=\"il_CalShortDayOfWeek\">".$this->lng->txt("We_short")."</td>";
00123                 $cal = $cal."<td class=\"il_CalShortDayOfWeek\">".$this->lng->txt("Th_short").
00124                         "</td><td class=\"il_CalShortDayOfWeek\">".$this->lng->txt("Fr_short").
00125                         "</td><td class=\"il_CalShortDayOfWeek\">".$this->lng->txt("Sa_short").
00126                         "</td><td class=\"il_CalShortDayOfWeek\">".$this->lng->txt("Su_short")."</td></tr>";
00127                 
00128                 $kw = strftime ("%V", mktime(0,0,0,$cal_month,1,$cal_year)); // get actual number of week to start with
00129         
00130                 $counter = 1; // general counter; calendar will always dislpay 42 days
00131                 $day = 1;       // variable needed for displaying first week, if first week is split into different month
00132                 $ts_week = mktime (0,0,0,$cal_month,1,$cal_year); // timestamp that contains the week and is updated every loop inside brackets
00133         
00134                 // loop to generate html-code for actual weeks and days in month
00135                 for ($x = 1; $x <= 6; $x++)
00136                 {               
00137                                 $cal = $cal. " <tr><td bgcolor='#AAAAAA' class=\"il_CalShortWeek\"><a href=\"dateplaner.php?app=week&month=".$cal_month."&year=".$cal_year."&timestamp=".$ts_week."\">$kw</td> ";
00138                                 $ts_week = strtotime ("+1 week", $ts_week );
00139         
00140                                 if ($x == 1)
00141                                 {                               
00142                                         $tmp = $startday;
00143                                         while ($tmp <= $lastday)
00144                                         {
00145                                                 $cal = $cal." <td class=\"il_CalDay\"> $tmp</td> "; // displays days in old month if first day in month isn't Monday
00146                                                 $tmp++;
00147                                                 $counter++;
00148                                         }
00149                                         
00150                                         $empty_string ="";
00151                                         while ($counter <=7)
00152                                         {
00153                                                 $ts_day = mktime (0,0,0, $cal_month, $day, $cal_year);  // timestamps to display different day views
00154                                                 if ($day == $cal_day&& $cal_month == date (m) && $cal_year == date (Y)) $empty_string = " bgcolor='FF8000'";
00155         
00156                                                 // html-code for table entry and according link
00157                                                 $cal = $cal." <td class=\"il_CalDay\" ".$empty_string."><a href=\"dateplaner.php?app=day&month=".$cal_month."&year=".$cal_year."&timestamp=".$ts_day."\">$day</a></td> ";
00158                                                 $day++;
00159                                                 $tmp++;
00160                                                 $counter++;
00161                                                 $empty_string ="";
00162                                                         
00163                                         }
00164                                         if ($kw >= 52 ) $kw = 0; // adjusts week numbers if you display january or december 
00165                                         $day = 1; // resets variable...
00166                                         
00167                                 }
00168                                 else                    
00169                                 {
00170                                         for ($c = 7 - $firstday + ($x-2) * 7; $c <= 6 - $firstday + ($x-1) *7 && $counter <= 42; $c++) // c represents the actual day in month
00171                                         {
00172                                                 if ($c <= $days_in_month)
00173                                                 {
00174                                                         $ts_day = mktime (0,0,0, $cal_month, $c, $cal_year);  // timestamps to display different day views
00175                                                         if ($c == $cal_day && $cal_month == date (m) && $cal_year == date (Y)) $empty_string = " bgcolor='FF8000'";
00176                                                                                                         
00177                                                         // html-code for table entry and according link
00178                                                         $cal = $cal. "<td class=\"il_CalDay\" ".$empty_string."><a href=\"dateplaner.php?app=day&month=".$cal_month."&year=".$cal_year."&timestamp=".$ts_day."\"> $c</a></td>";
00179                                                         $counter++;
00180                                                         $empty_string ="";
00181                                                 }
00182                                                 else  // clause displays days that belong to next month
00183                                                 {
00184                                                         $cal = $cal. "<td class=\"il_CalDay\"> $day</td>";
00185                                                         $day++;
00186                                                         $counter++;
00187                                                 }                                                               
00188                                         } 
00189                                 }                       
00190                                 $cal = $cal. "</tr> \n "; // complete table row
00191                                 $kw++;                                  // update weeknumber
00192                 }
00193                 $cal = $cal." </table>"; // complete table
00194                 
00195                 return $cal;
00196         
00197         }
00198 
00199 }
00200 
00201 ?>

Generated on Fri Dec 13 2013 17:56:47 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1