Mercurial > hg > lukkari
annotate index.php @ 160:a84b40bc2a99
Add parselist.pl utility and use it in update script.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 17 Aug 2015 22:02:22 +0300 |
parents | 66f3f02d5172 |
children | 0c3c27de6710 |
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 // |
158 | 3 // OAMK Lukkari v2.4 |
4 // (C) Copyright 2010 - 2015 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 |
150
5c0eacb7d35d
Use the renamed framework include.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
8 require "msitegen.inc.php"; |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
9 |
136 | 10 // Default settings |
147 | 11 $pageName = "OAMK Lukkari"; |
158 | 12 $pageVersion = "2.4"; |
137
657b0b7bf409
More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
13 $mobileMode = FALSE; |
136 | 14 $baseURI = "http://example.com/"; |
15 | |
115 | 16 $pageLanguages = array("fi", "en"); |
136 | 17 $pageCSSData = array("cookie" => "lukcss", "prefix" => "luk"); |
115 | 18 |
136 | 19 $classDefaultID = "DEFAULT"; |
153
9c6290ad087d
Improve class code handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
20 $classIDFile = array(FALSE => "classes.txt", TRUE => "classes_next.txt"); |
82
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
21 $courseCacheFile = "coursecache.txt"; |
1 | 22 |
136 | 23 if (file_exists("config.inc.php")) |
24 @require "config.inc.php"; | |
25 | |
26 // | |
27 // Hardcoded tables | |
28 // | |
63 | 29 $lukDayNames = array( |
30 "fi" => array("Maanantai", "Tiistai", "Keskiviikko", "Torstai", "Perjantai", "Lauantai", "Sunnuntai"), | |
31 "en" => array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"), | |
32 ); | |
33 | |
98
6a7172b3a841
Update to match the main page API.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
34 $pageTranslations = array( |
63 | 35 "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
|
36 |
055c33cba66e
Make the current/next period button a bit clearer ..
Matti Hamalainen <ccr@tnsp.org>
parents:
98
diff
changeset
|
37 "Shown" => array("fi" => "Näkyvillä"), |
63 | 38 "Next period" => array("fi" => "Seuraava periodi"), |
39 "Current period" => array("fi" => "Nykyinen periodi"), | |
40 "Switch" => array("fi" => "Vaihda"), | |
41 | |
42 "contact" => array( | |
148
b6eb02871dbf
Update some texts and translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
147
diff
changeset
|
43 "en" => "Contact <b>%1</b> or <b>%2</b>. ". |
b6eb02871dbf
Update some texts and translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
147
diff
changeset
|
44 "The author can't be held responsible for any errors or inaccuracies in the data!", |
b6eb02871dbf
Update some texts and translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
147
diff
changeset
|
45 |
b6eb02871dbf
Update some texts and translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
147
diff
changeset
|
46 "fi" => "Yhteydenotot <b>%1</b> tai <b>%2</b>. ". |
b6eb02871dbf
Update some texts and translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
147
diff
changeset
|
47 "En vastaa mahdollisista virheistä tai epätarkkuuksista tiedoissa!", |
63 | 48 ), |
49 | |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
50 "updated" => array( |
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
51 "en" => "Last updated: <b>%1</b>.", |
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
52 "fi" => "Päivitetty: <b>%1</b>.", |
103
38e9772901f1
Add in hdd.fi advertisement.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
53 ), |
38e9772901f1
Add in hdd.fi advertisement.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
54 |
63 | 55 "beta" => array( |
147 | 56 "en" => " NOTICE! %2 v%1 is still under development. There may be bugs.", |
57 "fi" => " HUOM! %2 v%1 on vielä kehityksen alla. Bugeja voi löytyä.", | |
63 | 58 ), |
59 | |
60 "viikossa" => array( | |
61 "en" => "Total of <b>%1</b> hours in the week.", | |
62 "fi" => "Viikossa yhteensä <b>%1</b> tuntia.", | |
63 ), | |
64 | |
145
c028506aa9cc
Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
65 "vuoroviikoin" => array( |
c028506aa9cc
Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
66 "en" => "Every other week", |
c028506aa9cc
Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
67 "fi" => "Vuoroviikoin", |
c028506aa9cc
Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
68 ), |
c028506aa9cc
Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
69 |
63 | 70 "classNotSet" => array( |
71 "en" => "Class not set, using default <b>%1</b>.", | |
72 "fi" => "Luokkaa ei asetettu, käytetään vakioarvoa <b>%1</b>.", | |
73 ), | |
89
f9cd4c5ca3d6
Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
88
diff
changeset
|
74 |
f9cd4c5ca3d6
Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
88
diff
changeset
|
75 "classDataNotFound" => array( |
f9cd4c5ca3d6
Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
88
diff
changeset
|
76 "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
|
77 "ilmestyy se järjestelmään seuraavan päivityksen aikana. Luokkatiedot ". |
153
9c6290ad087d
Improve class code handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
78 "päivitetään noin kerran viikossa. <b>On myös mahdollista, että luokkakoodi ". |
9c6290ad087d
Improve class code handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
79 "on olemassa vain seuraavan periodin tiedoissa.</b>", |
148
b6eb02871dbf
Update some texts and translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
147
diff
changeset
|
80 |
89
f9cd4c5ca3d6
Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
88
diff
changeset
|
81 "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
|
82 "should appear in this system during the next update. The data is updated ". |
153
9c6290ad087d
Improve class code handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
83 "approximately once per week. <b>It is also possible that the code only ". |
9c6290ad087d
Improve class code handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
84 "exists for next period's data.</b>", |
89
f9cd4c5ca3d6
Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
88
diff
changeset
|
85 ), |
63 | 86 |
106
e7bd58dec4f3
Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
87 "classListNotFound" => array( |
e7bd58dec4f3
Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
88 "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
|
89 "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
|
90 ), |
e7bd58dec4f3
Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
91 |
e7bd58dec4f3
Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
92 "classFormatError" => array( |
e7bd58dec4f3
Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
93 "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
|
94 "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
|
95 ), |
e7bd58dec4f3
Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
96 |
114 | 97 "Style" => array( |
98 "fi" => "Tyyli", | |
99 ), | |
154 | 100 |
101 "linkToggle" => array( | |
102 "fi" => "Vaihda nykyisen ja seuraavan periodin (jos saatavilla) lukujärjestyksen välillä.", | |
103 "en" => "Switch view between current and next period (if available) timetable.", | |
104 ), | |
105 | |
106 "linkOrig" => array( | |
107 "fi" => "Linkki alkuperäiseen lukujärjestysdataan.", | |
108 "en" => "Link to the original time table data.", | |
109 ), | |
119
78b4eb3a9719
Add link to the page with current settings, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
110 |
154 | 111 "linkMobile" => array( |
112 "fi" => "Yksinkertaisempi mobiililaiteversio lukujärjestyksestä.", | |
113 "en" => "Simpler mobile device version of the timetable.", | |
114 ), | |
115 | |
116 "linkCurrLuk" => array( | |
119
78b4eb3a9719
Add link to the page with current settings, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
117 "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
|
118 "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
|
119 ), |
63 | 120 // "" => array("fi" => ), |
121 ); | |
122 | |
123 | |
124 function lukGetDayName($day) | |
125 { | |
126 global $lukDayNames, $pageLang; | |
127 | |
128 if (isset($lukDayNames[$pageLang]) && isset($lukDayNames[$pageLang][$day])) | |
129 return $lukDayNames[$pageLang][$day]; | |
130 else | |
131 return $lukDayNames["en"][$day]; | |
132 } | |
133 | |
134 | |
43
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
135 function lukCheckClassID(&$id) |
1 | 136 { |
135
31ba82aabbba
Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
137 global $classDefaultID; |
114 | 138 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)) |
139 { | |
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
|
140 $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
|
141 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
|
142 } else { |
135
31ba82aabbba
Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
143 stError(cmQM("classFormatError", $classDefaultID)); |
31ba82aabbba
Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
144 $id = $classDefaultID; |
1 | 145 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
|
146 } |
1 | 147 } |
148 | |
59 | 149 |
63 | 150 function lukGetWeekdayFromTimestamp($stamp) |
59 | 151 { |
152 $info = getdate($stamp); | |
153 $day = $info["wday"]; | |
154 return ($day > 0) ? $day - 1 : $day + 6; | |
155 } | |
156 | |
157 | |
158 function lukGetHourStamp($stamp) | |
5 | 159 { |
59 | 160 return date("H:i", mktime(0, 0, $stamp, 0, 0, 0)); |
161 } | |
162 | |
163 | |
164 function lukGetHourStr($hour) | |
165 { | |
166 global $classHourTimes; | |
167 if (isset($classHourTimes[$hour])) | |
168 { | |
169 return | |
170 "<br />". | |
171 lukGetHourStamp($classHourTimes[$hour]["start"]). | |
172 " - ". | |
173 lukGetHourStamp($classHourTimes[$hour]["end"]). | |
174 "<br /><br />"; | |
175 } | |
17 | 176 else |
59 | 177 return "ERROR"; |
5 | 178 } |
179 | |
180 | |
141
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
181 function lukClassGetHourStr($start, $end) |
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
182 { |
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
183 global $classHourTimes; |
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
184 return |
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
185 lukGetHourStamp($classHourTimes[$start]["start"]). |
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
186 " - ". |
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
187 lukGetHourStamp($classHourTimes[$end]["end"]); |
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
188 } |
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
189 |
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
190 |
43
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
191 function lukMatchCourse($id) |
1 | 192 { |
137
657b0b7bf409
More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
193 global $cache, $cacheDirty, $pageCharset, $pageLang, $mobileMode; |
64
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
194 |
138 | 195 //$uri = "http://www.oamk.fi/opiskelijalle/rakenne/opinto-opas/koulutusohjelmat/?sivu=oj&kieli=".strtoupper($pageLang)."&koodi1=".$id; |
196 $uri = "http://www.oamk.fi/koulutus_ja_hakeminen/opiskelu_oamkissa/opinto-opas/koulutusohjelmat/?sivu=oj_kuvaus&koodi1=".$id."&kieli=".strtoupper($pageLang); | |
64
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
197 |
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
198 // Create the index |
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
199 if (!isset($cache[$id])) |
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
200 $cache[$id] = array(); |
1 | 201 |
202 // Check if course exists in cache | |
64
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
203 if (!isset($cache[$id][$pageLang])) |
59 | 204 { |
205 // Not cached, try to fetch data | |
1 | 206 $cacheDirty = TRUE; |
64
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
207 $data = @file_get_contents($uri); |
59 | 208 if ($data !== FALSE) |
209 { | |
120
807c7b90386d
Iconv can spew some errors, so suppress them.
Matti Hamalainen <ccr@tnsp.org>
parents:
119
diff
changeset
|
210 $data = @iconv("iso-8859-15", $pageCharset, $data); |
64
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
211 if (preg_match("#<td class=\"smallheadercell\"><strong>(.+?)\s+(\d+)\s*(op|ECTS\s+cr)\s*</strong></td>#", $data, $m)) |
59 | 212 { |
1 | 213 // Add data to cache |
64
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
214 $cache[$id][$pageLang] = array("desc" => $m[1], "op" => intval($m[2])); |
1 | 215 } |
216 } | |
217 } | |
218 | |
64
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
219 if (isset($cache[$id]) && isset($cache[$id][$pageLang])) |
59 | 220 { |
137
657b0b7bf409
More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
221 if ($mobileMode) |
657b0b7bf409
More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
222 { |
657b0b7bf409
More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
223 return "<b>".chentities($cache[$id][$pageLang]["desc"])."</b>"; |
657b0b7bf409
More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
224 } |
657b0b7bf409
More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
225 else |
657b0b7bf409
More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
226 { |
657b0b7bf409
More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
227 return |
657b0b7bf409
More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
228 "<a target=\"_blank\" title=\"".chentities($id." - ".$cache[$id][$pageLang]["op"]." op"). |
657b0b7bf409
More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
229 "\" href=\"".chentities($uri)."\">".chentities($cache[$id][$pageLang]["desc"])."</a>"; |
657b0b7bf409
More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
230 } |
59 | 231 } |
1 | 232 else |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
233 return chentities($id); |
1 | 234 } |
235 | |
236 | |
145
c028506aa9cc
Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
237 function lukGetClassInfo($class) |
59 | 238 { |
145
c028506aa9cc
Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
239 $data = $class["data"]; |
c028506aa9cc
Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
240 if ($class["grouped"]) |
59 | 241 { |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
242 $out = "<table><tr>"; |
59 | 243 |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
244 $maxCount = 0; |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
245 foreach ($data as $col) |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
246 { |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
247 $out .= "<td>".lukMatchCourse($col[0])."</td>"; |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
248 if (count($col) > $maxCount) |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
249 $maxCount = count($col); |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
250 } |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
251 $out .= "</tr>"; |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
252 |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
253 for ($i = 1; $i < $maxCount; $i++) |
59 | 254 { |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
255 $out .= "<tr>"; |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
256 foreach ($data as $col) |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
257 { |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
258 $out .= "<td>"; |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
259 if (isset($col[$i])) |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
260 $out .= chentities($col[$i]); |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
261 $out .= "</td>"; |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
262 } |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
263 $out .= "</tr>"; |
59 | 264 } |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
265 |
145
c028506aa9cc
Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
266 $out .= "</table>"; |
c028506aa9cc
Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
267 |
c028506aa9cc
Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
268 if ($class["turns"]) |
c028506aa9cc
Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
269 $out .= cmQM("vuoroviikoin"); |
c028506aa9cc
Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
270 |
c028506aa9cc
Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
271 return $out; |
59 | 272 } |
273 else | |
274 { | |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
275 $out = lukMatchCourse($data[0][0])."<br />"; |
59 | 276 |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
277 for ($i = 1; $i < count($data[0]); $i++) |
59 | 278 { |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
279 $out .= chentities($data[0][$i])."<br />"; |
59 | 280 } |
145
c028506aa9cc
Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
281 if ($class["turns"]) |
c028506aa9cc
Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
282 $out .= cmQM("vuoroviikoin"); |
59 | 283 |
284 return $out; | |
285 } | |
286 } | |
287 | |
288 | |
289 function lukFindClass($day, $hour) | |
290 { | |
291 global $classHourDefs, $classDayTable; | |
292 if (isset($classDayTable[$day])) | |
293 { | |
294 foreach ($classDayTable[$day] as $id) | |
295 { | |
296 if ($hour >= $classHourDefs[$id]["start"] && | |
297 $hour < $classHourDefs[$id]["start"] + $classHourDefs[$id]["hours"]) | |
298 return $id; | |
299 } | |
300 } | |
301 return 0; | |
302 } | |
303 | |
304 | |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
305 function lukReadClassFile($filename, &$mtimestamp) |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
306 { |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
307 // Attempt to open file for reading |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
308 if (($fp = @fopen($filename, "rb")) === false) |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
309 return false; |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
310 |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
311 $mtimestamp = filemtime($filename); |
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
312 $mclasses = FALSE; |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
313 |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
314 // Lock file so that we do not get clashes |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
315 if (flock($fp, LOCK_SH)) |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
316 { |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
317 $mclasses = array(); |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
318 // Read and parse data |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
319 while (!feof($fp)) |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
320 { |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
321 $str = trim(fgets($fp, 128)); |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
322 if (strlen($str) > 2 && $str[0] != "#") |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
323 $mclasses[] = $str; |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
324 } |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
325 |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
326 // Release lock |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
327 flock($fp, LOCK_UN); |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
328 } |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
329 |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
330 fclose($fp); |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
331 return $mclasses; |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
332 } |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
333 |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
334 |
128
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
335 function lukPrintTimeTable($mini) |
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 global $classInfo, $classHourDefs, $classHourTimes; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
338 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
339 // $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
|
340 $currStamp = time(); |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
341 $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
|
342 $currDay = lukGetWeekdayFromTimestamp($currStamp); |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
343 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
344 $nextStamp = $currStamp + 30 * 60; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
345 $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
|
346 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
347 // Create the timetable table |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
348 if ($mini) |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
349 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
350 $out = |
144 | 351 "<table id=\"timeTable\">\n". |
352 " <tr>\n". | |
353 " <th></th>". | |
354 " <th class=\"days\">".lukGetDayName($currDay)."</th>\n". | |
355 " </tr>\n"; | |
128
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 $startDay = $currDay; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
358 $lastDay = $currDay + 1; |
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 else |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
361 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
362 $out = |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
363 "<p>".join("; ", $classInfo["general"]). |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
364 //" [".cmQM("viikossa", $classInfo["totalHours"])."]". |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
365 "</p>\n". |
144 | 366 "<table id=\"timeTable\">\n". |
367 " <tr>\n". | |
368 " <th></th>\n"; | |
128
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
369 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
370 $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
|
371 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
|
372 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
373 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
|
374 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
375 $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
|
376 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
377 $out .= " </tr>\n"; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
378 $startDay = 0; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
379 $lastDay = $classInfo["maxDays"]; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
380 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
381 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
382 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
383 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
|
384 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
385 $out .= " <tr>\n". |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
386 " <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
|
387 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
|
388 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
389 $id = lukFindClass($day, $hour); |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
390 if ($id > 0) |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
391 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
392 $class = &$classHourDefs[$id]; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
393 if (!isset($class["set"])) |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
394 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
395 $class["set"] = TRUE; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
396 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
397 $nextActive = $day == $currDay && |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
398 $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
|
399 $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
|
400 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
401 $isActive = $day == $currDay && |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
402 $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
|
403 $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
|
404 |
141
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
405 $out .= " <td rowspan=\"".$class["hours"]."\" ". |
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
406 "title=\"".lukClassGetHourStr($hour, $hour + $class["hours"] - 1)."\" class=\"". |
128
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
407 ($isActive ? "clactive " : ""). |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
408 (!$isActive && $nextActive ? "clnext " : ""). |
145
c028506aa9cc
Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
409 (($class["grouped"] || $class["turns"]) ? "clgrouped" : "clnormal")."\">". |
c028506aa9cc
Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
410 lukGetClassInfo($class). |
128
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
411 "<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
|
412 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
413 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
414 else |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
415 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
416 $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
|
417 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
418 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
419 $out .= " </tr>\n"; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
420 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
421 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
422 return $out."</table>\n"; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
423 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
424 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
425 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
426 |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
427 // |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
428 // 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
|
429 // |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
430 // 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
|
431 // 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
|
432 // 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
|
433 // |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
434 |
142
0e8b8fac920d
Check request instead of $_GET.
Matti Hamalainen <ccr@tnsp.org>
parents:
141
diff
changeset
|
435 if (($tmp = stGetRequestItem("lang", FALSE, TRUE)) !== FALSE) |
87
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
436 { |
142
0e8b8fac920d
Check request instead of $_GET.
Matti Hamalainen <ccr@tnsp.org>
parents:
141
diff
changeset
|
437 $tmp = strtolower($tmp); |
87
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
438 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
|
439 { |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
440 $pageLang = $tmp; |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
441 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
|
442 } |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
443 } |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
444 else |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
445 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
|
446 { |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
447 $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
|
448 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
|
449 $pageLang = $tmp; |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
450 } |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
451 |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
452 |
143
d70c899b0571
Remove mobile mode, and another $_GET.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
453 // Check class setting |
d70c899b0571
Remove mobile mode, and another $_GET.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
454 if (($classID = stGetRequestItem("luokka", FALSE, TRUE)) !== FALSE && lukCheckClassID($classID)) |
83 | 455 { |
143
d70c899b0571
Remove mobile mode, and another $_GET.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
456 setcookie("lukluokka", $classID, time() + 365*24*60*60); // expire in a year |
59 | 457 } |
458 else | |
459 if (isset($_COOKIE["lukluokka"])) | |
460 { | |
135
31ba82aabbba
Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
461 $classID = $_COOKIE["lukluokka"]; |
31ba82aabbba
Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
462 lukCheckClassID($classID); |
59 | 463 } |
464 else | |
465 { | |
135
31ba82aabbba
Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
466 stError(cmQM("classNotSet", $classDefaultID)); |
31ba82aabbba
Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
467 $classID = $classDefaultID; |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
468 } |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
469 |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
470 |
87
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
471 // Check next period flag |
142
0e8b8fac920d
Check request instead of $_GET.
Matti Hamalainen <ccr@tnsp.org>
parents:
141
diff
changeset
|
472 if (isset($_REQUEST["next"])) |
59 | 473 { |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
474 $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
|
475 $cachePath = "cache-next/"; |
59 | 476 } |
477 else | |
478 { | |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
479 $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
|
480 $cachePath = "cache/"; |
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
481 } |
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
482 |
159
66f3f02d5172
Add default (empty string) value for origBaseURI variable.
Matti Hamalainen <ccr@tnsp.org>
parents:
158
diff
changeset
|
483 // Get original base URI data |
66f3f02d5172
Add default (empty string) value for origBaseURI variable.
Matti Hamalainen <ccr@tnsp.org>
parents:
158
diff
changeset
|
484 $origBaseURI = ""; |
82
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
485 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
|
486 require $cachePath."baseuri.data"; |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
487 |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
488 |
1 | 489 // Global cache for course data |
490 $cache = array(); | |
491 $cacheDirty = FALSE; | |
492 | |
493 // 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
|
494 $fp = @fopen($courseCacheFile, "rb"); |
59 | 495 if ($fp) |
496 { | |
497 if (flock($fp, LOCK_SH)) | |
498 { | |
82
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
499 require($courseCacheFile); |
1 | 500 flock($fp, LOCK_UN); |
501 } | |
502 fclose($fp); | |
503 } | |
504 | |
43
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
505 |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
506 // Read classfile |
155
241467521661
Fix obsolete call-time reference.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
507 if (($classIDs = lukReadClassFile($classIDFile[$nextPeriod], $timestamp)) === false) |
139
0ccb459aaecb
Oops. stQM() should've beem cmQM(). Fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
508 stError(cmQM("classListNotFound")); |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
509 |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
510 |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
511 // Read class data |
135
31ba82aabbba
Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
512 $dataFile = $cachePath.$classID.".data"; |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
513 if (!file_exists($dataFile)) |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
514 { |
135
31ba82aabbba
Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
515 stError(cmQM("classDataNotFound", chentities($classID))); |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
516 $haveData = FALSE; |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
517 } |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
518 else |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
519 { |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
520 require($dataFile); |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
521 $haveData = isset($classInfo); |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
522 } |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
523 |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
524 |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
525 // Create references to mobile device (Apple touch) icons |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
526 $extra = ""; |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
527 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
|
528 { |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
529 $extra .= " <link rel=\"apple-touch-icon\" ". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
530 ($addSize ? "sizes=\"".$iconSize."x".$iconSize."\" " : ""). |
110
7d77d21873d1
Add mobile/Apple "touch icons".
Matti Hamalainen <ccr@tnsp.org>
parents:
108
diff
changeset
|
531 "href=\"img/icon-".$iconSize."-precomposed.png\" />\n"; |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
532 } |
18 | 533 |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
534 |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
535 // Start printing the page |
147 | 536 $pageTitle = $haveData ? $classID." / ".join("; ", $classInfo["info"]) : $classID; |
537 cmPrintPageHeader($pageTitle." - ".$pageName, $extra); | |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
538 |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
539 |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
540 // Info box |
130
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
541 echo |
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
542 "<div id=\"infobox\">\n". |
147 | 543 " <div id=\"ctitle\">".$pageName." v".$pageVersion."</div>\n"; |
130
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
544 |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
545 if (!$mobileMode) |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
546 { |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
547 echo |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
548 " <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
|
549 |
149
834abfd9d8e9
Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
550 if (isset($pageCSSAlts)) |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
551 { |
149
834abfd9d8e9
Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
552 foreach ($pageCSSAlts as $name => $id) |
834abfd9d8e9
Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
553 { |
834abfd9d8e9
Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
554 echo |
834abfd9d8e9
Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
555 "<a ".(($pageCSSIndex == $id) ? "class=\"selected\" " : ""). |
834abfd9d8e9
Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
556 "href=\"".$baseURI."?css=".$id."\">".$name."</a>"; |
834abfd9d8e9
Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
557 } |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
558 } |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
559 |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
560 echo |
130
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
561 "</div>\n"; |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
562 } |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
563 |
130
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
564 echo |
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
565 " <div id=\"clang\">"; |
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
566 |
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
567 foreach ($pageLanguages as $id) |
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
568 { |
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
569 echo |
131 | 570 "<a ".(($pageLang == $id) ? "class=\"selected\" " : ""). |
130
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
571 "href=\"".$baseURI."?lang=".$id."\">".$id."</a>"; |
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
572 } |
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
573 |
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
574 echo |
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
575 "</div>\n". |
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
576 "</div>\n"; |
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
577 |
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
578 |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
579 // Additional controls |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
580 echo |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
581 "<form id=\"controls\" action=\"".$baseURI."\" method=\"get\">\n". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
582 " <table>\n". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
583 " <tr>\n". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
584 " <th>\n". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
585 " <select name=\"luokka\">\n"; |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
586 |
140
26d266a685ed
Fix handling of class selection when no class list is available.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
587 if ($classIDs !== FALSE) |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
588 { |
140
26d266a685ed
Fix handling of class selection when no class list is available.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
589 foreach ($classIDs as $id) |
26d266a685ed
Fix handling of class selection when no class list is available.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
590 { |
26d266a685ed
Fix handling of class selection when no class list is available.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
591 echo |
26d266a685ed
Fix handling of class selection when no class list is available.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
592 " <option ".($classID == $id ? "selected=\"selected\" " : ""). |
26d266a685ed
Fix handling of class selection when no class list is available.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
593 "value=\"".$id."\">".chentities($id)."</option>\n"; |
26d266a685ed
Fix handling of class selection when no class list is available.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
594 } |
1 | 595 } |
135
31ba82aabbba
Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
596 |
30 | 597 echo |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
598 " </select>\n". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
599 " </th>\n". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
600 " <th><input class=\"submit\" type=\"submit\" value=\"".cmQM("Switch")."\" /></th>\n"; |
17 | 601 |
83 | 602 if (!$mobileMode) |
603 { | |
96 | 604 echo |
154 | 605 " <th><a id=\"next\" class=\"textctrl\" href=\"". |
606 $baseURI.($nextPeriod ? "" : "?next")."\" title=\"".cmQM("linkToggle")."\">". | |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
607 cmQM("Shown").": ".($nextPeriod ? cmQM("Next period") : cmQM("Current period")). |
134
6f7a2f9dcad4
Fix some errors due to undefined variables in case the class data is not
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
608 "</a></th>\n"; |
6f7a2f9dcad4
Fix some errors due to undefined variables in case the class data is not
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
609 |
6f7a2f9dcad4
Fix some errors due to undefined variables in case the class data is not
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
610 if ($haveData) |
6f7a2f9dcad4
Fix some errors due to undefined variables in case the class data is not
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
611 { |
6f7a2f9dcad4
Fix some errors due to undefined variables in case the class data is not
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
612 echo |
154 | 613 " <th><a id=\"orig\" class=\"textctrl\" href=\"".$origBaseURI.$classID.$origBaseExt."\" title=\"".cmQM("linkOrig")."\">".cmQM("Original")."</a></th>\n"; |
134
6f7a2f9dcad4
Fix some errors due to undefined variables in case the class data is not
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
614 //" <th><a id=\"xml\" class=\"textctrl\" href=\"".$baseURI.$cachePath."/".$luokka.".xml\">XML</a></th>\n"; |
6f7a2f9dcad4
Fix some errors due to undefined variables in case the class data is not
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
615 } |
6f7a2f9dcad4
Fix some errors due to undefined variables in case the class data is not
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
616 |
6f7a2f9dcad4
Fix some errors due to undefined variables in case the class data is not
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
617 echo |
154 | 618 " <th><a class=\"textctrl mobile\" href=\"http://tnsp.org/mluk/\" title=\"".cmQM("linkMobile")."\">Mobile</a></th>\n"; |
83 | 619 } |
78 | 620 |
135
31ba82aabbba
Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
621 $currURL = $baseURI."?luokka=".$classID."&lang=".$pageLang. |
123 | 622 (isset($pageCSSIndex) ? "&css=".$pageCSSIndex : ""). |
623 ($nextPeriod ? "&next" : ""); | |
119
78b4eb3a9719
Add link to the page with current settings, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
624 |
96 | 625 echo |
154 | 626 " <th><a href=\"".$currURL."\" class=\"textctrl\" title=\"".cmQM("linkCurrLuk")."\">Link</a></th>\n". |
627 // " <th class=\"advert\"><a href=\"http://tnsp.org/u/G1X\"><img src=\"img/hdd_fi.gif\" alt=\"HDD.fi\" /></a></th>\n". | |
628 " <th class=\"advert\"><a href=\"http://tnsp.org/u/H9w\"><img src=\"img/batmud.png\" alt=\"BatMUD\" /></a></th>\n". | |
629 // " <th><a href=\"http://tnsp.org/testluk/\"><img src=\"img/test.png\" alt=\"Lukkari v3\" /></a></th>\n". | |
96 | 630 " </tr>\n". |
631 " </table>\n". | |
632 "</form>\n". | |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
633 "<h1>".$pageTitle."</h1>\n"; |
1 | 634 |
635 // Show error messages | |
59 | 636 if ($errorSet) |
637 { | |
1 | 638 echo "<ul>\n"; |
44
57af36f0864e
Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
639 foreach ($errorMsgs as $msg) |
135
31ba82aabbba
Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
640 echo "<li>".$msg."</li>\n"; |
1 | 641 echo "</ul>\n"; |
642 } | |
643 | |
59 | 644 if ($haveData) |
645 { | |
83 | 646 echo lukPrintTimeTable($mobileMode); |
59 | 647 } |
5 | 648 |
73 | 649 echo |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
650 "<div id=\"footer\">". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
651 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
|
652 " / ". |
133 | 653 cmQM("updated", strftime("%d.%m.%Y, %H:%M", $timestamp)). |
147 | 654 //" <div style=\"color: red;\">".cmQM("beta", $pageVersion, $pageName)."</div>\n". |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
655 "</div>\n"; |
84 | 656 |
98
6a7172b3a841
Update to match the main page API.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
657 cmPrintPageFooter(); |
1 | 658 |
659 | |
660 // 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
|
661 if ($cacheDirty) |
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
662 { |
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
663 $str = "<?\n\$cache = ".var_export($cache, TRUE)."\n?>"; |
114 | 664 if (file_put_contents($courseCacheFile, $str, LOCK_EX) === FALSE) |
665 { | |
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
|
666 // Can't do much anything here .. |
1 | 667 } |
668 } | |
669 | |
670 ?> |