public function guess_search_type($query) { $return_type = "text"; $return_value = null; $return_display = null; if (is_postcode($query)) { $return_type = "postcode"; $return_display = clean_postcode($query); } else { if (is_partial_postcode($query)) { $return_type = "partial postcode"; $return_display = strtoupper($query); } else { //party name $search = factory::create("search"); $result = $search->search("party", array(array("name", "=", $query), array("country_id", "=", $this->country_id))); if (count($result) == 1) { $return_type = "party"; $return_value = $result[0]->party_id; $return_display = $result[0]->name; } else { //TODO: match a place name } } } return array("type" => $return_type, "value" => $return_value, "display" => $return_display); }
public static function get_location_type($search_term) { $search_type = "placename"; //check if is postcode if (is_postcode($search_term)) { $search_type = "postcode"; } //check if partial postcode if (is_partial_postcode($search_term)) { $search_type = "partialpostcode"; } //check if is zipcode if (is_zipcode($search_term)) { $search_type = "zipcode"; } //check if long lat if (is_longlat($search_term)) { $search_type = "longlat"; } return $search_type; }