Mercurial > hg > lukkari
diff index.php @ 72:6fd715063abc
Clean up some parsing operations.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 24 Oct 2012 06:31:32 +0300 |
parents | 0329105ddedc |
children | 241839ebb09f |
line wrap: on
line diff
--- a/index.php Wed Oct 24 04:30:36 2012 +0300 +++ b/index.php Wed Oct 24 06:31:32 2012 +0300 @@ -176,28 +176,43 @@ } -function lukGetClassInfo($isSplit, $data) +function lukGetClassInfo($grouped, $data) { - if ($isSplit) + if ($grouped) { - $out = "<table>". - "<tr><td>".lukMatchCourse($data[0])."</td><td>".lukMatchCourse($data[1])."</td></tr>"; + $out = "<table><tr>"; - for ($i = 2; $i < count($data); $i += 2) + $maxCount = 0; + foreach ($data as $col) + { + $out .= "<td>".lukMatchCourse($col[0])."</td>"; + if (count($col) > $maxCount) + $maxCount = count($col); + } + $out .= "</tr>"; + + for ($i = 1; $i < $maxCount; $i++) { - $out .= "<tr><td>".lukChEntities($data[$i])."</td><td>". - (isset($data[$i+1]) ? lukChEntities($data[$i+1]) : "")."</td></tr>"; + $out .= "<tr>"; + foreach ($data as $col) + { + $out .= "<td>"; + if (isset($col[$i])) + $out .= lukChEntities($col[$i]); + $out .= "</td>"; + } + $out .= "</tr>"; } - + return $out."</table>"; } else { - $out = lukMatchCourse($data[0])."<br />"; + $out = lukMatchCourse($data[0][0])."<br />"; - for ($i = 1; $i < count($data); $i++) + for ($i = 1; $i < count($data[0]); $i++) { - $out .= lukChEntities($data[$i])."<br />"; + $out .= lukChEntities($data[0][$i])."<br />"; } return $out; @@ -205,26 +220,6 @@ } -function lukGetClassInfoData($id) -{ - global $classInfo; - - if (isset($id)) - { - if ($id >= 0 && isset($classInfo[$id])) - { - $i = $classInfo[$id]; - $isSplit = preg_match("/^[A-Z]\d{6}$/", $i["data"][1]); - return lukGetClassInfo($isSplit, $i["data"]); - } - else - return "<p>Ei tunteja.</p>"; - } - else - return "<p>Ei mitään.</p>"; -} - - function lukFindClass($day, $hour) { global $classHourDefs, $classDayTable; @@ -385,15 +380,13 @@ { $class["set"] = TRUE; - $isSplit = preg_match("/^[A-Z]\d{6}$/", $class["data"][1]); - $isActive = $day == $currDay && $currTime >= $classHourTimes[$class["start"]]["start"] && $currTime < $classHourTimes[$class["start"] + $class["hours"] - 1]["end"]; $out .= " <td rowspan=\"".$class["hours"]. "\" class=\"".($isActive ? "clactive " : "").($class["grouped"] ? "clgrouped" : "clnormal")."\">". - lukGetClassInfo($isSplit, $class["data"]). + lukGetClassInfo($class["grouped"], $class["data"]). "<div class=\"nhours\"><span>".$class["hours"]."h</span></div></td>\n"; } }