|
| 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 | +?> |
0 commit comments