From b45ef040bb2fbb81f30b8608e2851ca724273ad7 Mon Sep 17 00:00:00 2001 From: james Date: Thu, 30 Oct 2008 17:57:05 +0000 Subject: [PATCH] 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 --- admin/translations.php | 72 +++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 25 deletions(-) diff --git a/admin/translations.php b/admin/translations.php index 2027a3e..9c29c66 100644 --- a/admin/translations.php +++ b/admin/translations.php @@ -4,7 +4,7 @@ SFIAB Website: http://www.sfiab.ca Copyright (C) 2005 Sci-Tech Ontario Inc - Copyright (C) 2005 James Grant + Copyright (C) 2008 James Grant 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 ""; @@ -72,14 +78,12 @@ echo ""; echo ""; echo "
"; -if($show=="missing") -{ +if($show=="missing") { echo i18n("Show missing translations"); echo "  |  "; echo "".i18n("Show all translations").""; } -else -{ +else { echo "".i18n("Show missing translations").""; echo "  |  "; 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 "
"; +echo ""; +echo ""; +echo ""; +?> + + +"; -echo "".i18n("English")." / ".$translangname."".i18n("Save").""; +echo ""; +echo "\n"; +echo ""; +echo "".i18n("English")." / ".$translangname."\n"; while($r=mysql_fetch_object($q)) { - echo ""; - echo ""; - echo "lang\" />"; - echo "strmd5\" />"; echo ""; echo ""; - echo "strmd5&lang=$r->lang\">"; - echo " "; + echo "strmd5\">\n"; + echo ""; echo htmlspecialchars($r->str); if($r->argsdesc) echo "
".i18n("Arguments:")." $r->argsdesc "; - echo ""; - echo ""; echo ""; echo ""; - echo "val)."\" />"; + echo ""; + echo "strmd5}\" onchange=\"return doFocus('{$r->strmd5}');\" style=\"width: 95%\" type=\"text\" name=\"val[{$r->strmd5}]\" value=\"".htmlspecialchars($r->val)."\" />"; echo ""; echo "
"; - echo "
\n"; } echo ""; +echo ""; +echo "\n"; send_footer(); ?>