Make the translations manager much mroe user friendly:

1) can edit more than one translation at a time
2) can delete more than one translation at a time
This commit is contained in:
james 2008-10-30 17:57:05 +00:00
parent 59d42980e1
commit b45ef040bb

View File

@ -4,7 +4,7 @@
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
Copyright (C) 2008 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
@ -43,16 +43,22 @@ if($_GET['show']) $show=$_GET['show'];
else if($_POST['show']) $show=$_POST['show'];
if(!$show) $show="missing";
if($_POST['strmd5'] && $_POST['lang'] && $_POST['val'])
{
mysql_query("UPDATE translations SET val='".mysql_escape_string(stripslashes($_POST['val']))."' WHERE strmd5='".$_POST['strmd5']."' AND lang='".$_POST['lang']."'");
echo happy(i18n("Translation saved"));
}
if($_GET['action']=="delete" && $_GET['delete'] && $_GET['lang'])
{
mysql_query("DELETE FROM translations WHERE strmd5='".$_GET['delete']."' AND lang='".$_GET['lang']."'");
echo happy(i18n("Translation deleted"));
if($_POST['action']=="save") {
//first, delete anything thats supposed to eb deleted
if(count($_POST['delete'])) {
foreach($_POST['delete'] AS $del) {
mysql_query("DELETE FROM translations WHERE lang='".mysql_real_escape_string($_SESSION['translang'])."' AND strmd5='".mysql_real_escape_string($del)."'");
}
echo happy(i18n("Translation(s) deleted"));
}
if($_POST['changedFields']) {
$changed=split(",",$_POST['changedFields']);
foreach($changed AS $ch) {
mysql_query("UPDATE translations SET val='".mysql_escape_string(stripslashes($_POST['val'][$ch]))."' WHERE strmd5='".mysql_real_escape_string($ch)."' AND lang='".mysql_real_escape_string($_SESSION['translang'])."'");
}
echo happy(i18n("Translation(s) saved"));
}
}
echo "<table>";
@ -72,14 +78,12 @@ echo "</form>";
echo "</td></tr>";
echo "</table>";
if($show=="missing")
{
if($show=="missing") {
echo i18n("Show missing translations");
echo "&nbsp; | &nbsp;";
echo "<a href=\"translations.php?show=all\">".i18n("Show all translations")."</a>";
}
else
{
else {
echo "<a href=\"translations.php?show=missing\">".i18n("Show missing translations")."</a>";
echo "&nbsp; | &nbsp;";
echo i18n("Show all translations");
@ -98,32 +102,50 @@ $q=mysql_query("SELECT * FROM translations WHERE lang='".$_SESSION['translang'].
$num=mysql_num_rows($q);
echo i18n("Showing %1 translation strings",array($num),array("number of strings"));
echo "<form method=\"post\" action=\"translations.php\">";
echo "<input type=\"hidden\" name=\"show\" value=\"$show\" />";
echo "<input type=\"hidden\" name=\"action\" value=\"save\" />";
echo "<input id=\"changedFields\" type=\"hidden\" name=\"changedFields\" value=\"\">";
?>
<script type="text/javascript">
function doFocus(strmd5) {
var obj=document.getElementById('val_'+strmd5);
var ch=document.getElementById('changedFields');
obj.style.backgroundColor="#FFBFF2";
if(ch.value)
ch.value=ch.value+","+strmd5;
else
ch.value=strmd5;
return true;
}
</script>
<?
echo "<table class=\"tableedit\">";
echo "<tr><th>".i18n("English")." / ".$translangname."</th><th>".i18n("Save")."</th></tr>";
echo "<tr><th>";
echo "<img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\">\n";
echo "</th>";
echo "<th>".i18n("English")." / ".$translangname."</th></tr>\n";
while($r=mysql_fetch_object($q))
{
echo "<form method=\"post\" action=\"translations.php\">";
echo "<input type=\"hidden\" name=\"show\" value=\"$show\" />";
echo "<input type=\"hidden\" name=\"lang\" value=\"$r->lang\" />";
echo "<input type=\"hidden\" name=\"strmd5\" value=\"$r->strmd5\" />";
echo "<tr>";
echo "<td valign=\"top\">";
echo "<a onclick=\"return confirmClick('Are you sure you want to delete this translation?');\" href=\"translations.php?show=$show&action=delete&delete=$r->strmd5&lang=$r->lang\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo "&nbsp;";
echo "<input type=\"checkbox\" name=\"delete[]\" value=\"$r->strmd5\">\n";
echo "</td><td>";
echo htmlspecialchars($r->str);
if($r->argsdesc)
echo "<br /><i>".i18n("Arguments:")." $r->argsdesc </i>";
echo "</td>";
echo "<td rowspan=\"2\" valign=\"middle\" ><input type=\"submit\" value=\"".i18n("Save")."\" /></td>";
echo "</tr>";
echo "<tr>";
echo "<td valign=\"top\"><input style=\"width: 95%\" type=\"text\" name=\"val\" value=\"".htmlspecialchars($r->val)."\" /></td>";
echo "<td></td>";
echo "<td valign=\"top\"><input id=\"val_{$r->strmd5}\" onchange=\"return doFocus('{$r->strmd5}');\" style=\"width: 95%\" type=\"text\" name=\"val[{$r->strmd5}]\" value=\"".htmlspecialchars($r->val)."\" /></td>";
echo "</tr>";
echo "<tr><td colspan=\"2\"><hr /></td></tr>";
echo "</form>\n";
}
echo "</table>";
echo "<input type=\"submit\" value=\"".i18n("Save")."\">";
echo "</form>\n";
send_footer();
?>