Skip to content

Commit

Permalink
Fixed issue #08730: Allways take default language radix separator for…
Browse files Browse the repository at this point in the history
… all s

Dev: sLEMradix is a survey settings, then put it in SurveyRuntimeHelper
Dev: Allways add 'default' settings in run, but replace it in SurveyRuntime
  • Loading branch information
Shnoulle committed Feb 20, 2014
1 parent a75997d commit e9b6e11
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 25 deletions.
24 changes: 9 additions & 15 deletions application/controllers/survey/index.php
Expand Up @@ -21,33 +21,27 @@ public function run()
* if we call exit at some point in the code. (Which we shouldn't, but
* it happens.)
*/
// Javascript Var
// Ensure to set some var, but script are replaced in SurveyRuntimeHelper
$aLSJavascriptVar=array();
$aLSJavascriptVar['bFixNumAuto']=(int)(bool)Yii::app()->getConfig('bFixNumAuto',1);
$aLSJavascriptVar['bNumRealValue']=(int)(bool)Yii::app()->getConfig('bNumRealValue',0);
if(isset($thissurvey['surveyls_numberformat']))
{
$radix=getRadixPointData($thissurvey['surveyls_numberformat']);
}
else
{
$aLangData=getLanguageData();
$radix=getRadixPointData($aLangData[ Yii::app()->getConfig('defaultlang')]['radixpoint']);// or $clang->langcode . defaultlang ensure it's same for each language ?
}
$aLSJavascriptVar['sLEMradix']=$radix['separator'];
$aLangData=getLanguageData();
$aRadix=getRadixPointData($aLangData[ Yii::app()->getConfig('defaultlang')]['radixpoint']);
$aLSJavascriptVar['sLEMradix']=$aRadix['separator'];
$sLSJavascriptVar="LSvar=".json_encode($aLSJavascriptVar) . ';';
App()->clientScript->registerScript('sLSJavascriptVar',$sLSJavascriptVar,CClientScript::POS_HEAD);
App()->clientScript->registerScript('setJsVar',"setJsVar();",CClientScript::POS_BEGIN);// Ensure all js var is set before rendering the page (User can click before $.ready)

App()->getClientScript()->registerPackage('jqueryui');
App()->getClientScript()->registerPackage('jquery-touch-punch');
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."survey_runtime.js");
useFirebug();

ob_start(function($buffer, $phase) {
App()->getClientScript()->render($buffer);
App()->getClientScript()->reset();
return $buffer;
});
App()->getClientScript()->render($buffer);
App()->getClientScript()->reset();
return $buffer;
});
ob_implicit_flush(false);
$this->action();
ob_flush();
Expand Down
31 changes: 31 additions & 0 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -177,6 +177,14 @@ function run($surveyid,$args) {
$thissurvey = getSurveyInfo($surveyid);
}
$LEMsessid = 'survey_' . $surveyid;
if (isset($_SESSION[$LEMsessid]['s_lang']))
{
$this->setJavascriptVar($surveyid, $_SESSION[$LEMsessid]['s_lang']);
}
else
{
$this->setJavascriptVar($surveyid, $thissurvey['language']);
}
$sTemplatePath=getTemplatePath(Yii::app()->getConfig("defaulttemplate")).DIRECTORY_SEPARATOR;
if (isset ($_SESSION['survey_'.$surveyid]['templatepath']))
{
Expand Down Expand Up @@ -1190,4 +1198,27 @@ function run($surveyid,$args) {
doFooter();

}
/**
* setJavascriptVar
*
*
* @return @void
* @param integer $iSurveyId : the survey id for the script
* @param string $sLanguage : the actual language for the survey
*/
public function setJavascriptVar($iSurveyId, $sLanguage)
{
$aSurveyinfo=getSurveyInfo($iSurveyId);
if(isset($aSurveyinfo['surveyls_numberformat']))
{
$aLSJavascriptVar=array();
$aLSJavascriptVar['bFixNumAuto']=(int)(bool)Yii::app()->getConfig('bFixNumAuto',1);
$aLSJavascriptVar['bNumRealValue']=(int)(bool)Yii::app()->getConfig('bNumRealValue',0);
$aRadix=getRadixPointData($aSurveyinfo['surveyls_numberformat']);
$aLSJavascriptVar['sLEMradix']=$aRadix['separator'];
$sLSJavascriptVar="LSvar=".json_encode($aLSJavascriptVar) . ';';
App()->clientScript->registerScript('sLSJavascriptVar',$sLSJavascriptVar,CClientScript::POS_HEAD);
}
// Don't update, because already set in index/run
}
}
13 changes: 3 additions & 10 deletions scripts/survey_runtime.js
Expand Up @@ -75,16 +75,9 @@ $(document).ready(function()
* setJsVar : Get all global used var
*/
function setJsVar(){
if (typeof LSvar!="undefined" && LSvar instanceof Object == false) {
bFixNumAuto=1;
bNumRealValue=0;
LEMradix=".";
}
else {
bFixNumAuto=LSvar.bFixNumAuto;
bNumRealValue=LSvar.bNumRealValue;
LEMradix=LSvar.sLEMradix;
}
bFixNumAuto=LSvar.bFixNumAuto;
bNumRealValue=LSvar.bNumRealValue;
LEMradix=LSvar.sLEMradix;
numRegex = new RegExp('[^-' + LEMradix + '0-9]','g');
intRegex = new RegExp('[^-0-9]','g');
}
Expand Down

0 comments on commit e9b6e11

Please sign in to comment.