Commit f3eb90fd authored by Denis Chenu's avatar Denis Chenu

[feature] 3.X compatibility

- This is really an hack …
parent ae4a44a9
......@@ -50,6 +50,7 @@ class messageHelper{
$this->sTemplate=$oSurvey->template;
} else {
$this->sTemplate=Yii::app()->getConfig('defaulttemplate');
$this->iSurveyId = null;
}
/* Find actual language*/
$this->sLanguage=Yii::app()->language;
......@@ -67,7 +68,7 @@ class messageHelper{
*
* return @void
*/
public function render($message)
public function render($message,$title=null)
{
/* Needed when rendering : we don't send thissurvey */
Yii::app()->setConfig('surveyID',$this->iSurveyId);
......@@ -82,29 +83,74 @@ class messageHelper{
case '2_06':
$templateDir=\Template::model()->getTemplatePath($this->sTemplate);
Yii::app()->controller->layout='bare';
if (getLanguageRTL(Yii::app()->language)) {
$renderData['dir'] = ' dir="rtl" ';
} else {
$renderData['dir'] = '';
}
$renderData['language']=$this->sLanguage;
$renderData['templateDir']=$templateDir;
$renderData['useCompletedTemplate']=$this->useCompletedTemplate;
Yii::app()->controller->render("renderMessage.views.2_06.public",$renderData);
Yii::app()->end();
break;
case '2_50':
case '3_00':
$oTemplate = \Template::model()->getInstance($this->sTemplate);
$templateDir= $oTemplate->viewPath;
Yii::app()->controller->layout='bare';
if (getLanguageRTL(Yii::app()->language)) {
$renderData['dir'] = ' dir="rtl" ';
} else {
$renderData['dir'] = '';
}
$renderData['language']=$this->sLanguage;
$renderData['templateDir']=$templateDir;
$renderData['useCompletedTemplate']=$this->useCompletedTemplate;
Yii::app()->controller->render("renderMessage.views.2_50.public",$renderData);
Yii::app()->end();
break;
case '3_00':
if(!$title) {
$title = Yii::app()->getConfig('sitename');
}
$oTemplate = \Template::model()->getInstance($this->sTemplate);
$aSurveyInfo = array(
'languagecode' => $this->sLanguage,
'dir' => getLanguageRTL(Yii::app()->language) ? 'rtl' : 'ltr',
'surveyls_title' => $title,
'adminemail' => Yii::app()->getConfig("siteadminemail"),
'adminname' => Yii::app()->getConfig("siteadminname"),
);
if($this->iSurveyId) {
$aSurveyInfo = getSurveyInfo($iSurveyId, App()->getLanguage());
$oSurvey=\Survey::model()->findByPk($this->iSurveyId);
} else {
$oSurvey = new \stdClass();
}
$oSurvey->active = "Y";
//~ $aSurveyInfo['surveyls_title'] = $title;
$aSurveyInfo['aCompleted']['showDefault'] =false;
$aSurveyInfo['aCompleted']['sEndText'] =$message;
$aSurveyInfo['aAssessments']['show'] =false;
$aSurveyInfo['aCompleted']['aPrintAnswers']['show'] =false;
$aSurveyInfo['aCompleted']['aPublicStatistics']['show'] =false;
$aSurveyInfo['aCompleted']['aPublicStatistics']['sSurveylsUrl'] =null;
$aSurveyInfo['include_content'] = 'submit';
$aSurveyInfo['active'] = 'Y';
$renderData = array_merge($renderData, array(
'oTemplate' => $oTemplate,
'sSiteName' => Yii::app()->getConfig('sitename'),
'sSiteAdminName' => Yii::app()->getConfig("siteadminname"),
'sSiteAdminEmail' => Yii::app()->getConfig("siteadminemail"),
'aSurveyInfo' => $aSurveyInfo,
'oSurvey' => $oSurvey,
));
Yii::app()->controller->render("renderMessage.views.3_00.public",$renderData);
Yii::app()->end();
default:
return;
}
if (getLanguageRTL(Yii::app()->language))
{
$renderData['dir'] = ' dir="rtl" ';
}
else
{
$renderData['dir'] = '';
}
$renderData['language']=$this->sLanguage;
$renderData['templateDir']=$templateDir;
$renderData['useCompletedTemplate']=$this->useCompletedTemplate;
Yii::app()->controller->render("renderMessage.views.{$lsApiVersion}.public",$renderData);
Yii::app()->end();
}
/**
......
<?php
App()->clientScript->registerCssFile($assetUrl.'/renderMessage.css');
?><div class="rm-flash-container">
<?php foreach($messages as $message){
echo Yii::app()->controller->renderPartial("renderMessage.views.2_50.flashMessage",$message);
}?>
</div>
<div class="rm-flash-message alert alert-<?php echo $type; ?>">
<button type="button" class="close" data-dismiss="alert" aria-label="<?php echo gT("Close"); ?>">
<span aria-hidden="true">&times;</span>
</button>
<?php echo $message; ?>
</div>
<!DOCTYPE html>
<html lang="{{ aSurveyInfo.languagecode }}" dir="{{ aSurveyInfo.dir }}" class="{{ aSurveyInfo.languagecode }} dir-{{ aSurveyInfo.dir }} {{ aSurveyInfo.class.html }}" {{ aSurveyInfo.attr.html }}>
{% block head %}
{# Headers, metadata, etc #}
{{ include('./subviews/header/head.twig') }}
{% endblock %}
<body style="padding-top: 90px;" class=" {{ aSurveyInfo.class.body }} font-{{ aSurveyInfo.options.font }} lang-{{aSurveyInfo.languagecode}} {{aSurveyInfo.surveyformat}} {% if( aSurveyInfo.options.brandlogo == "on") %}brand-logo{%endif%}" {{ aSurveyInfo.attr.body }} >
{% if (aSurveyInfo.options.ajaxmode == "on" and aSurveyInfo.printPdf != 1) %}
{% block ajaxindicator %}
{# In vanilla, this file is empty, we keep it to have a common layout between all core themes #}
{{ include('./subviews/navigation/ajax_indicator.twig') }}
{% endblock %}
{% endif %}
{# This used for the pjax system #}
{% block pjaxbegin %}
<div id="beginScripts" class="script-container">
<###begin###>
</div>
{% endblock %}
{# Ajaxify cannot handle an element that is a direct child of body, so => create simple wrapper section #}
<article>
<div id="{{ aSurveyInfo.id.dynamicreload }}">
{% block body %}
{# Bootstrap Navigation Bar: the top menu #}
{% block nav_bar %}
{{ include('./subviews/header/nav_bar.twig') }}
{% endblock %}
<!-- Outer Frame Container -->
{% block content %}
{#
Content depends on the action (survey, questions, register, assesments, submit, etc)
Action are in ./subviews/content/
#}
{% set sViewContent = './subviews/content/' ~ aSurveyInfo.include_content ~ '.twig' %}
{% include './subviews/content/outerframe.twig' with {'include_content': sViewContent } %}
{% endblock %}
{# Basic ThemeScript options #}
{{ registerScript("BasicThemeScripts", "
if(window.basicThemeScripts === undefined){
window.basicThemeScripts = new ThemeScripts();
}
basicThemeScripts.initGlobal();
", POS_END) }}
{% endblock %}
</div>
</article>
{% block pjaxend %}
<div id="bottomScripts" class="script-container">
<###end###>
</div>
{% endblock %}
{% block themescripts %}
<script>
window.basicThemeScripts.init();
</script>
{% endblock %}
</body>
</html>
<?php
Yii::app()->twigRenderer->renderTemplateFromFile("layout_global.twig", array('oSurvey' => $oSurvey,'aSurveyInfo' => $aSurveyInfo), false);
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment