Skip to content

Commit

Permalink
Fixed language issues while survey taking
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@12014 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Jan 12, 2012
1 parent 7a2cfff commit 75bb260
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 53 deletions.
14 changes: 13 additions & 1 deletion application/controllers/InstallerController.php
Expand Up @@ -139,14 +139,26 @@ private function stepWelcome()
Yii::app()->session['installerLang'] = $_POST['installerLang'];
$this->redirect($this->createUrl('installer/license'));
}
$this->loadHelper('surveytranslator');

$aData['clang'] = $clang = $this->lang;
$aData['title'] = $clang->gT('Welcome');
$aData['descp'] = $clang->gT('Welcome to the LimeSurvey installation wizard. This wizard will guide you through the installation, database setup and initial configuration of LimeSurvey.');
$aData['classesForStep'] = array('on','off','off','off','off','off');
$aData['progressValue'] = 0;

$this->loadHelper('surveytranslator');
if (isset(Yii::app()->session['installerLang']))
{
$currentLanguage=Yii::app()->session['installerLang'];
}
else
$currentLanguage='en';

foreach(getLanguageData(true, $currentLanguage) as $langkey => $languagekind)
{
$languages[htmlspecialchars($langkey)] = sprintf('%s - %s', $languagekind['nativedescription'], $languagekind['description']);
}
$aData['languages']=$languages;
$this->render('/installer/welcome_view',$aData);
}

Expand Down
4 changes: 2 additions & 2 deletions application/controllers/admin/globalsettings.php
Expand Up @@ -68,7 +68,7 @@ private function _displaySettings()
$data['updatelastcheck'] = Yii::app()->getConfig("updatelastcheck");
$data['updateavailable'] = Yii::app()->getConfig("updateavailable");
$data['updateinfo'] = Yii::app()->getConfig("updateinfo");
$data['allLanguages'] = getLanguageData();
$data['allLanguages'] = getLanguageData(false, Yii::app()->session['adminlang']);
if (trim(Yii::app()->getConfig('restrictToLanguages')) == '') {
$data['restrictToLanguages'] = array_keys($data['allLanguages']);
$data['excludedLanguages'] = array();
Expand Down Expand Up @@ -100,7 +100,7 @@ private function _saveSettings()
}

