-
Notifications
You must be signed in to change notification settings - Fork 994
/
textElements.php
151 lines (149 loc) · 6.92 KB
/
textElements.php
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
150
151
<!-- Text element tabs -->
<ul class="nav nav-tabs me-auto" role="tablist">
<li class="nav-item" role="presentation">
<a class="nav-link active" href="#question-tab" aria-controls="question-tab" role="tab" data-bs-toggle="tab">
<?= gT('Question'); ?>
</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link" href="#question-help-tab" aria-controls="question-help-tab" role="tab" data-bs-toggle="tab">
<?= gT('Help'); ?>
</a>
</li>
<?php if ($showScriptField): ?>
<li class="nav-item" role="presentation">
<a class="nav-link" href="#script-field-tab" aria-controls="script-field-tab" role="tab" data-bs-toggle="tab">
<?= gT('Script'); ?>
</a>
</li>
<?php endif; ?>
<li class="nav-item ms-auto">
<!-- Language selector -->
<?php
$this->renderPartial(
"languageselector",
['oSurvey' => $oSurvey]
); ?>
</li>
</ul>
<div class="tab-content bg-white ps-2 pe-2">
<!-- Question text tab content -->
<div role="tabpanel" class="tab-pane show active" id="question-tab">
<?php foreach($oSurvey->allLanguages as $lang): ?>
<div class="lang-hide lang-<?= $lang; ?>" style="<?= $lang != $oSurvey->language ? 'display: none;' : '' ?>">
<div class="mb-3">
<div class="input-group w-100">
<?= CHtml::textArea(
"questionI10N[$lang][question]",
$question->questionl10ns[$lang]->question ?? '',
[
'class' => 'form-control',
'cols' => '60',
'rows' => '8',
'id' => "question_{$lang}",
'data-contents-dir' => getLanguageRTL($lang) ? 'rtl' : 'ltr',
'placeholder' => gT('Enter your question here...'),
]
); ?>
<?= getEditor(
'question-text',//"question_" . $lang, //this is important for LimereplacementfieldsController function getReplacementFields(...)!
"question_" . $lang,
"[".gT("Question:","js")."](".$lang.")",
$oSurvey->sid,
$question->gid ?? 0,
$question->qid ?? 0,
'editquestion');
?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<!-- Question help tab content -->
<div role="tabpanel" class="tab-pane" id="question-help-tab">
<?php foreach($oSurvey->allLanguages as $lang): ?>
<div class="lang-hide lang-<?= $lang; ?>" style="<?= $lang != $oSurvey->language ? 'display: none;' : '' ?>">
<div class="mb-3">
<div class="input-group w-100">
<?= CHtml::textArea(
"questionI10N[$lang][help]",
$question->questionl10ns[$lang]->help ?? '',
[
'class' => 'form-control',
'cols' => '60',
'rows' => '4',
'id' => "help_{$lang}",
'data-contents-dir' => getLanguageRTL($lang) ? 'rtl' : 'ltr',
'placeholder' => gT('Enter some help text if your question needs some explanation here...'),
]
); ?>
<?= getEditor(
"help_".$lang,
"help_".$lang,
"[".gT("Help:", "js")."](".$lang.")",
$oSurvey->sid,
$question->gid ?? 0,
$question->qid ?? 0,
$action = ''
); ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php if ($showScriptField): ?>
<!-- Script tab content -->
<div role="tabpanel" class="tab-pane" id="script-field-tab">
<?php foreach($oSurvey->allLanguages as $lang): ?>
<div class="lang-hide lang-<?= $lang; ?>" style="<?= $lang != $oSurvey->language ? 'display: none;' : '' ?>">
<div class="mb-3">
<?php if ($lang == $oSurvey->language): ?>
<div class="row">
<div class="col-12 text-end">
<input
type="checkbox"
name="question[same_script]"
id="same_script"
value=1
<?php if($question->same_script): ?>
checked = 'checked'
<?php endif; ?>
/>
<label for="same_script">
<?= gT('Use for all languages'); ?>
</label>
</div>
</div>
<?php else: ?>
<?php
$this->widget('ext.AlertWidget.AlertWidget', [
'text' => gT('The script for this language will not be used because "Use for all languages" is set on the base language\'s script.'),
'type' => 'warning',
'htmlOptions' => ['class' => 'same-script-alert d-none']
]);
?>
<?php endif; ?>
<?= CHtml::textArea(
"questionI10N[$lang][script]",
$question->questionl10ns[$lang]->script,
[
'id' => CHtml::getIdByName("questionI10N[{$lang}][script]"),
'rows' => '10',
'cols' => '20',
'data-filetype' => 'javascript',
'class' => 'ace form-control',
'style' => 'width: 100%',
'data-lang' => "$lang",
'readonly' => !App()->user->isScriptUpdateAllowed()
]
); ?>
<p class="alert well">
<?= gT("This optional script field will be wrapped, so that the script is correctly executed after the question is displayed."); ?>
<?= !App()->user->isScriptUpdateAllowed() ? gT("You do not have sufficient permissions to update the script.") : ""; ?>
</p>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>