Skip to content

Commit

Permalink
Dev: use new render flow
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed May 4, 2017
1 parent 5130596 commit 5f45693
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
17 changes: 6 additions & 11 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -483,7 +483,7 @@ public function run($surveyid,$args)
$thissurvey['aLEM']['debugvalidation']['message'] = $moveResult['message'];
}

echo Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_main.twig"), array('aSurveyInfo'=>$thissurvey), false);
Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_main.twig"), array('aSurveyInfo'=>$thissurvey), false);
}


Expand Down Expand Up @@ -1077,8 +1077,7 @@ private function saveAllIfNeeded()
$cSave = new Save();
// $cSave->showsaveform($thissurvey['sid']); // generates a form and exits, awaiting input
$thissurvey['aSaveForm'] = $cSave->getSaveFormDatas($thissurvey['sid']);
echo Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_save.twig"), array('aSurveyInfo'=>$thissurvey), false);
Yii::app()->end();
Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_save.twig"), array('aSurveyInfo'=>$thissurvey), false);
}else{
// Intentional retest of all conditions to be true, to make sure we do have tokens and surveyid
// Now update lastpage to $_SESSION[$LEMsessid]['step'] in SurveyDynamic, otherwise we land on
Expand Down Expand Up @@ -1122,8 +1121,7 @@ private function saveSubmitIfNeeded()
// reshow the form if there is an error
if (!empty($aResult['aSaveErrors'])){
$thissurvey['aSaveForm'] = $cSave->getSaveFormDatas($thissurvey['sid']);
echo Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_save.twig"), array('aSurveyInfo'=>$thissurvey), false);
Yii::app()->end();
Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_save.twig"), array('aSurveyInfo'=>$thissurvey), false);
}

$moveResult = $this->moveResult = LimeExpressionManager::GetLastMoveResult(true);
Expand Down Expand Up @@ -1194,8 +1192,7 @@ private function moveSubmitIfNeeded()
$completed = templatereplace($thissurvey['surveyls_endtext'], array(), $redata, 'SubmitEndtextI', false, NULL, array(), true );
$this->completed = $completed;

echo Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_submit_preview.twig"), array('aSurveyInfo'=>$thissurvey), false);
App()->end();
Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_submit_preview.twig"), array('aSurveyInfo'=>$thissurvey), false);
}else{

//Update the token if needed and send a confirmation email
Expand Down Expand Up @@ -1299,8 +1296,7 @@ private function moveSubmitIfNeeded()
killSurveySession($surveyid);
}

echo Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_submit.twig"), array('aSurveyInfo'=>$thissurvey), false);
exit;
Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_submit.twig"), array('aSurveyInfo'=>$thissurvey), false);
}
}

Expand Down Expand Up @@ -1645,8 +1641,7 @@ private function manageClearAll()

$thissurvey['surveyUrl'] = $restarturl;

echo Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_clearall.twig"), array('aSurveyInfo'=>$thissurvey), false);
App()->end();
Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_clearall.twig"), array('aSurveyInfo'=>$thissurvey), false);
}
}

Expand Down
12 changes: 4 additions & 8 deletions application/helpers/frontend_helper.php
Expand Up @@ -1477,9 +1477,7 @@ function renderRenderWayForm($renderWay, array $scenarios, $sTemplateViewPath, $
$thissurvey["aForm"] = $aForm;
$thissurvey['surveyUrl'] = App()->createUrl("/survey/index",array("sid"=>$surveyid));

echo Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_user_forms.twig"), array('aSurveyInfo'=>$thissurvey), false);
// With a good logic in survey runtime, we could avoid those exits
Yii::app()->end();
Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_user_forms.twig"), array('aSurveyInfo'=>$thissurvey), false);
break;

case "register": //Register new user
Expand Down Expand Up @@ -1579,8 +1577,7 @@ function renderError($sTitle='', $sMessage, $thissurvey, $sTemplateViewPath )
$aError['message'] = $sMessage;
$thissurvey['aError'] = $aError;

echo Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_errors.twig"), array('aSurveyInfo'=>$thissurvey), false);
Yii::app()->end();
Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_errors.twig"), array('aSurveyInfo'=>$thissurvey), false);
}


Expand Down Expand Up @@ -2215,8 +2212,7 @@ function checkCompletedQuota($surveyid,$return=false)
}
}

echo Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_quotas.twig"), array('aSurveyInfo'=>$thissurvey), false);
Yii::app()->end();
Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_quotas.twig"), array('aSurveyInfo'=>$thissurvey), false);
}

/**
Expand Down Expand Up @@ -2321,7 +2317,7 @@ function display_first_page($thissurvey) {
LimeExpressionManager::FinishProcessingPage();

$thissurvey['surveyUrl'] = Yii::app()->getController()->createUrl("survey/index",array("sid"=>$surveyid)); // For form action (will remove newtest)
echo Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_first_page.twig"), array('aSurveyInfo'=>$thissurvey), false);
Yii::app()->twigRenderer->renderTemplateFromString( file_get_contents($sTemplateViewPath."layout_first_page.twig"), array('aSurveyInfo'=>$thissurvey), false);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion templates/default/views/subviews/progess_bar.twig
Expand Up @@ -21,7 +21,7 @@
<div class="top-container">
<div class="container top-content">
{% if aSurveyInfo.format != 'A' and aSurveyInfo.showprogress is defined and aSurveyInfo.showprogress == 'Y' %}
{{ registerPublicCssFile('lime-progress.css') }}
{{ registerPublicCssFile('lime-progress.css') }}

{% set progressValue = ( aSurveyInfo.progress.total > 0 ) ? intval( (aSurveyInfo.progress.currentstep - 1) / aSurveyInfo.progress.total * 100 ) : 0 %}
<div class="progress">
Expand Down

0 comments on commit 5f45693

Please sign in to comment.