# HG changeset patch # User Matti Hamalainen # Date 1346081720 -10800 # Node ID 57af36f0864e3563ab49c46728ee56a7599046a9 # Parent 7621bfc47491dd5f4958d9cc960b8aa866a9bb49 Rename some functions + reindentation cosmetics. diff -r 7621bfc47491 -r 57af36f0864e index.php --- a/index.php Mon Aug 27 07:56:07 2012 +0300 +++ b/index.php Mon Aug 27 18:35:20 2012 +0300 @@ -51,7 +51,7 @@ $id = $m[1]; return TRUE; } else { - lukErrorMsg("Virhe! Luokan täytyy olla muotoa XXXnXXX, käytetään vakioarvoa ".$luokkaDefault."."); + errorMsg("Virhe! Luokan täytyy olla muotoa XXXnXXX, käytetään vakioarvoa ".$luokkaDefault."."); $id = $luokkaDefault; return FALSE; } @@ -121,7 +121,7 @@ $luokka = $_COOKIE["lukluokka"]; lukCheckClassID($luokka); } else { - lukErrorMsg("Luokkaa ei asetettu, käytetään vakioarvoa ".$luokkaDefault."."); + errorMsg("Luokkaa ei asetettu, käytetään vakioarvoa ".$luokkaDefault."."); $luokka = $luokkaDefault; } @@ -176,12 +176,14 @@ } fclose($fp); } else { - lukErrorMsg("Luokkien listaa ei löytynyt. Kokeile ladata sivu uudelleen hetken kuluttua."); + errorMsg("Luokkien listaa ei löytynyt. Kokeile ladata sivu uudelleen hetken kuluttua."); } if (!file_exists($dataFile)) { - lukErrorMsg("Luokan ".lukChEntities($luokka)." tietoja ei löytynyt! Jos luokkakoodi on uusi, ilmestyy se järjestelmään seuraavan päivityksen aikana. Luokkatiedot päivitetään 2 kertaa vuorokaudessa."); + errorMsg("Luokan ".lukChEntities($luokka)." tietoja ei löytynyt! ". + "Jos luokkakoodi on uusi, ilmestyy se järjestelmään seuraavan ". + "päivityksen aikana. Luokkatiedot päivitetään kerran viikossa."); $haveData = FALSE; } else { require($dataFile); @@ -189,7 +191,7 @@ } -function printHourInfo($dayHours, $showDays) +function lukPrintHourInfo($dayHours, $showDays) { $out = " \n Tunteja
(ryhmä/vv)\n"; for ($day = 0; $day < $showDays; $day++) { @@ -213,7 +215,7 @@ } -function findNextHour(&$j, &$i, $day, $hour, $chk) +function lukFindNextActiveHour(&$j, &$i, $day, $hour, $chk) { global $classInfo, $classHourTable; // for ($j = $day; $j < $classInfo["maxdays"]; $j++) @@ -230,28 +232,28 @@ } -function getHourInfo($isSplit, $d) +function lukGetHourInfo($isSplit, $d) { if ($isSplit) { $out = "". ""; - for ($j = 2; $j < count($d); $j += 2) - $out .= ""; + for ($i = 2; $i < count($d); $i += 2) + $out .= ""; return $out."
".lukMatchCourse($d[0])."".lukMatchCourse($d[1])."
".lukChEntities($d[$j])."".(isset($d[$j+1]) ? lukChEntities($d[$j+1]) : "")."
".lukChEntities($d[$i])."".(isset($d[$i+1]) ? lukChEntities($d[$i+1]) : "")."
"; } else { $out = lukMatchCourse($d[0])."
"; - for ($j = 1; $j < count($d); $j++) - $out .= lukChEntities($d[$j])."
"; + for ($i = 1; $i < count($d); $i++) + $out .= lukChEntities($d[$i])."
"; return $out; } } -function getHourInfoData($id) +function lukGetHourInfoData($id) { global $classDefs; @@ -259,7 +261,7 @@ if ($id >= 0 && isset($classDefs[$id])) { $i = $classDefs[$id]; $isSplit = preg_match("/^[A-Z]\d{6}$/", $i["data"][1]); - return getHourInfo($isSplit, $i["data"]); + return lukGetHourInfo($isSplit, $i["data"]); } else return "

Ei tunteja.

