Skip to content

Commit

Permalink
Dev: twigged clear all
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Apr 11, 2017
1 parent 804f958 commit f8c5d21
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 3 deletions.
31 changes: 29 additions & 2 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -45,6 +45,7 @@ class SurveyRuntimeHelper {
private $surveyOptions; // Few options comming from thissurvey, App->getConfig, LEM. Could be replaced by $oSurvey + relations ; the one coming from LEM and getConfig should be public variable on the surveyModel, set via public methods (active, allowsave, anonymized, assessments, datestamp, deletenonvalues, ipaddr, radix, refurl, savetimings, surveyls_dateformat, startlanguage, target, tempdir,timeadjust)
private $totalquestions; // Number of question in the survey. Same, should be moved to survey model.
private $bTokenAnswerPersitance; // Are token used? Same...
private $bTokensexist;
private $assessments; // Is assement used? Same...
private $sLangCode; // Current language code

Expand Down Expand Up @@ -652,7 +653,7 @@ private function setArgs()
//THE FOLLOWING DEALS WITH SUBMITTING ANSWERS AND COMPLETING AN ACTIVE SURVEY
//don't use cookies if tokens are being used
if ($thissurvey['active'] == "Y"){
if ($thissurvey['usecookie'] == "Y" && $tokensexist != 1) {
if ($thissurvey['usecookie'] == "Y" && $this->bTokensexist != 1) {
setcookie("LS_" . $surveyid . "_STATUS", "COMPLETE", time() + 31536000); //Cookie will expire in 365 days
}
}
Expand Down Expand Up @@ -1611,7 +1612,8 @@ private function getErrorHtmlMessage()
*/
private function manageClearAll()
{
$sessionSurvey = Yii::app()->session["survey_{$this->surveyid}"];
$thissurvey = $this->thissurvey;
$sessionSurvey = Yii::app()->session["survey_{$this->surveyid}"];

if (App()->request->getPost('confirm-clearall') == 'confirm'){

Expand All @@ -1637,12 +1639,36 @@ private function manageClearAll()
killSurveySession($this->surveyid);

//TODO TWIG

/***
$content = templatereplace(file_get_contents($this->sTemplateViewPath."clearall.pstpl"),array());
App()->getController()->layout = 'survey';
App()->getController()->render("/survey/system/display",array('content'=>$content));
*/

global $token;
if($token){
$restartparam['token']=sanitize_token($token);
}

if (Yii::app()->request->getQuery('lang')){
$restartparam['lang'] = sanitize_languagecode(Yii::app()->request->getQuery('lang'));
}else{
$s_lang = isset(Yii::app()->session['survey_'.$this->surveyid]['s_lang']) ? Yii::app()->session['survey_'.$this->surveyid]['s_lang'] : 'en';
$restartparam['lang'] = $s_lang;
}

$restartparam['newtest'] = "Y";
$restarturl = Yii::app()->getController()->createUrl("survey/index/sid/$this->surveyid",$restartparam);

$thissurvey['surveyUrl'] = $restarturl;

$redata = compact(array_keys(get_defined_vars()));
echo templatereplace(file_get_contents($this->sTemplateViewPath."layout_clearall.twig"), array(), $redata);
App()->end();


}elseif(App()->request->getPost('confirm-clearall') != 'cancel'){

LimeExpressionManager::JumpTo($sessionSurvey['step'], false, true, true, false); // do process the POST data
Expand Down Expand Up @@ -1694,6 +1720,7 @@ private function showTokenOrCaptchaFormsIfNeeded()
global $clienttoken;
global $tokensexist;

$this->tokensexist = $tokensexist;
/**
* This method has multiple outcomes that virtually do the same thing
* Possible scenarios/subscenarios are =>
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/frontend_helper.php
Expand Up @@ -1469,7 +1469,7 @@ function renderRenderWayForm($renderWay, array $redata, array $scenarios, $sTemp
$aForm['sType'] = ($scenarios['tokenRequired'])?'token':'captcha';
$aForm['token'] = array_key_exists('token', $aEnterTokenData)?$aEnterTokenData['token']:null;
$aForm['aEnterErrors'] = $aEnterTokenData['aEnterErrors'];
$aForm['bCaptchaEnabled'] = $aEnterTokenData['bCaptchaEnabled'];
$aForm['bCaptchaEnabled'] = (isset($aEnterTokenData['bCaptchaEnabled']))?$aEnterTokenData['bCaptchaEnabled']:'';

// Rendering user_forms_layout.twig
$thissurvey["aForm"] = $aForm;
Expand Down
56 changes: 56 additions & 0 deletions templates/default/views/layout_clearall.twig
@@ -0,0 +1,56 @@
{#
LimeSurvey
Copyright (C) 2007-2017 The LimeSurvey Project Team / Louis Gac
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.
#}
<!DOCTYPE html>
<html lang="{{ aSurveyInfo.languagecode }}" dir="{{ aSurveyInfo.dir }}" class="no-js {{ aSurveyInfo.languagecode }} dir-{{ aSurveyInfo.dir }} ">

{# Headers, metadatas, etc #}
{{ include('./subviews/head.twig') }}

<body class="default lang-{{surveylanguage}} {{surveyformat}}">

{# Bootstrap Navigation Bar: the top menu #}
{{ include('./subviews/nav_bar.twig') }}

<!-- Outer Frame Container -->
<div class="outerframe container" id="outerframeContainer">

<!-- Main Row -->
<div id="main-row">
<!-- Main Col -->
<div class="col-centered" id="main-col">

<div class='return-to-survey'>
<div class="url-wrapper url-wrapper-survey-return">
<a href="{{ aSurveyInfo.surveyUrl }}" class="ls-return">{{ "Restart this Survey" }}</a>
</div>
</div>
</div>

</div> <!-- main col -->
</div> <!-- main row -->
</div> <!-- outer frame container -->

{# Bootstrap alert modal #}
{{ include('./subviews/bootstrap_alert_modal.twig') }}

<!-- some template.js function launched before ready -->
<script type="text/javascript">
/*<![CDATA[*/
sliderSuffixClone();
fixBodyPadding();
hideQuestionWithRelevanceSubQuestion();
hideEmptyPart();
/*]]>*/
</script>
</body>
</html>
<!-- end of startpage.twig -->

0 comments on commit f8c5d21

Please sign in to comment.