00001 <?php 00002 00014 require_once "./classes/Calendar/class.ilAppointment.php"; 00015 00016 class ilCalendarTools 00017 { 00018 var $months = array(1 => "Januar", 00019 2 => "Februar", 00020 3 => "März", 00021 4 => "April", 00022 5 => "Mai", 00023 6 => "Juni", 00024 7 => "Juli", 00025 8 => "August", 00026 9 => "September", 00027 10 => "Oktober", 00028 11 => "November", 00029 12 => "Dezember"); 00030 00031 var $shortMonths = array(1 => "Jan", 00032 2 => "Feb", 00033 3 => "Mrz", 00034 4 => "Apr", 00035 5 => "Mai", 00036 6 => "Jun", 00037 7 => "Jul", 00038 8 => "Aug", 00039 9 => "Sep", 00040 10 => "Okt", 00041 11 => "Nov", 00042 12 => "Dez"); 00043 00044 var $weekdays = array(1 => "Montag", 00045 2 => "Dienstag", 00046 3 => "Mittwoch", 00047 4 => "Donnerstag", 00048 5 => "Freitag", 00049 6 => "Samstag", 00050 7 => "Sonntag",); 00051 00052 var $shortWeekdays = array(1 => "Mo", 00053 2 => "Di", 00054 3 => "Mi", 00055 4 => "Do", 00056 5 => "Fr", 00057 6 => "Sa", 00058 7 => "So"); 00059 00060 var $daymapping = array(7,1,2,3,4,5,6); 00061 00062 function getMonth($month) { 00063 return $this->months[$month]; 00064 } 00065 00066 function getShortMonth($month) { 00067 return $this->shortMonths[$month]; 00068 } 00069 00070 function getMappedWeekday($wday) { 00071 return $this->weekdays[$this->daymapping[$wday]]; 00072 } 00073 00074 function getMappedShortWeekday($wday) { 00075 return $this->shortWeekdays[$this->daymapping[$wday]]; 00076 } 00077 00078 function getWeekday($wday) { 00079 return $this->weekdays[$wday]; 00080 } 00081 00082 function getShortWeekday($wday) { 00083 return $this->shortWeekdays[$wday]; 00084 } 00085 00086 function getNumOfDays($month, $year) { 00087 return date("t", mktime(0,0,0,$month,1,$year)); 00088 } 00089 00090 function getNumOfDaysTS($timestamp) { 00091 return date("t", $timestamp); 00092 } 00093 00094 function getFirstWeekday($month, $year=0) { 00095 if ($year == 0) 00096 $year=date("Y"); 00097 $weekdayFirstDay = date("w", mktime(0,0,0,$month,1,$year)); 00098 if ($weekdayFirstDay == 0) 00099 $weekdayFirstDay = 7; 00100 return $weekdayFirstDay; 00101 } 00102 00103 function getBeginningDay($chosenDateTS) { 00104 if(date("w", $chosenDateTS) == 1) 00105 return $chosenDateTS; 00106 else 00107 return strtotime("last Monday", $chosenDateTS); 00108 } 00109 00110 function addLeadingZero($number) { 00111 if ($number < 10) 00112 return "0".$number; 00113 else 00114 return $number; 00115 } 00116 00117 function getWeek($ts) { 00118 return date("W", $ts); 00119 } 00120 00121 function compareTSYear($ts1, $ts2) { 00122 $tsa1 = getdate($ts1); 00123 $tsa2 = getdate($ts2); 00124 if ($tsa1["year"] == $tsa2["year"]) 00125 return TRUE; 00126 else 00127 return FALSE; 00128 } 00129 00130 function compareTSMonth($ts1, $ts2) { 00131 $tsa1 = getdate($ts1); 00132 $tsa2 = getdate($ts2); 00133 if ( $tsa1["year"] == $tsa2["year"] 00134 && $tsa1["mon"] == $tsa2["mon"] ) 00135 return TRUE; 00136 else 00137 return FALSE; 00138 } 00139 00140 function compareTSDate($ts1, $ts2) { 00141 $tsa1 = getdate($ts1); 00142 $tsa2 = getdate($ts2); 00143 if ( $tsa1["year"] == $tsa2["year"] 00144 && $tsa1["mon"] == $tsa2["mon"] 00145 && $tsa1["mday"] == $tsa2["mday"]) 00146 return TRUE; 00147 else 00148 return FALSE; 00149 } 00150 00151 function compareTSHour($ts1, $ts2) { 00152 $tsa1 = getdate($ts1); 00153 $tsa2 = getdate($ts2); 00154 if ( $tsa1["year"] == $tsa2["year"] 00155 && $tsa1["mon"] == $tsa2["mon"] 00156 && $tsa1["mday"] == $tsa2["mday"] 00157 && $tsa1["hours"] == $tsa2["hours"]) 00158 return TRUE; 00159 else 00160 return FALSE; 00161 } 00162 00163 function compareTSMinute($ts1, $ts2) { 00164 $tsa1 = getdate($ts1); 00165 $tsa2 = getdate($ts2); 00166 if ( $tsa1["year"] == $tsa2["year"] 00167 && $tsa1["mon"] == $tsa2["mon"] 00168 && $tsa1["mday"] == $tsa2["mday"] 00169 && $tsa1["hours"] == $tsa2["hours"] 00170 && $tsa1["minutes"] == $tsa2["minutes"]) 00171 return TRUE; 00172 else 00173 return FALSE; 00174 } 00175 00176 function getSubstr($str, $stop=1, $appointment) { 00177 if (strlen($str) > $stop) 00178 $str = substr($str, 0, $stop-3)."..."; 00179 00180 if (!(strpos($str, "<i>[E]</i>") === false) || !(strpos($str, "<i>[M]</i>") === false)) { 00181 $link = $str; 00182 } 00183 else { 00184 $link = "<a href=\"cal_edit_entry.php?aid=".$appointment->getAppointmentId()."&ts=".$appointment->getStartTimestamp()."\" target=\"bottom\">".$str."</a>"; 00185 } 00186 return $link; 00187 } 00188 00189 function isNumeric($str) { 00190 $isNumeric = 0; 00191 for ($i=0;$i<strlen($str);$i++) { 00192 switch($str{$i}) { 00193 case "0": 00194 case "1": 00195 case "2": 00196 case "3": 00197 case "4": 00198 case "5": 00199 case "6": 00200 case "7": 00201 case "8": 00202 case "9": 00203 $isNumeric++; 00204 break; 00205 } 00206 } 00207 return ($isNumeric == strlen($str)); 00208 } 00209 } 00210 00211 ?>