BMLT Root Server
Functions
common_search.inc.php File Reference

This file contains a routine that allows a search to be established with an existing c_comdef_search_manager object. More...

Go to the source code of this file.

Functions

 SetUpSearch (&$in_search_manager, &$in_http_vars)
 This function sets up the search manager to do the specified search. It does not actually do the search. More...
 
 GetAllContainedServiceBodyIDs ($in_parent_id=0)
 This gets all the Service bodies, and returns a one-dimensional arry, containing its ID, and the IDs of all the Service bodies that are contained in the array. More...
 
 BuildFormats ($in_mtg_obj, $lite=false)
 This displays the format keys, along with abbreviations to display when the cursor is over them. More...
 
 BuildTown ($in_mtg_obj)
 Combines the town, borough and neighborhood into one string. More...
 
 BuildTime ($in_time, $in_integer=false)
 This creates a time string to be displayed for the meeting. The display is done in non-military time, and "midnight" and "noon" are substituted for 12:59:00, 00:00:00 and 12:00:00. More...
 
 BuildLocation ($in_mtg_obj)
 This combines the location and street address fields. More...
 
 GetGeocodeFromString ($in_string, $in_weekday_tinyint_array)
 This function uses the server-level Google Maps API to try to geocode an address from the string passed in. A instance of c_comdef_server needs to have been instantiated by the time this is called. More...
 

Detailed Description

This file contains a routine that allows a search to be established with an existing c_comdef_search_manager object.

This file is part of the Basic Meeting List Toolbox (BMLT).

Find out more at: https://bmlt.app

BMLT is free software: you can redistribute it and/or modify it under the terms of the MIT License.

BMLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MIT License for more details.

You should have received a copy of the MIT License along with this code. If not, see https://opensource.org/licenses/MIT.

Definition in file common_search.inc.php.

Function Documentation

BuildFormats (   $in_mtg_obj,
  $lite = false 
)

This displays the format keys, along with abbreviations to display when the cursor is over them.

Returns
a string, containing the HTML rendered by the function, or, if the $lite parameter is set to true, an associative, multidimensional array, containing the information.
Parameters
$in_mtg_objA reference to an instance of c_comdef_meeting.
$liteIf this is set to true, then the formats will be returned in an associative array, instead of as HTML. Default is false.

Definition at line 574 of file common_search.inc.php.

References c_comdef_htmlspecialchars().

577  {
578  $formats = "";
579 
580  $formats_obj = $in_mtg_obj->GetMeetingDataValue('formats');
581 
582  if (is_array($formats_obj) && count($formats_obj)) {
583  foreach ($formats_obj as $format) {
584  if ($format instanceof c_comdef_format) {
585  $key = htmlspecialchars($format->GetKey());
586  $name = c_comdef_htmlspecialchars($format->GetLocalName());
587  $desc = c_comdef_htmlspecialchars($format->GetLocalDescription());
588  if ($lite) {
589  $formats[$key]['name'] = $name;
590  $formats[$key]['desc'] = $desc;
591  } else {
592  $formatspacer = '';
593  if ($formats) {
594  $formatspacer = ' ';
595  }
596 
597  $formats .= "<span class=\"c_comdef_search_results_single_format\"><abbr title=\"$desc\">$formatspacer$key</abbr></span>";
598  }
599  }
600  }
601  }
602 
603  return $formats;
604 }
A Class for Format Codes.
c_comdef_htmlspecialchars($in_string)
This function creates a displayable string.
BuildLocation (   $in_mtg_obj)

This combines the location and street address fields.

Returns
a string, containing the HTML rendered by the function.
Parameters
$in_mtg_objA reference to an instance of c_comdef_meeting.

Definition at line 669 of file common_search.inc.php.

References $ret, and c_comdef_htmlspecialchars().

671 {
672  $ret = "";
673 
674  if ($in_mtg_obj instanceof c_comdef_meeting) {
675  $location_text = c_comdef_htmlspecialchars(trim(stripslashes($in_mtg_obj->GetMeetingDataValue('location_text'))));
676  $street = c_comdef_htmlspecialchars(trim(stripslashes($in_mtg_obj->GetMeetingDataValue('location_street'))));
677  $info = c_comdef_htmlspecialchars(trim(stripslashes($in_mtg_obj->GetMeetingDataValue('location_info'))));
678 
679  if ($location_text) {
680  $ret .= $location_text;
681  }
682 
683  if ($street) {
684  if ($ret) {
685  $ret .= ", ";
686  }
687  $ret .= $street;
688  }
689 
690  if ($info) {
691  if ($ret) {
692  $ret .= " ";
693  }
694  $ret .= "($info)";
695  }
696  }
697 
698  return $ret;
699 }
A class to hold a single meeting object.
$ret
Definition: contact.php:226
c_comdef_htmlspecialchars($in_string)
This function creates a displayable string.
BuildTime (   $in_time,
  $in_integer = false 
)

