forked from chaosarium/lwt
-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
mobile.php
345 lines (270 loc) · 11.1 KB
/
mobile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<?php
/**
* \file
* \brief LWT Mobile
*
* Call: mobile.php?...
* ...action=1&lang=[langid] ... Language menu
* ...action=2&lang=[langid] ... Texts in a language
* ...action=3&lang=[langid]&text=[textid] ... Sentences of a text
* ...action=4&lang=[langid]&text=[textid]&sent=[sentid] ... Terms of a sentence
* ...action=5&lang=[langid]&text=[textid]&sent=[sentid] ... Terms of a sentence (next sent)
*
* PHP version 8.1
*
* @category User_Interface
* @package Lwt
* @author LWT Project <[email protected]>
* @license Unlicense <http://unlicense.org/>
* @link https://hugofara.github.io/lwt/docs/php/files/mobile.html
* @since 1.4.0
*/
require_once 'inc/session_utility.php';
/**************************************************************/
if (isset($_REQUEST["action"])) { // Action
$action = (int) $_REQUEST["action"]; // Action code
/* -------------------------------------------------------- */
if ($action == 1) {
$lang = $_REQUEST["lang"];
$langname = getLanguage($lang);
?>
<ul id="<?php echo $action . '-' . $lang; ?>" title="<?php echo tohtml($langname); ?>">
<li class="group"><?php echo tohtml($langname); ?> Texts</li>
<li><a href="mobile.php?action=2&lang=<?php echo $lang; ?>">All <?php echo tohtml($langname); ?> Texts</a></li>
<li><a href="mobile.php#notyetimpl">Text Tags</a></li>
<li class="group"><?php echo tohtml($langname); ?> Terms</li>
<li><a href="mobile.php#notyetimpl">All <?php echo tohtml($langname); ?> Terms</a></li>
<li><a href="mobile.php#notyetimpl">Term Tags</a></li>
</ul>
<?php
} // $action == 1
/* -------------------------------------------------------- */
elseif ($action == 2) {
$lang = $_REQUEST["lang"];
$langname = getLanguage($lang);
$sql = 'select TxID, TxTitle from ' . $tbpref . 'texts where TxLgID = ' . $lang .
' order by TxTitle';
$res = do_mysqli_query($sql);
?>
<ul id="<?php echo $action . '-' . $lang; ?>" title="All <?php echo tohtml($langname); ?> Texts">
<?php
while ($record = mysqli_fetch_assoc($res)) {
echo '<li><a href="mobile.php?action=3&lang=' .
$lang . '&text=' . $record["TxID"] . '">' .
tohtml($record["TxTitle"]) . '</a></li>';
}
?>
</ul>
<?php
mysqli_free_result($res);
} // $action == 2
/* -------------------------------------------------------- */
elseif ($action == 3) {
$lang = $_REQUEST["lang"];
$text = $_REQUEST["text"];
$texttitle = (string) get_first_value(
'select TxTitle as value from ' . $tbpref . 'texts where TxID = ' . $text
);
$textaudio = (string) get_first_value(
'select TxAudioURI as value from ' . $tbpref . 'texts where TxID = ' . $text
);
$sql = 'select SeID, SeText from ' . $tbpref . 'sentences where SeTxID = ' . $text . ' order by SeOrder';
$res = do_mysqli_query($sql);
?>
<ul id="<?php echo $action . '-' . $text; ?>" title="<?php echo tohtml($texttitle); ?>">
<li class="group">Title</li>
<li><?php echo tohtml($texttitle); ?></li>
<?php
if (isset($textaudio) && trim($textaudio) != '') {
?>
<li class="group">Audio</li>
<li>Play: <audio src="<?php echo trim($textaudio); ?>" controls></audio></li>
<?php
}
?>
<li class="group">Text</li>
<?php
while ($record = mysqli_fetch_assoc($res)) {
if (trim((string) $record["SeText"]) != '¶') {
echo '<li><a href="mobile.php?action=4&lang=' .
$lang . '&text=' . $text .
'&sent=' . $record["SeID"] . '">' .
tohtml($record["SeText"]) . '</a></li>';
}
}
?>
</ul>
<?php
mysqli_free_result($res);
} // $action == 3
/* -------------------------------------------------------- */
elseif ($action == 4 || $action == 5) {
$lang = $_REQUEST["lang"];
$text = $_REQUEST["text"];
$sent = $_REQUEST["sent"];
$senttext = get_first_value(
'SELECT SeText AS value FROM ' . $tbpref . 'sentences WHERE SeID = ' . $sent
);
$nextsent = get_first_value(
'SELECT SeID AS value
FROM ' . $tbpref . 'sentences
WHERE SeTxID = ' . $text . ' AND trim(SeText) != \'¶\' AND SeID > ' . $sent . '
ORDER BY SeID
LIMIT 1'
);
$sql =
'SELECT
CASE WHEN Ti2WordCount>0 THEN Ti2WordCount ELSE 1 END as Code,
CASE WHEN CHAR_LENGTH(Ti2Text)>0 THEN Ti2Text ELSE WoText END AS TiText,
Ti2Order,
CASE WHEN Ti2WordCount > 0 THEN 0 ELSE 1 END AS TiIsNotWord,
WoID, WoTranslation, WoRomanization, WoStatus
FROM (' .
$tbpref . 'textitems2
LEFT JOIN ' . $tbpref . 'words
ON (Ti2WoID = WoID) AND (Ti2LgID = WoLgID)
)
WHERE Ti2SeID = ' . $sent . '
ORDER BY Ti2Order asc, Ti2WordCount desc';
$res = do_mysqli_query($sql);
if ($action == 4) {
?>
<ul id="<?php echo $action . '-' . $sent; ?>" title="<?php echo tohtml($senttext); ?>">
<?php
}
?>
<li class="group">Sentence</li>
<li><?php echo tohtml($senttext); ?></li>
<li class="group">Terms</li>
<?php
$saveterm = '';
$savetrans = '';
$saverom = '';
$savestat = '';
$until = 0;
while ($record = mysqli_fetch_assoc($res)) {
$actcode = (int)$record['Code'];
$order = (int)$record['Ti2Order'];
if ($order <= $until ) {
continue;
}
if ($order > $until ) {
if (trim($saveterm) != '') {
$desc = trim(($saverom != '' ? '[' . $saverom . '] ' : '') . $savetrans);
echo '<li><span class="status' . $savestat . '">' . tohtml($saveterm) . '</span>' .
tohtml($desc != '' ? ' → ' . $desc : '') . '</li>';
}
$saveterm = '';
$savetrans = '';
$saverom = '';
$savestat = '';
$until = $order;
}
if ($record['TiIsNotWord'] != 0 && trim((string) $record['TiText']) != '') {
echo '<li>' . tohtml($record['TiText']) . '</li>';
}
else {
$until = $order + 2 * ($actcode-1);
$saveterm = (string) $record['TiText'];
$savetrans = '';
if(isset($record['WoID'])) {
$savetrans = $record['WoTranslation'];
if ($savetrans == '*') { $savetrans = '';
}
}
$saverom = trim(
isset($record['WoRomanization']) ?
(string) $record['WoRomanization'] : ""
);
$savestat = $record['WoStatus'];
}
}
mysqli_free_result($res);
if (trim($saveterm) != '') {
$desc = trim(($saverom != '' ? '[' . $saverom . '] ' : '') . $savetrans);
echo '<li><span class="status' . $savestat . '">' . tohtml($saveterm) . '</span>' .
tohtml($desc != '' ? ' → ' . $desc : '') . '</li>';
}
if (isset($nextsent)) {
echo '<li><a target="_replace" href="mobile.php?action=5&lang=' .
$lang . '&text=' . $text .
'&sent=' . $nextsent . '">Next Sentence</a></li>';
}
if ($action == 4) {
?>
</ul>
<?php
}
} // $action == 4 / 5
/* -------------------------------------------------------- */
} // isset($_REQUEST["action"])
/**************************************************************/
else { // No Action = Start screen
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-language" content="en" />
<title>Mobile LWT</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<link rel="apple-touch-icon" href="img/apple-touch-icon-57x57.png" />
<link rel="apple-touch-icon" sizes="72x72" href="img/apple-touch-icon-72x72.png" />
<link rel="apple-touch-icon" sizes="114x114" href="img/apple-touch-icon-114x114.png" />
<link rel="apple-touch-startup-image" href="img/apple-touch-startup.png">
<meta name="apple-touch-fullscreen" content="YES" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<style type="text/css" media="screen">
@import "./iui/iui.css";
span.status1 {
background-color: #F5B8A9;
}
span.status2 {
background-color: #F5CCA9;
}
span.status3 {
background-color: #F5E1A9;
}
span.status4 {
background-color: #F5F3A9;
}
span.status5 {
background-color: #DDFFDD;
}
</style>
<script type="text/javascript" src="./iui/iui.js" charset="utf-8"></script>
</head>
<body>
<div class="toolbar">
<h1 id="pageTitle"></h1>
<a id="backButton" class="button" href="#"></a>
<a class="button" href="mobile.php" target="_self">Home</a>
</div>
<ul id="home" title="Mobile LWT" selected="true">
<li class="group">Languages</li>
<?php
$sql = 'select LgID, LgName from ' . $tbpref . 'languages where LgName<>"" order by LgName';
$res = do_mysqli_query($sql);
while ($record = mysqli_fetch_assoc($res)) {
echo '<li><a href="mobile.php?action=2&lang=' . $record["LgID"] . '">' .
tohtml($record["LgName"]) . '</a></li>';
}
mysqli_free_result($res);
?>
<li class="group">Other</li>
<li><a href="#about">About</a></li>
<li><a href="index.php" target="_self">LWT Standard Version</a></li>
</ul>
<div id="about" title="About">
<p style="text-align:center; margin-top:50px;">
This is "Learning With Texts" (LWT) for Mobile Devices<br />Version <?php echo get_version(); ?><br /><br />"Learning with Texts" (LWT) is released into the Public Domain. This applies worldwide. In case this is not legally possible, any entity is granted the right to use this work for any purpose, without any conditions, unless such conditions are required by law.<br /><br /> Developed with the <a href="http://iui-js.org" target="_self">iUI Framework</a>.<br /><br /><b>Back to<br/><a href="index.php" target="_self">LWT Standard Version</a></b>
</p>
</div>
<div id="notyetimpl" title="Sorry...">
<p style="text-align:center; margin-top:50px;">Not yet implemented!</p>
</div>
</body>
</html>
<?php
} // No Action = Start screen
?>