Repository navigation
Expand file tree
/
Copy pathedit_languages.php
More file actions
785 lines (738 loc) · 32.1 KB
/
Copy pathedit_languages.php
File metadata and controls
785 lines (738 loc) · 32.1 KB
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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
<?php
/**
* \file
* \brief Manage languages
*
* Call: edit_languages.php?....
* ... refresh=[langid] ... reparse all texts in lang
* ... del=[langid] ... do delete
* ... op=Save ... do insert new
* ... op=Change ... do update
* ... new=1 ... display new lang. screen
* ... chg=[langid] ... display edit screen
*
* @package Lwt
* @author LWT Project <lwt-project@hotmail.com>
* @license Unlicense <http://unlicense.org/>
* @link https://hugofara.github.io/lwt/docs/html/edit__languages_8php.html
* @since 1.0.3
* @since 2.4.0 Refactored with functional paradigm
*/
require_once 'inc/session_utility.php';
/**
* Prepare a JavaScript code that checks for duplicate names in languages.
*
* @return void
*/
function edit_languages_alert_duplicate()
{
?>
<script type="text/javascript">
//<![CDATA[
var LANGUAGES = <?php echo json_encode(get_languages()); ?>;
/// Check if langname exists and its lang# != curr
function check_dupl_lang(curr) {
const l = $('#LgName').val();
if (l in LANGUAGES) {
if (curr != LANGUAGES[l]) {
alert('Language "' + l +
'" already exists. Please change the language name!');
$('#LgName').focus();
return false;
}
}
return true;
}
//]]>
</script>
<?php
}
/**
* Refresh sentence and text items from a specific language.
*
* @param {int} $lid Language ID
*
* @return {string} Number of sentences and textitems refreshed
*
* @global {string} $tbpref Database table prefix
*/
function edit_languages_refresh($lid)
{
global $tbpref;
$message2 = runsql(
'delete from ' . $tbpref . 'sentences where SeLgID = ' . $lid,
"Sentences deleted"
);
$message3 = runsql(
'delete from ' . $tbpref . 'textitems2 where Ti2LgID = ' . $lid,
"Text items deleted"
);
adjust_autoincr('sentences', 'SeID');
$sql = "select TxID, TxText from " . $tbpref . "texts
where TxLgID = " . $lid . "
order by TxID";
$res = do_mysqli_query($sql);
while ($record = mysqli_fetch_assoc($res)) {
$txtid = (int)$record["TxID"];
$txttxt = $record["TxText"];
splitCheckText($txttxt, $lid, $txtid);
}
mysqli_free_result($res);
$message = $message2 .
" / " . $message3 .
" / Sentences added: " . get_first_value(
'select count(*) as value
from ' . $tbpref . 'sentences
where SeLgID = ' . $lid
) .
" / Text items added: " . get_first_value(
'select count(*) as value
from ' . $tbpref . 'textitems2
where Ti2LgID = ' . $lid
);
return $message;
}
/**
* Delete a language.
*
* @param {int} $lid Language ID
*
* @return {string} Info on the number of languages deleted
*
* @global {string} $tbpref Database table prefix
*/
function edit_languages_delete($lid)
{
global $tbpref;
$anztexts = get_first_value(
'select count(TxID) as value
from ' . $tbpref . 'texts
where TxLgID = ' . $lid
);
$anzarchtexts = get_first_value(
'select count(AtID) as value
from ' . $tbpref . 'archivedtexts
where AtLgID = ' . $lid
);
$anzwords = get_first_value(
'select count(WoID) as value
from ' . $tbpref . 'words
where WoLgID = ' . $lid
);
$anzfeeds = get_first_value(
'select count(NfID) as value
from ' . $tbpref . 'newsfeeds
where NfLgID = ' . $lid
);
if ($anztexts > 0 || $anzarchtexts > 0 || $anzwords > 0 || $anzfeeds > 0) {
$message = 'You must first delete texts, archived texts, newsfeeds and words with this language!';
} else {
$message = runsql(
'UPDATE ' . $tbpref . 'languages
SET LgName = "", LgDict1URI = "", LgDict2URI = "",
LgGoogleTranslateURI = "", LgExportTemplate = "", LgTextSize = DEFAULT,
LgCharacterSubstitutions = "", LgRegexpSplitSentences = "",
LgExceptionsSplitSentences = "", LgRegexpWordCharacters = "",
LgRemoveSpaces = DEFAULT, LgSplitEachChar = DEFAULT,
LgRightToLeft = DEFAULT where LgID = ' . $lid,
"Deleted"
);
}
return $message;
}
/**
* Save a new language to the database.
*
* @return {string} Success or error message
*
* @global {string} $tbpref Database table prefix
*/
function edit_languages_op_save()
{
global $tbpref;
$val = get_first_value(
'select min(LgID) as value
from ' . $tbpref . 'languages
where LgName=""'
);
if (! isset($val)) {
$message = runsql(
'insert into ' . $tbpref . 'languages (
LgName, LgDict1URI, LgDict2URI, LgGoogleTranslateURI,
LgExportTemplate, LgTextSize, LgCharacterSubstitutions,
LgRegexpSplitSentences, LgExceptionsSplitSentences,
LgRegexpWordCharacters, LgRemoveSpaces, LgSplitEachChar,
LgRightToLeft
) values(' .
convert_string_to_sqlsyntax($_REQUEST["LgName"]) . ', ' .
convert_string_to_sqlsyntax($_REQUEST["LgDict1URI"]) . ', '.
convert_string_to_sqlsyntax($_REQUEST["LgDict2URI"]) . ', '.
convert_string_to_sqlsyntax($_REQUEST["LgGoogleTranslateURI"]) . ', '.
convert_string_to_sqlsyntax($_REQUEST["LgExportTemplate"]) . ', '.
$_REQUEST["LgTextSize"] . ', '.
convert_string_to_sqlsyntax_notrim_nonull($_REQUEST["LgCharacterSubstitutions"]) . ', '.
convert_string_to_sqlsyntax($_REQUEST["LgRegexpSplitSentences"]) . ', '.
convert_string_to_sqlsyntax_notrim_nonull($_REQUEST["LgExceptionsSplitSentences"]) . ', '.
convert_string_to_sqlsyntax($_REQUEST["LgRegexpWordCharacters"]) . ', '.
$_REQUEST["LgRemoveSpaces"] . ', '.
$_REQUEST["LgSplitEachChar"] . ', '.
$_REQUEST["LgRightToLeft"] .
')',
'Saved'
);
}
else {
$message = runsql(
'update ' . $tbpref . 'languages set ' .
'LgName = ' . convert_string_to_sqlsyntax($_REQUEST["LgName"]) . ', ' .
'LgDict1URI = ' . convert_string_to_sqlsyntax($_REQUEST["LgDict1URI"]) . ', ' .
'LgDict2URI = ' . convert_string_to_sqlsyntax($_REQUEST["LgDict2URI"]) . ', ' .
'LgGoogleTranslateURI = ' . convert_string_to_sqlsyntax($_REQUEST["LgGoogleTranslateURI"]) . ', ' .
'LgExportTemplate = ' . convert_string_to_sqlsyntax($_REQUEST["LgExportTemplate"]) . ', ' .
'LgTextSize = ' . $_REQUEST["LgTextSize"] . ', ' .
'LgCharacterSubstitutions = ' . convert_string_to_sqlsyntax_notrim_nonull($_REQUEST["LgCharacterSubstitutions"]) . ', ' .
'LgRegexpSplitSentences = ' . convert_string_to_sqlsyntax($_REQUEST["LgRegexpSplitSentences"]) . ', ' .
'LgExceptionsSplitSentences = ' . convert_string_to_sqlsyntax_notrim_nonull($_REQUEST["LgExceptionsSplitSentences"]) . ', ' .
'LgRegexpWordCharacters = ' . convert_string_to_sqlsyntax($_REQUEST["LgRegexpWordCharacters"]) . ', ' .
'LgRemoveSpaces = ' . $_REQUEST["LgRemoveSpaces"] . ', ' .
'LgSplitEachChar = ' . $_REQUEST["LgSplitEachChar"] . ', ' .
'LgRightToLeft = ' . $_REQUEST["LgRightToLeft"] .
' where LgID = ' . $val,
'Saved'
);
}
return $message;
}
/**
* Edit an existing text in the database.
*
* @param {int} $lid Language ID
*
* @return {string} Number of texts updated and items reparsed.
*
* @global {string} $tbpref Database table prefix
*/
function edit_languages_op_change($lid)
{
global $tbpref;
// Get old values
$sql = "select * from " . $tbpref . "languages where LgID=" . $lid;
$res = do_mysqli_query($sql);
$record = mysqli_fetch_assoc($res);
if ($record == false) {
my_die("Cannot access language data: $sql");
}
$oldCharacterSubstitutions = $record['LgCharacterSubstitutions'];
$oldRegexpSplitSentences = $record['LgRegexpSplitSentences'];
$oldExceptionsSplitSentences = $record['LgExceptionsSplitSentences'];
$oldRegexpWordCharacters = $record['LgRegexpWordCharacters'];
$oldRemoveSpaces = $record['LgRemoveSpaces'];
$oldSplitEachChar = $record['LgSplitEachChar'];
mysqli_free_result($res);
$needReParse = (
convert_string_to_sqlsyntax_notrim_nonull($_REQUEST["LgCharacterSubstitutions"])
!= convert_string_to_sqlsyntax_notrim_nonull($oldCharacterSubstitutions)
) || (
convert_string_to_sqlsyntax($_REQUEST["LgRegexpSplitSentences"]) !=
convert_string_to_sqlsyntax($oldRegexpSplitSentences)
) || (
convert_string_to_sqlsyntax_notrim_nonull($_REQUEST["LgExceptionsSplitSentences"])
!= convert_string_to_sqlsyntax_notrim_nonull($oldExceptionsSplitSentences)
) || (
convert_string_to_sqlsyntax($_REQUEST["LgRegexpWordCharacters"]) !=
convert_string_to_sqlsyntax($oldRegexpWordCharacters)
) || ($_REQUEST["LgRemoveSpaces"] != $oldRemoveSpaces) ||
($_REQUEST["LgSplitEachChar"] != $oldSplitEachChar);
$message = runsql(
'update ' . $tbpref . 'languages set ' .
'LgName = ' . convert_string_to_sqlsyntax($_REQUEST["LgName"]) . ', ' .
'LgDict1URI = ' . convert_string_to_sqlsyntax($_REQUEST["LgDict1URI"]) . ', ' .
'LgDict2URI = ' . convert_string_to_sqlsyntax($_REQUEST["LgDict2URI"]) . ', ' .
'LgGoogleTranslateURI = ' . convert_string_to_sqlsyntax($_REQUEST["LgGoogleTranslateURI"]) . ', ' .
'LgExportTemplate = ' . convert_string_to_sqlsyntax($_REQUEST["LgExportTemplate"]) . ', ' .
'LgTextSize = ' . $_REQUEST["LgTextSize"] . ', ' .
'LgCharacterSubstitutions = ' . convert_string_to_sqlsyntax_notrim_nonull($_REQUEST["LgCharacterSubstitutions"]) . ', ' .
'LgRegexpSplitSentences = ' . convert_string_to_sqlsyntax($_REQUEST["LgRegexpSplitSentences"]) . ', ' .
'LgExceptionsSplitSentences = ' . convert_string_to_sqlsyntax_notrim_nonull($_REQUEST["LgExceptionsSplitSentences"]) . ', ' .
'LgRegexpWordCharacters = ' . convert_string_to_sqlsyntax($_REQUEST["LgRegexpWordCharacters"]) . ', ' .
'LgRemoveSpaces = ' . $_REQUEST["LgRemoveSpaces"] . ', ' .
'LgSplitEachChar = ' . $_REQUEST["LgSplitEachChar"] . ', ' .
'LgRightToLeft = ' . $_REQUEST["LgRightToLeft"] .
' where LgID = ' . $lid,
'Updated'
);
if ($needReParse) {
runsql(
'delete from ' . $tbpref . 'sentences where SeLgID = ' . $lid,
"Sentences deleted"
);
runsql(
'delete from ' . $tbpref . 'textitems2 where Ti2LgID = ' . $lid,
"Text items deleted"
);
adjust_autoincr('sentences', 'SeID');
runsql(
"UPDATE " . $tbpref . "words
SET WoWordCount = 0
where WoLgID = " . $lid,
''
);
init_word_count();
$sql = "select TxID, TxText
from " . $tbpref . "texts
where TxLgID = " . $lid . "
order by TxID";
$res = do_mysqli_query($sql);
$cntrp = 0;
while ($record = mysqli_fetch_assoc($res)) {
$txtid = (int)$record["TxID"];
$txttxt = $record["TxText"];
splitCheckText($txttxt, $lid, $txtid);
$cntrp++;
}
mysqli_free_result($res);
$message .= " / Reparsed texts: " . $cntrp;
} else {
$message .= " / Reparsing not needed";
}
return $message;
}
/**
* Display a form to createa new language.
*
* @return void
*/
function edit_languages_new()
{
?>
<h4>
New Language <a href="docs/info.html#howtolang">
<img src="icn/question-frame.png" title="Help" alt="Help" /></a>
</h4>
<script type="text/javascript" charset="utf-8">
$(document).ready(ask_before_exiting);
</script>
<form class="validate" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" onsubmit="return check_dupl_lang(0);">
<table class="tab1" cellspacing="0" cellpadding="5">
<tr>
<td class="td1 center backlightyellow" style="border-top-left-radius:inherit;border-top-right-radius:inherit;" colspan="2">
<img src="icn/wizard.png" title="Language Settings Wizard" alt="Language Settings Wizard" class="click" onclick="window.open('select_lang_pair.php', 'wizard', 'width=400, height=400, scrollbars=yes, menubar=no, resizable=yes, status=no');" /><br /><span class="click" onclick="window.open('select_lang_pair.php', 'wizard', 'width=400, height=400, scrollbars=yes, menubar=no, resizable=yes, status=no');"><img src="icn/arrow-000-medium.png" title="->" alt="->" /> <b>Language Settings Wizard</b> <img src="icn/arrow-180-medium.png" title="<-" alt="<-" /></span><br /><span class="smallgray">Select your native (L1) and study (L2) languages, and let the wizard set all language settings marked in yellow!<br />(You can adjust the settings afterwards.)</span></td>
</tr>
</table>
<table class="tab1" cellspacing="0" cellpadding="5">
<tr>
<td class="td1 right backlightyellow">Study Language "L2":</td>
<td class="td1">
<input type="text" class="notempty setfocus checkoutsidebmp" data_info="Study Language" name="LgName" id="LgName" value="" maxlength="40" size="40" /> <img src="icn/status-busy.png" title="Field must not be empty" alt="Field must not be empty" /></td>
</tr>
<tr>
<td class="td1 right backlightyellow">Dictionary 1 URI:</td>
<td class="td1">
<input type="text" class="checkdicturl notempty checkoutsidebmp" name="LgDict1URI" value="" maxlength="200" size="60" data_info="Dictionary 1 URI" /> <img src="icn/status-busy.png" title="Field must not be empty" alt="Field must not be empty" /></td>
</tr>
<tr>
<td class="td1 right">Dictionary 2 URI:</td>
<td class="td1">
<input type="text" class="checkdicturl checkoutsidebmp" name="LgDict2URI" value="" maxlength="200" size="60" data_info="Dictionary 2 URI" /></td>
</tr>
<tr>
<td class="td1 right backlightyellow">GoogleTranslate URI:</td>
<td class="td1">
<input type="text" class="checkdicturl checkoutsidebmp" name="LgGoogleTranslateURI" value="*http://translate.google.com/?ie=UTF-8&sl=••&tl=••&text=###" maxlength="200" size="60" data_info="GoogleTranslate URI" /></td>
</tr>
<tr>
<td class="td1 right backlightyellow">Text Size:</td>
<td class="td1"><select name="LgTextSize" class="notempty">
<?php echo get_languagessize_selectoptions(150); ?></select>
</td>
</tr>
<tr>
<td class="td1 right">Character Substitutions:</td>
<td class="td1">
<input type="text" class="checkoutsidebmp" data_info="Character Substitutions" name="LgCharacterSubstitutions" value="´='|`='|’='|‘='|...=…|..=‥" maxlength="500" size="60" /></td>
</tr>
<tr>
<td class="td1 right backlightyellow">RegExp Split Sentences:</td>
<td class="td1">
<input type="text" class="notempty checkoutsidebmp" name="LgRegexpSplitSentences" value=".!?:;" maxlength="500" size="60" data_info="RegExp Split Sentences" /> <img src="icn/status-busy.png" title="Field must not be empty" alt="Field must not be empty" /></td>
</tr>
<tr>
<td class="td1 right">Exceptions Split Sentences:</td>
<td class="td1">
<input type="text" class="checkoutsidebmp" data_info="Exceptions Split Sentences" name="LgExceptionsSplitSentences" value="Mr.|Dr.|[A-Z].|Vd.|Vds." maxlength="500" size="60" /></td>
</tr>
<tr>
<td class="td1 right backlightyellow">RegExp Word Characters:</td>
<td class="td1">
<input type="text" class="notempty checkoutsidebmp" data_info="RegExp Word Characters" name="LgRegexpWordCharacters" value="a-zA-ZÀ-ÖØ-öø-ȳ" maxlength="500" size="60" /> <img src="icn/status-busy.png" title="Field must not be empty" alt="Field must not be empty" /></td>
</tr>
<tr>
<td class="td1 right backlightyellow">Make each character a word:</td>
<td class="td1"><select name="LgSplitEachChar">
<?php echo get_yesno_selectoptions(0); ?></select>
(e.g. for Chinese, Japanese, etc.)</td>
</tr>
<tr>
<td class="td1 right backlightyellow">Remove spaces:</td>
<td class="td1">
<select name="LgRemoveSpaces">
<?php echo get_yesno_selectoptions(0); ?>
</select>
(e.g. for Chinese, Japanese, etc.)</td>
</tr>
<tr>
<td class="td1 right backlightyellow">Right-To-Left Script:</td>
<td class="td1">
<select name="LgRightToLeft">
<?php echo get_yesno_selectoptions(0); ?>
</select>
(e.g. for Arabic, Hebrew, Farsi, Urdu, etc.)</td>
</tr>
<tr>
<td class="td1 right">
Export Template
<img class="click" src="icn/question-frame.png" title="Help" alt="Help" onclick="oewin('export_template.html');" /> :
</td>
<td class="td1">
<input type="text" class="checkoutsidebmp" data_info="Export Template" name="LgExportTemplate" value="$y\t$t\n" maxlength="1000" size="60" />
</td>
</tr>
<tr>
<td class="td1 right" colspan="2">
<input type="button" value="Cancel" onclick="{resetDirty(); location.href='edit_languages.php';}" />
<input type="submit" name="op" value="Save" /></td>
</tr>
</table>
<p class="smallgray">
<b>Important:</b>
<br />
The placeholders "••" for the from/sl and dest/tl language codes in the
URIs must be <b>replaced</b> by the actual source and target language
codes!<br />
<a href="docs/info.html#howtolang" read the documentation</a>.
Languages with a <b>non-Latin alphabet need special attention</b>,
<a href="docs/info.html#langsetup" also here</a>.
</p>
</form>
<?php
}
/**
* Display a form to edit an existing language.
*
* @param {int} $lid Language ID
*
* @return void
*/
function edit_languages_change($lid)
{
global $tbpref;
$sql = 'select * from ' . $tbpref . 'languages where LgID = ' . $lid;
$res = do_mysqli_query($sql);
if ($record = mysqli_fetch_assoc($res)) {
?>
<h4>Edit Language
<a href="docs/info.html#howtolang">
<img src="icn/question-frame.png" title="Help" alt="Help" /></a>
</h4>
<script type="text/javascript" charset="utf-8">
$(document).ready(ask_before_exiting);
</script>
<form class="validate" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" onsubmit="return check_dupl_lang(<?php echo $lid; ?>);">
<input type="hidden" name="LgID" value="<?php echo $lid; ?>" />
<table class="tab1" cellspacing="0" cellpadding="5">
<tr>
<td class="td1 right">Study Language "L2":</td>
<td class="td1">
<input type="text" class="notempty setfocus checkoutsidebmp" data_info="Study Language" name="LgName" id="LgName" value="<?php echo tohtml($record['LgName']); ?>" maxlength="40" size="40" /> <img src="icn/status-busy.png" title="Field must not be empty" alt="Field must not be empty" /></td>
</tr>
<tr>
<td class="td1 right">Dictionary 1 URI:</td>
<td class="td1">
<input type="text" class="notempty checkdicturl checkoutsidebmp" name="LgDict1URI" value="<?php echo tohtml($record['LgDict1URI']); ?>" maxlength="200" size="60" data_info="Dictionary 1 URI" /> <img src="icn/status-busy.png" title="Field must not be empty" alt="Field must not be empty" /></td>
</tr>
<tr>
<td class="td1 right">Dictionary 2 URI:</td>
<td class="td1">
<input type="text" class="checkdicturl checkoutsidebmp" name="LgDict2URI" value="<?php echo tohtml($record['LgDict2URI']); ?>" maxlength="200" size="60" data_info="Dictionary 2 URI" /></td>
</tr>
<tr>
<td class="td1 right">GoogleTranslate URI:</td>
<td class="td1">
<input type="text" class="checkdicturl checkoutsidebmp" name="LgGoogleTranslateURI" value="<?php echo tohtml($record['LgGoogleTranslateURI']); ?>" maxlength="200" size="60" data_info="GoogleTranslate URI" /></td>
</tr>
<tr>
<td class="td1 right">Text Size:</td>
<td class="td1">
<select name="LgTextSize"><?php echo get_languagessize_selectoptions($record['LgTextSize']); ?></select></td>
</tr>
<tr>
<td class="td1 right">Character Substitutions:</td>
<td class="td1">
<input type="text" class="checkoutsidebmp" data_info="Character Substitutions" name="LgCharacterSubstitutions" value="<?php echo tohtml($record['LgCharacterSubstitutions']); ?>" maxlength="500" size="60" /></td>
</tr>
<tr>
<td class="td1 right">RegExp Split Sentences:</td>
<td class="td1">
<input type="text" class="notempty checkoutsidebmp" name="LgRegexpSplitSentences" value="<?php echo tohtml($record['LgRegexpSplitSentences']); ?>" maxlength="500" size="60" data_info="RegExp Split Sentences" /> <img src="icn/status-busy.png" title="Field must not be empty" alt="Field must not be empty" /></td>
</tr>
<tr>
<td class="td1 right">Exceptions Split Sentences:</td>
<td class="td1">
<input type="text" class="checkoutsidebmp" data_info="Exceptions Split Sentences" name="LgExceptionsSplitSentences" value="<?php echo tohtml($record['LgExceptionsSplitSentences']); ?>" maxlength="500" size="60" /></td>
</tr>
<tr>
<td class="td1 right">RegExp Word Characters:</td>
<td class="td1">
<input type="text" class="notempty checkoutsidebmp" data_info="RegExp Word Characters" name="LgRegexpWordCharacters" value="<?php echo tohtml($record['LgRegexpWordCharacters']); ?>" maxlength="500" size="60" /> <img src="icn/status-busy.png" title="Field must not be empty" alt="Field must not be empty" /></td>
</tr>
<tr>
<td class="td1 right">Make each character a word:</td>
<td class="td1">
<select name="LgSplitEachChar">
<?php echo get_yesno_selectoptions($record['LgSplitEachChar']); ?>
</select>
(e.g. for Chinese, Japanese, etc.)</td>
</tr>
<tr>
<td class="td1 right">Remove spaces:</td>
<td class="td1">
<select name="LgRemoveSpaces">
<?php echo get_yesno_selectoptions($record['LgRemoveSpaces']); ?>
</select>
(e.g. for Chinese, Japanese, etc.)</td>
</tr>
<tr>
<td class="td1 right">Right-To-Left Script:</td>
<td class="td1">
<select name="LgRightToLeft">
<?php echo get_yesno_selectoptions($record['LgRightToLeft']); ?>
</select>
(e.g. for Arabic, Hebrew, Farsi, Urdu, etc.)</td>
</tr>
<tr>
<td class="td1 right">
Export Template
<img class="click" src="icn/question-frame.png" title="Help" alt="Help" onclick="oewin('export_template.html');" /> :
</td>
<td class="td1">
<input type="text" class="checkoutsidebmp" data_info="Export Template" name="LgExportTemplate" value="<?php echo tohtml($record['LgExportTemplate']); ?>" maxlength="1000" size="60" />
</td>
</tr>
<tr>
<td class="td1 right" colspan="2">
<input type="button" value="Cancel" onclick="{resetDirty(); location.href='edit_languages.php';}" />
<input type="submit" name="op" value="Change" /></td>
</tr>
</table>
<p class="smallgray">
<b>Warning:</b> Changing certain language settings
(e.g. RegExp Word Characters, etc.)<br />may cause partial or complete loss
of improved annotated texts!
</p>
</form>
<?php
}
mysqli_free_result($res);
}
/**
* Display the standard page of saved languages.
*
* @param {string} $message An information message to display.
*
* @global {string} $tbpref Database table prefix
* @global {int} $debug 1 to display debugging data
*
* @return void
*/
function edit_languages_display($message)
{
global $tbpref, $debug;
echo error_message_with_hide($message, 0);
$current = (int) getSetting('currentlanguage');
$recno = get_first_value(
'SELECT COUNT(*) AS value
FROM ' . $tbpref . 'languages
WHERE LgName<>""'
);
?>
<p>
<a href="<?php echo $_SERVER['PHP_SELF']; ?>?new=1">
<img src="icn/plus-button.png" title="New" alt="New" /> New Language ...
</a>
</p>
<?php
if ($recno==0) {
?>
<p>No languages found.</p>
<?php
return;
}
?>
<table class="sortable tab1" cellspacing="0" cellpadding="5">
<tr>
<th class="th1 sorttable_nosort">Curr.<br />Lang.</th>
<th class="th1 sorttable_nosort">Test<br />↓↓↓</th>
<th class="th1 sorttable_nosort">Actions</th>
<th class="th1 clickable">Language</th>
<th class="th1 sorttable_numeric clickable">Texts,<br />Reparse</th>
<th class="th1 sorttable_numeric clickable">Arch.<br />Texts</th>
<th class="th1 sorttable_numeric clickable">Newsfeeds<br />(Articles)</th>
<th class="th1 sorttable_numeric clickable">Terms</th>
<th class="th1 sorttable_nosort">Export<br />Template?</th>
</tr>
<?php
$sql = 'SELECT LgID, LgName, LgExportTemplate
FROM ' . $tbpref . 'languages
WHERE LgName<>"" ORDER BY LgName';
if ($debug) {
echo $sql;
}
// May be refactored with KISS principle
$res = do_mysqli_query(
'select NfLgID, count(*) as value
from ' . $tbpref . 'newsfeeds
group by NfLgID'
);
$newsfeedcount = null;
while ($record = mysqli_fetch_assoc($res)) {
$newsfeedcount[$record['NfLgID']] = $record['value'];
}
// May be refactored with KISS principle
$res = do_mysqli_query(
'SELECT NfLgID, count(*) AS value
FROM ' . $tbpref . 'newsfeeds, ' . $tbpref . 'feedlinks
WHERE NfID=FlNfID
GROUP BY NfLgID'
);
$feedarticlescount = null;
while ($record = mysqli_fetch_assoc($res)) {
$feedarticlescount[$record['NfLgID']] = $record['value'];
}
$res = do_mysqli_query($sql);
while ($record = mysqli_fetch_assoc($res)) {
$lid = (int)$record['LgID'];
$foo = get_first_value(
'select count(TxID) as value
from ' . $tbpref . 'texts
where TxLgID=' . $lid
);
$textcount = is_numeric($foo) ? (int)$foo : 0;
$foo = get_first_value(
'select count(AtID) as value
from ' . $tbpref . 'archivedtexts
where AtLgID=' . $lid
);
$archtextcount = is_numeric($foo) ? (int)$foo : 0;
$foo = get_first_value(
'select count(WoID) as value
from ' . $tbpref . 'words
where WoLgID=' . $lid
);
$wordcount = is_numeric($foo) ? (int)$foo : 0;
if (is_null($newsfeedcount) || empty($newsfeedcount)) {
$nfcount = 0;
} else if (isset($newsfeedcount[$lid])) {
$nfcount = (int)$newsfeedcount[$lid];
} else {
$nfcount = 0;
}
if (is_null($feedarticlescount) || empty($feedarticlescount)) {
$fartcount = 0;
} else if (isset($feedarticlescount[$lid])) {
$fartcount = (int)$feedarticlescount[$lid];
} else {
$fartcount = 0;
}
echo '<tr>';
if ($current == $lid) {
$tdth = 'th';
echo '<th class="th1" style="border-top-left-radius:0;">
<img src="icn/exclamation-red.png" title="Current Language" alt="Current Language" />
</th>';
} else {
$tdth = 'td';
echo '<td class="td1 center">
<a href="save_setting_redirect.php?k=currentlanguage&v=' . $lid . '&u=edit_languages.php">
<img src="icn/tick-button.png" title="Set as Current Language" alt="Set as Current Language" />
</a>
</td>';
}
echo '<' . $tdth . ' class="' . $tdth . '1 center"><a href="do_test.php?lang=' . $lid . '">
<img src="icn/question-balloon.png" title="Test" alt="Test" /></a></' . $tdth . '>';
echo '<' . $tdth . ' class="' . $tdth . '1 center" nowrap="nowrap"> <a href="' . $_SERVER['PHP_SELF'] . '?chg=' . $lid . '">
<img src="icn/document--pencil.png" title="Edit" alt="Edit" /></a>';
if ($textcount == 0 && $archtextcount == 0 && $wordcount == 0 && $nfcount == 0) {
echo ' <span class="click" onclick="if (confirmDelete()) location.href=\'' . $_SERVER['PHP_SELF'] . '?del=' . $lid . '\';">
<img src="icn/minus-button.png" title="Delete" alt="Delete" /></span>';
} else {
echo ' <img src="icn/placeholder.png" title="Delete not possible" alt="Delete not possible" />';
}
echo ' </' . $tdth . '>';
echo '<' . $tdth . ' class="' . $tdth . '1 center">' . tohtml((string)$record['LgName']) . '</' . $tdth . '>';
if ($textcount > 0) {
echo '<' . $tdth . ' class="' . $tdth . '1 center">
<a href="edit_texts.php?page=1&query=&filterlang=' . $lid . '">' .
$textcount . '</a> <a href="' . $_SERVER['PHP_SELF'] . '?refresh=' . $lid . '">
<img src="icn/lightning.png" title="Reparse Texts" alt="Reparse Texts" /></a>';
} else {
echo '<' . $tdth . ' class="' . $tdth . '1 center">0 <img src="';
print_file_path('icn/placeholder.png');
echo'" title="No texts to reparse" alt="No texts to reparse" />';
}
echo '</' . $tdth . '>';
echo '<' . $tdth . ' class="' . $tdth . '1 center">' .
($archtextcount > 0 ? '<a href="edit_archivedtexts.php?page=1&query=&filterlang=' . $lid . '">' .
$archtextcount . '</a>' : '0' ) . '</' . $tdth . '>';
echo '<' . $tdth . ' class="' . $tdth . '1 center">' .
($nfcount > 0 ? '<a href="do_feeds.php?query=&selected_feed=&check_autoupdate=1&filterlang=' . $lid . '">' .
$nfcount . ' (' . $fartcount . ')</a>' : '0' ) . '</' . $tdth . '>';
echo '<' . $tdth . ' class="' . $tdth . '1 center">' .
($wordcount > 0 ? '<a href="edit_words.php?page=1&query=&text=&status=&filterlang=' .
$lid . '&status=&tag12=0&tag2=&tag1=">' . $wordcount . '</a>' : '0' ) . '</' . $tdth . '>';
echo '<' . $tdth . ' class="' . $tdth . '1 center" style="border-top-right-radius:0;">' .
(isset($record['LgExportTemplate']) ? '<img src="icn/status.png" title="Yes" alt="Yes" />' :
'<img src="icn/status-busy.png" title="No" alt="No" />' ) . '</' . $tdth . '>';
echo '</tr>';
}
mysqli_free_result($res);
?>
</table>
<?php
}
/**
* Display a variation of the edit_language page.
*
* @return void
*/
function edit_languages_do_page()
{
pagestart('My Languages', true);
edit_languages_alert_duplicate();
$message = '';
if (isset($_REQUEST['refresh'])) {
$message = edit_languages_refresh($_REQUEST['refresh']);
}
if (isset($_REQUEST['del'])) {
$message = edit_languages_delete((int)$_REQUEST['del']);
} elseif (isset($_REQUEST['op'])) {
// Insert new text or change an existing one
if ($_REQUEST['op'] == 'Save') {
// INSERT
$message = edit_languages_op_save();
} elseif ($_REQUEST['op'] == 'Change') {
// UPDATE
$message = edit_languages_op_change((int)$_REQUEST["LgID"]);
}
}
// Display part
if (isset($_REQUEST['new'])) {
edit_languages_new();
} elseif (isset($_REQUEST['chg'])) {
edit_languages_change((int)$_REQUEST['chg']);
} else {
edit_languages_display($message);
}
pageend();
}
edit_languages_do_page();
?>