This creates a time string to be displayed for the meeting. The display is done in non-military time, and "midnight" and "noon" are substituted for 12:59:00, 00:00:00 and 12:00:00.

Returns
a string, containing the HTML rendered by the function.
Parameters
$in_timeA string. The value of the time field.
$in_integerIf true, the time is returned as an integer (Military time).

Definition at line 641 of file common_search.inc.php.

References c_comdef_htmlspecialchars(), and c_comdef_server\GetLocalStrings().

644  {
645  $localized_strings = c_comdef_server::GetLocalStrings();
646 
647  $time = null;
648 
649  if ($in_integer) {
650  $time = intval(str_replace(':', '', $in_time)) / 100;
651  } else {
652  if (($in_time == "00:00:00") || ($in_time == "23:59:00")) {
653  $time = c_comdef_htmlspecialchars($localized_strings['comdef_server_admin_strings']['meeting_editor_screen_meeting_noon_label']);
654  } elseif ($in_time == "12:00:00") {
655  $time = c_comdef_htmlspecialchars($localized_strings['comdef_server_admin_strings']['meeting_editor_screen_meeting_midnight_label']);
656  } else {
657  $time = c_comdef_htmlspecialchars(date($localized_strings['time_format'], strtotime($in_time)));
658  }
659  }
660 
661  return $time;
662 }
static GetLocalStrings($in_lang_enum=null)
This gets the appropriate language files, and puts all the the strings into an associative array...
c_comdef_htmlspecialchars($in_string)
This function creates a displayable string.
BuildTown (   $in_mtg_obj)

Combines the town, borough and neighborhood into one string.

Returns
a string, containing the HTML rendered by the function.
Parameters
$in_mtg_objA reference to an instance of c_comdef_meeting.

Definition at line 611 of file common_search.inc.php.

References c_comdef_htmlspecialchars().

613 {
614  $location_borough = c_comdef_htmlspecialchars(trim(stripslashes($in_mtg_obj->GetMeetingDataValue('location_city_subsection'))));
615  $location_town = c_comdef_htmlspecialchars(trim(stripslashes($in_mtg_obj->GetMeetingDataValue('location_municipality'))));
616  $location_neighborhood = c_comdef_htmlspecialchars(trim(stripslashes($in_mtg_obj->GetMeetingDataValue('location_neighborhood'))));
617  $location_province = c_comdef_htmlspecialchars(trim(stripslashes($in_mtg_obj->GetMeetingDataValue('location_province'))));
618 
619  if ($location_province) {
620  $location_town .= ', '.$location_province;
621  }
622 
623  if ($location_borough) {
624  $location_town = "<span class=\"c_comdef_search_results_town\">$location_borough</span>, <span class=\"c_comdef_search_results_town\">$location_town</span>";
625  }
626 
627  if ($location_neighborhood) {
628  $location_town = "$location_town <span class=\"c_comdef_search_results_neighborhood\">($location_neighborhood)</span>";
629  }
630 
631  return $location_town;
632 }
c_comdef_htmlspecialchars($in_string)
This function creates a displayable string.
GetAllContainedServiceBodyIDs (   $in_parent_id = 0)

This gets all the Service bodies, and returns a one-dimensional arry, containing its ID, and the IDs of all the Service bodies that are contained in the array.

Returns
an array of integers.
Parameters
$in_parent_idThis is the ID of the top Service body (will not be included in the reponse).

Definition at line 545 of file common_search.inc.php.

References $ret, and c_comdef_server\GetServer().

Referenced by SetUpSearch().

