Namespaces | Functions

modules/dateplaner/includes/inc.month.php File Reference

Go to the source code of this file.

Namespaces

namespace  dateplaner
 

dateplaner includes personal an group specific date management developt for ilias3 and adapted also to ilias2


Functions

 setNavigation ($timestamp)
 void function setNavigation($timestamp,$rowSpan) set variables in the navigation of week
 getDayInWeek ($week_ts)
 function getDayInWeek($week_ts) get number of a day into a week
 getContent ($start_ts, $end_ts, $DB)
 function getContent($start_ts, $end_ts) get Content for the Week View from the sortdates functions
 setDaysInMonth ($dayinmonth_ts, $DATE, &$style)
 void function setDaysInMonth($date_ts, $DATE, $style) set the Output for normal Dates into the Week view
 setMonthView ($week_ts, $week_s, $first_change, $DB)
 void function setMonthView($week_ts) the Main function of the month view called from the executed file

Function Documentation

getContent ( start_ts,
end_ts,
DB 
)

function getContent($start_ts, $end_ts) get Content for the Week View from the sortdates functions

Parameters:
int $begin_ts
int $end_ts
int $DB (object of th db class ) string $DP_UId ( actual User ID ) array $_SESSION ( Array DP_Keywords ( actual Keywords)
Returns:
Array [][][] $DATE [0] Dates ( normel Dates ) [1] WholeDates ( one day Dates )

Definition at line 112 of file inc.month.php.

References $_SESSION, $DB, $DP_UId, getDateList(), and getWholeDayDateList().

{
        global $DP_UId , $_SESSION ;

        $Dates                          = getDateList ($DP_UId, $start_ts, $end_ts, $_SESSION[DP_Keywords], $DB);
        $WholeDates                     = getWholeDayDateList ($DP_UId, $start_ts, $end_ts, $_SESSION[DP_Keywords], $DB);
        $DATE[0]=$Dates;
        $DATE[1]=$WholeDates;

        return $DATE;
} // end func

Here is the call graph for this function:

getDayInWeek ( week_ts  ) 

function getDayInWeek($week_ts) get number of a day into a week

Parameters:
int $week_ts
Returns:
string $daynumber

Definition at line 82 of file inc.month.php.

Referenced by setMonthView().

{

                $ttd            = new TimestampToDate;
                $ttd->ttd($week_ts);

                $daynumber      = $ttd->weekdaynumber ;

                // sunday is day 0 in standart , monday day 1
                // but we need that sunday is day 7 
                if ($daynumber==0) {
                        $daynumber=7;
                }

                return $daynumber;
}// end func

Here is the caller graph for this function:

setDaysInMonth ( dayinmonth_ts,
DATE,
&$  style 
)

void function setDaysInMonth($date_ts, $DATE, $style) set the Output for normal Dates into the Week view

Parameters:
int $date_ts
Array[][][] $DATE ( Date Data )
string $style ( to format rows, control variable ) Array $DP_language ( include Languageproperties ) array $DP_CSS ( contains CSS Strings from the conf.gui file ) Array $_SESSION ( include the Resolution, java script options ) sting $actualtemplate ( current template ) string $templatefolder ( current used template folder )
Returns:
string $month_float ( contains the output )

Definition at line 139 of file inc.month.php.

References $_SESSION, $actualtemplate, $DP_CSS, $DP_language, $Gui, $id, $month_float, and $templatefolder.

{
                global  $DP_language, $DP_CSS, $templatefolder, $actualtemplate, $_SESSION;

                $ttd            = new TimestampToDate;
                $Gui            = new Gui();
                $Dates          = $DATE[0];
                $WholeDates     = $DATE[1];

                $ttd->ttd($dayinmonth_ts);
                
                // if java script disabeld set standard view
                if($_SESSION[DP_ScreenWith] == "" or !$_SESSION[DP_ScreenWith]) {
                        $DP_ScreenHeight        = "768";
                        $DP_ScreenWith          = "1024" ;
                }else {
                        $DP_ScreenHeight        = $_SESSION[DP_ScreenHeight];
                        $DP_ScreenWith          = $_SESSION[DP_ScreenWith] ;
                }

                // change colour of months
                $day            = $ttd->day_of_month ;
                if ("01" == $day)
                {
                        if ($style == $DP_CSS[tblrow1]) 
                        { 
                                $style = $DP_CSS[tblrow2]; 
                        }
                        else                                                            
                        { 
                                $style = $DP_CSS[tblrow1]; 
                        }
                }

                // change table height for Browse comatibility
                // it depends on the the screen Height and width 
                if (!$DP_ScreenHeight)  
                {
                        $height                 ="15%"  ;
                }
                else 
                {
                        $height=(15*($DP_ScreenHeight - 150))/100       ;
                }

                if (!$DP_ScreenWith) 
                {
                        $shorttextmax2          = 9; // max lenght of shorttext in one day dates
                        $shorttextmax           = 5; // max lenght of shorttext in normal dates
                        $width                          ="13%"  ;
                }
                else 
                {
                        // Height an width dedected
                        $width=(13*($DP_ScreenWith - 180))/100  ;

                        switch ($DP_ScreenWith) 
                        {
                                case '800':
                                        $datesperdaymax         = 2 ; // max dates in a day 
                                        $shorttextmax           = 1 ; // max lenght of shorttext in normal dates
                                        $shorttextmax2          = 4 ; // max lenght of shorttext in one day dates
                                        break;
                                case '1024':
                                        $datesperdaymax         = 4 ; // max dates in a day 
                                        $shorttextmax           = 3 ; // max lenght of shorttext in normal dates
                                        $shorttextmax2          = 9 ; // max lenght of shorttext in one day dates
                                        break;
                                case '1280':
                                        $datesperdaymax         = 6 ; // max dates in a day 
                                        $shorttextmax           = 8 ; // max lenght of shorttext in normal dates
                                        $shorttextmax2          = 14; // max lenght of shorttext in one day dates
                                        break;
                                case '1600':
                                        $datesperdaymax         = 8 ; // max dates in a day 
                                        $shorttextmax           = 13; // max lenght of shorttext in normal dates
                                        $shorttextmax2          = 18; // max lenght of shorttext in one day dates
                                        break;
                                default :
                                        $datesperdaymax         = 4 ; // max dates in a day 
                                        $shorttextmax           = 3 ; // max lenght of shorttext in normal dates
                                        $shorttextmax2          = 9 ; // max lenght of shorttext in one day dates
                        }
                }

                $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 \" ";

                // if today change background
                if ($dayinmonth_ts >=  mktime(0,0,0) and $dayinmonth_ts <=  mktime(23,59,59)) 
                {
                        $month_float = $month_float."$DP_CSS[tblrow1] >";
                        $month_float = $month_float."
<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" style=\"border-collapse: collapse\" width=\"100%\" height=\"100%\">
                        ";
                }
                else 
                {
                        $month_float = $month_float.$style.">";
                        $month_float = $month_float."
<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" width=\"100%\" height=\"100%\">
                        ";
                }

                // if first day in Month display Month name
                if ("01" == $day) 
                {
                        $month_float = $month_float."
        <tr>
                <td height=\"8\" style=\"border-style: solid; border-width: 1\" $DP_CSS[tblheader] ><center><span $DP_CSS[small]>$ttd->monthname</span></center></td>
        </tr>
                        ";
                }

                $month_float = $month_float.'
        <tr>
            <td height="*" valign="top">
                        ';

                // filter Dates of the day out of the array
                $endofday_ts = mktime(23,59,59,$ttd->monthnumber,$ttd->day_of_month,$ttd->year_long);  
                
                // 1st - one day dates , cause more important 
                if($WholeDates) 
                {
                for ($i=0;$i<count($WholeDates);$i++) 
                {
                        if ($WholeDates[$i][1] >= $dayinmonth_ts and $WholeDates[$i][1] <= $endofday_ts)  
                        {
                                $datesperday++;
                                $ttd->ttd($WholeDates[$i][1]);

                                // count sting lenght
                                if (strlen ($WholeDates[$i][5]) >= $shorttextmax2) 
                                {
                                        $shortext = substr($WholeDates[$i][5], 0, $shorttextmax2)." ."; 
                                }
                                else 
                                {
                                        $shortext = $WholeDates[$i][5];
                                }
                                $alttag = $WholeDates[$i][5];

                                $text = $Dates[$i][6];
                                $id = rand(1,100);


                                if($_SESSION[DP_JSscript] != 1) {
                                        $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>"; 
                                }else {
                                        $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>"; 
                                        $month_float.= $Gui->setToolTip($starttime, $endtime, $Dates[$i][5], $text, $id );
                                }



                        }
                        if ($datesperdaymax == $datesperday) 
                        {
                                $month_float = $month_float."<span ".$DP_CSS[small]."><a href=\"dateplaner.php?app=day&timestamp=".$dayinmonth_ts."\">".$DP_language[more]."</a> </span>";
                                break ;  
                        }
                }
                }

                // 2nd - normal dates  
                if($Dates) 
                {
                for ($i=0;$i<count($Dates);$i++) 
                {
                        if ($Dates[$i][1] >= $dayinmonth_ts and $Dates[$i][1] <= $endofday_ts)  
                        {
                                $datesperday++;
                                $ttd->ttd($Dates[$i][1]);

                                // count sting lenght
                                if (strlen ($Dates[$i][5]) >= $shorttextmax) 
                                {
                                        $shortext = substr($Dates[$i][5], 0, $shorttextmax)." .."; 

                                }
                                else 
                                {
                                        $shortext = $Dates[$i][5];
                                }
                                $text = $Dates[$i][6];
                                $id = rand(101,200);
                                $starttime      = $ttd->hour_long.":".$ttd->minutes ;
                                $ttd->ttd($Dates[$i][2]);
                                $endtime        = $ttd->hour_long.":".$ttd->minutes ;
                                $alttag = $starttime." ".$DP_language[to]." ".$endtime." [ ".$Dates[$i][5]." ]";

                                if($_SESSION[DP_JSscript] != 1) {
                                        $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>"; 
                                }else {
                                        $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>"; 
                                        $month_float.= $Gui->setToolTip($starttime, $endtime, $Dates[$i][5], $text, $id );
                                }

                }
                        if ($datesperdaymax == $datesperday) {

                                $month_float = $month_float."<span ".$DP_CSS[small]."><a href=\"dateplaner.php?app=day&timestamp=".$dayinmonth_ts."\">".$DP_language[more]."</a> </span>";
                                break ;  
                        }
                }
                }

                // footer in days  

                $month_float = $month_float."
                                </center></strong>
            </td>
        </tr>
        <tr>
                <td height=\"8\">
                        <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]." >
                                <img border='0' src='.".DATEPLANER_ROOT_DIR.$templatefolder."/".$actualtemplate."/images/blind_1515.gif' width='15' height='15'  align='left' hspace='0'>
                        </a>    
                        <a href=\"dateplaner.php?app=day&timestamp=".$dayinmonth_ts."\" TITLE=\"".$DP_language[open_day]."\" ".$DP_CSS[navi_open].">
                                <img border='0' src='.".DATEPLANER_ROOT_DIR.$templatefolder."/".$actualtemplate."/images/blind_1515.gif' width='15' height='15' align='left' space='0'>
                        </a>
                </td>
        </tr>
</table>
                ";
                $month_float = $month_float."</td>";

                Return $month_float;

} // end func

