|
|
|
@ -85,7 +85,7 @@ function roblib_search_solr_site_theme() {
|
|
|
|
|
'roblib_search_solr_site' => array( |
|
|
|
|
'path' => $path . '/theme', |
|
|
|
|
'file' => $file, |
|
|
|
|
'template' => 'roblib-search-solr_site', |
|
|
|
|
'template' => 'roblib-search-solr-site', |
|
|
|
|
'variables' => array('results' => NULL), |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
@ -110,7 +110,7 @@ function roblib_search_solr_site_block_view($delta = '') {
|
|
|
|
|
// 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('Site Results'); |
|
|
|
|
$block['subject'] = t('Library Website'); |
|
|
|
|
// The content of the block is typically generated by calling a custom |
|
|
|
|
// function. |
|
|
|
|
$block['content'] = theme('roblib_search_solr_site', array('results' => NULL)); |
|
|
|
@ -132,21 +132,28 @@ function roblib_search_solr_site_ajax($query) {
|
|
|
|
|
* json |
|
|
|
|
*/ |
|
|
|
|
function roblib_search_solr_site_get_results($query) { |
|
|
|
|
$url = roblib_search_solr_site_get_search_url($query); |
|
|
|
|
$results = drupal_http_request($url); |
|
|
|
|
if($results->code != '200'){ |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
return $results->data; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param $query |
|
|
|
|
* @return string |
|
|
|
|
*/ |
|
|
|
|
function roblib_search_solr_site_get_search_url($query){ |
|
|
|
|
$solr_url = variable_get('roblib_search_solr_site_url', 'http://localhost:8983/solr'); |
|
|
|
|
//$query = $solr_url . '/select?wt=json&q=test page'; |
|
|
|
|
$num_results = variable_get('roblib_search_solr_site_num_results', '5'); |
|
|
|
|
$data = array( |
|
|
|
|
'wt' => 'json', |
|
|
|
|
'q' => $query, |
|
|
|
|
'q' => $query , |
|
|
|
|
'rows' => $num_results, |
|
|
|
|
); |
|
|
|
|
$url = url($solr_url . '/select', array('query' => $data)); |
|
|
|
|
$results = drupal_http_request($url); |
|
|
|
|
if($results->code != '200'){ |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
$temp = substr($results->data, 1); |
|
|
|
|
//$out = '{"rows":"' . $num_results . '",' . $results->data; |
|
|
|
|
return $results->data; |
|
|
|
|
return $url; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|