Skip to content

Commit 09913be

Browse files
committed
v1.6.1 new: show translations in read screen, bulk import new terms in read screen
1 parent ddcfa5c commit 09913be

22 files changed

Lines changed: 264 additions & 44 deletions

‎all_words_wellknown.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
var context = window.parent.frames['l'].document;
8585
var contexth = window.parent.frames['h'].document;
8686
<?php echo $javascript; ?>
87-
$('#learnstatus', contexth).html('<?php echo texttodocount2($_REQUEST['text']); ?>');
87+
$('#learnstatus', contexth).html('<?php echo addslashes(texttodocount2($_REQUEST['text'])); ?>');
8888
window.parent.frames['l'].setTimeout('cClick()', 1000);
8989
//]]>
9090
</script>

‎bulk_translate_words.php‎

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?php
2+
3+
require_once( 'settings.inc.php' );
4+
require_once( 'connect.inc.php' );
5+
require_once( 'dbutils.inc.php' );
6+
require_once( 'utilities.inc.php' );
7+
8+
$tid=$_REQUEST['tid'];
9+
if(isset ($_REQUEST["lastpos"]))$pos = $_REQUEST["lastpos"];
10+
if (isset($_REQUEST['term'])) {
11+
$cnt=0;
12+
$sqltext='insert into ' . $tbpref . 'words (WoLgID, WoTextLC, WoText, ' .
13+
'WoStatus, WoTranslation, WoSentence, WoRomanization, WoStatusChanged,' . make_score_random_insert_update('iv') . ') values ';
14+
$sqlarr=array();
15+
foreach($_REQUEST['term'] as $row){
16+
$sqlarr[]= '(' . convert_string_to_sqlsyntax($row['lg']) . ',' . convert_string_to_sqlsyntax(mb_strtolower($row['text'], 'UTF-8')) . ',' . convert_string_to_sqlsyntax($row['text']) . ',' . convert_string_to_sqlsyntax($row['status']) . ',' . (($row['trans']=='')?'"*"': convert_string_to_sqlsyntax($row['trans'])) . ', "", ""' . ', NOW(), ' . make_score_random_insert_update('id') . ')';
17+
$cnt++;
18+
}
19+
$sqltext .= rtrim(implode(',', $sqlarr),',');
20+
$max = get_first_value('select max(WoID) as value from ' . $tbpref . 'words');
21+
runsql($sqltext,'');
22+
pagestart($cnt . ' New Word' . ($cnt!=1?'s':'') . ' Saved',false);
23+
echo '<p id="displ_message">Updating Texts</p>';
24+
flush();
25+
$res = do_mysql_query('select WoID, WoTextLC, WoStatus, WoTranslation from ' . $tbpref . 'words where WoID > ' . $max);
26+
echo '<script type="text/javascript">var context = window.parent.frames[\'l\'].document;';
27+
while($record = mysql_fetch_assoc($res)){
28+
$hex = strToClassName(prepare_textdata($record["WoTextLC"]));
29+
echo '$(".TERM',$hex,'",context).removeClass("status0").addClass("status',$record["WoStatus"],'").attr("data_wid","',$record["WoID"],'").attr("data_status","',$record["WoStatus"],'").attr("data_trans",',prepare_textdata_js($record["WoTranslation"]),').each(function(){this.title = make_tooltip($(this).text(), $(this).attr(\'data_trans\'), $(this).attr(\'data_rom\'), $(this).attr(\'data_status\'));});';
30+
}
31+
echo "</script>";
32+
flush();
33+
do_mysql_query('UPDATE ' . $tbpref . 'textitems2 join ' . $tbpref . 'words on lower(Ti2Text)=WoTextLC AND Ti2WordCount =1 and Ti2LgID=WoLgID and WoID > ' . $max . ' set Ti2WoID = WoID');
34+
echo "<script type=\"text/javascript\">$('#learnstatus', window.parent.frames['h'].document).html('",addslashes(texttodocount2($tid)),"');$('#displ_message').remove();</script>";
35+
flush();
36+
}
37+
else {
38+
pagestart_nobody('Translate New Words');
39+
}
40+
if(isset($pos)){
41+
$sl=$_REQUEST["sl"];
42+
$tl=$_REQUEST["tl"];
43+
$cnt = 0;
44+
$lastpos = '';
45+
$limit = getSettingWithDefault('set-ggl-translation-per-page') + 1;
46+
?>
47+
<style>
48+
body {top:0px ! important;}
49+
td.td1{vertical-align:middle ! important;}
50+
</style>
51+
52+
<script type="text/javascript">
53+
$('h3,h4,title').addClass('notranslate');
54+
$(window).load(function() {
55+
var myVar = setInterval(function(){
56+
if( $( ".trans>font" ).length == $( ".trans" ).length){
57+
$('.trans').each(function() {
58+
var txt=$(this).text().toLowerCase();
59+
var cnt= $(this).attr('id').replace('Trans_', '');
60+
$(this).addClass('notranslate').html('<input type="text" name="term[' + cnt + '][trans]" value="' + txt + '" maxlength="100" size="35"></input>');
61+
});
62+
$('iframe,#google_translate_element').remove();
63+
selectToggle(true,'form1');
64+
$('[name^=term]').prop('disabled', false);
65+
clearInterval(myVar);
66+
}
67+
}, 300);
68+
});
69+
$(document).ready( function() {
70+
$('input[type="checkbox"]').change(function(){
71+
var v = parseInt($(this).val());
72+
var e = '[name=term\\[' + v + '\\]\\[text\\]],[name=term\\[' + v + '\\]\\[lg\\]],[name=term\\[' + v + '\\]\\[status\\]],[name=term\\[' + v + '\\]\\[trans\\]]';
73+
if(this.checked){
74+
$(e).prop('disabled', false);
75+
if($('input[type="checkbox"]:checked').length){$('input[type="submit"]').val('Save');}
76+
}
77+
else{
78+
$(e).prop('disabled', true);
79+
if(!$('input[type="checkbox"]:checked').length){if(!$('input[name="lastpos"]').length)v='End';else v='Next';$('input[type="submit"]').val(v);}
80+
}
81+
});
82+
});
83+
function googleTranslateElementInit() {
84+
new google.translate.TranslateElement({pageLanguage: '<?php echo $sl; ?>', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, includedLanguages: '<?php echo $tl; ?>', autoDisplay: false}, 'google_translate_element');
85+
}
86+
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
87+
<?php
88+
echo '<form name="form1" action="', $_SERVER['PHP_SELF'], '" method="post"><span class="notranslate"><div id="google_translate_element"></div><table class="tab3" cellspacing="0"><tr class="notranslate"><th class="th1 center" colspan="3"><input type="button" value="Mark All" onclick="$(\'input[type^=submit]\').val(\'Save\');selectToggle(true,\'form1\');$(\'[name^=term]\').prop(\'disabled\', false);" />
89+
<input type="button" value="Mark None" onclick="if(!$(\'input[name^=lastpos]\').length)v=\'End\';else v=\'Next\';$(\'input[type^=submit]\').val(v);selectToggle(false,\'form1\');$(\'[name^=term]\').prop(\'disabled\', true);" /><br /></th></tr><tr class="notranslate"><td class="td1">
90+
Marked Terms: </td><td class="td1">
91+
<select onchange="v=$(this).val();if(v==6){$(\'.markcheck:checked\').each(function(){e=$(\'#Term_\' + $(this).val());e.text(e.text().toLowerCase());$(\'#Text_\' + $(this).val()).val(e.text().toLowerCase());});$(this).prop(\'selectedIndex\',0);return false;}if(v==7){$(\'.markcheck:checked\').each(function(){$(\'#Trans_\' + $(this).val() + \' input\').val(\'*\');});$(this).prop(\'selectedIndex\',0);return false;}$(\'.markcheck:checked\').each(function(){$(\'#Stat_\' + $(this).val()).val(v);});$(this).prop(\'selectedIndex\',0);return false;"><option value="0" selected="selected">[Choose...]</option><option value="1">Set Status To [1]</option><option value="2">Set Status To [2]</option><option value="3">Set Status To [3]</option><option value="4">Set Status To [4]</option><option value="5">Set Status To [5]</option><option value="99">Set Status To [WKn]</option><option value="98">Set Status To [Ign]</option><option value="6">Set To Lowercase</option><option value="7">Delete Translation</option></select></td><td class="td1" style="min-width: 45px;"><input type="submit" value="Save" /></td></tr></table></span>
92+
<table class="tab3" cellspacing="0"><tr class="notranslate"><th class="th1">Mark</th><th class="th1">Term</th><th class="th1">Translation</th><th class="th1">Status</th></tr>';
93+
94+
$res = do_mysql_query ('select Ti2Text as word,Ti2LgID,Ti2Order from ' . $tbpref . 'textitems2 where Ti2WoID = 0 and Ti2TxID = ' . $tid . ' AND Ti2WordCount =1 and Ti2Order > ' . $pos . ' group by LOWER(Ti2Text) order by Ti2Order limit ' . $limit);
95+
while($record = mysql_fetch_assoc($res)){
96+
if(++$cnt<$limit){
97+
$value=tohtml($record['word']);
98+
echo '<tr><td class="td1 center notranslate"><input name="marked[', $cnt ,']" type="checkbox" class="markcheck" checked="checked" value="', $cnt , '" /></td><td id="Term_', $cnt ,'" class="td1 left notranslate">',$value,'</td><td class="td1 right trans" id="Trans_', $cnt ,'">',$value,'</td><td class="td1 center notranslate"><select id="Stat_', $cnt ,'" name="term[', $cnt ,'][status]"><option value="1" selected="selected">[1]</option><option value="2">[2]</option><option value="3">[3]</option><option value="4">[4]</option><option value="5">[5]</option><option value="99">[WKn]</option><option value="98">[Ign]</option></select><input type="hidden" id="Text_', $cnt ,'" name="term[', $cnt ,'][text]" value="',$value,'" /><input type="hidden" name="term[', $cnt ,'][lg]" value="',tohtml($record['Ti2LgID']),'" /></td></tr>';
99+
}
100+
else $lastpos='<input type="hidden" name="lastpos" value="' . ($record['Ti2Order'] - 1) . '" /><input type="hidden" name="sl" value="' . $sl . '" /><input type="hidden" name="tl" value="' . $tl . '" />';
101+
}
102+
103+
echo '</table><input type="hidden" name="tid" value="',$tid,'" />', $lastpos ,'</form>';
104+
}
105+
pageend();
106+
?>

