Paul Pound
8 years ago
13 changed files with 279 additions and 335 deletions
@ -1,99 +0,0 @@ |
|||||||
Drupal.behaviors.roblib_search_islandscholar = { |
|
||||||
attach: function (context, settings) { |
|
||||||
url = settings.roblib_search_islandscholar.search_url; |
|
||||||
jQuery.getJSON(url, function (data) { |
|
||||||
var items = []; |
|
||||||
var numberOfDocs = 0; |
|
||||||
try { |
|
||||||
numberOfDocs = data.response.docs.length; |
|
||||||
} catch (err) { |
|
||||||
// do nothing leave docLength at 0
|
|
||||||
} |
|
||||||
if (numberOfDocs < 1) { |
|
||||||
jQuery('#' + 'roblib-search-content-islandscholar').empty().append('No Results'); |
|
||||||
jQuery('.' + 'pane-roblib-search-islandscholar-roblib-islandscholar-results').hide(); |
|
||||||
} else { |
|
||||||
var counter = 0; |
|
||||||
var divs = new Array(); |
|
||||||
var content = new Array(); |
|
||||||
jQuery.each(data.response.docs, function (key, val) { |
|
||||||
id = 'roblib-search-islandscholar-' + counter; |
|
||||||
content[counter] = ''; |
|
||||||
if (typeof val['mods_abstract_s'] !== 'undefined') { |
|
||||||
content[counter] = val['mods_abstract_s'][0]; |
|
||||||
} else { |
|
||||||
content[counter] = 'No abstract available'; |
|
||||||
} |
|
||||||
divs[counter++] = id; |
|
||||||
items.push('<div class ="roblib-search-row" id="' + id + '">\n\ |
|
||||||
<div class="roblib-title islandscholar">\n\ |
|
||||||
<a href="http://www.islandscholar.ca/fedora/repository/' + val.PID + '">' + val['dc.title'] + '</a></div>'); |
|
||||||
try { |
|
||||||
items.push('<div class="islandscholar-authors">'); |
|
||||||
jQuery.each(val["mods_author_lastname_first_ms"], function (key2, val2) { |
|
||||||
items.push('<span class="islandscholar-author">' + val2 + ';</span> ') |
|
||||||
}) |
|
||||||
items.push('</div>') |
|
||||||
} catch (e) { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
items.push('<div class="islandscholar-source">'); |
|
||||||
|
|
||||||
|
|
||||||
if (typeof val.mods_relatedItem_host_titleInfo_title_s !== 'undefined') { |
|
||||||
items.push('<span class="islandscholar-hostTitle">' + val.mods_relatedItem_host_titleInfo_title_s + '</span> ') |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
if (typeof val.mods_canonical_date_issued_s !== 'undefined') { |
|
||||||
items.push('<span class="islandscholar-citation">' + val.mods_canonical_date_issued_s + '</span> ') |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
if (typeof val.mods_part_detail_volume_number_s !== 'undefined') { |
|
||||||
items.push('<span class="islandscholar-citation">Vol. </span><span class="islandscholar-citation">' + val.mods_part_detail_volume_number_s + '</span> ') |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
if (typeof val.mods_part_detail_issue_number_s !== 'undefined') { |
|
||||||
items.push('<span class="islandscholar-citation">Issue </span><span class="islandscholar-citation">' + val.mods_part_detail_issue_number_s + ',</span> ') |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
if (typeof val.mods_part_extent_start_s !== 'undefined') { |
|
||||||
items.push('<span class="islandscholar-citation">p</span><span class="islandscholar-citation">' + val.mods_part_extent_start_s + '</span>') |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
if (typeof val.mods_part_extent_end_s !== 'undefined') { |
|
||||||
items.push('<span class="islandscholar-citation">-</span><span class="islandscholar-citation">' + val.mods_part_extent_end_s + ',</span>') |
|
||||||
} |
|
||||||
|
|
||||||
if (typeof val.mods_genre_s !== 'undefined') { |
|
||||||
items.push('<div class="islandscholar-label">' + val.mods_genre_s + '</div> '); |
|
||||||
} |
|
||||||
|
|
||||||
if (jQuery.inArray('PDF', val.fedora_datastreams_ms) > 0) { |
|
||||||
items.push('<div>full text</div>'); |
|
||||||
} |
|
||||||
|
|
||||||
items.push('</div>'); |
|
||||||
|
|
||||||
items.push('</div>'); |
|
||||||
}); |
|
||||||
|
|
||||||
|
|
||||||
jQuery('#roblib-search-content-islandscholar').empty().append(items.join('')); |
|
||||||
qtipify(divs, content, 'Abstract'); |
|
||||||
var number = data.response.numFound; |
|
||||||
var query = encodeURIComponent(data.responseHeader.params.q);//.'milk';
|
|
||||||
jQuery('#roblib-search-islandscholar-more').empty().append('<a id="islandscholar-see-more-result"' + |
|
||||||
' href="http://www.islandscholar.ca/islandora/search/' + query + '?type=dismax">see all results</a>'); |
|
||||||
|
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
@ -0,0 +1,19 @@ |
|||||||
|
Drupal.behaviors.roblib_search_passthru = { |
||||||
|
attach: function (context, settings) { |
||||||
|
scholar_url = settings.roblib_search_passthru.scholar_search_url; |
||||||
|
evergreen_url = settings.roblib_search_passthru.evergreen_search_url; |
||||||
|
jQuery.getJSON(scholar_url, function (data) { |
||||||
|
var scholar_numfound = data.response.numFound; |
||||||
|
var query = encodeURIComponent(data.responseHeader.params.q); |
||||||
|
jQuery('#roblib-search-passthru-islandscholar-more').empty().append('<a id="passthru-islandscholar-see-more-result"' + |
||||||
|
' href="http://www.islandscholar.ca/islandora/search/' + query + '?type=dismax">Islandscholar Results (' + scholar_numfound + ')</a>'); |
||||||
|
|
||||||
|
}); |
||||||
|
jQuery.getJSON(evergreen_url, function (data) { |
||||||
|
var evergreen_numfound = data.numberOfRecords; |
||||||
|
jQuery('#roblib-search-passthru-evergreen-more').empty().append('<a href = "' + data.catalogBaseSearchUrl + '">PEI Collection (' + |
||||||
|
evergreen_numfound +')</a>'); |
||||||
|
}); |
||||||
|
jQuery('#roblib-search-content-passthru').empty(); |
||||||
|
} |
||||||
|
} |
@ -1,8 +0,0 @@ |
|||||||
name = Roblib Search IslandScholar |
|
||||||
dependencies[] = roblib_search |
|
||||||
configure = admin/roblib_search/islandscholar_search |
|
||||||
description = implements the Roblib Search IslandScholar results |
|
||||||
package = Roblib Search |
|
||||||
version = 7.x-dev |
|
||||||
core = 7.x |
|
||||||
stylesheets[all][] = css/roblib_search_islandscholar.css |
|
@ -1,197 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
/** |
|
||||||
* @file |
|
||||||
* Implementation of Roblib search for searching several targets. |
|
||||||
*/ |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* Implements hook_menu(). |
|
||||||
*/ |
|
||||||
function roblib_search_islandscholar_menu() { |
|
||||||
$items = array(); |
|
||||||
|
|
||||||
$items['admin/roblib_search/islandscholar_search'] = array( |
|
||||||
'title' => 'Roblib Islandscholar Search Target configuration', |
|
||||||
'description' => 'Configuration for the Roblib Islandscholar site search target', |
|
||||||
'page callback' => 'drupal_get_form', |
|
||||||
'page arguments' => array('roblib_search_islandscholar_config_form'), |
|
||||||
'access arguments' => array('access administration pages'), |
|
||||||
'type' => MENU_NORMAL_ITEM, |
|
||||||
); |
|
||||||
|
|
||||||
$items['roblib_search/islandscholar/ajax/%'] = array( |
|
||||||
'title' => 'islandscholar ajax', |
|
||||||
'page callback' => 'roblib_search_islandscholar_ajax', |
|
||||||
'page arguments' => array(3), |
|
||||||
'type' => MENU_CALLBACK, |
|
||||||
'access arguments' => array('search roblib islandscholar'), |
|
||||||
); |
|
||||||
|
|
||||||
return $items; |
|
||||||
} |
|
||||||
|
|
||||||
function roblib_search_islandscholar_config_form($form, &$form_state) { |
|
||||||
$form['roblib_search_islandscholar_url'] = array( |
|
||||||
'#type' => 'textfield', |
|
||||||
'#title' => t('Islandscholar Solr url'), |
|
||||||
'#default_value' => variable_get('roblib_search_islandscholar_url', 'http://www.islandscholar.ca:8080/solr/'), |
|
||||||
'#description' => t('The base Islandscholar Solr URL, for example http://www.islandscholar.ca:8080/solr/'), |
|
||||||
'#required' => TRUE, |
|
||||||
); |
|
||||||
$form['roblib_search_islandscholar_num_results'] = array( |
|
||||||
'#type' => 'textfield', |
|
||||||
'#title' => t('Number of results to return'), |
|
||||||
'#default_value' => variable_get('roblib_search_islandscholar_num_results', '5'), |
|
||||||
'#description' => t('The number of results to display in the Bento box'), |
|
||||||
'#required' => TRUE, |
|
||||||
); |
|
||||||
$form['roblib_search_islandscholar_fq'] = array( |
|
||||||
'#type' => 'textarea', |
|
||||||
'#title' => t('Filter Query'), |
|
||||||
'#default_value' => variable_get('roblib_search_islandscholar_fq', 'PID:ir* AND (RELS_EXT_hasModel_uri_ms:info\:fedora/ir\:thesisCModel OR RELS_EXT_hasModel_uri_ms:info\:fedora/ir\:citationCModel)'), |
|
||||||
'#description' => t('A query used to restrict the results to namespace and content models'), |
|
||||||
'#required' => TRUE, |
|
||||||
); |
|
||||||
|
|
||||||
$form['roblib_search_islandscholar_qf'] = array( |
|
||||||
'#type' => 'textarea', |
|
||||||
'#title' => t('Query Field'), |
|
||||||
'#default_value' => variable_get('roblib_search_islandscholar_qf', 'dc.title^2.5 dc.creator^5.0 dc.contributor^2.0 dc.description^2.0 dc.identifier^2.0 dc.type^2.0 catch_all_fields_mt^1.0'), |
|
||||||
'#description' => t('The fields to query and a weight for each field.'), |
|
||||||
'#required' => TRUE, |
|
||||||
); |
|
||||||
|
|
||||||
return system_settings_form($form); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Implements hook_permission(). |
|
||||||
*/ |
|
||||||
function roblib_search_islandscholar_permission() { |
|
||||||
return array( |
|
||||||
'search roblib islandscholar' => array( |
|
||||||
'title' => t('Search the islandscholar target'), |
|
||||||
'description' => t('Search all Roblib islandscholar target. This permission exposes the search blocks and allows you to see search results.'), |
|
||||||
), |
|
||||||
'administer roblib search_islandscholar' => array( |
|
||||||
'title' => t('Administer Roblib Search Evergreen'), |
|
||||||
'description' => t('Administer settings for the Roblib islandscholar search client.'), |
|
||||||
), |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Implements hook_theme(). |
|
||||||
*/ |
|
||||||
function roblib_search_islandscholar_theme() { |
|
||||||
// set path |
|
||||||
$path = drupal_get_path('module', 'roblib_search_islandscholar'); |
|
||||||
$file = 'theme.inc'; |
|
||||||
|
|
||||||
return array( |
|
||||||
// results page |
|
||||||
'roblib_search_islandscholar' => array( |
|
||||||
'path' => $path . '/theme', |
|
||||||
'file' => $file, |
|
||||||
'template' => 'roblib-search-islandscholar', |
|
||||||
'variables' => array('results' => NULL), |
|
||||||
) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
function roblib_search_islandscholar_block_info() { |
|
||||||
|
|
||||||
$blocks['roblib_islandscholar_results'] = array( |
|
||||||
// info: The name of the block. |
|
||||||
'info' => t('Roblib Islandscholar Solr Search Results block'), |
|
||||||
// Block caching options (per role, per user, etc.) |
|
||||||
'cache' => DRUPAL_CACHE_PER_ROLE, // default |
|
||||||
); |
|
||||||
|
|
||||||
return $blocks; |
|
||||||
} |
|
||||||
|
|
||||||
function roblib_search_islandscholar_preprocess_panels_pane(&$variables, $hook){ |
|
||||||
if($variables['pane']->subtype == 'roblib_search_islandscholar-roblib_islandscholar_results'){ |
|
||||||
$variables['title_prefix'] = '<div class="roblib-search-header roblib-search-islandscholar-header">'; |
|
||||||
$variables['title_suffix'] ='</div>'; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Implements hook_block_view(). |
|
||||||
*/ |
|
||||||
function roblib_search_islandscholar_block_view($delta = '') { |
|
||||||
//The $delta parameter tells us which block is being requested. |
|
||||||
switch ($delta) { |
|
||||||
case 'roblib_islandscholar_results': |
|
||||||
$block['subject'] = t('IslandScholar'); |
|
||||||
$block['content'] = theme('roblib_search_islandscholar', array('results' => NULL)); |
|
||||||
break; |
|
||||||
} |
|
||||||
return $block; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* An endpoint for the islandscholar ajax call |
|
||||||
* |
|
||||||
* @param string $query |
|
||||||
* |
|
||||||
*/ |
|
||||||
function roblib_search_islandscholar_ajax($query) { |
|
||||||
$output = roblib_search_islandscholar_get_results($query); |
|
||||||
print $output; |
|
||||||
exit(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @param $query |
|
||||||
* @return string |
|
||||||
*/ |
|
||||||
function roblib_search_islandscholar_get_search_url($query){ |
|
||||||
$solr_url = variable_get('roblib_search_islandscholar_url', 'http://localhost:8983/solr'); |
|
||||||
$num_results = variable_get('roblib_search_islandscholar_num_results', '5'); |
|
||||||
$data = array( |
|
||||||
'wt' => 'json', |
|
||||||
'q' => $query , |
|
||||||
'fq' => variable_get('roblib_search_islandscholar_fq','PID:ir* AND (RELS_EXT_hasModel_uri_ms:info\:fedora/ir\:thesisCModel OR RELS_EXT_hasModel_uri_ms:info\:fedora/ir\:citationCModel)'), |
|
||||||
'qf' => variable_get('roblib_search_islandscholar_qf','dc.title^2.5 dc.creator^5.0 dc.contributor^2.0 dc.description^2.0 dc.identifier^2.0 dc.type^2.0 catch_all_fields_mt^1.0'), |
|
||||||
'rows' => $num_results, |
|
||||||
'defType' => 'dismax', |
|
||||||
); |
|
||||||
$url = url($solr_url . '/select', array('query' => $data)); |
|
||||||
return $url; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @param string $query |
|
||||||
* |
|
||||||
* @return string |
|
||||||
* json |
|
||||||
*/ |
|
||||||
function roblib_search_islandscholar_get_results($query) { |
|
||||||
$url = roblib_search_islandscholar_get_search_url($query); |
|
||||||
$results = drupal_http_request($url); |
|
||||||
if($results->code != '200'){ |
|
||||||
return ""; |
|
||||||
} |
|
||||||
return $results->data; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Implements hook_help(). |
|
||||||
*/ |
|
||||||
function roblib_search_islandscholar_help($path, $arg) { |
|
||||||
switch ($path) { |
|
||||||
case 'admin/help#roblib_search_islandscholar': |
|
||||||
return t( |
|
||||||
'<p> |
|
||||||
provides an Islandscholar target for the Roblib search module |
|
||||||
</p>' |
|
||||||
); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
@ -0,0 +1,8 @@ |
|||||||
|
name = Roblib Search Passthru |
||||||
|
dependencies[] = roblib_search |
||||||
|
#configure = admin/roblib_search/passthru_search |
||||||
|
description = implements the Roblib Search Passthru results |
||||||
|
package = Roblib Search |
||||||
|
version = 7.x-dev |
||||||
|
core = 7.x |
||||||
|
stylesheets[all][] = css/roblib_search_passthru.css |
@ -0,0 +1,207 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
/** |
||||||
|
* @file |
||||||
|
* Implementation of Roblib search for searching several targets. |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Implements hook_menu(). |
||||||
|
*/ |
||||||
|
function roblib_search_passthru_menu() { |
||||||
|
$items = []; |
||||||
|
|
||||||
|
$items['roblib_search/passthru/scholar/ajax/%'] = [ |
||||||
|
'title' => 'Passthru ajax', |
||||||
|
'page callback' => 'roblib_search_passthru_islandscholar_ajax', |
||||||
|
'page arguments' => [4], |
||||||
|
'type' => MENU_CALLBACK, |
||||||
|
'access arguments' => ['search roblib'], |
||||||
|
]; |
||||||
|
$items['roblib_search/passthru/evergreen/ajax/%'] = [ |
||||||
|
'title' => 'evergreen ajax', |
||||||
|
'page callback' => 'roblib_search_passthru_evergreen_ajax', |
||||||
|
'page arguments' => [4], |
||||||
|
'type' => MENU_CALLBACK, |
||||||
|
'access arguments' => ['search roblib'], |
||||||
|
]; |
||||||
|
|
||||||
|
return $items; |
||||||
|
} |
||||||
|
|
||||||
|
function roblib_search_passthru_evergreen_ajax($query) { |
||||||
|
$output = roblib_search_passthru_evergreen_get_results($query); |
||||||
|
print $output; |
||||||
|
exit(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
* @param string $query |
||||||
|
* |
||||||
|
* @return string |
||||||
|
* json |
||||||
|
*/ |
||||||
|
function roblib_search_passthru_evergreen_get_results($query) { |
||||||
|
$url = variable_get('roblib_search_evergreen_url', 'http://islandpines.roblib.upei.ca'); |
||||||
|
$url_suffix = variable_get('roblib_search_evergreen_search_suffix', '/opac/extras/sru?version=1.1&operation=searchRetrieve&query='); |
||||||
|
$number_of_records = variable_get('roblib_search_evergreen_num_results', '5'); |
||||||
|
$query = trim($query); |
||||||
|
$query = str_replace(' ', '%20AND%20', $query); //hack until the library decides if we want phrase or individual words |
||||||
|
$query .= '%20AND%20%22prince%20edward%20island%22'; |
||||||
|
$search_url = $url . $url_suffix . $query . '&maximumRecords=' . $number_of_records; |
||||||
|
$results = drupal_http_request($search_url); |
||||||
|
if ($results->code == '200') { |
||||||
|
$output = roblib_search_passthru_evergreen_parse_results($results, $query); |
||||||
|
} |
||||||
|
else { |
||||||
|
watchdog('roblib_search_evergreen', 'Error retrieving results: %error', ['%error' => $results->status_message], WATCHDOG_ERROR); |
||||||
|
$output = ''; |
||||||
|
} |
||||||
|
return json_encode($output); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
* @param string $results |
||||||
|
* results in marcxml |
||||||
|
* |
||||||
|
* @return array $output |
||||||
|
* information we want from the xml stored in an array |
||||||
|
*/ |
||||||
|
function roblib_search_passthru_evergreen_parse_results($results, $query) { |
||||||
|
$xml = $results->data; |
||||||
|
if (!isset($xml)) { |
||||||
|
return 'no results found'; |
||||||
|
} |
||||||
|
$sxml = simplexml_load_string(trim($results->data)); |
||||||
|
$output = []; |
||||||
|
if ($sxml) { |
||||||
|
$sxml->registerXPathNamespace('marcxml', 'http://www.loc.gov/MARC21/slim'); |
||||||
|
$sxml->registerXPathNamespace('srw', 'http://www.loc.gov/zing/srw/'); |
||||||
|
$number_of_records = $sxml->xpath('//srw:numberOfRecords'); |
||||||
|
$output['numberOfRecords'] = (string) $number_of_records[0]; |
||||||
|
$catalog_base_search_url = 'http://islandpines.roblib.upei.ca/eg/opac/results?qtype=keyword&l=4&d=2&ol=4&tp=&query='; |
||||||
|
$catalog_base_search_url .= $query; |
||||||
|
$output['catalogBaseSearchUrl'] = $catalog_base_search_url; |
||||||
|
} |
||||||
|
return $output; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Implements hook_theme(). |
||||||
|
*/ |
||||||
|
function roblib_search_passthru_theme() { |
||||||
|
// set path |
||||||
|
$path = drupal_get_path('module', 'roblib_search_passthru'); |
||||||
|
$file = 'theme.inc'; |
||||||
|
|
||||||
|
return [ |
||||||
|
// results page |
||||||
|
'roblib_search_passthru' => [ |
||||||
|
'path' => $path . '/theme', |
||||||
|
'file' => $file, |
||||||
|
'template' => 'roblib-search-passthru', |
||||||
|
'variables' => ['results' => NULL], |
||||||
|
], |
||||||
|
]; |
||||||
|
} |
||||||
|
|
||||||
|
function roblib_search_passthru_block_info() { |
||||||
|
|
||||||
|
$blocks['roblib_passthru_results'] = [ |
||||||
|
// info: The name of the block. |
||||||
|
'info' => t('Misc Results'), |
||||||
|
// Block caching options (per role, per user, etc.) |
||||||
|
'cache' => DRUPAL_CACHE_PER_ROLE, |
||||||
|
]; |
||||||
|
|
||||||
|
|
||||||
|
return $blocks; |
||||||
|
} |
||||||
|
|
||||||
|
function roblib_search_passthru_preprocess_panels_pane(&$variables, $hook) { |
||||||
|
if ($variables['pane']->subtype == 'roblib_search_passthru-roblib_passthru_results') { |
||||||
|
$variables['title_prefix'] = '<div class="roblib-search-header roblib-search-passthru-header">'; |
||||||
|
$variables['title_suffix'] = '</div>'; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Implements hook_block_view(). |
||||||
|
*/ |
||||||
|
function roblib_search_passthru_block_view($delta = '') { |
||||||
|
$block = []; |
||||||
|
switch ($delta) { |
||||||
|
case 'roblib_passthru_results': |
||||||
|
$block['subject'] = t('Misc Results'); |
||||||
|
$block['content'] = theme('roblib_search_passthru', ['results' => NULL]); |
||||||
|
break; |
||||||
|
} |
||||||
|
return $block; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* An endpoint for the passthru ajax call |
||||||
|
* |
||||||
|
* @param string $query |
||||||
|
* |
||||||
|
*/ |
||||||
|
function roblib_search_passthru_islandscholar_ajax($query) { |
||||||
|
$output = roblib_search_passthru_get_results($query); |
||||||
|
debug($output, 'pp_passthru_content', TRUE); |
||||||
|
print $output; |
||||||
|
exit(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param $query |
||||||
|
* |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
function roblib_search_passthru_get_search_url($query) { |
||||||
|
$solr_url = variable_get('roblib_search_islandscholar_url', 'http://islandscholar.ca:8080/solr'); |
||||||
|
$num_results = variable_get('roblib_search_islandscholar_num_results', '5'); |
||||||
|
$data = [ |
||||||
|
'wt' => 'json', |
||||||
|
'q' => $query, |
||||||
|
'fq' => variable_get('roblib_search_islandscholar_fq', 'PID:ir* AND (RELS_EXT_hasModel_uri_ms:info\:fedora/ir\:thesisCModel OR RELS_EXT_hasModel_uri_ms:info\:fedora/ir\:citationCModel)'), |
||||||
|
'qf' => variable_get('roblib_search_islandscholar_qf', 'dc.title^2.5 dc.creator^5.0 dc.contributor^2.0 dc.description^2.0 dc.identifier^2.0 dc.type^2.0 catch_all_fields_mt^1.0'), |
||||||
|
'rows' => $num_results, |
||||||
|
'defType' => 'dismax', |
||||||
|
]; |
||||||
|
$url = url($solr_url . '/select', ['query' => $data]); |
||||||
|
return $url; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
* @param string $query |
||||||
|
* |
||||||
|
* @return string |
||||||
|
* json |
||||||
|
*/ |
||||||
|
function roblib_search_passthru_get_results($query) { |
||||||
|
$url = roblib_search_passthru_get_search_url($query); |
||||||
|
$results = drupal_http_request($url); |
||||||
|
if ($results->code != '200') { |
||||||
|
return ""; |
||||||
|
} |
||||||
|
return $results->data; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Implements hook_help(). |
||||||
|
*/ |
||||||
|
function roblib_search_passthru_help($path, $arg) { |
||||||
|
switch ($path) { |
||||||
|
case 'admin/help#roblib_search_passthru': |
||||||
|
return t( |
||||||
|
'<p> |
||||||
|
provides a Passthru target for the Roblib search module |
||||||
|
</p>' |
||||||
|
); |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -1,13 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
/** |
|
||||||
* @file roblib-search-islandscholar.tpl.php |
|
||||||
|
|
||||||
*/ |
|
||||||
?> |
|
||||||
<div class ="roblib-search-more" id="roblib-search-islandscholar-more">Search all Results</div> |
|
||||||
<div class ="roblib-search-content solr-site" id="roblib-search-content-islandscholar"> |
|
||||||
<img src="<?php print (empty($spinner_path) ? ' ' : $spinner_path); ?>"/>
|
|
||||||
</div> |
|
||||||
|
|
||||||
|
|
@ -0,0 +1,15 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
/** |
||||||
|
* @file roblib-search-passthru.tpl.php |
||||||
|
|
||||||
|
*/ |
||||||
|
?> |
||||||
|
|
||||||
|
<div class ="roblib-search-content " id="roblib-search-content-passthru"> |
||||||
|
<img src="<?php print (empty($spinner_path) ? ' ' : $spinner_path); ?>"/>
|
||||||
|
</div> |
||||||
|
<div class ="roblib-passthru-search" id="roblib-search-passthru-islandscholar-more"></div> |
||||||
|
<div class ="roblib-passthru-search" id="roblib-search-passthru-evergreen-more"></div> |
||||||
|
|
||||||
|
|
Loading…
Reference in new issue