Skip to content

Commit

Permalink
gettext-changes.
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/phpsurveyor@1803 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Jul 28, 2006
1 parent 70fae4d commit c99cdc2
Show file tree
Hide file tree
Showing 42 changed files with 5,769 additions and 199 deletions.
6 changes: 3 additions & 3 deletions admin/dataentry.php
Expand Up @@ -80,7 +80,7 @@

if ($action == "edit" || $action == "" || $action == "editsaved")
{
loadPublicLangFile($surveyid);
GetLanguageFromSurveyID($surveyid);
}

if ($action == "insert")
Expand All @@ -93,7 +93,7 @@
if (isset($_POST['save']) && $_POST['save'] == "on")
{
//Save this, don't submit to final response table
loadPublicLangFile($surveyid);
GetLanguageFromSurveyID($surveyid);
$saver['identifier']=returnglobal('save_identifier');
$saver['password']=returnglobal('save_password');
$saver['passwordconfirm']=returnglobal('save_confirmpassword');
Expand Down Expand Up @@ -1336,7 +1336,7 @@ function saveshow(value)
.$surveyoptions
."</table>";

loadPublicLangFile($surveyid);
GetLanguageFromSurveyID($surveyid);
$thissurvey=getSurveyInfo($surveyid);
$surveytable = "{$dbprefix}survey_$surveyid";

Expand Down
1 change: 1 addition & 0 deletions admin/export.php
Expand Up @@ -332,6 +332,7 @@
$query = "SELECT language FROM {$dbprefix}surveys WHERE sid=$surveyid";
$result = db_execute_assoc($query);
while ($row=$result->FetchRow()) {$surveylanguage = $row['language'];}

bindtextdomain($surveylanguage, dirname(__FILE__).'/locale');
textdomain($surveylanguage);

Expand Down
8 changes: 4 additions & 4 deletions admin/html.php
Expand Up @@ -103,7 +103,7 @@
foreach (getlanguagedata() as $langkey=>$languagekind)
{
$cssummary .= "\t\t\t\t<option value='$langkey'";
if ($langkey == $currentlang) {$cssummary .= " selected";}
if ($langkey == $_SESSION['adminlang']) {$cssummary .= " selected";}
$cssummary .= ">".$languagekind['description']."</option>\n";
}
$cssummary .= "\t\t\t</select>\n"
Expand Down Expand Up @@ -466,7 +466,7 @@
. "\t\t<td>$setfont {$s1row['template']}</font></td></tr>\n"
. "\t<tr $showstyle id='surveydetails8'><td align='right' valign='top'>$setfont<strong>"
. _("Language:")."</strong></font></td>\n";
if (!$s1row['language']) {$language=$currentlang;} else {$language=$s1row['language'];}
if (!$s1row['language']) {$language=$currentadminlang;} else {$language=$s1row['language'];}
if ($s1row['urldescrip']==""){$s1row['urldescrip']=$s1row['url'];}
$surveysummary .= "\t\t<td>$setfont$language</font></td></tr>\n"
. "\t<tr $showstyle id='surveydetails9'><td align='right' valign='top'>$setfont<strong>"
Expand Down Expand Up @@ -1801,7 +1801,7 @@
$editsurvey .= "\t\t\t<option value='".$langkey2."'";
if ($esrow['language'] && $esrow['language'] == htmlspecialchars($langname['description'])) {$editsurvey .= " selected";}
// if language has been renamed then default to DefaultLanguage
if (!$esrow['language'] && $currentlang && $currentlang == $langname) {$editsurvey .= " selected";}
if (!$esrow['language'] && $currentadminlang && $currentadminlang == $langname) {$editsurvey .= " selected";}
$editsurvey .= ">".$langname['description']."</option>\n";
}
$editsurvey .= "\t\t</select></td>\n"
Expand Down Expand Up @@ -2004,7 +2004,7 @@
foreach ($languages as $langkey2=>$langname)
{
$newsurvey .= "\t\t\t<option value='".$langkey2."'";
// if ($currentlang && $currentlang == $langname) {$newsurvey .= " selected";}
// if ($currentadminlang && $currentadminlang == $langname) {$newsurvey .= " selected";}
$newsurvey .= ">".$langname['description']."</option>\n";
}
}
Expand Down
8 changes: 4 additions & 4 deletions admin/navigator.php
Expand Up @@ -1188,7 +1188,7 @@ function showPreview($surveyid, $gid, $qid=null) {
if ($qid !== null) {
$thisquestion=getQuestionInfo($qid);
}
loadPublicLangFile($surveyid);
GetLanguageFromSurveyID($surveyid);
$ia=array($qid,
"DUMMY",
$thisquestion['title'],
Expand Down Expand Up @@ -1271,7 +1271,7 @@ function showPreview($surveyid, $gid, $qid=null) {

function checkSettings($dbprefix) {
//GET NUMBER OF SURVEYS
global $currentlang, $databasename, $currentlang, $scriptname, $homeurl, $imagefiles, $connect;
global $currentadminlang, $databasename, $currentadminlang, $scriptname, $homeurl, $imagefiles, $connect;

$query = "SELECT sid FROM {$dbprefix}surveys";
$result = $connect->Execute($query);
Expand Down Expand Up @@ -1318,7 +1318,7 @@ function checkSettings($dbprefix) {
</tr>
<tr>
<td align='right'><strong>"._("Default Language").":</strong></td>
<td>$currentlang</td>
<td>$currentadminlang</td>
</tr>
<tr>
<td align='right'><strong>"._("Current Language").":</strong></td>
Expand All @@ -1327,7 +1327,7 @@ function checkSettings($dbprefix) {
<select name='lang' onChange='form.submit()'>\n";
foreach (getadminlanguages() as $language)
{
echo "\t\t\t\t<option value='$language'".autoComparitor($currentlang, $language, " selected").">$language</option>\n";
echo "\t\t\t\t<option value='$language'".autoComparitor($currentadminlang, $language, " selected").">$language</option>\n";
}
echo " </select>
<input type='hidden' name='action' value='changelang'></td>
Expand Down
2 changes: 1 addition & 1 deletion admin/printablesurvey.php
Expand Up @@ -50,7 +50,7 @@
if (!is_dir($thistpl)) {$thistpl=$tpldir."/default";}
$langdir="$publicdir/lang";
$langfilename="$langdir/$surveylanguage.lang.php";
if (!is_file($langfilename)) {$langfilename="$langdir/$currentlang.lang.php";}
if (!is_file($langfilename)) {$langfilename="$langdir/$currentadminlang.lang.php";}
require($langfilename);

sendcacheheaders();
Expand Down
2 changes: 1 addition & 1 deletion admin/results.php
Expand Up @@ -327,7 +327,7 @@ function giveMeRawDataFromFieldNames($surveyid, $gid, $qid, $fieldlimiters=array
}
// echo "[$questiontype]<br />";
if ($output == "full") {
loadPublicLangFile($surveyid);
GetLanguageFromSurveyID($surveyid);
//echo "<pre>"; print_r($answers); echo "</pre>";
switch($questiontype) {
case "L":
Expand Down
13 changes: 9 additions & 4 deletions admin/sessioncontrol.php
Expand Up @@ -40,11 +40,16 @@
session_name("PHPSurveyorAdmin");
session_start();



//LANGUAGE ISSUES
if (returnglobal('action') == "changelang")
{
$_SESSION['lang']=returnglobal('lang');
$_SESSION['adminlang']=SetInterfaceLanguage(returnglobal('lang'));
}
//CHANGE LANGUAGE IF SESSION LANG DOESN'T MATCH DEFAULT LANG
if (isset($_SESSION['lang'])) {$currentlang=$_SESSION['lang'];}
?>
elseif (!isset($_SESSION['adminlang']) || $_SESSION['adminlang']=='' )
{
$_SESSION['adminlang']=SetInterfaceLanguage($defaultlang);
}

?>
2 changes: 1 addition & 1 deletion admin/statistics.php
Expand Up @@ -112,7 +112,7 @@ function show(element) {
while ($row=$result->FetchRow()) {$surveylanguage = $row['language']; $datestamp=$row['datestamp'];}
$langdir="$publicdir/lang";
$langfilename="$langdir/$surveylanguage.lang.php";
if (!is_file($langfilename)) {$langfilename="$langdir/$currentlang.lang.php";}
if (!is_file($langfilename)) {$langfilename="$langdir/$currentadminlang.lang.php";}
require($langfilename);

// 1: Get list of questions from survey
Expand Down
2 changes: 1 addition & 1 deletion admin/templates.php
Expand Up @@ -657,7 +657,7 @@ function doreplacement($file) { //Produce sample page from template file
fwrite($fnew, $line);
}
fclose($fnew);
$langdir_template="$homeurl/lang/$currentlang";
$langdir_template="$homeurl/lang/$currentadminlang";
echo "<br />\n"
."<iframe src='$tempurl/template_temp_$time.html' width='95%' height='400' name='sample' style='background-color: white'>Embedded Frame</iframe>\n"
."<br />&nbsp;<br />"
Expand Down
2 changes: 1 addition & 1 deletion admin/vvexport.php
Expand Up @@ -83,7 +83,7 @@
$fieldmap=createFieldMap($surveyid, "full");
$surveytable = "{$dbprefix}survey_$surveyid";

loadPublicLangFile($surveyid);
GetLanguageFromSurveyID($surveyid);

$fieldnames = array_values($connect->MetaColumnNames($surveytable, true));

Expand Down
20 changes: 14 additions & 6 deletions common.php
Expand Up @@ -131,7 +131,7 @@
//SET LANGUAGE DIRECTORY
if ($sourcefrom == "admin")
{
$langdir="$publicurl/locale/$currentlang/help";
$langdir="$publicurl/locale/".$_SESSION['adminlang']."/help";
if (!is_dir($langdir))
{
$langdir="$publicurl/locale/en/help"; //default to english if there is no matching language dir
Expand Down Expand Up @@ -988,9 +988,9 @@ function sendcacheheaders()
{
global $embedded;
if ( $embedded ) return;
global $currentlang, $thissurvey;
global $currentadminlang, $thissurvey;
if (isset($thissurvey['language'])) {$language=$thissurvey['language'];}
else {$language=$currentlang;} //$thissurvey['language'] will exist if this is a public survey
else {$language=$currentadminlang;} //$thissurvey['language'] will exist if this is a public survey
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
Expand Down Expand Up @@ -1204,7 +1204,7 @@ function createFieldMap($surveyid, $style="null") {
//This function generates an array containing the fieldcode, and matching data in the same
//order as the activate script
global $dbprefix, $connect;
loadPublicLangFile($surveyid);
GetLanguageFromSurveyID($surveyid);
//Check for any additional fields for this survey and create necessary fields (token and datestamp and ipaddr)
$pquery = "SELECT private, datestamp, ipaddr, refurl FROM ".db_table_name('surveys')." WHERE sid=$surveyid";
$presult=db_execute_assoc($pquery);
Expand Down Expand Up @@ -1687,16 +1687,24 @@ function getSavedCount($surveyid)
return $count;
}

function loadPublicLangFile($surveyid)
function GetLanguageFromSurveyID($surveyid)
{
global $connect;
//This function loads the local language file applicable to a survey
global $dbprefix, $publicdir, $currentlang;
$query = "SELECT language FROM ".db_table_name('surveys')." WHERE sid=$surveyid";
$result = db_execute_num($query) or die ("Couldn't get language file");
while ($row=$result->FetchRow()) {$surveylanguage = $row[0];}
return $surveylanguage;
}

function SetInterfaceLanguage($languagetoset)
{
bindtextdomain($languagetoset, dirname(__FILE__).'/locale');
textdomain($languagetoset);
return $languagetoset;
}


function buildLabelsetCSArray()
{
global $dbprefix, $connect;
Expand Down
2 changes: 1 addition & 1 deletion config.php
Expand Up @@ -89,7 +89,7 @@
// Only applicable, of course, if you have chosen "R" for $dropdowns and/or $lwcdropdowns
$repeatheadings = "25"; // The number of answers to show before repeating the headings in array (flexible) questions. Set to 0 to turn this feature off
$minrepeatheadings = 3; // The minimum number of remaing answers that are required before repeating the headings in array (flexible) questions.
$defaultlang = "de"; // The default language to use - the available languages are the directory names in the /locale dir - for example de = German
$defaultlang = "de"; // The default language to use - the available languages are the directory names in the /locale dir - for example de = German

$OS = PHP_OS;

Expand Down
25 changes: 16 additions & 9 deletions index.php
Expand Up @@ -76,14 +76,25 @@
doFooter();
exit;
}


//Check to see if a refering URL has been captured.
getreferringurl();

if (!isset($token)) {$token=trim(returnglobal('token'));}
//GET BASIC INFORMATION ABOUT THIS SURVEY
$thissurvey=getSurveyInfo($surveyid);

if (is_array($thissurvey)) {$surveyexists=1;} else {$surveyexists=0;}

// Check if the current survey language is set - if not set it
// this way it can be changed later (for example by a special question type)
if (!isset($_SESSION['publiclang']) || ($_SESSION['publiclang']==''))
{
$_SESSION['publiclang']=SetInterfaceLanguage(GetLanguageFromSurveyID($surveyid));
}


//SEE IF SURVEY USES TOKENS
$i = 0; $tokensexist = 0;
$tablelist = $connect->MetaTables() or die ("Error getting tokens<br />".htmlspecialchars($connect->ErrorMsg()));
Expand All @@ -92,14 +103,12 @@
if ($tbl == "{$dbprefix}tokens_$surveyid") {$tokensexist = 1;}
}



//SET THE TEMPLATE DIRECTORY
if (!$thissurvey['templatedir']) {$thistpl=$tpldir."/default";} else {$thistpl=$tpldir."/{$thissurvey['templatedir']}";}
if (!is_dir($thistpl)) {$thistpl=$tpldir."/default";}

//Set the appropiate language settings for gettext

bindtextdomain($thissurvey['language'], dirname(__FILE__).'/locale');
textdomain($thissurvey['language']);


//MAKE SURE SURVEY HASN'T EXPIRED
Expand Down Expand Up @@ -321,6 +330,7 @@
// --> END NEW FEATURE - SAVE



sendcacheheaders();
//CALL APPROPRIATE SCRIPT
switch ($thissurvey['format'])
Expand Down Expand Up @@ -1003,15 +1013,12 @@ function submittokens()
else
{
//Get the default email_confirm from the default admin lang file
global $currentlang, $homedir, $homeurl;
$langdir="$homeurl/lang/$currentlang";
$langdir2="$homedir/lang/$currentlang";
global $currentadminlang, $homedir, $homeurl;
$langdir="$homeurl/lang/$currentadminlang";
if (!is_dir($langdir2))
{
$langdir="$homeurl/lang/english"; //default to english if there is no matching language dir
$langdir2="$homedir/lang/english";
}
require("$langdir2/messages.php");
$message = _("Dear {FIRSTNAME},\n\nThis email is to confirm that you have completed the survey titled {SURVEYNAME} and your response has been saved. Thank you for participating.\n\nIf you have any further questions about this email, please contact {ADMINNAME} on {ADMINEMAIL}.\n\nSincerely,\n\n{ADMINNAME}");
}

Expand Down
14 changes: 7 additions & 7 deletions locale/de/help/admin.html
Expand Up @@ -32,7 +32,7 @@
<tbody>
<tr>
<td valign="top"><small><small> <font face="Verdana"><img
src="../../images/home.gif" border="0" height="20" width="20"> </font>
src="../../../images/home.png" border="0" height="20" width="20"> </font>
</small></small></td>
<td valign="top"><small><small> <strong><font face="Verdana">Hauptseite:</font></strong><font
face="Verdana"> Klicken Sie
Expand All @@ -42,7 +42,7 @@
</tr>
<tr>
<td valign="top"><small><small> <font face="Verdana"><img
src="../../images/security.gif" border="0" height="20" width="20"> </font>
src="../../../images/security.png" border="0" height="20" width="20"> </font>
</small></small></td>
<td valign="top"><small><small> <span
style="font-family: verdana; font-weight: bold;">Sicherheit:</span><font
Expand All @@ -51,7 +51,7 @@
</tr>
<tr>
<td valign="top"><small><small> <font face="Verdana"><img
src="../../images/badsecurity.gif" border="0" height="20" width="20"> </font>
src="../../../images/badsecurity.png" border="0" height="20" width="20"> </font>
</small></small></td>
<td valign="top"><small><small>&nbsp;<span
style="font-family: verdana;"><span style="font-weight: bold;">Keine
Expand All @@ -62,7 +62,7 @@
</tr>
<tr>
<td valign="top"><small><small> <font face="Verdana"><img
src="../../images/checkdb.gif" border="0" height="20" width="20"> </font>
src="../../../images/checkdb.png" border="0" height="20" width="20"> </font>
</small></small></td>
<td valign="top"><small><small> <font style="font-weight: bold;"
face="Verdana">Datenbank
Expand All @@ -73,7 +73,7 @@
</tr>
<tr>
<td valign="top"><small><small> <font face="Verdana"><img
src="../../images/labels.gif" border="0" height="20" width="20"> </font>
src="../../../images/labels.png" border="0" height="20" width="20"> </font>
</small></small></td>
<td valign="top"><small><small> <font style="font-weight: bold;"
face="Verdana">Beschriftungssets
Expand All @@ -85,7 +85,7 @@
</tr>
<tr>
<td valign="top"><small><small> <font face="Verdana"><img
src="../../images/add.gif" border="0" height="20" width="20"> </font>
src="../../../images/add.png" border="0" height="20" width="20"> </font>
</small></small></td>
<td valign="top"><small><small> <font style="font-weight: bold;"
face="Verdana">Umfrage
Expand All @@ -103,7 +103,7 @@
<br>
<br>
<u><strong><a name="Adding a New Survey">Umfrage hinzuf&uuml;gen</a></strong></u><br>
Klicken Sie auf <img src="../../images/add.gif" border="0" height="20"
Klicken Sie auf <img src="../../../images/add.png" border="0" height="20"
width="20">
um eine neue Umfrage zu erzeugen oder zu importieren.</font> </small></small></p>
<p><small><small> <font face="Verdana">In der nun folgenden Seite
Expand Down

0 comments on commit c99cdc2

Please sign in to comment.