/
layout_global.twig
149 lines (112 loc) · 6.38 KB
/
layout_global.twig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
{#
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.
(¯`·._.·(¯`·._.· Global Layout ·._.·´¯)·._.·´¯)
This is the global layout that will be used to displayed most pages (less the error page)
If you're creating your own template, remember there is no obligation to respect the current file flow of this template.
This is different from the old LimeSurvey template engine, where you had to provide every one of the pstpl files.
Here, you must have a file called main_layout.twig (called from SurveyRuntimeHelper::run() ).
Other than that, you're free to organize your files and inclusions as you want.
(¯`·._.·(¯`·._.· Bootstrap ·._.·´¯)·._.·´¯)
LimeSurvey uses Bootstrap.
See: https://getbootstrap.com
This template is an instance of Bootswatch Theme Flatly.
See: https://bootswatch.com/
(¯`·._.·(¯`·._.· Twig Engine ·._.·´¯)·._.·´¯)
The template engine uses Twig.
See: http://twig.sensiolabs.org/
The main variable is aSurveyInfo. It's an array containing the main information about the survey.
aSurveyInfo also contains other needed arrays, such as aNavigator, or aQuestionGroups (which contain aQuestions), etc.
If you want to see what is availabe in aSurveyInfo, turn debug mode on in application/config.php, and copy the following line to the end of the <body> element below:
{{ dump(aSurveyInfo) }}
To echo a variable, just insert : {{ variable }}
To translate a string, just insert : {{gT( string )}}
NOTE: aSurveyInfo should be cleaned to remove the unnecessary data.
(¯`·._.·(¯`·._.· Twig Engine: advanced ·._.·´¯)·._.·´¯)
For security reason, Twig is in a sandBox.
About sandBox, see: http://twig.sensiolabs.org/doc/2.x/api.html#sandbox-extension
Available functions/Object Methods are defined in internal.php: components => twigRenderer
Eg:
Functions : 'include', 'dump', 'flatEllipsizeText', 'getLanguageData', 'array_flip', 'array_intersect_key', 'registerPublicCssFile', 'getAllQuestionClasses', 'getShowqnumcode', 'intval'
Methods :
- CHtml::textfield() (and: form, link, emailField, beginForm, endForm, dropDownList,htmlButton)
- Survey::getAllLanguages()
- LSHttpRequest::getParam()
If you need to add simple functions or static methods, just add them to internal.php.
If you need to add complex process, use application/core/LS_Twig_Extension.php (more help/comments there)
NOTE: Feel free to ask for functions, variables, etc, that you feel are missing - https://bugs.limesurvey.org/my_view_page.php
#}
<!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 %}
{# Top Container: in this template, it contains only #}
{% block progress %}
{{ include('./subviews/header/progress_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 %}
{# Bootstrap alert modal #}
{{ include('./subviews/messages/bootstrap_alert_modal.twig') }}
{# Basic ThemeScript options #}
{{ registerScript("BasicThemeScripts", "
if(window.basicThemeScripts === undefined){
window.basicThemeScripts = new ThemeScripts();
}
basicThemeScripts.initGlobal();
", "POS_END") }}
{% endblock %}
</div>
</article>
{% block footer %}
{{ include('./subviews/footer/footer.twig') }}
{% endblock %}
{% block pjaxend %}
<div id="bottomScripts" class="script-container">
<###end###>
</div>
{% endblock %}
{% block themescripts %}
<script>
window.basicThemeScripts.init();
</script>
{% endblock %}
</body>
</html>