Browse Source

limited islandscholar results with same filters as scholar

2.x-ebsco
Paul Pound 11 years ago
parent
commit
6a2af09980
  1. 32
      targets/islandscholar/js/islandscholar_results.js
  2. 35
      targets/islandscholar/roblib_search_islandscholar.module
  3. 8
      targets/islandscholar/theme/roblib-search-islandscholar.tpl.php

32
targets/islandscholar/js/islandscholar_results.js

@ -88,36 +88,18 @@ Drupal.behaviors.roblib_search_islandscholar = {
items.push('</div>');
});
var number = parseInt(data.rows);
jQuery('#roblib-search-content-islandscholar').empty().append(items.join(''));
var number = data.response.numFound;
var query = encodeURIComponent(data.responseHeader.params.q);//.'milk';
var scholarUrl = "http://www.islandscholar.ca/islandora/solr/search/"
jQuery('#roblib-search-islandscholar-more').empty().append('<a id="islandscholar-see-more-result"' +
' href="http://www.islandscholar.ca/islandora/solr/search/' + query + '">see all ' + number + ' results</a>');
items = showMoreItems(items, number);
//items = showMoreItems(items, number);
}
});
}
}
function showMoreItems(items, number) {
for (var i = 0; i < number; i++) {
jQuery('#' + 'roblib-search-content-solr-site').append(items.pop());
}
if (items.length > 0)
{
jQuery('#roblib-search-solr-site-more').empty().append('<a id="islandscholar_see_more_result">see ' + items.length + ' more results</a>');
jQuery('#see_more_result').click(function() {
items = showMoreItems(items, number);
});
}
else
{
jQuery('#roblib-search-solr-site-more').empty().append('no more results');
}
return items;
}

35
targets/islandscholar/roblib_search_islandscholar.module

@ -98,6 +98,9 @@ function roblib_search_islandscholar_block_info() {
return $blocks;
}
/**
* Implements hook_block_view().
*/
function roblib_search_islandscholar_block_view($delta = '') {
//The $delta parameter tells us which block is being requested.
switch ($delta) {
@ -109,6 +112,12 @@ function roblib_search_islandscholar_block_view($delta = '') {
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;
@ -116,28 +125,36 @@ function roblib_search_islandscholar_ajax($query) {
}
/**
*
* @param string $query
* @param $query
* @return string
* json
*/
function roblib_search_islandscholar_get_results($query) {
function roblib_search_islandscholar_get_search_url($query){
$solr_url = variable_get('roblib_search_islandscholar_url', 'http://localhost:8983/solr');
//$query = $solr_url . '/select?wt=json&q=test page';
$num_results = variable_get('roblib_search_islandscholar_num_results', '5');
$data = array(
'wt' => 'json',
'q' => $query,
'fq' => 'PID:ir*',
'q' => $query ,
'fq' => 'PID:ir* AND (rels.hasModel:info\:fedora/islandora\:thesisCModel OR rels.hasModel:info\:fedora/islandora\:citationCModel)',
'qf' => 'mods.title^3.0 mods.subTitle^2.5 mods.author^5.0 mods.department^2.0 mods.abstract^1.5 dc.title^2.5 mods.subject^1.5 dc.creator^5.0 dc.contributor^2.0 dc.description^2.0 mods.genre^1.0 mods.hostTitle^2.0 mods.issn^1.0 mods.date^2.0 pdf.text^2.0 dsm.PDF^2.0 collection_title^1.0',
'rows' => $num_results,
);
$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 "";
}
$temp = substr($results->data, 1);
//$out = '{"rows":"' . $num_results . '",' . $results->data;
return $results->data;
}

8
targets/islandscholar/theme/roblib-search-islandscholar.tpl.php

@ -16,9 +16,9 @@
* @see template_preprocess_roblib_search_wrapper()
*/
?>
<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); ?>"/>
<img src="<?php print (empty($spinner_path) ? ' ' : $spinner_path); ?>"/>
</div>
<div class ="roblib-search-more" id="roblib-search-solr-site-more">Search all Results</div>

Loading…
Cancel
Save