‎delete_mword.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
?>
7575

7676
});
77-
$('#learnstatus', contexth).html('<?php echo texttodocount2($tid); ?>');
77+
$('#learnstatus', contexth).html('<?php echo addslashes(texttodocount2($tid)); ?>');
7878
window.parent.frames['l'].focus();
7979
window.parent.frames['l'].setTimeout('cClick()', 100);
8080
//]]>

‎delete_word.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
var contexth = window.parent.frames['h'].document;
5757
var title = make_tooltip(<?php echo prepare_textdata_js($term); ?>,'','','');
5858
$('.word<?php echo $wid; ?>', context).removeClass('status99 status98 status1 status2 status3 status4 status5 word<?php echo $wid; ?>').addClass('status0').attr('data_status','0').attr('data_trans','').attr('data_rom','').attr('data_wid','').attr('title',title);
59-
$('#learnstatus', contexth).html('<?php echo texttodocount2($tid); ?>');
59+
$('#learnstatus', contexth).html('<?php echo addslashes(texttodocount2($tid)); ?>');
6060
window.parent.frames['l'].focus();
6161
window.parent.frames['l'].setTimeout('cClick()', 100);
6262
//]]>
@@ -65,4 +65,4 @@
6565

6666
pageend();
6767

68-
?>
68+
?>

