/
_generaloptions_panel.php
executable file
·362 lines (339 loc) · 18 KB
/
_generaloptions_panel.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<?php
/**
* General options
* @var AdminController $this
* @var Survey $oSurvey
*/
$scriptVarsNeccessary = "
var jsonUrl = '';
var sAction = '';
var sParameter = '';
var sTargetQuestion = '';
var sNoParametersDefined = '';
var sAdminEmailAddressNeeded = '" . gT("If you are using surveys with a closed participant group or notifications emails you need to set an administrator email address.", 'js') . "'
var sURLParameters = '';
var sAddParam = '';
";
Yii::app()->getClientScript()->registerScript(
"GeneralOption-variables",
$scriptVarsNeccessary,
LSYii_ClientScript::POS_BEGIN
);
?>
<!-- General options -->
<?php
$yii = Yii::app();
$controller = $yii->getController();
$action = 'editsurveysettings';
$formatSelectOptions = array(
'S' => gT('Question by Question', 'unescaped'),
'G' => gT('Group by Group', 'unescaped'),
'A' => gT('All in one', 'unescaped')
);
$bGlobalSettings = !empty($this->currentModuleAction) && $this->currentModuleAction == 'globalsettings';
if ($bShowInherited) {
$formatSelectOptions['I'] = $oSurveyOptions->format . " ᴵ";
}
?>
<?php if ($action == 'editsurveysettings'): ?>
<?php
$sConfirmLanguageScript = "
$(document).on('submit','#globalsetting',function(){
if(!ConfirmLanguageChange('" . gT("All questions, answers, etc for removed languages will be lost. Are you sure?", "js") . "')){
return false;
}
});
function ConfirmLanguageChange(confirmtxt) {
if ($('#oldlanguages').val().trim()=='') {
mylangs= [];
} else {
mylangs=$('#oldlanguages').val().split(' ');
}
if (checkSelect2Languages(mylangs)) {
return true;
} else {
return confirm(confirmtxt);
}
}
function checkSelect2Languages(mylangs) {
newLanguages=$('#additional_languages').val();
for (x = 0; x < mylangs.length; x++) {
if ($.inArray(mylangs[x],newLanguages)==-1) {
return false;
}
}
return true;
}
";
Yii::app()->getClientScript()->registerScript("GeneralOption-confirm-language", $sConfirmLanguageScript, LSYii_ClientScript::POS_POSTSCRIPT);
// var_dump($owner);
?>
<!-- Container -->
<div class="row">
<div class="col-lg-6 col-12">
<?php if ($bShowAllOptions === true) { ?>
<?php if (!$oSurvey->isNewRecord): ?>
<!-- Survey Languages -->
<div class="mb-3">
<label class=" form-label" for='additional_languages'><?php eT("Survey languages:"); ?></label>
<div class="">
<?php
$aAllLanguages = getLanguageDataRestricted(false, 'short');
Yii::app()->getController()->widget('ext.admin.survey.LanguagesWidget.LanguagesWidget',
array(
'asDropDownList' => true,
'htmlOptions' => array('multiple' => 'multiple', 'style' => "width: 100%", 'class' => 'form-select'),
'data' => $aAllLanguages,
'value' => $oSurvey->allLanguages,
'name' => 'additional_languages',
'pluginOptions' => array(
'placeholder' => gT('Select additional languages', 'unescaped'),
'baselanguage' => $oSurvey->language,
'baselanguage_selector' => '#language',
)
)
);
?>
<input type='hidden' name='oldlanguages' id='oldlanguages' value='<?php echo implode(' ', $oSurvey->additionalLanguages); ?>'>
</div>
</div>
<!-- Base language -->
<div class="mb-3">
<label class=" form-label"><?php eT("Base language:"); ?></label>
<div class="">
<?php $this->widget('yiiwheels.widgets.select2.WhSelect2',
array(
'asDropDownList' => true,
'htmlOptions' => array('style' => "width: 100%"),
'data' => array_intersect_key($aAllLanguages, array_flip($oSurvey->allLanguages)),
'value' => $oSurvey->language,
'name' => 'language',
'pluginOptions' => array()
)
); ?>
</div>
</div>
<?php endif; ?>
<?php } ?>
<!-- Survey owner -->
<?php
if (isset($oSurvey->owner_id) && Yii::app()->session['loginID'] == $oSurvey->owner_id || Permission::model()->hasGlobalPermission('superadmin', 'read')):?>
<div class="mb-3">
<label class=" form-label" for='owner_id'><?php eT("Survey owner:"); ?></label>
<div class=""><?php
Yii::app()->getController()->widget('yiiwheels.widgets.select2.WhSelect2',
array(
'asDropDownList' => true,
'htmlOptions' => array(
'style' => 'width:100%;'
),
'data' => isset($users) ? $users : [],
'value' => $oSurvey->owner_id,
'name' => 'owner_id',
'pluginOptions' => array()
)
);
?>
</div>
</div>
<?php endif; ?>
<!-- Administrator -->
<div class="mb-3">
<?php //Switch for creation/editing ?>
<?php $admin = $oSurvey->admin; ?>
<div class="row">
<div class="col-12 col-lg-8 content-right">
<label class=" form-label" for='admin'><?php eT("Administrator:"); ?></label>
<input class="form-control inherit-edit <?php echo($bShowInherited && $admin === 'inherit' ? 'd-none' : 'd-block'); ?>" type='text' size='50' id='admin' name='admin'
value="<?php echo htmlspecialchars((string) $admin); ?>" data-inherit-value="inherit" data-saved-value="<?php echo htmlspecialchars((string) $admin); ?>"/>
<input class="form-control inherit-readonly <?php echo($bShowInherited && $admin === 'inherit' ? 'd-block' : 'd-none'); ?>" type='text' size='50'
value="<?php echo htmlspecialchars((string) $oSurveyOptions->admin); ?>" readonly/>
</div>
<div class="col-12 col-lg-4 content-right <?php echo($bShowInherited ? 'd-block' : 'd-none'); ?>">
<label class=" form-label content-center col-12" for='admin'><?php eT("Inherit:"); ?></label>
<?php $this->widget('ext.ButtonGroupWidget.ButtonGroupWidget', [
'name' => 'adminbutton',
'checkedOption' => ($bShowInherited && $admin === 'inherit' ? 'Y' : 'N'),
'selectOptions' => $optionsOnOff,
'htmlOptions' => [
'class' => 'text-option-inherit'
]
]); ?>
</div>
</div>
</div>
<!-- Admin email -->
<div class="mb-3">
<?php //Switch for creation/editing ?>
<?php $adminemail = $oSurvey->adminemail; ?>
<div class="row">
<div class="col-12 col-lg-8 content-right">
<label class=" form-label" for='adminemail'><?php eT("Administrator email address:"); ?></label>
<input class="form-control inherit-edit <?php echo($bShowInherited && $adminemail === 'inherit' ? 'd-none' : 'd-block'); ?>" type='<?php echo ($bShowInherited) ? 'text' : 'email'; ?>'
size='50' id='adminemail' name='adminemail' value="<?php echo htmlspecialchars((string) $adminemail); ?>" data-inherit-value="inherit" data-saved-value="<?php echo htmlspecialchars((string) $adminemail); ?>"/>
<input class="form-control inherit-readonly <?php echo($bShowInherited && $adminemail === 'inherit' ? 'd-block' : 'd-none'); ?>" type='text' size='50'
value="<?php echo htmlspecialchars((string) $oSurveyOptions->adminemail); ?>" readonly/>
</div>
<div class="col-12 col-lg-4 content-right <?php echo($bShowInherited ? 'd-block' : 'd-none'); ?>">
<label class=" form-label content-center col-12" for='adminemail'><?php eT("Inherit:"); ?></label>
<?php $this->widget('ext.ButtonGroupWidget.ButtonGroupWidget', [
'name' => 'adminemailbutton',
'checkedOption' => ($bShowInherited && $adminemail === 'inherit' ? 'Y' : 'N'),
'selectOptions' => $optionsOnOff,
'htmlOptions' => [
'class' => 'text-option-inherit'
]
]); ?>
</div>
</div>
</div>
<!-- Bounce email -->
<div class="mb-3">
<?php //Switch for creation/editing ?>
<?php $bounce_email = $oSurvey->bounce_email; ?>
<div class="row">
<div class="col-12 col-lg-8 content-right">
<label class=" form-label" for='bounce_email'><?php eT("Bounce email address:"); ?></label>
<input class="form-control inherit-edit <?php echo($bShowInherited && $bounce_email === 'inherit' ? 'd-none' : 'd-block'); ?>"
type='<?php echo ($bShowInherited) ? 'text' : 'email'; ?>' size='50' id='bounce_email' name='bounce_email' value="<?php echo htmlspecialchars((string) $bounce_email); ?>"
data-inherit-value="inherit" data-saved-value="<?php echo htmlspecialchars((string) $bounce_email); ?>"/>
<input class="form-control inherit-readonly <?php echo($bShowInherited && $bounce_email === 'inherit' ? 'd-block' : 'd-none'); ?>" type='text' size='50'
value="<?php echo htmlspecialchars((string) $oSurveyOptions->bounce_email); ?>" readonly/>
</div>
<div class="col-12 col-lg-4 content-right <?php echo($bShowInherited ? 'd-block' : 'd-none'); ?>">
<label class=" form-label content-center col-12" for='bounce_email'><?php eT("Inherit:"); ?></label>
<?php $this->widget('ext.ButtonGroupWidget.ButtonGroupWidget', [
'name' => 'bounce_emailbutton',
'checkedOption' => ($bShowInherited && $bounce_email === 'inherit' ? 'Y' : 'N'),
'selectOptions' => $optionsOnOff,
'htmlOptions' => [
'class' => 'text-option-inherit '
]
]); ?>
</div>
</div>
</div>
<?php else: ?>
<!-- End URL -->
<div class="mb-3">
<label class=" form-label" for='url'><?php eT("End URL:"); ?></label>
<div class="">
<input type='text' class="form-control" id='url' name='url' placeholder="http://example.com"/>
</div>
</div>
<!-- URL description -->
<div class="mb-3">
<label class=" form-label" for='urldescrip'><?php eT("URL description:"); ?></label>
<div class="">
<input type='text' maxlength='255' size='50' id='urldescrip' name='urldescrip' value='' class="form-control" placeholder="<?php eT('Some description text'); ?>"/>
</div>
</div>
<!-- Date format -->
<div class="mb-3">
<label class=" form-label" for='dateformat'><?php eT("Date format:"); ?></label>
<div class="">
<?php echo CHtml::listBox('dateformat', $sDateFormatDefault, $aDateFormatData, array('id' => 'dateformat', 'size' => '1', 'class' => 'form-control')); ?>
</div>
</div>
<!-- Decimal mark -->
<div class="mb-3">
<label class=" form-label" for='numberformat'><?php eT("Decimal mark:"); ?></label>
<div class="">
<?php echo CHtml::listBox('numberformat', $sRadixDefault, $aRadixPointData, array('id' => 'numberformat', 'size' => '1', 'class' => 'form-control')); ?>
</div>
</div>
<!-- Administrator -->
<div class="mb-3">
<label class=" form-label" for='admin'><?php eT("Administrator:"); ?></label>
<div class="">
<input type='text' size='50' id='admin' name='admin' class="form-control" value='<?php echo $owner['full_name']; ?>'/>
</div>
</div>
<!-- Admin email -->
<div class="mb-3">
<label class=" form-label" for='adminemail'><?php eT("Administrator email address:"); ?></label>
<div class="">
<input type='email' size='30' class="form-control" id='adminemail' name='adminemail' value='<?php echo $owner['email']; ?>'/>
</div>
</div>
<!-- Bounce Email -->
<div class="mb-3">
<label class=" form-label" for='bounce_email'><?php eT("Bounce email address:"); ?></label>
<div class="">
<input type='email' size='50' class="form-control" id='bounce_email' name='bounce_email' value='<?php echo $owner['bounce_email']; ?>'/>
</div>
</div>
<?php endif; ?>
</div>
<div class="col-lg-6 col-12">
<!-- Survey Group -->
<?php if ($bShowAllOptions === true) { ?>
<div class="mb-3">
<label class=" form-label" for='gsid'><?php eT("Group:"); ?></label>
<div class="">
<?php $this->widget('yiiwheels.widgets.select2.WhSelect2',
array(
'asDropDownList' => true,
'htmlOptions' => array('style' => "width: 100%"),
'data' => isset($aSurveyGroupList) ? $aSurveyGroupList : [],
'value' => $oSurvey->gsid,
'name' => 'gsid',
'pluginOptions' => array()
)
); ?>
</div>
</div>
<?php } ?>
<!-- Format -->
<div class="mb-3">
<label class=" form-label" for='format'><?php eT("Format:"); ?></label>
<div>
<?php $this->widget('ext.ButtonGroupWidget.ButtonGroupWidget', [
'name' => 'format',
'checkedOption' => $oSurvey->format,
'selectOptions' => $formatSelectOptions,
]); ?>
</div>
</div>
<?php
$themeConf = TemplateConfiguration::getInstanceFromTemplateName(($oSurvey->template === 'inherit') ? $oSurveyOptions->template : $oSurvey->template);
$inheritedThemeName = $oSurvey->oOptions->template;
?>
<!-- Theme -->
<div class="mb-3" >
<label class=" form-label" for='template'><?php eT("Theme:"); ?></label>
<div class="">
<select id='template' style="width:100%;" class="form-select activate-search" name='template' data-updateurl='<?php echo App()->createUrl('themeOptions/getPreviewTag') ?>'
data-inherit-template-name='<?= $themeConf->template_name ?>'>
<?php if ($bShowInherited || $bGlobalSettings) : ?>
<option value="inherit" <?= ($oSurvey->template == 'inherit') ? 'selected="selected"' : ''; ?>>
<?= gT('Inherit') . ' [' . CHtml::encode($inheritedThemeName) . ']' ?>
</option>
<?php endif; ?>
<?php
$aTemplateList = Template::getTemplateList();
foreach ($aTemplateList as $templateName => $folder) {
if (Permission::model()->hasGlobalPermission('templates', 'read') || Permission::model()->hasTemplatePermission($templateName
) || $oSurvey->template == htmlspecialchars((string) $templateName)) { ?>
<option value='<?php echo CHtml::encode($templateName); ?>'
<?php if ($oSurvey->template && htmlspecialchars((string) $templateName) === $themeConf->template_name && $oSurvey->template !== 'inherit') { ?>
selected='selected'
<?php } elseif (!$oSurvey->template && $templateName === App()->getConfig('defaulttheme') && $oSurvey->template !== 'inherit') { ?>
selected='selected'
<?php } ?>
><?php echo CHtml::encode($templateName); ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
<div class="col-md-6 mt-4 w-100" id="preview-image-container">
<?php echo $themeConf->getPreview() ?>
</div>
</div>
<?php
/* @todo : add a js var with standard template list name */
//$aStandardTemplateLis=Template::getStandardTemplateList();
?>
</div>
</div>
<?php $this->renderPartial('/surveyAdministration/_inherit_sub_footer'); ?>