547 {
548  $in_parent_id = intval($in_parent_id);
549  $ret = array( $in_parent_id );
550 
551  $service_bodies = c_comdef_server::GetServer()->GetServiceBodyArray();
552 
553  foreach ($service_bodies as $service_body) {
554  $sb_id = intval($service_body->GetID());
555  $parent_id = intval($service_body->GetOwnerID());
556 
557  if ($in_parent_id == $parent_id) {
558  $ret2 = GetAllContainedServiceBodyIDs($sb_id);
559  $ret = array_merge($ret, $ret2);
560  }
561  }
562 
563  return $ret;
564 }
$ret
Definition: contact.php:226
GetAllContainedServiceBodyIDs($in_parent_id=0)
This gets all the Service bodies, and returns a one-dimensional arry, containing its ID...
GetGeocodeFromString (   $in_string,
  $in_weekday_tinyint_array 
)

This function uses the server-level Google Maps API to try to geocode an address from the string passed in. A instance of c_comdef_server needs to have been instantiated by the time this is called.

Returns
an associative array of two floating-point numbers, representing the longitude and latitude, in degrees, of any geocoded result. Null, if no valid result was returned.
Parameters
$in_stringThe string to be checked.
$in_weekday_tinyint_arrayAn array of weekdays in which to filter for.

Definition at line 712 of file common_search.inc.php.

References $ret, c_comdef_server\GetLocalStrings(), and c_comdef_server\HuntForRadius().

Referenced by SetUpSearch().

715  {
716  $ret = null;
717  $localized_strings = c_comdef_server::GetLocalStrings();
718 
719  $geo_uri = $localized_strings['comdef_server_admin_strings']['ServerMapsURL'];
720 
721  if ($localized_strings['region_bias']) {
722  $geo_uri .= '&region='.$localized_strings['region_bias'];
723  }
724 
725  if ($localized_strings['google_api_key']) {
726  $geo_uri .= '&key='.$localized_strings['google_api_key'];
727  }
728 
729  // Bit of a kludge. If the string is just a number (a postcode), then we add the region bias directly to it.
730  if (is_numeric($in_string) && $localized_strings['region_bias']) {
731  $in_string .= " ".$localized_strings['region_bias'];
732  }
733 
734  $geo_uri = str_replace('##SEARCH_STRING##', urlencode($in_string), $geo_uri);
735 
736  // We set up a 200-mile bounds, in order to encourage Google to look in the proper place.
737  $m_p_deg = 100 / (111.321 * cos(deg2rad($localized_strings['search_spec_map_center']['latitude'])) * 1.609344); // Degrees for 100 miles.
738  $bounds_ar = strval($localized_strings['search_spec_map_center']['latitude'] - $m_p_deg).",". strval($localized_strings['search_spec_map_center']['longitude'] - $m_p_deg); // Southwest corner
739  $bounds_ar .= "|";
740  $bounds_ar .= strval($localized_strings['search_spec_map_center']['latitude'] + $m_p_deg).",".strval($localized_strings['search_spec_map_center']['longitude'] + $m_p_deg); // Northeast corner
741 
742  $xml = simplexml_load_file($geo_uri);
743 
744  if ($xml->status == 'OK') {
745  $ret['longitude'] = floatval($xml->result->geometry->location->lng);
746  $ret['latitude'] = floatval($xml->result->geometry->location->lat);
747  $radius = c_comdef_server::HuntForRadius($localized_strings['number_of_meetings_for_auto'], $ret['longitude'], $ret['latitude'], $in_weekday_tinyint_array);
748  if ($radius) {
749  // The native units for the radius search is km. We need to convert to miles, if we are in miles.
750  if ($localized_strings['dist_units'] == 'mi') {
751  $radius /= 1.609344;
752  }
753 
754  $ret['radius'] = $radius;
755  } else {
756  $ret = null;
757  }
758  }
759 
760  return $ret;
761 }
static GetLocalStrings($in_lang_enum=null)
This gets the appropriate language files, and puts all the the strings into an associative array...
$ret
Definition: contact.php:226
static HuntForRadius($in_search_result_count, $in_long_in_degrees, $in_lat_in_degrees, $in_weekday_tinyint_array, $in_service_bodies_array=null)
Find the smallest radius that contains at least the given number of meetings. The way this works is t...
SetUpSearch ( $in_search_manager,
$in_http_vars 
)

This function sets up the search manager to do the specified search. It does not actually do the search.

Parameters
$in_search_managerA reference to an instance of c_comdef_search_manager. The search manager to set up.

Definition at line 30 of file common_search.inc.php.

References $local_strings, GetAllContainedServiceBodyIDs(), c_comdef_meeting\GetDataTableTemplate(), GetGeocodeFromString(), and c_comdef_server\GetLocalStrings().

