|
|
@ -98,6 +98,9 @@ function roblib_search_islandscholar_block_info() { |
|
|
|
return $blocks; |
|
|
|
return $blocks; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Implements hook_block_view(). |
|
|
|
|
|
|
|
*/ |
|
|
|
function roblib_search_islandscholar_block_view($delta = '') { |
|
|
|
function roblib_search_islandscholar_block_view($delta = '') { |
|
|
|
//The $delta parameter tells us which block is being requested. |
|
|
|
//The $delta parameter tells us which block is being requested. |
|
|
|
switch ($delta) { |
|
|
|
switch ($delta) { |
|
|
@ -109,6 +112,12 @@ function roblib_search_islandscholar_block_view($delta = '') { |
|
|
|
return $block; |
|
|
|
return $block; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* An endpoint for the islandscholar ajax call |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param string $query |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
*/ |
|
|
|
function roblib_search_islandscholar_ajax($query) { |
|
|
|
function roblib_search_islandscholar_ajax($query) { |
|
|
|
$output = roblib_search_islandscholar_get_results($query); |
|
|
|
$output = roblib_search_islandscholar_get_results($query); |
|
|
|
print $output; |
|
|
|
print $output; |
|
|
@ -116,28 +125,36 @@ function roblib_search_islandscholar_ajax($query) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* |
|
|
|
* @param $query |
|
|
|
* @param string $query |
|
|
|
|
|
|
|
* @return string |
|
|
|
* @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'); |
|
|
|
$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'); |
|
|
|
$num_results = variable_get('roblib_search_islandscholar_num_results', '5'); |
|
|
|
$data = array( |
|
|
|
$data = array( |
|
|
|
'wt' => 'json', |
|
|
|
'wt' => 'json', |
|
|
|
'q' => $query, |
|
|
|
'q' => $query , |
|
|
|
'fq' => 'PID:ir*', |
|
|
|
'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, |
|
|
|
'rows' => $num_results, |
|
|
|
); |
|
|
|
); |
|
|
|
$url = url($solr_url . '/select', array('query' => $data)); |
|
|
|
$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); |
|
|
|
$results = drupal_http_request($url); |
|
|
|
if($results->code != '200'){ |
|
|
|
if($results->code != '200'){ |
|
|
|
return ""; |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} |
|
|
|
$temp = substr($results->data, 1); |
|
|
|
|
|
|
|
//$out = '{"rows":"' . $num_results . '",' . $results->data; |
|
|
|
|
|
|
|
return $results->data; |
|
|
|
return $results->data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|