/
admin_templates.php
313 lines (260 loc) · 9.5 KB
/
admin_templates.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
<script type="text/html" id="bulk-actions-active-tmpl">
<option selected="selected" value=""><?php echo __('Bulk Actions'); ?></option>
<option value="export"><?php echo __('Export Selected'); ?></option>
<?php if( current_user_can( Caldera_Forms::get_manage_cap() ) ){ ?><option value="trash"><?php echo __('Move to Trash'); ?></option><?php } ?>
</script>
<script type="text/html" id="cf-export-template">
<input type="hidden" name="export-form" value="{{formid}}">
<input type="hidden" name="cal_del" value="{{nonce}}">
<div class="caldera-config-group">
<label><?php echo __('Export Type', 'caldera-forms'); ?></label>
<div class="caldera-config-field">
<select class="form-export-type" name="format" style="width: 230px;">
<option value="json"><?php _e('Backup / Importable (json)' , 'caldera-forms' ); ?></option>
<option value="php"><?php _e('PHP include File' , 'caldera-forms' ); ?></option>
</select>
</div>
</div>
<p class="description" id="json_export_option"><?php _e('This gives you a .json file that can be imported into Caldera Forms.'); ?></p>
<div style="display:none;" id="php_export_options">
<div class="caldera-config-group">
<label><?php echo __('Form ID', 'caldera-forms'); ?></label>
<div class="caldera-config-field">
<input type="text" class="block-input field-config" data-format="key" name="form_id" value="{{formslug}}" required="required">
</div>
</div>
<div class="caldera-config-group">
<label><?php echo __('Pin to Admin', 'caldera-forms'); ?></label>
<div class="caldera-config-field">
<label><input type="checkbox" name="pin_menu" value="1"> <?php _e("Set form to be pinned to Admin Menu", "caldera-forms"); ?></label>
</div>
</div>
<div class="caldera-config-group">
<label><?php echo __('Field Slugs', 'caldera-forms'); ?></label>
<div class="caldera-config-field">
<label><input type="checkbox" name="convert_slugs" value="1"> <?php _e("Convert Field ID's to use field slugs", "caldera-forms"); ?></label>
</div>
</div>
<hr>
<p class="description"><?php _e('This gives you a hardcoded .php file that can be included in projects. It includes the correct filter for the ID specific form allowing you to easily use the form by simply including the file.'); ?></p>
<p class="description"><?php _e('This is not a backup and cannot be imported.'); ?></p>
</div>
{{#script}}
jQuery( function( $ ){
$(document).on('change', '.form-export-type', function(){
if( this.value === 'php' ){
$('#json_export_option').slideUp(100);
$('#php_export_options').slideDown(100);
}else{
$('#php_export_options').slideUp(100);
$('#json_export_option').slideDown(100);
}
})
});
{{/script}}
</div>
</script>
<script type="text/html" id="bulk-actions-trash-tmpl">
<option selected="selected" value=""><?php echo __('Bulk Actions'); ?></option>
<option value="export"><?php echo __('Export Selected'); ?></option>
<?php if( current_user_can( 'delete_others_posts' ) ){ ?><option value="active"><?php echo __('Restore'); ?></option>
<option value="delete"><?php echo __('Delete Permanently'); ?></option><?php } ?>
</script>
<script type="text/html" id="import-form-tmpl">
<form class="new-form-form" action="admin.php?page=caldera-forms&import=true" enctype="multipart/form-data" method="POST">
<?php
wp_nonce_field( 'cf-import', 'cfimporter' );
do_action('caldera_forms_import_form_template_start');
?>
<div class="caldera-config-group">
<label for=""><?php echo __('Form Name', 'caldera-forms'); ?></label>
<div class="caldera-config-field">
<input type="text" class="new-form-name block-input field-config" name="name" value="" required="required">
</div>
</div>
<div class="caldera-config-group">
<label for=""><?php echo __('Form File', 'caldera-forms'); ?></label>
<div class="caldera-config-field">
<input type="file" class="new-form-name" name="import_file" required="required" style="width: 230px;">
</div>
</div>
<div class="baldrick-modal-footer" style="display: block; clear: both; position: relative; height: 24px; width: 100%; margin: 0px -12px;">
<button type="submit" class="button button-primary" style="float:right;"><?php echo __('Import Form', 'caldera-forms'); ?></button>
</div>
<?php
do_action('caldera_forms_import_form_template_end');
?>
</form>
</script>
<script type="text/html" id="new-form-tmpl">
{{#if clone}}
<?php
do_action('caldera_forms_clone_form_template_start');
?>
{{else}}
<?php
do_action('caldera_forms_new_form_template_start');
?>
{{/if}}
<div class="caldera-config-group">
<label for=""><?php echo __('Form Name', 'caldera-forms'); ?></label>
<div class="caldera-config-field">
<input type="text" class="new-form-name block-input field-config" name="name" value="" required="required">
</div>
</div>
<div class="caldera-config-group">
<label for=""><?php echo __('Description', 'caldera-forms'); ?></label>
<div class="caldera-config-field">
<textarea class="block-input field-config" name="description" value=""></textarea>
</div>
</div>
{{#if clone}}<input type="hidden" name="clone" value="{{clone}}">
<?php
do_action('caldera_forms_clone_form_template_end');
?>
{{else}}
<?php
do_action('caldera_forms_new_form_template_end');
?>
{{/if}}
</script>
<script type="text/html" id="forms-list-alt-tmpl">
{{#if entries}}
<div class="list form-panel postbox" data-form="{{form}}">
<table class="table table-condensed cf-table-viewer">
<thead>
<tr>
<th style="width:16px;"><input type="checkbox" class="cf-bulkcheck"></th>
<th><?php echo __('ID', 'caldera-forms'); ?></th>
<th><?php echo __('Submitted', 'caldera-forms'); ?></th>
{{#each fields}}
<th>{{this}}</th>
{{/each}}
<th style="width: 100px;"></th>
</tr>
</thead>
<tbody>
{{#if entries}}
{{#each entries}}
<tr id="entry_row_{{_entry_id}}">
<td style="width:16px;"><input type="checkbox" class="cf-entrycheck" value="{{_entry_id}}"></td>
<td>{{_entry_id}}</td>
<td>{{_date}}</td>
{{#each data}}
<td>{{#if label}}{{value}}{{else}}{{{this}}}{{/if}}</td>
{{/each}}
<td style="text-align: right; width: 100px;"><?php do_action('caldera_forms_entry_actions'); ?></td>
</tr>
{{/each}}
{{else}}
<tr><td colspan="100"><?php echo __('No entries found', 'caldera-forms'); ?></td></tr>
{{/if}}
</tbody>
</table>
</div>
{{else}}
<p class="description"><?php echo __('No entries yet.', 'caldera-forms'); ?></p>
{{/if}}
</script>
<script type="text/html" id="view-entry-tmpl">
{{#if user}}
<div class="user-avatar user-avatar-{{user/ID}}"{{#if user/name}} title="{{user/name}}"{{/if}} style="margin-top:-1px;">
{{{user/avatar}}}
</div>
{{/if}}
<div id="main-entry-panel" class="tab-detail-panel" data-tab="<?php _e('Entry', 'caldera-forms'); ?>">
<h4><?php echo __('Submitted', 'caldera-forms'); ?> <small class="description">{{date}}</small></h4>
<hr>
{{#each data}}
<div class="entry-line">
<label>{{label}}</label>
<div>{{#if view/label}}{{view/value}}{{else}}{{{view}}}{{/if}} </div>
</div>
{{/each}}
</div>
{{#if meta}}
{{#each meta}}
<div id="meta-{{@key}}" data-tab="{{name}}" class="tab-detail-panel">
<h4>{{name}}</h4>
<hr>
{{#unless template}}
{{#each data}}
{{#if title}}
<h4>{{title}}</h4>
{{/if}}
{{#each entry}}
<div class="entry-line">
<label>{{meta_key}}</label>
<div>{{{meta_value}}} </div>
</div>
{{/each}}
{{/each}}
{{/unless}}
<?php do_action('caldera_forms_entry_meta_templates'); ?>
</div>
{{/each}}
{{/if}}
</script>
<script type="text/javascript">
jQuery(function($){
$('body').on('change', '.cf-bulkcheck', function(){
var checked = $(this),
parent = checked.closest('.cf-table-viewer'),
checks = parent.find('.cf-entrycheck'),
action = $('#cf_bulk_action');
checks.prop('checked', checked.prop('checked'));
});
$('body').on('change', '.cf-entrycheck', function(){
var checkall = $('.cf-bulkcheck'),
allchecks = $('.cf-entrycheck'),
checked = $('.cf-entrycheck:checked');
if(allchecks.length != checked.length){
checkall.prop('checked', false);
}else{
checkall.prop('checked', true);
}
});
$('body').on('click', '.cf-bulk-action', function(){
var action = $('#cf_bulk_action'),
bulkCheck = $('.cf-bulkcheck');
if( !action.val().length){
return;
}
action.prop('disabled', true);
var checks = $('#form-entries-viewer .cf-entrycheck:checked'),
form = $('#form-entries-viewer .list.form-panel').data('form');
if(checks.length){
var list = [],
rows = [];
for( var i = 0; i<checks.length; i++){
list.push(checks[i].value);
rows.push('#entry_row_' + checks[i].value);
}
var row_items = $(rows.join(','));
var data = {
'action' : 'cf_bulk_action',
'do' : action.val(),
'items' : list,
'form' : form
}
row_items.animate({"opacity": .4}, 500);
$.post(ajaxurl, data, function(res){
if(res.status && res.entries && res.total){
row_items.remove();
$('.entry_count_' + form).html(res.total);
$('input.current-page').trigger('change');
}else if(res.url){
row_items.animate({"opacity": 1}, 500);
window.location = res.url;
}else if(res.status === 'reload'){
$('input.current-page').trigger('change');
}
action.val('').prop('disabled', false);
bulkCheck.prop('checked', false);
});
}else{
action.prop('disabled', false);
}
});
});
</script>