annotate index.php @ 177:f8ae384b817e

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