From b0c4a1b97b045a0c08730fc0e24dc5229d773ad8 Mon Sep 17 00:00:00 2001 From: Shawn Kwang Date: Mon, 16 Oct 2017 13:45:53 -0500 Subject: [PATCH 1/3] Drupal: Added Search Help block to search pages. Search Help block added via a separate modue: boinc_solr_search, which contains customiations to the solr search functionality for BOINC. Also modified date format to use consistent date. https://dev.gridrepublic.org/browse/DBOINCP-331 --- .../boinc_solr_search/boinc_solr_search.info | 10 ++ .../boinc_solr_search.module | 99 +++++++++++++++++++ .../default/boinc/themes/boinc/css/pages.css | 6 +- .../default/boinc/themes/boinc/template.php | 6 ++ 4 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 drupal/sites/default/boinc/modules/boinc_solr_search/boinc_solr_search.info create mode 100644 drupal/sites/default/boinc/modules/boinc_solr_search/boinc_solr_search.module diff --git a/drupal/sites/default/boinc/modules/boinc_solr_search/boinc_solr_search.info b/drupal/sites/default/boinc/modules/boinc_solr_search/boinc_solr_search.info new file mode 100644 index 0000000000..f4076e80b3 --- /dev/null +++ b/drupal/sites/default/boinc/modules/boinc_solr_search/boinc_solr_search.info @@ -0,0 +1,10 @@ +name = BOINC Solr Search +description = BOINC Customizations for Solr Search +core = 6.x +dependencies[] = apachesolr +dependencies[] = apachesolr_search +dependencies[] = boinccore +package = BOINC + +version = 6.x-0.1 +timestamp = 1507924492 \ No newline at end of file diff --git a/drupal/sites/default/boinc/modules/boinc_solr_search/boinc_solr_search.module b/drupal/sites/default/boinc/modules/boinc_solr_search/boinc_solr_search.module new file mode 100644 index 0000000000..57e9e0ed14 --- /dev/null +++ b/drupal/sites/default/boinc/modules/boinc_solr_search/boinc_solr_search.module @@ -0,0 +1,99 @@ + 'BOINC Search Help', + ); + return $blocks; +} + +/* + * + */ +function boinc_solr_search_block_view($delta = 0) { + $block = array(); + switch($delta) { + case 'boinc_solr_search_0': + $items = array( + "By default a search matches ANY search term. Results with more than one term will be presented higher in the search results.", + "You may use 'AND' to have the search engine return results with ALL search terms.", + "For example, searching for 'boinc AND client' will only contain results with words boinc and client." + ); + + drupal_add_js('misc/collapse.js'); + // @todo - add bts() + // For Drupal 7 the format of the array changes, see https://api.drupal.org/api/drupal/includes%21form.inc/function/theme_fieldset/7.x for details. + $collapsible_item = array( + '#title' => 'Search Help', + '#description' => theme_item_list($items), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#attributes' => array( + 'class' => 'search-help-block', + ), + ); + $block['content'] = theme('fieldset', $collapsible_item); + break; + } + return $block; +} + +// @todo - remove function after development +function _boinc_solr_search_helpform($form, &$form_state) { + + // @todo - add bts() + $items = array( + "By default a search matches ANY search term. Results with more than one term will be presented higher in the search results.", + "You may use 'AND' to have the search engine return results with ALL search terms.", + "For example, searching for 'boinc AND client' will only contain results with words boinc and client." + ); + + $form = array(); + $form['help'] = array( + '#type' => 'fieldset', + '#collapsible' => TRUE, + '#collapsed' => TRUE, + // @todo - add bts() + '#title' => 'Search Help', + ); + $form['help']['text'] = array( + '#type' => 'item', + '#description' => theme_item_list($items), + ); + return $form; +} \ No newline at end of file diff --git a/drupal/sites/default/boinc/themes/boinc/css/pages.css b/drupal/sites/default/boinc/themes/boinc/css/pages.css index 6a3fb74a2f..1c942f33c5 100644 --- a/drupal/sites/default/boinc/themes/boinc/css/pages.css +++ b/drupal/sites/default/boinc/themes/boinc/css/pages.css @@ -919,9 +919,6 @@ table.user-projects { .page-search-site #content { width: 650px; } -.page-search-site .framing { - padding-bottom: 13px; -} .page-search-site h1.title { display: none; } @@ -989,6 +986,9 @@ table.user-projects { padding-top: 7px; margin: 0 0 0 120px; } +.search-help-block { + min-height: 54px; +} /* Search pane */ .panel-secondary #search-form #edit-keys-wrapper { diff --git a/drupal/sites/default/boinc/themes/boinc/template.php b/drupal/sites/default/boinc/themes/boinc/template.php index 05bed24e09..068f97f4cf 100644 --- a/drupal/sites/default/boinc/themes/boinc/template.php +++ b/drupal/sites/default/boinc/themes/boinc/template.php @@ -534,6 +534,12 @@ function boinc_preprocess_search_result(&$variables) { // Locality $variables['locality'] = $language->language; + // Change the format of the search result date/time in the info string. + if ($variables['result']['date']) { + $variables['info_split']['date'] = date('j M Y G:i:s T', $variables['result']['date']); + } + $variables['info'] = implode(' - ', $variables['info_split']); + $type = strtolower($variables['result']['bundle']); switch ($type) { case 'profile': From 3ca75f6970373418c24fdc967d75487982d071ae Mon Sep 17 00:00:00 2001 From: Shawn Kwang Date: Mon, 16 Oct 2017 14:13:48 -0500 Subject: [PATCH 2/3] Drupal: Added block settings to Feature global_search_solr. --- ...search_solr.features.fe_block_settings.inc | 45 +++++++++++++++++++ .../global_search_solr.info | 2 + 2 files changed, 47 insertions(+) diff --git a/drupal/sites/all/features/global_search_solr/global_search_solr.features.fe_block_settings.inc b/drupal/sites/all/features/global_search_solr/global_search_solr.features.fe_block_settings.inc index b5963ee1a4..2e4f0d5927 100644 --- a/drupal/sites/all/features/global_search_solr/global_search_solr.features.fe_block_settings.inc +++ b/drupal/sites/all/features/global_search_solr/global_search_solr.features.fe_block_settings.inc @@ -84,6 +84,21 @@ function global_search_solr_default_fe_block_settings() { 'cache' => '-1', ); + $theme['boinc_solr_search-boinc_solr_search_0'] = array( + 'module' => 'boinc_solr_search', + 'delta' => 'boinc_solr_search_0', + 'theme' => 'boinc', + 'status' => '1', + 'weight' => '0', + 'region' => 'sidebar_second', + 'custom' => '0', + 'throttle' => '0', + 'visibility' => '1', + 'pages' => 'search/*', + 'title' => '', + 'cache' => '1', + ); + $export['boinc'] = $theme; // einstein @@ -164,6 +179,21 @@ function global_search_solr_default_fe_block_settings() { 'cache' => '-1', ); + $theme['boinc_solr_search-boinc_solr_search_0'] = array( + 'module' => 'boinc_solr_search', + 'delta' => 'boinc_solr_search_0', + 'theme' => 'einstein', + 'status' => '1', + 'weight' => '-20', + 'region' => 'sidebar_second', + 'custom' => '0', + 'throttle' => '0', + 'visibility' => '1', + 'pages' => 'search/*', + 'title' => '', + 'cache' => '1', + ); + $export['einstein'] = $theme; // garland @@ -244,6 +274,21 @@ function global_search_solr_default_fe_block_settings() { 'cache' => '-1', ); + $theme['boinc_solr_search-boinc_solr_search_0'] = array( + 'module' => 'boinc_solr_search', + 'delta' => 'boinc_solr_search_0', + 'theme' => 'garland', + 'status' => 0, + 'weight' => '0', + 'region' => '', + 'custom' => '0', + 'throttle' => '0', + 'visibility' => '1', + 'pages' => 'search/*', + 'title' => '', + 'cache' => '1', + ); + $export['garland'] = $theme; $theme_default = variable_get('theme_default', 'garland'); diff --git a/drupal/sites/all/features/global_search_solr/global_search_solr.info b/drupal/sites/all/features/global_search_solr/global_search_solr.info index 336212692a..721ad8ddde 100644 --- a/drupal/sites/all/features/global_search_solr/global_search_solr.info +++ b/drupal/sites/all/features/global_search_solr/global_search_solr.info @@ -4,6 +4,7 @@ core = "6.x" package = "Features" dependencies[] = "apachesolr" dependencies[] = "apachesolr_search" +dependencies[] = "boinc_solr_search" dependencies[] = "ctools" dependencies[] = "facetapi" dependencies[] = "fe_block" @@ -23,6 +24,7 @@ features[fe_block_settings][] = "facetapi-7ML0OK3vgYXeSgMyfPmmpnz2TBw9jZ7J" features[fe_block_settings][] = "facetapi-GiIy4zr9Gu0ZSa0bumw1Y9qIIpIDf1wu" features[fe_block_settings][] = "facetapi-WtseAVugB1EhxGslwR3XIwoa0sVTttYt" features[fe_block_settings][] = "facetapi-wWWinJ0eOefOtAMbjo2yl86Mnf1rO12j" +features[fe_block_settings][] = "boinc_solr_search-boinc_solr_search_0" features[user_permission][] = "administer search" features[user_permission][] = "search content" features[user_permission][] = "use advanced search" From 0d4647c0422121839a3ec761a0e3dc9a9192b074 Mon Sep 17 00:00:00 2001 From: Shawn Kwang Date: Tue, 17 Oct 2017 09:31:06 -0500 Subject: [PATCH 3/3] Drupal: Addd bts() function calls to text. Added documentation, removed unused function. --- .../boinc_solr_search.module | 47 +++++-------------- 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/drupal/sites/default/boinc/modules/boinc_solr_search/boinc_solr_search.module b/drupal/sites/default/boinc/modules/boinc_solr_search/boinc_solr_search.module index 57e9e0ed14..53dca7f564 100644 --- a/drupal/sites/default/boinc/modules/boinc_solr_search/boinc_solr_search.module +++ b/drupal/sites/default/boinc/modules/boinc_solr_search/boinc_solr_search.module @@ -30,36 +30,40 @@ function boinc_solr_search_block($op = 'list', $delta = 0, $edit = array()) { } } -/* +/** + * Implementation of hook_block_info() * + * This is a Drupal 7 hook, which will allow this module to be + * (somewhat) forward compatible. */ function boinc_solr_search_block_info() { $blocks = array(); $blocks['boinc_solr_search_0'] = array( - // @todo - add bts() - 'info' => 'BOINC Search Help', + 'info' => t('BOINC Search Help'), ); return $blocks; } -/* +/** + * Implementation of hook_block_view() * + * This is a Drupal 7 hook, which will allow this module to be + * (somewhat) forward compatible. */ function boinc_solr_search_block_view($delta = 0) { $block = array(); switch($delta) { case 'boinc_solr_search_0': $items = array( - "By default a search matches ANY search term. Results with more than one term will be presented higher in the search results.", - "You may use 'AND' to have the search engine return results with ALL search terms.", - "For example, searching for 'boinc AND client' will only contain results with words boinc and client." + bts('By default a search matches ANY search term. Results with more than one term will be presented higher in the search results.', array(), NULL, 'boinc:search-help-sidebar-block'), + bts('You may use \'AND\' to have the search engine return results with ALL search terms.', array(), NULL, 'boinc:search-help-sidebar-block'), + bts('For example, searching for \'boinc AND client\' will only contain results with words boinc and client.', array(), NULL, 'boinc:search-help-sidebar-block') ); drupal_add_js('misc/collapse.js'); - // @todo - add bts() // For Drupal 7 the format of the array changes, see https://api.drupal.org/api/drupal/includes%21form.inc/function/theme_fieldset/7.x for details. $collapsible_item = array( - '#title' => 'Search Help', + '#title' => bts('Search Help', array(), NULL, 'boinc:search-help-sidebar-block'), '#description' => theme_item_list($items), '#collapsible' => TRUE, '#collapsed' => TRUE, @@ -72,28 +76,3 @@ function boinc_solr_search_block_view($delta = 0) { } return $block; } - -// @todo - remove function after development -function _boinc_solr_search_helpform($form, &$form_state) { - - // @todo - add bts() - $items = array( - "By default a search matches ANY search term. Results with more than one term will be presented higher in the search results.", - "You may use 'AND' to have the search engine return results with ALL search terms.", - "For example, searching for 'boinc AND client' will only contain results with words boinc and client." - ); - - $form = array(); - $form['help'] = array( - '#type' => 'fieldset', - '#collapsible' => TRUE, - '#collapsed' => TRUE, - // @todo - add bts() - '#title' => 'Search Help', - ); - $form['help']['text'] = array( - '#type' => 'item', - '#description' => theme_item_list($items), - ); - return $form; -} \ No newline at end of file