diff index.php @ 48:d41b51cd4ae5

Implement switchable CSS support and a new default style + very minor code cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 17 Oct 2012 14:02:24 +0300
parents d8a1e85b8dda
children 16aea8e5cb71
line wrap: on
line diff
--- a/index.php	Sat Oct 13 12:01:08 2012 +0300
+++ b/index.php	Wed Oct 17 14:02:24 2012 +0300
@@ -1,20 +1,20 @@
-<?php
+ <?php
 //
 // Yes, this is horrible. :|
 //
-$pageCSS = array("luk.css");
 $pageCharset = "utf-8";
 $internalCharset = "utf-8";
 $luokkaDefault = "TTE9SNO";
 $classFile = "luokat.txt";
-$mapFile = "kartta.png";
-$roomFile = "luokkatilat.txt";
 $cacheFile = "coursecache.txt";
 $baseURI = "http://tnsp.org/luk/";
 //$infoURI = "http://www.oamk.fi/opiskelijalle/rakenne/opinto-opas/koulutusohjelmat/?sivu=oj&kieli=FI&opas=2010-2011&vuosi=10S11K&koodi1=";
 $infoURI = "http://www.oamk.fi/opiskelijalle/rakenne/opinto-opas/koulutusohjelmat/?sivu=oj&kieli=FI&koodi1=";
 $dayNames = array("Maanantai", "Tiistai", "Keskiviikko", "Torstai", "Perjantai", "Lauantai", "Sunnuntai");
 
+$pageCSSData = array("cookie" => "lukcss", "prefix" => $baseURI."luk");
+$altCSS = array("blue" => "1", "old" => "2");
+
 $hourStamps = array(
   array( 8, 15),
   array( 9, 15),
@@ -100,13 +100,6 @@
 }
 
 
-function lukMatchClass($matches)
-{
-  global $baseURI;
-  return "<b><a href=\"".$baseURI."?tila=".$matches[1]."\">".$matches[1]."</a></b> ".$matches[2];
-}
-
-
 // Check for mini-info mode
 $miniMode = isset($_GET["nyt"]);
 
@@ -126,18 +119,6 @@
 }
 
 
-if (isset($_GET["tila"])) {
-  $tila = $_GET["tila"];
-  echo "Luokkatilan n&auml;ytt&ouml;moodi ei viel&auml; tuettu.<br />\n";
-  exit;
-
-  $fp = @fopen($roomFile, "rb");
-  if ($fp) {
-    fclose($fp);
-  }
-}
-
-
 if (isset($_GET["next"])) {
   $nextPeriod = TRUE;
   $dataFile = "cache-next/".$luokka.".data";
@@ -191,16 +172,6 @@
 }
 
 
-function lukPrintHourInfo($dayHours, $showDays)
-{
-  $out = " <tr>\n  <td>Tunteja<br />(<b>ryhmä/vv</b>)</td>\n";
-  for ($day = 0; $day < $showDays; $day++) {
-    $out .=  "  <td>".$dayHours[$day]["total"]."h (<b>".$dayHours[$day]["grouped"]."h</b>)</td>\n";
-  }
-  return $out." </tr>\n";
-}
-
-
 function lukResolveHours($start, $day, $cmp, $mark = FALSE)
 {
   global $classHourTable, $classInfo;
@@ -405,8 +376,7 @@
     $out .= " </tr>\n";
   }
 
-  $out .= lukPrintHourInfo($dayHours, $classInfo["maxdays"]).
-  "</table>\n";
+  $out .= "</table>\n";
 
 } // haveData
 
@@ -414,8 +384,6 @@
 $pageTitle = $haveData ? $luokka." / ".join("; ", $classInfo["info"]) : $luokka;
 printPageHeader($pageTitle);
 
-if ($miniMode) echo "<div id=\"mini\">\n";
-
 echo
 "<form id=\"controls\" action=\"".$baseURI."\" method=\"get\">
  <table>
@@ -459,12 +427,16 @@
 
 echo $out;
 
-echo "<div style=\"position: relative; top: 5em; font-size: 5pt;\"><hr />
+echo "<div id=\"footer\">
 Yhteydenotot <b>ccr @ IRCNet</b> tai <b>ccr at tnsp dot org</b>. En vastaa mahdollisista virheistä tiedoissa!
 </div>
+<div id=\"csssel\">
+Style: ";
+foreach ($altCSS as $name => $id)
+  echo "<a href=\"?css=".$id."\">".$name."</a>";
+echo "
+</div>
 ";
-
-if ($miniMode) echo "</div>\n";
 printPageFooter();