* @author Mike Howard * @since 1.3 * @content_tag No {client_*} * @content_tag No {event_*} * @content_tags {label}, {label_class}, {field}, {field_class}, {submit_text}, {submit_class}, {please_wait_text}, {please_wait_class} * @shortcodes Not Supported * * Do not change any form field ID's. * * Do not customise this file! * If you wish to make changes, copy this file to your theme directory /theme/mdjm-templates/availabilty/availabilty-horizontal.php */ ?> <?php do_action('mdjm_print_notices'); ?> <div id="mdjm-availability-result"></div> <div id="mdjm-availability-checker"> <p><label for="{field}" class="{label_class}">{label}</label> <input type="text" name="{field}" id="{field}" class="{field_class}" size="20" placeholder="<?php echo mdjm_format_datepicker_date(); ?> " /> <input type="submit" name="mdjm-submit-availability" id="mdjm-submit-availability" class="{submit_class}" value="{submit_text}" /></p> <span id="pleasewait" class="{please_wait_class}">{please_wait_text} <img src="<?php echo MDJM_PLUGIN_URL; ?> /assets/images/loading.gif" alt="{please_wait_text}" /></span> </div>
/** * Datepicker. * * @since 1.3 * @param arr $args Datepicker field serttings. * @return void */ function mdjm_insert_datepicker($args = array()) { $defaults = array('class' => 'mdjm_date', 'altfield' => '_mdjm_event_date', 'altformat' => 'yy-mm-dd', 'firstday' => get_option('start_of_week'), 'changeyear' => 'true', 'changemonth' => 'true'); $args = wp_parse_args($args, $defaults); if (!empty($args['id'])) { $field = '#' . $args['id']; } else { $field = '.' . $args['class']; } ?> <script type="text/javascript"> jQuery(document).ready( function($) { $("<?php echo $field; ?> ").datepicker({ dateFormat : "<?php echo mdjm_format_datepicker_date(); ?> ", altField : "#<?php echo $args['altfield']; ?> ", altFormat : "<?php echo $args['altformat']; ?> ", firstDay : "<?php echo $args['firstday']; ?> ", changeYear : "<?php echo $args['changeyear']; ?> ", changeMonth : "<?php echo $args['changemonth']; ?> ", minDate : "<?php echo isset($args['mindate']) ? $args['mindate'] : ''; ?> ", maxDate : "<?php echo isset($args['maxdate']) ? $args['maxdate'] : ''; ?> " }); }); </script> <?php }
/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param arr $args Widget arguments. * @param arr $instance Saved values from database. */ public function widget($args, $instance) { add_action('wp_head', array(&$this, 'datepicker')); if (!empty($instance['ajax'])) { self::ajax($args, $instance); } echo $args['before_widget']; if (!empty($instance['title'])) { echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title']; } /* Check for form submission & process */ if (isset($_POST['mdjm_widget_avail_submit']) && $_POST['mdjm_widget_avail_submit'] == $instance['submit_text']) { $dj_avail = dj_available('', $_POST['widget_check_date']); if (isset($dj_avail)) { if (!empty($dj_avail['available'])) { if (isset($instance['available_action']) && $instance['available_action'] != 'text') { ?> <script type="text/javascript"> window.location = '<?php echo mdjm_get_formatted_url($instance['available_action']) . 'mdjm_avail=1&mdjm_avail_date=' . $_POST['widget_check_date']; ?> '; </script> <?php } } else { if (isset($instance['unavailable_action']) && $instance['unavailable_action'] != 'text') { ?> <script type="text/javascript"> window.location = '<?php echo mdjm_get_formatted_url($instance['unavailable_action']); ?> '; </script> <?php } } } // if( isset( $dj_avail ) ) } // if( isset( $_POST['mdjm_avail_submit'] ) ... /* We need the jQuery Calendar */ wp_enqueue_script('jquery-ui-datepicker'); wp_enqueue_style('jquery-ui-css', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css'); mdjm_insert_datepicker(array('class' => 'mdjm_widget_date', 'altfield' => 'widget_check_date', 'mindate' => '1')); if (isset($instance['intro']) && !empty($instance['intro'])) { if (isset($_POST['mdjm_widget_avail_submit']) && $_POST['mdjm_widget_avail_submit'] == $instance['submit_text']) { $search = array('{EVENT_DATE}', '{EVENT_DATE_SHORT}'); $replace = array(date('l, jS F Y', strtotime($_POST['widget_check_date'])), mdjm_format_short_date($_POST['widget_check_date'])); } if (!isset($_POST['mdjm_widget_avail_submit']) || $_POST['mdjm_widget_avail_submit'] != $instance['submit_text']) { echo '<div id="widget_avail_intro">' . $instance['intro'] . '</div>'; } else { if (!empty($instance['ajax'])) { ?> <div id="widget_availability_result"></div> <?php } else { if (!empty($dj_avail['available']) && $instance['available_action'] == 'text' && !empty($instance['available_text'])) { echo str_replace($search, $replace, $instance['available_text']); } else { echo str_replace($search, $replace, $instance['unavailable_text']); } } } } ?> <form name="mdjm-widget-availability-check" id="mdjm-widget-availability-check" method="post"> <label for="widget_avail_date"><?php echo $instance['label']; ?> </label> <input type="text" name="widget_avail_date" id="widget_avail_date" class="mdjm_widget_date" style="z-index:99;" placeholder="<?php echo mdjm_format_datepicker_date(); ?> " /> <input type="hidden" name="widget_check_date" id="widget_check_date" value="" /> <p<?php echo isset($instance['submit_centre']) && $instance['submit_centre'] == 'Y' ? ' style="text-align:center"' : ''; ?> > <input type="submit" name="mdjm_widget_avail_submit" id="mdjm_widget_avail_submit" value="<?php echo $instance['submit_text']; ?> " /> <div id="widget_pleasewait" class="page-content" style="display: none;"><?php _e('Please wait...', 'mobile-dj-manager'); ?> <img src="<?php echo MDJM_PLUGIN_URL; ?> /assets/images/loading.gif" alt="<?php _e('Please wait...', 'mobile-dj-manager'); ?> " /></div> </form> <script type="text/javascript"> jQuery(document).ready(function($){ // Configure the field validator $('#mdjm-widget-availability-check').validate({ rules: { widget_avail_date: { required: true, }, }, messages: { widget_avail_date: { required: "<?php _e('Please enter a date', 'mobile-dj-manager'); ?> ", }, }, errorClass: "mdjm-form-error", validClass: "mdjm-form-valid", } ); }); </script> <?php echo $args['after_widget']; }
/** * Format the date for the datepicker script * * * @since 1.3 * @remove 1.5 * @replacement mdjm_format_datepicker_date */ function mdjm_jquery_short_date() { _deprecated_function(__FUNCTION__, '1.3', 'mdjm_format_datepicker_date()'); return mdjm_format_datepicker_date(); }
/** * The Availability checker form * * @params arr $args Optional: Settings passed from the shortcode * * @return */ public static function availability_form($args = '') { global $mdjm_settings; /** * Initialise the datepicker script */ ?> <?php mdjm_insert_datepicker(array('class' => 'custom_date', 'altfield' => 'check_date', 'mindate' => 'today')); ?> <?php echo '<!-- ' . __('MDJM Availability Checker', 'mobile-dj-manager') . ' (' . MDJM_VERSION_NUM . ') -->'; /** * If we are not using AJAX and a check has been performed and we're displaying text results */ if (self::$ajax == true) { ?> <div id="availability_result"></div> <?php } else { self::display_result(); } /** * Now display the availability checker form */ echo '<form name="mdjm-availability-check" id="mdjm-availability-check" method="post">' . "\r\n"; // Label echo '<label for="avail_date"'; // Label Wrap if (!empty($args['label_wrap']) && $args['label_wrap'] == 'false') { echo ' style="display: inline;"'; } // Label Class if (!empty($args['label_class']) && $args['label_class'] != 'false') { echo ' class="' . $args['label_class'] . '"'; } echo '>' . $args['label'] . ' </label>'; if (!empty($args['label_wrap']) && $args['label_wrap'] != 'false') { echo '<br />' . "\r\n"; } // Input field echo '<input type="text" name="avail_date" id="avail_date" class="custom_date" placeholder="' . mdjm_format_datepicker_date() . '"'; // Input Wrap if (!empty($args['field_wrap']) && $args['field_wrap'] == 'false') { echo ' style="display: inline;"'; } // Input Class if (!empty($args['field_class']) && $args['field_class'] != 'false') { echo ' class="' . $args['field_class'] . '"'; } echo ' readonly required />'; // Hidden field for datepicker echo '<input type="hidden" name="check_date" id="check_date" />' . "\r\n"; if (!empty($args['submit_wrap']) && $args['submit_wrap'] != 'false') { echo '<br /><br />' . "\r\n"; } // Submit field echo '<input type="submit" name="mdjm_avail_submit" id="mdjm_avail_submit" value="' . $args['submit_text'] . '"'; // Submit wrap if (!empty($args['submit_wrap']) && $args['submit_wrap'] == 'false') { echo ' style="display: inline;"'; } // Submit Class if (!empty($args['submit_class']) && $args['submit_class'] != 'false') { echo ' class="' . $args['submit_class'] . '"'; } echo '/>' . "\r\n"; // Please wait echo '<span id="pleasewait" style="display: none;" class="page-content'; // Please wait class if (!empty($args['please_wait_class']) && $args['please_wait_class'] != 'false') { echo ' ' . $args['please_wait_class']; } echo '" >'; if (!empty($args['please_wait_text'])) { echo $args['please_wait_text']; } else { echo __('Please wait...', 'mobile-dj-manager'); } echo '<img src="/wp-admin/images/loading.gif" alt="' . __('Please wait...', 'mobile-dj-manager') . '" /></span>' . "\r\n"; echo '</form>' . "\r\n"; self::validate(); echo '<!-- ' . __('MDJM Availability Checker', 'mobile-dj-manager') . ' (' . MDJM_VERSION_NUM . ') -->'; }