# HG changeset patch # User Matti Hamalainen # Date 1294794406 -7200 # Node ID 7777913211496176aaebaf893f755b033fffb118 # Parent e0f1a5861f282fb5d97f45db808c4da1ccc2c267 Modularize, cleanup. diff -r e0f1a5861f28 -r 777791321149 index.php --- a/index.php Wed Jan 12 02:54:52 2011 +0200 +++ b/index.php Wed Jan 12 03:06:46 2011 +0200 @@ -198,30 +198,36 @@ } -function getHourInfo($id) +function getHourInfo($isSplit, $d) +{ + if ($isSplit) { + $out = "". + ""; + + for ($j = 2; $j < count($d); $j += 2) + $out .= ""; + + return $out."
".matchCourse($d[0])."".matchCourse($d[1])."
".htmlentities($d[$j])."".(isset($d[$j+1]) ? htmlentities($d[$j+1]) : "")."
"; + } else { + $out = matchCourse($d[0])."
"; + + for ($j = 1; $j < count($d); $j++) + $out .= htmlentities($d[$j])."
"; + + return $out; + } +} + + +function getHourInfoData($id) { global $classDefs; if (isset($id)) { if ($id >= 0 && isset($classDefs[$id])) { $i = $classDefs[$id]; - $d = $i["data"]; - $out = ""; - - $isSplit = preg_match("/^[A-Z]\d{6}$/", $d[1]); - if ($isSplit) { - $out .= "". - ""; - for ($j = 2; $j < count($d); $j += 2) - $out .= ""; - $out .= "
".matchCourse($d[0])."".matchCourse($d[1])."
".htmlentities($d[$j])."".(isset($d[$j+1]) ? htmlentities($d[$j+1]) : "")."
"; - } else { - $out .= matchCourse($d[0])."
"; - for ($j = 1; $j < count($d); $j++) - $out .= htmlentities($d[$j])."
"; - } - - return $out; + $isSplit = preg_match("/^[A-Z]\d{6}$/", $i["data"][1]); + return getHourInfo($isSplit, $i["data"]); } else return "

Ei tunteja.

"; } else @@ -241,7 +247,7 @@ $out = "
\n". "

".$dayNames[$day]." ".$aika["mday"].".".$aika["mon"].".".$aika["year"]." - klo ".$aika["hours"].":".$aika["minutes"]."

\n". - getHourInfo($chk)."\n"; + getHourInfoData($chk)."\n"; // $out .= "hour=".$hour."/day=".$day."
\n"; if ($day >= $classInfo["maxdays"]) { @@ -270,7 +276,7 @@ $day = $aika["wday"] - 1; if ($day < 0) $day = 7; $out .= "

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

\n". - getHourInfo($found)."\n". + getHourInfoData($found)."\n". "
\n"; } } @@ -337,20 +343,9 @@ } $out .= " "; - - if ($isSplit) { - $out .= "". - ""; - for ($j = 2; $j < count($d); $j += 2) - $out .= ""; - $out .= "
".matchCourse($d[0])."".matchCourse($d[1])."
".htmlentities($d[$j])."".(isset($d[$j+1]) ? htmlentities($d[$j+1]) : "")."
"; - } else { - $out .= matchCourse($d[0])."
"; - for ($j = 1; $j < count($d); $j++) - $out .= htmlentities($d[$j])."
"; - } - $out .= "
".$hours."h
\n"; + "\" class=\"".($isSplit || $i["grouped"] ? "clgrouped" : "clnormal")."\">". + getHourInfo($isSplit, $d). + "
".$hours."h
\n"; } } else errorMsg("Internal error cell $hour / $day : hour id $h does not exist!");