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

calendar/includes/inc.week.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 
00044 function setNavigation($timestamp,$rowSpan)
00045 {
00046         global $DP_language;
00047 
00048         $Gui            = new Gui();
00049 
00050         $today          = mktime(0,0,0);
00051         $lastweek       = strtotime ("last week" , $timestamp) ;
00052         $nextweek       = strtotime ("+7 days" , $timestamp) ;
00053         $rowSpan = $rowSpan+1;
00054 
00055         eval ("\$week_navigation = \"".$Gui->getTemplate("week_navigation")."\";");
00056 
00057         Return $week_navigation;
00058 
00059 } // end func
00060 
00061 
00068 function setDateInTblHead($timestamp)
00069 {
00070         $ttd                    = new TimestampToDate;
00071 
00072         $ttd->ttd($timestamp);
00073 
00074         $S_Datum[monday_full]           = $ttd->shorttime ;
00075         $S_Datum[monday_link]           = $timestamp ;
00076         $S_Datum[week]                          = $ttd->weeknumber;
00077 
00078         $ttd->ttd(strtotime ("+1 day" , $timestamp));
00079         $S_Datum[tuesday_full]          = $ttd->shorttime ;
00080         $S_Datum[tuesday_link]          = strtotime ("+1 day" , $timestamp) ;
00081 
00082         $ttd->ttd(strtotime ("+2 day" , $timestamp));
00083         $S_Datum[wednesday_full]        = $ttd->shorttime ;
00084         $S_Datum[wednesday_link]        = strtotime ("+2 day" , $timestamp) ;
00085 
00086         $ttd->ttd(strtotime ("+3 day" , $timestamp));
00087         $S_Datum[thursday_full]         = $ttd->shorttime ;
00088         $S_Datum[thursday_link]         = strtotime ("+3 day" , $timestamp) ;
00089 
00090         $ttd->ttd(strtotime ("+4 day" , $timestamp));
00091         $S_Datum[friday_full]           = $ttd->shorttime ;
00092         $S_Datum[friday_link]           = strtotime ("+4 day" , $timestamp) ;
00093 
00094         $ttd->ttd(strtotime ("+5 day" , $timestamp));
00095         $S_Datum[saturday_full]         = $ttd->shorttime ;
00096         $S_Datum[saturday_link]         = strtotime ("+5 day" , $timestamp) ;
00097 
00098         $ttd->ttd(strtotime ("+6 day" , $timestamp));
00099         $S_Datum[sunday_full]           = $ttd->shorttime ;
00100         $S_Datum[sunday_link]           = strtotime ("+6 day" , $timestamp) ;
00101 
00102         Return  $S_Datum; 
00103 
00104 } // end func
00105 
00118 function getContent($begin_ts, $end_ts, $DB)
00119 {
00120 
00121         global $DP_UId , $_SESSION ;
00122 
00123         $Dates                          = getDateList ($DP_UId, $begin_ts, $end_ts, $_SESSION[DP_Keywords], $DB);
00124         $WholeDates                     = getWholeDayDateList ($DP_UId, $begin_ts, $end_ts, $_SESSION[DP_Keywords], $DB);
00125         $DATE[0]=$Dates;
00126         $DATE[1]=$WholeDates;
00127         return $DATE;
00128 
00129 } // end func
00130 
00143 function setDatesInWeek($date_ts, $Dates, $day_ts, $row_height, &$style)
00144 {
00145 
00146                 global $DP_language, $DP_CSS, $_SESSION;
00147 
00148                 $ttd = new TimestampToDate;
00149                 $Gui = new Gui();
00150 
00151                 $datesperhalfhourmax    = 4 ; // max dates in a day
00152                 $shorttextmax                   = 10; // max lenght of shorttext in normal dates
00153                 $today_style                    = $DP_CSS[tblrow1];
00154 
00155                 $ttd->ttd($date_ts);
00156                 $day = $ttd->day_of_month ;
00157 
00158                 $week_float = $week_float."<td width=\"11%\" height=\"".$row_height."%\" style=\"border-style: solid;  border-width: 1 \"  ";
00159 
00160                 // if today change background
00161                 if ($date_ts >=  mktime(0,0,0) and $date_ts <=  mktime(23,59,59)) 
00162                 {
00163                         $week_float = $week_float.$today_style."  >";
00164                 }
00165                 else 
00166                 {
00167                         $week_float = $week_float.$style.">";
00168                 }
00169 
00170                 // filter Dates of the day out of the array
00171                 $datebeginend_ts = strtotime ("+30 minutes", $date_ts); 
00172                 for ($i=0;$i< count($Dates);$i++) 
00173                 {
00174                         if ($Dates[$i][1] >= $date_ts and $Dates[$i][1] < $datebeginend_ts)  
00175                         {
00176                                 $datesperhalfhour++;
00177                                 $ttd->ttd($Dates[$i][1]);
00178                                 // count sting lenght
00179                                 if (strlen ($Dates[$i][5]) >= $shorttextmax) 
00180                                 {
00181                                         $shortext = substr($Dates[$i][5], 0, $shorttextmax)." .."; 
00182                                 }
00183                                 else 
00184                                 {
00185                                         $shortext = $Dates[$i][5];
00186                                 }
00187                                 $starttime      = $ttd->hour_long.":".$ttd->minutes ;
00188 
00189                                 $ttd->ttd($Dates[$i][2]);
00190                                 $endtime        = $ttd->hour_long.":".$ttd->minutes ;
00191 
00192                                 $alttag         = $starttime." bis ".$endtime." [ ".$Dates[$i][5]." ]";
00193 
00194                                 $text = $Dates[$i][6];
00195                                 $id = rand(1,100);
00196 
00197                                 if($_SESSION[DP_JSscript] != 1 ) {
00198                                         $week_float = $week_float."<span ".$DP_CSS[small]."><a  TITLE=\"".$alttag."\" href=\"dateplaner.php?app=date&timestamp=".$day_ts."&date_id=".$Dates[$i][0]."&PHPSESSID=".session_id()."\" target=\"_blank\">".$starttime." - ".$endtime."</a> <br>".$shortext."</span><br>"; 
00199                                 }else {
00200                                         $week_float = $week_float."<span ".$DP_CSS[small]."><a onMouseOver=show('".$id."') onMouseOut=hide('".$id."')  href=\"javascript:popup('dateplaner.php?app=date&timestamp=".$day_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." - ".$endtime."</a> <br>".$shortext."</span><br>"; 
00201                                         $week_float.= $Gui->setToolTip($starttime, $endtime, $Dates[$i][5], $text, $id );
00202                                 }
00203 
00204                         }
00205 
00206                         if ($datesperhalfhourmax == $datesperhalfhour) 
00207                         {
00208                                 $week_float = $week_float."<span ".$DP_CSS[small]."><a href=\"day.php?timestamp=".$date_ts."\">".$DP_language[more]."</a> </span>";
00209                                 break ;  
00210                         }
00211                 }
00212 
00213                 $week_float = $week_float."</td>";      
00214 
00215                 Return $week_float;
00216 } // end func
00217 
00230 function setDayDatesInWeek($date_ts, $Dates, $row_height, &$style)
00231 {
00232                 global $DP_language, $DP_CSS, $_SESSION;
00233                 $ttd = new TimestampToDate;
00234                 $Gui = new Gui();
00235 
00236                 $datesperhalfhourmax    = 4 ; // maximale Termine pro Tag
00237                 $shorttextmax                   = 12; // maximale L�nge des shorttextes
00238 
00239                 $today_style                    = $DP_CSS[tblrow1];
00240 
00241                 $ttd->ttd($date_ts);
00242                 $day = $ttd->day_of_month ;
00243 
00244                 $week_float = $week_float."<td width=\"11%\" height=\"".$row_height."%\" style=\"border-style: solid;  border-width: 1 \" ";
00245 
00246                 // if today change background
00247                 if ($date_ts >=  mktime(0,0,0) and $date_ts <=  mktime(23,59,59)) 
00248                 {
00249                         $week_float = $week_float.$today_style."  >";
00250                 }
00251                 else 
00252                 {
00253                         $week_float = $week_float.$style.">";
00254                 }
00255 
00256                 // filter Dates of the day out of the array
00257                 $dayend_ts = strtotime ("+23 hours +59 minutes +59 seconds", $date_ts); 
00258                 for ($i=0;$i< count($Dates);$i++) 
00259                 {
00260                         if ($Dates[$i][1] >= $date_ts and $Dates[$i][2] <= $dayend_ts)  
00261                         {
00262                                 $datesperhalfhour++;
00263                                 $ttd->ttd($Dates[$i][1]);
00264 
00265                                 // count sting lenght
00266                                 if (strlen ($Dates[$i][5]) >= $shorttextmax) 
00267                                 {
00268                                         $shortext = substr($Dates[$i][5], 0, $shorttextmax)." .."; 
00269                                 }
00270                                 else 
00271                                 {
00272                                         $shortext = $Dates[$i][5];
00273                                 }
00274                                 $alttag         = " [ ".$Dates[$i][5]." ]";
00275 
00276                                 $text = $Dates[$i][6];
00277                                 $id = rand(100,200);
00278 
00279 
00280                                 if($_SESSION[DP_JSscript] != 1 ) {
00281                                         $week_float = $week_float."<span ".$DP_CSS[small]."><a  TITLE=\"".$alttag."\" href=\"dateplaner.php?app=date&timestamp=".$day_ts."&date_id=".$Dates[$i][0]."&PHPSESSID=".session_id()."\" target=\"_blank\"><b>".$shortext."</b></a> </span><br>"; 
00282                                 }else {
00283                                         $week_float = $week_float."<span ".$DP_CSS[small]."><a onMouseOver=show('".$id."') onMouseOut=hide('".$id."')  href=\"javascript:popup('dateplaner.php?app=date&timestamp=".$date_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')\" ><b>".$shortext."</b></a></span><br>"; 
00284                                         $week_float.= $Gui->setToolTip($starttime, $endtime, $Dates[$i][5], $text, $id );
00285                                 }
00286 
00287 
00288 
00289                         }
00290                         if ($datesperhalfhourmax == $datesperhalfhour) 
00291                         {
00292                                 $week_float = $week_float."<span ".$DP_CSS[small]."><a href=\"day.php?timestamp=".$date_ts."\">".$DP_language[more]."</a> </span>";
00293                                 break ;  
00294                         }
00295                 }
00296 
00297                 $week_float = $week_float."</td>";
00298                 Return $week_float;
00299 } // end func
00300 
00317 function setWeekView($week_ts, $DB)
00318 
00319 {
00320         global $DP_language, $DP_CSS, $_SESSION;
00321 
00322         srand(microtime()*1000000);
00323 
00324         // time period for view
00325 
00326         $from_time      = $_SESSION[DP_Starttime]; 
00327         $to_time        = $_SESSION[DP_Endtime];
00328 
00329         $ttd = new TimestampToDate;
00330 
00331         $ttd->ttd($week_ts);
00332 
00333         // if the timestamp into the week , set to the first day 
00334         if ($ttd->weekdaynumber != 1 ) 
00335         {                                                                               
00336                 $week_ts = strtotime ("last Monday", $week_ts );
00337                 $ttd->ttd($week_ts);
00338         }
00339 
00340         $week_ts = mktime(0,0,0,$ttd->monthnumber,$ttd->day_of_month,$ttd->year_long);  
00341         $ttd->ttd($week_ts);
00342 
00343         // set Week view start and End time
00344         $start_ts       = $week_ts;
00345         $end_ts         = strtotime ("+6 days 23 hours 59 minutes 59 seconds", $week_ts );      
00346         $DATE           = getContent($start_ts, $end_ts, $DB);
00347         $Dates          = $DATE[0];
00348         $WholeDates     = $DATE[1];
00349 
00350         // take care that no date begin or end after time zone above
00351         // if it, enhance time zone
00352         if($Dates) 
00353         {
00354         for ($i=0;$i< count($Dates);$i++) 
00355         {
00356                 $ttdend = new TimestampToDate;
00357                 $ttdend->ttd($Dates[$i][2]);
00358 
00359                 $end = $ttdend->hour_long.":".$ttdend->minutes.":".$ttdend->seconds;
00360 
00361                 $ttd->ttd($Dates[$i][1]);
00362                 $begin = $ttd->hour_long.":".$ttd->minutes.":".$ttd->seconds;
00363 
00364                 if ($ttd->hour_short <= (int)$from_time )  
00365                 {
00366                         $from_time = $ttd->hour_short;
00367                 }
00368                 if ($ttdend->hour_short >= (int)$to_time) 
00369                 {
00370                         $to_time = $ttdend->hour_short+1;
00371                 }
00372         }
00373         }
00374 
00375         // count rows for view
00376         $rows           = (($to_time - $from_time)*2)+1;
00377         // count rows height , best compatibility
00378         $row_height = 100/$rows;
00379 
00380         $week_navigation        = setNavigation($week_ts,$rows);
00381         $S_Datum                        = setDateInTblHead($week_ts) ;
00382 
00383         $monatstag_ts   = $week_ts;
00384     $style                      = $DP_CSS[tblrow2];
00385 
00386         // 1st - one day dates , cause more important 
00387         $c_rows = 0;
00388         for ($i=0;$i<=7;$i++) 
00389         {
00390 
00391                 if ($i==0) 
00392                 {
00393                         $week_float = $week_float."<tr >\n";
00394                         $week_float = $week_float."<td width=\"4%\" height=\"".$row_height."%\" style=\"border-style: solid;  border-width: 1\" $DP_CSS[tblrow2] ><center>".$DP_language[o_day_date]."<center></td>";
00395                 }
00396                 else 
00397                 {
00398                         $week_float = $week_float.setDayDatesInWeek($monatstag_ts, $WholeDates, $row_height, $style);
00399                         $monatstag_ts = strtotime ("+1 day", $monatstag_ts );
00400                 }
00401                         $ttd->ttd($monatstag_ts);
00402         }
00403 
00404         $week_float             = $week_float."</tr>\n";
00405         $c_rows++;
00406         $ttd->ttd($week_ts);
00407         $week_ts                = mktime($from_time,0,0,$ttd->monthnumber,$ttd->day_of_month,$ttd->year_long);
00408         $monatstag_ts   = $week_ts;
00409         $style                  = $DP_CSS[tblrow2];
00410         $day_ts                 = mktime(0,0,0,$ttd->monthnumber,$ttd->day_of_month,$ttd->year_long);
00411         
00412         // 2nd - normal dates  
00413         while($c_rows < $rows)
00414         { 
00415                 for ($i=0;$i<=7;$i++) 
00416                 {
00417                         if ($i==0) 
00418                         {
00419                         // set time in left row
00420                                 $time = (($c_rows-1)/2)+$from_time;
00421                                 if (floor($time)!=0) 
00422                                 {
00423                                         if (($time/floor($time)) > 1) 
00424                                         {
00425                                                 $time = floor ($time).":30";
00426                                         }
00427                                         else 
00428                                         {
00429                                                 $time = $time.":00";
00430                                         }
00431 
00432                                 }
00433                                 else 
00434                                 {
00435                                         if (round ($time)==1) 
00436                                         {
00437                                                 $time = "0:30";
00438                                         }
00439                                         else 
00440                                         {
00441                                                 $time = "0:00";
00442                                         }
00443                                 }
00444                                 $week_float = $week_float."<tr >\n";
00445                                 $week_float = $week_float."<td width=\"4%\" height=\"".$row_height."%\" style=\"border-style: solid;  border-width: 1\" $DP_CSS[tblrow2] ><center>".$time."<center></td>";
00446                         }
00447                         else 
00448                         {
00449                                 $week_float     = $week_float.setDatesInWeek($monatstag_ts, $Dates, $day_ts, $row_height, $style);
00450                                 $monatstag_ts = strtotime ("+1 day", $monatstag_ts );
00451 
00452                         }
00453                         $ttd->ttd($monatstag_ts);
00454                         $day_ts                 = mktime(0,0,0,$ttd->monthnumber,$ttd->day_of_month,$ttd->year_long);
00455                 }
00456                 $week_ts                = strtotime ("+30 minutes", $week_ts);  
00457                 $monatstag_ts   = $week_ts ;
00458                 $week_float             = $week_float."</tr>\n";
00459                 $c_rows++;
00460         }
00461         $week_float = $week_float."</tr>\n";
00462 
00463         $Return[0] = $week_navigation;
00464         $Return[1] = $week_float;
00465         $Return[2] = $S_Datum;
00466 
00467         Return $Return;
00468 }//end func
00469 ?>

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