Mercurial > hg > lukkari
annotate index.php @ 193:16ce445c499a v3 tip
Import v3 branch.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 22 Jan 2017 02:31:10 +0200 |
parents | f2adb44ea251 |
children |
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 // |
193 | 3 // OAMK Lukkari v3.0 |
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 |
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"; |
193 | 12 $pageVersion = "3.0alpha"; |
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 lukGetHourStamp($classHourTimes[$hour]["start"]). | |
198 " - ". | |
193 | 199 lukGetHourStamp($classHourTimes[$hour]["end"]); |
59 | 200 } |
17 | 201 else |
59 | 202 return "ERROR"; |
5 | 203 } |
204 | |
205 | |
141
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
206 function lukClassGetHourStr($start, $end) |
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
207 { |
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
208 global $classHourTimes; |
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
209 return |
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
210 lukGetHourStamp($classHourTimes[$start]["start"]). |
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
211 " - ". |
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
212 lukGetHourStamp($classHourTimes[$end]["end"]); |
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 |
36fb1ce941d5
Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
215 |
171
66c871dacbc2
Improve course ID handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
216 function lukFetchCourseData($id, $uri, &$cache) |
167
074a4a00af08
Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
166
diff
changeset
|
217 { |
074a4a00af08
Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
166
diff
changeset
|
218 global $pageCharset; |
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 if (($data = @file_get_contents($uri)) !== FALSE) |
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 $data = @iconv("iso8859-15", $pageCharset, $data); |
171
66c871dacbc2
Improve course ID handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
223 |
167
074a4a00af08
Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
166
diff
changeset
|
224 // <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
|
225 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
|
226 { |
175 | 227 $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
|
228 return TRUE; |
074a4a00af08
Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
166
diff
changeset
|
229 } |
074a4a00af08
Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
166
diff
changeset
|
230 else |
074a4a00af08
Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
166
diff
changeset
|
231 // <td><strong>... (N op)</strong></td> |
171
66c871dacbc2
Improve course ID handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
232 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
|
233 { |
175 | 234 $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
|
235 return TRUE; |
074a4a00af08
Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
166
diff
changeset
|
236 } |
074a4a00af08
Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
166
diff
changeset
|
237 } |
074a4a00af08
Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
166
diff
changeset
|
238 return FALSE; |
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 |
074a4a00af08
Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
166
diff
changeset
|
241 |
43
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
242 function lukMatchCourse($id) |
1 | 243 { |
167
074a4a00af08
Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
166
diff
changeset
|
244 global $cache, $cacheDirty, $pageLang, $mobileMode; |
64
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
245 |
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
246 // Create the index |
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
247 if (!isset($cache[$id])) |
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
248 $cache[$id] = array(); |
1 | 249 |
250 // Check if course exists in cache | |
64
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
251 if (!isset($cache[$id][$pageLang])) |
59 | 252 { |
253 // Not cached, try to fetch data | |
167
074a4a00af08
Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
166
diff
changeset
|
254 $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
|
255 if ( |
177
f8ae384b817e
Change fetching order again.
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
256 lukFetchCourseData($id, $uri."&opas=2014-2015", $cache[$id][$pageLang]) || |
f8ae384b817e
Change fetching order again.
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
257 lukFetchCourseData($id, $uri."&opas=2015-2016", $cache[$id][$pageLang]) |
171
66c871dacbc2
Improve course ID handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
258 ) |
167
074a4a00af08
Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
166
diff
changeset
|
259 $cacheDirty = TRUE; |
1 | 260 } |
167
074a4a00af08
Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
166
diff
changeset
|
261 |
64
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
262 if (isset($cache[$id]) && isset($cache[$id][$pageLang])) |
59 | 263 { |
137
657b0b7bf409
More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
264 if ($mobileMode) |
657b0b7bf409
More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
265 { |
657b0b7bf409
More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
266 return "<b>".chentities($cache[$id][$pageLang]["desc"])."</b>"; |
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 else |
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 return |
657b0b7bf409
More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
271 "<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
|
272 "\" 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
|
273 } |
59 | 274 } |
1 | 275 else |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
276 return chentities($id); |
1 | 277 } |
278 | |
279 | |
193 | 280 function lukGetClassInfo($class, $indent = "") |
59 | 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 $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
|
283 if ($class["grouped"]) |
59 | 284 { |
193 | 285 $out = ""; |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
286 foreach ($data as $col) |
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
287 { |
193 | 288 $out .= |
289 $indent."<div class=\"group\">\n". | |
290 $indent." <div class=\"groupCell\">".lukMatchCourse($col[0])."</div>\n"; | |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
291 |
193 | 292 for ($i = 1; $i < count($col); $i++) |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
293 { |
193 | 294 $out .= |
295 $indent." <div class=\"groupCell\">". | |
296 (isset($col[$i]) ? chentities($col[$i]) : ""). | |
297 "</div>\n"; | |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
298 } |
193 | 299 |
300 $out .= $indent."</div>\n"; | |
59 | 301 } |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
302 |
193 | 303 if ($class["turns"]) |
304 $out .= "<div class=\"groupCell eoWeekly\">".cmQM("vuoroviikoin")."</div>\n"; | |
305 | |
306 return $out; | |
59 | 307 } |
308 else | |
309 { | |
193 | 310 $out = $indent."<div class=\"groupCell\">".lukMatchCourse($data[0][0])."</div>\n"; |
59 | 311 |
72
6fd715063abc
Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
312 for ($i = 1; $i < count($data[0]); $i++) |
59 | 313 { |
193 | 314 $out .= $indent."<div class=\"groupCell\">".chentities($data[0][$i])."</div>\n"; |
59 | 315 } |
316 | |
193 | 317 if ($class["turns"]) |
318 $out .= "<div class=\"groupCell eoWeekly\">".cmQM("vuoroviikoin")."</div>\n"; | |
176
113820219e8b
Cleanup and add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
319 |
193 | 320 return $out; |
321 } | |
59 | 322 } |
323 | |
324 | |
325 function lukFindClass($day, $hour) | |
326 { | |
327 global $classHourDefs, $classDayTable; | |
328 if (isset($classDayTable[$day])) | |
329 { | |
330 foreach ($classDayTable[$day] as $id) | |
331 { | |
332 if ($hour >= $classHourDefs[$id]["start"] && | |
333 $hour < $classHourDefs[$id]["start"] + $classHourDefs[$id]["hours"]) | |
334 return $id; | |
335 } | |
336 } | |
337 return 0; | |
338 } | |
339 | |
340 | |
183
dda30eff3266
Fix handling of data modification timestamps.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
341 function lukReadClassFile($filename) |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
342 { |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
343 // Attempt to open file for reading |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
344 if (($fp = @fopen($filename, "rb")) === false) |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
345 return false; |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
346 |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
347 $mclasses = FALSE; |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
348 |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
349 // Lock file so that we do not get clashes |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
350 if (flock($fp, LOCK_SH)) |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
351 { |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
352 $mclasses = array(); |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
353 // Read and parse data |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
354 while (!feof($fp)) |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
355 { |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
356 $str = trim(fgets($fp, 128)); |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
357 if (strlen($str) > 2 && $str[0] != "#") |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
358 $mclasses[] = $str; |
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 |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
361 // Release lock |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
362 flock($fp, LOCK_UN); |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
363 } |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
364 |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
365 fclose($fp); |
173 | 366 |
367 sort($mclasses); | |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
368 return $mclasses; |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
369 } |
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 |
128
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
372 function lukPrintTimeTable($mini) |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
373 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
374 global $classInfo, $classHourDefs, $classHourTimes; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
375 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
376 // $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
|
377 $currStamp = time(); |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
378 $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
|
379 $currDay = lukGetWeekdayFromTimestamp($currStamp); |
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 $nextStamp = $currStamp + 30 * 60; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
382 $nextTime = $nextStamp - mktime(0, 0, 0); |
193 | 383 |
384 $out = | |
385 "<div id=\"timeTable\">\n"; | |
128
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 // Create the timetable table |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
388 if ($mini) |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
389 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
390 $startDay = $currDay; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
391 $lastDay = $currDay + 1; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
392 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
393 else |
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 $startDay = 0; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
396 $lastDay = $classInfo["maxDays"]; |
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 |
193 | 399 $out .= |
400 " <div class=\"timeTableHourList\" style=\"width: ".($mini ? "20%" : "10%").";\">\n". | |
401 " <div class=\"timeTableWeekday\"> </div>\n"; | |
128
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
402 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
|
403 { |
193 | 404 $out .= " <div class=\"timeTableHourBox\"><div class=\"timeTableHour\">".lukGetHourStr($hour)."</div></div>\n"; |
405 } | |
406 $out .= " </div>\n"; | |
407 | |
408 if ($mini) | |
409 $tmpS = "style=\"width: 75%;\""; | |
410 else | |
411 $tmpS = sprintf("style=\"width: %1.3f%%;\"", 100 / ($lastDay - $startDay + 1)); | |
412 | |
413 for ($day = $startDay; $day < $lastDay; $day++) | |
414 { | |
415 $out .= | |
416 " <div class=\"timeTableDay".($day == $currDay ? " active" : "")."\" ".$tmpS.">\n". | |
417 " <div class=\"timeTableWeekday\">".lukGetDayName($day)."</div>\n"; | |
418 | |
419 for ($hour = $classInfo["firstHour"]; $hour < $classInfo["lastHour"]; $hour++) | |
128
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 $id = lukFindClass($day, $hour); |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
422 if ($id > 0) |
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 $class = &$classHourDefs[$id]; |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
425 if (!isset($class["set"])) |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
426 { |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
427 $class["set"] = TRUE; |
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 $nextActive = $day == $currDay && |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
430 $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
|
431 $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
|
432 |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
433 $isActive = $day == $currDay && |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
434 $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
|
435 $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
|
436 |
193 | 437 $out .= |
438 " <div class=\"classInfoBox\" style=\"height: ".($class["hours"] * 6)."em;\">\n". | |
439 " <div class=\"classInfo". | |
440 ($isActive ? " clactive" : ""). | |
441 (!$isActive && $nextActive ? " clnext " : ""). | |
442 (($class["grouped"] || $class["turns"]) ? " clgrouped" : " clnormal")."\">\n". | |
443 lukGetClassInfo($class, " "). | |
444 " <div class=\"nhours\"><span>".lukClassGetHourStr($hour, $hour + $class["hours"] - 1)." (".$class["hours"]."h)</span></div>\n". | |
445 " </div>\n". | |
446 " </div>\n"; | |
128
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
447 } |
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 else |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
450 { |
193 | 451 $out .= " <div class=\"classInfoBox\"><div class=\"classInfo clnothing\"></div></div>\n"; |
128
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
452 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
453 } |
193 | 454 $out .= " </div>\n"; |
128
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
455 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
456 |
193 | 457 return $out."</div>\n"; |
128
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
458 } |
0f451151b9f1
Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
459 |
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 |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
462 // |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
463 // 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
|
464 // |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
465 // 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
|
466 // 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
|
467 // 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
|
468 // |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
469 |
142
0e8b8fac920d
Check request instead of $_GET.
Matti Hamalainen <ccr@tnsp.org>
parents:
141
diff
changeset
|
470 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
|
471 { |
142
0e8b8fac920d
Check request instead of $_GET.
Matti Hamalainen <ccr@tnsp.org>
parents:
141
diff
changeset
|
472 $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
|
473 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
|
474 { |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
475 $pageLang = $tmp; |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
476 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
|
477 } |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
478 } |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
479 else |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
480 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
|
481 { |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
482 $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
|
483 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
|
484 $pageLang = $tmp; |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
485 } |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
486 |
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
487 |
193 | 488 // Cookie info window |
489 $showCookieInfo = isset($_COOKIE["lukcookieinfo"]) ? !$_COOKIE["lukcookieinfo"] : TRUE; | |
490 | |
491 | |
492 // Development info window | |
493 $showDevInfo = isset($_COOKIE["lukdevinfo"]) ? $_COOKIE["lukdevinfo"] : TRUE; | |
494 setcookie("lukdevinfo", 0, time() + 2*7*24*60*60); | |
495 | |
496 | |
188
658422c83b49
Change the class setting request parameter and cookie from "luokka" to
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
497 // 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
|
498 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
|
499 ($classID = stGetRequestItem("luokka", FALSE, TRUE)) !== FALSE) && lukCheckClassID($classID)) |
83 | 500 { |
188
658422c83b49
Change the class setting request parameter and cookie from "luokka" to
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
501 setcookie("lukclass", $classID, time() + 365*24*60*60); // expire in a year |
59 | 502 } |
503 else | |
188
658422c83b49
Change the class setting request parameter and cookie from "luokka" to
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
504 if (isset($_COOKIE["lukclass"])) |
59 | 505 { |
188
658422c83b49
Change the class setting request parameter and cookie from "luokka" to
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
506 $classID = $_COOKIE["lukclass"]; |
135
31ba82aabbba
Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
507 lukCheckClassID($classID); |
59 | 508 } |
509 else | |
510 { | |
184
04490fe590ec
Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
511 stError(cmQM("class_not_set", $classDefaultID)); |
135
31ba82aabbba
Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
512 $classID = $classDefaultID; |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
513 } |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
514 |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
515 |
87
8743ff5302ce
Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
516 // Check next period flag |
142
0e8b8fac920d
Check request instead of $_GET.
Matti Hamalainen <ccr@tnsp.org>
parents:
141
diff
changeset
|
517 if (isset($_REQUEST["next"])) |
59 | 518 { |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
519 $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
|
520 $cachePath = "cache-next/"; |
59 | 521 } |
522 else | |
523 { | |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
524 $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
|
525 $cachePath = "cache/"; |
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
526 } |
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
527 |
159
66f3f02d5172
Add default (empty string) value for origBaseURI variable.
Matti Hamalainen <ccr@tnsp.org>
parents:
158
diff
changeset
|
528 // Get original base URI data |
66f3f02d5172
Add default (empty string) value for origBaseURI variable.
Matti Hamalainen <ccr@tnsp.org>
parents:
158
diff
changeset
|
529 $origBaseURI = ""; |
82
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
530 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
|
531 require $cachePath."baseuri.data"; |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
532 |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
533 |
1 | 534 // Global cache for course data |
535 $cache = array(); | |
536 $cacheDirty = FALSE; | |
537 | |
538 // Try to read cachefile, if we can get file lock on it | |
182 | 539 if (($fp = @fopen($courseCacheFile, "rb")) !== FALSE) |
59 | 540 { |
541 if (flock($fp, LOCK_SH)) | |
542 { | |
82
c553ad61e9c2
Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
79
diff
changeset
|
543 require($courseCacheFile); |
1 | 544 flock($fp, LOCK_UN); |
545 } | |
546 fclose($fp); | |
547 } | |
548 | |
43
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
549 |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
550 // Read classfile |
183
dda30eff3266
Fix handling of data modification timestamps.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
551 if (($classIDs = lukReadClassFile($classIDFile[$nextPeriod])) === false) |
184
04490fe590ec
Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
552 stError(cmQM("class_list_not_found")); |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
553 |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
554 |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
555 // Read class data |
135
31ba82aabbba
Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
556 $dataFile = $cachePath.$classID.".data"; |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
557 if (!file_exists($dataFile)) |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
558 { |
184
04490fe590ec
Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
559 stError(cmQM("class_data_not_found", chentities($classID))); |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
560 $haveData = FALSE; |
183
dda30eff3266
Fix handling of data modification timestamps.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
561 $timestamp = time(); |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
562 } |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
563 else |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
564 { |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
565 require($dataFile); |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
566 $haveData = isset($classInfo); |
183
dda30eff3266
Fix handling of data modification timestamps.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
567 $timestamp = filemtime($dataFile); |
107
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 |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
570 |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
571 // Create references to mobile device (Apple touch) icons |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
572 $extra = ""; |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
573 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
|
574 { |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
575 $extra .= " <link rel=\"apple-touch-icon\" ". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
576 ($addSize ? "sizes=\"".$iconSize."x".$iconSize."\" " : ""). |
110
7d77d21873d1
Add mobile/Apple "touch icons".
Matti Hamalainen <ccr@tnsp.org>
parents:
108
diff
changeset
|
577 "href=\"img/icon-".$iconSize."-precomposed.png\" />\n"; |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
578 } |
18 | 579 |
193 | 580 // XXX: Temporarily no-index (remember also robots.txt!) |
581 $extra .= " <meta name=\"robots\" content=\"noindex\">\n"; | |
582 | |
583 // For mobile shit | |
584 $extra .= " <meta name=\"viewport\" content=\"width=device-width\" />\n"; | |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
585 |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
586 // Start printing the page |
147 | 587 $pageTitle = $haveData ? $classID." / ".join("; ", $classInfo["info"]) : $classID; |
588 cmPrintPageHeader($pageTitle." - ".$pageName, $extra); | |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
589 |
193 | 590 echo " |
591 <script type=\"text/javascript\"> | |
592 function lukSetCookie(cname, cvalue, cctime) | |
593 { | |
594 var de = new Date(); | |
595 de.setTime(de.getTime() + cctime*1000); | |
596 document.cookie = cname +\"=\"+ cvalue +\"; expires=\"+ de.toUTCString(); | |
597 } | |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
598 |
193 | 599 function lukSetViewDo(elem, state) |
600 { | |
601 elem.style.display = state ? 'block' : 'none'; | |
602 } | |
603 | |
604 function lukSetView(id, state) | |
605 { | |
606 var elem = document.getElementById(id); | |
607 if (elem) lukSetViewDo(elem, state); | |
608 } | |
609 | |
610 function lukToggleView(id) | |
611 { | |
612 var elem = document.getElementById(id); | |
613 if (elem) lukSetViewDo(elem, (elem.style.display == 'none')); | |
614 } | |
615 | |
616 function lukAcknowledgeCookies() | |
617 { | |
618 lukSetCookie('lukcookieinfo', 1, 31*24*60*60); | |
619 var elem = document.getElementById('cookieInfo'); | |
620 if (elem) lukSetViewDo(elem, false); | |
621 } | |
622 </script> | |
623 | |
624 <div id=\"devInfo\" ".($showDevInfo ? "" : " style=\"display: none;\"")."> | |
625 <h1>Notice!</h1> | |
626 <p> | |
627 <b>This is the development version of 'Lukkari', tentatively called \"3.0alpha\".</b> | |
628 It is constantly changing, any features may be broken and fixed at | |
629 rapid pace. The style/layout is also in flux, and not finished - | |
630 there may be rendering bugs. Currently I am testing a non-table-based layout, | |
631 although it is not certain if it will be used in 'production'. | |
632 </p> | |
633 <p> | |
634 If you wish to suggest features, send e-mail to <b>ccr (at) tnsp (dot) org</b> | |
635 </p> | |
636 <div class=\"popupControls\"> | |
637 <button type=\"button\" onClick=\"lukSetView('devInfo', false);\">Okay</button> | |
638 </div> | |
639 </div> | |
640 "; | |
641 | |
642 if ($showCookieInfo) | |
643 { | |
644 echo | |
645 "<div id=\"cookieInfo\">\n". | |
646 " <p>Lukkari web-site uses <a href=\"http://en.wikipedia.org/wiki/HTTP_cookie\">HTTP cookies</a> ". | |
647 " to store current settings (language, default class ID, etc.) ". | |
648 " Also, Google Analytics used on this site may store information via cookies.". | |
649 " </p>". | |
650 " By continued use of this site, you acknowledge that you have been informed of the situation.". | |
651 " <div class=\"popupControls\">\n". | |
652 " <button type=\"button\" onclick=\"lukAcknowledgeCookies()\">Okay</button>\n". | |
653 " </div>\n". | |
654 "</div>\n"; | |
655 } | |
656 | |
657 | |
658 // Additional controls | |
130
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
659 echo |
193 | 660 " <div id=\"controls\">\n". |
661 " <div id=\"infobox\">\n". | |
662 " <div id=\"ctitle\">".$pageName." v".$pageVersion."</div>\n"; | |
130
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
663 |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
664 if (!$mobileMode) |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
665 { |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
666 echo |
193 | 667 " <div id=\"csssel\">".cmQM("Style").": "; |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
668 |
149
834abfd9d8e9
Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
669 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
|
670 { |
149
834abfd9d8e9
Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
671 foreach ($pageCSSAlts as $name => $id) |
834abfd9d8e9
Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
672 { |
834abfd9d8e9
Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
673 echo |
834abfd9d8e9
Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
674 "<a ".(($pageCSSIndex == $id) ? "class=\"selected\" " : ""). |
834abfd9d8e9
Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
675 "href=\"".$baseURI."?css=".$id."\">".$name."</a>"; |
834abfd9d8e9
Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
676 } |
129
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
677 } |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
678 |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
679 echo |
130
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
680 "</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
|
681 } |
b9ebc24f27fd
Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
682 |
193 | 683 echo " <div id=\"clang\">"; |
130
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
684 |
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
685 foreach ($pageLanguages as $id) |
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
686 { |
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
687 echo |
131 | 688 "<a ".(($pageLang == $id) ? "class=\"selected\" " : ""). |
130
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
689 "href=\"".$baseURI."?lang=".$id."\">".$id."</a>"; |
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
690 } |
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
691 |
7cfe0770168f
Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents:
129
diff
changeset
|
692 echo |
193 | 693 " </div>\n". |
694 " </div>\n". | |
695 " <form action=\"".$baseURI."\" method=\"get\">\n". | |
696 " <div>\n". | |
189
bc0d7a5d7b8e
Make class code selection list to autosubmit via javascript if scripts are
Matti Hamalainen <ccr@tnsp.org>
parents:
188
diff
changeset
|
697 " <select id=\"classSelect\" name=\"class\" onChange=\"this.form.submit();\">\n"; |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
698 |
140
26d266a685ed
Fix handling of class selection when no class list is available.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
699 if ($classIDs !== FALSE) |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
700 { |
140
26d266a685ed
Fix handling of class selection when no class list is available.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
701 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
|
702 { |
26d266a685ed
Fix handling of class selection when no class list is available.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
703 echo |
26d266a685ed
Fix handling of class selection when no class list is available.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
704 " <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
|
705 "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
|
706 } |
1 | 707 } |
135
31ba82aabbba
Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
708 |
30 | 709 echo |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
710 " </select>\n". |
193 | 711 " </div>\n". |
712 " <noscript><div><input id=\"classSwitch\" class=\"submit\" type=\"submit\" value=\"".cmQM("change")."\" /></div></noscript>\n"; | |
17 | 713 |
83 | 714 if (!$mobileMode) |
715 { | |
96 | 716 echo |
193 | 717 " <div><a id=\"nextPeriod\" class=\"textctrl\" href=\"". |
184
04490fe590ec
Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
718 $baseURI.($nextPeriod ? "" : "?next")."\" title=\"".cmQM("expl_toggle_period")."\">". |
04490fe590ec
Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
719 cmQM("period_shown").": ".($nextPeriod ? cmQM("next_period") : cmQM("current_period")). |
193 | 720 "</a></div>\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
|
721 |
6f7a2f9dcad4
Fix some errors due to undefined variables in case the class data is not
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
722 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
|
723 { |
6f7a2f9dcad4
Fix some errors due to undefined variables in case the class data is not
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
724 echo |
193 | 725 " <div><a id=\"origLink\" class=\"textctrl\" href=\"".$origBaseURI.$classID.$origBaseExt."\" title=\"".cmQM("expl_link_original_data")."\">".cmQM("link_original_data")."</a></div>\n"; |
726 //" <div><a id=\"xml\" class=\"textctrl\" href=\"".$baseURI.$cachePath."/".$class.".xml\">XML</a></div>\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
|
727 } |
6f7a2f9dcad4
Fix some errors due to undefined variables in case the class data is not
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
728 |
193 | 729 // echo " <div><a id=\"mobileLink\" class=\"textctrl mobile\" href=\"http://tnsp.org/mluk/\" title=\"".cmQM("expl_link_mobile_version")."\">".cmQM("link_mobile_version")."</a></div>\n"; |
83 | 730 } |
78 | 731 |
188
658422c83b49
Change the class setting request parameter and cookie from "luokka" to
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
732 $currURL = $baseURI."?class=".$classID."&lang=".$pageLang. |
123 | 733 (isset($pageCSSIndex) ? "&css=".$pageCSSIndex : ""). |
734 ($nextPeriod ? "&next" : ""); | |
119
78b4eb3a9719
Add link to the page with current settings, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
735 |
96 | 736 echo |
193 | 737 " <div><a href=\"".$currURL."\" class=\"textctrl\" title=\"".cmQM("expl_link_current_settings")."\">".cmQM("link_current_settings")."</a></div>\n". |
738 " <div><button id=\"toggleDevInfo\" type=\"button\" onclick=\"lukToggleView('devInfo')\">INFO</button></div>\n". | |
739 " </form>\n". | |
740 "</div>\n". | |
741 "<div id=\"header\">\n". | |
121
a6af6538777a
Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
742 "<h1>".$pageTitle."</h1>\n"; |
1 | 743 |
193 | 744 if (!$mobileMode) |
745 { | |
746 echo | |
747 "<p>".join("; ", $classInfo["general"]). | |
748 //" [".cmQM("viikossa", $classInfo["totalHours"])."]". | |
749 "</p>\n"; | |
750 } | |
751 | |
1 | 752 // Show error messages |
59 | 753 if ($errorSet) |
754 { | |
1 | 755 echo "<ul>\n"; |
44
57af36f0864e
Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
756 foreach ($errorMsgs as $msg) |
135
31ba82aabbba
Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
757 echo "<li>".$msg."</li>\n"; |
1 | 758 echo "</ul>\n"; |
759 } | |
760 | |
193 | 761 echo "</div>\n"; |
762 | |
59 | 763 if ($haveData) |
764 { | |
83 | 765 echo lukPrintTimeTable($mobileMode); |
59 | 766 } |
5 | 767 |
73 | 768 echo |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
769 "<div id=\"footer\">". |
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
770 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
|
771 " / ". |
133 | 772 cmQM("updated", strftime("%d.%m.%Y, %H:%M", $timestamp)). |
147 | 773 //" <div style=\"color: red;\">".cmQM("beta", $pageVersion, $pageName)."</div>\n". |
107
9f976ae7a3e2
Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
774 "</div>\n"; |
84 | 775 |
98
6a7172b3a841
Update to match the main page API.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
776 cmPrintPageFooter(); |
1 | 777 |
778 | |
779 // 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
|
780 if ($cacheDirty) |
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
781 { |
6900beff8789
Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
782 $str = "<?\n\$cache = ".var_export($cache, TRUE)."\n?>"; |
114 | 783 if (file_put_contents($courseCacheFile, $str, LOCK_EX) === FALSE) |
784 { | |
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
|
785 // Can't do much anything here .. |
1 | 786 } |
787 } | |
788 | |
789 ?> |