Mercurial > hg > lukkari
comparison index.php @ 83:85068c8513b4
Add back mobile mode.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 24 Oct 2012 13:58:00 +0300 |
parents | c553ad61e9c2 |
children | adaad33f929c |
comparison
equal
deleted
inserted
replaced
82:c553ad61e9c2 | 83:85068c8513b4 |
---|---|
235 return 0; | 235 return 0; |
236 } | 236 } |
237 | 237 |
238 | 238 |
239 // Check given parameters | 239 // Check given parameters |
240 $mobileMode = isset($_GET["mobile"]) || isset($_COOKIE["lukmobile"]); | 240 $mobileMode = FALSE; |
241 if (isset($_GET["m"])) | |
242 { | |
243 $mobileMode = intval($_GET["m"]); | |
244 setcookie("lukmobile", $mobileMode, time() + 365*24*60*60); // expire in a year | |
245 } | |
246 else | |
247 if (isset($_COOKIE["lukmobile"])) | |
248 { | |
249 $mobileMode = $_COOKIE["lukmobile"]; | |
250 } | |
251 | |
252 if ($mobileMode) | |
253 { | |
254 $pageCSSData["prefix"] = $baseURI."mluk"; | |
255 } | |
256 | |
241 | 257 |
242 if (isset($_GET["luokka"])) | 258 if (isset($_GET["luokka"])) |
243 { | 259 { |
244 $luokka = $_GET["luokka"]; | 260 $luokka = $_GET["luokka"]; |
245 if (lukCheckClassID($luokka)) | 261 if (lukCheckClassID($luokka)) |
349 require($dataFile); | 365 require($dataFile); |
350 $haveData = isset($classInfo); | 366 $haveData = isset($classInfo); |
351 } | 367 } |
352 | 368 |
353 | 369 |
354 function lukNormalTimeTable() | 370 function lukPrintTimeTable($mini) |
355 { | 371 { |
356 global $classInfo, $classHourDefs, $classHourTimes; | 372 global $classInfo, $classHourDefs, $classHourTimes; |
357 | 373 |
358 // $currStamp = time() + ((3 * 60) + 45) * 60; | 374 // $currStamp = time() + ((3 * 60) + 45) * 60; |
359 $currStamp = time(); | 375 $currStamp = time(); |
360 $currTime = $currStamp - mktime(0, 0, 0); | 376 $currTime = $currStamp - mktime(0, 0, 0); |
361 $currDay = lukGetWeekdayFromTimestamp($currStamp); | 377 $currDay = lukGetWeekdayFromTimestamp($currStamp); |
362 | 378 |
363 $nextStamp = $currStamp + 30 * 60; | 379 $nextStamp = $currStamp + 30 * 60; |
364 $nextTime = $nextStamp - mktime(0, 0, 0); | 380 $nextTime = $nextStamp - mktime(0, 0, 0); |
365 $nextDay = lukGetWeekdayFromTimestamp($nextStamp); | |
366 | 381 |
367 // Create the timetable table | 382 // Create the timetable table |
368 $out = | 383 if ($mini) |
369 "<p>".join("; ", $classInfo["general"])."</p>\n". | 384 { |
370 "<div>".lukMsg("viikossa", $classInfo["totalHours"])."</div>\n". | 385 $out = |
371 "<table class=\"timetable\">". | 386 "<table class=\"timetable\">". |
372 " <tr>\n <th></th>\n"; | 387 " <tr>\n <th></th>". |
373 $cellWidth = 100 / $classInfo["maxDays"]; | 388 " <th class=\"days\">".lukGetDayName($currDay)."</th>\n </tr>\n"; |
374 if ($cellWidth > 25) $cellWidth = 25; | 389 |
375 for ($day = 0; $day < $classInfo["maxDays"]; $day++) | 390 $startDay = $currDay; |
376 { | 391 $lastDay = $currDay + 1; |
377 $out .= " <th style=\"width: ".$cellWidth."%;\" class=\"days\">".lukGetDayName($day)."</th>\n"; | 392 } |
378 } | 393 else |
379 $out .= " </tr>\n"; | 394 { |
395 $out = | |
396 "<p>".join("; ", $classInfo["general"])."</p>\n". | |
397 "<div>".lukMsg("viikossa", $classInfo["totalHours"])."</div>\n". | |
398 "<table class=\"timetable\">". | |
399 " <tr>\n <th></th>\n"; | |
400 $cellWidth = 100 / $classInfo["maxDays"]; | |
401 if ($cellWidth > 25) $cellWidth = 25; | |
402 | |
403 for ($day = 0; $day < $classInfo["maxDays"]; $day++) | |
404 { | |
405 $out .= " <th style=\"width: ".$cellWidth."%;\" class=\"days\">".lukGetDayName($day)."</th>\n"; | |
406 } | |
407 $out .= " </tr>\n"; | |
408 $startDay = 0; | |
409 $lastDay = $classInfo["maxDays"]; | |
410 } | |
411 | |
380 | 412 |
381 for ($hour = $classInfo["firstHour"]; $hour < $classInfo["lastHour"]; $hour++) | 413 for ($hour = $classInfo["firstHour"]; $hour < $classInfo["lastHour"]; $hour++) |
382 { | 414 { |
383 $out .= " <tr>\n". | 415 $out .= " <tr>\n". |
384 " <th class=\"hours\">".lukGetHourStr($hour)."</th>\n"; | 416 " <th class=\"hours\">".lukGetHourStr($hour)."</th>\n"; |
385 for ($day = 0; $day < $classInfo["maxDays"]; $day++) | 417 for ($day = $startDay; $day < $lastDay; $day++) |
386 { | 418 { |
387 $id = lukFindClass($day, $hour); | 419 $id = lukFindClass($day, $hour); |
388 if ($id > 0) | 420 if ($id > 0) |
389 { | 421 { |
390 $class = &$classHourDefs[$id]; | 422 $class = &$classHourDefs[$id]; |
391 if (!isset($class["set"])) | 423 if (!isset($class["set"])) |
392 { | 424 { |
393 $class["set"] = TRUE; | 425 $class["set"] = TRUE; |
394 | 426 |
395 $nextActive = $day == $nextDay && | 427 $nextActive = $day == $currDay && |
396 $nextTime >= $classHourTimes[$class["start"]]["start"] && | 428 $nextTime >= $classHourTimes[$class["start"]]["start"] && |
397 $nextTime < $classHourTimes[$class["start"] + $class["hours"] - 1]["end"]; | 429 $nextTime < $classHourTimes[$class["start"] + $class["hours"] - 1]["end"]; |
398 | 430 |
399 $isActive = $day == $currDay && | 431 $isActive = $day == $currDay && |
400 $currTime >= $classHourTimes[$class["start"]]["start"] && | 432 $currTime >= $classHourTimes[$class["start"]]["start"] && |
438 } | 470 } |
439 echo | 471 echo |
440 " </select> | 472 " </select> |
441 </th> | 473 </th> |
442 <th><input class=\"submit\" type=\"submit\" value=\"".lukMsg("Switch")."\" /></th> | 474 <th><input class=\"submit\" type=\"submit\" value=\"".lukMsg("Switch")."\" /></th> |
443 <th><a href=\"".$origBaseURI.$luokka.$origBaseExt."\">".lukMsg("Original")."</a></th> | 475 "; |
444 | 476 |
445 <th><a href=\"".$baseURI.($nextPeriod ? "" : "?next")."\">". | 477 if (!$mobileMode) |
478 { | |
479 echo " | |
480 <th><a id=\"next\" class=\"textctrl\" href=\"".$baseURI.($nextPeriod ? "" : "?next")."\">". | |
446 ($nextPeriod ? lukMsg("Current period") : lukMsg("Next period"))."</a></th> | 481 ($nextPeriod ? lukMsg("Current period") : lukMsg("Next period"))."</a></th> |
447 | 482 <th><a id=\"orig\" class=\"textctrl\" href=\"".$origBaseURI.$luokka.$origBaseExt."\">".lukMsg("Original")."</a></th> |
448 <th><a href=\"".$baseURI.($nextPeriod ? "cache-next" : "cache")."/".$luokka.".xml\">XML</a></th> | 483 <th><a id=\"xml\" class=\"textctrl\" href=\"".$baseURI.$cachePath."/".$luokka.".xml\">XML</a></th> |
484 "; | |
485 } | |
486 | |
487 echo " | |
488 <th><a id=\"mobile\" class=\"imgctrl\" href=\"".$baseURI."?m=".($mobileMode ? 0 : 1)."\"><img src=\"img/mobile-white.png\" alt=\"Mobile\"></a></th> | |
449 </tr> | 489 </tr> |
450 </table> | 490 </table> |
451 </form> | 491 </form> |
452 "; | 492 "; |
453 | 493 |
462 echo "</ul>\n"; | 502 echo "</ul>\n"; |
463 } | 503 } |
464 | 504 |
465 if ($haveData) | 505 if ($haveData) |
466 { | 506 { |
467 echo lukNormalTimeTable(); | 507 echo lukPrintTimeTable($mobileMode); |
468 } | 508 } |
469 | 509 |
470 echo | 510 echo |
471 "<div id=\"footer\">". | 511 "<div id=\"footer\">". |
472 lukMsg("contact", "ccr @ IRCNet", "ccr (at) tnsp (dot) org"). | 512 lukMsg("contact", "ccr @ IRCNet", "ccr (at) tnsp (dot) org"). |