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

Generated on Fri Dec 13 2013 10:18:31 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1