PluginProbe
WP Directory Kit / 1.3.1
WP Directory Kit v1.3.1
1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 1.4.0 1.4.1 All 35 releases
wpdirectorykit / application / views / wdk_searchform / searchform_edit.php

searchform_edit.php in WP Directory Kit 1.3.1, at application/views/wdk_searchform/searchform_edit.php

383 lines 27.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The template for Edit Search Form.
4 *
5 * This is the template that form edit
6 *
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly.
11 }
12 ?>
13
14 <!-- This file should primarily consist of HTML with a little bit of PHP. -->
15
16 <div class="wrap wdk-wrap">
17
18 <h1 class="wp-heading-inline"><?php echo __('Search Form Designer','wpdirectorykit'); ?></h1>
19 <br /><br />
20
21 <div class="wdk-body">
22 <form method="post" action="<?php echo esc_url(wmvc_current_edit_url()); ?>" novalidate="novalidate">
23 <?php wp_nonce_field( 'wdk-searchform-edit_'.wmvc_show_data('idsearchform', $db_data, 1), '_wpnonce'); ?>
24 <div class="postbox" style="display: block;">
25 <div class="postbox-header">
26 <h3><?php echo __('Main info','wpdirectorykit'); ?></h3>
27 </div>
28 <div class="inside">
29 <?php
30 $form->messages('class="alert alert-danger"', __('Successfully saved', 'wpdirectorykit'));
31 ?>
32 <table class="form-table" role="presentation">
33 <tbody>
34 <tr>
35 <th scope="row"><label for="searchform_name"><?php echo __('Name','wpdirectorykit'); ?></label></th>
36 <td><input name="searchform_name" type="text" id="searchform_name" value="<?php echo wmvc_show_data('searchform_name', $db_data, ''); ?>" class="regular-text"></td>
37 </tr>
38 <tr class="hidden">
39 <th scope="row"><label for="searchform_json"><?php echo __('Search Form Json/Structure','wpdirectorykit'); ?></label></th>
40 <td>
41 <textarea readonly="readonly" name="searchform_json" type="text" id="searchform_json" class="regular-text"><?php echo esc_textarea(wmvc_show_data('searchform_json', $db_data, '')); ?></textarea>
42 </td>
43 </tr>
44 </tbody>
45 </table>
46 </div>
47 </div>
48
49 <div class="postbox" style="display: block;">
50 <div class="postbox-header">
51 <h3><?php echo __('Helper Classes','wpdirectorykit'); ?></h3>
52 </div>
53 <div class="inside">
54 <div class="" style="border: 1px solid rgb(207, 210, 210); background-color: #eee;padding: 10px 15px;">
55 <dl class="dl-helper">
56 <dt>hidden</dt>
57 <dd style="margin-left: 25px;"><?php echo __('Hide field on all','wpdirectorykit'); ?></dd>
58 <dt>wdk-col-1,wdk-col-2,wdk-col-3,wdk-col-4, wdk-col-n ... 12</dt>
59 <dd style="margin-left: 25px;"><?php echo __('Grid classes from 1 to 12','wpdirectorykit'); ?></dd>
60 </dl>
61 </div>
62 </div>
63 </div>
64
65 <?php
66 $main_fields = array();
67 $predefined_fields_array = array(
68 'search'=> array(
69 'idfield'=> 'search',
70 'field_type'=> 'SMART_SEARCH',
71 'field_label'=> '',
72 ),
73 'post_title'=>array(
74 'idfield'=> 'post_title',
75 'field_type'=> 'INPUTBOX',
76 'field_label'=> 'Title',
77 ),
78 'address'=>array(
79 'idfield'=> 'address',
80 'field_type'=> 'INPUTBOX',
81 'field_label'=> '',
82 ),
83 'cat'=>array(
84 'idfield'=> 'cat',
85 'field_type'=> 'CATEGORY',
86 'field_label'=> '',
87 ),
88 'loc'=>array(
89 'idfield'=> 'loc',
90 'field_type'=> 'LOCATION',
91 'field_label'=> '',
92 ),
93 'more'=>array(
94 'idfield'=> 'more',
95 'field_type'=> 'MORE',
96 'field_label'=> '',
97 ),
98 );
99
100 if(function_exists('run_wdk_bookings')) {
101 $predefined_fields_array['booking_date'] = array(
102 'idfield'=> 'booking_date',
103 'field_type'=> 'BOOKINGS_DATE',
104 'field_label'=> '',
105 );
106 $predefined_fields_array['booking_guest'] = array(
107 'idfield'=> 'booking_guest',
108 'field_type'=> 'NUMBER',
109 'field_label'=> __('Max guests','wpdirectorykit'),
110 );
111 }
112
113 foreach ($predefined_fields_array as $value) {
114 $predefined_field = new stdClass();
115 $predefined_field->idfield = $value['idfield'];
116 $predefined_field->lang_code = NULL;
117 $predefined_field->field_type = $value['field_type'];
118 $predefined_field->field_label = $value['field_label'];
119
120 $fields [] = $predefined_field ;
121 $main_fields [] = $predefined_field;
122 }
123 ?>
124
125 <div class="postbox" style="display: block;">
126 <div class="postbox-header"><h3><?php echo __('Drag & Drop Builder','wpdirectorykit'); ?></h3>
127 </div>
128 <div class="inside">
129 <p class="alert alert-info"><?php echo __('Drag fields from left side to right side, right side represents search form','wpdirectorykit'); ?></p>
130 <div class="wdk-builder-container">
131 <div class="wdk-builder-elements-column">
132 <div class="wdk-builder-elements-box">
133 <h3 class="sec-title"><?php echo __('Custom fields','wpdirectorykit'); ?></h3>
134 <div id="wdk-drag" class="wdk-builder-elements wdk-drop section_fields">
135 <?php foreach($main_fields as $key => $field):
136 if(isset($used_fields[$field->idfield]))continue; // skip if field is used
137 ?>
138 <div id="fid_<?php echo esc_attr($field->idfield); ?>" class="widget ui-draggable" rel="<?php echo esc_attr($field->idfield); ?>">
139 <div class="widget-top">
140 <div class="widget-title-action">
141 <button type="button" class="widget-action hide-if-no-js" aria-expanded="false">
142 <span class="toggle-indicator" aria-hidden="true"></span>
143 </button>
144 </div>
145 <div class="widget-title ui-draggable-handle"><h3>#<?php echo esc_html($field->idfield); ?> [<?php echo esc_html($field->field_type); ?>] <?php echo esc_html($field->field_label); ?><span class="in-widget-title"></span></h3></div>
146 </div>
147 <div class="widget-inside">
148 <div class="widget-content">
149 <p>
150 <label for="fid_<?php echo esc_attr($field->idfield); ?>-class"><?php echo __('CSS Class:','wpdirectorykit'); ?></label>
151 <input class="widefat class" id="fid_<?php echo esc_attr($field->idfield); ?>-class" name="fid_<?php echo esc_attr($field->idfield); ?>-class" type="text" value="">
152 </p>
153 <p>
154 <label for="fid_<?php echo esc_attr($field->idfield); ?>-columns"><?php echo __('Columns/Width:','wpdirectorykit'); ?></label>
155 <input class="widefat columns" id="fid_<?php echo esc_attr($field->idfield); ?>-columns" name="fid_<?php echo esc_attr($field->idfield); ?>-columns" type="number" value="">
156 </p>
157 <p>
158 <label for="fid_<?php echo esc_attr($field->idfield); ?>-query_type"><?php echo __('Search type:','wpdirectorykit'); ?></label>
159 <select class="widefat query_type" id="fid_<?php echo esc_attr($field->idfield); ?>-query_type" name="fid_<?php echo esc_attr($field->idfield); ?>-query_type">
160 <option value=""><?php echo __('None','wpdirectorykit'); ?></option>
161 <option value="exactly"><?php echo __('Exactly','wpdirectorykit'); ?></option>
162 </select>
163 </p>
164 </div>
165 </div>
166 </div>
167 <?php endforeach; ?>
168 <?php foreach($fields as $key => $field):
169 if(isset($used_fields[$field->idfield]))continue; // skip if field is used
170
171 if(in_array($field->idfield, array('search','loc','cat','address','post_title','more','booking_date','booking_guest')) !== FALSE)continue; // skip if field is used
172 ?>
173 <?php if($field->field_type=='SECTION'):?>
174 </div>
175 </div>
176 <div class="wdk-builder-elements-box">
177 <h3 class="sec-title"><?php echo esc_html($field->field_label); ?></h3>
178 <div id="wdk-drag" class="wdk-builder-elements wdk-drop section_fields" data-name="<?php echo esc_html($field->field_label); ?>">
179 <?php continue; endif;?>
180
181 <div id="fid_<?php echo esc_attr($field->idfield); ?>" class="widget ui-draggable" rel="<?php echo esc_attr($field->idfield); ?>">
182 <div class="widget-top">
183 <div class="widget-title-action">
184 <button type="button" class="widget-action hide-if-no-js" aria-expanded="false">
185 <span class="toggle-indicator" aria-hidden="true"></span>
186 </button>
187 </div>
188 <div class="widget-title ui-draggable-handle"><h3>#<?php echo esc_html($field->idfield); ?> [<?php echo esc_html($field->field_type); ?>] <?php echo esc_html($field->field_label); ?><span class="in-widget-title"></span></h3></div>
189 </div>
190 <div class="widget-inside">
191 <div class="widget-content">
192 <p>
193 <label for="fid_<?php echo esc_attr($field->idfield); ?>-class"><?php echo __('CSS Class:','wpdirectorykit'); ?></label>
194 <input class="widefat class" id="fid_<?php echo esc_attr($field->idfield); ?>-class" name="fid_<?php echo esc_attr($field->idfield); ?>-class" type="text" value="">
195 </p>
196 <p>
197 <label for="fid_<?php echo esc_attr($field->idfield); ?>-columns"><?php echo __('Columns/Width:','wpdirectorykit'); ?></label>
198 <input class="widefat columns" id="fid_<?php echo esc_attr($field->idfield); ?>-columns" name="fid_<?php echo esc_attr($field->idfield); ?>-columns" type="number" value="">
199 </p>
200 <p class=" <?php if($field->field_type =='CHECKBOX' || $field->field_type =='MORE' || $field->field_type =='TEXTAREA' || $field->field_type =='TEXTAREA_WYSIWYG' || $field->field_type =='CATEGORY' || $field->field_type =='LOCATION'):?> hidden <?php endif;?>">
201 <label for="fid_<?php echo esc_attr($field->idfield); ?>-query_type"><?php echo __('Search type:','wpdirectorykit'); ?></label>
202 <select class="widefat query_type" id="fid_<?php echo esc_attr($field->idfield); ?>-query_type" name="fid_<?php echo esc_attr($field->idfield); ?>-query_type">
203 <option value=""><?php echo __('None','wpdirectorykit'); ?></option>
204 <option value="exactly"><?php echo __('Exactly','wpdirectorykit'); ?></option>
205 <?php if(in_array($field->idfield, array('search','loc','cat','address','post_title')) == FALSE && $field->field_type !='CHECKBOX'):?>
206 <option value="min"><?php echo __('Min','wpdirectorykit'); ?></option>
207 <option value="max"><?php echo __('Max','wpdirectorykit'); ?></option>
208 <option value="min_max"><?php echo __('Min/Max','wpdirectorykit'); ?></option>
209 <?php endif;?>
210 <?php if(in_array($field->idfield, array('search','loc','cat','address','post_title')) == FALSE && $field->field_type =='NUMBER'):?>
211 <option value="slider_range"><?php echo __('Slider Range','wpdirectorykit'); ?></option>
212 <?php endif;?>
213 </select>
214 </p>
215 <?php if(in_array($field->idfield, array('search','loc','cat','address','post_title')) == FALSE && $field->field_type =='NUMBER'):?>
216 <p class="is_slider_range <?php if($field->query_type !='slider_range'):?> hidden <?php endif;?>">
217 <label for="fid_<?php echo esc_attr($field->idfield); ?>-value_min"><?php echo __('Value Min:','wpdirectorykit'); ?></label>
218 <input class="widefat value_min" id="fid_<?php echo esc_attr($field->idfield); ?>-value_min" name="fid_<?php echo esc_attr($field->idfield); ?>-value_min" type="number" value="">
219 </p>
220 <p class="is_slider_range <?php if($field->query_type !='slider_range'):?> hidden <?php endif;?>">
221 <label for="fid_<?php echo esc_attr($field->idfield); ?>-value_max"><?php echo __('Value Max:','wpdirectorykit'); ?></label>
222 <input class="widefat value_max" id="fid_<?php echo esc_attr($field->idfield); ?>-value_max" name="fid_<?php echo esc_attr($field->idfield); ?>-value_max" type="number" value="">
223 </p>
224 <?php endif;?>
225 </div>
226 </div>
227 </div>
228 <?php endforeach; ?>
229 </div>
230 </div>
231 </div>
232 <div class="drop-container">
233 <?php
234 $WMVC = &wdk_get_instance();
235 $WMVC->model('field_m');
236
237
238 ?>
239 <div id="wdk-drop" class="wdk-builder-selected wdk-drop">
240 <?php if(is_array($used_fields))
241 foreach($used_fields as $used_field):
242 if(isset($predefined_fields_array[$used_field->field_id])) {
243 $field = $predefined_fields_array[$used_field->field_id];
244 } else {
245 $field = $WMVC->field_m->get_fields_data($used_field->field_id);
246 }
247
248 //if(!isset($used_fields[$field->idfield]))continue; // skip if field is not used
249 ?>
250 <div id="fid_<?php echo esc_attr(wmvc_show_data('idfield', $field)); ?>" class="widget ui-draggable" rel="<?php echo esc_attr(wmvc_show_data('idfield', $field)); ?>">
251 <div class="widget-top">
252 <div class="widget-title-action">
253 <button type="button" class="widget-action hide-if-no-js" aria-expanded="false">
254 <span class="toggle-indicator" aria-hidden="true"></span>
255 </button>
256 <button type="button" class="widget-action-remove" title="<?php echo esc_attr__('Remove','wpdirectorykit');?>">
257 <span class="dashicons dashicons-no"></span>
258 </button>
259 </div>
260 <div class="widget-title ui-draggable-handle"><h3>#<?php echo esc_html(wmvc_show_data('idfield', $field)); ?> [<?php echo esc_html(wmvc_show_data('field_type', $field)); ?>] <?php echo esc_html(wmvc_show_data('field_label', $field)); ?><span class="in-widget-title"></span></h3></div>
261 </div>
262 <div class="widget-inside">
263 <div class="widget-content">
264 <p>
265 <label for="fid_<?php echo esc_attr(wmvc_show_data('idfield', $field)); ?>-class"><?php echo __('CSS Class:','wpdirectorykit'); ?></label>
266 <input class="widefat class" id="fid_<?php echo esc_attr(wmvc_show_data('idfield', $field)); ?>-class" name="fid_<?php echo esc_attr(wmvc_show_data('idfield', $field)); ?>-class" type="text" value="<?php echo wmvc_show_data('class', $used_fields[wmvc_show_data('idfield', $field)], ''); ?>">
267 </p>
268 <p>
269 <label for="fid_<?php echo esc_attr(wmvc_show_data('idfield', $field)); ?>-columns"><?php echo __('Columns/Width:','wpdirectorykit'); ?></label>
270 <input class="widefat columns" id="fid_<?php echo esc_attr(wmvc_show_data('idfield', $field)); ?>-columns" name="fid_<?php echo esc_attr(wmvc_show_data('idfield', $field)); ?>-columns" type="number" value="<?php echo wmvc_show_data('columns', $used_fields[wmvc_show_data('idfield', $field)], ''); ?>">
271 </p>
272 <p class=" <?php if(wmvc_show_data('field_type', $field) =='CHECKBOX' || wmvc_show_data('field_type', $field) =='TEXTAREA' || wmvc_show_data('field_type', $field) =='TEXTAREA_WYSIWYG' || wmvc_show_data('field_type', $field) =='CATEGORY' || wmvc_show_data('field_type', $field) =='LOCATION'):?> hidden <?php endif;?>">
273 <label for="fid_<?php echo esc_attr(wmvc_show_data('idfield', $field)); ?>-query_type"><?php echo __('Search type:','wpdirectorykit'); ?></label>
274 <select class="widefat query_type" id="fid_<?php echo esc_attr(wmvc_show_data('idfield', $field)); ?>-query_type" name="fid_<?php echo esc_attr(wmvc_show_data('idfield', $field)); ?>-query_type">
275 <option value=""><?php echo __('None','wpdirectorykit'); ?></option>
276 <option value="exactly" <?php if(wmvc_show_data('query_type', $used_fields[wmvc_show_data('idfield', $field)]) == 'exactly'): ?> selected="selected" <?php endif;?>><?php echo __('Exactly','wpdirectorykit'); ?></option>
277 <?php if(in_array(wmvc_show_data('idfield', $field), array('search','loc','cat','address','post_title')) == FALSE && wmvc_show_data('field_type', $field) !='CHECKBOX'):?>
278 <option value="min" <?php if(wmvc_show_data('query_type', $used_fields[wmvc_show_data('idfield', $field)]) == 'min'): ?> selected="selected" <?php endif;?>><?php echo __('Min','wpdirectorykit'); ?></option>
279 <option value="max" <?php if(wmvc_show_data('query_type', $used_fields[wmvc_show_data('idfield', $field)]) == 'max'): ?> selected="selected" <?php endif;?>><?php echo __('Max','wpdirectorykit'); ?></option>
280 <option value="min_max" <?php if(wmvc_show_data('query_type', $used_fields[wmvc_show_data('idfield', $field)]) == 'min_max'): ?> selected="selected" <?php endif;?>><?php echo __('Min/Max','wpdirectorykit'); ?></option>
281 <?php endif;?>
282 <?php if(in_array(wmvc_show_data('idfield', $field), array('search','loc','cat','address','post_title')) == FALSE && wmvc_show_data('field_type', $field) =='NUMBER'):?>
283 <option value="slider_range" <?php if(wmvc_show_data('query_type', $used_fields[wmvc_show_data('idfield', $field)]) == 'slider_range'): ?> selected="selected" <?php endif;?>><?php echo __('Slider Range','wpdirectorykit'); ?></option>
284 <?php endif;?>
285 </select>
286 </p>
287 <?php if(in_array(wmvc_show_data('idfield', $field), array('search','loc','cat','address','post_title')) == FALSE && wmvc_show_data('field_type', $field) =='NUMBER'):?>
288 <p class="is_slider_range <?php if(wmvc_show_data('query_type', $used_fields[wmvc_show_data('idfield', $field)]) !='slider_range'):?> hidden <?php endif;?>">
289 <label for="fid_<?php echo esc_attr(wmvc_show_data('idfield', $field)); ?>-value_min"><?php echo __('Value Min:','wpdirectorykit'); ?></label>
290 <input class="widefat value_min" id="fid_<?php echo esc_attr(wmvc_show_data('idfield', $field)); ?>-value_min" name="fid_<?php echo esc_attr(wmvc_show_data('idfield', $field)); ?>-value_min" type="number" value="<?php echo wmvc_show_data('value_min', $used_fields[wmvc_show_data('idfield', $field)], ''); ?>">
291 </p>
292 <p class="is_slider_range <?php if(wmvc_show_data('query_type', $used_fields[wmvc_show_data('idfield', $field)]) !='slider_range'):?> hidden <?php endif;?>">
293 <label for="fid_<?php echo esc_attr(wmvc_show_data('idfield', $field)); ?>-value_max"><?php echo __('Value Max:','wpdirectorykit'); ?></label>
294 <input class="widefat value_max" id="fid_<?php echo esc_attr(wmvc_show_data('idfield', $field)); ?>-value_max" name="fid_<?php echo esc_attr(wmvc_show_data('idfield', $field)); ?>-value_max" type="number" value="<?php echo wmvc_show_data('value_max', $used_fields[wmvc_show_data('idfield', $field)], ''); ?>">
295 </p>
296 <?php endif;?>
297 </div>
298 </div>
299 </div>
300 <?php endforeach; ?>
301 </div>
302 </div>
303 <br style="clear:both;" />
304 </div>
305 <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php echo esc_html__('Save Changes','wpdirectorykit'); ?>">
306 </div>
307 </div>
308 </form>
309 </div>
310
311 </div>
312
313 <?php
314 wp_enqueue_script( 'jquery-ui-core', false, array('jquery') );
315 wp_enqueue_script( 'jquery-ui-sortable', false, array('jquery') );
316 ?>
317
318 <script>
319 // Generate table
320 jQuery(document).ready(function($) {
321
322 $( "#wdk-drag, #wdk-drop" ).sortable({
323 connectWith: ".wdk-drop",
324 placeholder: "ui-sortable-placeholder widget-placeholder",
325 update: function(event, ui) {
326 if(!$(ui.item).find('.widget-action-remove').length){
327 $(ui.item).find('.widget-title-action').append('<button type="button" class="widget-action-remove" title="<?php echo esc_js(__('Remove','wpdirectorykit'));?>"><span class="dashicons dashicons-no"></span></button>');
328 }
329 save_data();
330 remove();
331 }
332 }).disableSelection();
333
334 $('button.widget-action').on('click', function(){
335 if($(this).attr("aria-expanded") == 'true')
336 {
337 $(this).attr("aria-expanded", 'false');
338 $(this).parent().parent().parent().find('.widget-inside').hide();
339 }
340 else
341 {
342 $(this).attr("aria-expanded", 'true');
343 $(this).parent().parent().parent().find('.widget-inside').show();
344 }
345 });
346
347 $('.wdk-builder-container').find('input,select').on('input', save_data);
348
349 $('.wdk-builder-container').find('select.query_type').on('input', function(e){
350 if($(this).find('option:selected').attr('value') == 'slider_range') {
351 $(this).closest('.widget-content').find('.is_slider_range').removeClass('hidden');
352 } else {
353 $(this).closest('.widget-content').find('.is_slider_range').addClass('hidden');
354 }
355 });
356 remove();
357 function remove() {
358 $('#wdk-drop .widget.ui-draggable .widget-action-remove').off().on('click', function(e){
359 e.preventDefault();
360 $('#wdk-drag').first().append($(this).closest('.widget.ui-draggable').detach())
361 save_data();
362 })
363 }
364
365 function save_data()
366 {
367 var data_fields_list = [];
368
369 $('#wdk-drop .widget.ui-draggable').each(function( index ) {
370 data_fields_list.push({'field_id': $( this ).attr('rel'),
371 'class': $( this ).find('input.class').val(),
372 'query_type': $( this ).find('select.query_type').val(),
373 'value_min': $( this ).find('input.value_min').val(),
374 'value_max': $( this ).find('input.value_max').val(),
375 'columns': $( this ).find('input.columns').val()});
376 });
377
378 $('#searchform_json').val(JSON.stringify(data_fields_list));
379 }
380 });
381
382 </script>
383 <?php $this->view('general/footer', $data); ?>