diff --git a/src/UNL/Search.php b/src/UNL/Search.php index 5b0ad20bde5743ca8ebf51ec595416556786765e..1f718e6c1ce6da30afb6cbc6038e9286927fe421 100644 --- a/src/UNL/Search.php +++ b/src/UNL/Search.php @@ -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); + } }