annotate index.php @ 45:d8a1e85b8dda

Change the visual style a tiny bit.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 24 Sep 2012 16:45:40 +0300
parents 57af36f0864e
children d41b51cd4ae5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
41
40d6c44c97ec Use <?php tag (aka long tag)
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
1 <?php
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
2 //
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
3 // Yes, this is horrible. :|
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
4 //
45
d8a1e85b8dda Change the visual style a tiny bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
5 $pageCSS = array("luk.css");
38
2195ede068c8 Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 37
diff changeset
6 $pageCharset = "utf-8";
2195ede068c8 Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 37
diff changeset
7 $internalCharset = "utf-8";
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 $luokkaDefault = "TTE9SNO";
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
9 $classFile = "luokat.txt";
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 $mapFile = "kartta.png";
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
11 $roomFile = "luokkatilat.txt";
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 $cacheFile = "coursecache.txt";
16
ea9558465ad6 Add link to original data, fix left-over beta stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
13 $baseURI = "http://tnsp.org/luk/";
30
6148ce4a83ed Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
14 //$infoURI = "http://www.oamk.fi/opiskelijalle/rakenne/opinto-opas/koulutusohjelmat/?sivu=oj&kieli=FI&opas=2010-2011&vuosi=10S11K&koodi1=";
6148ce4a83ed Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
15 $infoURI = "http://www.oamk.fi/opiskelijalle/rakenne/opinto-opas/koulutusohjelmat/?sivu=oj&kieli=FI&koodi1=";
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 $dayNames = array("Maanantai", "Tiistai", "Keskiviikko", "Torstai", "Perjantai", "Lauantai", "Sunnuntai");
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
18 $hourStamps = array(
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
19 array( 8, 15),
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
20 array( 9, 15),
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
21 array(10, 15),
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
22 array(11, 15),
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
23 array(12, 15),
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
24 array(13, 15),
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
25 array(14, 15),
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
26 array(15, 15),
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
27 array(16, 15),
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
28 array(17, 5),
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
29 array(18, 5),
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
30 array(19, 0),
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
31 array(20, 45),
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
32 );
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
33
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
34 // Include framework
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 require "mcommon.inc.php";
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 require "merrors.inc.php";
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37
2
2471bb891299 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
38
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
39 // Helper functions
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
40 function lukChEntities($str)
38
2195ede068c8 Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 37
diff changeset
41 {
2195ede068c8 Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 37
diff changeset
42 global $internalCharset;
2195ede068c8 Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 37
diff changeset
43 // return $str;
2195ede068c8 Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 37
diff changeset
44 return htmlentities($str, ENT_NOQUOTES, $internalCharset);
2195ede068c8 Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 37
diff changeset
45 }
2195ede068c8 Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 37
diff changeset
46
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
47 function lukCheckClassID(&$id)
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 {
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 global $luokkaDefault;
23
b4b86915ae2c Better input validation for $_GET arguments, thanks to Hjalmarr for pointing out the error.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
50 if (preg_match("#^([A-Z]{3}\d[A-Za-z0-9_]{1,6}|ccr|Ryh_[A-Z]{3}\d[A-Za-z0-9_]{1,6})$#", $id, $m)) {
b4b86915ae2c Better input validation for $_GET arguments, thanks to Hjalmarr for pointing out the error.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
51 $id = $m[1];
b4b86915ae2c Better input validation for $_GET arguments, thanks to Hjalmarr for pointing out the error.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
52 return TRUE;
b4b86915ae2c Better input validation for $_GET arguments, thanks to Hjalmarr for pointing out the error.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
53 } else {
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
54 errorMsg("Virhe! Luokan täytyy olla muotoa <b>XXXnXXX</b>, käytetään vakioarvoa <b>".$luokkaDefault."</b>.");
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 $id = $luokkaDefault;
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 return FALSE;
23
b4b86915ae2c Better input validation for $_GET arguments, thanks to Hjalmarr for pointing out the error.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
57 }
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
60 function lukMakeHourStamp($hour, $sec = 0, $mon = 0, $day = 0, $year = 0)
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
61 {
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
62 global $hourStamps;
17
611452d30bd4 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
63 if (isset($hourStamps[$hour]))
20
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
64 return mktime($hourStamps[$hour][0], $hourStamps[$hour][1], $sec, $mon, $year);
17
611452d30bd4 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
65 else
20
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
66 return mktime($hour + 8, 0, $sec, $mon, $year);
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
67 }
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
68
17
611452d30bd4 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
69
20
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
70 function getHour($hour)
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
71 {
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
72 $stamp = lukMakeHourStamp($hour);
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
73 return "<br />".date("H:i", $stamp)." - ".date("H:i", $stamp + 45 * 60)."<br /><br />";
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
74 }
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
75
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
76
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
77 function lukMatchCourse($id)
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 {
38
2195ede068c8 Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 37
diff changeset
79 global $cache, $infoURI, $cacheDirty, $internalCharset;
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 // Check if course exists in cache
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 if (!isset($cache[$id])) {
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 $cacheDirty = TRUE;
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 // Not cached, try to fetch data
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 $data = @file_get_contents($infoURI.$id);
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 if ($data !== FALSE) {
38
2195ede068c8 Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 37
diff changeset
87 $data = iconv("iso-8859-1", $internalCharset, $data);
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88 if (preg_match("#<td class=\"smallheadercell\"><strong>(.+?)\s+(\d+)\s*op\s*</strong></td>#", $data, $m)) {
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 // Add data to cache
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 $cache[$id] = array("desc" => $m[1], "op" => intval($m[2]));
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 if (isset($cache[$id]))
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
96 return "<a target=\"_blank\" title=\"".lukChEntities($id." - ".$cache[$id]["op"]." op").
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
97 "\" href=\"".lukChEntities($infoURI.$id)."\">".lukChEntities($cache[$id]["desc"])."</a>";
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 else
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
99 return lukChEntities($id);
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
103 function lukMatchClass($matches)
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 {
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 global $baseURI;
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
106 return "<b><a href=\"".$baseURI."?tila=".$matches[1]."\">".$matches[1]."</a></b> ".$matches[2];
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109
39
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
110 // Check for mini-info mode
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
111 $miniMode = isset($_GET["nyt"]);
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
112
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
113 // Check given parameters
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
114 if (isset($_GET["luokka"])) {
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
115 $luokka = $_GET["luokka"];
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
116 if (lukCheckClassID($luokka) && !$miniMode) {
39
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
117 setcookie("lukluokka", $luokka, time() + 365*24*60*60); // expire in a year
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
118 }
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
119 } else
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
120 if (isset($_COOKIE["lukluokka"])) {
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
121 $luokka = $_COOKIE["lukluokka"];
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
122 lukCheckClassID($luokka);
39
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
123 } else {
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
124 errorMsg("Luokkaa ei asetettu, käytetään vakioarvoa <b>".$luokkaDefault."</b>.");
39
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
125 $luokka = $luokkaDefault;
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
126 }
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
127
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
128
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
129 if (isset($_GET["tila"])) {
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
130 $tila = $_GET["tila"];
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
131 echo "Luokkatilan n&auml;ytt&ouml;moodi ei viel&auml; tuettu.<br />\n";
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
132 exit;
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
133
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
134 $fp = @fopen($roomFile, "rb");
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
135 if ($fp) {
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
136 fclose($fp);
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
137 }
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
138 }
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
139
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
140
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
141 if (isset($_GET["next"])) {
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
142 $nextPeriod = TRUE;
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
143 $dataFile = "cache-next/".$luokka.".data";
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
144 } else {
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
145 $nextPeriod = FALSE;
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
146 $dataFile = "cache/".$luokka.".data";
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
147 }
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
148
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
149
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150 // Global cache for course data
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 $cache = array();
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152 $cacheDirty = FALSE;
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154 // Try to read cachefile, if we can get file lock on it
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155 $fp = @fopen($cacheFile, "rb");
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156 if ($fp) {
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 if (flock($fp, LOCK_SH)) {
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158 require($cacheFile);
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 flock($fp, LOCK_UN);
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 fclose($fp);
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
164
28
ab06d838d916 Cosmetics & comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
165 // Read classfile
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
166 $fp = @fopen($classFile, "rb");
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
167 $classes = array();
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
168 if ($fp) {
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
169 if (flock($fp, LOCK_SH)) {
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
170 while (!feof($fp)) {
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
171 $str = trim(fgets($fp, 128));
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
172 if (strlen($str) > 2 && $str[0] != "#")
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
173 $classes[] = $str;
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
174 }
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
175 flock($fp, LOCK_UN);
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
176 }
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
177 fclose($fp);
17
611452d30bd4 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
178 } else {
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
179 errorMsg("Luokkien listaa ei löytynyt. Kokeile ladata sivu uudelleen hetken kuluttua.");
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182
31
dbe7ff545293 Add support for fetching and showing data for next/upcoming period.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
183 if (!file_exists($dataFile)) {
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
184 errorMsg("Luokan ".lukChEntities($luokka)." tietoja ei löytynyt! ".
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
185 "Jos luokkakoodi on uusi, ilmestyy se järjestelmään seuraavan ".
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
186 "päivityksen aikana. Luokkatiedot päivitetään kerran viikossa.");
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
187 $haveData = FALSE;
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
188 } else {
31
dbe7ff545293 Add support for fetching and showing data for next/upcoming period.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
189 require($dataFile);
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
190 $haveData = isset($classDefs);
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
193
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
194 function lukPrintHourInfo($dayHours, $showDays)
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
195 {
37
3ba4feff55cb Partially convert to UTF-8.
Matti Hamalainen <ccr@tnsp.org>
parents: 31
diff changeset
196 $out = " <tr>\n <td>Tunteja<br />(<b>ryhmä/vv</b>)</td>\n";
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
197 for ($day = 0; $day < $showDays; $day++) {
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
198 $out .= " <td>".$dayHours[$day]["total"]."h (<b>".$dayHours[$day]["grouped"]."h</b>)</td>\n";
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
199 }
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
200 return $out." </tr>\n";
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
204 function lukResolveHours($start, $day, $cmp, $mark = FALSE)
12
306028aa2253 Fix hour counts when table has been modified.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
205 {
306028aa2253 Fix hour counts when table has been modified.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
206 global $classHourTable, $classInfo;
306028aa2253 Fix hour counts when table has been modified.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
207 $n = 0;
306028aa2253 Fix hour counts when table has been modified.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
208 for ($i = $start; $i < $classInfo["maxhours"]; $i++)
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
209 if ($classHourTable[$i][$day] == $cmp) {
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
210 if ($mark) $classHourTable[$i][$day] = -9999;
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
211 $n++;
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
212 } else
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
213 break;
12
306028aa2253 Fix hour counts when table has been modified.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
214 return $n;
306028aa2253 Fix hour counts when table has been modified.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
215 }
306028aa2253 Fix hour counts when table has been modified.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
216
306028aa2253 Fix hour counts when table has been modified.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
217
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
218 function lukFindNextActiveHour(&$j, &$i, $day, $hour, $chk)
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
219 {
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
220 global $classInfo, $classHourTable;
20
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
221 // for ($j = $day; $j < $classInfo["maxdays"]; $j++)
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
222 $j = $day;
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
223 for ($i = $hour; $i < $classInfo["maxhours"]; $i++) {
20
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
224 if ($chk > 0 && $classHourTable[$i][$j] != $chk)
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
225 return $classHourTable[$i][$j];
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
226
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
227 if ($classHourTable[$i][$j] > 0 && $classHourTable[$i][$j] != $chk)
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
228 return $classHourTable[$i][$j];
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
229 }
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
230
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
231 return -1;
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
232 }
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
233
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
234
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
235 function lukGetHourInfo($isSplit, $d)
19
777791321149 Modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
236 {
777791321149 Modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
237 if ($isSplit) {
777791321149 Modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
238 $out = "<table>".
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
239 "<tr><td>".lukMatchCourse($d[0])."</td><td>".lukMatchCourse($d[1])."</td></tr>";
19
777791321149 Modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
240
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
241 for ($i = 2; $i < count($d); $i += 2)
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
242 $out .= "<tr><td>".lukChEntities($d[$i])."</td><td>".(isset($d[$i+1]) ? lukChEntities($d[$i+1]) : "")."</td></tr>";
19
777791321149 Modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
243
777791321149 Modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
244 return $out."</table>";
777791321149 Modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
245 } else {
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
246 $out = lukMatchCourse($d[0])."<br />";
19
777791321149 Modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
247
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
248 for ($i = 1; $i < count($d); $i++)
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
249 $out .= lukChEntities($d[$i])."<br />";
19
777791321149 Modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
250
777791321149 Modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
251 return $out;
777791321149 Modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
252 }
777791321149 Modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
253 }
777791321149 Modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
254
777791321149 Modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
255
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
256 function lukGetHourInfoData($id)
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
257 {
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
258 global $classDefs;
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
259
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
260 if (isset($id)) {
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
261 if ($id >= 0 && isset($classDefs[$id])) {
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
262 $i = $classDefs[$id];
19
777791321149 Modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
263 $isSplit = preg_match("/^[A-Z]\d{6}$/", $i["data"][1]);
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
264 return lukGetHourInfo($isSplit, $i["data"]);
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
265 } else
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
266 return "<p>Ei tunteja.</p>";
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
267 } else
37
3ba4feff55cb Partially convert to UTF-8.
Matti Hamalainen <ccr@tnsp.org>
parents: 31
diff changeset
268 return "<p>Ei mitään.</p>";
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
269
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
270 return "";
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
271 }
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
272
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
273
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
274 $out = "";
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
275
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
276 if ($miniMode && $haveData) {
20
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
277 $stamp = time();
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
278 $aika = getdate($stamp);
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
279 $day = $aika["wday"] - 1;
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
280 if ($day < 0) $day = 7;
20
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
281 $hour = $aika["hours"] - 8;
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
282
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
283 $out = "<div class=\"content\">\n";
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
284
45
d8a1e85b8dda Change the visual style a tiny bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
285 if ($hour >= 0 && $day >= 0 && $hour < sizeof($classHourTable))
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
286 {
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
287 $id = $classHourTable[$hour][$day];
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
288 $out .=
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
289 "<h2>".$dayNames[$day]." ".date("d.n.Y", $stamp)." - klo ".date("H:i", $stamp)."</h2>\n".
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
290 lukGetHourInfoData($id)."\n";
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
291 }
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
292
20
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
293
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
294 if (isset($id) && $id >= 0 && isset($classDefs[$id])) {
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
295 $i = $classDefs[$id];
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
296 $start = lukMakeHourStamp($i["start"]);
20
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
297 }
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
298
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
299 // echo "day=$day, hour=$hour, id=$id<br />\n";
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
300
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
301 if ($day >= $classInfo["maxdays"]) {
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
302 $day = $hour = 0;
20
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
303 $id = -1;
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
304 } else
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
305 if ($hour < 0) {
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
306 $hour = 0;
20
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
307 $id = -1;
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
308 } else
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
309 if ($hour >= $classInfo["maxhours"]) {
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
310 $day++;
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
311 $hour = 0;
20
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
312 $id = -1;
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
313 }
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
314
20
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
315 // echo "day=$day, hour=$hour, id=$id<br />\n";
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
316 $found = lukFindNextActiveHour($nday, $nhour, $day, $hour, $id);
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
317
20
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
318 // echo "nday=$nday, nhour=$nhour, id=$found<br />\n";
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
319
20
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
320 $out .= "<h2>Seuraavaksi";
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
321 if ($found > 0) {
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
322 $stamp = lukMakeHourStamp($nhour, 0, 0, $aika["mon"], $aika["mday"] + $nday - $day, $aika["year"]);
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
323 $aika = getdate($stamp);
20
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
324 $out .= ": ".$dayNames[$nday]." ".date("d.n.Y", $stamp)." - klo ".date("H:i", $stamp)."</h2>\n".
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
325 lukGetHourInfoData($found)."\n";
20
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
326 } else {
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
327 $out .= "</h2>\n".
37
3ba4feff55cb Partially convert to UTF-8.
Matti Hamalainen <ccr@tnsp.org>
parents: 31
diff changeset
328 "<p>Ei mitään</p>\n";
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
329 }
20
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
330
d9df76217991 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
331 $out .= "</div>\n";
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
332 }
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
333 else
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
334 if ($haveData) {
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
335 $totalHours = 0;
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
336 $totalGrouped = 0;
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
337 $dayHours = array();
7
2bb40c5945bc Remove useless variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
338
11
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
339 for ($day = 0; $day < $classInfo["maxdays"]; $day++) {
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
340 $dayHours[$day]["total"] = $dayHours[$day]["grouped"] = 0;
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
341
11
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
342 for ($hour = 0; $hour < $classInfo["maxhours"]; $hour++) {
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
343 $id = $classHourTable[$hour][$day];
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
344
11
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
345 if ($id > 0) {
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
346 $totalHours++;
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
347 $dayHours[$day]["total"]++;
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
348
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
349 if ($classDefs[$id]["grouped"]) {
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
350 $totalGrouped++;
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
351 $dayHours[$day]["grouped"]++;
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
352 }
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
353 }
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
354 }
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
355 }
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
356
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
357 // Create the timetable table
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
358 $out =
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
359 "<p>".join("; ", $classInfo["general"])."</p>\n".
37
3ba4feff55cb Partially convert to UTF-8.
Matti Hamalainen <ccr@tnsp.org>
parents: 31
diff changeset
360 "<div>Viikossa yhteensä <b>".$totalHours."</b> tuntia, joista <b>".$totalGrouped."</b> ryhmissä tai vuoroviikoin.</div>\n".
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
361 "<table class=\"timetable\">".
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
362 " <tr>\n <th></th>\n";
7
2bb40c5945bc Remove useless variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
363 for ($day = 0; $day < $classInfo["maxdays"]; $day++) {
18
e0f1a5861f28 Fixes, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
364 $out .= " <th style=\"width: ".(100 / $classInfo["maxdays"]).
e0f1a5861f28 Fixes, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
365 "%;\" class=\"days\">".$dayNames[$day]."</th>\n";
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
366 }
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
367 $out .= " </tr>\n";
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
368
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
369 for ($hour = 0; $hour < $classInfo["maxhours"]; $hour++) {
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
370 $out .= " <tr>\n".
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
371 " <th class=\"hours\">".getHour($hour)."</th>\n";
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
372 for ($day = 0; $day < $classInfo["maxdays"]; $day++) {
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
373 if (isset($classHourTable[$hour][$day])) {
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
374 $h = $classHourTable[$hour][$day];
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
375
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
376 if ($h < 1) {
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
377 if ($h > -9999) {
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
378 $n = lukResolveHours($hour, $day, $h, TRUE);
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
379 $out .= " <td rowspan=\"".$n."\" class=\"clnothing\"></td>\n";
12
306028aa2253 Fix hour counts when table has been modified.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
380 }
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
381 } else
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
382 if (isset($classDefs[$h])) {
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
383 if (!isset($classDefs[$h]["done"])) {
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
384 $classDefs[$h]["done"] = true;
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
385 $i = $classDefs[$h];
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
386 $d = $classDefs[$h]["data"];
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
387
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
388 $isSplit = preg_match("/^[A-Z]\d{6}$/", $d[1]);
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
389
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
390 $hours = lukResolveHours($hour, $day, $h, FALSE);
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
391 if ($hours != $i["hours"]) {
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
392 errorMsg("Internal error, cell $hour / $day : hour id $h hours ($hours) do not match ".$i["hours"]."!");
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
393 }
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
394
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
395 $out .= " <td rowspan=\"".$hours.
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
396 "\" class=\"".($isSplit || $i["grouped"] ? "clgrouped" : "clnormal")."\">".
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
397 lukGetHourInfo($isSplit, $d).
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
398 "<div class=\"nhours\"><span>".$hours."h</span></div></td>\n";
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
399 }
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
400 } else
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
401 errorMsg("Internal error cell $hour / $day : hour id $h does not exist!");
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
402 } else
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
403 errorMsg("Internal error, cell $hour / $day does not exist.");
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
404 }
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
405 $out .= " </tr>\n";
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
406 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
407
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
408 $out .= lukPrintHourInfo($dayHours, $classInfo["maxdays"]).
14
a2c61b010680 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 13
diff changeset
409 "</table>\n";
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
410
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
411 } // haveData
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
412
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
413
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
414 $pageTitle = $haveData ? $luokka." / ".join("; ", $classInfo["info"]) : $luokka;
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
415 printPageHeader($pageTitle);
18
e0f1a5861f28 Fixes, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
416
e0f1a5861f28 Fixes, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
417 if ($miniMode) echo "<div id=\"mini\">\n";
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
418
18
e0f1a5861f28 Fixes, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
419 echo
30
6148ce4a83ed Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
420 "<form id=\"controls\" action=\"".$baseURI."\" method=\"get\">
6148ce4a83ed Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
421 <table>
6148ce4a83ed Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
422 <tr>
45
d8a1e85b8dda Change the visual style a tiny bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
423 <th>
30
6148ce4a83ed Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
424 <select name=\"luokka\">
6148ce4a83ed Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
425 ";
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
426
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
427 foreach ($classes as $class) {
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
428 echo " <option ".($luokka == $class ? "selected=\"selected\" " : "")."value=\"".$class."\">".lukChEntities($class)."</option>\n";
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
429 }
30
6148ce4a83ed Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
430 echo
6148ce4a83ed Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
431 " </select>
45
d8a1e85b8dda Change the visual style a tiny bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
432 </th>
d8a1e85b8dda Change the visual style a tiny bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
433 <th><input class=\"submit\" type=\"submit\" value=\" Vaihda \" /></th>
d8a1e85b8dda Change the visual style a tiny bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
434 <th><a href=\"".$baseURI."?luokka=".$luokka;
17
611452d30bd4 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
435
611452d30bd4 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
436 if ($miniMode)
611452d30bd4 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
437 echo "\">Normaali";
611452d30bd4 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
438 else
611452d30bd4 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
439 echo "&amp;nyt\">Mini-info";
611452d30bd4 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
440
45
d8a1e85b8dda Change the visual style a tiny bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
441 echo "</a></th>
d8a1e85b8dda Change the visual style a tiny bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
442 <th><a href=\"http://www.oamk.fi/tyojarjestykset/otek/luokat/OR_".$luokka.".htm\">Alkuperäinen</a></th>
39
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
443
45
d8a1e85b8dda Change the visual style a tiny bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
444 <th><a href=\"".$baseURI.($nextPeriod ? "" : "?next")."\">".($nextPeriod ? "Nykyinen" : "Seuraava")." periodi</a></th>
30
6148ce4a83ed Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
445 </tr>
6148ce4a83ed Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
446 </table>
6148ce4a83ed Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
447 </form>
6148ce4a83ed Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
448 ";
13
57dd1db922c2 Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
449
18
e0f1a5861f28 Fixes, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
450 echo "<h1>".$pageTitle."</h1>\n";
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
451
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
452 // Show error messages
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
453 if ($errorSet) {
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
454 echo "<ul>\n";
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
455 foreach ($errorMsgs as $msg)
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
456 echo "<li>$msg</li>\n";
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
457 echo "</ul>\n";
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
458 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
459
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
460 echo $out;
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
461
28
ab06d838d916 Cosmetics & comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
462 echo "<div style=\"position: relative; top: 5em; font-size: 5pt;\"><hr />
37
3ba4feff55cb Partially convert to UTF-8.
Matti Hamalainen <ccr@tnsp.org>
parents: 31
diff changeset
463 Yhteydenotot <b>ccr @ IRCNet</b> tai <b>ccr at tnsp dot org</b>. En vastaa mahdollisista virheistä tiedoissa!
30
6148ce4a83ed Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
464 </div>
6148ce4a83ed Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
465 ";
18
e0f1a5861f28 Fixes, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
466
e0f1a5861f28 Fixes, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
467 if ($miniMode) echo "</div>\n";
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
468 printPageFooter();
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
469
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
470
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
471 // Dump the course data cache, but only if it has changed
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
472 if ($cacheDirty) {
27
7655db03ea60 Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
473 // Create string containing the data
7655db03ea60 Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
474 $str = "<?\n\$cache = array(\n";
7655db03ea60 Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
475 foreach ($cache as $id => $data) {
7655db03ea60 Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
476 $str .= " \"".addslashes($id)."\" => array(\"desc\" => \"".
7655db03ea60 Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
477 addslashes($data["desc"])."\", \"op\" => ".$data["op"]."),\n";
7655db03ea60 Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
478 }
7655db03ea60 Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
479 $str .= ");\n?>";
7655db03ea60 Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
480
7655db03ea60 Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
481 // Use locking to prevent concurrent access and dump data
7655db03ea60 Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
482 if (file_put_contents($cacheFile, $str, LOCK_EX) === FALSE) {
7655db03ea60 Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
483 // Can't do much anything here ..
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
484 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
485 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
486
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
487 ?>