From afa76df6aa5b7ecff12c849f322ddaef22e12bb8 Mon Sep 17 00:00:00 2001 From: LouisGac Date: Tue, 21 Feb 2017 10:39:05 +0100 Subject: [PATCH] Dev: use getNavigatorDatas() for main survey --- application/helpers/SurveyRuntimeHelper.php | 113 +------------------- application/helpers/frontend_helper.php | 2 +- 2 files changed, 2 insertions(+), 113 deletions(-) diff --git a/application/helpers/SurveyRuntimeHelper.php b/application/helpers/SurveyRuntimeHelper.php index 7f18603ba78..958c968c6cf 100644 --- a/application/helpers/SurveyRuntimeHelper.php +++ b/application/helpers/SurveyRuntimeHelper.php @@ -566,131 +566,20 @@ public function run($surveyid,$args) /** * Navigator */ - - /** - TODO: - $aNavigator['show'] = $aNavigator['show'] = $aNavigator['save']['show'] = $aNavigator['load']['show'] = false; - if (!$previewgrp && !$previewquestion){ - $thissurvey['aNavigator'] = getNavigatorDatasForTwig; - - } - - $thissurvey['hiddenInputs'] = "\n"; - $thissurvey['hiddenInputs'] .= "\n"; - $thissurvey['hiddenInputs'] .= "\n"; - $_SESSION[$LEMsessid]['LEMpostKey'] = mt_rand(); - $thissurvey['hiddenInputs'] .= "\n"; - - if (isset($token) && !empty($token)) - { - $thissurvey['hiddenInputs'] .= "\n\n"; - } - - - */ $thissurvey['aNavigator'] = array(); $thissurvey['aNavigator']['show'] = $aNavigator['show'] = $thissurvey['aNavigator']['save']['show'] = $thissurvey['aNavigator']['load']['show'] = false; if (!$previewgrp && !$previewquestion){ - - $thissurvey['aNavigator']['show'] = $aNavigator['show'] = true; - - $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 - $thissurvey['aNavigator']['disabled'] = ''; - if ($thissurvey['navigationdelay'] > 0 && ($iSessionMaxStep!==false && $iSessionMaxStep == $iSessionStep)) - { - $thissurvey['aNavigator']['disabled'] = " disabled"; - App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."/navigator-countdown.js"); - App()->getClientScript()->registerScript('navigator_countdown',"navigator_countdown(" . $thissurvey['navigationdelay'] . ");\n",CClientScript::POS_BEGIN); - } - - // Previous ? - if ($thissurvey['format'] != "A" && ($thissurvey['allowprev'] != "N") - && $iSessionStep - && !($iSessionStep == 1 && $thissurvey['showwelcome'] == 'N') - && !Yii::app()->getConfig('previewmode') - ){ - $sMovePrev="moveprev"; - } - - // Submit ? - if ($iSessionStep && ($iSessionStep == $iSessionTotalSteps) - || $thissurvey['format'] == 'A' - ){ - $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')){ - $sMoveNext=""; - } - - $thissurvey['aNavigator']['aMovePrev']['show'] = ( $sMovePrev != '' ); - $thissurvey['aNavigator']['aMoveNext']['show'] = ( $sMoveNext != '' ); - $thissurvey['aNavigator']['aMoveNext']['value'] = $sMoveNext; - - $redata = compact(array_keys(get_defined_vars())); - - //echo templatereplace(file_get_contents($sTemplateViewPath."navigator.pstpl"), array(), $redata); - + $thissurvey['aNavigator'] = getNavigatorDatas(); $thissurvey['hiddenInputs'] = "\n"; $thissurvey['hiddenInputs'] .= "\n"; $thissurvey['hiddenInputs'] .= "\n"; $_SESSION[$LEMsessid]['LEMpostKey'] = mt_rand(); $thissurvey['hiddenInputs'] .= "\n"; - if (isset($token) && !empty($token)) { $thissurvey['hiddenInputs'] .= "\n\n"; } - - - // SAVE BUTTON - if($thissurvey['allowsave'] == "Y"){ - - App()->getClientScript()->registerScript("activateActionLink","activateActionLink();\n",CClientScript::POS_END); - - // Fill some test here, more clear .... - $bTokenanswerspersistence = $thissurvey['tokenanswerspersistence'] == 'Y' && tableExists('tokens_'.$surveyid); - $bAlreadySaved = isset($_SESSION['survey_'.$surveyid]['scid']); - $iSessionStep = (isset($_SESSION['survey_'.$surveyid]['step'])? $_SESSION['survey_'.$surveyid]['step'] : false ); - $iSessionMaxStep = (isset($_SESSION['survey_'.$surveyid]['maxstep'])? $_SESSION['survey_'.$surveyid]['maxstep'] : false ); - - // Find out if the user has any saved data - if ($thissurvey['format'] == 'A'){ - if ( !$bTokenanswerspersistence && !$bAlreadySaved ){ - $thissurvey['aNavigator']['load']['show'] = true; - } - $thissurvey['aNavigator']['save']['show'] = true; - }elseif (!$iSessionStep) { - - //Welcome page, show load (but not save) - if (!$bTokenanswerspersistence && !$bAlreadySaved ){ - $thissurvey['aNavigator']['load']['show'] = true; - } - - if($thissurvey['showwelcome']=="N"){ - $thissurvey['aNavigator']['save']['show'] = true; - } - }elseif ($iSessionMaxStep==1 && $thissurvey['showwelcome']=="N"){ - //First page, show LOAD and SAVE - if (!$bTokenanswerspersistence && !$bAlreadySaved ){ - $thissurvey['aNavigator']['load']['show'] = true; - } - $thissurvey['aNavigator']['save']['show'] = true; - }elseif ($move != "movelast"){ - // Not on last page or submited survey - $thissurvey['aNavigator']['save']['show'] = true; - } - } } // For "clear all" buttons diff --git a/application/helpers/frontend_helper.php b/application/helpers/frontend_helper.php index 9168b6039c9..391e81aef3d 100644 --- a/application/helpers/frontend_helper.php +++ b/application/helpers/frontend_helper.php @@ -1758,7 +1758,7 @@ function getNavigatorDatas() } $aNavigator['save']['show'] = true; - }elseif ($move != "movelast"){ + }elseif (getMove() != "movelast"){ // Not on last page or submited survey $aNavigator['save']['show'] = true; }