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

modules/dateplaner/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 require_once    ('./include/inc.header.php');
00030 
00031 // catch hack attempts
00032 if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
00033 {
00034         $ilias->raiseError($lng->txt("msg_not_available_for_anon"),$ilias->error_obj->MESSAGE);
00035 }*/
00036 
00037 
00038 
00039 class ilMiniCal {
00040         
00041 
00042         var $ilias;
00043         var $tpl;
00044         var $lng;
00045 
00046         var $cal_month; // private variable containing the month that will be displayed
00047         var $cal_year;
00048         var $cal;
00049 
00050         
00051         function ilMiniCal()
00052         {
00053                 global $ilias, $tpl, $lng;
00054 
00055                 $this->ilias =& $ilias;
00056                 $this->tpl = & $tpl;
00057                 $this->lng =& $lng;
00058 
00059         
00060         }
00061 
00062         
00063         function show($month, $year)
00064         {
00065         
00066                 $cal_month = $month;
00067                 $cal_year = $year;
00068                 $cal_day = date(j);
00069         
00070         $lastday                = strftime("%d", mktime (0,0,0,$cal_month,0,$cal_year));        // was last month's last day the 30rd, 31st, ...?
00071         $firstday               = strftime ("%u", mktime(0,0,0,$cal_month,1,$cal_year)) - 2;    // which day is this month's first day ? (Monday,...)
00072         
00073         $startday = $lastday - $firstday;
00074 
00075         if ($lastday != 31 || $cal_month == "8" || $cal_month == "1")
00076         {
00077                 $days_in_month = 31;                            // decide how many days the actual month has
00078         }
00079         else
00080         {       
00081                 if ($cal_month != 02)
00082                 {
00083                         $days_in_month = 30;
00084                 }
00085                 else
00086                 {
00087                         if ($cal_year % 4 == 0)
00088                         {
00089                                 $days_in_month = 29;            // decide we're about to display a leap year and need to adjust the number of days
00090                         }       
00091                         else
00092                         {
00093                                 $days_in_month = 28;
00094                         }
00095                 }
00096 
00097         }
00098         $next = $cal_year + 1;
00099         $last = $cal_year - 1;
00100         $next_ts = mktime (0,0,0,$cal_month,1,$next);                   // timestamps for displaying day views for next and last year button
00101         $last_ts = mktime (0,0,0,$cal_month,1,$last);
00102 
00103         // beginning of html-code for table     
00104         $cal = "<table tableborder='1' rules='none' frame='box' bgcolor='#FFFFFF' style='margin-right: 10px;'><tr><td><a href=\"dateplaner.php?app=".$_GET["app"]."&month=$cal_month&year=$last&timestamp=$last_ts\"> < </a></td> <td align=\"center\" colspan=\"6\">".$this->lng->txt("short_".$cal_month)." $cal_year </td><td> <a href=\"dateplaner.php?app=".$_GET["app"]."&month=$cal_month&year=$next&timestamp=$next_ts\"> > </a> </td></tr>\n";
00105         $cal = $cal."<tr><td></td>";
00106         for($i = 1; $i <= 12; $i++)
00107         {
00108                 if ($i <= 9)
00109                 {
00110                         $tmp = "0".$i;          // standardizes content of $tmp to two digits representing months
00111                 }
00112                 else
00113                 {       
00114                         $tmp = $i;
00115                 }
00116                 $ts = mktime (0,0,0,$tmp,1,$cal_year);          // create timestamps to enable dayviews for months in actual year
00117                 $cal = $cal."<td><a href=\"dateplaner.php?app=".$_GET["app"]."&month=".$tmp."&year=".$cal_year."&timestamp=".$ts."\">".$this->lng->txt("short_".$tmp)."</td>";
00118                 if ($i == 6) $cal = $cal."<td></td></tr> \n <tr><td></td>";
00119                 
00120         }
00121         $cal = $cal."<td></td></tr> \n ";
00122         // html code for displaying days of week using ilias lng-module
00123         $cal = $cal."<tr bgcolor='#AAAAAA'><td >".$this->lng->txt("wk_short")."</td><td>".$this->lng->txt("Mo_short")."</td><td>".$this->lng->txt("Tu_short")."</td><td>".$this->lng->txt("We_short")."</td>";
00124         $cal = $cal."<td>".$this->lng->txt("Th_short")."</td><td>".$this->lng->txt("Fr_short")."</td><td>".$this->lng->txt("Sa_short")."</td><td>".$this->lng->txt("Su_short")."</td></tr>";
00125         
00126  
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'><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> $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 ".$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 ".$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> $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 10:18:30 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1