PluginProbe
WP Directory Kit / 1.3.3
WP Directory Kit v1.3.3
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_resultitem / resultitem_edit.php

resultitem_edit.php in WP Directory Kit 1.3.3, at application/views/wdk_resultitem/resultitem_edit.php

338 lines 18.9 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 Result Card.
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 <!-- This file should primarily consist of HTML with a little bit of PHP. -->
14
15 <div class="wrap wdk-wrap">
16
17 <h1 class="wp-heading-inline"><?php echo __('Result Card Designer','wpdirectorykit'); ?></h1>
18 <br /><br />
19
20 <div class="wdk-body">
21 <form method="post" action="<?php echo esc_url(wmvc_current_edit_url()); ?>" novalidate="novalidate">
22
23 <?php wp_nonce_field( 'wdk-resultitem-edit_'.wmvc_show_data('idresultitem', $db_data, 1), '_wpnonce'); ?>
24
25 <div class="postbox" style="display: block;">
26 <div class="postbox-header">
27 <h3><?php echo __('Main info','wpdirectorykit'); ?></h3>
28 </div>
29 <div class="inside">
30 <?php
31 $form->messages('class="alert alert-danger"', __('Successfully saved', 'wpdirectorykit'));
32 ?>
33 <table class="form-table" role="presentation">
34 <tbody>
35 <tr>
36 <th scope="row"><label for="resultitem_name"><?php echo __('Name','wpdirectorykit'); ?></label></th>
37 <td><input name="resultitem_name" type="text" id="resultitem_name" value="<?php echo esc_attr(wmvc_show_data('resultitem_name', $db_data, '')); ?>" class="regular-text"></td>
38 </tr>
39 <tr>
40 <th scope="row"><label for="is_multiline_enabled"><?php echo __('Multiline enabled','wpdirectorykit'); ?></label></th>
41 <td>
42 <input name="is_multiline_enabled" value="1" type="checkbox" id="is_multiline_enabled" class="regular-text" <?php echo !empty(wmvc_show_data('is_multiline_enabled', $db_data, ''))?'checked':''; ?>>
43 <p class="wdk-hint">
44 <?php echo esc_html__('Enable multilines on features part','wpdirectorykit'); ?>
45 </p>
46 </td>
47 </tr>
48 <tr>
49 <th scope="row"><label for="is_label_disable"><?php echo __('Show only icons','wpdirectorykit'); ?></label></th>
50 <td>
51 <input name="is_label_disable" value="1" type="checkbox" id="is_label_disable" class="regular-text" <?php echo !empty(wmvc_show_data('is_label_disable', $db_data, ''))?'checked':''; ?>>
52 <p class="wdk-hint">
53 <?php echo esc_html__('Show only icons instead of field label when available','wpdirectorykit'); ?>
54 </p>
55 </td>
56 </tr>
57 <tr class="hidden">
58 <th scope="row"><label for="resultitem_json"><?php echo __('Result Card Json/Structure','wpdirectorykit'); ?></label></th>
59 <td>
60 <textarea name="resultitem_json" type="text" id="resultitem_json" class="regular-text"><?php echo esc_textarea(wmvc_show_data('resultitem_json', $db_data, '')); ?></textarea>
61 </td>
62 </tr>
63 </tbody>
64 </table>
65 </div>
66 </div>
67
68 <?php
69 /* Post title */
70 $main_fields = array();
71 $predefined_fields_array = array(
72 array(
73 'idfield'=> 'post_id',
74 'field_type'=> 'WP',
75 'field_label'=> 'ID',
76 ),
77 array(
78 'idfield'=> 'date',
79 'field_type'=> 'WP',
80 'field_label'=> 'Date',
81 ),
82 array(
83 'idfield'=> 'date_modified',
84 'field_type'=> 'WP',
85 'field_label'=> 'Date Modified',
86 ),
87 array(
88 'idfield'=> 'post_title',
89 'field_type'=> 'WP',
90 'field_label'=> 'Title',
91 ),
92 array(
93 'idfield'=> 'post_content',
94 'field_type'=> 'WP',
95 'field_label'=> 'Content',
96 ),
97 array(
98 'idfield'=> 'address',
99 'field_type'=> 'INPUTBOX',
100 'field_label'=> '',
101 ),
102 array(
103 'idfield'=> 'category_id',
104 'field_type'=> 'CATEGORY',
105 'field_label'=> '',
106 ),
107 array(
108 'idfield'=> 'location_id',
109 'field_type'=> 'LOCATION',
110 'field_label'=> '',
111 ),
112 array(
113 'idfield'=> 'counter_views',
114 'field_type'=> 'Views',
115 'field_label'=> '',
116 ),
117 array(
118 'idfield'=> 'agent_image',
119 'field_type'=> 'IMAGE',
120 'field_label'=> '',
121 ),
122 );
123
124 foreach ($predefined_fields_array as $key => $value) {
125 $predefined_field = new stdClass();
126 $predefined_field->idfield = $value['idfield'];
127 $predefined_field->lang_code = NULL;
128 $predefined_field->field_type = $value['field_type'];
129 $predefined_field->field_label = $value['field_label'];
130
131 $fields [] = $predefined_field;
132 $main_fields [] = $predefined_field;
133 }
134
135 ?>
136
137 <div class="postbox" style="display: block;">
138 <div class="postbox-header"><h3><?php echo __('Drag & Drop Builder','wpdirectorykit'); ?></h3>
139 </div>
140 <div class="inside">
141 <p class="alert alert-info"><?php echo __('Drag fields from left side to right side, right side represents result card','wpdirectorykit'); ?></p>
142 <div class="wdk-builder-container">
143 <div class="wdk-builder-elements-column">
144 <div class="wdk-builder-elements-box">
145 <h3 class="sec-title"><?php echo __('General fields','wpdirectorykit'); ?></h3>
146 <div id="wdk-drag" class="wdk-builder-elements wdk-drop section_fields">
147 <?php foreach($main_fields as $key => $field):
148 if(isset($used_fields[$field->idfield]))continue; // skip if field is used
149 ?>
150 <div id="fid_<?php echo esc_attr($field->idfield); ?>" class="widget ui-draggable" rel="<?php echo esc_attr($field->idfield); ?>">
151 <div class="widget-top">
152 <div class="widget-title-action">
153 <button type="button" class="widget-action hide-if-no-js" aria-expanded="false">
154 <span class="toggle-indicator" aria-hidden="true"></span>
155 </button>
156 </div>
157 <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>
158 </div>
159 <div class="widget-inside">
160 <div class="widget-content">
161 <p>
162 <label for="fid_<?php echo esc_attr($field->idfield); ?>-class"><?php echo __('CSS Class:','wpdirectorykit'); ?></label>
163 <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="">
164 </p>
165 <p>
166 <label for="fid_<?php echo esc_attr($field->idfield); ?>-columns"><?php echo __('Columns/Width:','wpdirectorykit'); ?></label>
167 <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="">
168 </p>
169 </div>
170 </div>
171 </div>
172 <?php endforeach; ?>
173
174 <?php foreach($fields as $key => $field):
175 if(isset($used_fields[$field->idfield]))continue; // skip if field is used
176
177 if(in_array($field->idfield, array('search','loc','cat','address','post_title','more','booking_date','location_id','category_id','agent_image','post_content','date_modified','date','counter_views')) !== FALSE)continue; // skip if field is used
178 ?>
179 <?php if($field->field_type=='SECTION'):?>
180 </div>
181 </div>
182 <div class="wdk-builder-elements-box">
183 <h3 class="sec-title"><?php echo esc_html($field->field_label); ?></h3>
184 <div id="wdk-drag" class="wdk-builder-elements wdk-drop section_fields" data-name="<?php echo esc_html($field->field_label); ?>">
185 <?php continue; endif;?>
186
187 <div id="fid_<?php echo esc_attr($field->idfield); ?>" class="widget ui-draggable" rel="<?php echo esc_attr($field->idfield); ?>">
188 <div class="widget-top">
189 <div class="widget-title-action">
190 <button type="button" class="widget-action hide-if-no-js" aria-expanded="false">
191 <span class="toggle-indicator" aria-hidden="true"></span>
192 </button>
193 </div>
194 <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>
195 </div>
196 <div class="widget-inside">
197 <div class="widget-content">
198 <p>
199 <label for="fid_<?php echo esc_attr($field->idfield); ?>-class"><?php echo __('CSS Class:','wpdirectorykit'); ?></label>
200 <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="">
201 </p>
202 <p>
203 <label for="fid_<?php echo esc_attr($field->idfield); ?>-columns"><?php echo __('Columns/Width:','wpdirectorykit'); ?></label>
204 <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="">
205 </p>
206 </div>
207 </div>
208 </div>
209 <?php endforeach; ?>
210 </div>
211 </div>
212 </div>
213 <div class="drop-container">
214 <?php
215 $titles = array(__('Over Image Top','wpdirectorykit'),
216 __('Over Image Bottom','wpdirectorykit'),
217 __('Title Part','wpdirectorykit'),
218 __('Subtitle part','wpdirectorykit'),
219 __('Features part','wpdirectorykit'),
220 __('Pricing part','wpdirectorykit'),);
221
222 for($i=1;$i<=count($titles);$i++):
223 ?>
224 <h3><?php echo esc_html($titles[$i-1]); ?></h3>
225 <div id="wdk-drop-<?php echo esc_attr($i); ?>" class="wdk-builder-selected wdk-drop">
226 <?php if(isset($used_fields_sub[$i]) && is_array($used_fields_sub[$i]))
227 foreach($fields as $field):
228 if(!isset($used_fields_sub[$i][$field->idfield]))continue; // skip if field is not used
229 ?>
230 <div id="fid_<?php echo esc_attr($field->idfield); ?>" class="widget ui-draggable" rel="<?php echo esc_attr($field->idfield); ?>">
231 <div class="widget-top">
232 <div class="widget-title-action">
233 <button type="button" class="widget-action hide-if-no-js" aria-expanded="false">
234 <span class="toggle-indicator" aria-hidden="true"></span>
235 </button>
236 <button type="button" class="widget-action-remove" title="<?php echo esc_attr__('Remove','wpdirectorykit');?>">
237 <span class="dashicons dashicons-no"></span>
238 </button>
239 </div>
240 <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>
241 </div>
242 <div class="widget-inside">
243 <div class="widget-content">
244 <p>
245 <label for="fid_<?php echo esc_attr($field->idfield); ?>-class"><?php echo __('CSS Class:','wpdirectorykit'); ?></label>
246 <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="<?php echo wmvc_show_data('class', $used_fields[$field->idfield], ''); ?>">
247 </p>
248 <p>
249 <label for="fid_<?php echo esc_attr($field->idfield); ?>-columns"><?php echo __('Columns/Width:','wpdirectorykit'); ?></label>
250 <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="<?php echo wmvc_show_data('columns', $used_fields[$field->idfield], ''); ?>">
251 </p>
252 </div>
253 </div>
254 </div>
255 <?php endforeach; ?>
256 </div>
257 <br style="clear:both;" />
258 <?php endfor; ?>
259 </div>
260 <br style="clear:both;" />
261 </div>
262 <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php echo esc_html__('Save Changes','wpdirectorykit'); ?>">
263 </div>
264 </div>
265 </form>
266 </div>
267 </div>
268
269 <?php
270 wp_enqueue_script( 'jquery-ui-core', false, array('jquery') );
271 wp_enqueue_script( 'jquery-ui-sortable', false, array('jquery') );
272 ?>
273
274 <script>
275 // Generate table
276 jQuery(document).ready(function($) {
277
278 $( "#wdk-drag, #wdk-drop-1, #wdk-drop-2, #wdk-drop-3, #wdk-drop-4, #wdk-drop-5, #wdk-drop-6" ).sortable({
279 connectWith: ".wdk-drop",
280 placeholder: "ui-sortable-placeholder widget-placeholder",
281 update: function(event, ui) {
282 if(!$(ui.item).find('.widget-action-remove').length){
283 $(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>');
284 }
285 save_data();
286 remove();
287 }
288 }).disableSelection();
289
290 $('button.widget-action').on('click', function(){
291 if($(this).attr("aria-expanded") == 'true')
292 {
293 $(this).attr("aria-expanded", 'false');
294 $(this).parent().parent().parent().find('.widget-inside').hide();
295 }
296 else
297 {
298 $(this).attr("aria-expanded", 'true');
299 $(this).parent().parent().parent().find('.widget-inside').show();
300 }
301 });
302
303 $('.wdk-builder-container input').on('input', save_data);
304
305 remove();
306 function remove() {
307 $('.drop-container .wdk-drop .widget.ui-draggable .widget-action-remove').off().on('click', function(e){
308 e.preventDefault();
309 $('#wdk-drag').first().append($(this).closest('.widget.ui-draggable').detach())
310 save_data();
311 })
312 }
313
314 function save_data()
315 {
316 var data_fields_list = [];
317 var data_fields_sublist = [];
318
319 $('.drop-container .wdk-drop').each(function( index ) {
320 data_fields_sublist = [];
321
322 $(this).find('.widget.ui-draggable').each(function( index ) {
323 data_fields_sublist.push({'field_id': $( this ).attr('rel'),
324 'class': $( this ).find('input.class').val(),
325 'columns': $( this ).find('input.columns').val()});
326 })
327
328
329 data_fields_list.push(data_fields_sublist);
330 });
331
332 $('#resultitem_json').val(JSON.stringify(data_fields_list));
333 }
334 });
335 </script>
336
337 <?php $this->view('general/footer', $data); ?>
338