Fix translations for awards and award prizes

Also fix translations editor when the first language has an accent
This commit is contained in:
james 2010-03-03 19:25:19 +00:00
parent 217ce8e175
commit 6def9680bc
3 changed files with 21 additions and 11 deletions

View File

@ -31,6 +31,11 @@
$id = intval($_GET['id']);
$q=mysql_query("SELECT * FROM award_awards WHERE id='$id'");
$ret = mysql_fetch_assoc($q);
//json_encode NEEDS UTF8 DATA, but we store it in the database as ISO :(
foreach($ret AS $k=>$v) {
$ret[$k]=iconv("ISO-8859-1","UTF-8",$v);
}
//echo iconv("ISO-8859-1","UTF-8",json_encode($ret));
echo json_encode($ret);
exit;
@ -57,18 +62,18 @@
$q = "UPDATE award_awards SET
award_types_id='".intval($_POST['award_types_id'])."',
presenter='".mysql_escape_string(stripslashes($_POST['presenter']))."',
presenter='".mysql_escape_string(iconv("UTF-8","ISO-8859-1",stripslashes($_POST['presenter'])))."',
excludefromac='".(($_POST['excludefromac'] == 1) ? 1 : 0)."',
cwsfaward='".(($_POST['cwsfaward'] == 1) ? 1 : 0)."',
self_nominate='".(($_POST['self_nominate'] == 'yes') ? 'yes' : 'no')."',
schedule_judges='".(($_POST['schedule_judges'] == 'yes') ? 'yes' : 'no')."',
description='".mysql_escape_string(stripslashes($_POST['description']))."' ";
description='".mysql_escape_string(iconv("UTF-8","ISO-8859-1",stripslashes($_POST['description'])))."' ";
if(array_key_exists('name', $_POST)) {
/* These values may be disabled, if they name key exists, assume
* they aren't disabled and save them too */
$q .= ",name='".mysql_escape_string(stripslashes($_POST['name']))."',
criteria='".mysql_escape_string(stripslashes($_POST['criteria']))."',
$q .= ",name='".mysql_escape_string(iconv("UTF-8","ISO-8859-1",stripslashes($_POST['name'])))."',
criteria='".mysql_escape_string(iconv("UTF-8","ISO-8859-1",stripslashes($_POST['criteria'])))."',
sponsors_id='".intval($_POST['sponsors_id'])."' ";
}
$q .= "WHERE id='$id'";
@ -157,6 +162,9 @@
$q = mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='$id' ORDER BY `order`");
}
while($r=mysql_fetch_assoc($q)) {
foreach($r AS $k=>$v) {
$r[$k]=iconv("ISO-8859-1","UTF-8",$v);
}
$ret[] = $r;
}
echo json_encode($ret);
@ -165,6 +173,9 @@
$id = intval($_GET['id']);
$q = mysql_query("SELECT * FROM award_prizes WHERE id='$id'");
$ret=mysql_fetch_assoc($q);
foreach($ret AS $k=>$v) {
$ret[$k]=iconv("ISO-8859-1","UTF-8",$v);
}
echo json_encode($ret);
exit;
@ -183,7 +194,7 @@
case 'prize_save':
$id = intval($_POST['id']);
$q="UPDATE award_prizes SET
prize='".mysql_escape_string(stripslashes($_POST['prize']))."',
prize='".mysql_escape_string(stripslashes(iconv("UTF-8","ISO-8859-1",$_POST['prize'])))."',
cash='".intval($_POST['cash'])."',
scholarship='".intval($_POST['scholarship'])."',
value='".intval($_POST['value'])."',

View File

@ -28,10 +28,9 @@ user_auth_required('committee', 'admin');
$ret=array();
foreach($config['languages'] AS $l=>$ln) {
if($l==$config['default_language']) continue;
$q=mysql_query("SELECT * FROM translations WHERE lang='$l' AND strmd5='".md5($_GET['str'])."'");
$q=mysql_query("SELECT * FROM translations WHERE lang='$l' AND strmd5='".md5(iconv("ISO-8859-1","UTF-8",$_GET['str']))."'");
if($r=mysql_fetch_object($q))
$ret[$l]=$r->val;
$ret[$l]=iconv("ISO-8859-1","UTF-8",$r->val);
else
$ret[$l]="";
}

View File

@ -25,7 +25,6 @@
include "../common.inc.php";
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
print_r($_POST);
foreach($config['languages'] AS $l=>$ln) {
if($l==$config['default_language']) continue;
@ -35,13 +34,14 @@ foreach($config['languages'] AS $l=>$ln) {
if($_POST['translate_'.$l]) {
$q=mysql_query("SELECT * FROM translations WHERE lang='$l' AND strmd5='$m'");
if(mysql_num_rows($q))
mysql_query("UPDATE translations SET val='".mysql_real_escape_string(stripslashes($_POST['translate_'.$l]))."' WHERE lang='$l' AND strmd5='$m'");
mysql_query("UPDATE translations SET val='".mysql_real_escape_string(iconv("UTF-8","ISO-8859-1",stripslashes($_POST['translate_'.$l])))."' WHERE lang='$l' AND strmd5='$m'");
else
mysql_query("INSERT INTO translations (lang,strmd5,str,val) VALUES ('$l','$m','".mysql_real_escape_string(stripslashes($_POST['translate_str_hidden']))."','".mysql_escape_string(stripslashes($_POST['translate_'.$l]))."')");
mysql_query("INSERT INTO translations (lang,strmd5,str,val) VALUES ('$l','$m','".mysql_real_escape_string(iconv("UTF-8","ISO-8859-1",stripslashes($_POST['translate_str_hidden'])))."','".mysql_escape_string(iconv("UTF-8","ISO-8859-1",stripslashes($_POST['translate_'.$l])))."')");
}
else {
mysql_query("DELETE FROM translations WHERE lang='$l' AND strmd5='$m'");
}
}
echo "ok";
?>