Merge pull request #2173 from drshawnkwang/drupal_feature-solrhelp-date

Drupal: Add Search Help block.
This commit is contained in:
tristanolive 2017-10-19 22:58:23 -04:00 committed by GitHub
commit f0c38d5d60
6 changed files with 144 additions and 3 deletions

View File

@ -84,6 +84,21 @@ function global_search_solr_default_fe_block_settings() {
'cache' => '-1', '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; $export['boinc'] = $theme;
// einstein // einstein
@ -164,6 +179,21 @@ function global_search_solr_default_fe_block_settings() {
'cache' => '-1', '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; $export['einstein'] = $theme;
// garland // garland
@ -244,6 +274,21 @@ function global_search_solr_default_fe_block_settings() {
'cache' => '-1', '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; $export['garland'] = $theme;
$theme_default = variable_get('theme_default', 'garland'); $theme_default = variable_get('theme_default', 'garland');

View File

@ -4,6 +4,7 @@ core = "6.x"
package = "Features" package = "Features"
dependencies[] = "apachesolr" dependencies[] = "apachesolr"
dependencies[] = "apachesolr_search" dependencies[] = "apachesolr_search"
dependencies[] = "boinc_solr_search"
dependencies[] = "ctools" dependencies[] = "ctools"
dependencies[] = "facetapi" dependencies[] = "facetapi"
dependencies[] = "fe_block" dependencies[] = "fe_block"
@ -23,6 +24,7 @@ features[fe_block_settings][] = "facetapi-7ML0OK3vgYXeSgMyfPmmpnz2TBw9jZ7J"
features[fe_block_settings][] = "facetapi-GiIy4zr9Gu0ZSa0bumw1Y9qIIpIDf1wu" features[fe_block_settings][] = "facetapi-GiIy4zr9Gu0ZSa0bumw1Y9qIIpIDf1wu"
features[fe_block_settings][] = "facetapi-WtseAVugB1EhxGslwR3XIwoa0sVTttYt" features[fe_block_settings][] = "facetapi-WtseAVugB1EhxGslwR3XIwoa0sVTttYt"
features[fe_block_settings][] = "facetapi-wWWinJ0eOefOtAMbjo2yl86Mnf1rO12j" 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][] = "administer search"
features[user_permission][] = "search content" features[user_permission][] = "search content"
features[user_permission][] = "use advanced search" features[user_permission][] = "use advanced search"

View File

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

View File

@ -0,0 +1,78 @@
<?php
// $id$
/**
* @file
* Module contains boinc-related customizations for apache solr
* search.
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Hooks into drupal
* * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* Implementation of hook_block()
*
* Functions are forward compatible with Drupal 7 hooks.
*/
function boinc_solr_search_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
return boinc_solr_search_block_info();
break;
case 'view':
return boinc_solr_search_block_view($delta);
break;
case 'configure':
case 'save':
default:
}
}
/**
* 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(
'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(
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');
// 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' => bts('Search Help', array(), NULL, 'boinc:search-help-sidebar-block'),
'#description' => theme_item_list($items),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#attributes' => array(
'class' => 'search-help-block',
),
);
$block['content'] = theme('fieldset', $collapsible_item);
break;
}
return $block;
}

View File

@ -919,9 +919,6 @@ table.user-projects {
.page-search-site #content { .page-search-site #content {
width: 650px; width: 650px;
} }
.page-search-site .framing {
padding-bottom: 13px;
}
.page-search-site h1.title { .page-search-site h1.title {
display: none; display: none;
} }
@ -989,6 +986,9 @@ table.user-projects {
padding-top: 7px; padding-top: 7px;
margin: 0 0 0 120px; margin: 0 0 0 120px;
} }
.search-help-block {
min-height: 54px;
}
/* Search pane */ /* Search pane */
.panel-secondary #search-form #edit-keys-wrapper { .panel-secondary #search-form #edit-keys-wrapper {

View File

@ -534,6 +534,12 @@ function boinc_preprocess_search_result(&$variables) {
// Locality // Locality
$variables['locality'] = $language->language; $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']); $type = strtolower($variables['result']['bundle']);
switch ($type) { switch ($type) {
case 'profile': case 'profile':