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