function eme_global_map_json($eventful = false, $scope = "all", $category = '', $map_id, $offset = 0) { $eventful = ($eventful==="true" || $eventful==="1") ? true : $eventful; $eventful = ($eventful==="false" || $eventful==="0") ? false : $eventful; $locations = eme_get_locations((bool)$eventful,$scope,$category,$offset); $json_locations = array(); foreach($locations as $location) { $json_location = array(); # first we set the balloon info $tmp_loc=eme_replace_locations_placeholders(get_option('eme_location_baloon_format'), $location); # no newlines allowed, otherwise no map is shown $tmp_loc=preg_replace("/\r\n?|\n\r?/","<br />",$tmp_loc); $json_location[] = '"location_balloon":"'.eme_trans_sanitize_html($tmp_loc).'"'; # second, we fill in the rest of the info foreach($location as $key => $value) { # we skip some keys, since json is limited in size we only return what's needed in the javascript if (preg_match('/location_balloon|location_id|location_latitude|location_longitude/', $key)) { # no newlines allowed, otherwise no map is shown $value=preg_replace("/\r\n?|\n\r/","<br />",$value); $json_location[] = '"'.$key.'":"'.eme_trans_sanitize_html($value).'"'; } } $json_locations[] = "{".implode(",",$json_location)."}"; } $zoom_factor=get_option('eme_global_zoom_factor'); $maptype=get_option('eme_global_maptype'); if ($zoom_factor >14) $zoom_factor=14; $json = '{"locations":['; $json .= implode(",", $json_locations); $json .= '],"enable_zooming":"'; $json .= get_option('eme_gmap_zooming') ? 'true' : 'false'; $json .= '","zoom_factor":"' ; $json .= $zoom_factor; $json .= '","maptype":"' ; $json .= $maptype; $json .= '","map_id":"' ; $json .= $map_id; $json .= '"}' ; echo $json; }
function eme_locations_search_ajax() { if (isset($_GET['id']) && $_GET['id'] != "") { $item = eme_get_location($_GET['id']); $record = array(); $record['id'] = $item['location_id']; $record['name'] = eme_trans_sanitize_html($item['location_name']); $record['address'] = eme_trans_sanitize_html($item['location_address']); $record['town'] = eme_trans_sanitize_html($item['location_town']); $record['latitude'] = eme_trans_sanitize_html($item['location_latitude']); $record['longitude'] = eme_trans_sanitize_html($item['location_longitude']); echo json_encode($record); } else { $locations = eme_get_locations(); $return = array(); if (!isset($_GET["q"])) { echo json_encode($return); return; } foreach ($locations as $item) { $record = array(); $record['id'] = $item['location_id']; $record['name'] = eme_trans_sanitize_html($item['location_name']); $record['address'] = eme_trans_sanitize_html($item['location_address']); $record['town'] = eme_trans_sanitize_html($item['location_town']); $record['latitude'] = eme_trans_sanitize_html($item['location_latitude']); $record['longitude'] = eme_trans_sanitize_html($item['location_longitude']); $return[] = $record; } $q = strtolower($_GET["q"]); if (!$q) { return; } $result = array(); foreach ($return as $row) { if (strpos(strtolower($row['name']), $q) !== false) { $result[] = $row; } } echo json_encode($result); } }
function eme_replace_filter_form_placeholders($format, $multiple, $multisize, $scope_count, $fields, $category, $notcategory) { if ($fields == "all") { $fields = "categories,locations,towns,weeks,months"; } preg_match_all("/#_[A-Za-z0-9_]+/", $format, $placeholders); usort($placeholders[0], 'sort_stringlenth'); // if one of these changes, also the eme_events.php needs changing for the "Next page" part $cat_post_name = "eme_cat_filter"; $loc_post_name = "eme_loc_filter"; $town_post_name = "eme_town_filter"; $scope_post_name = "eme_scope_filter"; $localised_scope_post_name = "eme_localised_scope_filter"; $selected_scope = isset($_REQUEST[$scope_post_name]) ? eme_sanitize_request($_REQUEST[$scope_post_name]) : ''; $selected_location = isset($_REQUEST[$loc_post_name]) ? eme_sanitize_request($_REQUEST[$loc_post_name]) : ''; $selected_town = isset($_REQUEST[$town_post_name]) ? eme_sanitize_request($_REQUEST[$town_post_name]) : ''; $selected_category = isset($_REQUEST[$cat_post_name]) ? eme_sanitize_request($_REQUEST[$cat_post_name]) : ''; $extra_conditions_arr = array(); if ($category != '') { $extra_conditions_arr[] = "(category_id IN ({$category}))"; } if ($notcategory != '') { $extra_conditions_arr[] = "(category_id NOT IN ({$notcategory}))"; } $extra_conditions = implode(' AND ', $extra_conditions_arr); $scope_fieldcount = 0; foreach ($placeholders[0] as $result) { $replacement = ""; $eventful = 0; $found = 1; $orig_result = $result; if (preg_match('/#_(EVENTFUL_)?FILTER_CATS/', $result) && get_option('eme_categories_enabled')) { if (strstr($result, '#_EVENTFUL')) { $eventful = 1; } $categories = eme_get_categories($eventful, "future", $extra_conditions); if ($categories && (empty($fields) || strstr($fields, 'categories'))) { $cat_list = array(); foreach ($categories as $this_category) { $id = $this_category['category_id']; $cat_list[$id] = eme_translate($this_category['category_name']); } asort($cat_list); if ($multiple) { $cat_list = array(0 => __('Select one or more categories', 'eme')) + $cat_list; $replacement = eme_ui_multiselect($selected_category, $cat_post_name, $cat_list, $multisize); } else { $cat_list = array(0 => __('Select a category', 'eme')) + $cat_list; $replacement = eme_ui_select($selected_category, $cat_post_name, $cat_list); } } } elseif (preg_match('/#_(EVENTFUL_)?FILTER_LOCS/', $result)) { if (strstr($result, '#_EVENTFUL')) { $eventful = 1; } $locations = eme_get_locations($eventful, "future"); if ($locations && (empty($fields) || strstr($fields, 'locations'))) { $loc_list = array(); foreach ($locations as $this_location) { $id = $this_location['location_id']; $loc_list[$id] = eme_translate($this_location['location_name']); } asort($loc_list); if ($multiple) { $loc_list = array(0 => __('Select one or more locations', 'eme')) + $loc_list; $replacement = eme_ui_multiselect($selected_location, $loc_post_name, $loc_list, $multisize); } else { $loc_list = array(0 => __('Select a location', 'eme')) + $loc_list; $replacement = eme_ui_select($selected_location, $loc_post_name, $loc_list); } } } elseif (preg_match('/#_(EVENTFUL_)?FILTER_TOWNS/', $result)) { if (strstr($result, '#_EVENTFUL')) { $eventful = 1; } $towns = eme_get_locations($eventful, "future"); if ($towns && (empty($fields) || strstr($fields, 'towns'))) { $town_list = array(); foreach ($towns as $this_town) { $id = eme_translate($this_town['location_town']); $town_list[$id] = $id; } asort($town_list); if ($multiple) { $town_list = array(0 => __('Select one or more towns', 'eme')) + $town_list; $replacement = eme_ui_multiselect($selected_town, $town_post_name, $town_list, $multisize); } else { $town_list = array(0 => __('Select a town', 'eme')) + $town_list; $replacement = eme_ui_select($selected_town, $town_post_name, $town_list); } } } elseif (preg_match('/#_FILTER_WEEKS/', $result)) { if ($scope_fieldcount == 0 && (empty($fields) || strstr($fields, 'weeks'))) { $replacement = eme_ui_select($selected_scope, $scope_post_name, eme_create_week_scope($scope_count)); $scope_fieldcount++; } } elseif (preg_match('/#_FILTER_MONTHS/', $result)) { if ($scope_fieldcount == 0 && (empty($fields) || strstr($fields, 'months'))) { $replacement = eme_ui_select($selected_scope, $scope_post_name, eme_create_month_scope($scope_count)); $scope_fieldcount++; } } elseif (preg_match('/#_FILTER_MONTHRANGE/', $result)) { if ($scope_fieldcount == 0 && (empty($fields) || strstr($fields, 'monthrange'))) { $replacement = "<input type='text' id='{$localised_scope_post_name}' name='{$localised_scope_post_name}' readonly='readonly' >"; $replacement .= "<input type='hidden' id='{$scope_post_name}' name='{$scope_post_name}' value='" . eme_sanitize_html($selected_scope) . "'>"; wp_enqueue_script('eme-jquery-datepick'); wp_enqueue_style('eme-jquery-datepick', EME_PLUGIN_URL . "js/jquery-datepick/jquery.datepick.css"); // jquery ui locales are with dashes, not underscores $locale_code = get_locale(); $locale_code = preg_replace("/_/", "-", $locale_code); $locale_file = EME_PLUGIN_DIR . "js/jquery-datepick/jquery.datepick-{$locale_code}.js"; $locale_file_url = EME_PLUGIN_URL . "js/jquery-datepick/jquery.datepick-{$locale_code}.js"; // for english, no translation code is needed) if ($locale_code != "en-US") { if (!file_exists($locale_file)) { $locale_code = substr($locale_code, 0, 2); $locale_file = EME_PLUGIN_DIR . "js/jquery-datepick/jquery.datepick-{$locale_code}.js"; $locale_file_url = EME_PLUGIN_URL . "js/jquery-datepick/jquery.datepick-{$locale_code}.js"; } if (file_exists($locale_file)) { wp_enqueue_script('eme-jquery-datepick-locale', $locale_file_url); } } ob_start(); ?> <script type="text/javascript"> var locale_code = '<?php echo $locale_code; ?> '; var firstDayOfWeek = <?php echo get_option('start_of_week'); ?> ; </script> <?php $replacement .= ob_get_clean(); $replacement .= "<script type='text/javascript' src='" . EME_PLUGIN_URL . "js/eme_filters.js'></script>"; } } elseif (preg_match('/#_FILTER_YEARS/', $result)) { if ($scope_fieldcount == 0 && (empty($fields) || strstr($fields, 'years'))) { $replacement = eme_ui_select($selected_scope, $scope_post_name, eme_create_year_scope($scope_count)); $scope_fieldcount++; } } else { $found = 0; } if ($found) { $replacement = apply_filters('eme_general', $replacement); $format = str_replace($orig_result, $replacement, $format); } } return do_shortcode($format); }
function eme_meta_box_div_location_name($event) { $use_select_for_locations = get_option('eme_use_select_for_locations'); // qtranslate there? Then we need the select, otherwise locations will be created again... $lang = eme_detect_lang(); if (!empty($lang)) { $use_select_for_locations = 1; } $gmap_is_active = get_option('eme_gmap_is_active'); $location = eme_get_location($event['location_id']); ?> <table id="eme-location-data"> <?php if ($use_select_for_locations) { $location_0 = eme_new_location(); $location_0['location_id'] = 0; $locations = eme_get_locations(); ?> <tr> <th><?php _e('Location', 'eme'); ?> </th> <td> <select name="location-select-id" id='location-select-id' size="1"> <option value="<?php echo $location_0['location_id']; ?> " ><?php echo eme_trans_sanitize_html($location_0['location_name']); ?> </option> <?php $selected_location = $location_0; foreach ($locations as $tmp_location) { $selected = ""; if (isset($location['location_id']) && $location['location_id'] == $tmp_location['location_id']) { $selected_location = $location; $selected = "selected='selected' "; } ?> <option value="<?php echo $tmp_location['location_id']; ?> " <?php echo $selected; ?> ><?php echo eme_trans_sanitize_html($tmp_location['location_name']); ?> </option> <?php } ?> </select> <input type='hidden' name='location-select-name' value='<?php echo eme_trans_sanitize_html($selected_location['location_name']); ?> ' /> <input type='hidden' name='location-select-town' value='<?php echo eme_trans_sanitize_html($selected_location['location_town']); ?> ' /> <input type='hidden' name='location-select-address' value='<?php echo eme_trans_sanitize_html($selected_location['location_address']); ?> ' /> <input type='hidden' name='location-select-latitude' value='<?php echo eme_trans_sanitize_html($selected_location['location_latitude']); ?> ' /> <input type='hidden' name='location-select-longitude' value='<?php echo eme_trans_sanitize_html($selected_location['location_longitude']); ?> ' /> </td> <?php if ($gmap_is_active) { ?> <td> <div id='eme-admin-map-not-found'> <p> <?php _e('Map not found', 'eme'); ?> </p> </div> <div id='eme-admin-location-map'></div></td> <?php } ?> </tr> <tr > <td colspan='2' rowspan='5' style='vertical-align: top'> <?php _e('Select a location for your event', 'eme'); ?> </td> </tr> <?php } else { ?> <tr> <th><?php _e('Name', 'eme'); ?> </th> <td><input id="location_name" type="text" name="location_name" value="<?php echo eme_trans_sanitize_html($location['location_name']); ?> " /></td> <?php if ($gmap_is_active) { ?> <td rowspan='6'> <div id='eme-admin-map-not-found'> <p> <?php _e('Map not found', 'eme'); ?> </p> </div> <div id='eme-admin-location-map'></div></td> <?php } ?> </tr> <tr> <td colspan='2'> <?php _e('The name of the location where the event takes place. You can use the name of a venue, a square, etc', 'eme'); ?> <br /> <?php _e('If you leave this empty, the map will NOT be shown for this event', 'eme'); ?> </td> </tr> <tr> <th><?php _e('Address:', 'eme'); ?> </th> <td><input id="location_address" type="text" name="location_address" value="<?php echo $location['location_address']; ?> " /></td> </tr> <tr> <td colspan='2'> <?php _e('The address of the location where the event takes place. Example: 21, Dominick Street', 'eme'); ?> </td> </tr> <tr> <th><?php _e('Town:', 'eme'); ?> </th> <td><input id="location_town" type="text" name="location_town" value="<?php echo $location['location_town']; ?> " /></td> </tr> <tr> <td colspan='2'> <?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.', 'eme'); ?> </td> </tr> <tr> <th><?php _e('Latitude:', 'eme'); ?> </th> <td><input id="location_latitude" type="text" name="location_latitude" value="<?php echo $location['location_latitude']; ?> " /></td> </tr> <tr> <th><?php _e('Longitude:', 'eme'); ?> </th> <td><input id="location_longitude" type="text" name="location_longitude" value="<?php echo $location['location_longitude']; ?> " /></td> </tr> <tr> <td colspan='2'> <?php _e('If you\'re using the Google Map integration and are really serious about the correct place, use these.', 'eme'); ?> </td> </tr> <?php } ?> </table> <?php }