You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

495 lines
15 KiB

#!/usr/bin/perl
#
# $Id: Interpreter.pl,v 1.8 2006/01/23 21:39:30 ddoughty Exp $
#
# Source File: Interpreter.pl
# Get config
require 'sitecfg.pl';
require 'testlib.pl';
&app_initialize;
print "Content-Type: text/html\n\n";
if (&get_session($FORM{'tid'})) {
$FORM{'submit'} =~ s/\+/ /g;
if ($FORM{'submit'} eq 'Save Changes') {
$sNotice = "Translations updated";
&UpdateTranslation();
} elsif ($FORM{'submit'} eq 'printtable') {
&PrintPrintForm();
} elsif ($FORM{'submit'} eq 'printenglish') {
&PrintEnglishForm();
} else {
$sNotice = "";
&PrintForm();
}
}
sub PrintForm {
$nshref = ($SESSION{'browserapp'} eq MSIE) ? "" : "HREF=\"#top\"";
if ($SESSION{'uac'} =~ /txlatr./ ) {
$sPrintlink="";
$logoutbutton = "<BR><CENTER>
<FORM METHOD=POST ACTION=\"$PATHS{'cgiroot'}/logout.pl\"
Name=\"syncform\" TARGET=\"exit\">
<INPUT NAME=\"tid\" TYPE=HIDDEN VALUE=\"$SESSION{'tid'}\">
<INPUT NAME=\"csec\" TYPE=HIDDEN VALUE=\"$SYSTEM{'autologout'}\">
<INPUT NAME=\"idle\" TYPE=HIDDEN VALUE=\"N\">
<A $nshref
onMouseOver=\"document.logoff.src='$PATHS{'graphroot'}/btnlogouton.gif'\"
onMouseOut=\"document.logoff.src='$PATHS{'graphroot'}/btnlogoutoff.gif'\"
onClick=\"return log_out(document.syncform)\"
><IMG NAME=\"logoff\" SRC=\"$PATHS{'graphroot'}/btnlogoutoff.gif\" border=0 alt=\"Log Out\"></A>
</FORM>\n</CENTER>\n";
$logoutjscript = "
function log_out(objForm) {
var sURL;
sURL = \"$PATHS{'cgiroot'}/logout.pl?tid=$SESSION{'tid'}&idle=N\";
top.document.location.replace(sURL);
}\n";
} else {
$logoutbutton = "";
$logoutjscript = "";
$sPrintlink="<a href=\"$PATHS{'cgiroot'}/Interpreter.pl?tid=$SESSION{'tid'}&lang=$FORM{'lang'}&submit=printtable\" target=\"wdwprinttable\">Print-Translations</a>
<a href=\"$PATHS{'cgiroot'}/Interpreter.pl?tid=$SESSION{'tid'}&lang=$FORM{'lang'}&submit=printenglish\" target=\"wdwprinttable\">Print-English</a>";
}
$idEnglish = "enu";
@sEnglish = &get_phrases($idEnglish);
$txtEnglish = $LANGUAGE_ID{$idEnglish};
$idTranslation = $FORM{'lang'};
@sTranslation = &get_phrases($idTranslation);
$txtTranslation = $LANGUAGE_ID{$idTranslation};
$basefont="";
$fontface="";
$fontend = "";
if ($FORM{'lang'} eq 'arb') { $charset="iso-8859-6";}
elsif ($FORM{'lang'} eq 'cyr') {
$charset="iso-8859-5";
# $charset="koi8-r";
$basefont="<BASEFONT FACE=\"Verdana Cyr\">";
$fontface="<FONT FACE=\"Verdana Cyr\">";
$fontend = "</FONT>";
} else { $charset="iso-8859-1";}
$locator = "<center>\n";
$locator = join('', $locator, "<a href=\"\#x0\">\[-\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x54\">\[A\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x91\">\[B\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x103\">\[C\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x159\">\[D\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x183\">\[E\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x209\">\[F\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x220\">\[G\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x233\">\[H\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x240\">\[I\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x254\">\[JL\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x263\">\[M\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x279\">\[N\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x300\">\[O\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x310\">\[P\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x328\">\[Q\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x334\">\[R\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x356\">\[S\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x406\">\[T\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x440\">\[U\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x448\">\[V\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x453\">\[W\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x460\">\[Y\]\&nbsp\;</a> ");
$locator = join('', $locator, "<a href=\"\#x466\">\[+\]\&nbsp\;</a><BR>\n");
$locator = join('', $locator, "</center>\n");
$pad = "000";
for (0 .. $#sEnglish) {
$x = "$_";
$y = int(4 - length($x));
if ($y) {$x = join('', substr($pad,0,$y), $x);}
$locator = join('', $locator, "<a href=\"\#x$_\">\[$x\]\&nbsp\;</a> ");
}
print "<HTML>
<HEAD>
<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=$charset\">
<TITLE>Test-Central $txtEnglish-$txtTranslation Translation</TITLE>
$basefont
<SCRIPT language=\"JavaScript\">
<!--
var aEnglish,aSymbol,aMath,aMisc,aKeys,aCharSet;
bNSNG = ($SESSION{'browserapp'} =~ \"MSIE\") ? 0 : 1;
aEnglish=\"aeiouyAEIOUYaeiouyAEIOUYaeiouyAEIOUYaeiouyAEIOUYcnsCN!?\";
aSymbol =\" \";
aEnglish=\"aeiouyAEIOUYaeiouyAEIOUYaeiouyAEIOUYaeiouyAEIOUYcnsCN!?\";
aMath = \"0123+x. 0123o - Aau \";
aMisc = \"rcsp \";
aSymbol =\" \";
function tGotFocus(oTxt) {
oSelTxt = oTxt;
return true;
}
function langselect(oSelLang) {
var oCtrl,i,j,k,sChar,x,sBlank;
sBlank = \" \";
if (oSelLang.selectedIndex == 1) {
aKeys=\"'`^:~+\";
aCharSet = aEnglish;
sBlank = \"French\";
aSymbol= \" � � \";
aSymbol+=\"�� � �� � \";
aSymbol+=\"����� ����� \";
aSymbol+=\" �� � �� � \";
aSymbol+=\"� � \";
} else { if (oSelLang.selectedIndex == 2) {
aKeys=\"'`^:~+\";
aCharSet = aEnglish;
sBlank = \"German\";
aSymbol= \" \";
aSymbol+=\" \";
aSymbol+=\" \";
aSymbol+=\"� �� � � \";
aSymbol+=\" � \";
} else { if (oSelLang.selectedIndex == 3) {
aKeys=\"'`^:~+\";
aCharSet = aEnglish;
sBlank = \"Spanish\";
aSymbol= \"������������\";
aSymbol+=\" \";
aSymbol+=\" \";
aSymbol+=\" � � \";
aSymbol+=\" � ѡ�\";
} else { if (oSelLang.selectedIndex == 4) {
aKeys=\"'/:^\";
aCharSet = aMath;
sBlank = \"Math\";
aSymbol= \"�����׷ \";
aSymbol+=\"ؼ��� \";
aSymbol+=\"� \";
aSymbol+=\"��� \";
aSymbol+=\" \";
} else { if (oSelLang.selectedIndex == 5) {
aKeys=\"^\";
aCharSet = aMisc;
sBlank = \"Misc\";
aSymbol= \"���� \";
aSymbol+=\" \";
aSymbol+=\" \";
aSymbol+=\" \";
aSymbol+=\" \";
} else {
sBlank = \"\";
aKeys=\"\";
aCharSet = \"\";
}}}}}
return true;
}
function languagesupport(oTxt) {
var ostart,oText,schar,iidx,siidx;
if (bNSNG) { return true;}
oText = oTxt.value;
ostart=oText.length-1;
if (ostart > -1) {
iidx=aKeys.indexOf(oText.charAt(ostart));
if (iidx == 5) {iidx = 4};
if (iidx != -1) {
ostart--;
schar=oText.charAt(ostart);
siidx=iidx*12;
iidx=aCharSet.indexOf(schar,siidx);
if (iidx != -1) {
if (aSymbol.charAt(iidx) != \" \") {
oTxt.value=oText.substring(0,ostart)+aSymbol.charAt(iidx);
}
}
}
}
return true;
}
function onConvert(oTxt) {
var ostart,oText,schar,schar2,iidx,siidx,oOutput,oend;
oText = oTxt.value;
oOutput = oText.charAt(0);
for (ostart=1; ostart<=oText.length-1;ostart++) {
schar2=oText.charAt(ostart);
iidx=aKeys.indexOf(schar2);
if (iidx == 5) {iidx = 4};
if (iidx == -1) {
oOutput += schar2;
} else {
oend=ostart-1;
schar=oText.charAt(oend);
siidx=iidx*12;
iidx=aCharSet.indexOf(schar,siidx);
if (iidx == -1) {
oOutput += schar2;
} else {
if (aSymbol.charAt(iidx) != \" \") {
oend=oOutput.length-1;
oOutput = oOutput.substring(0,oend)+aSymbol.charAt(iidx);
} else {
oOutput += schar2;
}
}
}
}
oTxt.value=oOutput;
return true;
}
function onWdwLoad() {
if (\"$idTranslation\" == \"fr\") {
document.form1.languageext.selectedIndex = 1;
} else {
if (\"$idTranslation\" == \"sp\") {
document.form1.languageext.selectedIndex = 3;
} else {
if (\"$idTranslation\" == \"deu\") {
document.form1.languageext.selectedIndex = 2;
} else {
document.form1.languageext.selectedIndex = 0;
}
}
}
langselect(document.form1.languageext);
return true;
}
$logoutjscript
window.onload=onWdwLoad;
//-->
</SCRIPT>
</HEAD>
<BODY BGCOLOR=\"\#FFFFFF\" TEXT=\"\#000000\" LINK=\"\#0000FF\" VLINK=\"\#800080\">
<FORM METHOD=POST NAME=\"form1\">
<input type=\"hidden\" name=\"tid\" value=\"$SESSION{'tid'}\">
<input type=\"hidden\" name=\"lang\" value=\"$idTranslation\">
<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\" width=100\%>
<tr>
<td colspan=2><IMG SRC=\"$PATHS{'graphroot'}/logo.gif\" WIDTH=160 BORDER=0></td>
<td align=center><FONT SIZE=4><b>Test-Central $txtEnglish-$txtTranslation Phrase Translations</b></FONT></td>
</tr>
<tr>
<td align=left><font size=1 color=\"green\">$sPrintlink\&nbsp\;</font></td>
<td colspan=2 align=right><font size=1 color=\"green\">$sNotice\&nbsp\;</font></td>
</tr>
<TR>
<td colspan=3 align=left valign=top nowrap>
<FONT SIZE=2 COLOR=\"#FF0000\">
<a name=\"langspt\">SYMBOL MODE:&nbsp;</a>
<SELECT name=\"languageext\" onChange=\"return langselect(this)\">
<OPTION value=\"enu\">ENGLISH
<OPTION value=\"fr\">FRENCH
<OPTION value=\"deu\">GERMAN
<OPTION value=\"sp\">SPANISH
<OPTION value=\"math\">Math/Scientific
<OPTION value=\"misc\">Miscellaneous
</SELECT>&nbsp;&nbsp;(to return here, click the symbol link)
&nbsp;&nbsp;(to goto logout, click <a href=\"\#bottom\">end</a>)
</FONT>
</td>
</TR>
<tr>
<td colspan=3><font size=2>$locator</font></td>
</tr>
<tr>
<td width=100><b>Text ID</b></td>
<td colspan=2><b>$txtEnglish<BR>
$txtTranslation</b></td>
</tr>
";
for (0 .. $#sEnglish) {
$sconv = $sTranslation[$_];
chop ($sconv);
$sconv =~ s/\&amp\;/\&/g;
$sconv =~ s/<BR>/\r\n/g;
$rows=1;
$cols=length($sEnglish[$_]);
$size=length($sEnglish[$_]);
if ($cols < 20) {
$cols = 30;
$inputtype = "<input type=text name=\"x$_\" size=60 maxlength=$cols value=\"$sconv\" onKeyPress=\"languagesupport(this)\" onFocus=\"return tGotFocus(this)\" onBlur=\"return onConvert(this)\">";
} else {
if ($cols > 19) {$cols = 60};
$rows = int($size / 25);
if ($rows < 2) { $rows = 2;}
if ($rows > 5) { $rows = 5;}
$inputtype = "<textarea name=\"x$_\" rows=$rows cols=$cols onKeyPress=\"languagesupport(this)\" onFocus=\"return tGotFocus(this)\" onBlur=\"return onConvert(this)\">$sconv</textarea>";
};
print "<tr>
<td valign=top width=100>x$_</td>
<td colspan=2 valign=top><a name=\"x$_\">$sEnglish[$_]</a><BR>
$fontface$inputtype$fontend<BR>
<a href=\"\#top\">top</a>
<a href=\"\#bottom\">end</a>
<a href=\"\#langspt\">symbols</a>
</td>
</tr>
";
}
print "<tr>
<td colspan=3 align=center>
<a name=\"bottom\">\&nbsp\;</a>
<input type=\"submit\" name=\"submit\" value=\"Save Changes\">
</td>
</tr>
</table>
$logoutbutton
</form>
</BODY>
</HTML>
";
}
sub UpdateTranslation {
$idEnglish = "enu";
@sEnglish = &get_phrases($idEnglish);
@sTranslation = &get_phrases($FORM{'lang'});
$txtTranslation = $language;
$idTranslation = $languageid;
for (0 .. $#sEnglish) {
chop ($sTranslation[$_]);
$id = "x$_";
if ($FORM{$id} ne '') {
$sTranslation[$_] = $FORM{$id};
$sTranslation[$_] =~ s/\+/ /g;
if ($FORM{'lang'} ne 'kor') { $sTranslation[$_] =~ s/\&/\&amp\;/g; }
$sTranslation[$_] =~ s/\r//g;
$sTranslation[$_] =~ s/\n/<BR>/g;
} else {
if ($sTranslation[$_] ne '') {
if ($FORM{'lang'} ne 'kor') { $sTranslation[$_] =~ s/\&/\&amp\;/g; }
$sTranslation[$_] =~ s/\r//g;
$sTranslation[$_] =~ s/\n/<BR>/g;
} else {
$sTranslation[$_] = "$FORM{'lang'}-$_";
}
}
}
&put_phrases($FORM{'lang'});
&PrintForm();
}
sub PrintPrintForm {
$idEnglish = "enu";
@sEnglish = &get_phrases($idEnglish);
$txtEnglish = $LANGUAGE_ID{$idEnglish};
$idTranslation = $FORM{'lang'};
@sTranslation = &get_phrases($idTranslation);
$txtTranslation = $LANGUAGE_ID{$idTranslation};
$basefont="";
$fontface="";
$fontend = "";
if ($FORM{'lang'} eq 'arb') { $charset="iso-8859-6";}
elsif ($FORM{'lang'} eq 'cyr') {
$charset="iso-8859-5";
# $charset="koi8-r";
$basefont="<BASEFONT FACE=\"Verdana Cyr\">";
$fontface="<FONT FACE=\"Verdana Cyr\">";
$fontend = "</FONT>";
} else { $charset="iso-8859-1";}
print "<HTML>
<HEAD>
<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=$charset\">
<TITLE>Test-Central $txtEnglish-$txtTranslation Translation</TITLE>
$basefont
</HEAD>
<BODY BGCOLOR=\"\#FFFFFF\" TEXT=\"\#000000\" LINK=\"\#0000FF\" VLINK=\"\#800080\">
<FORM METHOD=POST NAME=\"form1\">
<input type=\"hidden\" name=\"tid\" value=\"$SESSION{'tid'}\">
<input type=\"hidden\" name=\"lang\" value=\"$idTranslation\">
<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\" width=100\%>
<tr>
<td colspan=2><IMG SRC=\"$PATHS{'graphroot'}/logo.gif\" WIDTH=160 BORDER=0></td>
<td align=center><FONT SIZE=4><b>Test-Central $txtEnglish-$txtTranslation Phrase Translations</b></FONT></td>
</tr>
<tr>
<td width=100><b>Text ID</b></td>
<td colspan=2><b>$txtEnglish<BR>
$txtTranslation</b></td>
</tr>
";
for (0 .. $#sEnglish) {
$sconv = $sTranslation[$_];
chop ($sconv);
$sconv =~ s/\&amp\;/\&/g;
$sconv =~ s/<BR>/\r\n/g;
$rows=1;
$cols=length($sEnglish[$_])+8;
$size=length($sEnglish[$_]);
if ($cols < 60) {
$inputtype = "<input type=text name=\"x$_\" size=60 maxlength=$cols value=\"$sconv\" onKeyPress=\"languagesupport(this)\" onFocus=\"return tGotFocus(this)\" onBlur=\"return onConvert(this)\">";
} else {
if ($cols > 59) {$cols = 60};
$rows = int($size / 25);
if ($rows < 2) { $rows = 2;}
if ($rows > 5) { $rows = 5;}
$inputtype = "<textarea name=\"x$_\" rows=$rows cols=$cols onKeyPress=\"languagesupport(this)\" onFocus=\"return tGotFocus(this)\" onBlur=\"return onConvert(this)\">$sconv</textarea>";
};
print "<tr>
<td valign=top width=100>x$_</td>
<td colspan=2 valign=top>$sEnglish[$_]<BR>
$fontface$inputtype$fontend<BR>
</td>
</tr>
";
}
print "
</table>
</form>
</BODY>
</HTML>
";
}
sub PrintEnglishForm {
$idEnglish = "enu";
@sEnglish = &get_phrases($idEnglish);
$txtEnglish = $LANGUAGE_ID{$idEnglish};
$fontface="";
$fontend = "";
$charset="iso-8859-1";
print "<HTML>
<HEAD>
<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=$charset\">
<TITLE>Test-Central $txtEnglish Phrases</TITLE>
</HEAD>
<BODY BGCOLOR=\"\#FFFFFF\" TEXT=\"\#000000\" LINK=\"\#0000FF\" VLINK=\"\#800080\">
<FORM METHOD=POST NAME=\"form1\">
<input type=\"hidden\" name=\"tid\" value=\"$SESSION{'tid'}\">
<input type=\"hidden\" name=\"lang\" value=\"$idTranslation\">
<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\" width=100\%>
<tr>
<td><IMG SRC=\"$PATHS{'graphroot'}/logo.gif\" WIDTH=100 BORDER=0></td>
<td align=center><FONT SIZE=4><b>Test-Central $txtEnglish Phrases</b></FONT></td>
</tr>
<tr>
<td width=100><b>Text ID</b></td>
<td><b>$txtEnglish</b></td>
</tr>
";
for (0 .. $#sEnglish) {
print "<tr>
<td valign=top width=100>x$_</td>
<td valign=top>$sEnglish[$_]</td>
</tr>
";
}
print "
</table>
</form>
</BODY>
</HTML>
";
}