Test Failed
Pull Request — master (#397)
by Kiran
18:54
created
geodirectory-functions/map-functions/get_markers.php 1 patch
Indentation   +343 added lines, -343 removed lines patch added patch discarded remove patch
@@ -7,61 +7,61 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'homemap_catlist') {
10
-    global $gd_session;
11
-    $gd_post_type = sanitize_text_field($_REQUEST['post_type']);
12
-    $gd_session->set('homemap_catlist_ptype', $gd_post_type);
13
-    $post_taxonomy = geodir_get_taxonomies($gd_post_type);
14
-    $map_canvas_name = sanitize_text_field($_REQUEST['map_canvas']);
15
-    $child_collapse = (bool)$_REQUEST['child_collapse'];
16
-    echo home_map_taxonomy_walker($post_taxonomy, 0, true, 0, $map_canvas_name, $child_collapse, true);
17
-    die;
10
+	global $gd_session;
11
+	$gd_post_type = sanitize_text_field($_REQUEST['post_type']);
12
+	$gd_session->set('homemap_catlist_ptype', $gd_post_type);
13
+	$post_taxonomy = geodir_get_taxonomies($gd_post_type);
14
+	$map_canvas_name = sanitize_text_field($_REQUEST['map_canvas']);
15
+	$child_collapse = (bool)$_REQUEST['child_collapse'];
16
+	echo home_map_taxonomy_walker($post_taxonomy, 0, true, 0, $map_canvas_name, $child_collapse, true);
17
+	die;
18 18
 }
19 19
 
20 20
 // Send the content-type header with correct encoding
21 21
 header("Content-type: text/javascript; charset=utf-8");
22 22
 
23 23
 if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'cat') { // Retrives markers data for categories
24
-    echo get_markers();
25
-    exit;
24
+	echo get_markers();
25
+	exit;
26 26
 } else if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'info') { // Retrives marker info window html
27
-    /**
28
-     * @global object $wpdb WordPress Database object.
29
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
30
-     * @global object $gd_session GeoDirectory Session object.
31
-     */
32
-    global $wpdb, $plugin_prefix, $gd_session;
33
-
34
-    if ($_REQUEST['m_id'] != '') {
35
-        $pid = (int)$_REQUEST['m_id'];
36
-    } else {
37
-        echo __('No marker data found', 'geodirectory');
38
-        exit;
39
-    }
40
-
41
-    if (isset($_REQUEST['post_preview']) && $_REQUEST['post_preview'] != '' && $gd_ses_listing = $gd_session->get('listing')) {
42
-        $post = (object)$gd_ses_listing;
43
-        echo geodir_get_infowindow_html($post, $_REQUEST['post_preview']);
44
-    } else {
45
-        $geodir_post_type = get_post_type($pid);
46
-
47
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
48
-
49
-        $sql = $wpdb->prepare("SELECT * FROM " . $table . " WHERE post_id = %d", array($pid));
50
-
51
-        $postinfo = $wpdb->get_results($sql);
52
-
53
-        $data_arr = array();
54
-
55
-        if ($postinfo) {
56
-            $srcharr = array("'", "/", "-", '"', '\\');
57
-            $replarr = array("′", "⁄", "–", "“", '');
58
-
59
-            foreach ($postinfo as $postinfo_obj) {
60
-                echo geodir_get_infowindow_html($postinfo_obj);
61
-            }
62
-        }
63
-    }
64
-    exit;
27
+	/**
28
+	 * @global object $wpdb WordPress Database object.
29
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
30
+	 * @global object $gd_session GeoDirectory Session object.
31
+	 */
32
+	global $wpdb, $plugin_prefix, $gd_session;
33
+
34
+	if ($_REQUEST['m_id'] != '') {
35
+		$pid = (int)$_REQUEST['m_id'];
36
+	} else {
37
+		echo __('No marker data found', 'geodirectory');
38
+		exit;
39
+	}
40
+
41
+	if (isset($_REQUEST['post_preview']) && $_REQUEST['post_preview'] != '' && $gd_ses_listing = $gd_session->get('listing')) {
42
+		$post = (object)$gd_ses_listing;
43
+		echo geodir_get_infowindow_html($post, $_REQUEST['post_preview']);
44
+	} else {
45
+		$geodir_post_type = get_post_type($pid);
46
+
47
+		$table = $plugin_prefix . $geodir_post_type . '_detail';
48
+
49
+		$sql = $wpdb->prepare("SELECT * FROM " . $table . " WHERE post_id = %d", array($pid));
50
+
51
+		$postinfo = $wpdb->get_results($sql);
52
+
53
+		$data_arr = array();
54
+
55
+		if ($postinfo) {
56
+			$srcharr = array("'", "/", "-", '"', '\\');
57
+			$replarr = array("′", "⁄", "–", "“", '');
58
+
59
+			foreach ($postinfo as $postinfo_obj) {
60
+				echo geodir_get_infowindow_html($postinfo_obj);
61
+			}
62
+		}
63
+	}
64
+	exit;
65 65
 }
