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...

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.
 BuildFormats ($in_mtg_obj, $lite=false)
 This displays the format keys, along with abbreviations to display when the cursor is over them.
 BuildTown ($in_mtg_obj)
 Combines the town, borough and neighborhood into one 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.
 BuildLocation ($in_mtg_obj)
 This combines the location and street address fields.
 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.

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: http://magshare.org/bmlt

BMLT is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

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 GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this code. If not, see <http://www.gnu.org/licenses/>.


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.

Referenced by DisplayMeeting().

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.
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).

Referenced by DisplayMeeting().

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.

Referenced by DisplayMeeting().

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.

Referenced by SetUpSearch().

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.
in_http_varsThe various HTTP GET and POST parameters. The values that are important to the search are:
  • 'services' This is an array of positive integers. This is interpreted as an array of integers. Each integer represents the ID of a Service Body. A positive integer means that the search will look specifically for meetings that contain that Service Body ID. If the integer is negative (preceded by a minus sign -), then the criteria will be to look for meetings that don't contain that ID. If no 'services' values are given, then the search will not use the Service Body field as a search criteria.
  • 'weekdays' This is an array of positive integers ( 1-7). This is interpreted as an array of integers. Each integer represents a weekday (1 -> Sunday, 7 -> Saturday). A positive integer means that the search will look specifically for meetings that occur on that weekday. If the integer is negative (preceded by a minus sign -), then the criteria will be to look for meetings that don't occur on that weekday. If no 'weekdays' values are given, then the search will not use the weekday field as a search criteria.
  • 'bmlt_search_type' This is set to 'advanced' if the search is an advanced one (we need to take more criteria into consideration).
  • 'advanced_search_mode' This is set if the call was made from the advanced search page.
  • 'advanced_formats' This is the formats array, but is only counted if the bmlt_search_type is set to 'advanced'.
  • 'advanced_service_bodies' This is the same, but for Service Bodies.
  • 'advanced_weekdays' ...and weekdays.
  • 'advanced_radius' ...and radius (in degrees)
  • advanced_mapmode If this is true (1), then the Advanced form is using its map.
  • 'advanced_published' This is a switch to indicate whether or not to display published or unpublished meetings. It is only viable for logged-in users, and can have these values:
    • -1 Search for ONLY unpublished meetings
    • 0 Search for published and unpublished meetings.
    • 1 Search for ONLY published meetings.
  • 'formats' This is an array of positive integers. This is interpreted as an array of integers. Each integer represents a format shared ID. A format ID means that the search will look specifically for meetings that have that format. If the format is negative (preceded by a minus sign -), then the criteria will be to look for meetings that don't have that format. If no 'formats' values are given, then the search will not use the formats field as a search criteria.
  • 'langs' This is an array of 2-character strings. This is interpreted as an array of strings. Each string represents a language code, and is a 2-character string. A language string means that the search will look specifically for meetings that are in that language. If the language is preceded by a minus sign -, then the criteria will be to look for meetings that are not in that language. If no 'langs' values are given, then the search will not use the lang_enum field as a search criteria.

The following values specify a start time "window." The meeting must start on, or after StartsAfterH/M, and can start no later than StartsBeforeH/M

  • 'StartsAfterH' A positive integer between 0 and 23. The hour of the minimal start time for meetings, in military time.
  • 'StartsAfterM' A positive integer between 0 and 59. The minute of the minimal start time for meetings, in military time.
  • 'StartsBeforeH' A positive integer between 0 and 23. The hour of the maximal start time for meetings, in military time.
  • 'StartsBeforeM' A positive integer between 0 and 59. The minute of the maximal start time for meetings, in military time.

The following values specify a time duration "window." The meeting can last no longer than MaxDurationH/M, and no less than MinDurationH/M.

  • 'MinDurationH' A positive integer. This is the number of hours in the minimal duration.
  • 'MinDurationM' A positive integer. This is the number of minutes in the minimal duration.
  • 'MaxDurationH' A positive integer. This is the number of hours in the maximal duration.
  • 'MaxDurationM' A positive integer. This is the number of minutes in the maximal duration.

This is how meetings are located. We don't use address lookups. Instead, we geolocate the meetings via the longitude and latitude fields in each record. If you don't specify a geolocation, then the entire database is searched. If you do specify one, then only the portion within the radius is searched.

  • 'geo_width' A floating point number. This is the radius (not diameter) of the search, in MILES (not Kilometers). If this is negative, then it should be an integer, and that indicates an auto-radius is requested to find the number of meetings in the integer.
  • 'geo_width_km' A floating point number. This is the radius (not diameter) of the search, in KILOMETERS (not Miles). If this is negative, then it should be an integer, and that indicates an auto-radius is requested to find the number of meetings in the integer.
  • 'long_val' If one of the three radius specifiers is zero or undefined, this is ignored. This is a floating point number that specifies the longitude, in degrees, of the center of the search radius.
  • 'lat_val' If one of the three radius specifiers is zero or undefined, this is ignored. This is a floating point number that specifies the latitude, in degrees, of the center of the search radius.
  • 'SearchString' A string. If this is specified, then all the string fields of the meetings specified by the above criteria will be searched for the string. By default, if the language supports metaphone (sound like search), then that is used.
  • 'StringSearchIsAnAddress' A boolean. Nonzero means that the given string should not be checked against any of the fields in the meeting data. Instead, it is to be considered a submission to the Google Maps geocode, and will be used to determine a cernter point in a local search.
  • 'SearchStringAll' If nonzero, then all of the words in the search string will have to be matched for a meetings to qualify.
  • 'SearchStringExact' If nonzero, metaphone will not be used, and the spelling must be exact.
  • 'SearchStringRadius' If specified, the radius of the search around the address (ignored if StringSearchIsAnAddress is false). The units are in whatever the server units are for this language (can be miles or kilometers). Negative numbers must always be integers, and specify a rough target number of meetings for auto-radius.
  • 'meeting_ids' An array of positive integers. Each integer is an ID of an individual meeting. If this is set, all other search criteria are ignored.
  • 'meeting_key' A string. This is the exact name of the key to match. If this is null (Default), the following three are ignored. NOTE: As of 1.5, the behavior of this field has changed. If it is an array, then the string search is done via metaphone, unless meeting_key_match_case is true. If it is an array, then the search is done on all the fields in the array, assuming they are all text. Non-string fields are ignored.
  • 'meeting_key_value' A string. The value to match. NOTE: As of Version 1.5, this is matched with a metaphone match, as well as the RegEx match.
  • 'meeting_key_match_case' If true, the case must match. Default is false. NOTE: As of Version 1.5, setting this to TRUE also stops the metaphone search.
  • 'meeting_key_contains' If this is false, then the string must be complete. Default is true (contains).
  • 'sort_results_by_distance' If this is true, then, if possible, the search results will be sorted by distance from the radius center.

Referenced by DisplaySearchResultsCSV(), DisplaySearchResultsList(), and DisplaySearchResultsMap().

 All Classes Files Functions Variables Enumerations