2006-09-19 22:40:46 +00:00
|
|
|
<?
|
|
|
|
/*
|
|
|
|
This file is part of the 'Science Fair In A Box' project
|
|
|
|
SFIAB Website: http://www.sfiab.ca
|
|
|
|
|
|
|
|
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
|
|
|
|
Copyright (C) 2005 James Grant <james@lightbox.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public
|
|
|
|
License as published by the Free Software Foundation, version 2.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; see the file COPYING. If not, write to
|
|
|
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
?>
|
2007-12-10 20:53:41 +00:00
|
|
|
<?
|
|
|
|
require_once("ajax.inc.php");
|
|
|
|
?>
|
2006-09-19 22:40:46 +00:00
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
var queryInProgress=false;
|
|
|
|
var translateOpen=false;
|
|
|
|
var translationObject;
|
|
|
|
var langstr="<? foreach($config['languages'] AS $l=>$ln){ $lstr.="$l/"; } echo substr($lstr,0,-1)?>";
|
|
|
|
|
|
|
|
var jsTranslateLangs=new Array();
|
|
|
|
<?
|
|
|
|
$x=0;
|
|
|
|
foreach($config['languages'] AS $l=>$ln)
|
|
|
|
{
|
|
|
|
if($l=="en")continue;
|
|
|
|
echo "jsTranslateLangs[$x]=\"$l\";\n";
|
|
|
|
$x++;
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
2008-11-03 02:11:52 +00:00
|
|
|
function selectVisibility(vis) {
|
|
|
|
//we'll always have form0=translationdropdownform, form1=langselectform, form2...infinity=forms on the page
|
|
|
|
for(x=2;x<document.forms.length;x++) {
|
|
|
|
var frm=document.forms[x];
|
|
|
|
for(y=0;y<frm.elements.length;y++) {
|
|
|
|
var e=frm.elements[y];
|
|
|
|
if(e.type=="select-one")
|
|
|
|
e.style.visibility=vis;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-09-19 22:40:46 +00:00
|
|
|
|
|
|
|
function getTranslations(o)
|
|
|
|
{
|
|
|
|
var objItem=document.getElementById(o);
|
|
|
|
var url="<?=$config['SFIABDIRECTORY']?>/admin/gettranslation.php?str="+escape(objItem.value);
|
|
|
|
|
|
|
|
if(!queryInProgress)
|
|
|
|
{
|
|
|
|
queryInProgress=true;
|
|
|
|
http.open("GET", url , true);
|
|
|
|
http.onreadystatechange = handleResponse;
|
|
|
|
http.send(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleResponse()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
|
|
|
|
if(http.readyState==4)
|
|
|
|
{
|
|
|
|
queryInProgress=false;
|
|
|
|
var d=document.getElementById('translationdropdown');
|
|
|
|
// alert(completeField);
|
|
|
|
|
|
|
|
try {
|
|
|
|
results = http.responseText.split('\n');
|
|
|
|
var num=results.length;
|
|
|
|
|
|
|
|
for(i=0;i<results.length;i++)
|
|
|
|
{
|
|
|
|
if(!results[i]){ num--; continue; }
|
|
|
|
|
|
|
|
line = results[i].split(':');
|
|
|
|
//line[0] has "en" or "fr" or the lang code
|
|
|
|
//line[1] has the actual translation for that language
|
|
|
|
objInput=document.getElementById('translation['+line[0]+']');
|
|
|
|
if(line[1])
|
|
|
|
{
|
|
|
|
//alert(objInput);
|
|
|
|
objInput.value=line[1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
objInput.value="";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(e)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
catch(e)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function translateButton(o)
|
|
|
|
{
|
|
|
|
document.write("<a href=\"#\" onclick=\"return translateDropdown('"+o+"')\"><?=i18n("translations")?></a>");
|
|
|
|
}
|
|
|
|
function translateDropdown(o)
|
|
|
|
{
|
|
|
|
translationObject=document.getElementById(o);
|
|
|
|
var d=document.getElementById('translationdropdown');
|
2008-11-03 02:11:52 +00:00
|
|
|
if(translateOpen) {
|
2006-09-19 22:40:46 +00:00
|
|
|
d.style.visibility="hidden";
|
2008-11-03 02:11:52 +00:00
|
|
|
selectVisibility("visible");
|
|
|
|
}
|
2006-09-19 22:40:46 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
getTranslations(o);
|
|
|
|
objItem=translationObject;
|
|
|
|
|
|
|
|
var tagheight=objItem.offsetHeight;
|
2008-11-03 02:11:52 +00:00
|
|
|
var tagwidth=objItem.offsetWidth+75;
|
2006-09-19 22:40:46 +00:00
|
|
|
|
|
|
|
//alert('tagheight='+tagheight+' tagwidth='+tagwidth);
|
|
|
|
|
|
|
|
var intx=0;
|
|
|
|
var inty=0;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
intx+=objItem.offsetLeft;
|
|
|
|
inty+=objItem.offsetTop;
|
|
|
|
objParent=objItem.offsetParent.tagName;
|
|
|
|
objItem=objItem.offsetParent;
|
|
|
|
} while(objParent!="BODY");
|
|
|
|
|
|
|
|
d.style.top=inty+tagheight+"px";
|
2008-11-03 02:11:52 +00:00
|
|
|
d.style.left=(intx-75)+"px";
|
|
|
|
d.style.width=(tagwidth)+"px";
|
2006-09-19 22:40:46 +00:00
|
|
|
// d.style.height=dropdownheight+"px";
|
|
|
|
d.style.visibility="visible";
|
|
|
|
|
|
|
|
oButton=document.getElementById('buttonsavetranslations');
|
|
|
|
oButton.value="<?=i18n("Save Translations")?>";
|
|
|
|
|
2008-11-03 02:11:52 +00:00
|
|
|
selectVisibility("hidden");
|
|
|
|
|
2006-09-19 22:40:46 +00:00
|
|
|
}
|
|
|
|
translateOpen=!translateOpen;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function savetranslations()
|
|
|
|
{
|
|
|
|
var url="<?=$config['SFIABDIRECTORY']?>/admin/settranslation.php?str="+escape(translationObject.value);
|
|
|
|
var x;
|
|
|
|
for(x=0;x<jsTranslateLangs.length;x++)
|
|
|
|
{
|
|
|
|
oTmp=document.getElementById('translation['+jsTranslateLangs[x]+']');
|
|
|
|
url+="&"+jsTranslateLangs[x]+"="+escape(oTmp.value);
|
|
|
|
}
|
|
|
|
oButton=document.getElementById('buttonsavetranslations');
|
|
|
|
oButton.value="<?=i18n("Saving translations...")?>";
|
|
|
|
|
|
|
|
if(!queryInProgress)
|
|
|
|
{
|
|
|
|
queryInProgress=true;
|
|
|
|
http.open("GET", url , true);
|
|
|
|
http.onreadystatechange = handleSaveResponse;
|
|
|
|
http.send(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleSaveResponse()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
|
|
|
|
if(http.readyState==4)
|
|
|
|
{
|
|
|
|
queryInProgress=false;
|
|
|
|
var d=document.getElementById('translationdropdown');
|
|
|
|
|
|
|
|
oButton=document.getElementById('buttonsavetranslations');
|
|
|
|
oButton.value="<?=i18n("Translations Saved")?>";
|
|
|
|
|
|
|
|
setTimeout("translateDropdown('dummy');",500); //it doesnt matter what obj we use, because we're just clearing it anyways
|
|
|
|
|
|
|
|
//who cares what happens, we're done thats all we care about
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
catch(e)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<?
|
|
|
|
$num=count($config['languages'])-1; //subtract 1 for english
|
2008-11-03 02:11:52 +00:00
|
|
|
$divheight=($num*25)+50;
|
2006-09-19 22:40:46 +00:00
|
|
|
?>
|
2008-11-03 02:11:52 +00:00
|
|
|
<style type="text/css">
|
|
|
|
.translationdropdown
|
|
|
|
{
|
|
|
|
position: absolute;
|
|
|
|
z-index: 100;
|
|
|
|
overflow: auto;
|
|
|
|
width: 300px;
|
|
|
|
background-color: #669966;
|
|
|
|
visibility: hidden;
|
|
|
|
border: 0px;
|
|
|
|
top: 0px;
|
|
|
|
left:0px;
|
|
|
|
width:300px;
|
|
|
|
height:<?=$divheight?>px;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
<div class="translationdropdown" name="translationdropdown" id="translationdropdown">
|
2006-09-19 22:40:46 +00:00
|
|
|
<form name="translationform" method="get">
|
2008-11-03 02:11:52 +00:00
|
|
|
<table cellspacing=0 cellpadding=0 border=0 style="width: 99%; font-size: 0.8em;">
|
2006-09-19 22:40:46 +00:00
|
|
|
<?
|
|
|
|
foreach($config['languages'] AS $l=>$ln)
|
|
|
|
{
|
|
|
|
if($l=="en") continue;
|
2008-11-03 02:11:52 +00:00
|
|
|
echo "<tr><td style=\"width: 75px;\">$ln:</td><td><input type=\"text\" style=\"width: 100%;\" id=\"translation[$l]\" name=\"translation[$l]\"></td></tr>";
|
2006-09-19 22:40:46 +00:00
|
|
|
}
|
2008-11-03 02:11:52 +00:00
|
|
|
echo "</table>\n";
|
|
|
|
echo "<input type=\"button\" id=\"buttonsavetranslations\" onclick=\"return savetranslations()\" value=\"".i18n("Save Translations")."\">";
|
2006-09-19 22:40:46 +00:00
|
|
|
?>
|
|
|
|
</form>
|
|
|
|
</div>
|