annotate index.php @ 193:16ce445c499a v3 tip

Import v3 branch.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 22 Jan 2017 02:31:10 +0200
parents f2adb44ea251
children
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 //
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
3 // OAMK Lukkari v3.0
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
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
187
3fca160af8a5 Update site framework include.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
8 require "mgeneric.inc.php";
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
9
136
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";
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
12 $pageVersion = "3.0alpha";
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(
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
35 "change" => array(
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
36 "fi" => "Vaihda",
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
37 "en" => "Change",
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
38 ),
148
b6eb02871dbf Update some texts and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
39
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
40 "period_shown" => array(
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
41 "fi" => "Näkyvillä",
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
42 "en" => "Shown",
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
43 ),
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
44 "next_period" => array(
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
45 "fi" => "Seuraava periodi",
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
46 "en" => "Next period",
63
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
47 ),
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
48 "current_period" => array(
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
49 "fi" => "Nykyinen periodi",
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
50 "en" => "Current period",
103
38e9772901f1 Add in hdd.fi advertisement.
Matti Hamalainen <ccr@tnsp.org>
parents: 100
diff changeset
51 ),
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
52 "expl_toggle_period" => array(
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
53 "fi" => "Vaihda nykyisen ja seuraavan periodin (jos saatavilla) lukujärjestyksen välillä.",
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
54 "en" => "Switch view between current and next period (if available) timetable.",
63
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
55 ),
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
56
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
57 "viikossa" => array(
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
58 "fi" => "Viikossa yhteensä <b>%1</b> tuntia.",
63
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
59 "en" => "Total of <b>%1</b> hours in the week.",
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
60 ),
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
61
145
c028506aa9cc Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
62 "vuoroviikoin" => array(
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
63 "fi" => "Vuoroviikoin",
145
c028506aa9cc Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
64 "en" => "Every other week",
c028506aa9cc Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
65 ),
c028506aa9cc Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
66
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
67 "class_not_set" => array(
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
68 "fi" => "Luokkaa ei asetettu, käytetään vakioarvoa <b>%1</b>.",
63
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
69 "en" => "Class not set, using default <b>%1</b>.",
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
70 ),
89
f9cd4c5ca3d6 Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents: 88
diff changeset
71
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
72 "class_data_not_found" => array(
89
f9cd4c5ca3d6 Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents: 88
diff changeset
73 "fi" => "Luokan %1 tietoja ei löytynyt! Jos luokkakoodi on uusi, ".
f9cd4c5ca3d6 Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents: 88
diff changeset
74 "ilmestyy se järjestelmään seuraavan päivityksen aikana. Luokkatiedot ".
153
9c6290ad087d Improve class code handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
75 "päivitetään noin kerran viikossa. <b>On myös mahdollista, että luokkakoodi ".
9c6290ad087d Improve class code handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
76 "on olemassa vain seuraavan periodin tiedoissa.</b>",
148
b6eb02871dbf Update some texts and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
77
89
f9cd4c5ca3d6 Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents: 88
diff changeset
78 "en" => "Data for class %1 was not found. If the class code is new, it ".
f9cd4c5ca3d6 Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents: 88
diff changeset
79 "should appear in this system during the next update. The data is updated ".
153
9c6290ad087d Improve class code handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
80 "approximately once per week. <b>It is also possible that the code only ".
9c6290ad087d Improve class code handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
81 "exists for next period's data.</b>",
89
f9cd4c5ca3d6 Translate one more error message.
Matti Hamalainen <ccr@tnsp.org>
parents: 88
diff changeset
82 ),
63
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
83
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
84 "class_list_not_found" => array(
106
e7bd58dec4f3 Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 105
diff changeset
85 "fi" => "Luokkien listaa ei löytynyt. Kokeile ladata sivu uudelleen hetken kuluttua.",
e7bd58dec4f3 Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 105
diff changeset
86 "en" => "Class list not found. An update may be in progress, try reloading in a minute.",
e7bd58dec4f3 Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 105
diff changeset
87 ),
e7bd58dec4f3 Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 105
diff changeset
88
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
89 "class_format_error" => array(
106
e7bd58dec4f3 Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 105
diff changeset
90 "fi" => "Virhe! Luokan täytyy olla muotoa <b>XXXnXXX</b>, käytetään vakioarvoa <b>%1</b>.",
e7bd58dec4f3 Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 105
diff changeset
91 "en" => "Error! Class code must be of format <b>XXXnXXX</b>, using default value of <b>%1</b>.",
e7bd58dec4f3 Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 105
diff changeset
92 ),
e7bd58dec4f3 Update for newer framework, add some translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 105
diff changeset
93
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
94 "change_style" => array(
114
09d811e4387d Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
95 "fi" => "Tyyli",
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
96 "en" => "Style",
114
09d811e4387d Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
97 ),
154
4106691d3b25 Add some link titles.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
98
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
99 "link_original_data" => array(
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
100 "fi" => "Alkuperäinen",
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
101 "en" => "Original",
154
4106691d3b25 Add some link titles.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
102 ),
4106691d3b25 Add some link titles.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
103
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
104 "expl_link_original_data" => array(
154
4106691d3b25 Add some link titles.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
105 "fi" => "Linkki alkuperäiseen lukujärjestysdataan.",
4106691d3b25 Add some link titles.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
106 "en" => "Link to the original time table data.",
4106691d3b25 Add some link titles.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
107 ),
119
78b4eb3a9719 Add link to the page with current settings, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
108
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
109 "link_mobile_version" => array(
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
110 "en" => "Mobile",
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
111 "fi" => "Mobile",
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
112 ),
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
113
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
114 "expl_link_mobile_version" => array(
154
4106691d3b25 Add some link titles.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
115 "fi" => "Yksinkertaisempi mobiililaiteversio lukujärjestyksestä.",
4106691d3b25 Add some link titles.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
116 "en" => "Simpler mobile device version of the timetable.",
4106691d3b25 Add some link titles.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
117 ),
4106691d3b25 Add some link titles.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
118
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
119 "link_current_settings" => array(
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
120 "fi" => "Linkki",
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
121 "en" => "Link",
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
122 ),
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
123
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
124 "expl_link_current_settings" => array(
119
78b4eb3a9719 Add link to the page with current settings, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
125 "fi" => "Linkki tähän lukujärjestykseen nykyisillä asetuksilla (kieli, jne.)",
78b4eb3a9719 Add link to the page with current settings, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
126 "en" => "Link to the this timetable with current settings (language, etc.)",
78b4eb3a9719 Add link to the page with current settings, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
127 ),
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
128
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
129 "contact" => array(
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
130 "fi" => "Yhteydenotot <b>%1</b> tai <b>%2</b>. ".
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
131 "En vastaa mahdollisista virheistä tai epätarkkuuksista tiedoissa!",
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
132
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
133 "en" => "Contact <b>%1</b> or <b>%2</b>. ".
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
134 "The author can't be held responsible for any errors or inaccuracies in the data!",
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
135 ),
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
136
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
137 "updated" => array(
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
138 "fi" => "Päivitetty: <b>%1</b>.",
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
139 "en" => "Last updated: <b>%1</b>.",
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
140 ),
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
141
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
142 "beta" => array(
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
143 "fi" => " HUOM! %2 v%1 on vielä kehityksen alla. Bugeja voi löytyä.",
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
144 "en" => " NOTICE! %2 v%1 is still under development. There may be bugs.",
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
145 ),
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
146
63
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
147 // "" => array("fi" => ),
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
148 );
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
149
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
150
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
151 function lukGetDayName($day)
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
152 {
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
153 global $lukDayNames, $pageLang;
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
154
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
155 if (isset($lukDayNames[$pageLang]) && isset($lukDayNames[$pageLang][$day]))
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
156 return $lukDayNames[$pageLang][$day];
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
157 else
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
158 return $lukDayNames["en"][$day];
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
159 }
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
160
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
161
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
162 function lukCheckClassID(&$id)
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163 {
135
31ba82aabbba Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents: 134
diff changeset
164 global $classDefaultID;
114
09d811e4387d Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
165 if (preg_match("#^([A-Z]{3}\d[A-Za-z0-9_]{1,6}|ccr|Ryh_[A-Z]{3}\d[A-Za-z0-9_]{1,6})$#", $id, $m))
09d811e4387d Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
166 {
23
b4b86915ae2c Better input validation for $_GET arguments, thanks to Hjalmarr for pointing out the error.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
167 $id = $m[1];
b4b86915ae2c Better input validation for $_GET arguments, thanks to Hjalmarr for pointing out the error.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
168 return TRUE;
b4b86915ae2c Better input validation for $_GET arguments, thanks to Hjalmarr for pointing out the error.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
169 } else {
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
170 stError(cmQM("class_format_error", $classDefaultID));
135
31ba82aabbba Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents: 134
diff changeset
171 $id = $classDefaultID;
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 return FALSE;
23
b4b86915ae2c Better input validation for $_GET arguments, thanks to Hjalmarr for pointing out the error.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
173 }
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
176
63
6635246b70d9 Implement translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
177 function lukGetWeekdayFromTimestamp($stamp)
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
178 {
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
179 $info = getdate($stamp);
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
180 $day = $info["wday"];
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
181 return ($day > 0) ? $day - 1 : $day + 6;
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
182 }
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
183
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
184
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
185 function lukGetHourStamp($stamp)
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
186 {
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
187 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
188 }
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
189
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
190
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
191 function lukGetHourStr($hour)
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
192 {
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
193 global $classHourTimes;
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
194 if (isset($classHourTimes[$hour]))
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
195 {
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
196 return
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
197 lukGetHourStamp($classHourTimes[$hour]["start"]).
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
198 " - ".
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
199 lukGetHourStamp($classHourTimes[$hour]["end"]);
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
200 }
17
611452d30bd4 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
201 else
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
202 return "ERROR";
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
203 }
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
204
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
205
141
36fb1ce941d5 Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
206 function lukClassGetHourStr($start, $end)
36fb1ce941d5 Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
207 {
36fb1ce941d5 Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
208 global $classHourTimes;
36fb1ce941d5 Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
209 return
36fb1ce941d5 Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
210 lukGetHourStamp($classHourTimes[$start]["start"]).
36fb1ce941d5 Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
211 " - ".
36fb1ce941d5 Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
212 lukGetHourStamp($classHourTimes[$end]["end"]);
36fb1ce941d5 Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
213 }
36fb1ce941d5 Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
214
36fb1ce941d5 Add more information as a title attribute.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
215
171
66c871dacbc2 Improve course ID handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
216 function lukFetchCourseData($id, $uri, &$cache)
167
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
217 {
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
218 global $pageCharset;
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
219
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
220 if (($data = @file_get_contents($uri)) !== FALSE)
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
221 {
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
222 $data = @iconv("iso8859-15", $pageCharset, $data);
171
66c871dacbc2 Improve course ID handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
223
167
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
224 // <td id="oj_nimi" class="smallheadercell"><strong>Korjausrakentamisen rakennussuunnittelu 3 op</strong></td>
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
225 if (preg_match("#<td id=\"oj_nimi\" class=\"smallheadercell\"><strong>(.+?)\s+(\d+)\s*(op|ECTS\s+cr)\s*</strong></td>#", $data, $m))
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
226 {
175
6dea01a68019 Trim input.
Matti Hamalainen <ccr@tnsp.org>
parents: 173
diff changeset
227 $cache = array("desc" => trim($m[1]), "op" => intval($m[2]), "uri" => $uri);
167
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
228 return TRUE;
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
229 }
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
230 else
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
231 // <td><strong>... (N op)</strong></td>
171
66c871dacbc2 Improve course ID handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
232 if (preg_match("#<td><strong>(.+?)\s+\((\d+)\s*(op|ECTS\s+cr|cr)\)\s*</strong></td>#i", $data, $m))
167
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
233 {
175
6dea01a68019 Trim input.
Matti Hamalainen <ccr@tnsp.org>
parents: 173
diff changeset
234 $cache = array("desc" => trim($m[1]), "op" => intval($m[2]), "uri" => $uri);
167
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
235 return TRUE;
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
236 }
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
237 }
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
238 return FALSE;
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
239 }
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
240
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
241
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
242 function lukMatchCourse($id)
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243 {
167
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
244 global $cache, $cacheDirty, $pageLang, $mobileMode;
64
6900beff8789 Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
245
6900beff8789 Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
246 // Create the index
6900beff8789 Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
247 if (!isset($cache[$id]))
6900beff8789 Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
248 $cache[$id] = array();
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
250 // Check if course exists in cache
64
6900beff8789 Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
251 if (!isset($cache[$id][$pageLang]))
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
252 {
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
253 // Not cached, try to fetch data
167
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
254 $uri = "http://www.oamk.fi/opinto-opas/opintojaksohaku/?sivu=oj_kuvaus&koodi1=".$id."&kieli=".strtoupper($pageLang);
171
66c871dacbc2 Improve course ID handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
255 if (
177
f8ae384b817e Change fetching order again.
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
256 lukFetchCourseData($id, $uri."&opas=2014-2015", $cache[$id][$pageLang]) ||
f8ae384b817e Change fetching order again.
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
257 lukFetchCourseData($id, $uri."&opas=2015-2016", $cache[$id][$pageLang])
171
66c871dacbc2 Improve course ID handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
258 )
167
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
259 $cacheDirty = TRUE;
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260 }
167
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
261
64
6900beff8789 Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
262 if (isset($cache[$id]) && isset($cache[$id][$pageLang]))
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
263 {
137
657b0b7bf409 More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
264 if ($mobileMode)
657b0b7bf409 More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
265 {
657b0b7bf409 More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
266 return "<b>".chentities($cache[$id][$pageLang]["desc"])."</b>";
657b0b7bf409 More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
267 }
657b0b7bf409 More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
268 else
657b0b7bf409 More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
269 {
657b0b7bf409 More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
270 return
657b0b7bf409 More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
271 "<a target=\"_blank\" title=\"".chentities($id." - ".$cache[$id][$pageLang]["op"]." op").
167
074a4a00af08 Refactor course cache updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
272 "\" href=\"".chentities($cache[$id][$pageLang]["uri"])."\">".chentities($cache[$id][$pageLang]["desc"])."</a>";
137
657b0b7bf409 More merging with mobile version.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
273 }
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
274 }
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
275 else
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
276 return chentities($id);
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
277 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
278
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
280 function lukGetClassInfo($class, $indent = "")
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
281 {
145
c028506aa9cc Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
282 $data = $class["data"];
c028506aa9cc Separate the concepts of "every other week" classes and split group classes.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
283 if ($class["grouped"])
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
284 {
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
285 $out = "";
72
6fd715063abc Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
286 foreach ($data as $col)
6fd715063abc Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
287 {
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
288 $out .=
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
289 $indent."<div class=\"group\">\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
290 $indent." <div class=\"groupCell\">".lukMatchCourse($col[0])."</div>\n";
72
6fd715063abc Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
291
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
292 for ($i = 1; $i < count($col); $i++)
72
6fd715063abc Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
293 {
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
294 $out .=
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
295 $indent." <div class=\"groupCell\">".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
296 (isset($col[$i]) ? chentities($col[$i]) : "").
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
297 "</div>\n";
72
6fd715063abc Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
298 }
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
299
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
300 $out .= $indent."</div>\n";
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
301 }
72
6fd715063abc Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
302
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
303 if ($class["turns"])
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
304 $out .= "<div class=\"groupCell eoWeekly\">".cmQM("vuoroviikoin")."</div>\n";
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
305
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
306 return $out;
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
307 }
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
308 else
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
309 {
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
310 $out = $indent."<div class=\"groupCell\">".lukMatchCourse($data[0][0])."</div>\n";
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
311
72
6fd715063abc Clean up some parsing operations.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
312 for ($i = 1; $i < count($data[0]); $i++)
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
313 {
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
314 $out .= $indent."<div class=\"groupCell\">".chentities($data[0][$i])."</div>\n";
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
315 }
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
316
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
317 if ($class["turns"])
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
318 $out .= "<div class=\"groupCell eoWeekly\">".cmQM("vuoroviikoin")."</div>\n";
176
113820219e8b Cleanup and add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
319
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
320 return $out;
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
321 }
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
322 }
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
323
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
324
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
325 function lukFindClass($day, $hour)
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
326 {
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
327 global $classHourDefs, $classDayTable;
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
328 if (isset($classDayTable[$day]))
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
329 {
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
330 foreach ($classDayTable[$day] as $id)
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
331 {
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
332 if ($hour >= $classHourDefs[$id]["start"] &&
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
333 $hour < $classHourDefs[$id]["start"] + $classHourDefs[$id]["hours"])
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
334 return $id;
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
335 }
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
336 }
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
337 return 0;
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
338 }
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
339
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
340
183
dda30eff3266 Fix handling of data modification timestamps.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
341 function lukReadClassFile($filename)
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
342 {
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
343 // Attempt to open file for reading
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
344 if (($fp = @fopen($filename, "rb")) === false)
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
345 return false;
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
346
121
a6af6538777a Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
347 $mclasses = FALSE;
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
348
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
349 // Lock file so that we do not get clashes
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
350 if (flock($fp, LOCK_SH))
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
351 {
121
a6af6538777a Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
352 $mclasses = array();
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
353 // Read and parse data
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
354 while (!feof($fp))
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
355 {
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
356 $str = trim(fgets($fp, 128));
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
357 if (strlen($str) > 2 && $str[0] != "#")
121
a6af6538777a Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
358 $mclasses[] = $str;
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
359 }
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
360
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
361 // Release lock
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
362 flock($fp, LOCK_UN);
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
363 }
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
364
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
365 fclose($fp);
173
d98aaa540459 Sort class list. Mlem.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
366
d98aaa540459 Sort class list. Mlem.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
367 sort($mclasses);
121
a6af6538777a Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
368 return $mclasses;
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
369 }
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
370
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
371
128
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
372 function lukPrintTimeTable($mini)
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
373 {
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
374 global $classInfo, $classHourDefs, $classHourTimes;
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
375
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
376 // $currStamp = time() + ((3 * 60) + 45) * 60;
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
377 $currStamp = time();
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
378 $currTime = $currStamp - mktime(0, 0, 0);
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
379 $currDay = lukGetWeekdayFromTimestamp($currStamp);
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
380
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
381 $nextStamp = $currStamp + 30 * 60;
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
382 $nextTime = $nextStamp - mktime(0, 0, 0);
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
383
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
384 $out =
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
385 "<div id=\"timeTable\">\n";
128
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
386
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
387 // Create the timetable table
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
388 if ($mini)
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
389 {
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
390 $startDay = $currDay;
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
391 $lastDay = $currDay + 1;
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
392 }
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
393 else
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
394 {
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
395 $startDay = 0;
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
396 $lastDay = $classInfo["maxDays"];
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
397 }
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
398
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
399 $out .=
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
400 " <div class=\"timeTableHourList\" style=\"width: ".($mini ? "20%" : "10%").";\">\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
401 " <div class=\"timeTableWeekday\">&nbsp;</div>\n";
128
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
402 for ($hour = $classInfo["firstHour"]; $hour < $classInfo["lastHour"]; $hour++)
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
403 {
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
404 $out .= " <div class=\"timeTableHourBox\"><div class=\"timeTableHour\">".lukGetHourStr($hour)."</div></div>\n";
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
405 }
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
406 $out .= " </div>\n";
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
407
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
408 if ($mini)
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
409 $tmpS = "style=\"width: 75%;\"";
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
410 else
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
411 $tmpS = sprintf("style=\"width: %1.3f%%;\"", 100 / ($lastDay - $startDay + 1));
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
412
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
413 for ($day = $startDay; $day < $lastDay; $day++)
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
414 {
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
415 $out .=
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
416 " <div class=\"timeTableDay".($day == $currDay ? " active" : "")."\" ".$tmpS.">\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
417 " <div class=\"timeTableWeekday\">".lukGetDayName($day)."</div>\n";
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
418
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
419 for ($hour = $classInfo["firstHour"]; $hour < $classInfo["lastHour"]; $hour++)
128
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
420 {
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
421 $id = lukFindClass($day, $hour);
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
422 if ($id > 0)
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
423 {
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
424 $class = &$classHourDefs[$id];
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
425 if (!isset($class["set"]))
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
426 {
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
427 $class["set"] = TRUE;
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
428
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
429 $nextActive = $day == $currDay &&
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
430 $nextTime >= $classHourTimes[$class["start"]]["start"] &&
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
431 $nextTime < $classHourTimes[$class["start"] + $class["hours"] - 1]["end"];
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
432
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
433 $isActive = $day == $currDay &&
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
434 $currTime >= $classHourTimes[$class["start"]]["start"] &&
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
435 $currTime < $classHourTimes[$class["start"] + $class["hours"] - 1]["end"];
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
436
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
437 $out .=
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
438 " <div class=\"classInfoBox\" style=\"height: ".($class["hours"] * 6)."em;\">\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
439 " <div class=\"classInfo".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
440 ($isActive ? " clactive" : "").
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
441 (!$isActive && $nextActive ? " clnext " : "").
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
442 (($class["grouped"] || $class["turns"]) ? " clgrouped" : " clnormal")."\">\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
443 lukGetClassInfo($class, " ").
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
444 " <div class=\"nhours\"><span>".lukClassGetHourStr($hour, $hour + $class["hours"] - 1)." (".$class["hours"]."h)</span></div>\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
445 " </div>\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
446 " </div>\n";
128
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
447 }
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
448 }
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
449 else
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
450 {
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
451 $out .= " <div class=\"classInfoBox\"><div class=\"classInfo clnothing\"></div></div>\n";
128
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
452 }
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
453 }
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
454 $out .= " </div>\n";
128
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
455 }
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
456
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
457 return $out."</div>\n";
128
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
458 }
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
459
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
460
0f451151b9f1 Move code for one function to same group as others.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
461
129
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
462 //
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
463 // Main code begins
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
464 //
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
465 // Check given parameters:
87
8743ff5302ce Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
466 // Language must be the first setting to be validated,
8743ff5302ce Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
467 // so that the translation support works properly.
129
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
468 //
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
469
142
0e8b8fac920d Check request instead of $_GET.
Matti Hamalainen <ccr@tnsp.org>
parents: 141
diff changeset
470 if (($tmp = stGetRequestItem("lang", FALSE, TRUE)) !== FALSE)
87
8743ff5302ce Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
471 {
142
0e8b8fac920d Check request instead of $_GET.
Matti Hamalainen <ccr@tnsp.org>
parents: 141
diff changeset
472 $tmp = strtolower($tmp);
87
8743ff5302ce Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
473 if (in_array($tmp, $pageLanguages))
8743ff5302ce Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
474 {
8743ff5302ce Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
475 $pageLang = $tmp;
8743ff5302ce Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
476 setcookie("luklang", $tmp, time() + 365*24*60*60); // expire in a year
8743ff5302ce Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
477 }
8743ff5302ce Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
478 }
8743ff5302ce Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
479 else
8743ff5302ce Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
480 if (isset($_COOKIE["luklang"]))
8743ff5302ce Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
481 {
8743ff5302ce Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
482 $tmp = $_COOKIE["luklang"];
8743ff5302ce Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
483 if (in_array($tmp, $pageLanguages))
8743ff5302ce Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
484 $pageLang = $tmp;
8743ff5302ce Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
485 }
8743ff5302ce Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
486
8743ff5302ce Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
487
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
488 // Cookie info window
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
489 $showCookieInfo = isset($_COOKIE["lukcookieinfo"]) ? !$_COOKIE["lukcookieinfo"] : TRUE;
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
490
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
491
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
492 // Development info window
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
493 $showDevInfo = isset($_COOKIE["lukdevinfo"]) ? $_COOKIE["lukdevinfo"] : TRUE;
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
494 setcookie("lukdevinfo", 0, time() + 2*7*24*60*60);
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
495
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
496
188
658422c83b49 Change the class setting request parameter and cookie from "luokka" to
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
497 // Check class setting (check "luokka" for backwards compatibility also)
658422c83b49 Change the class setting request parameter and cookie from "luokka" to
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
498 if ((($classID = stGetRequestItem("class", FALSE, TRUE)) !== FALSE ||
658422c83b49 Change the class setting request parameter and cookie from "luokka" to
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
499 ($classID = stGetRequestItem("luokka", FALSE, TRUE)) !== FALSE) && lukCheckClassID($classID))
83
85068c8513b4 Add back mobile mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 82
diff changeset
500 {
188
658422c83b49 Change the class setting request parameter and cookie from "luokka" to
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
501 setcookie("lukclass", $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
502 }
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
503 else
188
658422c83b49 Change the class setting request parameter and cookie from "luokka" to
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
504 if (isset($_COOKIE["lukclass"]))
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
505 {
188
658422c83b49 Change the class setting request parameter and cookie from "luokka" to
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
506 $classID = $_COOKIE["lukclass"];
135
31ba82aabbba Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents: 134
diff changeset
507 lukCheckClassID($classID);
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
508 }
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
509 else
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
510 {
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
511 stError(cmQM("class_not_set", $classDefaultID));
135
31ba82aabbba Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents: 134
diff changeset
512 $classID = $classDefaultID;
39
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
513 }
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
514
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
515
87
8743ff5302ce Add some comments, check language setting first to have the proper language
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
516 // Check next period flag
142
0e8b8fac920d Check request instead of $_GET.
Matti Hamalainen <ccr@tnsp.org>
parents: 141
diff changeset
517 if (isset($_REQUEST["next"]))
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
518 {
39
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
519 $nextPeriod = TRUE;
82
c553ad61e9c2 Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
520 $cachePath = "cache-next/";
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
521 }
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
522 else
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
523 {
39
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
524 $nextPeriod = FALSE;
82
c553ad61e9c2 Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
525 $cachePath = "cache/";
c553ad61e9c2 Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
526 }
c553ad61e9c2 Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
527
159
66f3f02d5172 Add default (empty string) value for origBaseURI variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 158
diff changeset
528 // Get original base URI data
66f3f02d5172 Add default (empty string) value for origBaseURI variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 158
diff changeset
529 $origBaseURI = "";
82
c553ad61e9c2 Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
530 if (file_exists($cachePath."baseuri.data"))
c553ad61e9c2 Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
531 require $cachePath."baseuri.data";
39
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
532
78d0c1cd7282 Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
533
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
534 // Global cache for course data
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
535 $cache = array();
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
536 $cacheDirty = FALSE;
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
537
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
538 // Try to read cachefile, if we can get file lock on it
182
a59bb75aa0ec Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 178
diff changeset
539 if (($fp = @fopen($courseCacheFile, "rb")) !== FALSE)
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
540 {
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
541 if (flock($fp, LOCK_SH))
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
542 {
82
c553ad61e9c2 Make original data links work for both current and next period mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
543 require($courseCacheFile);
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
544 flock($fp, LOCK_UN);
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
545 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
546 fclose($fp);
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
547 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
548
43
7621bfc47491 Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
549
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
550 // Read classfile
183
dda30eff3266 Fix handling of data modification timestamps.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
551 if (($classIDs = lukReadClassFile($classIDFile[$nextPeriod])) === false)
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
552 stError(cmQM("class_list_not_found"));
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
553
129
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
554
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
555 // Read class data
135
31ba82aabbba Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents: 134
diff changeset
556 $dataFile = $cachePath.$classID.".data";
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
557 if (!file_exists($dataFile))
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
558 {
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
559 stError(cmQM("class_data_not_found", chentities($classID)));
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
560 $haveData = FALSE;
183
dda30eff3266 Fix handling of data modification timestamps.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
561 $timestamp = time();
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
562 }
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
563 else
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
564 {
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
565 require($dataFile);
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
566 $haveData = isset($classInfo);
183
dda30eff3266 Fix handling of data modification timestamps.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
567 $timestamp = filemtime($dataFile);
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
568 }
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
569
121
a6af6538777a Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
570
129
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
571 // Create references to mobile device (Apple touch) icons
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
572 $extra = "";
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
573 foreach (array(57 => FALSE, 76 => TRUE, 114 => TRUE, 120 => TRUE, 152 => TRUE) as $iconSize => $addSize)
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
574 {
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
575 $extra .= " <link rel=\"apple-touch-icon\" ".
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
576 ($addSize ? "sizes=\"".$iconSize."x".$iconSize."\" " : "").
110
7d77d21873d1 Add mobile/Apple "touch icons".
Matti Hamalainen <ccr@tnsp.org>
parents: 108
diff changeset
577 "href=\"img/icon-".$iconSize."-precomposed.png\" />\n";
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
578 }
18
e0f1a5861f28 Fixes, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
579
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
580 // XXX: Temporarily no-index (remember also robots.txt!)
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
581 $extra .= " <meta name=\"robots\" content=\"noindex\">\n";
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
582
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
583 // For mobile shit
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
584 $extra .= " <meta name=\"viewport\" content=\"width=device-width\" />\n";
129
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
585
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
586 // Start printing the page
147
f559f0161fd5 Use pageName variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
587 $pageTitle = $haveData ? $classID." / ".join("; ", $classInfo["info"]) : $classID;
f559f0161fd5 Use pageName variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
588 cmPrintPageHeader($pageTitle." - ".$pageName, $extra);
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
589
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
590 echo "
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
591 <script type=\"text/javascript\">
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
592 function lukSetCookie(cname, cvalue, cctime)
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
593 {
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
594 var de = new Date();
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
595 de.setTime(de.getTime() + cctime*1000);
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
596 document.cookie = cname +\"=\"+ cvalue +\"; expires=\"+ de.toUTCString();
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
597 }
129
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
598
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
599 function lukSetViewDo(elem, state)
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
600 {
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
601 elem.style.display = state ? 'block' : 'none';
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
602 }
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
603
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
604 function lukSetView(id, state)
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
605 {
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
606 var elem = document.getElementById(id);
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
607 if (elem) lukSetViewDo(elem, state);
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
608 }
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
609
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
610 function lukToggleView(id)
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
611 {
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
612 var elem = document.getElementById(id);
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
613 if (elem) lukSetViewDo(elem, (elem.style.display == 'none'));
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
614 }
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
615
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
616 function lukAcknowledgeCookies()
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
617 {
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
618 lukSetCookie('lukcookieinfo', 1, 31*24*60*60);
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
619 var elem = document.getElementById('cookieInfo');
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
620 if (elem) lukSetViewDo(elem, false);
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
621 }
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
622 </script>
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
623
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
624 <div id=\"devInfo\" ".($showDevInfo ? "" : " style=\"display: none;\"").">
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
625 <h1>Notice!</h1>
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
626 <p>
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
627 <b>This is the development version of 'Lukkari', tentatively called \"3.0alpha\".</b>
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
628 It is constantly changing, any features may be broken and fixed at
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
629 rapid pace. The style/layout is also in flux, and not finished -
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
630 there may be rendering bugs. Currently I am testing a non-table-based layout,
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
631 although it is not certain if it will be used in 'production'.
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
632 </p>
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
633 <p>
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
634 If you wish to suggest features, send e-mail to <b>ccr (at) tnsp (dot) org</b>
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
635 </p>
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
636 <div class=\"popupControls\">
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
637 <button type=\"button\" onClick=\"lukSetView('devInfo', false);\">Okay</button>
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
638 </div>
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
639 </div>
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
640 ";
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
641
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
642 if ($showCookieInfo)
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
643 {
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
644 echo
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
645 "<div id=\"cookieInfo\">\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
646 " <p>Lukkari web-site uses <a href=\"http://en.wikipedia.org/wiki/HTTP_cookie\">HTTP cookies</a> ".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
647 " to store current settings (language, default class ID, etc.) ".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
648 " Also, Google Analytics used on this site may store information via cookies.".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
649 " </p>".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
650 " By continued use of this site, you acknowledge that you have been informed of the situation.".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
651 " <div class=\"popupControls\">\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
652 " <button type=\"button\" onclick=\"lukAcknowledgeCookies()\">Okay</button>\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
653 " </div>\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
654 "</div>\n";
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
655 }
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
656
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
657
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
658 // Additional controls
130
7cfe0770168f Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
659 echo
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
660 " <div id=\"controls\">\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
661 " <div id=\"infobox\">\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
662 " <div id=\"ctitle\">".$pageName." v".$pageVersion."</div>\n";
130
7cfe0770168f Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
663
129
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
664 if (!$mobileMode)
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
665 {
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
666 echo
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
667 " <div id=\"csssel\">".cmQM("Style").": ";
129
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
668
149
834abfd9d8e9 Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
669 if (isset($pageCSSAlts))
129
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
670 {
149
834abfd9d8e9 Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
671 foreach ($pageCSSAlts as $name => $id)
834abfd9d8e9 Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
672 {
834abfd9d8e9 Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
673 echo
834abfd9d8e9 Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
674 "<a ".(($pageCSSIndex == $id) ? "class=\"selected\" " : "").
834abfd9d8e9 Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
675 "href=\"".$baseURI."?css=".$id."\">".$name."</a>";
834abfd9d8e9 Use CSSalts only if the variable is set.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
676 }
129
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
677 }
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
678
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
679 echo
130
7cfe0770168f Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
680 "</div>\n";
129
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
681 }
b9ebc24f27fd Move some code around a bit, to make mobile mode integration easier.
Matti Hamalainen <ccr@tnsp.org>
parents: 128
diff changeset
682
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
683 echo " <div id=\"clang\">";
130
7cfe0770168f Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
684
7cfe0770168f Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
685 foreach ($pageLanguages as $id)
7cfe0770168f Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
686 {
7cfe0770168f Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
687 echo
131
31347f83cbea Bugfix generated HTML.
Matti Hamalainen <ccr@tnsp.org>
parents: 130
diff changeset
688 "<a ".(($pageLang == $id) ? "class=\"selected\" " : "").
130
7cfe0770168f Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
689 "href=\"".$baseURI."?lang=".$id."\">".$id."</a>";
7cfe0770168f Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
690 }
7cfe0770168f Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
691
7cfe0770168f Sync infobox snippets from mluk.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
692 echo
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
693 " </div>\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
694 " </div>\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
695 " <form action=\"".$baseURI."\" method=\"get\">\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
696 " <div>\n".
189
bc0d7a5d7b8e Make class code selection list to autosubmit via javascript if scripts are
Matti Hamalainen <ccr@tnsp.org>
parents: 188
diff changeset
697 " <select id=\"classSelect\" name=\"class\" onChange=\"this.form.submit();\">\n";
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
698
140
26d266a685ed Fix handling of class selection when no class list is available.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
699 if ($classIDs !== FALSE)
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
700 {
140
26d266a685ed Fix handling of class selection when no class list is available.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
701 foreach ($classIDs as $id)
26d266a685ed Fix handling of class selection when no class list is available.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
702 {
26d266a685ed Fix handling of class selection when no class list is available.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
703 echo
26d266a685ed Fix handling of class selection when no class list is available.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
704 " <option ".($classID == $id ? "selected=\"selected\" " : "").
26d266a685ed Fix handling of class selection when no class list is available.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
705 "value=\"".$id."\">".chentities($id)."</option>\n";
26d266a685ed Fix handling of class selection when no class list is available.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
706 }
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
707 }
135
31ba82aabbba Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents: 134
diff changeset
708
30
6148ce4a83ed Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
709 echo
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
710 " </select>\n".
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
711 " </div>\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
712 " <noscript><div><input id=\"classSwitch\" class=\"submit\" type=\"submit\" value=\"".cmQM("change")."\" /></div></noscript>\n";
17
611452d30bd4 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
713
83
85068c8513b4 Add back mobile mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 82
diff changeset
714 if (!$mobileMode)
85068c8513b4 Add back mobile mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 82
diff changeset
715 {
96
0ba79f50e604 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
716 echo
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
717 " <div><a id=\"nextPeriod\" class=\"textctrl\" href=\"".
184
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
718 $baseURI.($nextPeriod ? "" : "?next")."\" title=\"".cmQM("expl_toggle_period")."\">".
04490fe590ec Cleanup translation code and translations.
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
719 cmQM("period_shown").": ".($nextPeriod ? cmQM("next_period") : cmQM("current_period")).
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
720 "</a></div>\n";
134
6f7a2f9dcad4 Fix some errors due to undefined variables in case the class data is not
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
721
6f7a2f9dcad4 Fix some errors due to undefined variables in case the class data is not
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
722 if ($haveData)
6f7a2f9dcad4 Fix some errors due to undefined variables in case the class data is not
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
723 {
6f7a2f9dcad4 Fix some errors due to undefined variables in case the class data is not
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
724 echo
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
725 " <div><a id=\"origLink\" class=\"textctrl\" href=\"".$origBaseURI.$classID.$origBaseExt."\" title=\"".cmQM("expl_link_original_data")."\">".cmQM("link_original_data")."</a></div>\n";
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
726 //" <div><a id=\"xml\" class=\"textctrl\" href=\"".$baseURI.$cachePath."/".$class.".xml\">XML</a></div>\n";
134
6f7a2f9dcad4 Fix some errors due to undefined variables in case the class data is not
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
727 }
6f7a2f9dcad4 Fix some errors due to undefined variables in case the class data is not
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
728
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
729 // echo " <div><a id=\"mobileLink\" class=\"textctrl mobile\" href=\"http://tnsp.org/mluk/\" title=\"".cmQM("expl_link_mobile_version")."\">".cmQM("link_mobile_version")."</a></div>\n";
83
85068c8513b4 Add back mobile mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 82
diff changeset
730 }
78
2f9c78c68a2c Add link to the XML.
Matti Hamalainen <ccr@tnsp.org>
parents: 73
diff changeset
731
188
658422c83b49 Change the class setting request parameter and cookie from "luokka" to
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
732 $currURL = $baseURI."?class=".$classID."&amp;lang=".$pageLang.
123
ad7ccdd904b7 Fix some HTML.
Matti Hamalainen <ccr@tnsp.org>
parents: 121
diff changeset
733 (isset($pageCSSIndex) ? "&amp;css=".$pageCSSIndex : "").
ad7ccdd904b7 Fix some HTML.
Matti Hamalainen <ccr@tnsp.org>
parents: 121
diff changeset
734 ($nextPeriod ? "&amp;next" : "");
119
78b4eb3a9719 Add link to the page with current settings, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
735
96
0ba79f50e604 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
736 echo
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
737 " <div><a href=\"".$currURL."\" class=\"textctrl\" title=\"".cmQM("expl_link_current_settings")."\">".cmQM("link_current_settings")."</a></div>\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
738 " <div><button id=\"toggleDevInfo\" type=\"button\" onclick=\"lukToggleView('devInfo')\">INFO</button></div>\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
739 " </form>\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
740 "</div>\n".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
741 "<div id=\"header\">\n".
121
a6af6538777a Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
742 "<h1>".$pageTitle."</h1>\n";
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
743
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
744 if (!$mobileMode)
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
745 {
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
746 echo
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
747 "<p>".join("; ", $classInfo["general"]).
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
748 //" [".cmQM("viikossa", $classInfo["totalHours"])."]".
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
749 "</p>\n";
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
750 }
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
751
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
752 // Show error messages
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
753 if ($errorSet)
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
754 {
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
755 echo "<ul>\n";
44
57af36f0864e Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
756 foreach ($errorMsgs as $msg)
135
31ba82aabbba Backport some cleanups from 3.0.
Matti Hamalainen <ccr@tnsp.org>
parents: 134
diff changeset
757 echo "<li>".$msg."</li>\n";
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
758 echo "</ul>\n";
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
759 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
760
193
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
761 echo "</div>\n";
16ce445c499a Import v3 branch.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
762
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
763 if ($haveData)
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
764 {
83
85068c8513b4 Add back mobile mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 82
diff changeset
765 echo lukPrintTimeTable($mobileMode);
59
aa201ddd33dd Cleaned up, v2.0 beta.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
766 }
5
3d6a83eaa2ba Improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
767
73
241839ebb09f More cleanups, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
768 echo
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
769 "<div id=\"footer\">".
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
770 cmQM("contact", "ccr @ IRCNet", "ccr (at) tnsp (dot) org").
121
a6af6538777a Add "last updated" timestamps and version stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
771 " / ".
133
ad10ab39e2d1 Fix date stamp.
Matti Hamalainen <ccr@tnsp.org>
parents: 131
diff changeset
772 cmQM("updated", strftime("%d.%m.%Y, %H:%M", $timestamp)).
147
f559f0161fd5 Use pageName variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
773 //" <div style=\"color: red;\">".cmQM("beta", $pageVersion, $pageName)."</div>\n".
107
9f976ae7a3e2 Reformat, modularize, cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
774 "</div>\n";
84
adaad33f929c Improve mobile mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 83
diff changeset
775
98
6a7172b3a841 Update to match the main page API.
Matti Hamalainen <ccr@tnsp.org>
parents: 96
diff changeset
776 cmPrintPageFooter();
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
777
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
778
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
779 // Dump the course data cache, but only if it has changed
64
6900beff8789 Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
780 if ($cacheDirty)
6900beff8789 Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
781 {
6900beff8789 Improve multi-language support.
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
782 $str = "<?\n\$cache = ".var_export($cache, TRUE)."\n?>";
114
09d811e4387d Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
783 if (file_put_contents($courseCacheFile, $str, LOCK_EX) === FALSE)
09d811e4387d Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
784 {
27
7655db03ea60 Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
785 // Can't do much anything here ..
1
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
786 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
787 }
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
788
21fde93375e9 Add beta code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
789 ?>