PluginProbe
WP Directory Kit / 1.2.8
WP Directory Kit v1.2.8
1.5.9 1.5.7 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 All 37 releases
wpdirectorykit / application / views / wdk_searchform / searchform_edit.php

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

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