| 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 wmvc_current_edit_url(); ?>" novalidate="novalidate"> |
| 22 |
|
| 23 |
<?php wp_nonce_field( 'wdk-resultitem-edit_'.wmvc_show_data('idresultitem', $db_data, 0), '_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 |
$predefined_fields_array = array( |
| 71 |
array( |
| 72 |
'idfield'=> 'post_title', |
| 73 |
'field_type'=> 'WP', |
| 74 |
'field_label'=> 'Title', |
| 75 |
), |
| 76 |
array( |
| 77 |
'idfield'=> 'post_content', |
| 78 |
'field_type'=> 'WP', |
| 79 |
'field_label'=> 'Content', |
| 80 |
), |
| 81 |
array( |
| 82 |
'idfield'=> 'address', |
| 83 |
'field_type'=> 'INPUTBOX', |
| 84 |
'field_label'=> '', |
| 85 |
), |
| 86 |
array( |
| 87 |
'idfield'=> 'category_id', |
| 88 |
'field_type'=> 'CATEGORY', |
| 89 |
'field_label'=> '', |
| 90 |
), |
| 91 |
array( |
| 92 |
'idfield'=> 'location_id', |
| 93 |
'field_type'=> 'LOCATION', |
| 94 |
'field_label'=> '', |
| 95 |
), |
| 96 |
array( |
| 97 |
'idfield'=> 'agent_image', |
| 98 |
'field_type'=> 'IMAGE', |
| 99 |
'field_label'=> '', |
| 100 |
), |
| 101 |
); |
| 102 |
|
| 103 |
foreach ($predefined_fields_array as $key => $value) { |
| 104 |
$predefined_field = new stdClass(); |
| 105 |
$predefined_field->idfield = $value['idfield']; |
| 106 |
$predefined_field->lang_code = NULL; |
| 107 |
$predefined_field->field_type = $value['field_type']; |
| 108 |
$predefined_field->field_label = $value['field_label']; |
| 109 |
|
| 110 |
$fields [] = $predefined_field ; |
| 111 |
} |
| 112 |
|
| 113 |
?> |
| 114 |
|
| 115 |
<div class="postbox" style="display: block;"> |
| 116 |
<div class="postbox-header"><h3><?php echo __('Drag & Drop Builder','wpdirectorykit'); ?></h3> |
| 117 |
</div> |
| 118 |
<div class="inside"> |
| 119 |
<p class="alert alert-info"><?php echo __('Drag fields from left side to right side, right side represents result card','wpdirectorykit'); ?></p> |
| 120 |
<div class="wdk-builder-container"> |
| 121 |
<div class="wdk-builder-elements-column"> |
| 122 |
<?php foreach($fields as $key => $field): |
| 123 |
if(isset($used_fields[$field->idfield]))continue; // skip if field is used |
| 124 |
?> |
| 125 |
<?php if($field->field_type=='SECTION'):?> |
| 126 |
<?php if( $key != 0):?> |
| 127 |
</div> |
| 128 |
</div> |
| 129 |
<?php endif;?> |
| 130 |
<div class="wdk-builder-elements-box"> |
| 131 |
<h3 class="sec-title"><?php echo esc_html($field->field_label); ?></h3> |
| 132 |
<div id="wdk-drag" class="wdk-builder-elements wdk-drop section_fields" data-name="<?php echo esc_html($field->field_label); ?>"> |
| 133 |
<?php continue; endif;?> |
| 134 |
|
| 135 |
<?php if( $key == 0):?> |
| 136 |
<div class="wdk-builder-elements-box"> |
| 137 |
<div id="wdk-drag" class="wdk-builder-elements wdk-drop"> |
| 138 |
<?php endif;?> |
| 139 |
|
| 140 |
<div id="fid_<?php echo esc_attr($field->idfield); ?>" class="widget ui-draggable" rel="<?php echo esc_attr($field->idfield); ?>"> |
| 141 |
<div class="widget-top"> |
| 142 |
<div class="widget-title-action"> |
| 143 |
<button type="button" class="widget-action hide-if-no-js" aria-expanded="false"> |
| 144 |
<span class="toggle-indicator" aria-hidden="true"></span> |
| 145 |
</button> |
| 146 |
</div> |
| 147 |
<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> |
| 148 |
</div> |
| 149 |
<div class="widget-inside"> |
| 150 |
<div class="widget-content"> |
| 151 |
<p> |
| 152 |
<label for="fid_<?php echo esc_attr($field->idfield); ?>-class"><?php echo __('CSS Class:','wpdirectorykit'); ?></label> |
| 153 |
<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=""> |
| 154 |
</p> |
| 155 |
<p> |
| 156 |
<label for="fid_<?php echo esc_attr($field->idfield); ?>-columns"><?php echo __('Columns/Width:','wpdirectorykit'); ?></label> |
| 157 |
<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=""> |
| 158 |
</p> |
| 159 |
</div> |
| 160 |
</div> |
| 161 |
</div> |
| 162 |
<?php endforeach; ?> |
| 163 |
</div> |
| 164 |
</div> |
| 165 |
</div> |
| 166 |
<div class="drop-container"> |
| 167 |
<?php |
| 168 |
$titles = array(__('Over Image Top','wpdirectorykit'), |
| 169 |
__('Over Image Bottom','wpdirectorykit'), |
| 170 |
__('Title Part','wpdirectorykit'), |
| 171 |
__('Subtitle part','wpdirectorykit'), |
| 172 |
__('Features part','wpdirectorykit'), |
| 173 |
__('Pricing part','wpdirectorykit'),); |
| 174 |
|
| 175 |
for($i=1;$i<=count($titles);$i++): |
| 176 |
?> |
| 177 |
<h3><?php echo esc_html($titles[$i-1]); ?></h3> |
| 178 |
<div id="wdk-drop-<?php echo esc_attr($i); ?>" class="wdk-builder-selected wdk-drop"> |
| 179 |
<?php if(isset($used_fields_sub[$i]) && is_array($used_fields_sub[$i])) |
| 180 |
foreach($fields as $field): |
| 181 |
if(!isset($used_fields_sub[$i][$field->idfield]))continue; // skip if field is not used |
| 182 |
?> |
| 183 |
<div id="fid_<?php echo esc_attr($field->idfield); ?>" class="widget ui-draggable" rel="<?php echo esc_attr($field->idfield); ?>"> |
| 184 |
<div class="widget-top"> |
| 185 |
<div class="widget-title-action"> |
| 186 |
<button type="button" class="widget-action hide-if-no-js" aria-expanded="false"> |
| 187 |
<span class="toggle-indicator" aria-hidden="true"></span> |
| 188 |
</button> |
| 189 |
</div> |
| 190 |
<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> |
| 191 |
</div> |
| 192 |
<div class="widget-inside"> |
| 193 |
<div class="widget-content"> |
| 194 |
<p> |
| 195 |
<label for="fid_<?php echo esc_attr($field->idfield); ?>-class"><?php echo __('CSS Class:','wpdirectorykit'); ?></label> |
| 196 |
<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], ''); ?>"> |
| 197 |
</p> |
| 198 |
<p> |
| 199 |
<label for="fid_<?php echo esc_attr($field->idfield); ?>-columns"><?php echo __('Columns/Width:','wpdirectorykit'); ?></label> |
| 200 |
<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], ''); ?>"> |
| 201 |
</p> |
| 202 |
</div> |
| 203 |
</div> |
| 204 |
</div> |
| 205 |
<?php endforeach; ?> |
| 206 |
</div> |
| 207 |
<br style="clear:both;" /> |
| 208 |
<?php endfor; ?> |
| 209 |
</div> |
| 210 |
<br style="clear:both;" /> |
| 211 |
</div> |
| 212 |
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php echo esc_html__('Save Changes','wpdirectorykit'); ?>"> |
| 213 |
</div> |
| 214 |
</div> |
| 215 |
</form> |
| 216 |
</div> |
| 217 |
</div> |
| 218 |
|
| 219 |
<?php |
| 220 |
wp_enqueue_script( 'jquery-ui-core', false, array('jquery') ); |
| 221 |
wp_enqueue_script( 'jquery-ui-sortable', false, array('jquery') ); |
| 222 |
?> |
| 223 |
|
| 224 |
<script> |
| 225 |
// Generate table |
| 226 |
jQuery(document).ready(function($) { |
| 227 |
|
| 228 |
$( "#wdk-drag, #wdk-drop-1, #wdk-drop-2, #wdk-drop-3, #wdk-drop-4, #wdk-drop-5, #wdk-drop-6" ).sortable({ |
| 229 |
connectWith: ".wdk-drop", |
| 230 |
placeholder: "ui-sortable-placeholder widget-placeholder", |
| 231 |
update: function(event, ui) { |
| 232 |
save_data(); |
| 233 |
} |
| 234 |
}).disableSelection(); |
| 235 |
|
| 236 |
$('button.widget-action').on('click', function(){ |
| 237 |
if($(this).attr("aria-expanded") == 'true') |
| 238 |
{ |
| 239 |
$(this).attr("aria-expanded", 'false'); |
| 240 |
$(this).parent().parent().parent().find('.widget-inside').hide(); |
| 241 |
} |
| 242 |
else |
| 243 |
{ |
| 244 |
$(this).attr("aria-expanded", 'true'); |
| 245 |
$(this).parent().parent().parent().find('.widget-inside').show(); |
| 246 |
} |
| 247 |
}); |
| 248 |
|
| 249 |
$('.wdk-builder-container input').on('input', save_data); |
| 250 |
|
| 251 |
function save_data() |
| 252 |
{ |
| 253 |
var data_fields_list = []; |
| 254 |
var data_fields_sublist = []; |
| 255 |
|
| 256 |
$('.drop-container .wdk-drop').each(function( index ) { |
| 257 |
data_fields_sublist = []; |
| 258 |
|
| 259 |
$(this).find('.widget.ui-draggable').each(function( index ) { |
| 260 |
data_fields_sublist.push({'field_id': $( this ).attr('rel'), |
| 261 |
'class': $( this ).find('input.class').val(), |
| 262 |
'columns': $( this ).find('input.columns').val()}); |
| 263 |
}) |
| 264 |
|
| 265 |
|
| 266 |
data_fields_list.push(data_fields_sublist); |
| 267 |
}); |
| 268 |
|
| 269 |
$('#resultitem_json').val(JSON.stringify(data_fields_list)); |
| 270 |
} |
| 271 |
}); |
| 272 |
</script> |
| 273 |
|
| 274 |
<?php $this->view('general/footer', $data); ?> |
| 275 |
|