"; } else @@ -269,6 +271,8 @@ } +$out = ""; + if ($miniMode && $haveData) { $stamp = time(); $aika = getdate($stamp); @@ -283,7 +287,7 @@ $id = $classHourTable[$hour][$day]; $out .= "

".$dayNames[$day]." ".date("d.n.Y", $stamp)." - klo ".date("H:i", $stamp)."

\n". - getHourInfoData($id)."\n"; + lukGetHourInfoData($id)."\n"; } @@ -309,7 +313,7 @@ } // echo "day=$day, hour=$hour, id=$id
\n"; - $found = findNextHour($nday, $nhour, $day, $hour, $id); + $found = lukFindNextActiveHour($nday, $nhour, $day, $hour, $id); // echo "nday=$nday, nhour=$nhour, id=$found
\n"; @@ -318,7 +322,7 @@ $stamp = lukMakeHourStamp($nhour, 0, 0, $aika["mon"], $aika["mday"] + $nday - $day, $aika["year"]); $aika = getdate($stamp); $out .= ": ".$dayNames[$nday]." ".date("d.n.Y", $stamp)." - klo ".date("H:i", $stamp)."\n". - getHourInfoData($found)."\n"; + lukGetHourInfoData($found)."\n"; } else { $out .= "\n". "

Ei mitään

\n"; @@ -362,46 +366,46 @@ } $out .= " \n"; -for ($hour = 0; $hour < $classInfo["maxhours"]; $hour++) { - $out .= " \n". - " ".getHour($hour)."\n"; - for ($day = 0; $day < $classInfo["maxdays"]; $day++) { - if (isset($classHourTable[$hour][$day])) { - $h = $classHourTable[$hour][$day]; - - if ($h < 1) { - if ($h > -9999) { - $n = lukResolveHours($hour, $day, $h, TRUE); - $out .= " \n"; - } - } else - if (isset($classDefs[$h])) { - if (!isset($classDefs[$h]["done"])) { - $classDefs[$h]["done"] = true; - $i = $classDefs[$h]; - $d = $classDefs[$h]["data"]; + for ($hour = 0; $hour < $classInfo["maxhours"]; $hour++) { + $out .= " \n". + " ".getHour($hour)."\n"; + for ($day = 0; $day < $classInfo["maxdays"]; $day++) { + if (isset($classHourTable[$hour][$day])) { + $h = $classHourTable[$hour][$day]; - $isSplit = preg_match("/^[A-Z]\d{6}$/", $d[1]); - - $hours = lukResolveHours($hour, $day, $h, FALSE); - if ($hours != $i["hours"]) { - lukErrorMsg("Internal error, cell $hour / $day : hour id $h hours ($hours) do not match ".$i["hours"]."!"); + if ($h < 1) { + if ($h > -9999) { + $n = lukResolveHours($hour, $day, $h, TRUE); + $out .= " \n"; } - - $out .= " ". - getHourInfo($isSplit, $d). - "
".$hours."h
\n"; - } + } else + if (isset($classDefs[$h])) { + if (!isset($classDefs[$h]["done"])) { + $classDefs[$h]["done"] = true; + $i = $classDefs[$h]; + $d = $classDefs[$h]["data"]; + + $isSplit = preg_match("/^[A-Z]\d{6}$/", $d[1]); + + $hours = lukResolveHours($hour, $day, $h, FALSE); + if ($hours != $i["hours"]) { + errorMsg("Internal error, cell $hour / $day : hour id $h hours ($hours) do not match ".$i["hours"]."!"); + } + + $out .= " ". + lukGetHourInfo($isSplit, $d). + "
".$hours."h
\n"; + } + } else + errorMsg("Internal error cell $hour / $day : hour id $h does not exist!"); } else - lukErrorMsg("Internal error cell $hour / $day : hour id $h does not exist!"); - } else - lukErrorMsg("Internal error, cell $hour / $day does not exist."); + errorMsg("Internal error, cell $hour / $day does not exist."); + } + $out .= " \n"; } - $out .= " \n"; -} - $out .= printHourInfo($dayHours, $classInfo["maxdays"]). + $out .= lukPrintHourInfo($dayHours, $classInfo["maxdays"]). "\n"; } // haveData @@ -448,7 +452,7 @@ // Show error messages if ($errorSet) { echo "\n"; }