‎do_feeds.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
$(document).scrollTo($('table').eq(0));
182182
});
183183
$('input[type="checkbox"]').change(function(){
184-
var feed = '[name^=feed\\['+ $(this).val() +'\\]'
184+
var feed = '[name^=feed\\['+ $(this).val() +'\\]';
185185
if(this.checked){
186186
$(feed+']').prop('disabled', false);
187187
$(feed+'\\[TxTitle\\]],'+feed+'\\[TxText\\]]').addClass("notempty");

‎do_text_text.php‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,17 @@
116116
});
117117
</script>
118118
<?php
119-
119+
$data_trans=$ann_exists?'data_ann':'data_trans';
120+
$displaystattrans=getSettingWithDefault('set-display-text-frame-term-translation');
121+
echo '<style>';
122+
if(checkStatusRange(1, $displaystattrans))echo '.wsty.status1:after{content: " " attr(' . $data_trans . ');}';
123+
if(checkStatusRange(2, $displaystattrans))echo '.wsty.status2:after{content: " " attr(' . $data_trans . ');}';
124+
if(checkStatusRange(3, $displaystattrans))echo '.wsty.status3:after{content: " " attr(' . $data_trans . ');}';
125+
if(checkStatusRange(4, $displaystattrans))echo '.wsty.status4:after{content: " " attr(' . $data_trans . ');}';
126+
if(checkStatusRange(5, $displaystattrans))echo '.wsty.status5:after{content: " " attr(' . $data_trans . ');}';
127+
if(checkStatusRange(98, $displaystattrans))echo '.wsty.status98:after{content: " " attr(' . $data_trans . ');}';
128+
if(checkStatusRange(99, $displaystattrans))echo '.wsty.status99:after{content: " " attr(' . $data_trans . ');}';
129+
echo '.wsty:after{font-size:50%;}</style>';
120130
echo '<div id="thetext" ' . ($rtlScript ? 'dir="rtl"' : '') . '><p style="' . ($removeSpaces ? 'word-break:break-all;' : '') .
121131
'font-size:' . $textsize . '%;line-height: 1.4; margin-bottom: 10px;">';
122132

‎edit_mword.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
229229
} else {
230230
?>
231231
$('.word' + woid, context).attr('data_trans',trans).attr('data_rom',roman).attr('title',title).removeClass('status<?php echo $_REQUEST['WoOldStatus']; ?>').addClass('status' + status).attr('data_status',status);
232-
$('#learnstatus', contexth).html('<?php echo texttodocount2($_REQUEST['tid']); ?>');
232+
$('#learnstatus', contexth).html('<?php echo addslashes(texttodocount2($_REQUEST['tid'])); ?>');
233233
<?php
234234
}
235235
?>

