Skip to content
Snippets Groups Projects
Commit 7958a4ac authored by Brett Bieber's avatar Brett Bieber
Browse files

Allow a cx google custom search engine ID to be specified.

parent 91f054d5
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@ if (isset($_GET['u'])
&& preg_match('/^https?/', $_GET['u'])
&& filter_var($_GET['u'], FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED)
&& $scanned = @file_get_contents($_GET['u'])) {
// Add local site search results
$scanned = new UNL_Templates_Scanner($scanned);
if (isset($scanned->navlinks)) {
require_once 'HTMLPurifier.auto.php';
......@@ -36,10 +37,17 @@ if (isset($_GET['u'])
$page->contactinfo = $purifier->purify($scanned->contactinfo);
}
}
$context = 'http://www1.unl.edu/search/linkedcse/?u='.$_GET['u'];
if (isset($_GET['cx'])) {
// Use their custom search engine instead of the linked one.
$context = '"'.htmlentities($_GET['cx']).'"';
} else {
// Auto-build a custom search engine
$context = '{crefUrl :"http://www1.unl.edu/search/linkedcse/?u='.$_GET['u'].'"}';
}
$page->addScriptDeclaration('
UNL_Search.do_local_search = true;
UNL_Search.local_search_context = "'.$context.'";
UNL_Search.local_search_context = '.$context.';
');
$local_results = '
<h3 class="sec_header">Local Results</h3>
......
......@@ -34,7 +34,7 @@ function searchInit() {
UNL_Search.local_search = new google.search.WebSearch();
//Apply the Custom Search Engine
UNL_Search.local_search.setSiteRestriction({crefUrl : UNL_Search.local_search_context});
UNL_Search.local_search.setSiteRestriction(UNL_Search.local_search_context);
//UNL_Search.local_search.setSiteRestriction('000150017203523626721:-1etga1qfci');
UNL_Search.local_search.setResultSetSize(GSearch.SMALL_RESULTSET)
UNL_Search.local_search.setSearchCompleteCallback(UNL_Search, UNL_Search.handleLocalResults)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment