/
templateeditorbar_view.php
243 lines (214 loc) · 12.1 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
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
<?php
/* @var $this AdminController */
// 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>
<div class='menubar' id="templateeditorbar">
<div class='row container-fluid'>
<!-- Left Menu -->
<div class="col-md-5">
<?php $importModal=false;?>
<?php if(is_writable($tempdir)):?>
<!-- Export -->
<?php if(Permission::model()->hasGlobalPermission('templates','export') && function_exists("zip_open")):?>
<a class="btn btn-default" id="button-export" href="<?php echo $this->createUrl('admin/themes/sa/templatezip/templatename/' . $templatename) ?>" role="button">
<span class="icon-export text-success"></span>
<?php eT("Export"); ?>
</a>
<?php endif;?>
<!-- Copy -->
<?php if(Permission::model()->hasGlobalPermission('templates','create')):?>
<?php if (is_writable($userthemerootdir)):?>
<a class="btn btn-default" id="button-extend-<?php echo $templatename; ?>" href="#" role="button" onclick="javascript: copyprompt('<?php eT("Please enter the name for the new theme:"); ?>', '<?php echo gT("extends_")."$templatename"; ?>', '<?php echo $templatename; ?>', 'copy')">
<span class="icon-copy text-success"></span>
<?php eT("Extend"); ?>
</a>
<?php else: ?>
<span class="btntooltip" data-toggle="tooltip" data-placement="bottom" title="<?php eT("The theme upload directory doesn't exist or is not writable."); ?>" style="display: inline-block" data-toggle="tooltip" data-placement="bottom">
<button type="button" class="btn btn-default btntooltip" disabled="disabled">
<span class="icon-copy text-success"></span>
<?php eT("Copy"); ?>
</button>
</span>
<?php endif;?>
<?php endif;?>
<?php else: ?>
<!-- All buttons disabled -->
<!-- import disabled -->
<?php
if (!function_exists("zip_open"))
{
$sMessage=gT("You cannot upload themes because you do not have the required ZIP library installed in PHP.");
}
else
{
$sMessage=gT("Some directories are not writable. Please change the folder permissions for /tmp and /upload/themes in order to enable this option.");
}
if(Permission::model()->hasGlobalPermission('templates','import')):?>
<span class="btntooltip" data-toggle="tooltip" data-placement="bottom" title="<?php echo $sMessage; ?>" style="display: inline-block" data-toggle="tooltip" data-placement="bottom" title="<?php echo $sMessage; ?>" >
<button type="button" class="btn btn-default btntooltip" disabled="disabled">
<span class="icon-import text-muted"></span>
<?php eT("Import"); ?>
</button>
</span>
<?php endif;?>
<!-- export disabled -->
<?php if(Permission::model()->hasGlobalPermission('templates','export')):?>
<span class="btntooltip" data-toggle="tooltip" data-placement="bottom" title="<?php echo $sMessage; ?>" style="display: inline-block" data-toggle="tooltip" data-placement="bottom" title="<?php echo $sMessage; ?>" >
<button type="button" class="btn btn-default btntooltip" disabled="disabled">
<span class="icon-export text-muted"></span>
<?php eT("Export"); ?>
</button>
</span>
<?php endif;?>
<!-- create disabled -->
<?php if(Permission::model()->hasGlobalPermission('templates','create')):?>
<span class="btntooltip" data-toggle="tooltip" data-placement="bottom" title="<?php echo $sMessage; ?>" style="display: inline-block" data-toggle="tooltip" data-placement="bottom" title="<?php echo $sMessage; ?>" >
<button type="button" class="btn btn-default btntooltip" disabled="disabled">
<span class="icon-copy text-muted"></span>
<?php eT("Copy"); ?>
</button>
</span>
<?php endif;?>
<?php endif;?>
<?php if(is_template_editable($templatename)):?>
<?php if(Permission::model()->hasGlobalPermission('templates','update')):?>
<a class="btn btn-default" id="button-rename-theme" href="#" role="button" onclick="javascript: copyprompt('<?php eT("Rename this theme to:"); ?>', '<?php echo $templatename; ?>', '<?php echo $templatename; ?>', 'rename');">
<span class="fa fa-pencil text-success"></span>
<?php eT("Rename"); ?>
</a>
<?php endif;?>
<?php if(Permission::model()->hasGlobalPermission('templates','delete')):?>
<a
id="button-delete"
href="<?php echo Yii::app()->getController()->createUrl('admin/themes/sa/delete/'); ?>"
data-post='{ "templatename": "<?php echo $templatename; ?>" }'
data-text="<?php eT('Are you sure you want to delete this theme?'); ?>"
title="<?php eT('Delete'); ?>"
class="btn btn-danger selector--ConfirmModal">
<span class="fa fa-trash "></span>
<?php eT('Delete'); ?>
</a>
<?php endif;?>
<?php endif;?>
</div>
<!-- Right Menu -->
<div class="col-md-7 text-right form-inline">
<div class="form-group">
<label for='templatedir'><?php eT("Theme:"); ?></label>
<select class="listboxtemplates form-control" 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",array('sa'=>'view','editfile'=>$relativePathEditfile,'screenname'=>$screenname)); ?>'); uri.addQueryParam('templatename',this.value); window.open(uri.toString(), '_top')">
<?php echo themeoptions($templates, $templatename); ?>
</select>
</div>
<div class="form-group">
<label for='listboxtemplates'><?php eT("Screen:"); ?></label>
<?php echo CHtml::dropDownList('screenname',$screenname,$screens,array(
'id'=>'listboxtemplates',
'class'=>"listboxtemplates form-control",
'onchange'=> "javascript: var uri = new Uri('".$this->createUrl("admin/themes",array('sa'=>'view','editfile'=>$relativePathEditfile,'templatename'=>$templatename))."'); uri.addQueryParam('screenname',this.value); window.open(uri.toString(), '_top')"
)); ?>
</div>
<?php if(isset($fullpagebar['savebutton']['form'])):?>
<a class="btn btn-success" href="#" role="button" id="save-form-button" data-form-id="<?php echo $fullpagebar['savebutton']['form']; ?>">
<span class="fa fa-floppy-o" ></span>
<?php eT("Save");?>
</a>
<?php endif;?>
<!-- Close -->
<?php if(isset($fullpagebar['closebutton']['url'])):?>
<a class="btn btn-danger" href="<?php echo $fullpagebar['closebutton']['url']; ?>" role="button">
<span class="fa fa-close" ></span>
<?php eT("Close");?>
</a>
<?php endif;?>
<?php if(isset($fullpagebar['returnbutton'])):?>
<a class="btn btn-default" href="<?php echo $this->createUrl("themeOptions/index"); ?>" role="button">
<span class="fa fa-backward" ></span>
<?php eT("Return to theme list"); ?>
</a>
<?php endif;?>
</div>
</div>
</div>
<?php if($importModal):?>
<?php $this->renderPartial('themeOptions/import_modal', ['importTemplate' => 'importtemplate', 'importModal' => 'importModal']); ?>
<?php endif;?>
<div class="col-lg-12 templateeditor">
<div class="h3 theme-editor-header"><?php eT("Theme editor:"); ?> <i><?php echo $templatename; ?></i></div>
<?php if(!is_template_editable($templatename)):?>
<div class="alert alert-info alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span >×</span></button>
<span class="fa fa-info-sign" ></span>
<strong>
<?php eT('Note: This is a standard theme.');?>
</strong>
<?php
printf(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>');
?>
</div>
<?php endif;?>
<?php if(intval($templateapiversion) < intval(App()->getConfig("templateapiversion")) ):?>
<div class="alert alert-info alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span >×</span></button>
<div class="h4">
<span class="fa fa-info-sign" ></span>
<?php eT('This theme is out of date.');?>
</div>
<?php
printf(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")));
?>
</div>
<?php endif;?>
</div>