‎edit_word.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
<?php
157157
}
158158
?>
159-
$('#learnstatus', contexth).html('<?php echo texttodocount2($_REQUEST['tid']); ?>');
159+
$('#learnstatus', contexth).html('<?php echo addslashes(texttodocount2($_REQUEST['tid'])); ?>');
160160
window.parent.frames['l'].focus();
161161
window.parent.frames['l'].setTimeout('cClick()', 100);
162162
<?php

‎icn/script-import.png‎

837 Bytes
Loading

‎insert_word_ignore.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
var contexth = window.parent.frames['h'].document;
6767
var title = make_tooltip(<?php echo prepare_textdata_js($word); ?>,'*','','98');
6868
$('.TERM<?php echo $hex; ?>', context).removeClass('status0').addClass('status98 word<?php echo $wid; ?>').attr('data_status','98').attr('data_wid','<?php echo $wid; ?>').attr('title',title);
69-
$('#learnstatus', contexth).html('<?php echo texttodocount2($_REQUEST['tid']); ?>');
69+
$('#learnstatus', contexth).html('<?php echo addslashes(texttodocount2($_REQUEST['tid'])); ?>');
7070
window.parent.frames['l'].focus();
7171
window.parent.frames['l'].setTimeout('cClick()', 100);
7272
//]]>

0 commit comments

Comments
 (0)