PluginProbe
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar / 2.0.2
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar v2.0.2
2.1.21 2.1.20 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 trunk 1.1 2.0 2.0.1 2.0.10.2 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.18 2.0.2 2.0.20 2.0.21 2.0.22 All 55 releases
booking-manager / core / admin / page-settings-listing.php

page-settings-listing.php in Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar 2.0.2, at core/admin/page-settings-listing.php

555 lines 27.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php /**
2 * @version 1.0
3 * @package Booking Manager
4 * @category Content of item Listing page
5 * @author wpdevelop
6 *
7 * @web-site http://oplugins.com/
8 * @email info@oplugins.com
9 *
10 * @modified 2015-11-13
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
15
16 /** Show Content
17 * Update Content
18 * Define Slug
19 * Define where to show
20 */
21 class WPBM_Page_SettingsListing extends WPBM_Page_Structure {
22
23
24 public function in_page() {
25 return 'oplugins';// 'wpbm-settings';
26 }
27
28
29 public function tabs() {
30
31 $tabs = array();
32 $tabs[ 'wpbm-settings' ] = array(
33 'title' => __( 'Settings', 'booking-manager' ) // Title of TAB
34 , 'page_title' => __( 'Settings', 'booking-manager' ) // Title of Page
35 , 'hint' => __( 'Settings', 'booking-manager' ) // Hint
36 , 'link' => '' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
37 , 'position' => '' // 'left' || 'right' || ''
38 , 'css_classes' => '' // CSS class(es)
39 , 'icon' => '' // Icon - link to the real PNG img
40 , 'font_icon' => 'glyphicon glyphicon-menu-hamburger' // CSS definition of forn Icon
41 , 'default' => false // Is this tab activated by default or not: true || false.
42 , 'disabled' => false // Is this tab disbaled: true || false.
43 , 'hided' => false // Is this tab hided: true || false.
44 , 'subtabs' => array()
45 );
46 // $subtabs = array();
47 // $tabs[ 'items' ][ 'subtabs' ] = $subtabs;
48
49 $subtabs['listing'] = array(
50 'type' => 'subtab' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'
51 , 'title' => __('Listing Template' , 'booking-manager') // Title of TAB
52 , 'page_title' => __('Listing Template', 'booking-manager') // Title of Page
53 , 'hint' => __('Listing Template' , 'booking-manager') // Hint
54 , 'link' => '' // link
55 , 'position' => '' // 'left' || 'right' || ''
56 , 'css_classes' => '' // CSS class(es)
57 //, 'icon' => 'http://.../icon.png' // Icon - link to the real PNG img
58 //, 'font_icon' => 'glyphicon glyphicon-envelope' // CSS definition of Font Icon
59 , 'default' => !true // Is this sub tab activated by default or not: true || false.
60 , 'disabled' => false // Is this sub tab deactivated: true || false.
61 , 'checkbox' => false // or definition array for specific checkbox: array( 'checked' => true, 'name' => 'feature1_active_status' ) //, 'checkbox' => array( 'checked' => $is_checked, 'name' => 'enabled_active_status' )
62 , 'content' => 'content' // Function to load as conten of this TAB
63 );
64
65 $tabs[ 'wpbm-settings' ]['subtabs'] = $subtabs;
66 return $tabs;
67 }
68
69
70 public function content() {
71
72 do_action( 'wpbm_hook_settings_page_header', array( 'page' => $this->in_page() ) ); // Define Notices Section and show some static messages, if needed.
73
74 ////////////////////////////////////////////////////////////////////////
75 // Submit /////////////////////////////////////////////////////////////
76
77 $submit_form_name = 'wpbm_form_listing'; // Define form name
78
79 if ( isset( $_POST['is_form_sbmitted_'. $submit_form_name ] ) ) {
80
81 // Nonce checking {Return false if invalid, 1 if generated between, 0-12 hours ago, 2 if generated between 12-24 hours ago. }
82 $nonce_gen_time = check_admin_referer( 'wpbm_settings_page_' . $submit_form_name ); // Its stop show anything on submiting, if its not refear to the original page
83
84 // Save Changes
85 $this->update();
86 }
87
88 ////////////////////////////////////////////////////////////////////////
89 // Get Data from DB ////////////////////////////////////////////////////
90 $data_list_tmpl = get_wpbm_option( 'wpbm_listing_template' );
91 //$data_list_tmpl = wpbm_nl_after_br( $data_list_tmpl );
92
93
94 ////////////////////////////////////////////////////////////////////////
95 // Toolbar /////////////////////////////////////////////////////////////
96 wpbm_bs_toolbar_sub_html_container_start();
97
98 ?><span class="wpdevelop"><div class="visibility_container clearfix-height" style="display:block;"><?php
99
100 wpbm_js_for_items_page(); // JavaScript functions
101
102 $this->toolbar_reset_to_default(); // Reset to Default Forms
103
104 $save_button = array( 'title' => __('Save Changes', 'booking-manager'), 'form' => $submit_form_name );
105 $this->toolbar_save_button( $save_button ); // Save Button
106
107 ?></div></span><?php
108
109 wpbm_bs_toolbar_sub_html_container_end();
110
111 ?><div class="clear"></div><?php
112
113 if ( 0 ) {
114 // Scroll links ////////////////////////////////////////////////////////
115 ?>
116 <div class="wpdvlp-sub-tabs" style="background:none;border:none;box-shadow: none;padding:0;"><span class="nav-tabs" style="text-align:right;">
117 <a href="javascript:void(0);" onclick="javascript:wpbm_scroll_to('#wpbm_settings_listing_metabox' );" original-title="" class="nav-tab go-to-link"><span><?php echo ucwords( __('Listing', 'booking-manager') ); ?></span></a>
118 </span></div>
119 <?php
120 }
121
122 ////////////////////////////////////////////////////////////////////////
123 // Content ////////////////////////////////////////////////////////////
124 ?>
125 <div class="clear" style="margin-bottom:10px;"></div>
126 <span class="metabox-holder">
127 <form name="<?php echo $submit_form_name; ?>" id="<?php echo $submit_form_name; ?>" action="" method="post">
128 <?php
129 // N o n c e field, and key for checking S u b m i t
130 wp_nonce_field( 'wpbm_settings_page_' . $submit_form_name );
131 ?><input type="hidden" name="is_form_sbmitted_<?php echo $submit_form_name; ?>" id="is_form_sbmitted_<?php echo $submit_form_name; ?>" value="1" /><?php
132
133 ?><input type="hidden" name="reset_to_default_form" id="reset_to_default_form" value="" /><?php
134
135 ?><div class="wpbm_settings_row wpbm_settings_row_left"><?php
136
137 wpbm_open_meta_box_section( 'wpbm_settings_listing', __('Event template - row for event listing', 'booking-manager') );
138
139 $this->show_listing_template( $data_list_tmpl );
140
141 wpbm_close_meta_box_section();
142 ?>
143 </div>
144 <div class="wpbm_settings_row wpbm_settings_row_right"><?php
145
146 wpbm_open_meta_box_section( 'wpbm_settings_listing_help', __('Help', 'booking-manager') );
147
148 $this->show_content_data_form_help();
149
150 wpbm_close_meta_box_section();
151 ?>
152 </div>
153 <div class="clear"></div>
154 <input type="submit" value="<?php _e('Save Changes','booking-manager'); ?>" class="button button-primary wpbm_submit_button" />
155 </form>
156 </span>
157 <?php
158
159 $this->css();
160 $this->js();
161
162 do_action( 'wpbm_hook_settings_page_footer', 'listing_template' );
163
164 }
165
166
167 /** Save Chanages */
168 public function update() {
169
170 // We can not use here such code:
171 // WPBM_Settings_API::validate_textarea_post_static( 'listing_template' );
172 // becuse its will remove also JavaScript, which possible to use for wizard form or in some other cases.
173 $data_list_tmpl = trim( stripslashes( $_POST['listing_template'] ) );
174 update_wpbm_option( 'wpbm_listing_template' , $data_list_tmpl );
175
176 wpbm_show_changes_saved_message();
177 }
178
179
180 // <editor-fold defaultstate="collapsed" desc=" CSS / JS " >
181
182 /** CSS for this page */
183 private function css() {
184 ?>
185 <style type="text/css">
186 .wpbm-help-message {
187 border:none;
188 }
189 /* toolbar fix */
190 .wpdevelop .visibility_container .control-group {
191 margin: 0 8px 5px 0;
192 }
193 /* Selectbox element in toolbar */
194 .visibility_container select optgroup{
195 color:#999;
196 vertical-align: middle;
197 font-style: italic;
198 font-weight: 400;
199 }
200 .visibility_container select option {
201 padding:5px;
202 font-weight: 600;
203 }
204 .visibility_container select optgroup option{
205 padding: 5px 20px;
206 color:#555;
207 font-weight: 600;
208 }
209 @media (max-width: 399px) {
210 #wpbm_create_new_custom_form_name_fields {
211 width: 100%;
212 }
213 }
214 /* iPad mini and all iPhones and other Mobile Devices */
215 @media (max-width: 782px) {
216 .wpbm_page .wpbm_send_button {
217 padding: 2px;
218 margin-top: 1px;
219 }
220 }
221 </style>
222 <?php
223 }
224
225
226 public function js() {
227 ?>
228 <script type="text/javascript">
229
230 /** Reset form to default template
231 *
232 * @param string template_name
233 */
234 function wpbm_reset_from_to_template( template_name ) {
235
236 var editor_textarea_id = 'listing_template';
237
238 var editor_textarea_content = wpbm_get_standard_template( template_name );
239
240 if( typeof tinymce != "undefined" ) {
241 var editor = tinymce.get( editor_textarea_id );
242 if( editor && editor instanceof tinymce.Editor ) {
243 editor.setContent( editor_textarea_content );
244 editor.save( { no_events: true } );
245 } else {
246 jQuery( '#' + editor_textarea_id ).val( editor_textarea_content );
247 }
248 } else {
249 jQuery( '#' + editor_textarea_id ).val( editor_textarea_content );
250 }
251 }
252
253 /** Get Standard Template
254 *
255 * @param string form_type
256 * @returns string
257 */
258 function wpbm_get_standard_template( template_name ) {
259
260 var form_content = '';
261
262 if ( ( 'standard' == template_name ) ){
263 form_content = '';
264 form_content +='<div class="wpbm-event"> \n';
265 form_content +=' <div style="width:35%;float:left;margin-right:5%;">[DATES]</div> \n';
266 form_content +=' <div style="width:60%;float:left;"> \n';
267 form_content +=' <h2>[SUMMARY]</h2> <span style="display:none;">[UID]</span> \n';
268 form_content +=' <p class="desciption">[DESCRIPTION]</p> \n';
269 form_content +=' </div> \n';
270 form_content +=' <div style="clear:both;"></div> \n';
271 form_content +='</div> \n';
272 form_content +='<hr />';
273 }
274 return form_content;
275 }
276
277 /*
278 // Catch data for summary
279 jQuery('#wpbm_textdata').on( "keypress", function( event ) {
280 if( event.which != 13) {
281 // wpbm_generate_send_info();
282 //return false;
283 }
284 });
285 jQuery('#wpbm_textdata').on( 'change', function(){
286 // wpbm_generate_send_info();
287 } );
288 jQuery(document).ready( function(){
289 // wpbm_generate_send_info();
290 });
291 // On click submit form
292 jQuery( '.wpbm_send_button' ).on( 'click', function() {
293 if ( jQuery( '.wpbm_send_button' ).hasClass( 'disabled' ) ) {
294 return false; // Prevent submit form, if button disabled.
295 }
296 jQuery('#wpbm_action').val('go_send');
297 jQuery('#wpbm_send_links_form<?php //echo $submit_form_name; ?>').submit();
298 return false;
299 });
300 //Allow enter key on textareas and submit buttons only
301 jQuery(document).on( "keypress", ":input:not(textarea):not([type=submit])", function( event ) {
302 if( event.which == 13) {
303 if ( jQuery( '.wpbm_send_button' ).hasClass( 'disabled' ) ) {
304 return false; // Prevent submit form, if button disabled.
305 }
306 //alert('You pressed enter!');
307 jQuery('#wpbm_action').val('go_send');
308 jQuery('#wpbm_send_links_form<?php //echo $submit_form_name; ?>').submit();
309 return false;
310 }
311 });
312 */
313 </script>
314 <?php
315 }
316
317
318
319 // </editor-fold>
320
321
322 // <editor-fold defaultstate="collapsed" desc=" Toolbar " >
323
324 /** Show Save button in toolbar for saving form */
325 private function toolbar_save_button( $save_button ) {
326
327 ?>
328 <div class="clear-for-mobile"></div><input
329 type="button"
330 class="button button-primary wpbm_submit_button"
331 value="<?php echo $save_button['title']; ?>"
332 onclick="if (typeof document.forms['<?php echo $save_button['form']; ?>'] !== 'undefined'){
333 document.forms['<?php echo $save_button['form']; ?>'].submit();
334 } else {
335 wpbm_admin_show_message( '<?php echo ' <strong>Error!</strong> Form <strong>' , $save_button['form'] , '</strong> does not exist.'; ?>.', 'error', 10000 ); //FixIn: 7.0.1.56
336 }"
337 />
338 <?php
339 }
340
341
342 /** Selection of default Template and Button for Reseting */
343 private function toolbar_reset_to_default() {
344
345 $templates = array();
346
347 $templates['selector_hint'] = array(
348 'title' => __('Select', 'booking-manager') . ' ' . __('Form Template', 'booking-manager')
349 , 'id' => ''
350 , 'name' => ''
351 , 'style' => 'font-weight: 400;border-bottom:1px dashed #ccc;'
352 , 'class' => ''
353 , 'disabled' => false
354 , 'selected' => false
355 , 'attr' => array()
356 );
357
358 $templates[ 'optgroup_sf_s' ] = array(
359 'optgroup' => true
360 , 'close' => false
361 , 'title' => '&nbsp;' . __('Standard Templates' ,'booking-manager')
362 );
363 $templates[ 'standard' ] = array(
364 'title' => __('Standard', 'booking-manager')
365 , 'id' => ''
366 , 'name' => ''
367 , 'style' => ''
368 , 'class' => ''
369 , 'disabled' => false
370 , 'selected' => false
371 , 'attr' => array()
372 );
373 /*
374 $templates[ '2collumns' ] = array(
375 'title' => '2 ' . __('Columns', 'booking-manager')
376 , 'id' => ''
377 , 'name' => ''
378 , 'style' => ''
379 , 'class' => ''
380 , 'disabled' => false
381 , 'selected' => false
382 , 'attr' => array()
383 );
384 */
385 $templates[ 'optgroup_sf_e' ] = array( 'optgroup' => true, 'close' => true );
386
387 /*
388 $templates[ 'optgroup_af_s' ] = array(
389 'optgroup' => true
390 , 'close' => false
391 , 'title' => '&nbsp;' . __('Advanced Templates' ,'booking-manager')
392 );
393 $templates[ 'wizard' ] = array(
394 'title' => __('Wizard (several steps)', 'booking-manager')
395 , 'id' => ''
396 , 'name' => ''
397 , 'style' => ''
398 , 'class' => ''
399 , 'disabled' => false
400 , 'selected' => false
401 , 'attr' => array()
402 );
403
404
405 $templates[ 'optgroup_af_e' ] = array( 'optgroup' => true, 'close' => true );
406 */
407
408 $params = array(
409 'label_for' => 'select_form_help_shortcode' // "For" parameter of label element
410 , 'label' => '' //__('Add New Field', 'booking-manager') // Label above the input group
411 , 'style' => '' // CSS Style of entire div element
412 , 'items' => array(
413 array(
414 'type' => 'addon'
415 , 'element' => 'text' // text | radio | checkbox
416 , 'text' => __('Reset Form', 'booking-manager') . ':'
417 , 'class' => '' // Any CSS class here
418 , 'style' => 'font-weight:600;' // CSS Style of entire div element
419 )
420 // Warning! Can be text or selectbox, not both OR you need to define width
421 , array(
422 'type' => 'select'
423 , 'id' => 'select_default_form_template'
424 , 'name' => 'select_default_form_template'
425 , 'style' => ''
426 , 'class' => ''
427 , 'multiple' => false
428 , 'disabled' => false
429 , 'disabled_options' => array() // If some options disbaled, then its must list here
430 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
431 , 'options' => $templates // Associated array of titles and values
432 , 'value' => '' // Some Value from optins array that selected by default
433 , 'onfocus' => ''
434 //, 'onchange' => "wpbm_show_fields_generator( this.options[this.selectedIndex].value );"
435 )
436 )
437 );
438
439
440
441
442 ?><div class="control-group wpbm-no-padding"><?php
443 wpbm_bs_input_group( $params );
444 ?></div><?php
445
446
447 $params = array(
448 'label_for' => 'min_cost' // "For" parameter of label element
449 , 'label' => '' //__('Add New Field', 'booking-manager') // Label above the input group
450 , 'style' => '' // CSS Style of entire div element
451 , 'items' => array(
452 array(
453 'type' => 'button'
454 , 'title' => __('Reset', 'booking-manager') // __('Reset', 'booking-manager')
455 , 'hint' => array( 'title' => __('Reset Form' ,'booking-manager') , 'position' => 'top' )
456 , 'class' => 'button tooltip_top'
457 , 'font_icon' => 'glyphicon glyphicon-repeat'
458 , 'icon_position' => 'right'
459 , 'action' => " var sel_res_val = document.getElementById('select_default_form_template').options[ document.getElementById('select_default_form_template').selectedIndex ].value;"
460 . " if ( sel_res_val == 'selector_hint') { "
461 . " wpbm_field_highlight( '#select_default_form_template' ); return;" //. " jQuery('#wpbm_form_field').submit();"
462 . " }"
463 //. " if ( wpbm_are_you_sure('" . esc_js(__('Do you really want to do this ?' ,'booking-manager')) . "') ) {"
464 . " wpbm_reset_from_to_template( sel_res_val ); " //. " jQuery('#wpbm_form_field').submit();"
465 //. " }"
466 )
467 )
468 );
469
470 ?><div class="control-group wpbm-no-padding"><?php
471 wpbm_bs_input_group( $params );
472 ?></div><?php
473
474 }
475
476 // </editor-fold>
477
478
479 // <editor-fold defaultstate="collapsed" desc=" C O N T E N T F o r m s " >
480
481
482 /** Show Booking Form - in Settings page */
483 private function show_listing_template( $data ) {
484
485 wp_editor( $data,
486 'listing_template',
487 array(
488 'wpautop' => false
489 , 'media_buttons' => false
490 , 'textarea_name' => 'listing_template'
491 , 'textarea_rows' => 10
492 , 'tinymce' => !false // Remove Visual Mode from the Editor
493 , 'default_editor' => 'html' // 'tinymce' | 'html' // 'html' is used for the "Text" editor tab.
494 , 'editor_class' => 'wpbm-textarea-tinymce' // Any extra CSS Classes to append to the Editor textarea
495 , 'teeny' => true // Whether to output the minimal editor configuration used in PressThis
496 , 'drag_drop_upload' => false // Enable Drag & Drop Upload Support (since WordPress 3.9)
497 )
498 );
499 //echo '<textarea id="listing_template" name="listing_template" class="darker-border" style="width:100%;" rows="33">' . htmlspecialchars($listing_template, ENT_NOQUOTES ) . '</textarea>';
500 ?><div class="clear"></div><?php
501 }
502
503
504
505 /** Show Help section for Content Fields Data Form - in Settings page */
506 private function show_content_data_form_help() {
507
508 ?>
509 <div class="wpbm-help-message">
510 <span class="description"><strong><?php printf(__('Use these shortcodes for customization: ' ,'booking-manager'));?></strong></span><br/>
511 <?php
512 ?><span class="description"><?php
513 printf( __( '%s - date(s) of event', 'booking-manager' ) , '<code>[DATES]</code>' );
514 ?></span><br/>
515 <span class="description"><?php
516 printf( __( '%s - summary info of event', 'booking-manager' ) , '<code>[SUMMARY]</code>' );
517 ?></span><br/>
518 <span class="description"><?php
519 printf( __( '%s - ID of event', 'booking-manager' ) , '<code>[UID]</code>' );
520 ?></span><br/>
521 <span class="description"><?php
522 printf( __( '%s - description of event', 'booking-manager' ) , '<code>[DESCRIPTION]</code>' );
523 ?></span><br/>
524 <span class="description"><?php
525 printf( __( '%s - date of event editing, creation', 'booking-manager' ), '<code>[MODIFIED]</code>' );
526 ?></span><br/>
527 <span class="description"><?php
528 printf( __( '%s - location of event', 'booking-manager' ) , '<code>[LOCATION]</code>' );
529 ?></span><br/>
530
531 <hr/>
532 <span class="description"><?php printf(__('%s - inserting new line' ,'booking-manager'),'<code>&lt;br/&gt;</code>');?></span><br/>
533 <span class="description">
534 <?php
535 echo '<strong>' . __('HTML' ,'booking-manager') . '.</strong> '
536 . sprintf(__('You can use any %sHTML tags%s in the booking form. Please use the HTML tags carefully. Be sure, that all "open" tags (like %s) are closed (like this %s).' ,'booking-manager')
537 ,'<strong>','</strong>'
538 ,'<code>&lt;div&gt;</code>'
539 ,'<code>&lt;/div&gt;</code>'
540 );
541 ?>
542 </span>
543 </div>
544 <?php
545 //echo '<hr />';
546
547 }
548
549 // </editor-fold>
550
551
552 }
553 add_action('wpbm_menu_created', array( new WPBM_Page_SettingsListing() , '__construct') ); // Executed after creation of Menu
554
555