Mercurial > hg > lukkari
annotate index.php @ 129:b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 27 Aug 2014 16:36:39 +0300 |
parents | 0f451151b9f1 |
children | 7cfe0770168f |
rev | line source |
---|---|
59 | 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 // |
127
1e44468dbbd8
Various style changes, and add indicators to currently selected language and
Matti Hamalainen <ccr@tnsp.org>
parents:
126
diff
changeset
|
3 // OAMK Lukkari v2.3 |
118 | 4 // (C) Copyright 2010 - 2014 Matti 'ccr' Hämäläinen <ccr@tnsp.org> |
65 | 5 // Yes, this code is rather horrible. :| |
43
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
6 // |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
7 // Include framework |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
8 require "mcommon.inc.php"; |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
9 |
127
1e44468dbbd8
Various style changes, and add indicators to currently selected language and
Matti Hamalainen <ccr@tnsp.org>
parents:
126
diff
changeset
|
10 $pageVersion = "2.3"; |
117 | 11 $baseURI = "http://tnsp.org/luk/"; |
64
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
12 $pageLang = "fi"; |
115 | 13 $pageLanguages = array("fi", "en"); |
14 $pageCSSData = array("cookie" => "lukcss", "prefix" => $baseURI."luk"); | |
15 $pageCSSAlts = array("blue" => "1", "old" => "2", "purple" => "3", "dark" => "4"); | |
16 | |
105 | 17 $classDefault = "TTE1SNO"; |
82
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
18 $classIDFile = "classes.txt"; |
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
19 $courseCacheFile = "coursecache.txt"; |
1 | 20 |
63 | 21 $lukDayNames = array( |
22 "fi" => array("Maanantai", "Tiistai", "Keskiviikko", "Torstai", "Perjantai", "Lauantai", "Sunnuntai"), | |
23 "en" => array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"), | |
24 ); | |
25 | |
98
6a7172b3a841
Update to match the main page API.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
26 $pageTranslations = array( |
63 | 27 "Original" => array("fi" => "Alkuperäinen"), |
100
055c33cba66e
Make the current/next period button a bit clearer ..
Matti Hamalainen <ccr@tnsp.org>
parents:
98
diff
changeset
|
28 |
055c33cba66e
Make the current/next period button a bit clearer ..
Matti Hamalainen <ccr@tnsp.org>
parents:
98
diff
changeset
|
29 "Shown" => array("fi" => "Näkyvillä"), |
63 | 30 "Next period" => array("fi" => "Seuraava periodi"), |
31 "Current period" => array("fi" => "Nykyinen periodi"), | |
32 "Switch" => array("fi" => "Vaihda"), | |
33 | |
34 "contact" => array( | |
126 | 35 "en" => "Contact <b>%1</b> or <b>%2</b>. The author can't be held responsible for any errors or inaccuracies in the data!", |
36 "fi" => "Yhteydenotot <b>%1</b> tai <b>%2</b>. En vastaa mahdollisista virheistä tai epätarkkuuksista tiedoissa!", | |
63 | 37 ), |
38 | |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
39 "updated" => array( |
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
40 "en" => "Last updated: <b>%1</b>.", |
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
41 "fi" => "Päivitetty: <b>%1</b>.", |
103
38e9772901f1
Add in hdd.fi advertisement.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
42 ), |
38e9772901f1
Add in hdd.fi advertisement.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
43 |
63 | 44 "beta" => array( |
126 | 45 "en" => " NOTICE! OAMK Lukkari v%1 is still under development. There may be bugs.", |
46 "fi" => " HUOM! OAMK Lukkari v%1 on vielä kehityksen alla. Bugeja voi löytyä.", | |
63 | 47 ), |
48 | |
49 "viikossa" => array( | |
50 "en" => "Total of <b>%1</b> hours in the week.", | |
51 "fi" => "Viikossa yhteensä <b>%1</b> tuntia.", | |
52 ), | |
53 | |
54 "classNotSet" => array( | |
55 "en" => "Class not set, using default <b>%1</b>.", | |
56 "fi" => "Luokkaa ei asetettu, käytetään vakioarvoa <b>%1</b>.", | |
57 ), | |
89
f9cd4c5ca3d6
Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
88
diff
changeset
|
58 |
f9cd4c5ca3d6
Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
88
diff
changeset
|
59 "classDataNotFound" => array( |
f9cd4c5ca3d6
Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
88
diff
changeset
|
60 "fi" => "Luokan %1 tietoja ei löytynyt! Jos luokkakoodi on uusi, ". |
f9cd4c5ca3d6
Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
88
diff
changeset
|
61 "ilmestyy se järjestelmään seuraavan päivityksen aikana. Luokkatiedot ". |
f9cd4c5ca3d6
Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
88
diff
changeset
|
62 "päivitetään kerran viikossa.", |
f9cd4c5ca3d6
Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
88
diff
changeset
|
63 "en" => "Data for class %1 was not found. If the class code is new, it ". |
f9cd4c5ca3d6
Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
88
diff
changeset
|
64 "should appear in this system during the next update. The data is updated ". |
f9cd4c5ca3d6
Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
88
diff
changeset
|
65 "once per week.", |
f9cd4c5ca3d6
Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
88
diff
changeset
|
66 ), |
63 | 67 |
106
e7bd58dec4f3
Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
68 "classListNotFound" => array( |
e7bd58dec4f3
Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
69 "fi" => "Luokkien listaa ei löytynyt. Kokeile ladata sivu uudelleen hetken kuluttua.", |
e7bd58dec4f3
Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
70 "en" => "Class list not found. An update may be in progress, try reloading in a minute.", |
e7bd58dec4f3
Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
71 ), |
e7bd58dec4f3
Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
72 |
e7bd58dec4f3
Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
73 "classFormatError" => array( |
e7bd58dec4f3
Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
74 "fi" => "Virhe! Luokan täytyy olla muotoa <b>XXXnXXX</b>, käytetään vakioarvoa <b>%1</b>.", |
e7bd58dec4f3
Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
75 "en" => "Error! Class code must be of format <b>XXXnXXX</b>, using default value of <b>%1</b>.", |
e7bd58dec4f3
Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
76 ), |
e7bd58dec4f3
Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
77 |
114 | 78 "Style" => array( |
79 "fi" => "Tyyli", | |
80 ), | |
119
78b4eb3a9719
Add link to the page with current settings, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
81 |
78b4eb3a9719
Add link to the page with current settings, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
82 "currLukLink" => array( |
78b4eb3a9719
Add link to the page with current settings, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
83 "fi" => "Linkki tähän lukujärjestykseen nykyisillä asetuksilla (kieli, jne.)", |
78b4eb3a9719
Add link to the page with current settings, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
84 "en" => "Link to the this timetable with current settings (language, etc.)", |
78b4eb3a9719
Add link to the page with current settings, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
85 ), |
63 | 86 // "" => array("fi" => ), |
87 ); | |
88 | |
89 | |
90 function lukGetDayName($day) | |
91 { | |
92 global $lukDayNames, $pageLang; | |
93 | |
94 if (isset($lukDayNames[$pageLang]) && isset($lukDayNames[$pageLang][$day])) | |
95 return $lukDayNames[$pageLang][$day]; | |
96 else | |
97 return $lukDayNames["en"][$day]; | |
98 } | |
99 | |
100 | |
43
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
101 function lukCheckClassID(&$id) |
1 | 102 { |
63 | 103 global $classDefault; |
114 | 104 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)) |
105 { | |
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
|
106 $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
|
107 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
|
108 } else { |
106
e7bd58dec4f3
Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
109 stError(cmQM("classFormatError", $classDefault)); |
63 | 110 $id = $classDefault; |
1 | 111 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
|
112 } |
1 | 113 } |
114 | |
59 | 115 |
63 | 116 function lukGetWeekdayFromTimestamp($stamp) |
59 | 117 { |
118 $info = getdate($stamp); | |
119 $day = $info["wday"]; | |
120 return ($day > 0) ? $day - 1 : $day + 6; | |
121 } | |
122 | |
123 | |
124 function lukGetHourStamp($stamp) | |
5 | 125 { |
59 | 126 return date("H:i", mktime(0, 0, $stamp, 0, 0, 0)); |
127 } | |
128 | |
129 | |
130 function lukGetHourStr($hour) | |
131 { | |
132 global $classHourTimes; | |
133 if (isset($classHourTimes[$hour])) | |
134 { | |
135 return | |
136 "<br />". | |
137 lukGetHourStamp($classHourTimes[$hour]["start"]). | |
138 " - ". | |
139 lukGetHourStamp($classHourTimes[$hour]["end"]). | |
140 "<br /><br />"; | |
141 } | |
17 | 142 else |
59 | 143 return "ERROR"; |
5 | 144 } |
145 | |
146 | |
43
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
147 function lukMatchCourse($id) |
1 | 148 { |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
149 global $cache, $cacheDirty, $pageCharset, $pageLang; |
64
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
150 |
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
151 $uri = "http://www.oamk.fi/opiskelijalle/rakenne/opinto-opas/koulutusohjelmat/?sivu=oj&kieli=".strtoupper($pageLang)."&koodi1=".$id; |
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
152 |
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
153 // Create the index |
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
154 if (!isset($cache[$id])) |
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
155 $cache[$id] = array(); |
1 | 156 |
157 // Check if course exists in cache | |
64
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
158 if (!isset($cache[$id][$pageLang])) |
59 | 159 { |
160 // Not cached, try to fetch data | |
1 | 161 $cacheDirty = TRUE; |
64
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
162 $data = @file_get_contents($uri); |
59 | 163 if ($data !== FALSE) |
164 { | |
120
807c7b90386d
Iconv can spew some errors, so suppress them.
Matti Hamalainen <ccr@tnsp.org>
parents:
119
diff
changeset
|
165 $data = @iconv("iso-8859-15", $pageCharset, $data); |
64
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
166 if (preg_match("#<td class=\"smallheadercell\"><strong>(.+?)\s+(\d+)\s*(op|ECTS\s+cr)\s*</strong></td>#", $data, $m)) |
59 | 167 { |
1 | 168 // Add data to cache |
64
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
169 $cache[$id][$pageLang] = array("desc" => $m[1], "op" => intval($m[2])); |
1 | 170 } |
171 } | |
172 } | |
173 | |
64
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
174 if (isset($cache[$id]) && isset($cache[$id][$pageLang])) |
59 | 175 { |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
176 return "<a target=\"_blank\" title=\"".chentities($id." - ".$cache[$id][$pageLang]["op"]." op"). |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
177 "\" href=\"".chentities($uri)."\">".chentities($cache[$id][$pageLang]["desc"])."</a>"; |
59 | 178 } |
1 | 179 else |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
180 return chentities($id); |
1 | 181 } |
182 | |
183 | |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
184 function lukGetClassInfo($grouped, $data) |
59 | 185 { |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
186 if ($grouped) |
59 | 187 { |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
188 $out = "<table><tr>"; |
59 | 189 |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
190 $maxCount = 0; |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
191 foreach ($data as $col) |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
192 { |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
193 $out .= "<td>".lukMatchCourse($col[0])."</td>"; |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
194 if (count($col) > $maxCount) |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
195 $maxCount = count($col); |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
196 } |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
197 $out .= "</tr>"; |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
198 |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
199 for ($i = 1; $i < $maxCount; $i++) |
59 | 200 { |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
201 $out .= "<tr>"; |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
202 foreach ($data as $col) |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
203 { |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
204 $out .= "<td>"; |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
205 if (isset($col[$i])) |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
206 $out .= chentities($col[$i]); |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
207 $out .= "</td>"; |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
208 } |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
209 $out .= "</tr>"; |
59 | 210 } |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
211 |
59 | 212 return $out."</table>"; |
213 } | |
214 else | |
215 { | |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
216 $out = lukMatchCourse($data[0][0])."<br />"; |
59 | 217 |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
218 for ($i = 1; $i < count($data[0]); $i++) |
59 | 219 { |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
220 $out .= chentities($data[0][$i])."<br />"; |
59 | 221 } |
222 | |
223 return $out; | |
224 } | |
225 } | |
226 | |
227 | |
228 function lukFindClass($day, $hour) | |
229 { | |
230 global $classHourDefs, $classDayTable; | |
231 if (isset($classDayTable[$day])) | |
232 { | |
233 foreach ($classDayTable[$day] as $id) | |
234 { | |
235 if ($hour >= $classHourDefs[$id]["start"] && | |
236 $hour < $classHourDefs[$id]["start"] + $classHourDefs[$id]["hours"]) | |
237 return $id; | |
238 } | |
239 } | |
240 return 0; | |
241 } | |
242 | |
243 | |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
244 function lukReadClassFile($filename, &$mtimestamp) |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
245 { |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
246 // Attempt to open file for reading |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
247 if (($fp = @fopen($filename, "rb")) === false) |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
248 return false; |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
249 |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
250 $mtimestamp = filemtime($filename); |
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
251 $mclasses = FALSE; |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
252 |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
253 // Lock file so that we do not get clashes |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
254 if (flock($fp, LOCK_SH)) |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
255 { |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
256 $mclasses = array(); |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
257 // Read and parse data |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
258 while (!feof($fp)) |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
259 { |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
260 $str = trim(fgets($fp, 128)); |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
261 if (strlen($str) > 2 && $str[0] != "#") |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
262 $mclasses[] = $str; |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
263 } |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
264 |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
265 // Release lock |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
266 flock($fp, LOCK_UN); |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
267 } |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
268 |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
269 fclose($fp); |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
270 return $mclasses; |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
271 } |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
272 |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
273 |
128
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
274 function lukPrintTimeTable($mini) |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
275 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
276 global $classInfo, $classHourDefs, $classHourTimes; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
277 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
278 // $currStamp = time() + ((3 * 60) + 45) * 60; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
279 $currStamp = time(); |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
280 $currTime = $currStamp - mktime(0, 0, 0); |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
281 $currDay = lukGetWeekdayFromTimestamp($currStamp); |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
282 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
283 $nextStamp = $currStamp + 30 * 60; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
284 $nextTime = $nextStamp - mktime(0, 0, 0); |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
285 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
286 // Create the timetable table |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
287 if ($mini) |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
288 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
289 $out = |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
290 "<table class=\"timetable\">". |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
291 " <tr>\n <th></th>". |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
292 " <th class=\"days\">".lukGetDayName($currDay)."</th>\n </tr>\n"; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
293 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
294 $startDay = $currDay; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
295 $lastDay = $currDay + 1; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
296 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
297 else |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
298 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
299 $out = |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
300 "<p>".join("; ", $classInfo["general"]). |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
301 //" [".cmQM("viikossa", $classInfo["totalHours"])."]". |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
302 "</p>\n". |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
303 "<table class=\"timetable\">". |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
304 " <tr>\n <th></th>\n"; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
305 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
306 $cellWidth = $classInfo["maxDays"] > 0 ? 100 / $classInfo["maxDays"] : 15; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
307 if ($cellWidth > 25) $cellWidth = 25; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
308 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
309 for ($day = 0; $day < $classInfo["maxDays"]; $day++) |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
310 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
311 $out .= " <th style=\"width: ".$cellWidth."%;\" class=\"days\">".lukGetDayName($day)."</th>\n"; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
312 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
313 $out .= " </tr>\n"; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
314 $startDay = 0; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
315 $lastDay = $classInfo["maxDays"]; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
316 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
317 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
318 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
319 for ($hour = $classInfo["firstHour"]; $hour < $classInfo["lastHour"]; $hour++) |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
320 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
321 $out .= " <tr>\n". |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
322 " <th class=\"hours\">".lukGetHourStr($hour)."</th>\n"; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
323 for ($day = $startDay; $day < $lastDay; $day++) |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
324 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
325 $id = lukFindClass($day, $hour); |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
326 if ($id > 0) |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
327 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
328 $class = &$classHourDefs[$id]; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
329 if (!isset($class["set"])) |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
330 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
331 $class["set"] = TRUE; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
332 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
333 $nextActive = $day == $currDay && |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
334 $nextTime >= $classHourTimes[$class["start"]]["start"] && |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
335 $nextTime < $classHourTimes[$class["start"] + $class["hours"] - 1]["end"]; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
336 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
337 $isActive = $day == $currDay && |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
338 $currTime >= $classHourTimes[$class["start"]]["start"] && |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
339 $currTime < $classHourTimes[$class["start"] + $class["hours"] - 1]["end"]; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
340 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
341 $out .= " <td rowspan=\"".$class["hours"]."\" class=\"". |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
342 ($isActive ? "clactive " : ""). |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
343 (!$isActive && $nextActive ? "clnext " : ""). |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
344 ($class["grouped"] ? "clgrouped" : "clnormal")."\">". |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
345 lukGetClassInfo($class["grouped"], $class["data"]). |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
346 "<div class=\"nhours\"><span>".$class["hours"]."h</span></div></td>\n"; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
347 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
348 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
349 else |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
350 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
351 $out .= " <td class=\"clnothing\"></td>\n"; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
352 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
353 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
354 $out .= " </tr>\n"; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
355 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
356 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
357 return $out."</table>\n"; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
358 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
359 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
360 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
361 |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
362 // |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
363 // Main code begins |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
364 // |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
365 // Check given parameters: |
87
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
366 // Language must be the first setting to be validated, |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
367 // so that the translation support works properly. |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
368 // |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
369 |
87
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
370 if (isset($_GET["lang"])) |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
371 { |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
372 $tmp = strtolower($_GET["lang"]); |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
373 if (in_array($tmp, $pageLanguages)) |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
374 { |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
375 $pageLang = $tmp; |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
376 setcookie("luklang", $tmp, time() + 365*24*60*60); // expire in a year |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
377 } |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
378 } |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
379 else |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
380 if (isset($_COOKIE["luklang"])) |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
381 { |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
382 $tmp = $_COOKIE["luklang"]; |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
383 if (in_array($tmp, $pageLanguages)) |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
384 $pageLang = $tmp; |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
385 } |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
386 |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
387 |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
388 // Check if we are using mobile mode |
83 | 389 $mobileMode = FALSE; |
88
d78a063b2053
Disable mobile mode in the main branch for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
390 /* |
83 | 391 if (isset($_GET["m"])) |
392 { | |
393 $mobileMode = intval($_GET["m"]); | |
394 setcookie("lukmobile", $mobileMode, time() + 365*24*60*60); // expire in a year | |
395 } | |
396 else | |
397 if (isset($_COOKIE["lukmobile"])) | |
398 { | |
399 $mobileMode = $_COOKIE["lukmobile"]; | |
400 } | |
401 | |
402 if ($mobileMode) | |
403 { | |
404 $pageCSSData["prefix"] = $baseURI."mluk"; | |
405 } | |
88
d78a063b2053
Disable mobile mode in the main branch for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
406 */ |
82
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
407 |
87
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
408 // Check class setting |
59 | 409 if (isset($_GET["luokka"])) |
410 { | |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
411 $luokka = $_GET["luokka"]; |
66
6315df2faeec
Remove a lingering miniMode variable check.
Matti Hamalainen <ccr@tnsp.org>
parents:
65
diff
changeset
|
412 if (lukCheckClassID($luokka)) |
59 | 413 { |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
414 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
|
415 } |
59 | 416 } |
417 else | |
418 if (isset($_COOKIE["lukluokka"])) | |
419 { | |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
420 $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
|
421 lukCheckClassID($luokka); |
59 | 422 } |
423 else | |
424 { | |
106
e7bd58dec4f3
Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
425 stError(cmQM("classNotSet", $classDefault)); |
63 | 426 $luokka = $classDefault; |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
427 } |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
428 |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
429 |
87
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
430 // Check next period flag |
59 | 431 if (isset($_GET["next"])) |
432 { | |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
433 $nextPeriod = TRUE; |
82
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
434 $cachePath = "cache-next/"; |
59 | 435 } |
436 else | |
437 { | |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
438 $nextPeriod = FALSE; |
82
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
439 $cachePath = "cache/"; |
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
440 } |
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
441 |
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
442 if (file_exists($cachePath."baseuri.data")) |
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
443 { |
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
444 require $cachePath."baseuri.data"; |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
445 } |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
446 |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
447 |
1 | 448 // Global cache for course data |
449 $cache = array(); | |
450 $cacheDirty = FALSE; | |
451 | |
452 // Try to read cachefile, if we can get file lock on it | |
82
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
453 $fp = @fopen($courseCacheFile, "rb"); |
59 | 454 if ($fp) |
455 { | |
456 if (flock($fp, LOCK_SH)) | |
457 { | |
82
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
458 require($courseCacheFile); |
1 | 459 flock($fp, LOCK_UN); |
460 } | |
461 fclose($fp); | |
462 } | |
463 | |
43
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
464 |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
465 // Read classfile |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
466 if (($classes = lukReadClassFile($classIDFile, &$timestamp)) === false) |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
467 stError(stQM("classListNotFound")); |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
468 |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
469 |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
470 // Read class data |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
471 $dataFile = $cachePath.$luokka.".data"; |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
472 if (!file_exists($dataFile)) |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
473 { |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
474 stError(cmQM("classDataNotFound", chentities($luokka))); |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
475 $haveData = FALSE; |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
476 } |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
477 else |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
478 { |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
479 require($dataFile); |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
480 $haveData = isset($classInfo); |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
481 } |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
482 |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
483 |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
484 // Set some variables |
5 | 485 $pageTitle = $haveData ? $luokka." / ".join("; ", $classInfo["info"]) : $luokka; |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
486 |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
487 |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
488 // Create references to mobile device (Apple touch) icons |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
489 $extra = ""; |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
490 foreach (array(57 => FALSE, 76 => TRUE, 114 => TRUE, 120 => TRUE, 152 => TRUE) as $iconSize => $addSize) |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
491 { |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
492 $extra .= " <link rel=\"apple-touch-icon\" ". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
493 ($addSize ? "sizes=\"".$iconSize."x".$iconSize."\" " : ""). |
110
7d77d21873d1
Add mobile/Apple "touch icons".
Matti Hamalainen <ccr@tnsp.org>
parents:
108
diff
changeset
|
494 "href=\"img/icon-".$iconSize."-precomposed.png\" />\n"; |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
495 } |
18 | 496 |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
497 |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
498 // Start printing the page |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
499 cmPrintPageHeader($pageTitle, $extra); |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
500 |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
501 |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
502 // Info box |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
503 if (!$mobileMode) |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
504 { |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
505 echo |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
506 "<div id=\"infobox\">\n". |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
507 " <div id=\"ctitle\">OAMK Lukkari v".$pageVersion."</div>\n". |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
508 " <div id=\"csssel\">".cmQM("Style").": "; |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
509 |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
510 foreach ($pageCSSAlts as $name => $id) |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
511 { |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
512 echo |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
513 "<a ".(($pageCSSIndex == $id) ? " class=\"selected\"" : ""). |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
514 "href=\"".$baseURI."?css=".$id."\">".$name."</a>"; |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
515 } |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
516 |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
517 echo |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
518 "</div>\n". |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
519 " <div id=\"clang\">"; |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
520 |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
521 foreach ($pageLanguages as $id) |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
522 { |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
523 echo |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
524 "<a ".(($pageLang == $id) ? " class=\"selected\"" : ""). |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
525 "href=\"".$baseURI."?lang=".$id."\">".$id."</a>"; |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
526 } |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
527 |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
528 echo "</div>\n"; |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
529 } |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
530 |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
531 echo "</div>\n"; |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
532 |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
533 |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
534 // Additional controls |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
535 echo |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
536 "<form id=\"controls\" action=\"".$baseURI."\" method=\"get\">\n". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
537 " <table>\n". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
538 " <tr>\n". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
539 " <th>\n". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
540 " <select name=\"luokka\">\n"; |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
541 |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
542 foreach ($classes as $class) |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
543 { |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
544 echo |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
545 " <option ".($luokka == $class ? "selected=\"selected\" " : ""). |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
546 "value=\"".$class."\">".chentities($class)."</option>\n"; |
1 | 547 } |
30 | 548 echo |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
549 " </select>\n". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
550 " </th>\n". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
551 " <th><input class=\"submit\" type=\"submit\" value=\"".cmQM("Switch")."\" /></th>\n"; |
17 | 552 |
83 | 553 if (!$mobileMode) |
554 { | |
96 | 555 echo |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
556 " <th><a id=\"next\" class=\"textctrl\" href=\"".$baseURI.($nextPeriod ? "" : "?next")."\">". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
557 cmQM("Shown").": ".($nextPeriod ? cmQM("Next period") : cmQM("Current period")). |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
558 "</a></th>\n". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
559 " <th><a id=\"orig\" class=\"textctrl\" href=\"".$origBaseURI.$luokka.$origBaseExt."\">".cmQM("Original")."</a></th>\n". |
116
ee258438635f
Disable generation of XML files, as they are not used really.
Matti Hamalainen <ccr@tnsp.org>
parents:
115
diff
changeset
|
560 // " <th><a id=\"xml\" class=\"textctrl\" href=\"".$baseURI.$cachePath."/".$luokka.".xml\">XML</a></th>\n". |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
561 " <th><a class=\"textctrl mobile\" href=\"http://tnsp.org/mluk/\">Mobile</a></th>\n"; |
83 | 562 } |
78 | 563 |
123 | 564 $currURL = $baseURI."?luokka=".$luokka."&lang=".$pageLang. |
565 (isset($pageCSSIndex) ? "&css=".$pageCSSIndex : ""). | |
566 ($nextPeriod ? "&next" : ""); | |
119
78b4eb3a9719
Add link to the page with current settings, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
567 |
96 | 568 echo |
126 | 569 " <th><a href=\"".$currURL."\" class=\"textctrl\" title=\"".cmQM("currLukLink")."\">Link</a></th>\n". |
570 // " <th class=\"advert\"><a href=\"http://tnsp.org/u/HXh\"><img src=\"img/cell.png\" alt=\"Division Cell\" /></a></th>\n". | |
571 " <th class=\"advert\"><a href=\"http://tnsp.org/u/G1X\"><img src=\"img/hdd_fi.gif\" alt=\"HDD.fi\" /></a></th>\n". | |
96 | 572 " </tr>\n". |
573 " </table>\n". | |
574 "</form>\n". | |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
575 "<h1>".$pageTitle."</h1>\n"; |
1 | 576 |
577 // Show error messages | |
59 | 578 if ($errorSet) |
579 { | |
1 | 580 echo "<ul>\n"; |
44
57af36f0864e
Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
581 foreach ($errorMsgs as $msg) |
1 | 582 echo "<li>$msg</li>\n"; |
583 echo "</ul>\n"; | |
584 } | |
585 | |
59 | 586 if ($haveData) |
587 { | |
83 | 588 echo lukPrintTimeTable($mobileMode); |
59 | 589 } |
5 | 590 |
73 | 591 echo |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
592 "<div id=\"footer\">". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
593 cmQM("contact", "ccr @ IRCNet", "ccr (at) tnsp (dot) org"). |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
594 " / ". |
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
595 cmQM("updated", strftime("%m.%d.%Y, %H:%M", $timestamp)). |
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
596 //" <div style=\"color: red;\">".cmQM("beta", $pageVersion)."</div>\n". |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
597 "</div>\n"; |
84 | 598 |
98
6a7172b3a841
Update to match the main page API.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
599 cmPrintPageFooter(); |
1 | 600 |
601 | |
602 // Dump the course data cache, but only if it has changed | |
64
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
603 if ($cacheDirty) |
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
604 { |
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
605 $str = "<?\n\$cache = ".var_export($cache, TRUE)."\n?>"; |
114 | 606 if (file_put_contents($courseCacheFile, $str, LOCK_EX) === FALSE) |
607 { | |
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
|
608 // Can't do much anything here .. |
1 | 609 } |
610 } | |
611 | |
612 ?> |