From a23a5651b9f6b36f2aa9f471050f25ef8133af48 Mon Sep 17 00:00:00 2001 From: Sven Houtmeyers Date: Fri, 8 May 2015 12:07:14 +0200 Subject: [PATCH 1/7] CEP-838 adding validated var to membership in pages theme --- culturefeed_pages/theme/theme.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/culturefeed_pages/theme/theme.inc b/culturefeed_pages/theme/theme.inc index 379ef179..6401432f 100644 --- a/culturefeed_pages/theme/theme.inc +++ b/culturefeed_pages/theme/theme.inc @@ -151,6 +151,7 @@ function culturefeed_pages_preprocess_culturefeed_page(&$variables) { $member['relation'] = check_plain($membership->relation); $member['role'] = check_plain($membership->role); $member['picture'] = check_plain($membership->user->depiction); + $member['validated'] = $membership->validated; $variables['members'][] = $member; } From d5d8c4fe9d4dd9b6c0a16755c12bfdf62c173fb1 Mon Sep 17 00:00:00 2001 From: Sven Houtmeyers Date: Wed, 6 May 2015 10:01:18 +0200 Subject: [PATCH 2/7] CEP-857 use redirect naar alle/city-slug when city is in query --- culturefeed_agenda/culturefeed_agenda.module | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/culturefeed_agenda/culturefeed_agenda.module b/culturefeed_agenda/culturefeed_agenda.module index 1672d02a..dcd80fcf 100644 --- a/culturefeed_agenda/culturefeed_agenda.module +++ b/culturefeed_agenda/culturefeed_agenda.module @@ -756,15 +756,20 @@ function culturefeed_agenda_url_outbound_alter(&$path, &$options, $original_path $city_parts = explode(' ', $location); // The search contains a zip code. Search city by zip + name. - if (is_numeric($city_parts[0])) { + if (is_numeric($city_parts[0]) && isset($city_parts[1])) { + // Search on city or city + (city) if (count($city_parts) == 2) { - // Static cache the result. - if (!isset($city_slugs[$city_parts[0]][$city_parts[1]])) { - $city_slugs[$city_parts[0]][$city_parts[1]] = db_query('SELECT slug FROM {culturefeed_search_cities} WHERE zip = :zip AND name = :name', array(':zip' => $city_parts[0], ':name' => $city_parts[1]))->fetchField(); - } - $location_slug = $city_slugs[$city_parts[0]][$city_parts[1]]; + $name = $city_parts[1]; + } + else { + $name = $city_parts[1] . ' ' . $city_parts[2]; + } + // Static cache the result. + if (!isset($city_slugs[$city_parts[0]][$city_parts[1]])) { + $city_slugs[$city_parts[0]][$city_parts[1]] = db_query('SELECT slug FROM {culturefeed_search_cities} WHERE zip = :zip AND name = :name', array(':zip' => $city_parts[0], ':name' => $name))->fetchField(); } + $location_slug = $city_slugs[$city_parts[0]][$city_parts[1]]; } // The search contains only a city / region name. Search on full name. else { From a079b9a1e4bdebd1a9a95a6c58c4c80b3509975b Mon Sep 17 00:00:00 2001 From: Sven Houtmeyers Date: Wed, 6 May 2015 10:48:31 +0200 Subject: [PATCH 3/7] CEP-857 also add wregs in location param when provided --- .../lib/Drupal/CultureFeedSearchPage.php | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php b/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php index 053c29ec..f9b71bde 100644 --- a/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php +++ b/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php @@ -445,6 +445,9 @@ protected function addFacetFilters($params) { // Add the location facet. Only use the location if a distance is set. // all other cases will search for a category Id of the type flandersregion // or workingregion. + + echo '
';print_r($params);echo '
'; + if (!empty($params['regId']) && !isset($params['distance'])) { $regFilter = array(); @@ -486,7 +489,24 @@ protected function addFacetFilters($params) { } else { $location = '"' . str_replace('"', '\"', $params['location']) . '"'; - $this->parameters[] = new Parameter\FilterQuery('category_flandersregion_name' . ':' . $location); + + // Also here add wregs if in params + if (!empty($params['wregIds'])) { + $regFilter[] = array_shift($params['wregIds']); + + $wregFilters = array(); + foreach ($params['wregIds'] as $wregId) { + $wregFilters[] = $wregId; + } + } + + $regFilterQuery = '('; + $regFilterQuery .= 'category_flandersregion_name' . ':' . $location; + if (!empty($wregFilters)) { + $regFilterQuery .= ' OR exact_category_id:(' . implode(' OR ', $wregFilters) . ')'; + } + $regFilterQuery .= ')'; + $this->parameters[] = new Parameter\FilterQuery($regFilterQuery); } } From 8115b0eb4608689f2955e31e0b1f2833278ac845 Mon Sep 17 00:00:00 2001 From: Sven Houtmeyers Date: Wed, 6 May 2015 10:51:01 +0200 Subject: [PATCH 4/7] CEP-857 remove debug --- culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php b/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php index f9b71bde..35d4fd87 100644 --- a/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php +++ b/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php @@ -445,9 +445,6 @@ protected function addFacetFilters($params) { // Add the location facet. Only use the location if a distance is set. // all other cases will search for a category Id of the type flandersregion // or workingregion. - - echo '
';print_r($params);echo '
'; - if (!empty($params['regId']) && !isset($params['distance'])) { $regFilter = array(); From 4bac9bde7081b3dbd8fec95182a11f33bf177cf6 Mon Sep 17 00:00:00 2001 From: Sven Houtmeyers Date: Wed, 6 May 2015 11:48:29 +0200 Subject: [PATCH 5/7] CEP-857 adding wregs params for pages --- culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php b/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php index 35d4fd87..3a3ff868 100644 --- a/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php +++ b/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php @@ -472,7 +472,7 @@ protected function addFacetFilters($params) { // Check if postal was present. $city_parts = explode(' ', $params['location']); - if (is_numeric($city_parts[0])) { + if (is_numeric($city_parts[0]) && empty($params['wregIds'])) { $distance = isset($params['distance']) ? $params['distance'] : FALSE; // If category_actortype_id we assume that we search on pages (on day we have to fix) @@ -486,7 +486,7 @@ protected function addFacetFilters($params) { } else { $location = '"' . str_replace('"', '\"', $params['location']) . '"'; - + // Also here add wregs if in params if (!empty($params['wregIds'])) { $regFilter[] = array_shift($params['wregIds']); From 5de7493bbaed5bec4e89809bf5aec4b925368f43 Mon Sep 17 00:00:00 2001 From: Sven Houtmeyers Date: Thu, 7 May 2015 16:38:36 +0200 Subject: [PATCH 6/7] CEP-857 adding option to search only on wregs --- .../lib/Drupal/CultureFeedSearchPage.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php b/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php index 3a3ff868..351a4b8a 100644 --- a/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php +++ b/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php @@ -448,7 +448,6 @@ protected function addFacetFilters($params) { if (!empty($params['regId']) && !isset($params['distance'])) { $regFilter = array(); - $regFilter[] = $params['regId']; if (!empty($params['wregIds'])) { $regFilter[] = array_shift($params['wregIds']); @@ -458,6 +457,10 @@ protected function addFacetFilters($params) { $wregFilters[] = $wregId; } } + + if (!empty($_GET['only-wregs'])) { + $regFilter[] = $params['regId']; + } $regFilterQuery = '('; $regFilterQuery .= 'category_id:(' . implode(' OR ', $regFilter) .')'; @@ -498,7 +501,17 @@ protected function addFacetFilters($params) { } $regFilterQuery = '('; - $regFilterQuery .= 'category_flandersregion_name' . ':' . $location; + + if (empty($_GET['only-wregs'])) { + $regFilterQuery .= 'category_flandersregion_name' . ':' . $location; + } + else { + $working_region_id = key(culturefeed_search_get_workingregion_categories(array('name_like' => $params['location']))); + if ($working_region_id) { + $regFilterQuery .= 'category_id' . ':' . $working_region_id; + } + } + if (!empty($wregFilters)) { $regFilterQuery .= ' OR exact_category_id:(' . implode(' OR ', $wregFilters) . ')'; } From 1da295420ead54a0c015356439c012d6ffaeb0c3 Mon Sep 17 00:00:00 2001 From: Sven Houtmeyers Date: Thu, 7 May 2015 19:58:11 +0200 Subject: [PATCH 7/7] CEP-857 fixin parameters logic --- culturefeed_search/includes/helpers.inc | 22 +++++ .../lib/Drupal/CultureFeedSearchPage.php | 88 +++++++------------ 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/culturefeed_search/includes/helpers.inc b/culturefeed_search/includes/helpers.inc index 8fe02ad5..52129fc5 100644 --- a/culturefeed_search/includes/helpers.inc +++ b/culturefeed_search/includes/helpers.inc @@ -720,6 +720,28 @@ function culturefeed_search_get_category_by_slug($slug, $domain = '') { } +/** + * Get a category by name. + */ +function culturefeed_search_get_category_by_name($name, $domain = '') { + + $query = db_select('culturefeed_search_terms', 'ct'); + $query->condition('name', $name); + $query->range(0, 1); + $query->addField('ct', 'tid'); + $query->addField('ct', 'slug'); + $query->addField('ct', 'p1'); + $query->addField('ct', 'p2'); + $query->addField('ct', 'p3'); + $query->addField('ct', 'p4'); + if (!empty($domain)) { + $query->condition('did', $domain); + } + + return $query->execute()->fetchObject(); + +} + /** * Get a city by slug. */ diff --git a/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php b/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php index 351a4b8a..0705e52d 100644 --- a/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php +++ b/culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php @@ -445,52 +445,17 @@ protected function addFacetFilters($params) { // Add the location facet. Only use the location if a distance is set. // all other cases will search for a category Id of the type flandersregion // or workingregion. - if (!empty($params['regId']) && !isset($params['distance'])) { - - $regFilter = array(); - - if (!empty($params['wregIds'])) { - $regFilter[] = array_shift($params['wregIds']); - - $wregFilters = array(); - foreach ($params['wregIds'] as $wregId) { - $wregFilters[] = $wregId; - } - } + if (!empty($params['regId']) || !empty($params['location'])) { - if (!empty($_GET['only-wregs'])) { - $regFilter[] = $params['regId']; - } - - $regFilterQuery = '('; - $regFilterQuery .= 'category_id:(' . implode(' OR ', $regFilter) .')'; - if (!empty($wregFilters)) { - $regFilterQuery .= ' OR exact_category_id:(' . implode(' OR ', $wregFilters) . ')'; - } - $regFilterQuery .= ')'; - $this->parameters[] = new Parameter\FilterQuery($regFilterQuery); - - } - elseif (!empty($params['location'])) { - - // Check if postal was present. - $city_parts = explode(' ', $params['location']); - if (is_numeric($city_parts[0]) && empty($params['wregIds'])) { - $distance = isset($params['distance']) ? $params['distance'] : FALSE; - - // If category_actortype_id we assume that we search on pages (on day we have to fix) - if (isset($params['facet']['category_actortype_id'])) { - $this->parameters[] = new Parameter\FilterQuery('zipcode' . ':' . $city_parts[0]); - } - else { - $this->parameters[] = new Parameter\Spatial\Zipcode($city_parts[0], $distance); + if (!isset($params['distance'])) { + + $regFilter = array(); + + if (empty($params['regId']) && !empty($params['location'])) { + $location = culturefeed_search_get_category_by_name($params['location']); + $params['regId'] = $location->tid; } - - } - else { - $location = '"' . str_replace('"', '\"', $params['location']) . '"'; - - // Also here add wregs if in params + if (!empty($params['wregIds'])) { $regFilter[] = array_shift($params['wregIds']); @@ -499,26 +464,39 @@ protected function addFacetFilters($params) { $wregFilters[] = $wregId; } } - - $regFilterQuery = '('; if (empty($_GET['only-wregs'])) { - $regFilterQuery .= 'category_flandersregion_name' . ':' . $location; - } - else { - $working_region_id = key(culturefeed_search_get_workingregion_categories(array('name_like' => $params['location']))); - if ($working_region_id) { - $regFilterQuery .= 'category_id' . ':' . $working_region_id; - } + $regFilter[] = $params['regId']; } - + + $regFilterQuery = '('; + $regFilterQuery .= 'category_id:(' . implode(' OR ', $regFilter) .')'; if (!empty($wregFilters)) { $regFilterQuery .= ' OR exact_category_id:(' . implode(' OR ', $wregFilters) . ')'; } $regFilterQuery .= ')'; $this->parameters[] = new Parameter\FilterQuery($regFilterQuery); + } - + elseif (!empty($params['location'])) { + + // Check if postal was present. + $city_parts = explode(' ', $params['location']); + if (is_numeric($city_parts[0]) && empty($params['wregIds'])) { + $distance = isset($params['distance']) ? $params['distance'] : FALSE; + + // If category_actortype_id we assume that we search on pages (on day we have to fix) + if (isset($params['facet']['category_actortype_id'])) { + $this->parameters[] = new Parameter\FilterQuery('zipcode' . ':' . $city_parts[0]); + } + else { + $this->parameters[] = new Parameter\Spatial\Zipcode($city_parts[0], $distance); + } + + } + + } + } // Calculate actor if available.