Mercurial > hg > lukkari
changeset 193:16ce445c499a v3 tip
Import v3 branch.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 22 Jan 2017 02:31:10 +0200 |
parents | 9f7eb4db99b4 |
children | |
files | index.php |
diffstat | 1 files changed, 174 insertions(+), 105 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ <?php // -// OAMK Lukkari v2.7 -// (C) Copyright 2010 - 2016 Matti 'ccr' Hämäläinen <ccr@tnsp.org> +// OAMK Lukkari v3.0 +// (C) Copyright 2010 - 2015 Matti 'ccr' Hämäläinen <ccr@tnsp.org> // 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 - "<br />". lukGetHourStamp($classHourTimes[$hour]["start"]). " - ". - lukGetHourStamp($classHourTimes[$hour]["end"]). - "<br /><br />"; + 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 = "<table><tr>"; - - // Calculate max columns and add course titles - $maxColumns = 0; + $out = ""; foreach ($data as $col) { - $out .= "<td>".lukMatchCourse($col[0])."</td>"; - if (count($col) > $maxColumns) - $maxColumns = count($col); - } - $out .= "</tr>"; + $out .= + $indent."<div class=\"group\">\n". + $indent." <div class=\"groupCell\">".lukMatchCourse($col[0])."</div>\n"; - // Print rest of the data - $ncol = 1; - for ($i = 1; $i < $maxColumns; $i++) - { - $out .= "<tr>"; - foreach ($data as $col) + for ($i = 1; $i < count($col); $i++) { - $out .= "<td>"; - if (isset($col[$i])) - $out .= chentities($col[$i]); - $out .= "</td>"; + $out .= + $indent." <div class=\"groupCell\">". + (isset($col[$i]) ? chentities($col[$i]) : ""). + "</div>\n"; } - $out .= "</tr>"; - $ncol++; + + $out .= $indent."</div>\n"; } - $out .= "</table>"; + if ($class["turns"]) + $out .= "<div class=\"groupCell eoWeekly\">".cmQM("vuoroviikoin")."</div>\n"; + + return $out; } else { - $out = lukMatchCourse($data[0][0])."<br />"; + $out = $indent."<div class=\"groupCell\">".lukMatchCourse($data[0][0])."</div>\n"; for ($i = 1; $i < count($data[0]); $i++) { - $out .= chentities($data[0][$i])."<br />"; + $out .= $indent."<div class=\"groupCell\">".chentities($data[0][$i])."</div>\n"; } - } - if ($class["turns"]) - $out .= cmQM("vuoroviikoin"); + if ($class["turns"]) + $out .= "<div class=\"groupCell eoWeekly\">".cmQM("vuoroviikoin")."</div>\n"; - return $out; + return $out; + } } @@ -391,48 +380,43 @@ $nextStamp = $currStamp + 30 * 60; $nextTime = $nextStamp - mktime(0, 0, 0); + + $out = + "<div id=\"timeTable\">\n"; // Create the timetable table if ($mini) { - $out = - "<table id=\"timeTable\">\n". - " <tr>\n". - " <th></th>". - " <th class=\"days\">".lukGetDayName($currDay)."</th>\n". - " </tr>\n"; - $startDay = $currDay; $lastDay = $currDay + 1; } else { - $out = - "<p>".join("; ", $classInfo["general"]). - //" [".cmQM("viikossa", $classInfo["totalHours"])."]". - "</p>\n". - "<table id=\"timeTable\">\n". - " <tr>\n". - " <th></th>\n"; - - $cellWidth = $classInfo["maxDays"] > 0 ? 100 / $classInfo["maxDays"] : 15; - if ($cellWidth > 25) $cellWidth = 25; - - for ($day = 0; $day < $classInfo["maxDays"]; $day++) - { - $out .= " <th style=\"width: ".$cellWidth."%;\" class=\"days\">".lukGetDayName($day)."</th>\n"; - } - $out .= " </tr>\n"; $startDay = 0; $lastDay = $classInfo["maxDays"]; } - + $out .= + " <div class=\"timeTableHourList\" style=\"width: ".($mini ? "20%" : "10%").";\">\n". + " <div class=\"timeTableWeekday\"> </div>\n"; for ($hour = $classInfo["firstHour"]; $hour < $classInfo["lastHour"]; $hour++) { - $out .= " <tr>\n". - " <th class=\"hours\">".lukGetHourStr($hour)."</th>\n"; - for ($day = $startDay; $day < $lastDay; $day++) + $out .= " <div class=\"timeTableHourBox\"><div class=\"timeTableHour\">".lukGetHourStr($hour)."</div></div>\n"; + } + $out .= " </div>\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 .= + " <div class=\"timeTableDay".($day == $currDay ? " active" : "")."\" ".$tmpS.">\n". + " <div class=\"timeTableWeekday\">".lukGetDayName($day)."</div>\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 .= " <td rowspan=\"".$class["hours"]."\" ". - "title=\"".lukClassGetHourStr($hour, $hour + $class["hours"] - 1)."\" class=\"". - ($isActive ? "clactive " : ""). - (!$isActive && $nextActive ? "clnext " : ""). - (($class["grouped"] || $class["turns"]) ? "clgrouped" : "clnormal")."\">". - lukGetClassInfo($class). - "<div class=\"nhours\"><span>".$class["hours"]."h</span></div></td>\n"; + $out .= + " <div class=\"classInfoBox\" style=\"height: ".($class["hours"] * 6)."em;\">\n". + " <div class=\"classInfo". + ($isActive ? " clactive" : ""). + (!$isActive && $nextActive ? " clnext " : ""). + (($class["grouped"] || $class["turns"]) ? " clgrouped" : " clnormal")."\">\n". + lukGetClassInfo($class, " "). + " <div class=\"nhours\"><span>".lukClassGetHourStr($hour, $hour + $class["hours"] - 1)." (".$class["hours"]."h)</span></div>\n". + " </div>\n". + " </div>\n"; } } else { - $out .= " <td class=\"clnothing\"></td>\n"; + $out .= " <div class=\"classInfoBox\"><div class=\"classInfo clnothing\"></div></div>\n"; } } - $out .= " </tr>\n"; + $out .= " </div>\n"; } - return $out."</table>\n"; + return $out."</div>\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 .= " <meta name=\"robots\" content=\"noindex\">\n"; + +// For mobile shit +$extra .= " <meta name=\"viewport\" content=\"width=device-width\" />\n"; // Start printing the page $pageTitle = $haveData ? $classID." / ".join("; ", $classInfo["info"]) : $classID; cmPrintPageHeader($pageTitle." - ".$pageName, $extra); +echo " +<script type=\"text/javascript\"> +function lukSetCookie(cname, cvalue, cctime) +{ + var de = new Date(); + de.setTime(de.getTime() + cctime*1000); + document.cookie = cname +\"=\"+ cvalue +\"; expires=\"+ de.toUTCString(); +} -// Info box +function lukSetViewDo(elem, state) +{ + elem.style.display = state ? 'block' : 'none'; +} + +function lukSetView(id, state) +{ + var elem = document.getElementById(id); + if (elem) lukSetViewDo(elem, state); +} + +function lukToggleView(id) +{ + var elem = document.getElementById(id); + if (elem) lukSetViewDo(elem, (elem.style.display == 'none')); +} + +function lukAcknowledgeCookies() +{ + lukSetCookie('lukcookieinfo', 1, 31*24*60*60); + var elem = document.getElementById('cookieInfo'); + if (elem) lukSetViewDo(elem, false); +} +</script> + +<div id=\"devInfo\" ".($showDevInfo ? "" : " style=\"display: none;\"")."> + <h1>Notice!</h1> + <p> + <b>This is the development version of 'Lukkari', tentatively called \"3.0alpha\".</b> + 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'. + </p> + <p> + If you wish to suggest features, send e-mail to <b>ccr (at) tnsp (dot) org</b> + </p> + <div class=\"popupControls\"> + <button type=\"button\" onClick=\"lukSetView('devInfo', false);\">Okay</button> + </div> +</div> +"; + +if ($showCookieInfo) +{ + echo + "<div id=\"cookieInfo\">\n". + " <p>Lukkari web-site uses <a href=\"http://en.wikipedia.org/wiki/HTTP_cookie\">HTTP cookies</a> ". + " to store current settings (language, default class ID, etc.) ". + " Also, Google Analytics used on this site may store information via cookies.". + " </p>". + " By continued use of this site, you acknowledge that you have been informed of the situation.". + " <div class=\"popupControls\">\n". + " <button type=\"button\" onclick=\"lukAcknowledgeCookies()\">Okay</button>\n". + " </div>\n". + "</div>\n"; +} + + +// Additional controls echo - "<div id=\"infobox\">\n". - " <div id=\"ctitle\">".$pageName." v".$pageVersion."</div>\n"; + " <div id=\"controls\">\n". + " <div id=\"infobox\">\n". + " <div id=\"ctitle\">".$pageName." v".$pageVersion."</div>\n"; if (!$mobileMode) { echo - " <div id=\"csssel\">".cmQM("Style").": "; + " <div id=\"csssel\">".cmQM("Style").": "; if (isset($pageCSSAlts)) { @@ -611,8 +680,7 @@ "</div>\n"; } -echo - " <div id=\"clang\">"; +echo " <div id=\"clang\">"; foreach ($pageLanguages as $id) { @@ -622,16 +690,10 @@ } echo - "</div>\n". - "</div>\n"; - - -// Additional controls -echo - "<form id=\"controls\" action=\"".$baseURI."\" method=\"get\">\n". - " <table>\n". - " <tr>\n". - " <th>\n". + " </div>\n". + " </div>\n". + " <form action=\"".$baseURI."\" method=\"get\">\n". + " <div>\n". " <select id=\"classSelect\" name=\"class\" onChange=\"this.form.submit();\">\n"; if ($classIDs !== FALSE) @@ -646,26 +708,25 @@ echo " </select>\n". - " </th>\n". - " <noscript><th><input id=\"classSwitch\" class=\"submit\" type=\"submit\" value=\"".cmQM("change")."\" /></th></noscript>\n"; + " </div>\n". + " <noscript><div><input id=\"classSwitch\" class=\"submit\" type=\"submit\" value=\"".cmQM("change")."\" /></div></noscript>\n"; if (!$mobileMode) { echo - " <th><a id=\"next\" class=\"textctrl\" href=\"". + " <div><a id=\"nextPeriod\" class=\"textctrl\" href=\"". $baseURI.($nextPeriod ? "" : "?next")."\" title=\"".cmQM("expl_toggle_period")."\">". cmQM("period_shown").": ".($nextPeriod ? cmQM("next_period") : cmQM("current_period")). - "</a></th>\n"; + "</a></div>\n"; if ($haveData) { echo - " <th><a id=\"orig\" class=\"textctrl\" href=\"".$origBaseURI.$classID.$origBaseExt."\" title=\"".cmQM("expl_link_original_data")."\">".cmQM("link_original_data")."</a></th>\n"; - //" <th><a id=\"xml\" class=\"textctrl\" href=\"".$baseURI.$cachePath."/".$class.".xml\">XML</a></th>\n"; + " <div><a id=\"origLink\" class=\"textctrl\" href=\"".$origBaseURI.$classID.$origBaseExt."\" title=\"".cmQM("expl_link_original_data")."\">".cmQM("link_original_data")."</a></div>\n"; + //" <div><a id=\"xml\" class=\"textctrl\" href=\"".$baseURI.$cachePath."/".$class.".xml\">XML</a></div>\n"; } - echo - " <th><a class=\"textctrl mobile\" href=\"http://tnsp.org/mluk/\" title=\"".cmQM("expl_link_mobile_version")."\">".cmQM("link_mobile_version")."</a></th>\n"; +// echo " <div><a id=\"mobileLink\" class=\"textctrl mobile\" href=\"http://tnsp.org/mluk/\" title=\"".cmQM("expl_link_mobile_version")."\">".cmQM("link_mobile_version")."</a></div>\n"; } $currURL = $baseURI."?class=".$classID."&lang=".$pageLang. @@ -673,15 +734,21 @@ ($nextPeriod ? "&next" : ""); echo - " <th><a href=\"".$currURL."\" class=\"textctrl\" title=\"".cmQM("expl_link_current_settings")."\">".cmQM("link_current_settings")."</a></th>\n". -// " <th class=\"advert\"><a href=\"http://tnsp.org/u/G1X\"><img src=\"img/hdd_fi.gif\" alt=\"HDD.fi\" /></a></th>\n". - " <th class=\"advert\"><a href=\"http://tnsp.org/u/H9w\"><img src=\"img/batmud.png\" alt=\"BatMUD\" /></a></th>\n". -// " <th><a href=\"http://tnsp.org/testluk/\"><img src=\"img/test.png\" alt=\"Lukkari v3\" /></a></th>\n". - " </tr>\n". - " </table>\n". - "</form>\n". + " <div><a href=\"".$currURL."\" class=\"textctrl\" title=\"".cmQM("expl_link_current_settings")."\">".cmQM("link_current_settings")."</a></div>\n". + " <div><button id=\"toggleDevInfo\" type=\"button\" onclick=\"lukToggleView('devInfo')\">INFO</button></div>\n". + " </form>\n". + "</div>\n". + "<div id=\"header\">\n". "<h1>".$pageTitle."</h1>\n"; +if (!$mobileMode) +{ + echo + "<p>".join("; ", $classInfo["general"]). + //" [".cmQM("viikossa", $classInfo["totalHours"])."]". + "</p>\n"; +} + // Show error messages if ($errorSet) { @@ -691,6 +758,8 @@ echo "</ul>\n"; } +echo "</div>\n"; + if ($haveData) { echo lukPrintTimeTable($mobileMode);