00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 include('WebBackend.php');
00023
00024 $backend = new WebBackend();
00025 $backend->EventHandler();
00026
00027 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
00028 <html>
00029 <head>
00030 <title>TranslationMemory</title>
00031 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
00032 <link rel="stylesheet" href="style.css" type="text/css" media="screen" />
00033 <script type="text/javascript" src="diff.js"></script>
00034 </head>
00035 <body>
00036 <form action="WebGUI.php" method="post" name="__Form" id="__Form">
00037 <input type="hidden" name="__Event" value="" id="__Event" />
00038
00039 <!-- backend variables -->
00040 <input type="hidden" name="xStringID" value="<? echo $backend->xStringID ?>" id="xStringID" />
00041 <input type="hidden" name="xProjectID" value="<? echo $backend->xProjectID ?>" id="xProjectID" />
00042 <input type="hidden" name="xOldLocaleID" value="<? echo $backend->xOldLocaleID ?>" id="xOldLocaleID" />
00043
00044 <input type="hidden" name="xStringStack" value="<? echo $backend->xStringStack ?>" id="xStringStack" />
00045 <input type="hidden" name="xBrowserHelper" value="<? echo $backend->xBrowserHelper ?>" id="xBrowserHelper" />
00046 <input type="hidden" name="xDelStringID" value="0" id="xDelStringID" />
00047
00048 <!-- client side variables -->
00049 <input type="hidden" name="htmlEditorChanged" value="0" id="htmlEditorChanged" />
00050 <input type="hidden" name="htmlOriginalString" value="<?
00051 if(!empty($backend->LocatedString))
00052 {
00053 echo FixQuot($backend->LocatedString->GetOriginal());
00054 }
00055 ?>" id="htmlOriginalString"/>
00056
00057 <table class="layout">
00058 <tr><td valign="top" class="projecttree">
00059
00060 <!-- *** PROJECT TREE *** -->
00061
00062 <?
00063 if(!empty($backend->LocatedProjects))
00064 {
00065
00066 for($i = count($backend->LocatedProjects)-1; $i >= 0; $i--)
00067 {
00068 echo "<ul class=\"projecttree\">\n<li><a href=\"javascript:__TriggerEvent('setproject', true, 'xProjectID','". $backend->LocatedProjects[$i]->GetID()."')\">";
00069 echo $backend->LocatedProjects[$i]->GetName();
00070 echo "</a>";
00071
00072
00073 if($backend->RootLastSeen > $backend->LocatedProjects[$i]->GetLastSeen())
00074 {
00075 echo " +";
00076 }
00077 }
00078
00079
00080 if($backend->ChildProjects->valid())
00081 {
00082 echo "<ul class=\"projecttree\">\n";
00083 foreach($backend->ChildProjects as $project)
00084 {
00085 echo("<li><a href=\"javascript:__TriggerEvent('setproject', true, 'xProjectID','". $project->GetID()."')\">");
00086 echo($project->GetName());
00087 echo("</a>");
00088
00089
00090 if($backend->RootLastSeen > $project->GetLastSeen())
00091 {
00092 echo " +++";
00093 }
00094
00095 echo("</li>\n");
00096 }
00097 echo "</ul>";
00098
00099 }
00100 for($i = count($backend->LocatedProjects)-1; $i >= 0; $i--)
00101 {
00102 echo "</li>\n</ul>\n";
00103 }
00104 }
00105 ?>
00106 </td>
00107
00108 <td valign="top">
00109
00110 <!-- *** ONE STRING EDITOR *** -->
00111
00112 <?
00113
00114 if(!empty($backend->LocatedString))
00115 {
00116 ?>
00117 <h1>Translation string editor area</h1>
00118
00119 <?
00120 $stringIsDead = ($backend->RootLastSeen > $backend->LocatedString->GetLastSeen());
00121 if($stringIsDead)
00122 {
00123
00124 echo("<div class=\"located-dead\">");
00125 }
00126 ?>
00127 <table class="located">
00128 <tr><th>Project Path</th>
00129 <td><?
00130
00131
00132 if(!empty($backend->LocatedProjects))
00133 {
00134 for($i = count($backend->LocatedProjects)-1; $i >= 0; $i--)
00135 {
00136
00137 $style = "";
00138 if($i == 0 && $backend->LocatedProjects[$i]->GetName() == "fuzzy.xml")
00139 {
00140 $style = "style=\"font-size: 25px\"";
00141 }
00142
00143
00144 echo "<a $style href=\"javascript:__TriggerEvent('setproject', true, 'xProjectID','". $backend->LocatedProjects[$i]->GetID()."')\">";
00145 echo $backend->LocatedProjects[$i]->GetName();
00146 echo "</a>";
00147 if($i != 0)
00148 {
00149 echo " -> ";
00150 }
00151 }
00152 }
00153 ?></td></tr>
00154 <tr><th>Original</th>
00155 <td><? echo FixQuot($backend->LocatedString->GetOriginal()) ?></td></tr>
00156 <tr><th><u>E</u>dit translation</th>
00157 <td><?
00158 $disableField = ($stringIsDead ? "disabled=\"disabled\"" : "");
00159
00160 if(strlen($backend->LocatedString->GetOriginal()) < 100)
00161 {
00162 echo "<input class=\"editshort\" type=\"text\" accesskey=\"e\" name=\"txtEditString_".$backend->xBrowserHelper."\" id=\"txtEditString_".$backend->xBrowserHelper."\" value=\"";
00163 echo FixQuot($backend->LocatedString->GetTranslation());
00164 echo "\" onchange=\"editorChanged();\" tabindex=\"1\" $disableField/>";
00165 }
00166 else
00167 {
00168 echo "<textarea class=\"editlong\" cols=\"80\" rows=\"8\" accesskey=\"e\" name=\"txtEditString_".$backend->xBrowserHelper."\" id=\"txtEditString_".$backend->xBrowserHelper."\" onchange=\"editorChanged();\" tabindex=\"1\" $disableField>";
00169 echo FixQuot($backend->LocatedString->GetTranslation());
00170 echo "</textarea>";
00171 }
00172 ?>
00173 </td></tr>
00174 </table>
00175 <?
00176
00177 $saveDisabled = "class=\"button-disabled\" disabled=\"disabled\"";
00178 $saveEnabled = "class=\"button\"";
00179 if($stringIsDead)
00180 {
00181
00182 echo("</div>");
00183
00184 $saveType = $saveDisabled;
00185 $saveTypePop = $saveDisabled;
00186 }
00187 else
00188 {
00189 $saveType = $saveEnabled;
00190 $saveTypePop = $saveEnabled;
00191
00192
00193 if($backend->xStringStack == "")
00194 {
00195 $saveTypePop = $saveDisabled;
00196 }
00197 }
00198 ?>
00199 <input <? echo $saveType; ?> type="button" onclick="__TriggerEvent('savenext', false);" value="Save + Next" tabindex="2" />
00200 <button <? echo $saveType; ?> type="button" onclick="__TriggerEvent('savenextmissing', false);" tabindex="3" accesskey="s"><u>S</u>ave + Next missing</button>
00201 <button <? echo $saveTypePop; ?> type="button" onclick="__TriggerEvent('savepopstack', false);" tabindex="3" accesskey="p" id="btnSavePopStack">Save + <u>p</u>op</button>
00202 <input <? echo $saveType; ?> type="button" onclick="__TriggerEvent('save', false);" value="Save" tabindex="4" />
00203 <!-- input class="button" type="button" onclick="__TriggerEvent('previous');" value="Previous" />
00204 <input class="button" type="button" onclick="__TriggerEvent('previoumissing');" value="Previous missing" / -->
00205 <input class="button" type="button" onclick="__TriggerEvent('next', true);" value="Next" tabindex="5" />
00206 <button class="button" type="button" onclick="__TriggerEvent('nextmissing', true);" tabindex="6" accesskey="n"><u>N</u>ext missing</button> Stack:
00207 <input class="codebutton" type="button" onclick="pushToStack('<? echo($backend->LocatedString->GetStringID()); ?>');" value="push" tabindex="7" />
00208 <input class="codebutton" type="button" onclick="popFromStack();" value="pop" tabindex="8" />
00209 <span id="plhStackView"></span>
00210 <br/>
00211 <?
00212 }
00213
00214 if(!empty($backend->CurrentStrings))
00215 {
00216 ?>
00217
00218 <!-- *** CURRENT PROJECT'S STRINGS *** -->
00219
00220 <p><a href="javascript:toggleStrings()" accesskey="t"><span class="underunder">t</span>oggle strings</a></p>
00221 <div id="divStrings">
00222 <h1>Strings in the currently selected project</h1>
00223 <?
00224
00225 $addHeader = true;
00226 foreach($backend->CurrentStrings as $str)
00227 {
00228
00229 if($addHeader)
00230 {
00231 ?>
00232 <table class="strings">
00233 <tr><th>Original string</th>
00234 <th>Translated string</th>
00235 <th>Action</th></tr>
00236 <?
00237 $addHeader = false;
00238 }
00239 if(!empty($backend->LocatedString) && $backend->LocatedString->GetStringID() == $str->GetStringID())
00240 {
00241 echo("<tr class=\"selected\">");
00242 }
00243 else
00244 {
00245 echo("<tr>");
00246 }
00247
00248 echo("<td class=\"string-original\">".FixQuot($str->GetOriginal())."</td>");
00249 echo("<td class=\"string-translation\">".FixQuot($str->GetTranslation())."</td>");
00250 echo("<td><a href=\"javascript:__TriggerEvent('editstring', true, 'xStringID','".$str->GetStringID()."');\">Edit</a>");
00251
00252
00253 if($backend->RootLastSeen > $str->GetLastSeen())
00254 {
00255 echo " +++ ";
00256 echo("<a href=\"javascript:if(confirm('Are you sure to delete from Translation Memory?')) { __TriggerEvent('deletestring', true, 'xDelStringID', '".$str->GetStringID()."'); }\">Del</a>");
00257 }
00258
00259 echo("</td>");
00260 echo("</tr>\n");
00261 }
00262 if($addHeader)
00263 {
00264
00265 ?>
00266 <p>There are no strings in the current project.</p>
00267 Find strings: <input class="button" type="button" onclick="__TriggerEvent('next', true);" value="Next" />
00268 <button class="button" type="button" onclick="__TriggerEvent('nextmissing', true);" accesskey="n"><u>N</u>ext missing</button>
00269 <?
00270 }
00271 else
00272 {
00273 echo("</table>");
00274 }
00275 ?></div><?
00276 }
00277 $sel = " selected=\"selected\"";
00278 ?> <h1>Search</h1><a name="searchresults"></a>
00279
00280 <!-- *** CUSTOM SEARCH BOX *** -->
00281
00282 <p>
00283 <select name="ddlSearchType" id="ddlSearchType">
00284 <option value="0"<? echo ($backend->ddlSearchType == 0 ? $sel : ""); ?>>Word index</option>
00285 <option value="1"<? echo ($backend->ddlSearchType == 1 ? $sel : ""); ?>>Part in original</option>
00286 <option value="2"<? echo ($backend->ddlSearchType == 2 ? $sel : ""); ?>>Part in translation</option>
00287 </select>
00288 <a href="javascript:clearFindText();">clear></a>
00289 <input type="text" size="35" id="txtFindText" name="txtFindText" value="<? echo FixQuot( $backend->txtFindText); ?>">
00290 <input class="button" type="button" value="Find" onclick="__TriggerEvent('find', true);"/>
00291 <!-- input class="button" type="button" value="Original"/--></p>
00292
00293
00294 <!-- *** SEARCH RESULTS *** -->
00295
00296
00297 <?
00298
00299 if(!empty($backend->Translations))
00300 {
00301 $accessKey = 1;
00302 ?>
00303 <table class="guesses">
00304 <tr><th>Match</th>
00305 <th>Original string</th>
00306 <?
00307 if(!empty($backend->LocatedString))
00308 {
00309 echo("<th>alt</th>");
00310 }
00311 ?>
00312 <th>Translated string (take by click)</th>
00313 <th>Action</th></tr><?
00314
00315 foreach($backend->Translations as $id => $tr)
00316 {
00317 foreach($tr["strings"] as $key => $str)
00318 {
00319
00320 if(!empty($backend->LocatedString) && $backend->LocatedString->GetStringID() == $str->GetStringID())
00321 {
00322 echo("<tr class=\"selected\">");
00323 }
00324 else
00325 {
00326 echo("<tr>");
00327 }
00328
00329
00330 echo("<td class=\"guess-percent\">");
00331 if($backend->ddlSearchType == 0)
00332 {
00333
00334 if(!empty($backend->LocatedString) && $backend->LocatedString->GetOriginal() == $str->GetOriginal()) {
00335 echo("<b>identical</b>");
00336 }
00337 else
00338 {
00339 echo($tr["percent"]."%");
00340 echo(" <a id=\"diffLink_".$str->GetStringID()."\" href=\"javascript:diffToOriginal(".$str->GetStringID().");\">(?)</a>");
00341 }
00342 }
00343 echo("</td>");
00344
00345
00346 echo("<td id=\"original_".$str->GetStringID()."\" class=\"guess-original\">".FixQuot($str->GetOriginal())."</td>");
00347
00348
00349 if(!empty($backend->LocatedString))
00350 {
00351
00352 echo("<td class=\"guess-accesskey\">");
00353 if($accessKey < 10)
00354 {
00355 echo("<a accesskey=\"$accessKey\" href=\"javascript:takeTranslation(".$str->GetStringID().");\"><span class=\"underunder\">$accessKey</span></a>");
00356 $accessKey++;
00357 }
00358 echo("</td>");
00359
00360
00361 echo("<td class=\"guess-translated\">");
00362 echo("<a id=\"results_".$str->GetStringID()."\" href=\"javascript:takeTranslation(".$str->GetStringID().");\">".FixQuot($str->GetTranslation())."</a>");
00363 echo("</td>");
00364 }
00365 else
00366 {
00367
00368 echo("<td class=\"guess-translated\">");
00369 echo(FixQuot($str->GetTranslation()));
00370 echo("</td>");
00371 }
00372
00373 echo("<td class=\"guess-action\">");
00374
00375
00376 echo("<a href=\"javascript:__TriggerEvent('editstring', true, 'xStringID', '".$str->GetStringID()."');\">Edit</a>");
00377
00378
00379 if($backend->RootLastSeen > $str->GetLastSeen())
00380 {
00381
00382 echo " +++ ";
00383 echo("<a href=\"javascript:if(confirm('Are you sure to delete from Translation Memory?')) { __TriggerEvent('deletestring', true, 'xDelStringID', '".$str->GetStringID()."'); }\">Del</a>");
00384 }
00385 else
00386 {
00387
00388 echo(" | <a href=\"javascript:pushToStack('".$str->GetStringID()."');\">push</a>");
00389 }
00390 echo("</td></tr>\n");
00391 }
00392 }
00393 ?></table><?
00394 if($backend->ddlSearchType != 0)
00395 {
00396 echo("Displayed ".count($backend->Translations)." results.<br/>");
00397 }
00398 }
00399 ?>
00400
00401 <!-- *** SEARCH REFRESH CONTROLS *** -->
00402
00403 <select name="ddlFindPercent">
00404 <?
00405 foreach(array(30,40,50,60,70,80,90) as $percent)
00406 {
00407 $sel = "";
00408 if($backend->ddlFindPercent == $percent)
00409 {
00410 $sel = " selected=\"selected\"";
00411 }
00412 echo "<option value=\"$percent\"$sel>> $percent%</option>";
00413 }
00414 ?>
00415 </select>
00416 (<input type="checkbox"> Ignore dead strings)
00417 <input type="button" value="Refresh" class="button" onclick="__TriggerEvent('find', true);"/><br/>
00418
00419 </td>
00420
00421 </tr>
00422 </table>
00423 <div class="localeswitch">
00424 <?
00425 echo "<select name=\"ddlLocaleID\">\n";
00426 foreach(TranslationProject::$LocaleIDCache as $name => $id)
00427 {
00428 $sel = "";
00429 if($backend->ddlLocaleID == $id)
00430 {
00431 $sel = " selected=\"selected\"";
00432 }
00433 echo "<option value=\"$id\"$sel>$name</option>\n";
00434 }
00435 echo "</select>\n";
00436 ?>
00437 <input type="button" value="Switch Locale" class="button" onclick="__TriggerEvent('setlocale', true);"/> |
00438
00439 <? if($CONFIG['enable_web_export']) { ?>
00440 <input type="button" value="Export language pack" class="button" onclick="__TriggerEvent('exportpack', true);"/> |
00441 <? } ?>
00442
00443 <a href="http://xartm.xaraya.hu">Homepage</a> | (c) 2006 Ferenc 'Lion/Kempelen' Veres
00444 </div>
00445 </form>
00446
00447 <script type="text/javascript">
00448
00449
00450
00451
00452 document.getElementById('__Event').value = '';
00453 document.getElementById('__Form').onsubmit = __FormSubmit();
00454
00455
00456 function __FormSubmit()
00457 {
00458 if(document.getElementById('__Event').value == '')
00459 {
00460 document.getElementById('__Event').value = 'find';
00461 }
00462 }
00463
00464 function __TriggerEvent(event, confirmEvent, args)
00465 {
00466
00467 if(document.getElementById('htmlEditorChanged').value == "1" &&
00468 confirmEvent &&
00469 !confirm("Discard current editing?"))
00470 {
00471 return;
00472 }
00473
00474
00475 for(i=2;i<arguments.length;i+=2)
00476 {
00477 document.getElementById(arguments[i]).value = arguments[i+1];
00478 }
00479 document.getElementById('__Event').value = event;
00480 document.getElementById('__Form').submit();
00481 }
00482
00483
00484
00485
00486 function takeTranslation(stringID)
00487 {
00488 translation = document.getElementById('results_' + stringID).innerHTML;
00489
00490
00491 translation = fixHtmlTags(translation);
00492
00493 document.getElementById('txtEditString_<? echo $backend->xBrowserHelper ?>').value = translation;
00494 editorChanged();
00495 }
00496
00497
00498 function fixHtmlTags(str)
00499 {
00500 str = str.replace(/\n/g, " ");
00501 str = str.replace(/\>/g, ">");
00502 str = str.replace(/\</g, "<");
00503 str = str.replace(/\&/g, "&");
00504
00505 return str;
00506 }
00507
00508
00509 function toggleStrings()
00510 {
00511 if(document.getElementById('divStrings').style.display == 'none')
00512 {
00513 document.getElementById('divStrings').style.display = 'block';
00514 }
00515 else
00516 {
00517 document.getElementById('divStrings').style.display = 'none';
00518 }
00519 }
00520
00521
00522 function pushToStack(stringID)
00523 {
00524 stackVar = document.getElementById('xStringStack');
00525 stackVar.value += "," + stringID;
00526
00527
00528
00529 showStack();
00530
00531
00532 btnSavePop = document.getElementById('btnSavePopStack');
00533 btnSavePop.disabled = false;
00534 btnSavePop.className = "button";
00535 }
00536
00537
00538 function popFromStack()
00539 {
00540 stringVar = document.getElementById('xStringID');
00541 stackVar = document.getElementById('xStringStack');
00542
00543 if(stackVar.value.length == 0)
00544 {
00545 alert("String stack is emtpy.");
00546 return;
00547 }
00548
00549
00550 rx = new RegExp('^\(.*\),\([0-9]+\)$');
00551 if(confirm("Take " + stackVar.value.replace(rx, "$2") + " out from stack and edit?"))
00552 {
00553 __TriggerEvent('editstring', true, 'xStringID', stackVar.value.replace(rx, "$2"), 'xStringStack', stackVar.value.replace(rx, "$1"));
00554 }
00555 }
00556
00557
00558 function showStack()
00559 {
00560
00561 stackVar = document.getElementById('xStringStack');
00562 stackString = stackVar.value.substr(1, stackVar.value.length);
00563 stackString = stackString.replace(/,/g,", ");
00564
00565
00566 stackView = document.getElementById('plhStackView');
00567 stackView.innerHTML = stackString;
00568 }
00569 <?
00570
00571 if(!empty($backend->LocatedString))
00572 {
00573 echo("showStack();");
00574 }
00575 ?>
00576
00577
00578 function editorChanged()
00579 {
00580 document.getElementById('htmlEditorChanged').value = "1";
00581 }
00582
00583
00584 function clearFindText()
00585 {
00586 document.getElementById('txtFindText').value = "";
00587 }
00588
00589
00590 function diffToOriginal(stringID)
00591 {
00592
00593 testedString = fixHtmlTags(document.getElementById('original_' + stringID).innerHTML);
00594
00595
00596 masterString = document.getElementById('htmlOriginalString').value;
00597 if(masterString == "")
00598 {
00599 alert("There is no current string selected to comapre to.");
00600 return;
00601 }
00602
00603 document.getElementById('original_' + stringID).innerHTML = StringDiff(masterString, testedString);
00604 document.getElementById('diffLink_' + stringID).innerHTML = "";
00605 }
00606
00607 </script>
00608
00609 </body>
00610 </html>