annotate showajax.php @ 429:2e4f20bd3b82

And moar.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 05 Dec 2013 21:46:35 +0200
parents d2ece5d0aaa4
children 48903fd966cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
126
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 <?
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 //
136
aeebfedb5709 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
3 // FAPWeb Simple Demoparty System
aeebfedb5709 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
4 // Party information display system AJAX backend module
aeebfedb5709 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
5 // (C) Copyright 2012-2013 Tecnic Software productions (TNSP)
126
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 //
175
8df523e6326a User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
7 require_once "mconfig.inc.php";
8df523e6326a User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
8 require_once "msite.inc.php";
126
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
10
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
11 function stPrintCompoEntry($entry, $class, $compo, $title = false)
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
12 {
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
13 echo
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
14 " <div class=\"".$class."\">\n";
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
15
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
16 if ($title !== false)
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
17 echo
387
3cc078b17260 Show backend work.
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
18 " <div class=\"entryTitle\">".$title."</div>\n";
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
19
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
20 echo
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
21 " <div class=\"entryIndex\">#".$entry["show_id"]."</div>\n".
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
22 " <div class=\"entryName\">".chentities($entry["name"])."</div>\n";
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
23
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
24 if ($compo["showAuthors"])
387
3cc078b17260 Show backend work.
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
25 {
3cc078b17260 Show backend work.
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
26 if ($title === false)
3cc078b17260 Show backend work.
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
27 echo " <div class=\"entryBy\">by</div>\n";
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
28 echo " <div class=\"entryAuthor\">".chentities($entry["author"])."</div>\n";
387
3cc078b17260 Show backend work.
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
29 }
3cc078b17260 Show backend work.
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
30
3cc078b17260 Show backend work.
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
31 if ($title === false)
3cc078b17260 Show backend work.
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
32 echo " <div class=\"entryInfo\">".chentities($entry["info"])."</div>\n";
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
33
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
34 echo
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
35 " </div>\n";
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
36 }
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
37
163
1386a7a8816c Whitespace cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
38
140
20ca8edfb01a Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
39 function stPrintCompoSlide($compo, $entry, $prev)
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
40 {
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
41 echo
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
42 " <div class=\"compoHeader\">\n".
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
43 " <img src=\"img/fapsm.png\" /><br />\n".
387
3cc078b17260 Show backend work.
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
44 " <div class=\"compoTitle\">".chentities($compo["name"])." competition</div>\n".
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
45 " </div>\n";
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
46
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
47 if ($entry !== false)
386
0693747fa7d3 Indent.
Matti Hamalainen <ccr@tnsp.org>
parents: 356
diff changeset
48 stPrintCompoEntry($entry, "compoNext", $compo, false);
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
49
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
50 if ($prev !== false)
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
51 stPrintCompoEntry($prev, "compoPrev", $compo, "Previous entry");
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
52 }
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
53
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
54
140
20ca8edfb01a Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
55 function stPrintRotationSlide($slide)
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
56 {
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
57 echo
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
58 " <div class=\"showHeader\">\n".
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
59 " <img src=\"img/fapsm.png\" /><br />\n".
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
60 " </div>\n".
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
61 " <div class=\"showText\">\n".
140
20ca8edfb01a Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
62 $slide["text"].
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
63 " </div>\n";
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
64 }
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
65
163
1386a7a8816c Whitespace cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
66
391
0c1798c9d486 Add disabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 387
diff changeset
67 function stGuruMeditation()
0c1798c9d486 Add disabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 387
diff changeset
68 {
0c1798c9d486 Add disabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 387
diff changeset
69 echo
0c1798c9d486 Add disabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 387
diff changeset
70 "<div class=\"guru\">".
0c1798c9d486 Add disabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 387
diff changeset
71 "Software Failure.&nbsp;&nbsp;&nbsp;Press left mouse button to continue.<br />".
0c1798c9d486 Add disabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 387
diff changeset
72 "Guru Meditation #00000004.0000AAC0".
0c1798c9d486 Add disabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 387
diff changeset
73 "</div>\n";
0c1798c9d486 Add disabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 387
diff changeset
74 }
0c1798c9d486 Add disabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 387
diff changeset
75
0c1798c9d486 Add disabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 387
diff changeset
76
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
77 //
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
78 // Initialize
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
79 //
126
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 stSetupCacheControl();
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 if (!stConnectSQLDB())
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 die("Could not connect to SQL database.");
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
85 stReloadDisplayVars();
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
86
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
87
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
88 //
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
89 // Check if the slide needs updating?
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
90 //
145
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
91 $updated = FALSE;
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
92
152
6e6fba2da3d1 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
93 // Temporary slides are handled globally
145
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
94 if (stGetDisplayVar("tempDuration") > 0 &&
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
95 stGetDisplayVar("tempSlide") > 0 &&
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
96 stGetDisplayVar("tempSlideSet"))
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
97 {
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
98 $sql = stPrepareSQL("SELECT * FROM displaySlides WHERE id=%d",
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
99 stGetDisplayVar("tempSlide"));
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
100
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
101 if (($res = stFetchSQL($sql)) !== false)
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
102 {
145
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
103 stSetDisplayVar("tempSlideSet", FALSE);
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
104 stSetDisplayVar("activeSlideMode", SMODE_ROTATE);
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
105 stSetDisplayVar("activeSlide", stGetDisplayVar("tempSlide"));
429
2e4f20bd3b82 And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 417
diff changeset
106 stSetDisplayVar("activeSlideExpire", time() + stGetDisplayVar("tempDuration"));
145
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
107 $updated = TRUE;
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
108 }
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
109 }
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
110 else
152
6e6fba2da3d1 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
111 // Otherwise we act according to global show mode
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
112 switch (stGetDisplayVar("showMode"))
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
113 {
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
114 case SMODE_ROTATE:
152
6e6fba2da3d1 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
115 //
6e6fba2da3d1 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
116 // Rotation / normal slide show mode
6e6fba2da3d1 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
117 //
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
118 stSetDisplayVar("activeSlideMode", SMODE_ROTATE);
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
119
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
120 if (stGetDisplayVar("rotateList") == 0)
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
121 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
122 stSetDisplayVar("rotateList", 1);
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
123 stSetDisplayVar("activeSlideExpire", 0);
145
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
124 $updated = TRUE;
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
125 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
126
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
127 if (time() >= stGetDisplayVar("activeSlideExpire") &&
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
128 stGetDisplayVar("rotateList") > 0)
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
129 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
130 // Get list of slides from active rotation list
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
131 $list = stGetDisplayVar("rotateList");
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
132 $sql = stPrepareSQL(
416
876846d8ed5b Rename some database things.
Matti Hamalainen <ccr@tnsp.org>
parents: 409
diff changeset
133 "SELECT * FROM rotationListSlides WHERE list_id=%d ORDER BY order_num",
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
134 $list);
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
135
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
136 if (($slideList = stExecSQL($sql)) !== false)
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
137 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
138 // Get slide at current index
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
139 $slides = array();
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
140 foreach ($slideList as $slide)
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
141 $slides[] = $slide;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
142
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
143 $index = stGetDisplayVar("rotateListIndex");
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
144 if (count($slides) > $index)
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
145 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
146 $slide_id = $slides[$index]["slide_id"];
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
147 if ($slide_id != stGetDisplayVar("activeSlide"))
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
148 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
149 stSetDisplayVar("activeSlide", $slide_id);
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
150 stSetDisplayVar("activeSlideExpire", time() + stGetDisplayVar("rotateDuration"));
145
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
151 $updated = TRUE;
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
152 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
153 }
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
154
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
155 // Rotate to next slide
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
156 if (++$index >= count($slides))
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
157 $index = 0;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
158
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
159 stSetDisplayVar("rotateListIndex", $index);
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
160 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
161 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
162 break;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
163
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
164 case SMODE_COMPO:
152
6e6fba2da3d1 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
165 //
6e6fba2da3d1 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
166 // Competition mode, is controlled from admin UI, so we donẗ
6e6fba2da3d1 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
167 // actually do anything here.
6e6fba2da3d1 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
168 //
387
3cc078b17260 Show backend work.
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
169 if (time() >= stGetDisplayVar("activeSlideExpire"))
3cc078b17260 Show backend work.
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
170 stSetDisplayVar("activeSlideMode", SMODE_COMPO);
3cc078b17260 Show backend work.
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
171
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
172 break;
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
173 }
126
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174
152
6e6fba2da3d1 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
175 // Check if we need to update the "last updated" timestamp
145
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
176 if ($updated)
407
eaea1ae2bc3d Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
177 stDisplayUpdated();
145
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
178
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
179
152
6e6fba2da3d1 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
180 //
6e6fba2da3d1 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
181 // Serve the request
6e6fba2da3d1 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
182 //
144
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
183 $type = stGetRequestItem("type");
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
184 switch (stGetRequestItem("action"))
126
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 {
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
186 case "check":
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
187 // Check if there has been any change
145
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
188 $changed = stGetRequestItem("lastUpdate") != stGetDisplayVar("lastUpdate");
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
189 echo $changed ? "changed" : "nochange";
126
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190 break;
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
192 case "get":
144
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
193 switch ($type)
126
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 {
145
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
195 case "update":
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
196 echo stGetDisplayVar("lastUpdate");
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
197 break;
144
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
198
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
199 case "slide":
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
200 // Based on the currently active mode ...
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
201 switch (stGetDisplayVar("activeSlideMode"))
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
202 {
409
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
203 case SMODE_DISABLED:
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
204 stGuruMeditation();
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
205 break;
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
206
144
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
207 case SMODE_ROTATE:
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
208 // Slide rotation mode, display currently active slide
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
209 if (stGetDisplayVar("activeSlide") > 0)
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
210 {
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
211 $sql = stPrepareSQL("SELECT * FROM displaySlides WHERE id=%d",
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
212 stGetDisplayVar("activeSlide"));
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
213
144
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
214 if (($slide = stFetchSQL($sql)) !== false)
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
215 stPrintRotationSlide($slide);
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
216 }
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
217 else
391
0c1798c9d486 Add disabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 387
diff changeset
218 stGuruMeditation();
144
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
219 break;
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
220
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
221 case SMODE_COMPO:
152
6e6fba2da3d1 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
222 // Competition mode, show entry data
387
3cc078b17260 Show backend work.
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
223 $compo_id = stGetDisplayVar("compoID");
144
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
224 $compo = stFetchSQL(stPrepareSQL(
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
225 "SELECT * FROM compos WHERE id=%d",
387
3cc078b17260 Show backend work.
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
226 $compo_id));
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
227
144
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
228 $prev = stFetchSQL(stPrepareSQL(
387
3cc078b17260 Show backend work.
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
229 "SELECT * FROM entries WHERE compo_id=%d AND show_id=%d",
3cc078b17260 Show backend work.
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
230 $compo_id, stGetDisplayVar("compoPrevEntry")));
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
231
144
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
232 $entry = stFetchSQL(stPrepareSQL(
387
3cc078b17260 Show backend work.
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
233 "SELECT * FROM entries WHERE compo_id=%d AND show_id=%d",
3cc078b17260 Show backend work.
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
234 $compo_id, stGetDisplayVar("compoCurrEntry")));
144
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
235
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
236 if ($compo !== false)
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
237 stPrintCompoSlide($compo, $entry, $prev);
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
238 break;
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
239 }
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
240 break;
126
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
241 }
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242 break;
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244 default:
391
0c1798c9d486 Add disabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 387
diff changeset
245 stGuruMeditation();
126
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246 break;
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247 }
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
249
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
250 // Save changed variables
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
251 stSaveDisplayVars();
211
5bae42020034 Factorize some code into msitegen.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
252
417
d2ece5d0aaa4 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 416
diff changeset
253 //stDumpAJAXStatusErrors();
126
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254 ?>