From 75d4303d317e01227fc8c29d45ce7f78790e37f9 Mon Sep 17 00:00:00 2001 From: Marton Kiss Date: Mon, 23 Mar 2015 17:38:45 +0100 Subject: [PATCH] Parse meetup.com event locations with USA suffix Now the event location parser can parse the addresses with USA suffix, and removes backslashes in address normalization. Change-Id: Idc66f04395104540a13b888d4d9e2a91d9033448 --- modules/groups/groups_feeds/groups_feeds.test | 9 +++++++++ .../groups_feeds/includes/groups_feeds_meetup_events.inc | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/modules/groups/groups_feeds/groups_feeds.test b/modules/groups/groups_feeds/groups_feeds.test index 1f84609..5b11034 100644 --- a/modules/groups/groups_feeds/groups_feeds.test +++ b/modules/groups/groups_feeds/groups_feeds.test @@ -97,4 +97,13 @@ class MeetupLocationParserTest extends DrupalUnitTestCase { $this->assertEqual('Blue Box Group', $result['venue']); } + function testAddressPartWithSlash() { + $location = 'Redapt Systems (12226 134th Ct Ne\, Redmond\, WA\, USA)'; + $result = _parse_meetup_location($location); + $this->assertEqual('Redapt Systems', $result['venue']); + $this->assertEqual('12226 134th Ct Ne', $result['address']); + $this->assertEqual('Redmond, WA', $result['city']); + $this->assertEqual('United States', $result['country']); + } + } \ No newline at end of file diff --git a/modules/groups/groups_feeds/includes/groups_feeds_meetup_events.inc b/modules/groups/groups_feeds/includes/groups_feeds_meetup_events.inc index a54c09c..4c4cdfc 100644 --- a/modules/groups/groups_feeds/includes/groups_feeds_meetup_events.inc +++ b/modules/groups/groups_feeds/includes/groups_feeds_meetup_events.inc @@ -210,6 +210,9 @@ function _us_states_get_predefined_list() { function _match_us_location($elements) { $us_states = _us_states_get_predefined_list(); $state_part = array_shift($elements); + if ($state_part == 'USA') { + $state_part = array_shift($elements); + } if (strlen($state_part == 2)) { $state_code = $state_part; } else { @@ -250,6 +253,7 @@ function _match_location_by_country($elements) { * address parts as array elements */ function _normalize_address_elements($address_part) { + $address_part = stripslashes($address_part); $address_elements = explode(', ', rtrim($address_part, ')')); foreach ($address_elements as $k => $v) { $address_elements[$k] = trim($v);