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