Added a better results page.

This commit is contained in:
2022-04-28 13:48:44 -05:00
parent 8db2ab19f2
commit f050a4d31d
3 changed files with 234 additions and 40 deletions

View File

@ -1,67 +1,65 @@
<?php
$url = $_POST['url'];
$ctx = $_POST['ctx'];
$keywords = $_POST['keywords'];
// Variable intake and sanitization
$incomingurl = $_POST['url'];
$url = filter_var($incomingurl, FILTER_SANITIZE_URL);
$incomingctx = $_POST['ctx'];
$ctx = filter_var($incomingctx, FILTER_SANITIZE_STRING);
$incomingkeywords = $_POST['keywords'];
$keywords = filter_var($incomingkeywords, FILTER_SANITIZE_STRING);
$language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
$title = $_POST['title'];
$incomingtitle = $_POST['title'];
$title = filter_var($incomingtitle, FILTER_SANITIZE_STRING);
$incomingsubject= $_POST['subject'];
$subject = filter_var($incomingsubject, FILTER_SANITIZE_STRING);
$incomingauthor = $_POST['author'];
$author = filter_var($incomingauthor, FILTER_SANITIZE_STRING);
// Global variables used for URL construction
$searchprefix = "/search/searchresults.aspx?ctx=";
$searchmiddle = "&type=Boolean&term=";
$searchsuffix = "&sort=RELEVANCE&limit=&query=&page=0";
$searchjoiner = "%20and%20";
// Display posted variables
echo '<strong>URL:</strong> '.$url.'<br />';
echo '<strong>CTX:</strong> '.$ctx.'<br />';
echo '<strong>Keyword(s):</strong> '.$keywords.'<br />';
echo '<strong>Langauge:</strong> '.$language.'<br />';
echo '<strong>Title:</strong> '.$title.'<br />';
echo '<strong>Author:</strong> '.$author.'<br />';
echo '<strong>Subjects:</strong> '.$subject.'<br />';
echo '<strong>Langauge:</strong> '.$language.'<br />';
// Check for data
// Begin building the URL
// Langauge selection starts the URL
$la = 'la='.$language;
if (!empty($keywords)) {
$kw = 'kw='.$keywords;
$kw = $searchjoiner.'kw='.$keywords;
}
if (!empty($subject)) {
$su = $searchjoiner.'su='.$subject;
}
if (!empty($author)) {
$au = $searchjoiner.'au='.$author;
}
// Title status determines end of URL
if (!empty($title)) {
$urlend = $searchjoiner.'ti='.$title.$searchsuffix;
} else {
$urlend = $searchsuffix;
}
echo '<h3>Constructed link</h3>';
// Display the Search link
echo '<h3>Your Deep Link is:</h3>';
//echo $url.'/'.$ctx.'/';
// $address = implode(", ", array_filter(array($addressline1, $addressline2, $addressline3));
$SearchURL = implode("", array_filter(array($url, $searchprefix, $ctx, $searchmiddle, $la, $searchjoiner, $kw, $urlend)));
$SearchURL = implode("", array_filter(array($url, $searchprefix, $ctx, $searchmiddle, $la, $au, $kw, $su, $urlend)));
echo '<a href="'.$SearchURL.'">'.$SearchURL.'</a><br /><br />';
$ConstructedURL = $url.$searchprefix.$ctx.$searchmiddle.$kw.'%20and%20la='.$language.$searchsuffix;
echo '<a href="'.$ConstructedURL.'">'.$ConstructedURL.'</a>';
// https://ccs.polarislibrary.com/polaris/search/searchresults.aspx?ctx=14.1033.0.0.35&type=Boolean&term=COL=YOTHER%20and%20MAT=KIT%20and%20LA=POL%20and%20GENRE=games&sort=RELEVANCE&page=0
// https://escondido.librarycatalog.info/polaris/search/searchresults.aspx?ctx=3.1033.0.0.6&type=Boolean&term=kw=batgirl
/*
Search for:
* Keyword
* Title
* Author
* Language
* Subject Heading
* Collection Code
* Material Type
* ISBN
*/
?>