Skip to content

Commit

Permalink
Dev: added starpage.twig (will be replaced by layout.twig at the end …
Browse files Browse the repository at this point in the history
…of the process)
  • Loading branch information
LouisGac committed Jan 6, 2017
1 parent 092266e commit ab807eb
Show file tree
Hide file tree
Showing 2 changed files with 292 additions and 7 deletions.
26 changes: 19 additions & 7 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -96,6 +96,7 @@ public function run($surveyid,$args)
// Template settings
$oTemplate = $this->template = Template::model()->getInstance('', $surveyid);
$sTemplateViewPath = $this->sTemplateViewPath = $oTemplate->pstplPath;
Yii::app()->twigRenderer->setForcedPath($sTemplateViewPath);

// Survey settings
$this->surveyid = $surveyid;
Expand All @@ -108,7 +109,6 @@ public function run($surveyid,$args)
$show_empty_group = $this->show_empty_group;

$this->setJavascriptVar($surveyid);

$aPrivateVariables = $this->setArgs();
extract($aPrivateVariables); // For redata

Expand Down Expand Up @@ -307,8 +307,8 @@ public function run($surveyid,$args)
*
*/
if(!$previewquestion && !$previewgrp){
$questionindex = ls\helpers\questionIndexHelper::getInstance()->getIndexButton();
$questionindexmenu = ls\helpers\questionIndexHelper::getInstance()->getIndexLink();
$questionindex = ls\helpers\questionIndexHelper::getInstance()->getIndexButton();
$questionindexmenu = ls\helpers\questionIndexHelper::getInstance()->getIndexLink();
}

sendCacheHeaders();
Expand All @@ -318,8 +318,14 @@ public function run($surveyid,$args)
// First call to templatereplace

echo "<!-- SurveyRunTimeHelper -->";

$thissurvey['upload_file'] = (isset($upload_file) && $upload_file)?true:false;
$hiddenfieldnames = $thissurvey['hiddenfieldnames'] = implode("|", $inputnames);


$redata = compact(array_keys(get_defined_vars()));
echo templatereplace(file_get_contents($sTemplateViewPath."startpage.pstpl"), array(), $redata);
echo templatereplace(file_get_contents($sTemplateViewPath."startpage.twig"), array(), $redata);