$aRestrictToLanguages = explode(' ', sanitize_languagecodeS($_POST['restrictToLanguages']));
if (count(array_diff(array_keys(getLanguageData()), $aRestrictToLanguages)) == 0) {
if (count(array_diff(array_keys(getLanguageData(false,Yii::app()->session['adminlang'])), $aRestrictToLanguages)) == 0) {
$aRestrictToLanguages = '';
} else {
$aRestrictToLanguages = implode(' ', $aRestrictToLanguages);
Expand Down
8 changes: 4 additions & 4 deletions application/controllers/admin/translate.php
Expand Up @@ -56,7 +56,7 @@ public function index()
$survey_title = $surveyinfo['name'];

Yii::app()->loadHelper("surveytranslator");
$supportedLanguages = getLanguageData(FALSE);
$supportedLanguages = getLanguageData(FALSE,Yii::app()->session['adminlang']);

$baselangdesc = $supportedLanguages[$baselang]['description'];

Expand Down Expand Up @@ -373,7 +373,7 @@ private function _getLanguageList($surveyid, $tolang)
$clang = Yii::app()->lang;

$langs = Survey::model()->findByPk($surveyid)->additionalLanguages;
$supportedLanguages = getLanguageData(FALSE);
$supportedLanguages = getLanguageData(FALSE,Yii::app()->session['adminlang']);

$language_list .= CHtml::openTag('div', array('class'=>'menubar-right')); // Opens .menubar-right div
$language_list .= CHtml::tag('label', array('for'=>'translationlanguage'), $clang->gT("Translate to") . ":");
Expand Down Expand Up @@ -772,7 +772,7 @@ private function query($type, $action, $surveyid, $tolang, $baselang, $id1 = "",
case 'group':
case 'group_desc':
return Groups::model()->findAllByAttributes(array('sid'=>$surveyid, 'language'=>$baselang), array('order' => 'gid'));
case 'question':
case 'question':
case 'question_help':
return Questions::model()->findAllByAttributes(array('sid' => $surveyid,'language' => $baselang,'parent_qid' => 0), array('order' => 'qid'));
case 'subquestion':
Expand Down Expand Up @@ -815,7 +815,7 @@ private function query($type, $action, $surveyid, $tolang, $baselang, $id1 = "",
return Groups::model()->updateByPk(array('gid'=>$id1, 'language'=>$tolang),array('group_name' => $new), 'sid=:sid', array(':sid'=>$surveyid));
case 'group_desc':
return Groups::model()->updateByPk(array('gid'=>$id1, 'language'=>$tolang),array('description' => $new), 'sid=:sid', array(':sid'=>$surveyid));
case 'question':
case 'question':
return Questions::model()->updateByPk(array('qid'=>$id1, 'language'=>$tolang),array('question' => $new), 'sid=:sid AND parent_qid=0', array(':sid'=>$surveyid));
case 'question_help':
return Questions::model()->updateByPk(array('qid'=>$id1, 'language'=>$tolang),array('help' => $new), 'sid=:sid AND parent_qid=0', array(':sid'=>$surveyid));
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/frontend_helper.php
Expand Up @@ -275,7 +275,7 @@ function makelanguagechanger($baselang)
$defaultlang = Yii::app()->getConfig("defaultlang");
$htmlcode = "<select name=\"select\" class='languagechanger' onchange=\"javascript:window.location=this.value\">\n";
$htmlcode .= "<option value=\"".Yii::app()->getController()->createUrl("/survey/index")."?lang=". $defaultlang ."$tokenparam\">".getLanguageNameFromCode($defaultlang,false)."</option>\n";
foreach(getlanguagedataRestricted() as $key=>$val)
foreach(getLanguageDataRestricted() as $key=>$val)
{
$htmlcode .= "\t<option value=\"".Yii::app()->getController()->createUrl("/survey/index")."?lang=".$key."$tokenparam\" ";
if($key == $baselang)
Expand Down
52 changes: 20 additions & 32 deletions application/helpers/surveytranslator_helper.php
@@ -1,17 +1,17 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
* LimeSurvey
* Copyright (C) 2007-2011 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id$
*/
/*
* LimeSurvey
* Copyright (C) 2007-2011 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id$
*/


/*
Expand Down Expand Up @@ -59,21 +59,9 @@ function getDateFormatData($format=0)

}

function getLanguageData($orderbynative=false,$installer=false) {
function getLanguageData($orderbynative=false,$sLanguageCode='en') {

if ($installer)
{
$lang = Yii::app()->getConfig("installerLang");
if (!$lang)
{
$lang = "en";
}
$clang = new Limesurvey_lang($lang);
}
else
{
$clang = new Limesurvey_lang(Yii::app()->session['adminlang']);
}
$clang = new Limesurvey_lang($sLanguageCode);

static $supportedLanguages;
static $result = array();
Expand Down Expand Up @@ -692,7 +680,7 @@ function bCanShowDatePicker($dateformatdetails, $dateformats=null)

function getLanguageCodefromLanguage($languagetosearch)
{
$detaillanguages = getLanguageData();
$detaillanguages = getLanguageData(false,Yii::app()->session['adminlang']);
foreach ($detaillanguages as $key2=>$languagename)
{
if ($languagetosearch==$languagename['description'])
Expand All @@ -709,7 +697,7 @@ function getLanguageCodefromLanguage($languagetosearch)

function getLanguageNameFromCode($codetosearch, $withnative=true)
{
$detaillanguages = getLanguageData();
$detaillanguages = getLanguageData(false,Yii::app()->session['adminlang']);
if (isset($detaillanguages[$codetosearch]['description']))
{
if ($withnative) {
Expand All @@ -725,7 +713,7 @@ function getLanguageNameFromCode($codetosearch, $withnative=true)

function getLanguageRTL($codetosearch)
{
$detaillanguages = getLanguageData();
$detaillanguages = getLanguageData(false,Yii::app()->session['adminlang']);
if (isset($detaillanguages[$codetosearch]['rtl']))
{
return $detaillanguages[$codetosearch]['rtl'];
Expand All @@ -745,7 +733,7 @@ function getLanguageRTL($codetosearch)
*/
function getLanguageDetails($codetosearch)
{
$detaillanguages = getLanguageData();
$detaillanguages = getLanguageData(false,Yii::app()->session['adminlang']);
if (isset($detaillanguages[$codetosearch]))
{
return $detaillanguages[$codetosearch];
Expand All @@ -767,7 +755,7 @@ function getLanguageDataRestricted($orderbynative=false) {
}
else
{
$aArray=$aLanguageData;
$aArray=$aLanguageData;
}
return $aArray;
}
Expand Down
2 changes: 1 addition & 1 deletion application/models/InstallerConfigForm.php
Expand Up @@ -75,7 +75,7 @@ public function rules()
//Optional
array('adminLoginName, adminName, siteName, confirmPwd', 'safe', 'on' => 'optional'),
array('adminEmail', 'email', 'on' => 'optional'),
array('surveylang', 'in', 'range' => array_keys(getlanguagedata(true, true)), 'on' => 'optional'),
array('surveylang', 'in', 'range' => array_keys(getLanguageData(true, Yii::app()->getConfig("installerLang"))), 'on' => 'optional'),
array('adminLoginPwd', 'compare', 'compareAttribute' => 'confirmPwd', 'message' => Yii::app()->getController()->lang->gT('Passwords do not match!'), 'strict' => true, 'on' => 'optional'),
);
}
Expand Down
2 changes: 1 addition & 1 deletion application/views/admin/labels/editlabel_view.php
Expand Up @@ -36,7 +36,7 @@


<td align='left'><select size='5' style='min-width:220px;' id='available_languages' name='available_languages'>
<?php foreach (getLanguageData() as $langkey=>$langname)
<?php foreach (getLanguageData(false, Yii::app()->session['adminlang']) as $langkey=>$langname)
{
if (in_array($langkey,$langidsarray)==false) // base languag must not be shown here
{ ?>
Expand Down
Expand Up @@ -22,7 +22,7 @@
/* Build the options for additional languages */
$j = 1;
$lang = '{ "name":"language", "index":"language", "sorttype":"string", "sortable": true, "align":"center", "editable":true, "edittype":"select", "editoptions":{ "value":"';
$getlangvalues = getLanguageData();
$getlangvalues = getLanguageData(false, Yii::app()->session['adminlang']);
if (Yii::app()->session['adminlang'] != 'auto')
{
$lname[0] = Yii::app()->session['adminlang'] . ":" . $getlangvalues[Yii::app()->session['adminlang']]['description'];
Expand Down
Expand Up @@ -22,7 +22,7 @@
<?php
$options = array();
$options[''] = $clang->gT('Select...');
foreach (getLanguageData() as $langkey2 => $langname)
foreach (getLanguageData(false, Yii::app()->session['adminlang']) as $langkey2 => $langname)
{
$options[$langkey2] = $langname['description'];
}
Expand Down
Expand Up @@ -35,7 +35,7 @@

<td align='left'><select size='5' style='min-width:220px;' id='available_languages' name='available_languages'>
<?php $tempLang=Survey::model()->findByPk($surveyid)->additionalLanguages;
foreach (getLanguageDataRestricted () as $langkey2 => $langname) {
foreach (getLanguageDataRestricted (false, Yii::app()->session['adminlang']) as $langkey2 => $langname) {
if ($langkey2 != $esrow['language'] && in_array($langkey2, $tempLang) == false) { // base languag must not be shown here ?>
<option id='<?php echo $langkey2 ; ?>' value='<?php echo $langkey2; ?>'>
<?php echo $langname['description']; ?></option>
Expand Down
Expand Up @@ -3,7 +3,7 @@
<li>
<label for='language' title='<?php $clang->eT("This is the base language of your survey and it can't be changed later. You can add more languages after you have created the survey."); ?>'><span class='annotationasterisk'>*</span><?php $clang->eT("Base language:"); ?></label>
<select id='language' name='language'>
<?php foreach (getLanguageDataRestricted () as $langkey2 => $langname) { ?>
<?php foreach (getLanguageDataRestricted (false, Yii::app()->session['adminlang']) as $langkey2 => $langname) { ?>
<option value='<?php echo $langkey2; ?>'
<?php if (Yii::app()->getConfig('defaultlang') == $langkey2) { ?>
selected='selected'
Expand Down
2 changes: 1 addition & 1 deletion application/views/admin/token/browse.php
Expand Up @@ -2,7 +2,7 @@
$uidNames = array();
/* Build the options for additional languages */
$j = 1;
$getlangvalues = getLanguageData();
$getlangvalues = getLanguageData(false,Yii::app()->session['adminlang']);
if (Yii::app()->session['adminlang'] != 'auto')
{
$lname[0] = Yii::app()->session['adminlang'] . ":" . $getlangvalues[Yii::app()->session['adminlang']]['description'];
Expand Down
2 changes: 1 addition & 1 deletion application/views/admin/user/personalsettings.php
Expand Up @@ -11,7 +11,7 @@
<option value='auto'<?php if ($sSavedLanguage == 'auto') { echo " selected='selected'"; } ?>>
<?php $clang->eT("(Autodetect)"); ?>
</option>
<?php foreach (getlanguagedata(true) as $langkey => $languagekind)
<?php foreach (getLanguageData(true, Yii::app()->session['adminlang']) as $langkey => $languagekind)
{ ?>
<option value='<?php echo $langkey; ?>'<?php if ($langkey == $sSavedLanguage) {
echo " selected='selected'";
Expand Down
2 changes: 1 addition & 1 deletion application/views/installer/optconfig_view.php
Expand Up @@ -65,7 +65,7 @@
</td>
<td align="right">
<?php
foreach(getlanguagedata(true, true) as $langkey => $languagekind)
foreach(getLanguageData(true, Yii::app()->getConfig("installerLang")) as $langkey => $languagekind)
{
$languages[htmlspecialchars($langkey)] = sprintf('%s - %s', $languagekind['nativedescription'], $languagekind['description']);
}
Expand Down
4 changes: 0 additions & 4 deletions application/views/installer/welcome_view.php
Expand Up @@ -25,10 +25,6 @@
</td>
<td align="right">
<?php
foreach(getlanguagedata(true, true) as $langkey => $languagekind)
{
$languages[htmlspecialchars($langkey)] = sprintf('%s - %s', $languagekind['nativedescription'], $languagekind['description']);
}
echo CHtml::dropDownList('installerLang', 'en', $languages, array('style' => 'width: 190px', 'id' => 'installerLang', 'encode' => false));
?>
</td>
Expand Down

0 comments on commit 75bb260

Please sign in to comment.