setMonthView ( week_ts,
week_s,
first_change,
DB 
)

void function setMonthView($week_ts) the Main function of the month view called from the executed file

Parameters:
int $week_ts ( one timestamp in the week, which should be shown )
string $first_change ( control variable )
string $week_s ( control variable , identify the action source)
int $DB (object of th db class ) string $S_Datum ( contains Date from Table Top ) string $style ( to format rows, control variable ) array DP_CSS ( contains CSS Strings from the conf.gui file )
Returns:
Array $Return [0] string month_navigation ( contains the navigation output ) [1] string month_float ( contains the output ) [2] string month_string ( contains the month / year name for the output )

Definition at line 389 of file inc.month.php.

References $DB, $DP_CSS, $month_float, $month_string, getContent(), getDayInWeek(), and setNavigation().

{

        global $DP_CSS ;
        srand(microtime()*1000000);

        $ttd                                    = new TimestampToDate;
        $ttd->ttd($week_ts);
        $weeknumber                             = $ttd->weeknumber;
        $monthnumber                    = $ttd->monthnumber;
        $jahreszahl                             = $ttd->year_long;
        $firstDayInMonth_ts             = mktime(0,0,0,$monthnumber,1,$jahreszahl);             // first day of the month
        $month_string                   = $ttd->monthname." ".$ttd->year_long;

        // if there 31 days in month and the 1st is a saturday/sunday 
        // or if there 30 days in month and the 1st is a sunday than we have 6 weeks
        if (($ttd->anzahl_der_tage >= 30 and getDayInWeek($firstDayInMonth_ts) == 7) or 
                        ($ttd->anzahl_der_tage >= 31 and getDayInWeek($firstDayInMonth_ts) >= 6)) 
        {
                $weeks = 6;
        }
        else 
        {
                $weeks = 5;
        }
        

        // if the first change
        if ($first_change) {
                $month_navigation = setNavigation($firstDayInMonth_ts);
        }else {
                $month_navigation = setNavigation($week_ts);
        }

        $ttd->ttd($week_ts);

        // if the timestamp into the week , set to the first day 
        if ($ttd->weekdaynumber != 1 ) {                                                                                
                $week_ts = strtotime ("last Monday", $week_ts );
                $ttd->ttd($week_ts);
                // set 00:00.00 time
                $week_ts = mktime(0,0,0,$ttd->monthnumber,$ttd->day_of_month,$ttd->year_long);  
                $ttd->ttd($week_ts);
        }

        // catch Modnay before, to set month view weekly
        // if the navigation not used, take an other monday before
        if (!$week_s) 
        {                                                                                               
                $ttd->ttd($firstDayInMonth_ts);
                // if the timestamp into the week , set to the first day 
                if ($ttd->weekdaynumber != 1 ) 
                {                                                                               
                        $mondaybefore_ts = strtotime ("last Monday", $firstDayInMonth_ts );
                }
                else 
                {
                        $mondaybefore_ts = $firstDayInMonth_ts; 
                }
        }
        else 
        {
                $mondaybefore_ts = $week_ts;
        }


        $ttd->ttd($mondaybefore_ts);
        $weeknumber = $ttd->weeknumber;

        $dayinmonth_ts  = $mondaybefore_ts ;
        $style                  = $DP_CSS[tblrow1];

                                
        // set Month view start and End 
        $start_ts               = $dayinmonth_ts;
        $end_ts                 = strtotime ("+".$weeks." week", $week_ts );    
        $DATE                   = getContent($start_ts, $end_ts, $DB);

        
        // gerate Data for Output .. pass the month
        while($weeks > 0)
        { 
                for ($i=0;$i<=7;$i++) 
                {
                        if ($i==0) 
                        {
                                $month_float = $month_float."<tr>\n";
                                $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>";
                        }
                        else 
                        {
                                $month_float = $month_float.setDaysInMonth($dayinmonth_ts, $DATE, $style);
                                $dayinmonth_ts = strtotime ("+1 day", $dayinmonth_ts );
                        }
                        $ttd->ttd($dayinmonth_ts);
                }
                $weeknumber = $ttd->weeknumber;
                $month_float = $month_float."</tr>\n";
                $weeks--;
        }
        $month_float = $month_float."</tr>\n";

        $Return[0] = $month_navigation;
        $Return[1] = $month_float;
        $Return[2] = $month_string;

        Return  $Return;

}// end func

