diff --git a/targets/eds/roblib_search_eds.module b/targets/eds/roblib_search_eds.module index 34836ff..01dbb8a 100644 --- a/targets/eds/roblib_search_eds.module +++ b/targets/eds/roblib_search_eds.module @@ -198,13 +198,7 @@ function roblib_search_eds_block_info() { function roblib_search_eds_block_view($delta = '') { switch ($delta) { case 'roblib_search_eds_results': - // The subject is displayed at the top of the block. Note that it - // should be passed through t() for translation. The title configured - // for the block using Drupal UI supercedes this one. $block['subject'] = t('Books & Media'); - // The content of the block is typically generated by calling a custom - // function. - // $block['content'] = roblib_search_eds_get_results(); $block['content'] = theme('roblib_search_eds', array('results' => NULL)); break; @@ -257,10 +251,23 @@ function roblib_search_eds_get_results($query = NULL, $type = NULL) { //$params = "query=AND,$query&view=detailed&includefacets=n&$limiters&resultsperpage=$number_per_page"; $params = "query=AND,$query&view=detailed&includefacets=n&resultsperpage=$number_per_page"; $output = $eds_api->apiSearch($params); - $output = roblib_search_eds_get_detailed_result($output, $query, $eds_api); + roblib_search_eds_get_detailed_result($output, $query, $eds_api); return json_encode($output); } + +/** + * For each result query ebsco again to get the detailed record. + * + * and insert a new DetailedRecord element in each record. + * + * @param array $output + * The orginal search results array + * @param string $query + * The orginal query + * @param object $eds_api + * an ebco API PHP object + */ function roblib_search_eds_get_detailed_result(&$output, $query, &$eds_api) { foreach ($output['records'] as &$record) { $db = $record['DbId']; @@ -268,9 +275,17 @@ function roblib_search_eds_get_detailed_result(&$output, $query, &$eds_api) { $arr = $eds_api->apiRetrieve($an, $db, $query); $record['DetailedRecord'] = $arr['Items']; } - return $output; } +/** + * Creates the limiter string to append to the end of a query. + * + * @param string $type + * The type of search we want (Articles or Books) + * + * @return string + * The limiters to append to the query. + */ function roblib_search_eds_get_query_limiters($type) { $limiters = 'n'; switch ($type) { diff --git a/targets/solr_site/js/solr_site_databases.js b/targets/solr_site/js/solr_site_databases.js index fb8736d..77b87ee 100644 --- a/targets/solr_site/js/solr_site_databases.js +++ b/targets/solr_site/js/solr_site_databases.js @@ -3,6 +3,7 @@ Drupal.behaviors.roblib_search_solr_site_databases = { $url = settings.roblib_search_solr_site_databases.search_url; query = settings.roblib_search_solr_site_results.search_query; baseUrl = settings.roblib_search_solr_site_results.base_url; + default_site_type = settings.roblib_search_solr_site_results.default_site_type + '/'; jQuery.getJSON($url, function(data) { var items = []; var numberOfDocs = 0; @@ -35,7 +36,7 @@ Drupal.behaviors.roblib_search_solr_site_databases = { } if (numberOfDocs > 0) { - jQuery('#' + 'roblib-search-solr-site-databases-more').empty().append('see all results'); + jQuery('#' + 'roblib-search-solr-site-databases-more').empty().append('see all results'); } }); } diff --git a/targets/solr_site/js/solr_site_guides.js b/targets/solr_site/js/solr_site_guides.js index a17f0d3..d69281b 100644 --- a/targets/solr_site/js/solr_site_guides.js +++ b/targets/solr_site/js/solr_site_guides.js @@ -3,6 +3,7 @@ Drupal.behaviors.roblib_search_solr_site_guides = { $url = settings.roblib_search_solr_site_guides.search_url; query = settings.roblib_search_solr_site_results.search_query; baseUrl = settings.roblib_search_solr_site_results.base_url; + default_site_type = settings.roblib_search_solr_site_results.default_site_type + '/'; jQuery.getJSON($url, function(data) { var items = []; var numberOfDocs = 0; @@ -33,7 +34,7 @@ Drupal.behaviors.roblib_search_solr_site_guides = { } if (numberOfDocs > 0) { - jQuery('#' + 'roblib-search-solr-site-guides-more').empty().append('see all results'); + jQuery('#' + 'roblib-search-solr-site-guides-more').empty().append('see all results'); } }); } diff --git a/targets/solr_site/js/solr_site_results.js b/targets/solr_site/js/solr_site_results.js index 213c2ab..72e91e2 100644 --- a/targets/solr_site/js/solr_site_results.js +++ b/targets/solr_site/js/solr_site_results.js @@ -3,6 +3,7 @@ Drupal.behaviors.roblib_search_solr_site_results = { url = settings.roblib_search_solr_site_results.search_url; query = settings.roblib_search_solr_site_results.search_query; baseUrl = settings.roblib_search_solr_site_results.base_url; + default_site_type = settings.roblib_search_solr_site_results.default_site_type + '/'; jQuery.getJSON(url, function(data) { var items = []; var numberOfDocs = 0; @@ -35,7 +36,7 @@ Drupal.behaviors.roblib_search_solr_site_results = { } if (numberOfDocs > 0) { - jQuery('#' + 'roblib-search-solr-site-results-more').empty().append('see all results'); + jQuery('#' + 'roblib-search-solr-site-results-more').empty().append('see all results'); } }); } diff --git a/targets/solr_site/roblib_search_solr_site.module b/targets/solr_site/roblib_search_solr_site.module index bc4c936..b1bbcd0 100755 --- a/targets/solr_site/roblib_search_solr_site.module +++ b/targets/solr_site/roblib_search_solr_site.module @@ -311,6 +311,10 @@ function roblib_search_solr_site_add_url($json) { $responses = json_decode($json); foreach ($responses->response->docs as &$doc) { $nid = $doc->entity_id; + // The link field is a complex field and we get the text in solr but not the actual url. + // Since best best will only every return one result it's not much overhead to load the node + // and get the value of the link field. probably less overhead then installing additional + // modules to get the url in solr. $node = node_load($nid); $url = $node->field_link['und'][0]['url']; $doc->url = $url; diff --git a/targets/solr_site/theme/theme.inc b/targets/solr_site/theme/theme.inc index 99dd79b..929808f 100755 --- a/targets/solr_site/theme/theme.inc +++ b/targets/solr_site/theme/theme.inc @@ -56,6 +56,7 @@ function roblib_search_solr_site_preprocessor(&$variables, $type) { $search_url = $base_url . '/roblib_search/solr_site/' . $type . '/' . $query; drupal_add_js(drupal_get_path('module', 'roblib_search_solr_site') . '/js/solr_site_' . $type . '.js'); $key = 'roblib_search_solr_site_' . $type; + $default_module = variable_get('search_default_module','node'); drupal_add_js(array($key => array('search_url' => $search_url, 'search_query' => $query, - 'base_url' => $base_url)), array('type' => 'setting')); + 'base_url' => $base_url, 'default_site_type' => $default_module)), array('type' => 'setting')); }