Mercurial > hg > lukkari
comparison index.php @ 20:d9df76217991
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 12 Jan 2011 03:59:36 +0200 |
parents | 777791321149 |
children | b4b86915ae2c |
comparison
equal
deleted
inserted
replaced
19:777791321149 | 20:d9df76217991 |
---|---|
72 if ($fp) { | 72 if ($fp) { |
73 fclose($fp); | 73 fclose($fp); |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 | 77 |
78 function getHour($hour) | 78 function getHourStamp($hour, $sec = 0, $mon = 0, $day = 0, $year = 0) |
79 { | 79 { |
80 global $hourStamps; | 80 global $hourStamps; |
81 if (isset($hourStamps[$hour])) | 81 if (isset($hourStamps[$hour])) |
82 $stamp = mktime($hourStamps[$hour][0], $hourStamps[$hour][1], 0); | 82 return mktime($hourStamps[$hour][0], $hourStamps[$hour][1], $sec, $mon, $year); |
83 else | 83 else |
84 $stamp = mktime($hour + 8, 0, 0); | 84 return mktime($hour + 8, 0, $sec, $mon, $year); |
85 | 85 } |
86 | |
87 | |
88 function getHour($hour) | |
89 { | |
90 $stamp = getHourStamp($hour); | |
86 return "<br />".date("H:i", $stamp)." - ".date("H:i", $stamp + 45 * 60)."<br /><br />"; | 91 return "<br />".date("H:i", $stamp)." - ".date("H:i", $stamp + 45 * 60)."<br /><br />"; |
87 } | 92 } |
88 | 93 |
89 | 94 |
90 function matchCourse($id) | 95 function matchCourse($id) |
185 | 190 |
186 | 191 |
187 function findNextHour(&$j, &$i, $day, $hour, $chk) | 192 function findNextHour(&$j, &$i, $day, $hour, $chk) |
188 { | 193 { |
189 global $classInfo, $classHourTable; | 194 global $classInfo, $classHourTable; |
190 for ($j = $day; $j < $classInfo["maxdays"]; $j++) | 195 // for ($j = $day; $j < $classInfo["maxdays"]; $j++) |
196 $j = $day; | |
191 for ($i = $hour; $i < $classInfo["maxhours"]; $i++) { | 197 for ($i = $hour; $i < $classInfo["maxhours"]; $i++) { |
192 // echo "chk=$chk - i=$i / j=$j : ht=".$classHourTable[$i][$j]."<br />\n"; | 198 if ($chk > 0 && $classHourTable[$i][$j] != $chk) |
193 if (($chk > 0 && $classHourTable[$i][$j] != $chk) || $classHourTable[$i][$j] > 0) | 199 return $classHourTable[$i][$j]; |
200 | |
201 if ($classHourTable[$i][$j] > 0 && $classHourTable[$i][$j] != $chk) | |
194 return $classHourTable[$i][$j]; | 202 return $classHourTable[$i][$j]; |
195 } | 203 } |
196 | 204 |
197 return -1; | 205 return -1; |
198 } | 206 } |
236 return ""; | 244 return ""; |
237 } | 245 } |
238 | 246 |
239 | 247 |
240 if ($miniMode) { | 248 if ($miniMode) { |
241 $aika = getdate(); | 249 $stamp = time(); |
242 $hour = $aika["hours"] - 8; | 250 $aika = getdate($stamp); |
243 $day = $aika["wday"] - 1; | 251 $day = $aika["wday"] - 1; |
244 if ($day < 0) $day = 7; | 252 if ($day < 0) $day = 7; |
245 | 253 $hour = $aika["hours"] - 8; |
246 $chk = $classHourTable[$hour][$day]; | 254 |
255 $id = $classHourTable[$hour][$day]; | |
247 | 256 |
248 $out = "<div class=\"content\">\n". | 257 $out = "<div class=\"content\">\n". |
249 "<h2>".$dayNames[$day]." ".$aika["mday"].".".$aika["mon"].".".$aika["year"]." - klo ".$aika["hours"].":".$aika["minutes"]."</h2>\n". | 258 "<h2>".$dayNames[$day]." ".date("d.n.Y", $stamp)." - klo ".date("H:i", $stamp)."</h2>\n". |
250 getHourInfoData($chk)."\n"; | 259 getHourInfoData($id)."\n"; |
251 | 260 |
252 // $out .= "hour=".$hour."/day=".$day."<br />\n"; | 261 |
262 if (isset($id) && $id >= 0 && isset($classDefs[$id])) { | |
263 $i = $classDefs[$id]; | |
264 $start = getHourStamp($i["start"]); | |
265 } | |
266 | |
267 // echo "day=$day, hour=$hour, id=$id<br />\n"; | |
268 | |
253 if ($day >= $classInfo["maxdays"]) { | 269 if ($day >= $classInfo["maxdays"]) { |
254 $day = $hour = 0; | 270 $day = $hour = 0; |
255 $chk = -1; | 271 $id = -1; |
256 } else | 272 } else |
257 if ($hour < 0) { | 273 if ($hour < 0) { |
258 $hour = 0; | 274 $hour = 0; |
259 $chk = -1; | 275 $id = -1; |
260 } else | 276 } else |
261 if ($hour >= $classInfo["maxhours"]) { | 277 if ($hour >= $classInfo["maxhours"]) { |
262 $day++; | 278 $day++; |
263 $hour = 0; | 279 $hour = 0; |
264 $chk = -1; | 280 $id = -1; |
265 } | 281 } |
266 // $out .= "hour=".$hour."/day=".$day."<br />\n"; | 282 |
267 | 283 // echo "day=$day, hour=$hour, id=$id<br />\n"; |
268 $found = findNextHour($nday, $nhour, $day, $hour, $chk); | 284 $found = findNextHour($nday, $nhour, $day, $hour, $id); |
269 | 285 |
270 // $out .= "hour=".$nhour."/day=".$nday."/found=".$found."<br />\n"; | 286 // echo "nday=$nday, nhour=$nhour, id=$found<br />\n"; |
271 | 287 |
288 $out .= "<h2>Seuraavaksi"; | |
272 if ($found > 0) { | 289 if ($found > 0) { |
273 $stamp = mktime(8 + $nhour, 15, 0, $aika["mon"], $aika["mday"] + $nday - $day, $aika["year"]); | 290 $stamp = getHourStamp($nhour, 0, 0, $aika["mon"], $aika["mday"] + $nday - $day, $aika["year"]); |
274 $aika = getdate($stamp); | 291 $aika = getdate($stamp); |
275 $hour = $aika["hours"] - 8; | 292 $out .= ": ".$dayNames[$nday]." ".date("d.n.Y", $stamp)." - klo ".date("H:i", $stamp)."</h2>\n". |
276 $day = $aika["wday"] - 1; | 293 getHourInfoData($found)."\n"; |
277 if ($day < 0) $day = 7; | 294 } else { |
278 $out .= "<h2>Seuraavaksi: ".$dayNames[$nday]." ".date("d.n.Y", $stamp)." - klo ".date("H:i", $stamp)."</h2>\n". | 295 $out .= "</h2>\n". |
279 getHourInfoData($found)."\n". | 296 "<p>Ei mitään</p>\n"; |
280 "</div>\n"; | 297 } |
281 } | 298 |
299 $out .= "</div>\n"; | |
282 } | 300 } |
283 else | 301 else |
284 if ($haveData) { | 302 if ($haveData) { |
285 $totalHours = 0; | 303 $totalHours = 0; |
286 $totalGrouped = 0; | 304 $totalGrouped = 0; |