Here is the call graph for this function:

setNavigation ( timestamp  ) 

void function setNavigation($timestamp,$rowSpan) set variables in the navigation of week

Parameters:
int $timestamp string $month_navigation ( contains the output ) Array $DP_language ( include Languageproperties )

Definition at line 47 of file inc.month.php.

References $DP_language, and $Gui.

{

        global $DP_language;

        $Gui            = new Gui();
        $ttd            = new TimestampToDate;
        $rowSpan        = 6;

        $ttd->ttd($timestamp);
        $today          = mktime(0,0,0);
        $lastweek       = strtotime ("last week" , $timestamp) ;
        $nextweek       = strtotime ("+7 days" , $timestamp) ;

        $monthnumber    = $ttd->monthnumber;
        $jahreszahl     = $ttd->year_long;
        $timestamp      = mktime(0,0,0,$monthnumber,1,$jahreszahl);             // first day of the month
        $lastmonth      = strtotime ("last month", $timestamp) ;
        $nextmonth      = strtotime ("+1 month", $timestamp) ;
        $lastyear       = strtotime ("last year" , $timestamp) ;
        $nextyear       = strtotime ("+1 year" , $timestamp) ;

        eval ("\$month_navigation = \"".$Gui->gettemplate("month_navigation")."\";");

        Return $month_navigation;
        
} // end func