# HG changeset patch # User Matti Hamalainen # Date 1485045070 -7200 # Node ID 16ce445c499a15636a739ad2b98421f4eaf8780e # Parent 9f7eb4db99b44a473a2c826eec7ea7657d7507cd Import v3 branch. diff -r 9f7eb4db99b4 -r 16ce445c499a index.php --- a/index.php Mon Feb 15 06:42:51 2016 +0200 +++ b/index.php Sun Jan 22 02:31:10 2017 +0200 @@ -1,7 +1,7 @@ +// OAMK Lukkari v3.0 +// (C) Copyright 2010 - 2015 Matti 'ccr' Hämäläinen // Yes, this code is rather horrible. :| // // Include framework @@ -9,7 +9,7 @@ // Default settings $pageName = "OAMK Lukkari"; -$pageVersion = "2.7"; +$pageVersion = "3.0alpha"; $mobileMode = FALSE; $baseURI = "http://example.com/"; @@ -194,11 +194,9 @@ if (isset($classHourTimes[$hour])) { return - "
". lukGetHourStamp($classHourTimes[$hour]["start"]). " - ". - lukGetHourStamp($classHourTimes[$hour]["end"]). - "

"; + lukGetHourStamp($classHourTimes[$hour]["end"]); } else return "ERROR"; @@ -279,57 +277,48 @@ } -function lukGetClassInfo($class) +function lukGetClassInfo($class, $indent = "") { $data = $class["data"]; - if ($class["grouped"]) { - // Grouped format - $out = ""; - - // Calculate max columns and add course titles - $maxColumns = 0; + $out = ""; foreach ($data as $col) { - $out .= ""; - if (count($col) > $maxColumns) - $maxColumns = count($col); - } - $out .= ""; + $out .= + $indent."
\n". + $indent."
".lukMatchCourse($col[0])."
\n"; - // Print rest of the data - $ncol = 1; - for ($i = 1; $i < $maxColumns; $i++) - { - $out .= "
"; - foreach ($data as $col) + for ($i = 1; $i < count($col); $i++) { - $out .= ""; + $out .= + $indent."
". + (isset($col[$i]) ? chentities($col[$i]) : ""). + "
\n"; } - $out .= ""; - $ncol++; + + $out .= $indent."\n"; } - $out .= "
".lukMatchCourse($col[0])."
"; - if (isset($col[$i])) - $out .= chentities($col[$i]); - $out .= "
"; + if ($class["turns"]) + $out .= "
".cmQM("vuoroviikoin")."
\n"; + + return $out; } else { - $out = lukMatchCourse($data[0][0])."
"; + $out = $indent."
".lukMatchCourse($data[0][0])."
\n"; for ($i = 1; $i < count($data[0]); $i++) { - $out .= chentities($data[0][$i])."
"; + $out .= $indent."
".chentities($data[0][$i])."
\n"; } - } - if ($class["turns"]) - $out .= cmQM("vuoroviikoin"); + if ($class["turns"]) + $out .= "
".cmQM("vuoroviikoin")."
\n"; - return $out; + return $out; + } } @@ -391,48 +380,43 @@ $nextStamp = $currStamp + 30 * 60; $nextTime = $nextStamp - mktime(0, 0, 0); + + $out = + "
\n"; // Create the timetable table if ($mini) { - $out = - "\n". - " \n". - " ". - " \n". - " \n"; - $startDay = $currDay; $lastDay = $currDay + 1; } else { - $out = - "

".join("; ", $classInfo["general"]). - //" [".cmQM("viikossa", $classInfo["totalHours"])."]". - "

\n". - "
".lukGetDayName($currDay)."
\n". - " \n". - " \n"; - - $cellWidth = $classInfo["maxDays"] > 0 ? 100 / $classInfo["maxDays"] : 15; - if ($cellWidth > 25) $cellWidth = 25; - - for ($day = 0; $day < $classInfo["maxDays"]; $day++) - { - $out .= " \n"; - } - $out .= " \n"; $startDay = 0; $lastDay = $classInfo["maxDays"]; } - + $out .= + "
\n". + "
 
