From 951f8010937940caf47e0fc56dc12e2406790122 Mon Sep 17 00:00:00 2001 From: james Date: Tue, 19 Sep 2006 22:40:46 +0000 Subject: [PATCH] Add an AJAX powered translation dropdown to allow incorporation of single string translations in-line in any editor instead of having to manage the translations separately in the translation manager. Add the translation dropdown to a few fields in teh award sponsors, awards and award prizes. --- admin/award_awards.php | 4 +- admin/award_prizes.php | 2 +- admin/award_sponsors.php | 6 +- admin/gettranslation.php | 39 ++++++ admin/settranslation.php | 40 ++++++ common.inc.php | 7 + translationsdropdown.inc.php | 245 +++++++++++++++++++++++++++++++++++ 7 files changed, 336 insertions(+), 7 deletions(-) create mode 100644 admin/gettranslation.php create mode 100644 admin/settranslation.php create mode 100644 translationsdropdown.inc.php diff --git a/admin/award_awards.php b/admin/award_awards.php index 5628c34..8c25272 100644 --- a/admin/award_awards.php +++ b/admin/award_awards.php @@ -212,7 +212,7 @@ echo mysql_error(); echo "\n"; echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; echo ""; - echo "\n"; + echo "\n"; echo "
".i18n("Name")."
".i18n("Name")."
".i18n("Order")."(".i18n("presentation order").")
".i18n("Sponsor").""; $sq=mysql_query("SELECT id,organization FROM award_sponsors ORDER BY organization"); @@ -247,7 +247,7 @@ echo mysql_error(); echo ""; echo "
".i18n("Criteria")."
".i18n("Criteria")."
".i18n("Eligibility").""; echo ""; diff --git a/admin/award_prizes.php b/admin/award_prizes.php index b1d48e0..2ca73f3 100644 --- a/admin/award_prizes.php +++ b/admin/award_prizes.php @@ -128,7 +128,7 @@ echo "\n"; echo "
\n"; - echo "\n"; + echo "\n"; echo "\n"; echo "\n"; echo "\n"; diff --git a/admin/award_sponsors.php b/admin/award_sponsors.php index 66f6f35..42f61a2 100644 --- a/admin/award_sponsors.php +++ b/admin/award_sponsors.php @@ -26,9 +26,7 @@ auth_required('admin'); send_header("Administration - Award Sponsors"); -?> - -<< ".i18n("Back to Administration")."\n"; echo "<< ".i18n("Back to Awards")."\n"; @@ -105,7 +103,7 @@ echo "\n"; echo "
".i18n("Prize Description")."prize)."\" size=\"40\" maxlength=\"128\" />
".i18n("Prize Description")."prize)."\" size=\"40\" maxlength=\"128\" />
".i18n("Cash Amount")."\$cash)."\" size=\"10\" maxlength=\"10\" />
".i18n("Scholarship Amount")."\$scholarship)."\" size=\"10\" maxlength=\"10\" />
".i18n("Number")."number)."\" size=\"3\" maxlength=\"5\" />
\n"; - echo "\n"; + echo "\n"; echo "\n"; echo "\n"; echo "
".i18n("Organization Name")."organization)."\" size=\"60\" maxlength=\"128\" />
".i18n("Organization Name")."organization)."\" size=\"60\" maxlength=\"128\" />
".i18n("Address")."address)."\" size=\"60\" maxlength=\"64\" />
".i18n("City")."city)."\" size=\"32\" maxlength=\"32\" />
".i18n("Province").""; diff --git a/admin/gettranslation.php b/admin/gettranslation.php new file mode 100644 index 0000000..a3efedb --- /dev/null +++ b/admin/gettranslation.php @@ -0,0 +1,39 @@ + + Copyright (C) 2005 James Grant + + 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. +*/ +?> +$ln) +{ + if($l=="en") continue; + + $q=mysql_query("SELECT * FROM translations WHERE lang='$l' AND strmd5='".md5($_GET['str'])."'"); + if($r=mysql_fetch_object($q)) + echo "$l:$r->val\n"; + else + echo "$l:\n"; + + +} +?> diff --git a/admin/settranslation.php b/admin/settranslation.php new file mode 100644 index 0000000..40e31fe --- /dev/null +++ b/admin/settranslation.php @@ -0,0 +1,40 @@ + + Copyright (C) 2005 James Grant + + 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. +*/ +?> +$ln) +{ + if($l=="en") continue; + + //check if it exists; + $q=mysql_query("SELECT * FROM translations WHERE lang='$l' AND strmd5='".md5($_GET['str'])."'"); + if(mysql_num_rows($q)) + mysql_query("UPDATE translations SET val='".mysql_escape_string(stripslashes($_GET[$l]))."' WHERE lang='$l' AND strmd5='".md5($_GET['str'])."'"); + else + mysql_query("INSERT INTO translations (lang,strmd5,str,val) VALUES ('$l','".md5($_GET['str'])."','".mysql_escape_string(stripslashes($_GET['str']))."','".mysql_escape_string(stripslashes($_GET[$l]))."')"); + + +} +?> diff --git a/common.inc.php b/common.inc.php index 138f9a1..2792ebb 100644 --- a/common.inc.php +++ b/common.inc.php @@ -392,6 +392,13 @@ function confirmChanges() --> + +