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

modules/dateplaner/includes/inc.minicalendar.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                                                                                       |
00005         |       Dateplaner Modul                                                                                                                  |                                                                                                     
00006         +-----------------------------------------------------------------------------+
00007         | Copyright (c) 2004 ILIAS open source & University of Applied Sciences Bremen|
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 
00039 // it is an action required to generate images..
00040 if ($_GET[action] == "show") {
00041         $im = ImageCreate (162, 160)
00042       or die ("Kann keinen neuen GD-Bild-Stream erzeugen");
00043         $im = showMinicalendar($_GET[month],$_GET[year], $im, $_GET[DP_Lang]);
00044         // Ilias3 + GD >1.6.1
00045         ImagePNG($im);
00046 
00047         // Ilias2 + GD <1.6.1
00048         //ImageGif($im);
00049 
00050 }
00051 
00052 
00053 
00062 function showMinicalendar($month,$year, $im, $DP_Lang)
00063 {
00064 
00065         //language
00066         $array_tmp = @file('../lang/dp_'.$DP_Lang.'.lang');
00067         foreach($array_tmp as $v)
00068         {
00069                 if ((substr(trim($v),0,13)=='dateplaner#:#') && (substr_count($v,'#:#')>=2))
00070                 {//Line mustn't start with a ';' and must contain at least one '=' symbol.
00071                         $pos            = strpos($v, '#:#', '13');
00072                         $offset1        = strpos($v, '#:#', '13')-13;
00073                         $offset2        = strpos($v, '###', '13')-$offset1-16;
00074                         if($offset2 != (-$offset1-16)) {
00075                                 $DP_language[trim(substr($v,13,$offset1))] = trim(substr($v, $pos+3,$offset2));
00076                         }
00077                         else {
00078                                 $DP_language[trim(substr($v,13,$offset1))] = trim(substr($v, $pos+3));
00079                         }
00080                 }
00081         }
00082 
00083         if(!$month || !$year)
00084         {
00085                 $month = date(m);
00086                 $year = date(Y);        
00087         }
00088 
00089         //Wieviele Tage hat der vorherige month
00090         $lastday = strftime("%d.", mktime (0,0,0,$month,0,$year));
00091         //Welcher Wochentag ist der 1. des Monats
00092         $firstday = strftime ("%u", mktime(0,0,0,$month,1,$year))-2;
00093         if ($firstday == -1) $firstday = 6; 
00094         $startday = $lastday - $firstday;
00095 
00096     $Tagesnamen = array($DP_language[wk_short], $DP_language[Mo_short], $DP_language[Tu_short], $DP_language[We_short], $DP_language[Th_short], $DP_language[Fr_short], $DP_language[Sa_short], $DP_language[Su_short]);
00097         $Monatabk = array("", $DP_language[short_01], $DP_language[short_02], $DP_language[short_03], $DP_language[short_04], $DP_language[short_05], $DP_language[short_06], $DP_language[short_07], $DP_language[short_08], $DP_language[short_09], $DP_language[short_10],  $DP_language[short_11], $DP_language[short_12]);
00098 
00099         ImageColorAllocate ($im, 144, 144, 144);
00100         $color[1] = ImageColorAllocate ($im,0,0,0); //schwarz
00101         $color[2] = ImageColorAllocate ($im,144,144,144); //blau
00102         $color[3] = ImageColorAllocate ($im,43,43,43); // dunkelblau
00103         $color[4] = ImageColorAllocate ($im,255,255,255); //weiss
00104         $color[5] = ImageColorAllocate ($im,200,200,200); //hellblau
00105         $color[6] = ImageColorAllocate ($im,0,255,0); //ausblenden hellblau
00106         $color[7] = ImageColorAllocate ($im,255,200,150); //rot
00107 
00108         imagefilledrectangle ($im, 1, 49, 160, 65, $color[3]);
00109         imagefilledrectangle ($im, 1, 66, 20, 158, $color[3]);
00110 
00111         //ANZEIGE DES jahres und dessen navigation
00112         imagerectangle ($im, 10, 2, 25, 17, $color[4]);
00113         imagerectangle ($im, 135, 2, 150, 17, $color[4]);
00114         ImageString ($im, 5, 64, 2, $year, $color[4]);
00115         $points = array("20","6","20","12","15","9");
00116         imagefilledpolygon ($im, $points, 3, $color[4]);
00117         $points = array("140","6","140","12","145","9");
00118         imagefilledpolygon ($im, $points, 3, $color[4]);
00119 
00120         //Anzeige des monats und der navigation
00121         imageline ( $im, 2, 20 ,158 ,20 , $color[3]);
00122         imageline ( $im, 2, 33 ,158 ,33 , $color[3]);
00123         imageline ( $im, 2, 47 ,158 ,47 , $color[3]);
00124         imageline ( $im, 2, 20 ,2 ,47 , $color[3]);
00125         imageline ( $im, 158, 20 ,158 ,47 , $color[3]);
00126         
00127         imageline ( $im, 27, 20 ,27 ,47 , $color[3]);
00128         imageline ( $im, 54, 20 ,54 ,47 , $color[3]);
00129         imageline ( $im, 79, 20 ,79 ,47 , $color[3]);
00130         imageline ( $im, 105, 20 ,105 ,47 , $color[3]);
00131         imageline ( $im, 131, 20 ,131 ,47 , $color[3]);
00132 
00133         $c0 = 1;
00134         for($y = 20; $y <= 40; $y = $y+13)
00135         {
00136                 for($x = 5; $x <= 137; $x = $x+26)
00137                 {
00138                         if($month == $c0)
00139                         {
00140                                 $c1=4;
00141                         }
00142                         else
00143                         {
00144                                 $c1=3;
00145                         }
00146                         ImageString ($im, 3, $x, $y, $Monatabk[$c0++], $color[$c1]);
00147                 }
00148         }
00149 
00150         //Kalenderwoche
00151         $kw=strftime ("%V", mktime(0,0,0,$month,1,$year));
00152         if (date("w",mktime(0,0,0,$month,1,$year))==1) 
00153         {
00154                 $kw = $kw-1;
00155         }
00156         else 
00157         {
00158                 $kw = $kw+0;
00159         }
00160         for($y = 66; $y <= 145; $y = $y+15)
00161         {
00162                 ImageString ($im, 3, 4, $y, $kw++, $color[2]);
00163         }
00164         
00165         //Wochentage MO DI MI...
00166         $c0 = 0;
00167         for($x = 5; $x <= 145; $x = $x+20)
00168         {
00169                 ImageString ($im, 3, $x, 50, $Tagesnamen[$c0++], $color[5]);
00170         }
00171         
00172         //Tage des Monats, bzw. der Tagesnummern
00173         $c0 = 3;
00174         for($y = 66; $y <= 145; $y = $y+15)
00175         {
00176                 for($x = 25; $x <= 145; $x = $x+20)
00177                 {
00178                         if($startday > $lastday)
00179                         {
00180                                 if ($c0 == 5)
00181                                 {
00182                                         $c0 = 3;
00183                                 }
00184                                 else
00185                                 {
00186                                         $c0 = 5;
00187                                 }
00188                                 $startday = 1;          
00189                                 $monat1 = $month;
00190                                 $jahr1 = $year;
00191                                 if($month == 12)
00192                                 {
00193                                         $monat1 = 0;
00194                                         $jahr1 = $year + 1;
00195                                 }
00196                                 $lastday = strftime("%d.", mktime (0,0,0,$monat1+1,0,$jahr1));
00197                                 //Prüfung, ob Schaltjahr
00198                                 if($lastday == 29 && !date(L, mktime (0,0,0,$monat1+1,0,$jahr1))) $lastday = 28;
00199                         }
00200                         if($c0 == 5 && $startday == $tag)
00201                         {
00202                                 imagefilledrectangle ($im, $x-2, $y, $x+14, $y+13, $color[3]);
00203                                 if($startday == date("d")&& $year == date("Y") && $month == date("n"))
00204                                 {
00205                                         ImageString ($im, 3, $x, $y, $startday++ , $color[7]);  
00206                                 }
00207                                 else
00208                                 {
00209                                         ImageString ($im, 3, $x, $y, $startday++ , $color[4]);
00210                                 }
00211                         }
00212                         else if($c0 == 5 && $startday == date("d") && $year == date("Y") && $month == date("n"))
00213                         {
00214                                 ImageString ($im, 3, $x, $y, $startday++ , $color[7]);
00215                         }
00216                         else
00217                         {       
00218                                 ImageString ($im, 3, $x, $y, $startday++ , $color[$c0]);
00219                         }
00220                 }
00221         }
00222 
00223         return $im;
00224 } // end func
00225 
00226 
00233 function setMinicalendar($month, $year, $DP_Lang, $app)
00234 {
00235                 
00236         
00237         if(!$month || !$year)
00238         {
00239                 $month = date(m);
00240                 $year = date(Y);        
00241         }
00242 
00243 
00244         $lastday                = strftime("%d.", mktime (0,0,0,$month,0,$year));
00245         $firstday               = strftime ("%u", mktime(0,0,0,$month,1,$year))-2;
00246 
00247         if ($firstday == -1) $firstday = 6; 
00248         
00249         $startday = $lastday - $firstday;
00250 
00251         // generiere Bildmaps
00252         $minical_show = "
00253 <map name='Calendar'>"; 
00254         
00255         //Kalenderwoche
00256         $kw=strftime ("%V", mktime(0,0,0,$month,1,$year));
00257         $week_ts=mktime (0,0,0,$month,1,$year);
00258         if (date("w",$week_ts)==1) 
00259         {
00260                 $week_ts =  strtotime ("-1 week", $week_ts );
00261         }
00262         $x = 4;
00263         for($y = 66; $y <= 145; $y = $y+15)
00264         {
00265                         $x1 = $x + 15;
00266                         $y1 = $y + 15;
00267                         $minical_show = $minical_show. "
00268                         <area shape=rect coords='$x,$y,$x1,$y1' href='dateplaner.php?app=week&timestamp=$week_ts'>";
00269                         $week_ts= strtotime ("+1 week", $week_ts );
00270         }
00271 
00272 
00273         $c0 = false;
00274         for($y = 66; $y <= 145; $y = $y+15)
00275         {
00276                 for($x = 25; $x <= 145; $x = $x+20)
00277                 {
00278                         if($startday > $lastday || $startday == 1)
00279                         {
00280                                 if ($c0 == true)
00281                                 {
00282                                         $c0 = false;
00283                                 }
00284                                 else
00285                                 {
00286                                         $c0 = true;
00287                                 }
00288                                 $startday = 1;          
00289                                 $monat1 = $month;
00290                                 $jahr1 = $year;
00291                                 if($month == 12)
00292                                 {
00293                                         $monat1 = 0;
00294                                         $jahr1 = $year + 1;
00295                                 }
00296                                 $monat1 = $month+1;
00297                                 $lastday = strftime("%d.", mktime (0,0,0,$monat1,0,$jahr1));
00298                         }
00299                         if($c0)
00300                                 {
00301                                 $x1 = $x + 15;
00302                                 $y1 = $y + 15;
00303                                 $day_ts=mktime (0,0,0,$month,$startday,$year);
00304                                 $minical_show = $minical_show. "
00305         <area shape=rect coords='$x,$y,$x1,$y1' href='dateplaner.php?app=day&timestamp=$day_ts'>";
00306                         }
00307                         $startday++;
00308                 }
00309         }
00310 
00311         //Monatsnavigation
00312         $c0 = 1;
00313         for($y = 20; $y <= 40; $y = $y+13)
00314                 {
00315                 for($x = 5; $x <= 137; $x = $x+26)
00316                         {
00317                         $x1 = $x + 20;
00318                         $y1 = $y + 10;
00319                         $month_ts=mktime (0,0,0,$c0,1,$year);
00320                         $minical_show = $minical_show. "
00321         <area shape=rect coords='$x,$y,$x1,$y1' href='dateplaner.php?app=$app&month=$c0&year=$year&timestamp=$month_ts'>";
00322                         $c0++;
00323                 }       
00324         }
00325         $minical_show = $minical_show. "
00326         <area shape=rect coords='10,2,25,17' href='dateplaner.php?app=$app&month=$month&year=$year&action=last'>
00327         <area shape=rect coords='135,2,150,17' href='dateplaner.php?app=$app&month=$month&year=$year&action=next'>
00328 </map>
00329 
00330 <img src='.".DATEPLANER_ROOT_DIR."/includes/inc.minicalendar.php?action=show&month=".$month."&year=".$year."&DP_Lang=".$DP_Lang."' usemap='#Calendar' border=0>
00331 ";
00332         return $minical_show;
00333                 
00334 } // end func
00335 ?>

Generated on Fri Dec 13 2013 09:06:37 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1