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