2006-01-19 01:58:37 +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 >
2008-10-30 17:57:05 +00:00
Copyright ( C ) 2008 James Grant < james @ lightbox . org >
2006-01-19 01:58:37 +00:00
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 .
*/
?>
< ?
require ( " ../common.inc.php " );
2007-11-21 17:02:09 +00:00
require_once ( " ../user.inc.php " );
2010-07-13 03:30:17 +00:00
user_auth_required ( 'admin' );
2006-01-19 01:58:37 +00:00
2007-11-18 23:50:23 +00:00
send_header ( " Translations " ,
array ( 'Committee Main' => 'committee_main.php' ,
2008-08-22 20:50:38 +00:00
'Administration' => 'admin/index.php' ),
" translations_management "
2007-11-18 23:50:23 +00:00
);
2006-01-19 01:58:37 +00:00
2006-01-19 17:15:07 +00:00
//by default, we will edit the french translations
if ( $_GET [ 'translang' ]) $_SESSION [ 'translang' ] = $_GET [ 'translang' ];
if ( ! $_SESSION [ 'translang' ])
$_SESSION [ 'translang' ] = " fr " ;
2006-01-19 01:58:37 +00:00
if ( $_GET [ 'show' ]) $show = $_GET [ 'show' ];
else if ( $_POST [ 'show' ]) $show = $_POST [ 'show' ];
if ( ! $show ) $show = " missing " ;
2008-10-30 17:57:05 +00:00
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 " ));
}
2006-01-19 01:58:37 +00:00
}
2006-01-19 17:15:07 +00:00
echo " <table> " ;
echo " <tr><td> " ;
echo i18n ( " Choose a language to manage translations for " );
echo " </td><td> " ;
echo " <form name= \" langswitch \" method= \" get \" action= \" translations.php \" > " ;
echo " <select name= \" translang \" onchange= \" document.forms.langswitch.submit() \" > " ;
$q = mysql_query ( " SELECT * FROM languages WHERE lang!='en' " );
while ( $r = mysql_fetch_object ( $q ))
{
if ( $_SESSION [ 'translang' ] == $r -> lang ){ $sel = " selected= \" selected \" " ; $translangname = $r -> langname ;} else $sel = " " ;
echo " <option $sel value= \" $r->lang\ " > $r -> langname </ option > " ;
}
echo " </select> " ;
echo " </form> " ;
echo " </td></tr> " ;
echo " </table> " ;
2008-10-30 17:57:05 +00:00
if ( $show == " missing " ) {
2006-01-19 01:58:37 +00:00
echo i18n ( " Show missing translations " );
echo " | " ;
echo " <a href= \" translations.php?show=all \" > " . i18n ( " Show all translations " ) . " </a> " ;
}
2008-10-30 17:57:05 +00:00
else {
2006-01-19 01:58:37 +00:00
echo " <a href= \" translations.php?show=missing \" > " . i18n ( " Show missing translations " ) . " </a> " ;
echo " | " ;
echo i18n ( " Show all translations " );
}
2006-01-19 17:15:07 +00:00
2006-01-19 01:58:37 +00:00
echo " <br /> " ;
echo " <br /> " ;
echo i18n ( " Instructions: Enter the translation below the string and click Save. Only one translation can be saved at a time. The terms %1, %2, etc get substituded with various arguments to the string, so they must appear in the translation if they are in the original string. " );
echo " <br /> " ;
echo " <br /> " ;
2006-01-19 17:15:07 +00:00
if ( $show == " missing " ) $showquery = " AND ( val is null OR val='' ) " ;
2006-01-19 01:58:37 +00:00
else $showquery = " " ;
2006-01-19 17:15:07 +00:00
$q = mysql_query ( " SELECT * FROM translations WHERE lang=' " . $_SESSION [ 'translang' ] . " ' $showquery ORDER BY str " );
2006-01-19 01:58:37 +00:00
$num = mysql_num_rows ( $q );
2006-01-19 17:15:07 +00:00
echo i18n ( " Showing %1 translation strings " , array ( $num ), array ( " number of strings " ));
2006-01-19 01:58:37 +00:00
2008-10-30 17:57:05 +00:00
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 >
< ?
2006-01-19 01:58:37 +00:00
echo " <table class= \" tableedit \" > " ;
2008-10-30 17:57:05 +00:00
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 " ;
2006-01-19 01:58:37 +00:00
while ( $r = mysql_fetch_object ( $q ))
{
echo " <tr> " ;
2008-11-03 02:11:52 +00:00
echo " <td valign= \" top \" rowspan= \" 2 \" > " ;
2008-10-30 17:57:05 +00:00
echo " <input type= \" checkbox \" name= \" delete[] \" value= \" $r->strmd5\ " > \n " ;
echo " </td><td> " ;
2006-01-19 17:15:07 +00:00
echo htmlspecialchars ( $r -> str );
if ( $r -> argsdesc )
echo " <br /><i> " . i18n ( " Arguments: " ) . " $r->argsdesc </i> " ;
echo " </td> " ;
2006-01-19 01:58:37 +00:00
echo " </tr> " ;
echo " <tr> " ;
2008-10-30 17:57:05 +00:00
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> " ;
2006-01-19 01:58:37 +00:00
echo " </tr> " ;
}
echo " </table> " ;
2008-10-30 17:57:05 +00:00
echo " <input type= \" submit \" value= \" " . i18n ( " Save " ) . " \" > " ;
echo " </form> \n " ;
2006-01-19 01:58:37 +00:00
send_footer ();
?>