Skip to content
Snippets Groups Projects
Commit 7cb4d6e4 authored by Kevin Abel's avatar Kevin Abel
Browse files

Add methods to UNL_Search class to support more config

Also pulls bootstrap logic into class methods.
parent b6f1bc4a
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,10 @@ class UNL_Search
* @var array
*/
public static $jsapiKeys = array();
public static $mode = 'production';
public static $linkedCSEServer = 'http://www1.unl.edu/search/linkedcse/';
function __construct()
{
......@@ -49,13 +53,36 @@ class UNL_Search
}
return $html;
}
/**
* Returns a UNL_Templates_Scanner of the given URL or false on failure
*
* @param string $referrer
* @return boolean|UNL_Templates_Scanner
*/
public static function getScannedPage($referrer)
{
if ($referrer == 'http://www.unl.edu' ||
!preg_match('/^https?/', $referrer) ||
!filter_var($referrer, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED)
) {
return false;
}
$scanned = @file_get_contents($referrer);
if (!$scanned) {
return false;
}
return new UNL_Templates_Scanner($scanned);
}
/**
* Return an API key
*
* @return string
*/
function getJSAPIKey()
public static function getJSAPIKey()
{
if (empty(self::$jsapiKeys)) {
return '';
......@@ -65,4 +92,8 @@ class UNL_Search
return self::$jsapiKeys[0];
}
public static function getLinkedCSEUrl($referrer)
{
return self::$linkedCSEServer . '?u=' . urlencode($referrer);
}
}
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