function dbem_replace_placeholders($format, $event, $target = "html") { $event_string = $format; preg_match_all("/#@?_?[A-Za-z0-9]+/", $format, $placeholders); foreach ($placeholders[0] as $result) { // echo "RESULT: $result <br>"; // matches alla fields placeholder //TODO CUSTOM FIX FOR Brian // EVENTUALLY REMOVE if (preg_match('/#_JCCSTARTTIME/', $result)) { $time = substr($event['event_start_time'], 0, 5); $event_string = str_replace($result, $time, $event_string); } // END of REMOVE if (preg_match('/#_24HSTARTTIME/', $result)) { $time = substr($event['event_start_time'], 0, 5); $event_string = str_replace($result, $time, $event_string); } if (preg_match('/#_24HENDTIME/', $result)) { $time = substr($event['event_end_time'], 0, 5); $event_string = str_replace($result, $time, $event_string); } if (preg_match('/#_12HSTARTTIME/', $result)) { $AMorPM = "AM"; $hour = substr($event['event_start_time'], 0, 2); $minute = substr($event['event_start_time'], 3, 2); if ($hour > 12) { $hour = $hour - 12; $AMorPM = "PM"; } $time = "{$hour}:{$minute} {$AMorPM}"; $event_string = str_replace($result, $time, $event_string); } if (preg_match('/#_12HENDTIME/', $result)) { $AMorPM = "AM"; $hour = substr($event['event_end_time'], 0, 2); $minute = substr($event['event_end_time'], 3, 2); if ($hour > 12) { $hour = $hour - 12; $AMorPM = "PM"; } $time = "{$hour}:{$minute} {$AMorPM}"; $event_string = str_replace($result, $time, $event_string); } if (preg_match('/#_MAP/', $result)) { $location = dbem_get_location($event['location_id']); $map_div = dbem_single_location_map($location); $event_string = str_replace($result, $map_div, $event_string); } if (preg_match('/#_ADDBOOKINGFORM/', $result)) { $rsvp_is_active = get_option('dbem_gmap_is_active'); if ($event['event_rsvp']) { $rsvp_add_module .= dbem_add_booking_form(); } else { $rsvp_add_module .= ""; } $event_string = str_replace($result, $rsvp_add_module, $event_string); } if (preg_match('/#_REMOVEBOOKINGFORM/', $result)) { $rsvp_is_active = get_option('dbem_gmap_is_active'); if ($event['event_rsvp']) { $rsvp_delete_module .= dbem_delete_booking_form(); } else { $rsvp_delete_module .= ""; } $event_string = str_replace($result, $rsvp_delete_module, $event_string); } if (preg_match('/#_AVAILABLESEATS/', $result)) { $rsvp_is_active = get_option('dbem_gmap_is_active'); if ($event['event_rsvp']) { $availble_seats .= dbem_get_available_seats($event['event_id']); } else { $availble_seats .= ""; } $event_string = str_replace($result, $availble_seats, $event_string); } if (preg_match('/#_LINKEDNAME/', $result)) { $events_page_id = get_option('dbem_events_page'); $event_page_link = get_permalink($events_page_id); if (stristr($event_page_link, "?")) { $joiner = "&"; } else { $joiner = "?"; } $event_string = str_replace($result, "<a href='" . get_permalink($events_page_id) . $joiner . "event_id=" . $event['event_id'] . "' title='" . $event['event_name'] . "'>" . $event['event_name'] . "</a>", $event_string); } if (preg_match('/#_EVENTPAGEURL/', $result)) { $events_page_id = get_option('dbem_events_page'); $event_page_link = get_permalink($events_page_id); if (stristr($event_page_link, "?")) { $joiner = "&"; } else { $joiner = "?"; } $event_string = str_replace($result, get_permalink($events_page_id) . $joiner . "event_id=" . $event['event_id'], $event_string); } if (preg_match('/#_(NAME|NOTES|SEATS)/', $result)) { $field = "event_" . ltrim(strtolower($result), "#_"); $field_value = $event[$field]; if ($field == "event_notes") { if ($target == "html") { $field_value = apply_filters('dbem_notes', $field_value); } else { if ($target == "map") { $field_value = apply_filters('dbem_notes_map', $field_value); } else { $field_value = apply_filters('dbem_notes_rss', $field_value); } } } else { if ($target == "html") { $field_value = apply_filters('dbem_general', $field_value); } else { $field_value = apply_filters('dbem_general_rss', $field_value); } } $event_string = str_replace($result, $field_value, $event_string); } if (preg_match('/#_(ADDRESS|TOWN|PROVINCE)/', $result)) { $field = "location_" . ltrim(strtolower($result), "#_"); $field_value = $event[$field]; if ($field == "event_notes") { if ($target == "html") { $field_value = apply_filters('dbem_notes', $field_value); } else { if ($target == "map") { $field_value = apply_filters('dbem_notes_map', $field_value); } else { $field_value = apply_filters('dbem_notes_rss', $field_value); } } } else { if ($target == "html") { $field_value = apply_filters('dbem_general', $field_value); } else { $field_value = apply_filters('dbem_general_rss', $field_value); } } $event_string = str_replace($result, $field_value, $event_string); } if (preg_match('/#_(LOCATION)$/', $result)) { $field = "location_name"; $field_value = $event[$field]; if ($target == "html") { $field_value = apply_filters('dbem_general', $field_value); } else { $field_value = apply_filters('dbem_general_rss', $field_value); } $event_string = str_replace($result, $field_value, $event_string); } if (preg_match('/#_CONTACTNAME$/', $result)) { $event['event_contactperson_id'] ? $user_id = $event['event_contactperson_id'] : ($user_id = get_option('dbem_default_contact_person')); $name = dbem_get_user_name($user_id); $event_string = str_replace($result, $name, $event_string); } if (preg_match('/#_CONTACTEMAIL$/', $result)) { $event['event_contactperson_id'] ? $user_id = $event['event_contactperson_id'] : ($user_id = get_option('dbem_default_contact_person')); $email = dbem_get_user_email($user_id); $event_string = str_replace($result, dbem_ascii_encode($email), $event_string); } if (preg_match('/#_CONTACTPHONE$/', $result)) { $event['event_contactperson_id'] ? $user_id = $event['event_contactperson_id'] : ($user_id = get_option('dbem_default_contact_person')); $phone = dbem_get_user_phone($user_id); $event_string = str_replace($result, dbem_ascii_encode($phone), $event_string); } if (preg_match('/#_(IMAGE)/', $result)) { if ($event['location_image_url'] != '') { $location_image = "<img src='" . $event['location_image_url'] . "' alt='" . $event['location_name'] . "'/>"; } else { $location_image = ""; } $event_string = str_replace($result, $location_image, $event_string); } if (preg_match('/#_(LOCATIONPAGEURL)/', $result)) { $events_page_link = dbem_get_events_page(true, false); if (stristr($events_page_link, "?")) { $joiner = "&"; } else { $joiner = "?"; } $venue_page_link = $events_page_link . $joiner . "location_id=" . $event['location_id']; $event_string = str_replace($result, $venue_page_link, $event_string); } // matches all PHP time placeholders for endtime if (preg_match('/^#@[dDjlNSwzWFmMntLoYy]$/', $result)) { $event_string = str_replace($result, mysql2date(ltrim($result, "#@"), $event['event_end_date']), $event_string); } // matches all PHP date placeholders if (preg_match('/^#[dDjlNSwzWFmMntLoYy]$/', $result)) { // echo "-inizio-"; $event_string = str_replace($result, mysql2date(ltrim($result, "#"), $event['event_start_date']), $event_string); // echo $event_string; } // matches all PHP time placeholders if (preg_match('/^#@[aABgGhHisueIOPTZcrU]$/', $result)) { $event_string = str_replace($result, mysql2date(ltrim($result, "#@"), "0000-00-00 " . $event['event_end_time']), $event_string); // echo $event_string; } if (preg_match('/^#[aABgGhHisueIOPTZcrU]$/', $result)) { $event_string = str_replace($result, mysql2date(ltrim($result, "#"), "0000-00-00 " . $event['event_start_time']), $event_string); // echo $event_string; } /* Marcus/ROR Begin Edit*/ //Add a placeholder for categories if (preg_match('/#_CATEGORY$/', $result)) { $category = dbem_get_event_category($event['event_id']); if (stristr($event_page_link, "?")) { $joiner = "&"; } else { $joiner = "?"; } $event_string = str_replace($result, "<a href='" . get_permalink($events_page_id) . $joiner . "category=" . $category['category_id'] . "' title='" . $category['category_name'] . "'>" . $category['category_name'] . "</a>", $event_string); } /* Marcus/ROR End Edit */ } /* Marcus Begin Edit */ preg_match_all("/#@?_\\{[A-Za-z0-9 -\\/,\\.\\\\]+\\}/", $format, $placeholders); foreach ($placeholders[0] as $result) { if (substr($result, 0, 3) == "#@_") { $date = 'event_end_date'; $offset = 4; } else { $date = 'event_start_date'; $offset = 3; } $event_string = str_replace($result, mysql2date(substr($result, $offset, strlen($result) - ($offset + 1)), $event[$date]), $event_string); } /* Marcus End Edit */ return $event_string; }
</div> <h3 class='hndle'><span> <?php _e('Category', 'dbem'); ?> </span></h3> <div class="inside"> <p>Category: <select name="event[category_id]"> <?php $categories = dbem_get_categories(); ?> <option value="">Select...</option> <?php foreach ($categories as $category) { $event_category = dbem_get_event_category($event['event_id']); $selected = $category['category_id'] == $event_category['category_id'] ? "selected='selected'" : ''; ?> <option value="<?php echo $category['category_id']; ?> " <?php echo $selected; ?> > <?php echo $category['category_name']; ?> </option> <?php }
function dbem_event_form($event, $title, $element) { global $localised_date_formats; // change prefix according to event/recurrence $_GET['action'] == "edit_recurrence" ? $pref = "recurrence_" : ($pref = "event_"); $_GET['action'] == "edit_recurrence" ? $form_destination = "edit.php?page=events-manager/events-manager.php&action=update_recurrence&recurrence_id=" . $element : ($form_destination = "edit.php?page=events-manager/events-manager.php&action=update_event&event_id=" . $element); $locale_code = substr(get_locale(), 0, 2); $localised_date_format = $localised_date_formats[$locale_code]; $hours_locale = "24"; // Setting 12 hours format for those countries using it if (preg_match("/en|sk|zh|us|uk/", $locale_code)) { $hours_locale = "12"; } $localised_example = str_replace("yy", "2008", str_replace("mm", "11", str_replace("dd", "28", $localised_date_format))); $localised_end_example = str_replace("yy", "2008", str_replace("mm", "11", str_replace("dd", "28", $localised_date_format))); if ($event[$pref . 'start_date'] != "") { preg_match("/(\\d{4})-(\\d{2})-(\\d{2})/", $event[$pref . 'start_date'], $matches); $year = $matches[1]; $month = $matches[2]; $day = $matches[3]; $localised_date = str_replace("yy", $year, str_replace("mm", $month, str_replace("dd", $day, $localised_date_format))); } else { $localised_date = ""; } if ($event[$pref . 'end_date'] != "") { preg_match("/(\\d{4})-(\\d{2})-(\\d{2})/", $event[$pref . 'end_date'], $matches); $end_year = $matches[1]; $end_month = $matches[2]; $end_day = $matches[3]; $localised_end_date = str_replace("yy", $end_year, str_replace("mm", $end_month, str_replace("dd", $end_day, $localised_date_format))); } else { $localised_end_date = ""; } // if($event[$pref.'rsvp']) // echo (dbem_bookings_table($event[$pref.'id'])); $freq_options = array("daily" => __('Daily', 'dbem'), "weekly" => __('Weekly', 'dbem'), "monthly" => __('Monthly', 'dbem')); $days_names = array(1 => __('Mon'), 2 => __('Tue'), 3 => __('Wed'), 4 => __('Thu'), 5 => __('Fri'), 6 => __('Sat'), 7 => __('Sun')); $saved_bydays = explode(",", $event['recurrence_byday']); $weekno_options = array("1" => __('first', 'dbem'), '2' => __('second', 'dbem'), '3' => __('third', 'dbem'), '4' => __('fourth', 'dbem'), '-1' => __('last', 'dbem')); $event[$pref . 'rsvp'] ? $event_RSVP_checked = "checked='checked'" : ($event_RSVP_checked = ''); ?> <form id="eventForm" method="post" action="<?php echo $form_destination; ?> "> <div class="wrap"> <div id="icon-events" class="icon32"><br /></div> <h2><?php echo $title; ?> </h2> <?php if ($event['recurrence_id']) { ?> <p id='recurrence_warning'> <?php if (isset($_GET['action']) && $_GET['action'] == 'edit_recurrence') { _e('WARNING: This is a recurrence.', 'dbem'); ?> <br /> <?php _e('Modifying these data all the events linked to this recurrence will be rescheduled', 'dbem'); } else { _e('WARNING: This is a recurring event.', 'dbem'); _e('If you change these data and save, this will become an independent event.', 'dbem'); } ?> </p> <?php } ?> <?php /* Marcus Begin Edit */ //This is an edit for WP 2.8 for styling fix ?> <div id="poststuff" class="metabox-holder has-right-sidebar"> <!-- SIDEBAR --> <div id="side-info-column" class='inner-sidebar'> <div id='side-sortables'> <!-- recurrence postbox --> <div class="postbox "> <div class="handlediv" title="Fare clic per cambiare."><br /> </div> <h3 class='hndle'><span> <?php _e("Recurrence", 'dbem'); ?> </span></h3> <div class="inside"> <?php if (!$event['event_id']) { ?> <?php if ($event['recurrence_id'] != "") { $recurrence_YES = "checked='checked'"; } ?> <p> <input id="event-recurrence" type="checkbox" name="repeated_event" value="1" <?php echo $recurrence_YES; ?> /> <?php _e('Repeated event', 'dbem'); ?> </p> <div id="event_recurrence_pattern"> <p>Frequency: <select id="recurrence-frequency" name="recurrence_freq"> <?php dbem_option_items($freq_options, $event[$pref . 'freq']); ?> </select> </p> <p> <?php _e('Every', 'dbem'); ?> <input id="recurrence-interval" name='recurrence_interval' size='2' value='<?php echo $event['recurrence_interval']; ?> '> </input> <span class='interval-desc' id="interval-daily-singular"> <?php _e('day', 'dbem'); ?> </span> <span class='interval-desc' id="interval-daily-plural"> <?php _e('days', 'dbem'); ?> </span> <span class='interval-desc' id="interval-weekly-singular"> <?php _e('week', 'dbem'); ?> </span> <span class='interval-desc' id="interval-weekly-plural"> <?php _e('weeks', 'dbem'); ?> </span> <span class='interval-desc' id="interval-monthly-singular"> <?php _e('month', 'dbem'); ?> </span> <span class='interval-desc' id="interval-monthly-plural"> <?php _e('months', 'dbem'); ?> </span> </p> <p class="alternate-selector" id="weekly-selector"> <?php dbem_checkbox_items('recurrence_bydays[]', $days_names, $saved_bydays); ?> </p> <p class="alternate-selector" id="monthly-selector"> <?php _e('Every', 'dbem'); ?> <select id="monthly-modifier" name="recurrence_byweekno"> <?php dbem_option_items($weekno_options, $event['recurrence_byweekno']); ?> </select> <select id="recurrence-weekday" name="recurrence_byday"> <?php dbem_option_items($days_names, $event['recurrence_byday']); ?> </select> </p> </div> <p id="recurrence-tip"> <?php _e('Check if your event happens more than once according to a regular pattern', 'dbem'); ?> </p> <?php } else { if (!$event['recurrence_id']) { echo "<p>" . __('This is\'t a recurrent event', 'dbem') . ".</p>"; } else { $recurrence = dbem_get_recurrence($event['recurrence_id']); ?> <p> <?php echo $recurrence['recurrence_description']; ?> <br /> <a href="<?php bloginfo('wpurl'); ?> /wp-admin/edit.php?page=events-manager/events-manager.php&action=edit_recurrence&recurrence_id=<?php echo $recurrence['recurrence_id']; ?> "> <?php _e('Reschedule', 'dbem'); ?> </a></p> <?php } ?> <?php } ?> </div> </div> <div class="postbox "> <div class="handlediv" title="Fare clic per cambiare."><br /> </div> <h3 class='hndle'><span> <?php _e('Contact Person', 'dbem'); ?> </span></h3> <div class="inside"> <p>Contact: <?php wp_dropdown_users(array('name' => 'event_contactperson_id', 'show_option_none' => __("Select...", 'dbem'), 'selected' => $event['event_contactperson_id'])); ?> </p> </div> </div> <div class="postbox "> <div class="handlediv" title="Fare clic per cambiare."><br /> </div> <h3 class='hndle'><span>RSVP</span></h3> <div class="inside"> <p> <input id="rsvp-checkbox" name='event_rsvp' value='1' type='checkbox' <?php echo $event_RSVP_checked; ?> /> <?php _e('Enable registration for this event', 'dbem'); ?> </p> <div id='rsvp-data'> <?php if ($event['event_contactperson_id'] != NULL) { $selected = $event['event_contactperson_id']; } else { $selected = '0'; } ?> <p> <?php _e('Spaces'); ?> : <input id="seats-input" type="text" name="event_seats" size='5' value="<?php echo $event[$pref . 'seats']; ?> " /> </p> <?php if ($event['event_rsvp']) { ?> <?php dbem_bookings_compact_table($event[$pref . 'id']); ?> <?php } ?> </div> </div> </div> <?php /* Marcus Begin Edit */ //adding the category selection box ?> <div class="postbox "> <div class="handlediv" title="Fare clic per cambiare."><br /> </div> <h3 class='hndle'><span> <?php _e('Category', 'dbem'); ?> </span></h3> <div class="inside"> <p>Category: <select name="event_category_id"> <?php $categories = dbem_get_categories(); ?> <option value="">Select...</option> <?php foreach ($categories as $category) { $event_category = dbem_get_event_category($event['event_id']); $selected = $category['category_id'] == $event_category['category_id'] ? "selected='selected'" : ''; ?> <option value="<?php echo $category['category_id']; ?> " <?php echo $selected; ?> > <?php echo $category['category_name']; ?> </option> <?php } ?> </select> </p> </div> </div> </div> <?php /* Marcus End Edit */ ?> </div> <!-- END OF SIDEBAR --> <div id="post-body"> <div id="post-body-content"> <?php /* Marcus End Edit */ ?> <div id="event_name" class="stuffbox"> <h3> <?php _e('Name', 'dbem'); ?> </h3> <div class="inside"> <input type="text" name="event_name" value="<?php echo $event[$pref . 'name']; ?> " /> <br /> <?php _e('The event name. Example: Birthday party', 'dbem'); ?> </div> </div> <div id="event_start_date" class="stuffbox"> <h3 id='event-date-title'> <?php _e('Event date', 'dbem'); ?> </h3> <h3 id='recurrence-dates-title'> <?php _e('Recurrence dates', 'dbem'); ?> </h3> <div class="inside"> <input id="localised-date" type="text" name="localised_event_date" value="<?php echo $localised_date; ?> " style="display: none;" /> <input id="date-to-submit" type="text" name="event_date" value="<?php echo $event[$pref . 'start_date']; ?> " style="background: #FCFFAA" /> <input id="localised-end-date" type="text" name="localised_event_end_date" value="<?php echo $localised_end_date; ?> " style="display: none;" /> <input id="end-date-to-submit" type="text" name="event_end_date" value="<?php echo $event[$pref . 'end_date']; ?> " style="background: #FCFFAA" /> <br /> <span id='event-date-explanation'> <?php _e('The event date.', 'dbem'); /* Marcus Begin Edit */ echo " "; _e('When not reoccurring, this event spans between the beginning and end date.', 'dbem'); /* Marcus End Edit */ ?> </span><span id='recurrence-dates-explanation'> <?php _e('The recurrence beginning and end date.', 'dbem'); ?> </span> </div> </div> <div id="event_end_day" class="stuffbox"> <h3> <?php _e('Event time', 'dbem'); ?> </h3> <div class="inside"> <input id="start-time" type="text" size="8" maxlength="8" name="event_start_time" value="<?php echo $event[$pref . 'start_' . $hours_locale . "h_time"]; ?> " /> - <input id="end-time" type="text" size="8" maxlength="8" name="event_end_time" value="<?php echo $event[$pref . 'end_' . $hours_locale . "h_time"]; ?> " /> <br /> <?php _e('The time of the event beginning and end', 'dbem'); ?> . </div> </div> <div id="location_coordinates" class="stuffbox" style='display: none;'> <h3> <?php _e('Coordinates', 'dbem'); ?> </h3> <div class="inside"> <input id='location-latitude' name='location_latitude' type='text' value='<?php echo $event['location_latitude']; ?> ' size='15' /> - <input id='location-longitude' name='location_longitude' type='text' value='<?php echo $event['location_longitude']; ?> ' size='15' /> </div> </div> <div id="location_name" class="stuffbox"> <h3> <?php _e('Location', 'dbem'); ?> </h3> <div class="inside"> <table id="dbem-location-data"> <tr> <th><?php _e('Name:'); ?> </th> <td><input id="location-name" type="text" name="location_name" value="<?php echo $event['location_name']; ?> " /></td> <?php $gmap_is_active = get_option('dbem_gmap_is_active'); ?> <?php if ($gmap_is_active) { ?> <td rowspan='6'><div id='map-not-found' style='width: 400px; font-size: 140%; text-align: center; margin-top: 100px; display: hide'> <p> <?php _e('Map not found'); ?> </p> </div> <div id='event-map' style='width: 400px; height: 300px; background: green; display: hide; margin-right: 8px'></div></td> <?php } // end of IF_GMAP_ACTIVE ?> </tr> <tr> <td colspan='2'><p> <?php _e('The name of the location where the event takes place. You can use the name of a venue, a square, etc', 'dbem'); ?> </p></td> </tr> <tr> <th><?php _e('Address:'); ?> </th> <td><input id="location-address" type="text" name="location_address" value="<?php echo $event['location_address']; ?> " /></td> </tr> <tr> <td colspan='2'><p> <?php _e('The address of the location where the event takes place. Example: 21, Dominick Street', 'dbem'); ?> </p></td> </tr> <tr> <th><?php _e('Town:'); ?> </th> <td><input id="location-town" type="text" name="location_town" value="<?php echo $event['location_town']; ?> " /></td> </tr> <tr> <td colspan='2'><p> <?php _e('The town where the location is located. If you\'re using the Google Map integration and want to avoid geotagging ambiguities include the country in the town field. Example: Verona, Italy.', 'dbem'); ?> </p></td> </tr> </table> </div> </div> <div id="event_notes" class="postbox"> <h3> <?php _e('Details', 'dbem'); ?> </h3> <div class="inside"> <?php /* Marcus Begin Edit */ ?> <!-- Currently deactivated for editor test <textarea name="event_notes" rows="8" cols="60"> <?php echo $event[$pref . 'notes']; ?> </textarea> --> <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?> " class="postarea"> <?php the_editor($event[$pref . 'notes']); ?> </div> <?php /* Marcus End Edit */ ?> <br /> <?php _e('Details about the event', 'dbem'); ?> </div> </div> </div> <p class="submit"> <input type="submit" name="events_update" value="<?php _e('Submit Event', 'dbem'); ?> »" /> </p> </div> </div> </div> </form> <?php }
function dbem_replace_placeholders($format, $event, $target = "html") { $event_string = $format; preg_match_all("/#@?_?[A-Za-z0-9]+/", $format, $placeholders); foreach ($placeholders[0] as $result) { // echo "RESULT: $result <br>"; // matches alla fields placeholder //TODO CUSTOM FIX FOR Brian // EVENTUALLY REMOVE if (preg_match('/#_JCCSTARTTIME/', $result)) { $time = substr($event['event_start_time'], 0, 5); $event_string = str_replace($result, $time, $event_string); } // END of REMOVE if (preg_match('/#_24HSTARTTIME/', $result)) { $time = substr($event['event_start_time'], 0, 5); $event_string = str_replace($result, $time, $event_string); } if (preg_match('/#_24HENDTIME/', $result)) { $time = substr($event['event_end_time'], 0, 5); $event_string = str_replace($result, $time, $event_string); } if (preg_match('/#_12HSTARTTIME/', $result)) { $AMorPM = "AM"; $hour = substr($event['event_start_time'], 0, 2); $minute = substr($event['event_start_time'], 3, 2); if ($hour > 12) { $hour = $hour - 12; $AMorPM = "PM"; } $time = "{$hour}:{$minute} {$AMorPM}"; $event_string = str_replace($result, $time, $event_string); } if (preg_match('/#_12HENDTIME/', $result)) { $AMorPM = "AM"; $hour = substr($event['event_end_time'], 0, 2); $minute = substr($event['event_end_time'], 3, 2); if ($hour > 12) { $hour = $hour - 12; $AMorPM = "PM"; } $time = "{$hour}:{$minute} {$AMorPM}"; $event_string = str_replace($result, $time, $event_string); } if (preg_match('/#_MAP/', $result)) { $location = dbem_get_location($event['location_id']); $map_div = dbem_single_location_map($location); $event_string = str_replace($result, $map_div, $event_string); } if (preg_match('/#_ADDBOOKINGFORM/', $result)) { $rsvp_is_active = get_option('dbem_gmap_is_active'); if ($event['event_rsvp']) { $rsvp_add_module .= dbem_add_booking_form(); } else { $rsvp_add_module .= ""; } $event_string = str_replace($result, $rsvp_add_module, $event_string); } if (preg_match('/#_REMOVEBOOKINGFORM/', $result)) { $rsvp_is_active = get_option('dbem_gmap_is_active'); if ($event['event_rsvp']) { $rsvp_delete_module .= dbem_delete_booking_form(); } else { $rsvp_delete_module .= ""; } $event_string = str_replace($result, $rsvp_delete_module, $event_string); } if (preg_match('/#_AVAILABLESEATS/', $result)) { $rsvp_is_active = get_option('dbem_gmap_is_active'); if ($event['event_rsvp']) { $availble_seats .= dbem_get_available_seats($event['event_id']); } else { $availble_seats .= ""; } $event_string = str_replace($result, $availble_seats, $event_string); } if (preg_match('/#_LINKEDNAME/', $result)) { $events_page_id = get_option('dbem_events_page'); $event_page_link = get_permalink($events_page_id); if (stristr($event_page_link, "?")) { $joiner = "&"; } else { $joiner = "?"; } $event_string = str_replace($result, "<a href='" . get_permalink($events_page_id) . $joiner . "event_id=" . $event['event_id'] . "' title='" . $event['event_name'] . "'>" . $event['event_name'] . "</a>", $event_string); } if (preg_match('/#_EVENTPAGEURL(\\[(.+\\)]))?/', $result)) { $events_page_id = get_option('dbem_events_page'); if (stristr($event_page_link, "?")) { $joiner = "&"; } else { $joiner = "?"; } $event_string = str_replace($result, get_permalink($events_page_id) . $joiner . "event_id=" . $event['event_id'], $event_string); } if (preg_match('/#_(NAME|NOTES|SEATS|EXCERPT)/', $result)) { $field = "event_" . ltrim(strtolower($result), "#_"); $field_value = $event[$field]; if ($field == "event_notes" || $field == "event_excerpt") { /* Marcus Begin Edit */ if ($target == "html") { //If excerpt, we use more link text if ($field == "event_excerpt") { $matches = explode('<!--more-->', $event['event_notes']); $field_value = $matches[0]; $field_value = apply_filters('dbem_notes_excerpt', $field_value); } else { $field_value = apply_filters('dbem_notes', $field_value); } //$field_value = apply_filters('the_content', $field_value); - chucks a wobbly if we do this. } else { if ($target == "map") { $field_value = apply_filters('dbem_notes_map', $field_value); } else { if ($field == "event_excerpt") { $matches = explode('<!--more-->', $event['event_notes']); $field_value = htmlentities($matches[0]); $field_value = apply_filters('dbem_notes_rss', $field_value); } else { $field_value = apply_filters('dbem_notes_rss', $field_value); } $field_value = apply_filters('the_content_rss', $field_value); } } /* Marcus End Edit */ } else { if ($target == "html") { $field_value = apply_filters('dbem_general', $field_value); } else { $field_value = apply_filters('dbem_general_rss', $field_value); } } $event_string = str_replace($result, $field_value, $event_string); } if (preg_match('/#_(ADDRESS|TOWN|PROVINCE)/', $result)) { $field = "location_" . ltrim(strtolower($result), "#_"); $field_value = $event[$field]; if ($field == "event_notes") { if ($target == "html") { $field_value = apply_filters('dbem_notes', $field_value); } else { if ($target == "map") { $field_value = apply_filters('dbem_notes_map', $field_value); } else { $field_value = apply_filters('dbem_notes_rss', $field_value); } } } else { if ($target == "html") { $field_value = apply_filters('dbem_general', $field_value); } else { $field_value = apply_filters('dbem_general_rss', $field_value); } } $event_string = str_replace($result, $field_value, $event_string); } if (preg_match('/#_(LOCATION)$/', $result)) { $field = "location_name"; $field_value = $event[$field]; if ($target == "html") { $field_value = apply_filters('dbem_general', $field_value); } else { $field_value = apply_filters('dbem_general_rss', $field_value); } $event_string = str_replace($result, $field_value, $event_string); } if (preg_match('/#_CONTACTNAME$/', $result)) { $event['event_contactperson_id'] ? $user_id = $event['event_contactperson_id'] : ($user_id = get_option('dbem_default_contact_person')); $name = dbem_get_user_name($user_id); $event_string = str_replace($result, $name, $event_string); } if (preg_match('/#_CONTACTEMAIL$/', $result)) { $event['event_contactperson_id'] ? $user_id = $event['event_contactperson_id'] : ($user_id = get_option('dbem_default_contact_person')); $email = dbem_get_user_email($user_id); $event_string = str_replace($result, dbem_ascii_encode($email), $event_string); } if (preg_match('/#_CONTACTPHONE$/', $result)) { $event['event_contactperson_id'] ? $user_id = $event['event_contactperson_id'] : ($user_id = get_option('dbem_default_contact_person')); $phone = dbem_get_user_phone($user_id); $event_string = str_replace($result, dbem_ascii_encode($phone), $event_string); } if (preg_match('/#_(IMAGE)/', $result)) { if ($event['location_image_url'] != '') { $location_image = "<img src='" . $event['location_image_url'] . "' alt='" . $event['location_name'] . "'/>"; } else { $location_image = ""; } $event_string = str_replace($result, $location_image, $event_string); } if (preg_match('/#_(LOCATIONPAGEURL)/', $result)) { $events_page_link = dbem_get_events_page(true, false); if (stristr($events_page_link, "?")) { $joiner = "&"; } else { $joiner = "?"; } $venue_page_link = $events_page_link . $joiner . "location_id=" . $event['location_id']; $event_string = str_replace($result, $venue_page_link, $event_string); } // matches all PHP time placeholders for endtime if (preg_match('/^#@[dDjlNSwzWFmMntLoYy]$/', $result)) { $event_string = str_replace($result, mysql2date(ltrim($result, "#@"), $event['event_end_date']), $event_string); } // matches all PHP date placeholders if (preg_match('/^#[dDjlNSwzWFmMntLoYy]$/', $result)) { // echo "-inizio-"; $event_string = str_replace($result, mysql2date(ltrim($result, "#"), $event['event_start_date']), $event_string); // echo $event_string; } // matches all PHP time placeholders if (preg_match('/^#@[aABgGhHisueIOPTZcrU]$/', $result)) { $event_string = str_replace($result, mysql2date(ltrim($result, "#@"), "2000-10-10 " . $event['event_end_time']), $event_string); // echo $event_string; } if (preg_match('/^#[aABgGhHisueIOPTZcrU]$/', $result)) { $event_string = str_replace($result, mysql2date(ltrim($result, "#"), "2000-10-10 " . $event['event_start_time']), $event_string); //echo $event['event_start_time']; //echo mysql2date('h:i A', '2010-10-10 23:35:00')."<br/>"; // echo $event_string; } /* Marcus Begin Edit*/ //Add a placeholder for categories if (preg_match('/^#_CATEGORY$/', $result)) { $category = dbem_get_event_category($event['event_id']); $event_string = str_replace($result, $category['category_name'], $event_string); } /* Marcus End Edit */ } /* Marcus Begin Edit */ preg_match_all("/#@?_\\{[A-Za-z0-9 -\\/,\\.\\\\]+\\}/", $format, $results); foreach ($results[0] as $result) { if (substr($result, 0, 3) == "#@_") { $date = 'event_end_date'; $offset = 4; } else { $date = 'event_start_date'; $offset = 3; } if ($date == 'event_end_date' && $event[$date] == $event['event_start_date']) { $event_string = str_replace($result, '', $event_string); } else { $event_string = str_replace($result, mysql2date(substr($result, $offset, strlen($result) - ($offset + 1)), $event[$date]), $event_string); } } /* Marcus End Edit */ /* Marcus Begin Edit */ //This is for the custom attributes preg_match_all("/#_ATT\\{.+?\\}(\\{.+?\\})?/", $format, $results); foreach ($results[0] as $resultKey => $result) { //Strip string of placeholder and just leave the reference $attRef = substr(substr($result, 0, strpos($result, '}')), 6); $attString = $event['event_attributes'][$attRef]; if (trim($attString) == '' && $results[1][$resultKey] != '') { //Check to see if we have a second set of braces; $attString = substr($results[1][$resultKey], 1, strlen(trim($results[1][$resultKey])) - 2); } $event_string = str_replace($result, $attString, $event_string); } /* Marcus End Edit */ return $event_string; }