| 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 esc_html__('Result Card Designer','wpdirectorykit'); ?></h1> |
| 18 |
<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 esc_html__('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 esc_html__('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 esc_html__('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 esc_html__('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> |
| 58 |
<th scope="row"><label for="is_show_agent_details"><?php echo esc_html__('Show agent details','wpdirectorykit'); ?></label></th> |
| 59 |
<td> |
| 60 |
<input name="is_show_agent_details" value="1" type="checkbox" id="is_show_agent_details" class="regular-text" <?php echo !empty(wmvc_show_data('is_show_agent_details', $db_data, ''))?'checked':''; ?>> |
| 61 |
<p class="wdk-hint"> |
| 62 |
<?php echo esc_html__('Show basic agent details on result item card.','wpdirectorykit'); ?> |
| 63 |
</p> |
| 64 |
</td> |
| 65 |
</tr> |
| 66 |
<tr class="hidden"> |
| 67 |
<th scope="row"><label for="resultitem_json"><?php echo esc_html__('Result Card Json/Structure','wpdirectorykit'); ?></label></th> |
| 68 |
<td> |
| 69 |
<textarea name="resultitem_json" type="text" id="resultitem_json" class="regular-text"><?php echo esc_textarea(wmvc_show_data('resultitem_json', $db_data, '')); ?></textarea> |
| 70 |
</td> |
| 71 |
</tr> |
| 72 |
</tbody> |
| 73 |
</table> |
| 74 |
</div> |
| 75 |
</div> |
| 76 |
|
| 77 |
<?php |
| 78 |
/* Post title */ |
| 79 |
$main_fields = array(); |
| 80 |
$predefined_fields_array = array( |
| 81 |
array( |
| 82 |
'idfield'=> 'post_id', |
| 83 |
'field_type'=> 'WP', |
| 84 |
'field_label'=> 'ID', |
| 85 |
), |
| 86 |
array( |
| 87 |
'idfield'=> 'date', |
| 88 |
'field_type'=> 'WP', |
| 89 |
'field_label'=> 'Date', |
| 90 |
), |
| 91 |
array( |
| 92 |
'idfield'=> 'date_modified', |
| 93 |
'field_type'=> 'WP', |
| 94 |
'field_label'=> 'Date Modified', |
| 95 |
), |
| 96 |
array( |
| 97 |
'idfield'=> 'post_title', |
| 98 |
'field_type'=> 'WP', |
| 99 |
'field_label'=> 'Title', |
| 100 |
), |
| 101 |
array( |
| 102 |
'idfield'=> 'post_content', |
| 103 |
'field_type'=> 'WP', |
| 104 |
'field_label'=> 'Content', |
| 105 |
), |
| 106 |
array( |
| 107 |
'idfield'=> 'address', |
| 108 |
'field_type'=> 'INPUTBOX', |
| 109 |
'field_label'=> '', |
| 110 |
), |
| 111 |
array( |
| 112 |
'idfield'=> 'category_id', |
| 113 |
'field_type'=> 'CATEGORY', |
| 114 |
'field_label'=> '', |
| 115 |
), |
| 116 |
array( |
| 117 |
'idfield'=> 'location_id', |
| 118 |
'field_type'=> 'LOCATION', |
| 119 |
'field_label'=> '', |
| 120 |
), |
| 121 |
array( |
| 122 |
'idfield'=> 'counter_views', |
| 123 |
'field_type'=> 'Views', |
| 124 |
'field_label'=> '', |
| 125 |
), |
| 126 |
array( |
| 127 |
'idfield'=> 'agent_image', |
| 128 |
'field_type'=> 'IMAGE', |
| 129 |
'field_label'=> '', |
| 130 |
), |
| 131 |
array( |
| 132 |
'idfield'=> 'agent_name', |
| 133 |
'field_type'=> 'TEXT', |
| 134 |
'field_label'=> '', |
| 135 |
), |
| 136 |
array( |
| 137 |
'idfield'=> 'agent_email', |
| 138 |
'field_type'=> 'TEXT', |
| 139 |
'field_label'=> '', |
| 140 |
), |
| 141 |
); |
| 142 |
|
| 143 |
foreach ($predefined_fields_array as $key => $value) { |
| 144 |
$predefined_field = new stdClass(); |
| 145 |
$predefined_field->idfield = $value['idfield']; |
| 146 |
$predefined_field->lang_code = NULL; |
| 147 |
$predefined_field->field_type = $value['field_type']; |
| 148 |
$predefined_field->field_label = $value['field_label']; |
| 149 |
|
| 150 |
$fields [] = $predefined_field; |
| 151 |
$main_fields [] = $predefined_field; |
| 152 |
} |
| 153 |
|
| 154 |
$fields_assoc = array(); |
| 155 |
foreach($fields as $f){ |
| 156 |
$fields_assoc[$f->idfield] = $f; |
| 157 |
} |
| 158 |
?> |
| 159 |
|
| 160 |
<div class="postbox" style="display: block;"> |
| 161 |
<div class="postbox-header"><h3><?php echo esc_html__('Drag & Drop Builder','wpdirectorykit'); ?></h3> |
| 162 |
</div> |
| 163 |
<div class="inside"> |
| 164 |
<p class="alert alert-info"><?php echo esc_html__('Drag fields from left side to right side, right side represents result card','wpdirectorykit'); ?></p> |
| 165 |
<div class="wdk-builder-container"> |
| 166 |
<div class="wdk-builder-elements-column"> |
| 167 |
<div class="wdk-builder-elements-box"> |
| 168 |
<h3 class="sec-title"><?php echo esc_html__('General fields','wpdirectorykit'); ?></h3> |
| 169 |
<div id="wdk-drag" class="wdk-builder-elements wdk-drop section_fields"> |
| 170 |
<?php foreach($main_fields as $key => $field): |
| 171 |
if(isset($used_fields[$field->idfield]))continue; // skip if field is used |
| 172 |
?> |
| 173 |
<div id="fid_<?php echo esc_attr($field->idfield); ?>" class="widget ui-draggable" rel="<?php echo esc_attr($field->idfield); ?>"> |
| 174 |
<div class="widget-top"> |
| 175 |
<div class="widget-title-action"> |
| 176 |
<button type="button" class="widget-action hide-if-no-js" aria-expanded="false"> |
| 177 |
<span class="toggle-indicator" aria-hidden="true"></span> |
| 178 |
</button> |
| 179 |
</div> |
| 180 |
<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> |
| 181 |
</div> |
| 182 |
<div class="widget-inside"> |
| 183 |
<div class="widget-content"> |
| 184 |
<p> |
| 185 |
<label for="fid_<?php echo esc_attr($field->idfield); ?>-class"><?php echo esc_html__('CSS Class:','wpdirectorykit'); ?></label> |
| 186 |
<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=""> |
| 187 |
</p> |
| 188 |
<p> |
| 189 |
<label for="fid_<?php echo esc_attr($field->idfield); ?>-columns"><?php echo esc_html__('Columns/Width:','wpdirectorykit'); ?></label> |
| 190 |
<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=""> |
| 191 |
</p> |
| 192 |
<?php if(in_array($field->idfield, array('agent_image','agent_name','agent_email'))):?> |
| 193 |
<p> |
| 194 |
<label for="fid_<?php echo esc_attr($field->idfield); ?>-add_profile_link"> |
| 195 |
<input class="widefat add_profile_link" id="fid_<?php echo esc_attr($field->idfield); ?>-add_profile_link" name="fid_<?php echo esc_attr($field->idfield); ?>-add_profile_link" type="checkbox" value="1"> |
| 196 |
<?php echo esc_html__('Add profile link','wpdirectorykit'); ?> |
| 197 |
</label> |
| 198 |
</p> |
| 199 |
<?php endif;?> |
| 200 |
</div> |
| 201 |
</div> |
| 202 |
</div> |
| 203 |
<?php endforeach; ?> |
| 204 |
|
| 205 |
<?php foreach($fields as $key => $field): |
| 206 |
if(isset($used_fields[$field->idfield]))continue; // skip if field is used |
| 207 |
|
| 208 |
if(in_array($field->idfield, array('search','loc','cat','address','post_title','more','booking_date','location_id','category_id','agent_image','agent_name','agent_email','post_content','date_modified','date','counter_views')) !== FALSE)continue; // skip if field is used |
| 209 |
?> |
| 210 |
<?php if($field->field_type=='SECTION'):?> |
| 211 |
</div> |
| 212 |
</div> |
| 213 |
<div class="wdk-builder-elements-box"> |
| 214 |
<h3 class="sec-title"><?php echo esc_html($field->field_label); ?></h3> |
| 215 |
<div id="wdk-drag" class="wdk-builder-elements wdk-drop section_fields" data-name="<?php echo esc_attr($field->field_label); ?>"> |
| 216 |
<?php continue; endif;?> |
| 217 |
|
| 218 |
<div id="fid_<?php echo esc_attr($field->idfield); ?>" class="widget ui-draggable" rel="<?php echo esc_attr($field->idfield); ?>"> |
| 219 |
<div class="widget-top"> |
| 220 |
<div class="widget-title-action"> |
| 221 |
<button type="button" class="widget-action hide-if-no-js" aria-expanded="false"> |
| 222 |
<span class="toggle-indicator" aria-hidden="true"></span> |
| 223 |
</button> |
| 224 |
</div> |
| 225 |
<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> |
| 226 |
</div> |
| 227 |
<div class="widget-inside"> |
| 228 |
<div class="widget-content"> |
| 229 |
<p> |
| 230 |
<label for="fid_<?php echo esc_attr($field->idfield); ?>-class"><?php echo esc_html__('CSS Class:','wpdirectorykit'); ?></label> |
| 231 |
<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=""> |
| 232 |
</p> |
| 233 |
<p> |
| 234 |
<label for="fid_<?php echo esc_attr($field->idfield); ?>-columns"><?php echo esc_html__('Columns/Width:','wpdirectorykit'); ?></label> |
| 235 |
<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=""> |
| 236 |
</p> |
| 237 |
<?php if(in_array($field->idfield, array('agent_image','agent_name','agent_email'))):?> |
| 238 |
<p> |
| 239 |
<label for="fid_<?php echo esc_attr($field->idfield); ?>-add_profile_link"> |
| 240 |
<input class="widefat add_profile_link" id="fid_<?php echo esc_attr($field->idfield); ?>-add_profile_link" name="fid_<?php echo esc_attr($field->idfield); ?>-add_profile_link" type="checkbox" value="1"> |
| 241 |
<?php echo esc_html__('Add profile link','wpdirectorykit'); ?> |
| 242 |
</label> |
| 243 |
</p> |
| 244 |
<?php endif;?> |
| 245 |
</div> |
| 246 |
</div> |
| 247 |
</div> |
| 248 |
<?php endforeach; ?> |
| 249 |
</div> |
| 250 |
</div> |
| 251 |
</div> |
| 252 |
<div class="drop-container"> |
| 253 |
<?php |
| 254 |
$titles = array(__('Over Image Top','wpdirectorykit'), |
| 255 |
__('Over Image Bottom','wpdirectorykit'), |
| 256 |
__('Title Part','wpdirectorykit'), |
| 257 |
__('Subtitle part','wpdirectorykit'), |
| 258 |
__('Features part','wpdirectorykit'), |
| 259 |
__('Pricing part','wpdirectorykit'),); |
| 260 |
|
| 261 |
for($i=1;$i<=count($titles);$i++): |
| 262 |
?> |
| 263 |
<h3><?php echo esc_html($titles[$i-1]); ?></h3> |
| 264 |
<div id="wdk-drop-<?php echo esc_attr($i); ?>" class="wdk-builder-selected wdk-drop"> |
| 265 |
<?php |
| 266 |
if(isset($used_fields_sub[$i]) && is_array($used_fields_sub[$i])) { |
| 267 |
foreach($used_fields_sub[$i] as $fid => $cfg){ |
| 268 |
if(!isset($fields_assoc[$fid])) continue; // skip if field object not found |
| 269 |
$field = $fields_assoc[$fid]; |
| 270 |
?> |
| 271 |
<div id="fid_<?php echo esc_attr($field->idfield); ?>" class="widget ui-draggable" rel="<?php echo esc_attr($field->idfield); ?>"> |
| 272 |
<div class="widget-top"> |
| 273 |
<div class="widget-title-action"> |
| 274 |
<button type="button" class="widget-action hide-if-no-js" aria-expanded="false"> |
| 275 |
<span class="toggle-indicator" aria-hidden="true"></span> |
| 276 |
</button> |
| 277 |
<button type="button" class="widget-action-remove" title="<?php echo esc_attr__('Remove','wpdirectorykit');?>"> |
| 278 |
<span class="dashicons dashicons-no"></span> |
| 279 |
</button> |
| 280 |
</div> |
| 281 |
<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> |
| 282 |
</div> |
| 283 |
<div class="widget-inside"> |
| 284 |
<div class="widget-content"> |
| 285 |
<p> |
| 286 |
<label for="fid_<?php echo esc_attr($field->idfield); ?>-class"><?php echo esc_html__('CSS Class:','wpdirectorykit'); ?></label> |
| 287 |
<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 esc_attr(wmvc_show_data('class', $used_fields[$field->idfield], '')); ?>"> |
| 288 |
</p> |
| 289 |
<p> |
| 290 |
<label for="fid_<?php echo esc_attr($field->idfield); ?>-columns"><?php echo esc_html__('Columns/Width:','wpdirectorykit'); ?></label> |
| 291 |
<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 esc_attr(wmvc_show_data('columns', $used_fields[$field->idfield], '')); ?>"> |
| 292 |
</p> |
| 293 |
<?php if(in_array($field->idfield, array('agent_image','agent_name','agent_email'))):?> |
| 294 |
<p> |
| 295 |
<label for="fid_<?php echo esc_attr($field->idfield); ?>-add_profile_link"> |
| 296 |
<input class="widefat add_profile_link" id="fid_<?php echo esc_attr($field->idfield); ?>-add_profile_link" name="fid_<?php echo esc_attr($field->idfield); ?>-add_profile_link" type="checkbox" value="1"> |
| 297 |
<?php echo esc_html__('Add profile link','wpdirectorykit'); ?> |
| 298 |
</label> |
| 299 |
</p> |
| 300 |
<?php endif;?> |
| 301 |
</div> |
| 302 |
</div> |
| 303 |
</div> |
| 304 |
<?php |
| 305 |
} // end foreach ordered by used_fields_sub |
| 306 |
} |
| 307 |
?> |
| 308 |
</div> |
| 309 |
<br style="clear:both;" /> |
| 310 |
<?php endfor; ?> |
| 311 |
</div> |
| 312 |
<br style="clear:both;" /> |
| 313 |
</div> |
| 314 |
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php echo esc_attr__('Save Changes','wpdirectorykit'); ?>"> |
| 315 |
</div> |
| 316 |
</div> |
| 317 |
</form> |
| 318 |
</div> |
| 319 |
</div> |
| 320 |
|
| 321 |
<?php |
| 322 |
wp_enqueue_script( 'jquery-ui-core', false, array('jquery') ); |
| 323 |
wp_enqueue_script( 'jquery-ui-sortable', false, array('jquery') ); |
| 324 |
?> |
| 325 |
|
| 326 |
<script> |
| 327 |
// Generate table |
| 328 |
jQuery(document).ready(function($) { |
| 329 |
|
| 330 |
$( "#wdk-drag, #wdk-drop-1, #wdk-drop-2, #wdk-drop-3, #wdk-drop-4, #wdk-drop-5, #wdk-drop-6" ).sortable({ |
| 331 |
connectWith: ".wdk-drop", |
| 332 |
placeholder: "ui-sortable-placeholder widget-placeholder", |
| 333 |
update: function(event, ui) { |
| 334 |
if(!$(ui.item).find('.widget-action-remove').length){ |
| 335 |
$(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>'); |
| 336 |
} |
| 337 |
save_data(); |
| 338 |
remove(); |
| 339 |
} |
| 340 |
}).disableSelection(); |
| 341 |
|
| 342 |
$('button.widget-action').on('click', function(){ |
| 343 |
if($(this).attr("aria-expanded") == 'true') |
| 344 |
{ |
| 345 |
$(this).attr("aria-expanded", 'false'); |
| 346 |
$(this).parent().parent().parent().find('.widget-inside').hide(); |
| 347 |
} |
| 348 |
else |
| 349 |
{ |
| 350 |
$(this).attr("aria-expanded", 'true'); |
| 351 |
$(this).parent().parent().parent().find('.widget-inside').show(); |
| 352 |
} |
| 353 |
}); |
| 354 |
|
| 355 |
$('.wdk-builder-container input').on('input', save_data); |
| 356 |
|
| 357 |
remove(); |
| 358 |
function remove() { |
| 359 |
$('.drop-container .wdk-drop .widget.ui-draggable .widget-action-remove').off().on('click', function(e){ |
| 360 |
e.preventDefault(); |
| 361 |
$('#wdk-drag').first().append($(this).closest('.widget.ui-draggable').detach()) |
| 362 |
save_data(); |
| 363 |
}) |
| 364 |
} |
| 365 |
|
| 366 |
function save_data() |
| 367 |
{ |
| 368 |
var data_fields_list = []; |
| 369 |
var data_fields_sublist = []; |
| 370 |
|
| 371 |
$('.drop-container .wdk-drop').each(function( index ) { |
| 372 |
data_fields_sublist = []; |
| 373 |
|
| 374 |
$(this).find('.widget.ui-draggable').each(function( index ) { |
| 375 |
data_fields_sublist.push({'field_id': $( this ).attr('rel'), |
| 376 |
'class': $( this ).find('input.class').val(), |
| 377 |
'columns': $( this ).find('input.columns').val(), |
| 378 |
'add_profile_link': $( this ).find('input.add_profile_link').is(':checked') |
| 379 |
}); |
| 380 |
}) |
| 381 |
|
| 382 |
|
| 383 |
data_fields_list.push(data_fields_sublist); |
| 384 |
}); |
| 385 |
|
| 386 |
$('#resultitem_json').val(JSON.stringify(data_fields_list)); |
| 387 |
} |
| 388 |
}); |
| 389 |
</script> |
| 390 |
|
| 391 |
<?php $this->view('general/footer', $data); ?> |
| 392 |
|