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

modules/dateplaner/includes/inc.month.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 
00047 function setNavigation($timestamp)
00048 
00049 {
00050 
00051         global $DP_language;
00052 
00053         $Gui            = new Gui();
00054         $ttd            = new TimestampToDate;
00055         $rowSpan        = 6;
00056 
00057         $ttd->ttd($timestamp);
00058         $today          = mktime(0,0,0);
00059         $lastweek       = strtotime ("last week" , $timestamp) ;
00060         $nextweek       = strtotime ("+7 days" , $timestamp) ;
00061 
00062         $monthnumber    = $ttd->monthnumber;
00063         $jahreszahl     = $ttd->year_long;
00064         $timestamp      = mktime(0,0,0,$monthnumber,1,$jahreszahl);             // first day of the month
00065         $lastmonth      = strtotime ("last month", $timestamp) ;
00066         $nextmonth      = strtotime ("+1 month", $timestamp) ;
00067         $lastyear       = strtotime ("last year" , $timestamp) ;
00068         $nextyear       = strtotime ("+1 year" , $timestamp) ;
00069 
00070         eval ("\$month_navigation = \"".$Gui->gettemplate("month_navigation")."\";");
00071 
00072         Return $month_navigation;
00073         
00074 } // end func
00075 
00082 function getDayInWeek($week_ts) 
00083 {
00084 
00085                 $ttd            = new TimestampToDate;
00086                 $ttd->ttd($week_ts);
00087 
00088                 $daynumber      = $ttd->weekdaynumber ;
00089 
00090                 // sunday is day 0 in standart , monday day 1
00091                 // but we need that sunday is day 7 
00092                 if ($daynumber==0) {
00093                         $daynumber=7;
00094                 }
00095 
00096                 return $daynumber;
00097 }// end func
00098 
00099 
00112 function getContent($start_ts, $end_ts, $DB)
00113 
00114 {
00115         global $DP_UId , $_SESSION ;
00116 
00117         $Dates                          = getDateList ($DP_UId, $start_ts, $end_ts, $_SESSION[DP_Keywords], $DB);
00118         $WholeDates                     = getWholeDayDateList ($DP_UId, $start_ts, $end_ts, $_SESSION[DP_Keywords], $DB);
00119         $DATE[0]=$Dates;
00120         $DATE[1]=$WholeDates;
00121 
00122         return $DATE;
00123 } // end func
00124 
00139 function setDaysInMonth($dayinmonth_ts, $DATE, &$style)
00140 
00141 {
00142                 global  $DP_language, $DP_CSS, $templatefolder, $actualtemplate, $_SESSION;
00143 
00144                 $ttd            = new TimestampToDate;
00145                 $Gui            = new Gui();
00146                 $Dates          = $DATE[0];
00147                 $WholeDates     = $DATE[1];
00148 
00149                 $ttd->ttd($dayinmonth_ts);
00150                 
00151                 // if java script disabeld set standard view
00152                 if($_SESSION[DP_ScreenWith] == "" or !$_SESSION[DP_ScreenWith]) {
00153                         $DP_ScreenHeight        = "768";
00154                         $DP_ScreenWith          = "1024" ;
00155                 }else {
00156                         $DP_ScreenHeight        = $_SESSION[DP_ScreenHeight];
00157                         $DP_ScreenWith          = $_SESSION[DP_ScreenWith] ;
00158                 }
00159 
00160                 // change colour of months
00161                 $day            = $ttd->day_of_month ;
00162                 if ("01" == $day)
00163                 {
00164                         if ($style == $DP_CSS[tblrow1]) 
00165                         { 
00166                                 $style = $DP_CSS[tblrow2]; 
00167                         }
00168                         else                                                            
00169                         { 
00170                                 $style = $DP_CSS[tblrow1]; 
00171                         }
00172                 }
00173 
00174                 // change table height for Browse comatibility
00175                 // it depends on the the screen Height and width 
00176                 if (!$DP_ScreenHeight)  
00177                 {
00178                         $height                 ="15%"  ;
00179                 }
00180                 else 
00181                 {
00182                         $height=(15*($DP_ScreenHeight - 150))/100       ;
00183                 }
00184 
00185                 if (!$DP_ScreenWith) 
00186                 {
00187                         $shorttextmax2          = 9; // max lenght of shorttext in one day dates
00188                         $shorttextmax           = 5; // max lenght of shorttext in normal dates
00189                         $width                          ="13%"  ;
00190                 }
00191                 else 
00192                 {
00193                         // Height an width dedected
00194                         $width=(13*($DP_ScreenWith - 180))/100  ;
00195 
00196                         switch ($DP_ScreenWith) 
00197                         {
00198                                 case '800':
00199                                         $datesperdaymax         = 2 ; // max dates in a day 
00200                                         $shorttextmax           = 1 ; // max lenght of shorttext in normal dates
00201                                         $shorttextmax2          = 4 ; // max lenght of shorttext in one day dates
00202                                         break;
00203                                 case '1024':
00204                                         $datesperdaymax         = 4 ; // max dates in a day 
00205                                         $shorttextmax           = 3 ; // max lenght of shorttext in normal dates
00206                                         $shorttextmax2          = 9 ; // max lenght of shorttext in one day dates
00207                                         break;
00208                                 case '1280':
00209                                         $datesperdaymax         = 6 ; // max dates in a day 
00210                                         $shorttextmax           = 8 ; // max lenght of shorttext in normal dates
00211                                         $shorttextmax2          = 14; // max lenght of shorttext in one day dates
00212                                         break;
00213                                 case '1600':
00214                                         $datesperdaymax         = 8 ; // max dates in a day 
00215                                         $shorttextmax           = 13; // max lenght of shorttext in normal dates
00216                                         $shorttextmax2          = 18; // max lenght of shorttext in one day dates
00217                                         break;
00218                                 default :
00219                                         $datesperdaymax         = 4 ; // max dates in a day 
00220                                         $shorttextmax           = 3 ; // max lenght of shorttext in normal dates
00221                                         $shorttextmax2          = 9 ; // max lenght of shorttext in one day dates
00222                         }
00223                 }
00224 
00225                 $month_float = $month_float."<td width=\"".$width."\" height=\"".$height."\" valign=\"top\" style=\"border-style: solid;  border-width: 1; background-image:url(.".DATEPLANER_ROOT_DIR.$templatefolder."/".$actualtemplate."/images/".$day.".gif); background-repeat:no-repeat ; background-position:center center \" ";
00226 
00227                 // if today change background
00228                 if ($dayinmonth_ts >=  mktime(0,0,0) and $dayinmonth_ts <=  mktime(23,59,59)) 
00229                 {
00230                         $month_float = $month_float."$DP_CSS[tblrow1] >";
00231                         $month_float = $month_float."
00232 <table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" style=\"border-collapse: collapse\" width=\"100%\" height=\"100%\">
00233                         ";
00234                 }
00235                 else 
00236                 {
00237                         $month_float = $month_float.$style.">";
00238                         $month_float = $month_float."
00239 <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" width=\"100%\" height=\"100%\">
00240                         ";
00241                 }
00242 
00243                 // if first day in Month display Month name
00244                 if ("01" == $day) 
00245                 {
00246                         $month_float = $month_float."
00247         <tr>
00248                 <td height=\"8\" style=\"border-style: solid; border-width: 1\" $DP_CSS[tblheader] ><center><span $DP_CSS[small]>$ttd->monthname</span></center></td>
00249         </tr>
00250                         ";
00251                 }
00252 
00253                 $month_float = $month_float.'
00254         <tr>
00255             <td height="*" valign="top">
00256                         ';
00257 
00258                 // filter Dates of the day out of the array
00259                 $endofday_ts = mktime(23,59,59,$ttd->monthnumber,$ttd->day_of_month,$ttd->year_long);  
00260                 
00261                 // 1st - one day dates , cause more important 
00262                 if($WholeDates) 
00263                 {
00264                 for ($i=0;$i<count($WholeDates);$i++) 
00265                 {
00266                         if ($WholeDates[$i][1] >= $dayinmonth_ts and $WholeDates[$i][1] <= $endofday_ts)  
00267                         {
00268                                 $datesperday++;
00269                                 $ttd->ttd($WholeDates[$i][1]);
00270 
00271                                 // count sting lenght
00272                                 if (strlen ($WholeDates[$i][5]) >= $shorttextmax2) 
00273                                 {
00274                                         $shortext = substr($WholeDates[$i][5], 0, $shorttextmax2)." ."; 
00275                                 }
00276                                 else 
00277                                 {
00278                                         $shortext = $WholeDates[$i][5];
00279                                 }
00280                                 $alttag = $WholeDates[$i][5];
00281 
00282                                 $text = $Dates[$i][6];
00283                                 $id = rand(1,100);
00284 
00285 
00286                                 if($_SESSION[DP_JSscript] != 1) {
00287                                         $month_float = $month_float."<span ".$DP_CSS[small]."><a TITLE=\"".$alttag."\" href=\"dateplaner.php?app=date&timestamp=".$dayinmonth_ts."&date_id=".$WholeDates[$i][0]."&PHPSESSID=".session_id()."\" target=\"_blank\" >".$shortext."</a> </span><br>"; 
00288                                 }else {
00289                                         $month_float = $month_float."<span ".$DP_CSS[small]."><a onMouseOver=show('".$id."') onMouseOut=hide('".$id."')  href=\"javascript:popup('dateplaner.php?app=date&timestamp=".$dayinmonth_ts."&date_id=".$WholeDates[$i][0]."&PHPSESSID=".session_id()."','Date','width=600,height=650,directories=no,toolbar=no,location=no,menubar=no,scrollbars=yes,status=yes,resizable=yes,dependent=no')\" >".$shortext."</a> </span><br>"; 
00290                                         $month_float.= $Gui->setToolTip($starttime, $endtime, $Dates[$i][5], $text, $id );
00291                                 }
00292 
00293 
00294 
00295                         }
00296                         if ($datesperdaymax == $datesperday) 
00297                         {
00298                                 $month_float = $month_float."<span ".$DP_CSS[small]."><a href=\"dateplaner.php?app=day&timestamp=".$dayinmonth_ts."\">".$DP_language[more]."</a> </span>";
00299                                 break ;  
00300                         }
00301                 }
00302                 }
00303 
00304                 // 2nd - normal dates  
00305                 if($Dates) 
00306                 {
00307                 for ($i=0;$i<count($Dates);$i++) 
00308                 {
00309                         if ($Dates[$i][1] >= $dayinmonth_ts and $Dates[$i][1] <= $endofday_ts)  
00310                         {
00311                                 $datesperday++;
00312                                 $ttd->ttd($Dates[$i][1]);
00313 
00314                                 // count sting lenght
00315                                 if (strlen ($Dates[$i][5]) >= $shorttextmax) 
00316                                 {
00317                                         $shortext = substr($Dates[$i][5], 0, $shorttextmax)." .."; 
00318 
00319                                 }
00320                                 else 
00321                                 {
00322                                         $shortext = $Dates[$i][5];
00323                                 }
00324                                 $text = $Dates[$i][6];
00325                                 $id = rand(101,200);
00326                                 $starttime      = $ttd->hour_long.":".$ttd->minutes ;
00327                                 $ttd->ttd($Dates[$i][2]);
00328                                 $endtime        = $ttd->hour_long.":".$ttd->minutes ;
00329                                 $alttag = $starttime." ".$DP_language[to]." ".$endtime." [ ".$Dates[$i][5]." ]";
00330 
00331                                 if($_SESSION[DP_JSscript] != 1) {
00332                                         $month_float = $month_float."<span ".$DP_CSS[small]."><a TITLE=\"".$alttag."\" href=\"dateplaner.php?app=date&timestamp=".$dayinmonth_ts."&date_id=".$Dates[$i][0]."&PHPSESSID=".session_id()."\" target=\"_blank\" >".$starttime."</a> - ".$shortext."</a> </span><br>"; 
00333                                 }else {
00334                                         $month_float = $month_float."<span ".$DP_CSS[small]."><a onMouseOver=show('".$id."') onMouseOut=hide('".$id."')   href=\"javascript:popup('dateplaner.php?app=date&timestamp=".$dayinmonth_ts."&date_id=".$Dates[$i][0]."&PHPSESSID=".session_id()."','Date','width=600,height=650,directories=no,toolbar=no,location=no,menubar=no,scrollbars=yes,status=yes,resizable=yes,dependent=no')\" >".$starttime."</a> - ".$shortext." </span><br>"; 
00335                                         $month_float.= $Gui->setToolTip($starttime, $endtime, $Dates[$i][5], $text, $id );
00336                                 }
00337 
00338                 }
00339                         if ($datesperdaymax == $datesperday) {
00340 
00341                                 $month_float = $month_float."<span ".$DP_CSS[small]."><a href=\"dateplaner.php?app=day&timestamp=".$dayinmonth_ts."\">".$DP_language[more]."</a> </span>";
00342                                 break ;  
00343                         }
00344                 }
00345                 }
00346 
00347                 // footer in days  
00348 
00349                 $month_float = $month_float."
00350                                 </center></strong>
00351             </td>
00352         </tr>
00353         <tr>
00354                 <td height=\"8\">
00355                         <a href=\"javascript:popup('dateplaner.php?app=date&timestamp=".$dayinmonth_ts."&PHPSESSID=$PHPSESSID','Date','width=600,height=650,directories=no,toolbar=no,location=no,menubar=no,scrollbars=yes,status=yes,resizable=yes,dependent=no')\" TITLE=\"".$DP_language[new_doc]."\" ".$DP_CSS[navi_new]." >
00356                                 <img border='0' src='.".DATEPLANER_ROOT_DIR.$templatefolder."/".$actualtemplate."/images/blind_1515.gif' width='15' height='15'  align='left' hspace='0'>
00357                         </a>    
00358                         <a href=\"dateplaner.php?app=day&timestamp=".$dayinmonth_ts."\" TITLE=\"".$DP_language[open_day]."\" ".$DP_CSS[navi_open].">
00359                                 <img border='0' src='.".DATEPLANER_ROOT_DIR.$templatefolder."/".$actualtemplate."/images/blind_1515.gif' width='15' height='15' align='left' space='0'>
00360                         </a>
00361                 </td>
00362         </tr>
00363 </table>
00364                 ";
00365                 $month_float = $month_float."</td>";
00366 
00367                 Return $month_float;
00368 
00369 } // end func
00370 
00371 
00372 
00389 function setMonthView($week_ts, $week_s, $first_change, $DB)
00390 {
00391 
00392         global $DP_CSS ;
00393         srand(microtime()*1000000);
00394 
00395         $ttd                                    = new TimestampToDate;
00396         $ttd->ttd($week_ts);
00397         $weeknumber                             = $ttd->weeknumber;
00398         $monthnumber                    = $ttd->monthnumber;
00399         $jahreszahl                             = $ttd->year_long;
00400         $firstDayInMonth_ts             = mktime(0,0,0,$monthnumber,1,$jahreszahl);             // first day of the month
00401         $month_string                   = $ttd->monthname." ".$ttd->year_long;
00402 
00403         // if there 31 days in month and the 1st is a saturday/sunday 
00404         // or if there 30 days in month and the 1st is a sunday than we have 6 weeks
00405         if (($ttd->anzahl_der_tage >= 30 and getDayInWeek($firstDayInMonth_ts) == 7) or 
00406                         ($ttd->anzahl_der_tage >= 31 and getDayInWeek($firstDayInMonth_ts) >= 6)) 
00407         {
00408                 $weeks = 6;
00409         }
00410         else 
00411         {
00412                 $weeks = 5;
00413         }
00414         
00415 
00416         // if the first change
00417         if ($first_change) {
00418                 $month_navigation = setNavigation($firstDayInMonth_ts);
00419         }else {
00420                 $month_navigation = setNavigation($week_ts);
00421         }
00422 
00423         $ttd->ttd($week_ts);
00424 
00425         // if the timestamp into the week , set to the first day 
00426         if ($ttd->weekdaynumber != 1 ) {                                                                                
00427                 $week_ts = strtotime ("last Monday", $week_ts );
00428                 $ttd->ttd($week_ts);
00429                 // set 00:00.00 time
00430                 $week_ts = mktime(0,0,0,$ttd->monthnumber,$ttd->day_of_month,$ttd->year_long);  
00431                 $ttd->ttd($week_ts);
00432         }
00433 
00434         // catch Modnay before, to set month view weekly
00435         // if the navigation not used, take an other monday before
00436         if (!$week_s) 
00437         {                                                                                               
00438                 $ttd->ttd($firstDayInMonth_ts);
00439                 // if the timestamp into the week , set to the first day 
00440                 if ($ttd->weekdaynumber != 1 ) 
00441                 {                                                                               
00442                         $mondaybefore_ts = strtotime ("last Monday", $firstDayInMonth_ts );
00443                 }
00444                 else 
00445                 {
00446                         $mondaybefore_ts = $firstDayInMonth_ts; 
00447                 }
00448         }
00449         else 
00450         {
00451                 $mondaybefore_ts = $week_ts;
00452         }
00453 
00454 
00455         $ttd->ttd($mondaybefore_ts);
00456         $weeknumber = $ttd->weeknumber;
00457 
00458         $dayinmonth_ts  = $mondaybefore_ts ;
00459         $style                  = $DP_CSS[tblrow1];
00460 
00461                                 
00462         // set Month view start and End 
00463         $start_ts               = $dayinmonth_ts;
00464         $end_ts                 = strtotime ("+".$weeks." week", $week_ts );    
00465         $DATE                   = getContent($start_ts, $end_ts, $DB);
00466 
00467         
00468         // gerate Data for Output .. pass the month
00469         while($weeks > 0)
00470         { 
00471                 for ($i=0;$i<=7;$i++) 
00472                 {
00473                         if ($i==0) 
00474                         {
00475                                 $month_float = $month_float."<tr>\n";
00476                                 $month_float = $month_float."<td width=\"4%\" style=\"border-style: solid; border-width: 1\" $DP_CSS[tblrow2] ><center><a href=\"dateplaner.php?app=week&timestamp=".$dayinmonth_ts."\">".$weeknumber."</a><center></td>";
00477                         }
00478                         else 
00479                         {
00480                                 $month_float = $month_float.setDaysInMonth($dayinmonth_ts, $DATE, $style);
00481                                 $dayinmonth_ts = strtotime ("+1 day", $dayinmonth_ts );
00482                         }
00483                         $ttd->ttd($dayinmonth_ts);
00484                 }
00485                 $weeknumber = $ttd->weeknumber;
00486                 $month_float = $month_float."</tr>\n";
00487                 $weeks--;
00488         }
00489         $month_float = $month_float."</tr>\n";
00490 
00491         $Return[0] = $month_navigation;
00492         $Return[1] = $month_float;
00493         $Return[2] = $month_string;
00494 
00495         Return  $Return;
00496 
00497 }// end func
00498 ?>

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