\n"; for ($hour = $classInfo["firstHour"]; $hour < $classInfo["lastHour"]; $hour++) { - $out .= "
\n". - " \n"; - for ($day = $startDay; $day < $lastDay; $day++) + $out .= "
".lukGetHourStr($hour)."
\n"; + } + $out .= " \n"; + + if ($mini) + $tmpS = "style=\"width: 75%;\""; + else + $tmpS = sprintf("style=\"width: %1.3f%%;\"", 100 / ($lastDay - $startDay + 1)); + + for ($day = $startDay; $day < $lastDay; $day++) + { + $out .= + "
\n". + "
".lukGetDayName($day)."
\n"; + + for ($hour = $classInfo["firstHour"]; $hour < $classInfo["lastHour"]; $hour++) { $id = lukFindClass($day, $hour); if ($id > 0) @@ -450,24 +434,27 @@ $currTime >= $classHourTimes[$class["start"]]["start"] && $currTime < $classHourTimes[$class["start"] + $class["hours"] - 1]["end"]; - $out .= "
\n"; + $out .= + "
\n". + "
\n". + lukGetClassInfo($class, " "). + "
".lukClassGetHourStr($hour, $hour + $class["hours"] - 1)." (".$class["hours"]."h)
\n". + "
\n". + "
\n"; } } else { - $out .= " \n"; + $out .= "
\n"; } } - $out .= " \n"; + $out .= " \n"; } - return $out."
".lukGetDayName($day)."
".lukGetHourStr($hour)."". - lukGetClassInfo($class). - "
".$class["hours"]."h
\n"; + return $out."
\n"; } @@ -498,6 +485,15 @@ } +// Cookie info window +$showCookieInfo = isset($_COOKIE["lukcookieinfo"]) ? !$_COOKIE["lukcookieinfo"] : TRUE; + + +// Development info window +$showDevInfo = isset($_COOKIE["lukdevinfo"]) ? $_COOKIE["lukdevinfo"] : TRUE; +setcookie("lukdevinfo", 0, time() + 2*7*24*60*60); + + // Check class setting (check "luokka" for backwards compatibility also) if ((($classID = stGetRequestItem("class", FALSE, TRUE)) !== FALSE || ($classID = stGetRequestItem("luokka", FALSE, TRUE)) !== FALSE) && lukCheckClassID($classID)) @@ -581,21 +577,94 @@ "href=\"img/icon-".$iconSize."-precomposed.png\" />\n"; } +// XXX: Temporarily no-index (remember also robots.txt!) +$extra .= " \n"; + +// For mobile shit +$extra .= " \n"; // Start printing the page $pageTitle = $haveData ? $classID." / ".join("; ", $classInfo["info"]) : $classID; cmPrintPageHeader($pageTitle." - ".$pageName, $extra); +echo " + + +
+

Notice!

+

+ This is the development version of 'Lukkari', tentatively called \"3.0alpha\". + It is constantly changing, any features may be broken and fixed at + rapid pace. The style/layout is also in flux, and not finished - + there may be rendering bugs. Currently I am testing a non-table-based layout, + although it is not certain if it will be used in 'production'. +

+

+ If you wish to suggest features, send e-mail to ccr (at) tnsp (dot) org +

+
+ +
+
+"; + +if ($showCookieInfo) +{ + echo + "
\n". + "

Lukkari web-site uses HTTP cookies ". + " to store current settings (language, default class ID, etc.) ". + " Also, Google Analytics used on this site may store information via cookies.". + "

". + " By continued use of this site, you acknowledge that you have been informed of the situation.". + "
\n". + " \n". + "
\n". + "
\n"; +} + + +// Additional controls echo - "
\n". - "
".$pageName." v".$pageVersion."
\n"; + "
\n". + "
\n". + "
".$pageName." v".$pageVersion."
\n"; if (!$mobileMode) { echo - "
".cmQM("Style").": "; + "
".cmQM("Style").": "; if (isset($pageCSSAlts)) { @@ -611,8 +680,7 @@ "
\n"; } -echo - "
"; +echo "
"; foreach ($pageLanguages as $id) { @@ -622,16 +690,10 @@ } echo - "
\n". - "
\n"; - - -// Additional controls -echo - "
\n". - " \n". - " \n". - " \n". - " \n"; + " \n". + " \n"; if (!$mobileMode) { echo - " \n"; + "\n"; if ($haveData) { echo - " \n"; - //" \n"; + " \n"; + //" \n"; } - echo - " \n"; +// echo " \n"; } $currURL = $baseURI."?class=".$classID."&lang=".$pageLang. @@ -673,15 +734,21 @@ ($nextPeriod ? "&next" : ""); echo - " \n". -// " \n". - " \n". -// " \n". - " \n". - "
\n". + " \n". + " \n". + " \n". + "
\n". " \n". - "
". cmQM("period_shown").": ".($nextPeriod ? cmQM("next_period") : cmQM("current_period")). - "".cmQM("link_original_data")."XML".cmQM("link_mobile_version")."".cmQM("link_current_settings")."\"HDD.fi\"\"BatMUD\"\"Lukkari
\n". - "
\n". + " \n". + "
\n". + " \n". + "
\n". + "
\n". "

".$pageTitle."

\n"; +if (!$mobileMode) +{ + echo + "

".join("; ", $classInfo["general"]). + //" [".cmQM("viikossa", $classInfo["totalHours"])."]". + "

\n"; +} + // Show error messages if ($errorSet) { @@ -691,6 +758,8 @@ echo "\n"; } +echo "
\n"; + if ($haveData) { echo lukPrintTimeTable($mobileMode);