forked from chaosarium/lwt
-
Notifications
You must be signed in to change notification settings - Fork 20
/
set_word_on_hover.php
94 lines (80 loc) · 2.63 KB
/
set_word_on_hover.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
<?php
/**
* PHP version 8.1
*
* @category Helper_Frame
* @package Lwt
*/
use Lwt\Classes\GoogleTranslate;
require_once 'inc/session_utility.php';
require_once 'inc/classes/GoogleTranslate.php' ;
$translation = '*';
if ($_REQUEST['status']==1) {
$tl = $_GET["tl"];
$sl = $_GET["sl"];
$text = $_GET["text"];
$tl_array = GoogleTranslate::staticTranslate($text, $sl, $tl);
if ($tl_array) {
$translation = $tl_array[0];
}
if ($translation == $_GET["text"]) {
$translation = '*';
}
header('Pragma: no-cache');
header('Expires: 0');
}
$word = convert_string_to_sqlsyntax($_REQUEST['text']);
$wordlc = convert_string_to_sqlsyntax(mb_strtolower($_REQUEST['text'], 'UTF-8'));
$langid = get_first_value(
"SELECT TxLgID AS value FROM {$tbpref}texts WHERE TxID = " .
$_REQUEST['tid']
);
runsql(
"INSERT INTO {$tbpref}words (
WoLgID, WoTextLC, WoText, WoStatus, WoTranslation, WoSentence,
WoRomanization, WoStatusChanged," .
make_score_random_insert_update('iv') . ") values(
$langid, $wordlc, $word, " . $_REQUEST["status"] . ', ' .
convert_string_to_sqlsyntax($translation) . ', "", "", NOW(), ' .
make_score_random_insert_update('id') . '
)',
"Term saved"
);
$wid = get_last_key();
do_mysqli_query(
"UPDATE {$tbpref}textitems2 SET Ti2WoID = $wid
WHERE Ti2LgID = $langid AND LOWER(Ti2Text) = $wordlc"
);
$hex = strToClassName(
prepare_textdata(mb_strtolower($_REQUEST['text'], 'UTF-8'))
);
pagestart("New Term: " . $word, false);
echo '<p>Status: ' . get_colored_status_msg($_REQUEST['status']) . '</p><br />';
if ($translation != '*') {
echo '<p>Translation: <b>' . tohtml($translation) . '</b></p>';
}
?>
<script type="text/javascript">
const context = window.parent.document;
let title = '';
if (window.parent.LWT_DATA.settings.jQuery_tooltip)
title = make_tooltip(
<?php echo prepare_textdata_js($_REQUEST['text']); ?>,
<?php echo prepare_textdata_js($translation); ?>,
'',
'<?php echo $_REQUEST["status"]; ?>'
);
$('.TERM<?php echo $hex; ?>', context)
.removeClass('status0')
.addClass('status<?php echo $_REQUEST["status"]; ?> word<?php echo $wid; ?>')
.attr('data_status', '<?php echo $_REQUEST["status"]; ?>')
.attr('data_wid', '<?php echo $wid; ?>')
.attr('title', title)
.attr('data_trans','<?php echo tohtml($translation); ?>');
$('#learnstatus', context)
.html('<?php echo addslashes(todo_words_content((int) $_REQUEST['tid'])); ?>');
cleanupRightFrames();
</script>
<?php
pageend();
?>