66 66
 
67 67
 /**
@@ -79,80 +79,80 @@  discard block
 block discarded – undo
79 79
  * @return string
80 80
  */
81 81
 function get_markers() {
82
-    global $wpdb, $plugin_prefix, $geodir_cat_icons, $gd_marker_sizes;
82
+	global $wpdb, $plugin_prefix, $geodir_cat_icons, $gd_marker_sizes;
83 83
 
84
-    $search = '';
85
-    $main_query_array;
84
+	$search = '';
85
+	$main_query_array;
86 86
 
87
-    $srcharr = array("'", "/", "-", '"', '\\', ''');
88
-    $replarr = array("′", "⁄", "–", "“", '', "′");
87
+	$srcharr = array("'", "/", "-", '"', '\\', ''');
88
+	$replarr = array("′", "⁄", "–", "“", '', "′");
89 89
 
90
-    $post_type = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : 'gd_place';
90
+	$post_type = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : 'gd_place';
91 91
 
92
-    $map_cat_ids_array = array('0');
93
-    $cat_find_array = array(" FIND_IN_SET(%d, pd." . $post_type . "category)");
92
+	$map_cat_ids_array = array('0');
93
+	$cat_find_array = array(" FIND_IN_SET(%d, pd." . $post_type . "category)");
94 94
 
95 95
 
96
-    $field_default_cat = '';
97
-    if (isset($_REQUEST['cat_id']) && $_REQUEST['cat_id'] != '') {
98
-        $map_cat_arr = trim($_REQUEST['cat_id'], ',');
96
+	$field_default_cat = '';
97
+	if (isset($_REQUEST['cat_id']) && $_REQUEST['cat_id'] != '') {
98
+		$map_cat_arr = trim($_REQUEST['cat_id'], ',');
99 99
 
100
-        if (!empty($map_cat_arr)) {
101
-            $field_default_cat .= "WHEN (default_category IN (" . $map_cat_arr . ")) THEN default_category ";
100
+		if (!empty($map_cat_arr)) {
101
+			$field_default_cat .= "WHEN (default_category IN (" . $map_cat_arr . ")) THEN default_category ";
102 102
 
103
-            $map_cat_ids_array = explode(',', $map_cat_arr);
104
-            $cat_find_array = array();
105
-            foreach ($map_cat_ids_array as $cat_id) {
106
-                $field_default_cat .= "WHEN (FIND_IN_SET($cat_id, `" . $post_type . "category`) > 0) THEN $cat_id ";
107
-                $cat_find_array[] = " FIND_IN_SET(%d, pd." . $post_type . "category)";
108
-                $main_query_array[] = $cat_id;
109
-            }
103
+			$map_cat_ids_array = explode(',', $map_cat_arr);
104
+			$cat_find_array = array();
105
+			foreach ($map_cat_ids_array as $cat_id) {
106
+				$field_default_cat .= "WHEN (FIND_IN_SET($cat_id, `" . $post_type . "category`) > 0) THEN $cat_id ";
107
+				$cat_find_array[] = " FIND_IN_SET(%d, pd." . $post_type . "category)";
108
+				$main_query_array[] = $cat_id;
109
+			}
110 110
 
111
-        }
112
-    }
111
+		}
112
+	}
113 113
 
114
-    if (!empty($field_default_cat))
115
-        $field_default_cat = '';
114
+	if (!empty($field_default_cat))
115
+		$field_default_cat = '';
116 116
 
117
-    if (!empty($cat_find_array))
118
-        $search .= "AND (" . implode(' OR ', $cat_find_array) . ")";
117
+	if (!empty($cat_find_array))
118
+		$search .= "AND (" . implode(' OR ', $cat_find_array) . ")";
119 119
 
120
-    $main_query_array = $map_cat_ids_array;
120
+	$main_query_array = $map_cat_ids_array;
121 121
   
122
-    if (isset($_REQUEST['search']) && !empty($_REQUEST['search']) && $_REQUEST['search'] != __('Title', 'geodirectory')) {
123
-        $search .= " AND p.post_title LIKE %s";
124
-        $main_query_array[] = "%" . $_REQUEST['search'] . "%";
125
-    }
126
-
127
-    /**
128
-     * Filter the marker query search SQL, values are replaces with %s or %d.
129
-     *
130
-     * @since 1.5.3
131
-     *
132
-     * @param string $search The SQL query for search/where.
133
-     */
134
-    $search = apply_filters('geodir_marker_search', $search);
135
-    /**
136
-     * Filter the marker query search SQL values %s and %d, this is an array of values.
137
-     *
138
-     * @since 1.5.3
139
-     *
140
-     * @param array $main_query_array The SQL query values for search/where.
141
-     */
142
-    $main_query_array = apply_filters('geodir_marker_main_query_array', $main_query_array);
143
-
144
-    $gd_posttype = '';
145
-    if (isset($_REQUEST['gd_posttype']) && $_REQUEST['gd_posttype'] != '') {
146
-        $table = $plugin_prefix . $_REQUEST['gd_posttype'] . '_detail';
147
-        $gd_posttype = " AND p.post_type = %s";
148
-        $main_query_array[] = $_REQUEST['gd_posttype'];
149
-
150
-    } else
151
-        $table = $plugin_prefix . 'gd_place_detail';
152
-
153
-    $join = ", " . $table . " AS pd ";
154
-
155
-    /**
122
+	if (isset($_REQUEST['search']) && !empty($_REQUEST['search']) && $_REQUEST['search'] != __('Title', 'geodirectory')) {
123
+		$search .= " AND p.post_title LIKE %s";
124
+		$main_query_array[] = "%" . $_REQUEST['search'] . "%";
125
+	}
126
+
127
+	/**
128
+	 * Filter the marker query search SQL, values are replaces with %s or %d.
129
+	 *
130
+	 * @since 1.5.3
131
+	 *
132
+	 * @param string $search The SQL query for search/where.
133
+	 */
134
+	$search = apply_filters('geodir_marker_search', $search);
135
+	/**
136
+	 * Filter the marker query search SQL values %s and %d, this is an array of values.
137
+	 *
138
+	 * @since 1.5.3
139
+	 *
140
+	 * @param array $main_query_array The SQL query values for search/where.
141
+	 */
142
+	$main_query_array = apply_filters('geodir_marker_main_query_array', $main_query_array);
143
+
144
+	$gd_posttype = '';
145
+	if (isset($_REQUEST['gd_posttype']) && $_REQUEST['gd_posttype'] != '') {
146
+		$table = $plugin_prefix . $_REQUEST['gd_posttype'] . '_detail';
147
+		$gd_posttype = " AND p.post_type = %s";
148
+		$main_query_array[] = $_REQUEST['gd_posttype'];
149
+
150
+	} else
151
+		$table = $plugin_prefix . 'gd_place_detail';
152
+
153
+	$join = ", " . $table . " AS pd ";
154
+
155
+	/**
156 156
 	 * Filter the SQL JOIN clause for the markers data
157 157
 	 *
158 158
 	 * @since 1.0.0
@@ -169,16 +169,16 @@  discard block
 block discarded – undo
169 169
 	 * @param string $search Row of searched fields to use in WHERE clause.
170 170
 	 */
171 171
 	$search = apply_filters('geodir_home_map_listing_where', $search);
172
-    $search = str_replace(array("'%", "%'"), array("'%%", "%%'"), $search);
173
-    $cat_type = $post_type . 'category';
174
-    if ($post_type == 'gd_event') {
175
-        $event_select = ", pd.recurring_dates, pd.is_recurring";
176
-    } else {
177
-        $event_select = "";
178
-    }
179
-
180
-    $sql_select = 'SELECT pd.default_category, pd.' . $cat_type . ', pd.post_title, pd.post_id, pd.post_latitude, pd.post_longitude' . $event_select;
181
-    /**
172
+	$search = str_replace(array("'%", "%'"), array("'%%", "%%'"), $search);
173
+	$cat_type = $post_type . 'category';
174
+	if ($post_type == 'gd_event') {
175
+		$event_select = ", pd.recurring_dates, pd.is_recurring";
176
+	} else {
177
+		$event_select = "";
178
+	}
179
+
180
+	$sql_select = 'SELECT pd.default_category, pd.' . $cat_type . ', pd.post_title, pd.post_id, pd.post_latitude, pd.post_longitude' . $event_select;
181
+	/**
182 182
 	 * Filter the SQL SELECT clause to retrive fields data
183 183
 	 *
184 184
 	 * @since 1.0.0
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 */
198 198
 	$groupby = apply_filters('geodir_home_map_listing_groupby', $groupby);
199 199
 
200
-    $catsql = $wpdb->prepare("$select $field_default_cat FROM " . $wpdb->posts . " as p" . $join . " WHERE p.ID = pd.post_id AND p.post_status = 'publish' " . $search . $gd_posttype . $groupby , $main_query_array);
200
+	$catsql = $wpdb->prepare("$select $field_default_cat FROM " . $wpdb->posts . " as p" . $join . " WHERE p.ID = pd.post_id AND p.post_status = 'publish' " . $search . $gd_posttype . $groupby , $main_query_array);
201 201
     
202 202
 	/**
203 203
 	 * Filter the SQL query to retrive markers data
@@ -209,265 +209,265 @@  discard block
 block discarded – undo
209 209
 	 */
210 210
 	$catsql = apply_filters('geodir_home_map_listing_query', $catsql, $search);
211 211
 
212
-    $catinfo = $wpdb->get_results($catsql);
212
+	$catinfo = $wpdb->get_results($catsql);
213 213
 	
214
-    $cat_content_info = array();
215
-    $content_data = array();
216
-    $post_ids = array();
217
-
218
-    /**
219
-     * Called before marker data is processed into JSON.
220
-     *
221
-     * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers.
222
-     *
223
-     * @since 1.5.3
224
-     * @param object $catinfo The posts object containing all marker data.
225
-     * @see 'geodir_after_marker_post_process'
226
-     */
227
-    $catinfo = apply_filters('geodir_before_marker_post_process', $catinfo);
228
-
229
-    /**
230
-     * Called before marker data is processed into JSON.
231
-     *
232
-     * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers.
233
-     *
234
-     * @since 1.4.9
235
-     * @param object $catinfo The posts object containing all marker data.
236
-     * @see 'geodir_after_marker_post_process'
237
-     */
238
-    do_action('geodir_before_marker_post_process_action', $catinfo);
239
-
240
-    // Sort any posts into a ajax array
241
-    if (!empty($catinfo)) {
242
-        $geodir_cat_icons = geodir_get_term_icon();
243
-        global $geodir_date_time_format, $geodir_date_format, $geodir_time_format;
244
-
245
-        $today = strtotime(date_i18n('Y-m-d'));
246
-        $show_dates = $post_type == 'gd_event' ? (int)get_option('geodir_event_infowindow_dates_count', 1) : 0;
214
+	$cat_content_info = array();
215
+	$content_data = array();
216
+	$post_ids = array();
217
+
218
+	/**
219
+	 * Called before marker data is processed into JSON.
220
+	 *
221
+	 * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers.
222
+	 *
223
+	 * @since 1.5.3
224
+	 * @param object $catinfo The posts object containing all marker data.
225
+	 * @see 'geodir_after_marker_post_process'
226
+	 */
227
+	$catinfo = apply_filters('geodir_before_marker_post_process', $catinfo);
228
+
229
+	/**
230
+	 * Called before marker data is processed into JSON.
231
+	 *
232
+	 * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers.
233
+	 *
234
+	 * @since 1.4.9
235
+	 * @param object $catinfo The posts object containing all marker data.
236
+	 * @see 'geodir_after_marker_post_process'
237
+	 */
238
+	do_action('geodir_before_marker_post_process_action', $catinfo);
239
+
240
+	// Sort any posts into a ajax array
241
+	if (!empty($catinfo)) {
242
+		$geodir_cat_icons = geodir_get_term_icon();
243
+		global $geodir_date_time_format, $geodir_date_format, $geodir_time_format;
244
+
245
+		$today = strtotime(date_i18n('Y-m-d'));
246
+		$show_dates = $post_type == 'gd_event' ? (int)get_option('geodir_event_infowindow_dates_count', 1) : 0;
247 247
         
248
-        foreach ($catinfo as $catinfo_obj) {
249
-            $post_title = $catinfo_obj->post_title;
248
+		foreach ($catinfo as $catinfo_obj) {
249
+			$post_title = $catinfo_obj->post_title;
250 250
             
251
-            if ($post_type == 'gd_event' && !empty($catinfo_obj->recurring_dates) && $show_dates > 0) {
252
-                $event_dates = '';
253
-                $recurring_data = isset($catinfo_obj->recurring_dates) ? maybe_unserialize($catinfo_obj->recurring_dates) : array();
251
+			if ($post_type == 'gd_event' && !empty($catinfo_obj->recurring_dates) && $show_dates > 0) {
252
+				$event_dates = '';
253
+				$recurring_data = isset($catinfo_obj->recurring_dates) ? maybe_unserialize($catinfo_obj->recurring_dates) : array();
254 254
 
255
-                $post_info = geodir_get_post_info($catinfo_obj->post_id);
255
+				$post_info = geodir_get_post_info($catinfo_obj->post_id);
256 256
                 
257
-                if (!empty($catinfo_obj->is_recurring) && !empty($recurring_data) && !empty($recurring_data['is_recurring']) && geodir_event_recurring_pkg($post_info)) {
258
-                    $starttimes = '';
259
-                    $endtimes = '';
260
-                    $astarttimes = array();
261
-                    $aendtimes = array();
262
-                    if ( !isset( $recurring_data['repeat_type'] ) ) {
263
-                        $recurring_data['repeat_type'] = 'custom';
264
-                    }
265
-                    $repeat_type = isset( $recurring_data['repeat_type'] ) && in_array( $recurring_data['repeat_type'], array( 'day', 'week', 'month', 'year', 'custom' ) ) ? $recurring_data['repeat_type'] : 'year'; // day, week, month, year, custom
266
-                    $different_times = isset( $recurring_data['different_times'] ) && !empty( $recurring_data['different_times'] ) ? true : false;
257
+				if (!empty($catinfo_obj->is_recurring) && !empty($recurring_data) && !empty($recurring_data['is_recurring']) && geodir_event_recurring_pkg($post_info)) {
258
+					$starttimes = '';
259
+					$endtimes = '';
260
+					$astarttimes = array();
261
+					$aendtimes = array();
262
+					if ( !isset( $recurring_data['repeat_type'] ) ) {
263
+						$recurring_data['repeat_type'] = 'custom';
264
+					}
265
+					$repeat_type = isset( $recurring_data['repeat_type'] ) && in_array( $recurring_data['repeat_type'], array( 'day', 'week', 'month', 'year', 'custom' ) ) ? $recurring_data['repeat_type'] : 'year'; // day, week, month, year, custom
266
+					$different_times = isset( $recurring_data['different_times'] ) && !empty( $recurring_data['different_times'] ) ? true : false;
267 267
         
268
-                    $recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
268
+					$recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
269 269
                     
270
-                    if ( !empty( $recurring_dates ) ) {
271
-                        if ( empty( $recurring_data['all_day'] ) ) {
272
-                            if ( $repeat_type == 'custom' && $different_times ) {
273
-                                $astarttimes = isset( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array();
274
-                                $aendtimes = isset( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array();
275
-                            } else {
276
-                                $starttimes = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : '';
277
-                                $endtimes = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : '';
278
-                            }
279
-                        }
270
+					if ( !empty( $recurring_dates ) ) {
271
+						if ( empty( $recurring_data['all_day'] ) ) {
272
+							if ( $repeat_type == 'custom' && $different_times ) {
273
+								$astarttimes = isset( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array();
274
+								$aendtimes = isset( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array();
275
+							} else {
276
+								$starttimes = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : '';
277
+								$endtimes = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : '';
278
+							}
279
+						}
280 280
                         
281
-                        $e = 0;
282
-                        foreach( $recurring_dates as $key => $date ) {
283
-                            if ( $repeat_type == 'custom' && $different_times ) {
284
-                                if ( !empty( $astarttimes ) && isset( $astarttimes[$key] ) ) {
285
-                                    $starttimes = $astarttimes[$key];
286
-                                    $endtimes = $aendtimes[$key];
287
-                                } else {
288
-                                    $starttimes = '';
289
-                                    $endtimes = '';
290
-                                }
291
-                            }
281
+						$e = 0;
282
+						foreach( $recurring_dates as $key => $date ) {
283
+							if ( $repeat_type == 'custom' && $different_times ) {
284
+								if ( !empty( $astarttimes ) && isset( $astarttimes[$key] ) ) {
285
+									$starttimes = $astarttimes[$key];
286
+									$endtimes = $aendtimes[$key];
287
+								} else {
288
+									$starttimes = '';
289
+									$endtimes = '';
290
+								}
291
+							}
292 292
                             
293
-                            $duration = isset( $recurring_data['duration_x'] ) && (int)$recurring_data['duration_x'] > 0 ? (int)$recurring_data['duration_x'] : 1;
294
-                            $duration--;
295
-                            $enddate = date_i18n( 'Y-m-d', strtotime( $date . ' + ' . $duration . ' day' ) );
293
+							$duration = isset( $recurring_data['duration_x'] ) && (int)$recurring_data['duration_x'] > 0 ? (int)$recurring_data['duration_x'] : 1;
294
+							$duration--;
295
+							$enddate = date_i18n( 'Y-m-d', strtotime( $date . ' + ' . $duration . ' day' ) );
296 296
                             
297
-                            // Hide past dates
298
-                            if ( strtotime( $enddate ) < $today ) {
299
-                                continue;
300
-                            }
297
+							// Hide past dates
298
+							if ( strtotime( $enddate ) < $today ) {
299
+								continue;
300
+							}
301 301
                                     
302
-                            $sdate = strtotime( $date . ' ' . $starttimes );
303
-                            $edate = strtotime( $enddate . ' ' . $endtimes );
302
+							$sdate = strtotime( $date . ' ' . $starttimes );
303
+							$edate = strtotime( $enddate . ' ' . $endtimes );
304 304
                                         
305
-                            $start_date = date_i18n( $geodir_date_time_format, $sdate );
306
-                            $end_date = date_i18n( $geodir_date_time_format, $edate );
305
+							$start_date = date_i18n( $geodir_date_time_format, $sdate );
306
+							$end_date = date_i18n( $geodir_date_time_format, $edate );
307 307
                             
308
-                            $same_day = false;
309
-                            $full_day = false;
310
-                            $same_datetime = false;
308
+							$same_day = false;
309
+							$full_day = false;
310
+							$same_datetime = false;
311 311
                             
312
-                            if ( $starttimes == $endtimes && ( $starttimes == '' || $starttimes == '00:00:00' || $starttimes == '00:00' ) ) {
313
-                                $full_day = true;
314
-                            }
312
+							if ( $starttimes == $endtimes && ( $starttimes == '' || $starttimes == '00:00:00' || $starttimes == '00:00' ) ) {
313
+								$full_day = true;
314
+							}
315 315
                             
316
-                            if ( $start_date == $end_date && $full_day ) {
317
-                                $same_datetime = true;
318
-                            }
319
-
320
-                            $link_date = date_i18n( 'Y-m-d', $sdate );
321
-                            $title_date = date_i18n( $geodir_date_format, $sdate );
322
-                            if ( $full_day ) {
323
-                                $start_date = $title_date;
324
-                                $end_date = date_i18n( $geodir_date_format, $edate );
325
-                            }
316
+							if ( $start_date == $end_date && $full_day ) {
317
+								$same_datetime = true;
318
+							}
319
+
320
+							$link_date = date_i18n( 'Y-m-d', $sdate );
321
+							$title_date = date_i18n( $geodir_date_format, $sdate );
322
+							if ( $full_day ) {
323
+								$start_date = $title_date;
324
+								$end_date = date_i18n( $geodir_date_format, $edate );
325
+							}
326 326
                             
327
-                            if ( !$same_datetime && !$full_day && date_i18n( 'Y-m-d', $sdate ) == date_i18n( 'Y-m-d', $edate ) ) {
328
-                                $same_day = true;
327
+							if ( !$same_datetime && !$full_day && date_i18n( 'Y-m-d', $sdate ) == date_i18n( 'Y-m-d', $edate ) ) {
328
+								$same_day = true;
329 329
                                 
330
-                                $start_date .= ' - ' . date_i18n( $geodir_time_format, $edate );
331
-                            }
330
+								$start_date .= ' - ' . date_i18n( $geodir_time_format, $edate );
331
+							}
332 332
                             
333
-                            $event_dates .= ' :: ' . $start_date;
333
+							$event_dates .= ' :: ' . $start_date;
334 334
                         
335
-                            if ( !$same_day && !$same_datetime ) {
336
-                                $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date;
337
-                            }
335
+							if ( !$same_day && !$same_datetime ) {
336
+								$event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date;
337
+							}
338 338
                             
339
-                            $e++;
339
+							$e++;
340 340
                             
341
-                            if ($show_dates > 0 && $e == $show_dates) { // only show 3 event dates
342
-                                break;
343
-                            }
344
-                        }
345
-                    }
346
-                } else {
347
-                    $start_date = isset( $recurring_data['event_start'] ) ? $recurring_data['event_start'] : '';
348
-                    $end_date = isset( $recurring_data['event_end'] ) ? $recurring_data['event_end'] : $start_date;
349
-                    $all_day = isset( $recurring_data['all_day'] ) && !empty( $recurring_data['all_day'] ) ? true : false;
350
-                    $starttime = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : '';
351
-                    $endtime = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : '';
341
+							if ($show_dates > 0 && $e == $show_dates) { // only show 3 event dates
342
+								break;
343
+							}
344
+						}
345
+					}
346
+				} else {
347
+					$start_date = isset( $recurring_data['event_start'] ) ? $recurring_data['event_start'] : '';
348
+					$end_date = isset( $recurring_data['event_end'] ) ? $recurring_data['event_end'] : $start_date;
349
+					$all_day = isset( $recurring_data['all_day'] ) && !empty( $recurring_data['all_day'] ) ? true : false;
350
+					$starttime = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : '';
351
+					$endtime = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : '';
352 352
                 
353
-                    $event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] );
354
-                    $starttimes = isset( $recurring_data['starttimes'] ) && !empty( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array();
355
-                    $endtimes = isset( $recurring_data['endtimes'] ) && !empty( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array();
353
+					$event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] );
354
+					$starttimes = isset( $recurring_data['starttimes'] ) && !empty( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array();
355
+					$endtimes = isset( $recurring_data['endtimes'] ) && !empty( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array();
356 356
                     
357
-                    if ( !geodir_event_is_date( $start_date ) && !empty( $event_recurring_dates ) ) {
358
-                        $start_date = $event_recurring_dates[0];
359
-                    }
357
+					if ( !geodir_event_is_date( $start_date ) && !empty( $event_recurring_dates ) ) {
358
+						$start_date = $event_recurring_dates[0];
359
+					}
360 360
                                 
361
-                    if ( strtotime( $end_date ) < strtotime( $start_date ) ) {
362
-                        $end_date = $start_date;
363
-                    }
361
+					if ( strtotime( $end_date ) < strtotime( $start_date ) ) {
362
+						$end_date = $start_date;
363
+					}
364 364
                     
365
-                    if ($end_date != '' && strtotime($end_date) >= $today) {
366
-                        if ( $starttime == '' && !empty( $starttimes ) ) {
367
-                            $starttime = $starttimes[0];
368
-                            $endtime = $endtimes[0];
369
-                        }
365
+					if ($end_date != '' && strtotime($end_date) >= $today) {
366
+						if ( $starttime == '' && !empty( $starttimes ) ) {
367
+							$starttime = $starttimes[0];
368
+							$endtime = $endtimes[0];
369
+						}
370 370
                         
371
-                        $same_day = false;
372
-                        $one_day = false;
373
-                        if ( $start_date == $end_date && $all_day ) {
374
-                            $one_day = true;
375
-                        }
376
-
377
-                        if ( $all_day ) {
378
-                            $start_datetime = strtotime( $start_date );
379
-                            $end_datetime = strtotime( $end_date );
371
+						$same_day = false;
372
+						$one_day = false;
373
+						if ( $start_date == $end_date && $all_day ) {
374
+							$one_day = true;
375
+						}
376
+
377
+						if ( $all_day ) {
378
+							$start_datetime = strtotime( $start_date );
379
+							$end_datetime = strtotime( $end_date );
380 380
                             
381
-                            $start_date = date_i18n( $geodir_date_format, $start_datetime );
382
-                            $end_date = date_i18n( $geodir_date_format, $end_datetime );
383
-                            if ( $start_date == $end_date ) {
384
-                                $one_day = true;
385
-                            }
386
-                        } else {
387
-                            if ( $start_date == $end_date && $starttime == $endtime ) {
388
-                                $end_date = date_i18n( 'Y-m-d', strtotime( $start_date . ' ' . $starttime . ' +1 day' ) );
389
-                                $one_day = false;
390
-                            }
391
-                            $start_datetime = strtotime( $start_date . ' ' . $starttime );
392
-                            $end_datetime = strtotime( $end_date . ' ' . $endtime );
381
+							$start_date = date_i18n( $geodir_date_format, $start_datetime );
382
+							$end_date = date_i18n( $geodir_date_format, $end_datetime );
383
+							if ( $start_date == $end_date ) {
384
+								$one_day = true;
385
+							}
386
+						} else {
387
+							if ( $start_date == $end_date && $starttime == $endtime ) {
388
+								$end_date = date_i18n( 'Y-m-d', strtotime( $start_date . ' ' . $starttime . ' +1 day' ) );
389
+								$one_day = false;
390
+							}
391
+							$start_datetime = strtotime( $start_date . ' ' . $starttime );
392
+							$end_datetime = strtotime( $end_date . ' ' . $endtime );
393 393
                             
394
-                            $start_date = date_i18n( $geodir_date_time_format, $start_datetime );
395
-                            $end_date = date_i18n( $geodir_date_time_format, $end_datetime );
396
-                        }
394
+							$start_date = date_i18n( $geodir_date_time_format, $start_datetime );
395
+							$end_date = date_i18n( $geodir_date_time_format, $end_datetime );
396
+						}
397 397
 
398
-                        if ( !$one_day && date_i18n( 'Y-m-d', $start_datetime ) == date_i18n( 'Y-m-d', $end_datetime ) ) {
399
-                            $same_day = true;
398
+						if ( !$one_day && date_i18n( 'Y-m-d', $start_datetime ) == date_i18n( 'Y-m-d', $end_datetime ) ) {
399
+							$same_day = true;
400 400
                             
401
-                            $start_date .= ' - ' . date_i18n( $geodir_time_format, $end_datetime );
402
-                        }
401
+							$start_date .= ' - ' . date_i18n( $geodir_time_format, $end_datetime );
402
+						}
403 403
                         
404
-                        $event_dates .= ' :: ' . $start_date;
404
+						$event_dates .= ' :: ' . $start_date;
405 405
                         
406
-                        if ( !$same_day && !$one_day ) {
407
-                            $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date;
408
-                        }
409
-                    }
410
-                }
411
-
412
-                if (empty($event_dates)) {
413
-                    continue;
414
-                }
406
+						if ( !$same_day && !$one_day ) {
407
+							$event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date;
408
+						}
409
+					}
410
+				}
411
+
412
+				if (empty($event_dates)) {
413
+					continue;
414
+				}
415 415
                 
416
-                $post_title .= $event_dates;
417
-            }
416
+				$post_title .= $event_dates;
417
+			}
418 418
 
419
-            $map_cat_ids_array;
420
-            $default_cat = isset($catinfo_obj->default_category) ? $catinfo_obj->default_category : '';
419
+			$map_cat_ids_array;
420
+			$default_cat = isset($catinfo_obj->default_category) ? $catinfo_obj->default_category : '';
421 421
 
422
-            // if single cat lets just show that icon
423
-            if(is_array($map_cat_ids_array) && count($map_cat_ids_array)==1){
424
-                $default_cat = (int)$map_cat_ids_array[0];
425
-            }
422
+			// if single cat lets just show that icon
423
+			if(is_array($map_cat_ids_array) && count($map_cat_ids_array)==1){
424
+				$default_cat = (int)$map_cat_ids_array[0];
425
+			}
426 426
 
427
-            $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$default_cat]) ? $geodir_cat_icons[$default_cat] : '';
428
-            $mark_extra = (isset($catinfo_obj->marker_extra)) ? $catinfo_obj->marker_extra : '';
429
-            $title = str_replace($srcharr, $replarr, $post_title);
427
+			$icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$default_cat]) ? $geodir_cat_icons[$default_cat] : '';
428
+			$mark_extra = (isset($catinfo_obj->marker_extra)) ? $catinfo_obj->marker_extra : '';
429
+			$title = str_replace($srcharr, $replarr, $post_title);
430 430
             
431
-            if ($icon != '') {
432
-                $gd_marker_sizes = empty($gd_marker_sizes) ? array() : $gd_marker_sizes;
431
+			if ($icon != '') {
432
+				$gd_marker_sizes = empty($gd_marker_sizes) ? array() : $gd_marker_sizes;
433 433
                 
434
-                if (isset($gd_marker_sizes[$icon])) {
435
-                    $icon_size = $gd_marker_sizes[$icon];
436
-                } else {
437
-                    $icon_size = geodir_get_marker_size($icon);
438
-                    $gd_marker_sizes[$icon] = $icon_size;
439
-                }               
440
-            } else {
441
-                $icon_size = array('w' => 36, 'h' => 45);
442
-            }
443
-
444
-            $content_data[] = '{"id":"' . $catinfo_obj->post_id . '","t": "' . $title . '","lt": "' . $catinfo_obj->post_latitude . '","ln": "' . $catinfo_obj->post_longitude . '","mk_id":"' . $catinfo_obj->post_id . '_' . $default_cat . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"'.$mark_extra.'}';
445
-            $post_ids[] = $catinfo_obj->post_id;
446
-        }
447
-    }
448
-
449
-    /**
450
-     * Called after marker data is processed into JSON.
451
-     *
452
-     * Called after marker data is processed into JSON, this action can be used to change the format or add/remove markers.
453
-     *
454
-     * @since 1.4.9
455
-     * @param array $content_data The array containing all markers in JSON format.
456
-     * @param object $catinfo The posts object containing all marker data.
457
-     * @see 'geodir_before_marker_post_process'
458
-     */
459
-    do_action('geodir_after_marker_post_process', $content_data, $catinfo);
460
-
461
-    if (!empty($content_data)) {
462
-        $cat_content_info[] = implode(',', $content_data);
463
-    }
464
-
465
-    $totalcount = count(array_unique($post_ids));
466
-
467
-    if (!empty($cat_content_info)) {
468
-        return '[{"totalcount":"' . $totalcount . '",' . substr(implode(',', $cat_content_info), 1) . ']';
469
-    }
470
-    else {
471
-        return '[{"totalcount":"0"}]';
472
-    }
434
+				if (isset($gd_marker_sizes[$icon])) {
435
+					$icon_size = $gd_marker_sizes[$icon];
436
+				} else {
437
+					$icon_size = geodir_get_marker_size($icon);
438
+					$gd_marker_sizes[$icon] = $icon_size;
439
+				}               
440
+			} else {
441
+				$icon_size = array('w' => 36, 'h' => 45);
442
+			}
443
+
444
+			$content_data[] = '{"id":"' . $catinfo_obj->post_id . '","t": "' . $title . '","lt": "' . $catinfo_obj->post_latitude . '","ln": "' . $catinfo_obj->post_longitude . '","mk_id":"' . $catinfo_obj->post_id . '_' . $default_cat . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"'.$mark_extra.'}';
445
+			$post_ids[] = $catinfo_obj->post_id;
446
+		}
447
+	}
448
+
449
+	/**
450
+	 * Called after marker data is processed into JSON.
451
+	 *
452
+	 * Called after marker data is processed into JSON, this action can be used to change the format or add/remove markers.
453
+	 *
454
+	 * @since 1.4.9
455
+	 * @param array $content_data The array containing all markers in JSON format.
456
+	 * @param object $catinfo The posts object containing all marker data.
457
+	 * @see 'geodir_before_marker_post_process'
458
+	 */
459
+	do_action('geodir_after_marker_post_process', $content_data, $catinfo);
460
+
461
+	if (!empty($content_data)) {
462
+		$cat_content_info[] = implode(',', $content_data);
463
+	}
464
+
465
+	$totalcount = count(array_unique($post_ids));
466
+
467
+	if (!empty($cat_content_info)) {
468
+		return '[{"totalcount":"' . $totalcount . '",' . substr(implode(',', $cat_content_info), 1) . ']';
469
+	}
470
+	else {
471
+		return '[{"totalcount":"0"}]';
472
+	}
473 473
 }
474 474
\ No newline at end of file
Please login to merge, or discard this patch.