Referenced by DisplaySearchResultsCSV().

204  {
205  $search_string = isset($in_http_vars['SearchString']) ? trim($in_http_vars['SearchString']) : '';
206 
207  if ($search_string && !(isset($in_http_vars['StringSearchIsAnAddress']) && $in_http_vars['StringSearchIsAnAddress']) && intval($search_string) && (preg_match('|\d+|', $search_string) || preg_match('(|\d+|,)+', $search_string))) {
208  $temp_ids = explode(',', $search_string);
209 
210  if (is_array($temp_ids) && count($temp_ids)) {
211  $first = true;
212 
213  foreach ($temp_ids as $id) {
214  $id = intval(trim($id));
215 
216  if ($id) {
217  if ($first) {
218  $in_http_vars['meeting_ids'] = null;
219  $first = false;
220  }
221 
222  $in_http_vars['meeting_ids'][] = $id;
223  }
224  }
225  } else {
226  $id = intval($search_string);
227 
228  if ($id) {
229  $in_http_vars['meeting_ids'] = array ( intval($id) );
230  }
231  }
232  }
233 
234  // If we have a meeting ID array, then that defines the entire search. We ignore everything else
235  if (isset($in_http_vars['meeting_ids']) && is_array($in_http_vars['meeting_ids']) && count($in_http_vars['meeting_ids'])) {
236  $in_search_manager->SetMeetingIDArray($in_http_vars['meeting_ids']);
237  } else {
238  if (isset($in_http_vars['sort_results_by_distance'])) {
239  $in_search_manager->SetSortByDistance($in_http_vars['sort_results_by_distance']);
240  } elseif (isset($in_http_vars['sort_keys']) && $in_http_vars['sort_keys']) {
241  $sort_fields = array();
242  $keys = explode(',', $in_http_vars['sort_keys']);
243  $dir = 'asc';
244  foreach ($keys as $key) {
245  if (strtolower(trim($key)) == 'desc') {
246  $dir = 'desc';
247  } else {
249  if ($templates && count($templates)) {
250  $additional = array ();
251 
252  foreach ($templates as $template) {
253  $value = $template['key'];
254  array_push($additional, $value);
255  }
256 
257  $standards = array ( 'weekday_tinyint', 'id_bigint', 'worldid_mixed', 'service_body_bigint', 'lang_enum', 'duration_time', 'start_time', 'longitude', 'latitude' );
258  $templates = array_merge($standards, $additional);
259 
260  if (in_array($key, $templates)) {
261  array_push($sort_fields, $key);
262  }
263  }
264  }
265  }
266 
267  $in_search_manager->SetSort($sort_fields, $dir == 'desc', count($sort_fields));
268  }
269 
270  // The first thing we do is try to resolve any address lookups.
271  if ($search_string && isset($in_http_vars['StringSearchIsAnAddress']) && $in_http_vars['StringSearchIsAnAddress']) {
272  $geo_search = (isset($in_http_vars['geo_width']) && $in_http_vars['geo_width']) ? true : ((isset($in_http_vars['geo_width_km']) && $in_http_vars['geo_width_km']) ? true : false);
273 
274  // We do a geocode to find out if this is an address.
275  if (!$geo_search) {
276  $search_string = preg_replace('|,(\s*?)|', ', ', $search_string); // This works around a bug caused by too-tight commas.
277  $geo = GetGeocodeFromString($search_string, $in_http_vars['advanced_weekdays']);
278  if (is_array($geo) && count($geo)) {
279  $localized_strings = c_comdef_server::GetLocalStrings();
280 
281  $in_http_vars['long_val'] = $geo['longitude'];
282  $in_http_vars['lat_val'] = $geo['latitude'];
283 
284  if (isset($in_http_vars['SearchStringRadius']) && floatval($in_http_vars['SearchStringRadius']) != 0.0) {
285  if (intval($in_http_vars['SearchStringRadius']) < 0) {
286  $geo['radius'] = intval($in_http_vars['SearchStringRadius']);
287  } else {
288  $geo['radius'] = floatval($in_http_vars['SearchStringRadius']);
289  }
290  }
291 
292  if ($localized_strings['dist_units'] == 'mi') {
293  if (isset($in_http_vars['geo_width_km'])) {
294  unset($in_http_vars['geo_width_km']);
295  }
296  $in_http_vars['geo_width'] = $geo['radius'];
297  } else {
298  unset($in_http_vars['geo_width']);
299  $in_http_vars['geo_width_km'] = $geo['radius'];
300  }
301 
302  /* We need to undef these, because they can step on the long/lat. */
303  unset($search_string);
304  unset($in_http_vars['StringSearchIsAnAddress']);
305  unset($in_http_vars['SearchStringRadius']);
306  }
307  }
308  }
309 
310  // First, set up the services.
311  if (isset($in_http_vars['bmlt_search_type']) && ($in_http_vars['bmlt_search_type'] == 'advanced') && isset($in_http_vars['advanced_service_bodies']) && is_array($in_http_vars['advanced_service_bodies']) && count($in_http_vars['advanced_service_bodies'])) {
312  $in_http_vars['services'] = $in_http_vars['advanced_service_bodies'];
313  }
314 
315  if (isset($in_http_vars['services']) && !is_array($in_http_vars['services'])) {
316  $in_http_vars['services'] = array ( $in_http_vars['services'] );
317  }
318 
319  // Look for Service bodies.
320  if (isset($in_http_vars['services']) && is_array($in_http_vars['services']) && count($in_http_vars['services'])) {
321  $services = array();
322 
323  if (isset($in_http_vars['recursive']) && $in_http_vars['recursive']) {
324  foreach ($in_http_vars['services'] as $service) {
325  $nested = GetAllContainedServiceBodyIDs(intval($service));
326 
327  if (isset($nested) && is_array($nested) && count($nested)) {
328  foreach ($nested as $sb_i) {
329  $sb_i = intval($sb_i);
330  $services[$sb_i] = $sb_i;
331  }
332  }
333  }
334  } else {
335  $services = $in_http_vars['services'];
336  }
337 
338  $sb =& $in_search_manager->GetServiceBodies();
339 
340  foreach ($services as $service) {
341  $sb[intval($service)] = 1;
342  }
343  } else {
344  unset($in_http_vars['services']);
345  }
346 
347 
348  if (!( isset($in_http_vars['geo_width_km']) && $in_http_vars['geo_width_km'] )
349  && !( isset($in_http_vars['geo_width']) && $in_http_vars['geo_width'] )
350  && isset($in_http_vars['bmlt_search_type'])
351  && ($in_http_vars['bmlt_search_type'] == 'advanced')
352  && isset($in_http_vars['advanced_radius'])
353  && isset($in_http_vars['advanced_mapmode'])
354  && $in_http_vars['advanced_mapmode']
355  && ( floatval($in_http_vars['advanced_radius'] != 0.0) )
356  && isset($in_http_vars['lat_val'])
357  && isset($in_http_vars['long_val'])
358  && ( (floatval($in_http_vars['lat_val']) != 0.0) || (floatval($in_http_vars['long_val']) != 0.0) )
359  ) {
360  if ($localized_strings['dist_units'] == 'mi') {
361  $in_http_vars['geo_width'] = $in_http_vars['advanced_radius'];
362  unset($in_http_vars['geo_width_km']);
363  } else {
364  $in_http_vars['geo_width_km'] = $in_http_vars['advanced_radius'];
365  unset($in_http_vars['geo_width']);
366  }
367  }
368 
369  // If we aren't doing any geographic searches, then we won't have a search center.
370  if (!( isset($in_http_vars['geo_width']) && $in_http_vars['geo_width'] ) && !( isset($in_http_vars['geo_width_km']) && $in_http_vars['geo_width_km'] )) {
371  unset($in_http_vars['lat_val']);
372  unset($in_http_vars['long_val']);
373  }
374 
375  // Next, set up the weekdays.
376  if (isset($in_http_vars['bmlt_search_type']) && ($in_http_vars['bmlt_search_type'] == 'advanced') && isset($in_http_vars['advanced_weekdays']) && ((is_array($in_http_vars['advanced_weekdays']) && count($in_http_vars['advanced_weekdays'])) || isset($in_http_vars['advanced_weekdays']))) {
377  $in_http_vars['weekdays'] = $in_http_vars['advanced_weekdays'];
378  }
379 
380  if (isset($in_http_vars['weekdays']) && !is_array($in_http_vars['weekdays']) && (intval(abs($in_http_vars['weekdays'])) > 0) && (intval(abs($in_http_vars['weekdays'])) < 8)) {
381  $in_http_vars['weekdays'] = array ( intval($in_http_vars['weekdays']) );
382  }
383 
384  if (isset($in_http_vars['weekdays']) && is_array($in_http_vars['weekdays']) && count($in_http_vars['weekdays'])) {
385  $wd =& $in_search_manager->GetWeekdays();
386  foreach ($in_http_vars['weekdays'] as $weekday) {
387  $wd[abs(intval($weekday))] = intval($weekday) > 0 ? 1 : -1;
388  }
389  } elseif (isset($in_http_vars['weekdays'])) {
390  $wd =& $in_search_manager->GetWeekdays();
391  $wd[abs(intval($in_http_vars['weekdays']))] = intval(intval($in_http_vars['weekdays'])) > 0 ? 1 : -1;
392  }
393 
394  // Next, set up the formats.
395 
396  if (isset($in_http_vars['bmlt_search_type']) && ($in_http_vars['bmlt_search_type'] == 'advanced') && isset($in_http_vars['advanced_formats']) && is_array($in_http_vars['advanced_formats']) && count($in_http_vars['advanced_formats'])) {
397  $in_http_vars['formats'] = $in_http_vars['advanced_formats'];
398  }
399 
400  if (isset($in_http_vars['formats'])) {
401  if (!is_array($in_http_vars['formats'])) {
402  $in_http_vars['formats'] = array ( intval($in_http_vars['formats']) );
403  }
404 
405  $fm =& $in_search_manager->GetFormats();
406  foreach ($in_http_vars['formats'] as $format) {
407  $key = abs(intval($format));
408  $fm[$key] = (intval($format) > 0) ? 1 : -1;
409  }
410  }
411 
412  if (isset($in_http_vars['formats_comparison_operator']) && $in_http_vars['formats_comparison_operator'] == "OR") {
413  $in_search_manager->SetFormatsComparisonOperator("OR");
414  }
415 
416  // Next, set up the languages.
417  if (isset($in_http_vars['langs']) && is_array($in_http_vars['langs']) && count($in_http_vars['langs'])) {
418  $lan =& $in_search_manager->GetLanguages();
419  foreach ($in_http_vars['langs'] as $lng) {
420  $lan[$lng] = 1;
421  }
422  }
423 
424  // Next, set up the advanced published option.
425  if (isset($in_http_vars['advanced_published'])) {
426  $in_search_manager->SetPublished(intval($in_http_vars['advanced_published']));
427  } else {
428  $in_search_manager->SetPublished(1);
429  }
430 
431  // Set the start window.
432  $start_time = null;
433  $end_time = null;
434 
435  // Next, the minimum start time..
436  if (isset($in_http_vars['StartsAfterH']) || isset($in_http_vars['StartsAfterM'])) {
437  $start_hour = min(23, max(0, intval($in_http_vars['StartsAfterH'])));
438  $start_minute = min(59, max(0, intval($in_http_vars['StartsAfterM'])));
439  $start_time = mktime($start_hour, $start_minute);
440  }
441 
442  // Next, the maximum start time..
443  if (isset($in_http_vars['StartsBeforeH']) || isset($in_http_vars['StartsBeforeM'])) {
444  $end_hour = min(23, max(0, intval($in_http_vars['StartsBeforeH'])));
445  $end_minute = min(59, max(0, intval($in_http_vars['StartsBeforeM'])));
446  $end_time = mktime($end_hour, $end_minute);
447  }
448 
449  $in_search_manager->SetStartTime($start_time, $end_time);
450 
451  $end_time = null;
452 
453  // Next, the maximum end time..
454  if (isset($in_http_vars['EndsBeforeH']) || isset($in_http_vars['EndsBeforeM'])) {
455  $end_hour = min(23, max(0, intval($in_http_vars['EndsBeforeH'])));
456  $end_minute = min(59, max(0, intval($in_http_vars['EndsBeforeM'])));
457  $end_time = ($end_hour * 3600) + ($end_minute * 60);
458  }
459 
460  $in_search_manager->SetEndTime($end_time);
461 
462  // Set the duration window.
463  $max_duration_time = null;
464  $min_duration_time = null;
465 
466  // Next, the minimum start time..
467  if (isset($in_http_vars['MaxDurationH']) || isset($in_http_vars['MaxDurationM'])) {
468  $max_duration_hour = min(23, max(0, intval($in_http_vars['MaxDurationH'])));
469  $max_duration_minute = min(59, max(0, intval($in_http_vars['MaxDurationM'])));
470  $max_duration_time = mktime($max_duration_hour, $max_duration_minute);
471  }
472 
473  // Next, the maximum start time..
474  if (isset($in_http_vars['MinDurationH']) || isset($in_http_vars['MinDurationM'])) {
475  $min_duration_hour = min(23, max(0, intval($in_http_vars['MinDurationH'])));
476  $min_duration_minute = min(59, max(0, intval($in_http_vars['MinDurationM'])));
477  $min_duration_time = mktime($min_duration_hour, $min_duration_minute);
478  }
479 
480  $in_search_manager->SetDuration($max_duration_time, $min_duration_time);
481 
482  // Next, we deal with a geolocated search radius.
483 
484  if ((isset($in_http_vars['geo_width']) && ($in_http_vars['geo_width'] != 0))
485  || (isset($in_http_vars['geo_width_km']) && ($in_http_vars['geo_width_km'] != 0) )) {
486  $long = isset($in_http_vars['long_val']) ? floatval($in_http_vars['long_val']) : 0;
487  $lat = isset($in_http_vars['lat_val']) ? floatval($in_http_vars['lat_val']) : 0;
488  $radius_in_miles = 0;
489  $radius_in_km = 0;
491  $radius_auto = $local_strings['number_of_meetings_for_auto'];
492 
493  if (isset($in_http_vars['geo_width']) && ( $in_http_vars['geo_width'] != 0 )) {
494  if ($in_http_vars['geo_width'] < 0) {
495  $radius_auto = 0 - intval($in_http_vars['geo_width']);
496  } else {
497  $radius_in_miles = floatval($in_http_vars['geo_width']);
498  }
499  } elseif (isset($in_http_vars['geo_width_km']) && ( $in_http_vars['geo_width_km'] != 0 )) {
500  if ($in_http_vars['geo_width_km'] < 0) {
501  $radius_auto = 0 - intval($in_http_vars['geo_width_km']);
502  } else {
503  $radius_in_km = floatval($in_http_vars['geo_width_km']);
504  }
505  }
506 
507  if ($radius_in_miles > 0) {
508  $in_search_manager->SetSearchRadiusAndCenterInMiles($radius_in_miles, $long, $lat);
509  } elseif ($radius_in_km > 0) {
510  $in_search_manager->SetSearchRadiusAndCenterInKm($radius_in_km, $long, $lat);
511  } elseif ($radius_auto > 0) {
512  $in_search_manager->SetSearchRadiusAndCenterAuto($radius_auto, $long, $lat);
513  }
514  }
515 
516  if ($search_string && (!isset($in_http_vars['meeting_key']) || !(is_array($in_http_vars['meeting_key']) && count($in_http_vars['meeting_key'])))) {
517  // And last, but not least, a string search:
518  $find_all = (isset($in_http_vars['SearchStringAll']) && $in_http_vars['SearchStringAll']) ? true :false;
519  $literal = (isset($in_http_vars['SearchStringExact']) && $in_http_vars['SearchStringExact']) ? true :false;
520  $in_search_manager->SetSearchString($search_string, $find_all, $literal);
521  }
522 
523  if (isset($in_http_vars['meeting_key']) && $in_http_vars['meeting_key']) {
524  // This is true by default.
525  if (!isset($in_http_vars['meeting_key_contains'])) {
526  $in_http_vars['meeting_key_contains'] = false;
527  }
528 
529  // This is false by default.
530  if (!isset($in_http_vars['meeting_key_match_case'])) {
531  $in_http_vars['meeting_key_match_case'] = false;
532  }
533  $in_search_manager->SetKeyValueSearch($in_http_vars['meeting_key'], $in_http_vars['meeting_key_value'], $in_http_vars['meeting_key_match_case'], $in_http_vars['meeting_key_contains']);
534  }
535  }
536 }
static GetLocalStrings($in_lang_enum=null)
This gets the appropriate language files, and puts all the the strings into an associative array...
$local_strings
Definition: index.php:6
GetGeocodeFromString($in_string, $in_weekday_tinyint_array)
This function uses the server-level Google Maps API to try to geocode an address from the string pass...
static GetDataTableTemplate()
Returns an array that provides a template for the data table values (the optional/additional values)...
GetAllContainedServiceBodyIDs($in_parent_id=0)
This gets all the Service bodies, and returns a one-dimensional arry, containing its ID...