-
Notifications
You must be signed in to change notification settings - Fork 987
/
index.php
342 lines (335 loc) · 21 KB
/
index.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
<?php
/**
* @var ThemeOptionsController $this
* @var CActiveDataProvider $dataProvider
* @var bool $canImport
* @var string $importErrorMessage
* @var object $oQuestionTheme
* @var TemplateConfig $oSurveyTheme
* @var int $pageSize
* @var array $aAdminThemes
* @var array $aTemplatesWithoutDB
*/
// TODO: rename to template_list.php and move to template controller
// DO NOT REMOVE This is for automated testing to validate we see that page
echo viewHelper::getViewTestTag('templateOptions');
?>
<div class="list-themes">
<ul class="nav nav-tabs" id="themelist">
<li class="nav-item">
<a class="nav-link active" href="#surveythemes" data-bs-toggle="tab">
<?php eT('Survey themes'); ?>
</a>
</li>
<li>
<a class="nav-link" href="#adminthemes" data-bs-toggle="tab">
<?php eT('Admin themes'); ?>
</a>
</li>
<li>
<a class="nav-link" href="#questionthemes" data-bs-toggle="tab">
<?php eT('Question themes'); ?>
</a>
</li>
</ul>
<div class="tab-content">
<div id="surveythemes" class="tab-pane active">
<div class="list-surveys">
<h3><?= gT('Installed survey themes:') ?></h3>
<?php $this->renderPartial('./surveythemelist', [
'oSurveyTheme' => $oSurveyTheme,
'pageSize' => $pageSize
]
); ?>
<!-- Available Themes -->
<?php if (!empty($aTemplatesWithoutDB['valid'])) : ?>
<h3><?php eT('Available survey themes:'); ?></h3>
<div id="templates_no_db" >
<table class="items table table-hover">
<thead>
<tr>
<th><?php eT('Preview'); ?></th>
<th><?php eT('Folder'); ?></th>
<th><?php eT('Description'); ?></th>
<th><?php eT('Type'); ?></th>
<th><?php eT('Extends'); ?></th>
<th></th>
</tr>
</thead>
<tbody>
<?php /** @var TemplateManifest $oTemplate */ ?>
<?php $surveyThemeIterator = 0 ?>
<?php foreach ($aTemplatesWithoutDB['valid'] as $key => $oTemplate) : ?>
<tr class="odd">
<td class="col-lg-1"><?php echo $oTemplate->getPreview(); ?></td>
<td class="col-lg-2"><?php echo $oTemplate->sTemplateName; ?></td>
<td class="col-lg-3"><?php echo $oTemplate->getDescription(); ?></td>
<td class="col-lg-2"><?php eT('XML themes'); ?></td>
<td class="col-lg-1"><?php echo $oTemplate->config->metadata->extends; ?></td>
<?php if (TemplateConfig::isCompatible($oTemplate->path . 'config.xml')): ?>
<td class="col-lg-2"><?php echo $oTemplate->getButtons(); ?></td>
<?php else: ?>
<td class="col-lg-2">
<div class="d-grid gap-2">
<button type="button" class="btn btn-danger btn-sm" data-bs-toggle="modal"
data-bs-target="#templates_no_db_error_<?= $surveyThemeIterator ?>">
<i class="ri-error-warning-fill"></i><?= gT('Show errors') ?>
</button>
<div class="modal fade" id="templates_no_db_error_<?= $surveyThemeIterator ?>" tabindex="-1"
aria-labelledby="templates_no_db_error_title_<?= $surveyThemeIterator ?>" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="templates_no_db_error_title_<?= $surveyThemeIterator ?>"><?= gT('Errors') ?></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p><?= gT('The theme is not compatible with your version of LimeSurvey.') ?><br>
<a href="https://manual.limesurvey.org/Extension_compatibility" target="_blank">
<?= gT('For more information consult our manual.') ?>
</a>
</p>
<p><?= gT('Custom theme options set for this theme have been reset to the default.') ?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><?= gT('Close') ?></button>
</div>
</div>
</div>
</div>
<!-- Export -->
<?php if (Permission::model()->hasGlobalPermission('templates', 'export') && class_exists('ZipArchive')) : ?>
<a class="btn btn-outline-secondary btn-sm" id="button-export"
href="<?php echo $this->createUrl('admin/themes/sa/templatezip/templatename/' . $oTemplate->sTemplateName) ?>">
<span class="ri-upload-fill"></span>
<?php eT("Export"); ?>
</a>
<?php endif; ?>
<!-- Delete -->
<?php if (Permission::model()->hasGlobalPermission('templates', 'delete')) : ?>
<a id="template_editor_link_<?= $oTemplate->sTemplateName ?>"
href="<?php echo Yii::app()->getController()->createUrl('admin/themes/sa/deleteAvailableTheme/') ?>"
data-post='{ "templatename": "<?= CHtml::encode($oTemplate->sTemplateName) ?>" }'
data-text="<?php eT('Are you sure you want to delete this theme?'); ?>"
data-button-no="<?= gT('Cancel'); ?>"
data-button-yes="<?= gT('Delete'); ?>"
title="<?php eT('Delete'); ?>"
class="btn btn-danger btn-sm selector--ConfirmModal">
<span class="ri-delete-bin-fill"></span>
<?php eT('Delete'); ?>
</a>
<?php endif; ?>
</div>
</td>
<?php endif; ?>
</tr>
<?php $surveyThemeIterator++ ?>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
<!-- End Available Themes -->
<!-- Broken Themes -->
<?php if (!empty($aTemplatesWithoutDB['invalid'])) : ?>
<h3><?php eT('Broken survey themes'); ?></h3>
<div id="thembes_broken" >
<table class="items table table-hover">
<thead>
<tr>
<th><?php eT('Name'); ?></th>
<th><?php eT('Error message'); ?></th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach ($aTemplatesWithoutDB['invalid'] as $sName => $oBrokenTheme) : ?>
<tr class="odd">
<td class="col-lg-1 text-danger"><?= $sName ?></td>
<td class="col-lg-8 ">
<blockquote><?= $oBrokenTheme['error'] ?? '' ?></blockquote>
</td>
<td class="col-lg-2">
<div class="d-grid gap-2">
<!-- Export -->
<?php if (Permission::model()->hasGlobalPermission('templates', 'export') && class_exists('ZipArchive')) : ?>
<a class="btn btn-outline-secondary btn-sm" id="button-export"
href="<?php echo $this->createUrl('admin/themes/sa/brokentemplatezip/templatename/' . $sName) ?>">
<span class="ri-upload-fill"></span>
<?php eT("Export"); ?>
</a>
<?php endif; ?>
<!-- Delete -->
<?php if (Permission::model()->hasGlobalPermission('templates', 'delete')) : ?>
<a id="button-delete"
href="<?php echo Yii::app()->getController()->createUrl('admin/themes/sa/deleteBrokenTheme/'); ?>"
data-post='{ "templatename": "<?php echo CHtml::encode($sName); ?>" }'
data-text="<?php eT('Are you sure you want to delete this theme?'); ?>"
data-button-no="<?= gT('Cancel'); ?>"
data-button-yes="<?= gT('Delete'); ?>"
title="<?php eT('Delete'); ?>"
class="btn btn-danger btn-sm selector--ConfirmModal">
<span class="ri-delete-bin-fill"></span>
<?php eT('Delete'); ?>
</a>
<?php endif; ?>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
<!-- End Broken Themes -->
<!-- Deprecated Themes -->
<?php $aDeprecatedThemes = Template::getDeprecatedTemplates(); ?>
<?php if (count($aDeprecatedThemes) > 0) : ?>
<h3><?php eT('Deprecated survey themes:'); ?></h3>
<div id="deprecatedThemes" >
<table class="items table table-hover">
<thead>
<tr>
<th><?php eT('Name'); ?></th>
<th><?php eT('Export'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($aDeprecatedThemes as $aDeprecatedTheme) : ?>
<tr class="odd">
<td class="col-lg-9"><?php echo $aDeprecatedTheme['name']; ?></td>
<td class="col-lg-2">
<div class="d-grid gap-2">
<?php if (Permission::model()->hasGlobalPermission('templates', 'export') && class_exists('ZipArchive')) : ?>
<a class="btn btn-outline-secondary btn-sm" id="button-export"
href="<?php echo $this->createUrl('admin/themes/sa/deprecatedtemplatezip/templatename/' . $aDeprecatedTheme['name']) ?>"
role="button">
<span class="ri-upload-fill"></span>
<?php eT("Export"); ?>
</a>
<?php endif; ?>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
<!-- End Deprecated Themes -->
</div>
</div>
<div id="adminthemes" class="tab-pane">
<div class="list-surveys">
<h3><?php eT('Available admin themes:'); ?></h3>
<div id="admin_themes">
<table class="items table table-hover">
<thead>
<tr>
<th><?php eT('Preview'); ?></th>
<th><?php eT('Folder'); ?></th>
<th><?php eT('Description'); ?></th>
<th><?php eT('Type'); ?></th>
<th></th>
</tr>
</thead>
<tbody>
<?php $adminThemeIterator = 0 ?>
<?php foreach ($aAdminThemes as $key => $oTheme) : ?>
<tr class="odd">
<td class="col-lg-1"><?php echo $oTheme->preview; ?></td>
<td class="col-lg-2"><?php echo $oTheme->metadata->name; ?></td>
<td class="col-lg-3"><?php echo $oTheme->metadata->description; ?></td>
<td class="col-lg-2"><?php eT('Core admin theme'); ?></td>
<td class="col-lg-1">
<?php if (TemplateConfig::isCompatible($oTheme->path . 'config.xml')): ?>
<?php if ($oTheme->name === App()->getConfig('admintheme')) : ?>
<h3><strong class="text-info"><?php eT("Selected") ?></strong></h3>
<?php else : ?>
<a href="<?= $this->createUrl("themeOptions/setAdminTheme/", ['sAdminThemeName' => $oTheme->name]) ?>"
class="btn btn-outline-secondary btn-sm">
<?= gT("Select") ?>
</a>
<?php endif; ?>
<?php else: ?>
<button type="button" class="btn btn-danger btn-sm" data-bs-toggle="modal" data-bs-target="#admin_theme_error_<?= $adminThemeIterator ?>">
<i class="ri-error-warning-fill"></i><?= gT('Show errors') ?>
</button>
<div class="modal fade" id="admin_theme_error_<?= $adminThemeIterator ?>" tabindex="-1"
aria-labelledby="#admin_theme_error_title_<?= $adminThemeIterator ?>" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="admin_theme_error_title_<?= $adminThemeIterator ?>"><?= gT('Errors') ?></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p><?= gT('The theme is not compatible with your version of LimeSurvey.') ?></p>
<a href="https://manual.limesurvey.org/Extension_compatibility" target="_blank">
<?= gT('For more information consult our manual.') ?>
</a>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><?= gT('Close') ?></button>
</div>
</div>
</div>
</div>
<?php endif; ?>
</td>
</tr>
<?php $adminThemeIterator++?>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<div id="questionthemes" class="tab-pane">
<div class="col-12 list-surveys">
<?php echo '<h3>' . gT('Question themes:') . '</h3>'; ?>
<!-- Installed Question Themes -->
<?php $this->renderPartial('./installedthemelist', array('oQuestionTheme' => $oQuestionTheme, 'pageSize' => $pageSize)); ?>
<!-- Available Quesiton Themes and broken question themes-->
<?php $this->renderPartial('./availablethemelist', array('oQuestionTheme' => $oQuestionTheme, 'pageSize' => $pageSize)); ?>
</div>
</div>
</div>
</div>
<?php $this->renderPartial(
'./surveythememenu',
[
'canImport'=>$canImport,
'importErrorMessage'=>$importErrorMessage,
'importModal' => 'importSurveyModal',
'importTemplate' => 'importSurveyTemplate',
'themeType' => 'survey'
]
); ?>
<?php $this->renderPartial(
'./surveythememenu',
[
'canImport' => $canImport,
'importErrorMessage' => $importErrorMessage,
'importModal' => 'importQuestionModal',
'importTemplate' => 'importQuestionTemplate',
'themeType' => 'question'
]
); ?>
</div>
<script>
$('#themelist a').click(function (e) {
var target = $(e.target).attr("href");
$("#uploadandinstall").css('visibility', 'visible');
if (target === "#questionthemes") {
$("#uploadandinstall").attr('data-bs-target', '#importQuestionModal');
}
if (target === "#surveythemes") {
$("#uploadandinstall").attr('data-bs-target', '#importSurveyModal');
}
if(target === "#adminthemes") { //no upload$install for adminthemes
$("#uploadandinstall").attr('data-bs-target', '');
$("#uploadandinstall").css('visibility', 'hidden');
}
});
</script>