Open mzarafon opened 7 years ago
From previous Drupal project: `<?php //section header echo "
//get current url to find out what the user searched $url = $_SERVER["REQUEST_URI"]; $index1 = strpos($url, "site/") + 5; $index2 = strpos($url, "?"); if($index2 === false){ $query = substr($url , $index1 ); }else{ $query = substr($url , $index1 , $index2-$index1 ); }
//Narrow Scope to Just AQSI Statements
//Open Search does everything in D-Space
//convert weird character codes like '&' and spaces into the right code for Dspace $query = str_replace("%25", "%", $query ); $more_url = "https://scholarship.tricolib.brynmawr.edu/open-search/discover?query=" . $query . "&scope=10066/4022&order=DESC&rpp=20&sort_by=0&page=1&etal=0"; echo "
//Open Search feed for DSpace $feed_url = "https://scholarship.tricolib.brynmawr.edu/open-search/discover?query=" . $query . "&format=rss&rpp=100&scope=10066/4022";
// Debugging code for OpenSearch queries to make sure the API call is formatted correctly -Mike Z//
// echo "
// End debugging code //
//get the xml file associated with that search
//this will have all the data including title, link, and description
//we will format this file to full the full text search with data $data = file_get_contents($feed_url);
//get rid of the extra tags at the top of the document
//this is extra information about the feed that we don't need
$header_index = strpos($data, "
//get each individual entry, so we can go through it one at a time in our for loop
$array = explode("
//formatting to match regular searches echo "<ol class=\"search-results apachesolr_search-results\">";
//first one is empty not sure why, but there's no data there, so we'll skip it
//the first statement starts at index 1 for ($i=1; $i<$len; $i++){ //Statement Title $index1 = strpos($array[$i], "
The API call looks like this:
https://scholarship.tricolib.brynmawr.edu/open-search/discover?query=" . $query . "&scope=10066/4022&order=DESC&rpp=20&sort_by=0&page=1&etal=0
Where $query is the search query