|
|
@ -115,7 +115,7 @@ function roblib_search_cufts_theme() { |
|
|
|
'path' => $path . '/theme', |
|
|
|
'path' => $path . '/theme', |
|
|
|
'file' => $file, |
|
|
|
'file' => $file, |
|
|
|
'template' => 'roblib-search-cufts', |
|
|
|
'template' => 'roblib-search-cufts', |
|
|
|
'variables' => array('results' => NULL), |
|
|
|
'variables' => array('result'=>NULL) |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
@ -175,8 +175,22 @@ function roblib_search_cufts_get_results($query = NULL) { |
|
|
|
$url = variable_get('roblib_search_cufts_url', 'http://cufts2.lib.sfu.ca/CJDB/PCU/browse/show?'); |
|
|
|
$url = variable_get('roblib_search_cufts_url', 'http://cufts2.lib.sfu.ca/CJDB/PCU/browse/show?'); |
|
|
|
$url_suffix = variable_get('roblib_search_cufts_search_suffix', 'browse_field=title&search_type=startswith&format=json&search_terms='); |
|
|
|
$url_suffix = variable_get('roblib_search_cufts_search_suffix', 'browse_field=title&search_type=startswith&format=json&search_terms='); |
|
|
|
$number_of_records = variable_get('roblib_search_cufts_num_results', '5'); |
|
|
|
$number_of_records = variable_get('roblib_search_cufts_num_results', '5'); |
|
|
|
$search_url = $url . $url_suffix . '"' . $query . '"' . '&submit=Search&per_page='.$number_of_records; |
|
|
|
$search_url = $url . $url_suffix . $query . '&submit=Search'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//get the total number of result |
|
|
|
|
|
|
|
$results = drupal_http_request($search_url); |
|
|
|
|
|
|
|
if ($results->code == '200') { |
|
|
|
|
|
|
|
$output = $results->data; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
$output = $results->status_message; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$start_index = strpos($output,'"total_count":')+ strlen('"total_count":'); |
|
|
|
|
|
|
|
$end_index = strlen($output)-1; |
|
|
|
|
|
|
|
$length=$end_index-$start_index; |
|
|
|
|
|
|
|
$num_of_result = substr($output,$start_index,$length); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$search_url = $search_url . '&per_page='.$number_of_records; |
|
|
|
$results = drupal_http_request($search_url); |
|
|
|
$results = drupal_http_request($search_url); |
|
|
|
|
|
|
|
|
|
|
|
if ($results->code == '200') { |
|
|
|
if ($results->code == '200') { |
|
|
@ -185,7 +199,9 @@ function roblib_search_cufts_get_results($query = NULL) { |
|
|
|
else { |
|
|
|
else { |
|
|
|
$output = $results->status_message; |
|
|
|
$output = $results->status_message; |
|
|
|
} |
|
|
|
} |
|
|
|
return $output; |
|
|
|
|
|
|
|
|
|
|
|
$output = str_replace('"total_count":', '"numOfResults":'.$num_of_result.',"total_count":',$output); |
|
|
|
|
|
|
|
return $output; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|