Skip to content

Commit

Permalink
Dev: some cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Feb 20, 2017
1 parent d4efc9e commit 32c94c5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 deletions.
5 changes: 3 additions & 2 deletions application/helpers/SurveyRuntimeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ public function run($surveyid,$args)
}




if ( !$this->previewgrp && !$this->previewquestion){
$this->initMove(); // main methods to init session, LEM, moves, errors, etc
$aPrivateVariables = $this->getArgs();
Expand Down Expand Up @@ -166,6 +164,9 @@ public function run($surveyid,$args)


$this->moveSubmitIfNeeded();



extract($aPrivateVariables); // For redata

// We really need to replace redata get_defined_vars by something else.
Expand Down
50 changes: 27 additions & 23 deletions application/helpers/frontend_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1598,24 +1598,25 @@ function renderError($sTitle='', $sMessage, $thissurvey, $sTemplateViewPath )
* This function creates the form elements in the survey navigation bar
* Adding a hidden input for default behaviour without javascript
* Use button name="move" for real browser (with or without javascript) and IE6/7/8 with javascript
*
* TODO: TWIG IT !
*/
function surveymover()
{
$surveyid=Yii::app()->getConfig('surveyID');
$thissurvey=getSurveyInfo($surveyid);

$sMoveNext="movenext";
$sMovePrev="";
$iSessionStep=(isset($_SESSION['survey_'.$surveyid]['step']))?$_SESSION['survey_'.$surveyid]['step']:false;
$iSessionMaxStep=(isset($_SESSION['survey_'.$surveyid]['maxstep']))?$_SESSION['survey_'.$surveyid]['maxstep']:false;
$iSessionTotalSteps=(isset($_SESSION['survey_'.$surveyid]['totalsteps']))?$_SESSION['survey_'.$surveyid]['totalsteps']:false;
$sClass="ls-move-btn";
$sSurveyMover = "";
$sMoveNext = "movenext";
$sMovePrev = "";
$iSessionStep = (isset($_SESSION['survey_'.$surveyid]['step']))?$_SESSION['survey_'.$surveyid]['step']:false;
$iSessionMaxStep = (isset($_SESSION['survey_'.$surveyid]['maxstep']))?$_SESSION['survey_'.$surveyid]['maxstep']:false;
$iSessionTotalSteps = (isset($_SESSION['survey_'.$surveyid]['totalsteps']))?$_SESSION['survey_'.$surveyid]['totalsteps']:false;
$sClass = "ls-move-btn";
$sSurveyMover = "";

// Count down
if ($thissurvey['navigationdelay'] > 0 && ($iSessionMaxStep!==false && $iSessionMaxStep == $iSessionStep))
{
$sClass.=" disabled";
if ($thissurvey['navigationdelay'] > 0 && ($iSessionMaxStep!==false && $iSessionMaxStep == $iSessionStep)){
$sClass .= " disabled";
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."/navigator-countdown.js");
App()->getClientScript()->registerScript('navigator_countdown',"navigator_countdown(" . $thissurvey['navigationdelay'] . ");\n",CClientScript::POS_BEGIN);
}
Expand All @@ -1625,46 +1626,47 @@ function surveymover()
&& $iSessionStep
&& !($iSessionStep == 1 && $thissurvey['showwelcome'] == 'N')
&& !Yii::app()->getConfig('previewmode')
)
{
$sMovePrev="moveprev";
){
$sMovePrev = "moveprev";
}

// Submit ?
if ($iSessionStep && ($iSessionStep == $iSessionTotalSteps)
|| $thissurvey['format'] == 'A'
)
{
$sMoveNext="movesubmit";
$sMoveNext = "movesubmit";
}

// todo Remove Next if needed (exemple quota show previous only: maybe other, but actually don't use surveymover)
if(Yii::app()->getConfig('previewmode'))
{
if (Yii::app()->getConfig('previewmode')){
$sMoveNext="";
}


// Construction of mover

if($sMovePrev){
if ($sMovePrev){
// TODO: Twig it !
$sMovePrevButton = App()->getController()->renderPartial("/survey/system/actionButton/movePrevious",array('value'=>$sMovePrev,'class'=>"$sClass ls-move-previous-btn"),true);
//$sSurveyMover.= CHtml::htmlButton($sLangMoveprev,array('type'=>'submit','id'=>"{$sMovePrev}btn",'value'=>$sMovePrev,'name'=>$sMovePrev,'accesskey'=>'p','class'=>$sClass));
//~ $sMovePrevButton = CHtml::htmlButton($sLangMoveprev,array('type'=>'submit','id'=>"{$sMovePrev}btn",'value'=>$sMovePrev,'name'=>$sMovePrev,'accesskey'=>'p','class'=>$sClass." btn-default"));
}else{
$sMovePrevButton = '';
}

if($sMoveNext){
if($sMoveNext=="movesubmit"){
if ($sMoveNext){
if($sMoveNext == "movesubmit"){
// TODO: Twig it !
$sMoveNextButton = App()->getController()->renderPartial("/survey/system/actionButton/moveSubmit",array('value'=>"movesubmit",'class'=>"$sClass ls-move-submit-btn"),true);
}else{
// TODO: Twig it !
$sMoveNextButton = App()->getController()->renderPartial("/survey/system/actionButton/moveNext",array('value'=>"movenext",'class'=>"$sClass ls-move-next-btn"),true);
}
//~ $sMoveNextButton = CHtml::htmlButton($sLangMovenext,array('type'=>'submit','id'=>"{$sMoveNext}btn",'value'=>$sMoveNext,'name'=>$sMoveNext,'accesskey'=>$sAccessKeyNext,'class'=>$sClass." btn-primary"));
}else{
$sMoveNextButton = '';
}

return array('sMovePrevButton' => $sMovePrevButton, 'sMoveNextButton'=>$sMoveNextButton);
}

Expand Down Expand Up @@ -2179,14 +2181,16 @@ function display_first_page() {
$sTemplatePath = $oTemplate->path;
$sTemplateViewPath = $oTemplate->pstplPath;

sendCacheHeaders();
doHeader();

LimeExpressionManager::StartProcessingPage();
LimeExpressionManager::StartProcessingGroup(-1, false, $surveyid); // start on welcome page

$redata = compact(array_keys(get_defined_vars()));


sendCacheHeaders();
doHeader();


echo templatereplace(file_get_contents($sTemplateViewPath."startpage.pstpl"),array(),$redata,'frontend_helper[2757]');
echo CHtml::form(array("/survey/index","sid"=>$surveyid), 'post', array('id'=>'limesurvey','name'=>'limesurvey','autocomplete'=>'off', 'class'=>'frontend_helper'));

Expand Down

0 comments on commit 32c94c5

Please sign in to comment.