$aPopup=array(); // We can move this part where we want now
if (isset($backpopup))
{
Expand All @@ -342,20 +348,26 @@ public function run($surveyid,$args)
}
Yii::app()->clientScript->registerScript('startPopup',"LSvar.startPopups=".json_encode($aPopup).";",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScript('showStartPopups',"showStartPopups();",CClientScript::POS_END);
$hiddenfieldnames = implode("|", $inputnames);

if (isset($upload_file) && $upload_file)
/*
if (isset($upload_file) && $upload_file){
$this->thissurvey['upload_file'] = $thissurvey['upload_file'] = true;
echo "PWEEEEEEEEEEEEE";
echo CHtml::form(array("/survey/index","sid"=>$surveyid), 'post',array('enctype'=>'multipart/form-data','id'=>'limesurvey','name'=>'limesurvey', 'autocomplete'=>'off', 'class'=>'survey-form-container surveyRunTimeUploadFile'))."\n
<!-- INPUT NAMES -->
<input type='hidden' name='fieldnames' value='{$hiddenfieldnames}' id='fieldnames' />\n";
else
}else{
$this->thissurvey['upload_file'] = $thissurvey['upload_file'] = false;
echo CHtml::form(array("/survey/index","sid"=>$surveyid), 'post',array('id'=>'limesurvey', 'name'=>'limesurvey', 'autocomplete'=>'off', 'class'=>'survey-form-container surveyRunTime'))."\n
<!-- INPUT NAMES -->
<input type='hidden' name='fieldnames' value='{$hiddenfieldnames}' id='fieldnames' />\n";
}
// <-- END FEATURE - SAVE
// The default submit button
echo CHtml::htmlButton("default",array('type'=>'submit','id'=>"defaultbtn",'value'=>"default",'name'=>'move','class'=>"submit hidden",'style'=>'display:none'));
// <-- START THE SURVEY -->
*/
if ($surveyMode == 'survey')
{
if (isset($thissurvey['showwelcome']) && $thissurvey['showwelcome'] == 'N')
Expand Down
273 changes: 273 additions & 0 deletions templates/default/views/startpage.twig
@@ -0,0 +1,273 @@
<!-- startpage.pstl TWIG -->
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{#
!!!!NOTE!!!!
THIS IS A FIRST TEST TO USE TWIG IN PSTPL FILES
NOW, ANY VARIABLE DISPONIBLE IN $REDATA WILL BE USABLE FROM TEMPLATE FILES
IN THE QUESTION PSTPL, QUESTION OBJECT VARIABLES WILL BE AVAILABLE, SAME FOR GROUP, ETC
HERE WE USE THE ARRAY $aSurveyInfo
SO NOW, IT'S NOT NEEDED TO ADD ANYMORE ANY REPLACEMENT KEYWORD
MOST OF THE HTML GENERATED IN THE DIFFERENT HELPERS (LIKE SAVE_LINKS)
COULD BE PLACED DIRECTLY INSIDE THE PSTPL FILES
#}

<title>{{aSurveyInfo.surveyls_title}}</title>
<meta name="generator" content="LimeSurvey http://www.limesurvey.org" />

<!-- The following line includes jquery-ui.css or jquery-ui-custom.css from template dir, template.css and needed specific css file for survey -->
{TEMPLATECSS}

<!-- The following line includes jquery.js, jquery-ui.js, survey_runtime.js , template.js and needed specific js file for survey -->
{TEMPLATEJS}

<link rel="shortcut icon" href="{{templateurl}}favicon.ico" />
{{ include('google_analytics.twig') }}
</head>
<body class="default lang-{{surveylanguage}} {{surveyformat}}">

<div class="navbar navbar-default navbar-fixed-top">
<div class="navbar-header ">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="navbar-brand" >{{ aSurveyInfo.name }}</div>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right navbar-action-link">
{SAVE_LINKS}
{CLEARALL_LINKS}
{QUESTION_INDEX_MENU}
</ul>
</div>
</div>

<!-- Top container -->
<div class="top-container">
<div class="container top-content">{LANGUAGECHANGER}{PERCENTCOMPLETE}</div> <!-- must hide it without javascript -->
</div>

<div class="outerframe container" id="outerframeContainer">
<div id="main-row">
{FLASHMESSAGE}

<div class="col-centered" id="main-col">

{{ include('start_form.twig') }}

<!-- end of startpage.pstl -->

{#
Available in this pstpl file:
TODO: Sandbox the non necessary one
// aSurveyInfo:
{{ aSurveyInfo.template }};
{{ aSurveyInfo.language }};
{{ aSurveyInfo.sid }};
{{ aSurveyInfo.owner_id }};
{{ aSurveyInfo.admin }};
{{ aSurveyInfo.active }};
{{ aSurveyInfo.expires }};
{{ aSurveyInfo.startdate }};
{{ aSurveyInfo.adminemail }};
{{ aSurveyInfo.anonymized }};
{{ aSurveyInfo.faxto }};
{{ aSurveyInfo.savetimings }};
{{ aSurveyInfo.additional_languages }};
{{ aSurveyInfo.datestamp }};
{{ aSurveyInfo.usecookie }};
{{ aSurveyInfo.allowregister }};
{{ aSurveyInfo.allowsave }};
{{ aSurveyInfo.autonumber_start }};
{{ aSurveyInfo.autoredirect }};
{{ aSurveyInfo.allowprev }};
{{ aSurveyInfo.printanswers }};
{{ aSurveyInfo.ipaddr }};
{{ aSurveyInfo.refurl }};
{{ aSurveyInfo.datecreated }};
{{ aSurveyInfo.publicstatistics }};
{{ aSurveyInfo.publicgraphs }};
{{ aSurveyInfo.listpublic }};
{{ aSurveyInfo.sendconfirmation }};
{{ aSurveyInfo.tokenanswerspersistence }};
{{ aSurveyInfo.assessments }};
{{ aSurveyInfo.usecaptcha }};
{{ aSurveyInfo.usetokens }};
{{ aSurveyInfo.bounce_email }};
{{ aSurveyInfo.attributedescriptions }};
{{ aSurveyInfo.emailresponseto }};
{{ aSurveyInfo.emailnotificationto }};
{{ aSurveyInfo.tokenlength }};
{{ aSurveyInfo.showxquestions }};
{{ aSurveyInfo.showgroupinfo }};
{{ aSurveyInfo.shownoanswer }};
{{ aSurveyInfo.showqnumcode }};
{{ aSurveyInfo.bouncetime }};
{{ aSurveyInfo.bounceprocessing }};
{{ aSurveyInfo.bounceaccounttype }};
{{ aSurveyInfo.bounceaccounthost }};
{{ aSurveyInfo.bounceaccountpass }};
{{ aSurveyInfo.bounceaccountencryption }};
{{ aSurveyInfo.bounceaccountuser }};
{{ aSurveyInfo.showwelcome }};
{{ aSurveyInfo.showprogress }};
{{ aSurveyInfo.questionindex }};
{{ aSurveyInfo.navigationdelay }};
{{ aSurveyInfo.nokeyboard }};
{{ aSurveyInfo.alloweditaftercompletion }};
{{ aSurveyInfo.googleanalyticsstyle }};
{{ aSurveyInfo.googleanalyticsapikey }};
{{ aSurveyInfo.format }};
{{ aSurveyInfo.htmlemail }};
{{ aSurveyInfo.surveyls_survey_id }};
{{ aSurveyInfo.surveyls_language }};
{{ aSurveyInfo.surveyls_title }};
{{ aSurveyInfo.surveyls_description }};
{{ aSurveyInfo.surveyls_welcometext }};
{{ aSurveyInfo.surveyls_endtext }};
{{ aSurveyInfo.surveyls_url }};
{{ aSurveyInfo.surveyls_urldescription }};
{{ aSurveyInfo.surveyls_email_invite_subj }};
{{ aSurveyInfo.surveyls_email_invite }};
{{ aSurveyInfo.surveyls_email_remind_subj }};
{{ aSurveyInfo.surveyls_email_remind }};
{{ aSurveyInfo.surveyls_email_register_subj }};
{{ aSurveyInfo.surveyls_email_register }};
{{ aSurveyInfo.surveyls_email_confirm_subj }};
{{ aSurveyInfo.surveyls_email_confirm }};
{{ aSurveyInfo.surveyls_dateformat }};
{{ aSurveyInfo.surveyls_attributecaptions }};
{{ aSurveyInfo.email_admin_notification_subj }};
{{ aSurveyInfo.email_admin_notification }};
{{ aSurveyInfo.email_admin_responses_subj }};
{{ aSurveyInfo.email_admin_responses }};
{{ aSurveyInfo.surveyls_numberformat }};
{{ aSurveyInfo.attachments }};
{{ aSurveyInfo.name }};
{{ aSurveyInfo.description }};
{{ aSurveyInfo.welcome }};
{{ aSurveyInfo.templatedir }};
{{ aSurveyInfo.adminname }};
{{ aSurveyInfo.tablename }};
{{ aSurveyInfo.urldescrip }};
{{ aSurveyInfo.url }};
{{ aSurveyInfo.expiry }};
{{ aSurveyInfo.email_invite_subj }};
{{ aSurveyInfo.email_invite }};
{{ aSurveyInfo.email_remind_subj }};
{{ aSurveyInfo.email_remind }};
{{ aSurveyInfo.email_confirm_subj }};
{{ aSurveyInfo.email_confirm }};
{{ aSurveyInfo.email_register_subj }};
{{ aSurveyInfo.email_register }};
{{ aSurveyInfo.attributecaptions }};
{{ aSurveyInfo.template }};
{{ aSurveyInfo.language }};
{{ aSurveyInfo.sid }};
{{ aSurveyInfo.owner_id }};
{{ aSurveyInfo.admin }};
{{ aSurveyInfo.active }};
{{ aSurveyInfo.expires }};
{{ aSurveyInfo.startdate }};
{{ aSurveyInfo.adminemail }};
{{ aSurveyInfo.anonymized }};
{{ aSurveyInfo.faxto }};
{{ aSurveyInfo.savetimings }};
{{ aSurveyInfo.additional_languages }};
{{ aSurveyInfo.datestamp }};
{{ aSurveyInfo.usecookie }};
{{ aSurveyInfo.allowregister }};
{{ aSurveyInfo.allowsave }};
{{ aSurveyInfo.autonumber_start }};
{{ aSurveyInfo.autoredirect }};
{{ aSurveyInfo.allowprev }};
{{ aSurveyInfo.printanswers }};
{{ aSurveyInfo.ipaddr }};
{{ aSurveyInfo.refurl }};
{{ aSurveyInfo.datecreated }};
{{ aSurveyInfo.publicstatistics }};
{{ aSurveyInfo.publicgraphs }};
{{ aSurveyInfo.listpublic }};
{{ aSurveyInfo.sendconfirmation }};
{{ aSurveyInfo.tokenanswerspersistence }};
{{ aSurveyInfo.assessments }};
{{ aSurveyInfo.usecaptcha }};
{{ aSurveyInfo.usetokens }};
{{ aSurveyInfo.bounce_email }};
{{ aSurveyInfo.attributedescriptions }};
{{ aSurveyInfo.emailresponseto }};
{{ aSurveyInfo.emailnotificationto }};
{{ aSurveyInfo.tokenlength }};
{{ aSurveyInfo.showxquestions }};
{{ aSurveyInfo.showgroupinfo }};
{{ aSurveyInfo.shownoanswer }};
{{ aSurveyInfo.showqnumcode }};
{{ aSurveyInfo.bouncetime }};
{{ aSurveyInfo.bounceprocessing }};
{{ aSurveyInfo.bounceaccounttype }};
{{ aSurveyInfo.bounceaccounthost }};
{{ aSurveyInfo.bounceaccountpass }};
{{ aSurveyInfo.bounceaccountencryption }};
{{ aSurveyInfo.bounceaccountuser }};
{{ aSurveyInfo.showwelcome }};
{{ aSurveyInfo.showprogress }};
{{ aSurveyInfo.questionindex }};
{{ aSurveyInfo.navigationdelay }};
{{ aSurveyInfo.nokeyboard }};
{{ aSurveyInfo.alloweditaftercompletion }};
{{ aSurveyInfo.googleanalyticsstyle }};
{{ aSurveyInfo.googleanalyticsapikey }};
{{ aSurveyInfo.format }};
{{ aSurveyInfo.htmlemail }};
{{ aSurveyInfo.surveyls_survey_id }};
{{ aSurveyInfo.surveyls_language }};
{{ aSurveyInfo.surveyls_title }};
{{ aSurveyInfo.surveyls_description }};
{{ aSurveyInfo.surveyls_welcometext }};
{{ aSurveyInfo.surveyls_endtext }};
{{ aSurveyInfo.surveyls_url }};
{{ aSurveyInfo.surveyls_urldescription }};
{{ aSurveyInfo.surveyls_email_invite_subj }};
{{ aSurveyInfo.surveyls_email_invite }};
{{ aSurveyInfo.surveyls_email_remind_subj }};
{{ aSurveyInfo.surveyls_email_remind }};
{{ aSurveyInfo.surveyls_email_register_subj }};
{{ aSurveyInfo.surveyls_email_register }};
{{ aSurveyInfo.surveyls_email_confirm_subj }};
{{ aSurveyInfo.surveyls_email_confirm }};
{{ aSurveyInfo.surveyls_dateformat }};
{{ aSurveyInfo.surveyls_attributecaptions }};
{{ aSurveyInfo.email_admin_notification_subj }};
{{ aSurveyInfo.email_admin_notification }};
{{ aSurveyInfo.email_admin_responses_subj }};
{{ aSurveyInfo.email_admin_responses }};
{{ aSurveyInfo.surveyls_numberformat }};
{{ aSurveyInfo.attachments }};
{{ aSurveyInfo.name }};
{{ aSurveyInfo.description }};
{{ aSurveyInfo.welcome }};
{{ aSurveyInfo.templatedir }};
{{ aSurveyInfo.adminname }};
{{ aSurveyInfo.tablename }};
{{ aSurveyInfo.urldescrip }};
{{ aSurveyInfo.url }};
{{ aSurveyInfo.expiry }};
{{ aSurveyInfo.email_invite_subj }};
{{ aSurveyInfo.email_invite }};
{{ aSurveyInfo.email_remind_subj }};
{{ aSurveyInfo.email_remind }};
{{ aSurveyInfo.email_confirm_subj }};
{{ aSurveyInfo.email_confirm }};
{{ aSurveyInfo.email_register_subj }};
{{ aSurveyInfo.email_register }};
{{ aSurveyInfo.attributecaptions }};
#}

0 comments on commit ab807eb

Please sign in to comment.