/
templateeditorbar_view.php
150 lines (138 loc) · 6.23 KB
/
templateeditorbar_view.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
<?php
/* @var AdminController $this */
/* @var string $codelanguage */
/* @var string $highlighter */
// DO NOT REMOVE This is for automated testing to validate we see that page
echo viewHelper::getViewTestTag('themeEditor');
?>
<script type="text/javascript">
var adminlanguage = '<?php echo $codelanguage; ?>';
var highlighter = '<?php echo $highlighter; ?>';
</script>
<script type='text/javascript'>
function copyprompt(text, defvalue, copydirectory, action) {
if (newtemplatename = window.prompt(text, defvalue)) {
window.LS.sendPost(
'<?php echo $this->createUrl('admin/themes/sa/template'); ?>' + action,
false,
{'action': 'template' + action, 'newname': newtemplatename, 'copydir': copydirectory})
}
}
$(document).ready(function () {
$("#importtemplatefile").submit(function () {
filename = $("#upload_file").val();
if (filename == "") {
return false; // False click
}
var allowedtypes = ',<?php echo Yii::app()->getConfig('allowedthemeuploads') . ',' . Yii::app()->getConfig('allowedthemeimageformats'); ?>,';
var lastdotpos = -1;
var ext = '';
if ((lastdotpos = filename.lastIndexOf('.')) < 0) {
alert('<?php eT('This file type is not allowed to be uploaded.', 'js'); ?>');
return false;
} else {
ext = ',' + filename.substr(lastdotpos + 1) + ',';
ext = ext.toLowerCase();
if (allowedtypes.indexOf(ext) < 0) {
alert('<?php eT('This file type is not allowed to be uploaded.', 'js'); ?>');
return false;
} else {
return true;
}
}
});
});
</script>
<?php
App()->getClientScript()->registerScriptFile(
App()->getConfig('adminscripts') . 'topbar.js',
CClientScript::POS_END
);
//this line is from old part (see old_templateTopbar.php), it has always been false
$importModal = false;
?>
<?php if ($importModal) : ?>
<?php $this->renderPartial('themeOptions/import_modal', ['importTemplate' => 'importtemplate', 'importModal' => 'importModal']); ?>
<?php endif; ?>
<!-- theme dropdown select boxes-->
<!-- Right Menu -->
<div class="mt-3 mb-3">
<div class="row row-cols-auto align-items-center justify-content-end gx-2">
<!-- Theme Select Box -->
<label class="col col-form-label text-nowrap" for='templatedir'><?php eT("Theme:"); ?></label>
<div class="col">
<select class="col listboxtemplates form-select activate-search" id='templatedir' name='templatedir'
onchange="javascript: var uri = new Uri('<?php
// Don't put 'sa' into the URL dirctly because Yii will then try to use filenames directly in the path because of the route
echo $this->createUrl("admin/themes",
[
'sa' => 'view',
'editfile' => $relativePathEditfile,
'screenname' => $screenname
]); ?>'); uri.addQueryParam('templatename',this.value); window.open(uri.toString(), '_top')">
<?php echo themeoptions($templates, $templatename); ?>
</select>
</div>
<!-- Screen Select Box -->
<label class="col col-form-label text-nowrap" for='listboxtemplates'><?php eT("Screen:"); ?></label>
<div>
<?php echo CHtml::dropDownList('screenname',
$screenname,
$screens,
[
'id' => 'listboxtemplates',
'class' => "col listboxtemplates form-select activate-search",
'onchange' => "javascript: var uri = new Uri('" . $this->createUrl("admin/themes",
[
'sa' => 'view',
'editfile' => $relativePathEditfile,
'templatename' => $templatename
]) . "'); uri.addQueryParam('screenname',this.value); window.open(uri.toString(), '_top')"
]); ?>
</div>
<!-- @TODO unused button???-->
<?php if (isset($fullpagebar['savebutton']['form'])) : ?>
<a class="btn btn-primary" href="#" role="button" id="save-form-button"
data-form-id="<?php echo $fullpagebar['savebutton']['form']; ?>">
<span class="ri-check-fill"></span>
<?php eT("Save"); ?>
</a>
<?php endif; ?>
</div>
<!-- Template Editor -->
<div class="col-12 templateeditor">
<?php if (!is_template_editable($templatename)) : ?>
<?php
$message = '<strong>' .
gT('Note: This is a standard theme.') .
'</strong> ' .
sprintf(
gT('If you want to modify it %s you can extend it%s.'),
"<a href='#' title=\"" . gT("Extend theme") . "\""
. " onclick=\"javascript: copyprompt('" . gT("Please enter the name for the new theme:") . "', '" . gT("extends_") . "$templatename', '$templatename', 'copy')\">",
'</a>'
);
$this->widget('ext.AlertWidget.AlertWidget', [
'text' => $message,
'type' => 'info',
'htmlOptions' => ['class' => 'mt-1'],
]);
?>
<?php endif; ?>
<?php if ((int)$templateapiversion < (int)App()->getConfig("templateapiversion")) : ?>
<?php
$message = sprintf(
gT(
'We can not guarantee optimum operation. It would be preferable to no longer use it or to make it compatible with the version %s of the LimeSurvey API.'
),
intval(App()->getConfig("versionnumber"))
);
$this->widget('ext.AlertWidget.AlertWidget', [
'header' => gT('This theme is out of date.'),
'text' => $message,
'type' => 'info',
]);
?>
<?php endif; ?>
</div>
</div>