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
Branches
No related tags found
1 merge request!1WDN 4.0 Theme
...@@ -8,6 +8,10 @@ class UNL_Search ...@@ -8,6 +8,10 @@ class UNL_Search
*/ */
public static $jsapiKeys = array(); public static $jsapiKeys = array();
public static $mode = 'production';
public static $linkedCSEServer = 'http://www1.unl.edu/search/linkedcse/';
function __construct() function __construct()
{ {
...@@ -50,12 +54,35 @@ class UNL_Search ...@@ -50,12 +54,35 @@ class UNL_Search
return $html; 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 an API key
* *
* @return string * @return string
*/ */
function getJSAPIKey() public static function getJSAPIKey()
{ {
if (empty(self::$jsapiKeys)) { if (empty(self::$jsapiKeys)) {
return ''; return '';
...@@ -65,4 +92,8 @@ class UNL_Search ...@@ -65,4 +92,8 @@ class UNL_Search
return self::$jsapiKeys[0]; 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.
Please register or to comment