class DrupalGoogleMini in Google Search Appliance 6.2
Same name and namespace in other branches
- 5 DrupalGoogleMini.php \DrupalGoogleMini
Hierarchy
- class \GoogleMini
- class \DrupalGoogleMini
Expanded class hierarchy of DrupalGoogleMini
File
- ./
DrupalGoogleMini.php, line 7
View source
class DrupalGoogleMini extends GoogleMini {
var $cache = FALSE;
function __construct($debug = FALSE, $debug_callback = NULL) {
parent::__construct($debug, $debug_callback);
}
function log($message = NULL) {
if ($this->debug_callback) {
$callback = $this->debug_callback;
call_user_func($callback, $message);
}
watchdog("google_appliance", $message);
}
function getQueryParts() {
return $this->_queryParts;
}
function query($iteratorClass = 'GoogleMiniResultIterator') {
if (!db_table_exists('cache_google_appliance')) {
$this->cache = FALSE;
}
if (!$this->cache) {
return parent::query($iteratorClass);
}
else {
$cached_result_obj = NULL;
$cache_key = md5($this
->buildQuery());
$_cached_result_xml = cache_get($cache_key, 'cache_google_appliance');
$cached_result_xml = $_cached_result_xml->data;
$google_debug = variable_get('google_appliance_debug', 0);
if ($cached_result_xml) {
try {
$google_results = GoogleMini::resultFactory($cached_result_xml, $iteratorClass);
} catch (Exception $e) {
drupal_set_message($e
->getMessage(), 'error');
watchdog('google_appliance', $e
->getMessage());
return FALSE;
}
if ($google_debug >= 2) {
if (function_exists('dpr')) {
dpr("got cache for {$cache_key}");
}
}
elseif ($google_debug == 1) {
watchdog('google_appliance', "got cache for !cache_key at !url", array(
'!cache_key' => $cache_key,
'!url' => $_GET['q'],
));
}
}
else {
try {
$google_results = parent::query($iteratorClass);
} catch (Exception $e) {
drupal_set_message($e
->getMessage(), 'error');
watchdog('google_appliance', $e
->getMessage());
return FALSE;
}
$timeout = variable_get('google_appliance_cache_timeout', 600);
// 10 minutes by default
cache_set($cache_key, $google_results->payload
->asXML(), 'cache_google_appliance', time() + $timeout);
$google_debug = variable_get('google_debug', 0);
if ($google_debug >= 2) {
if (function_exists('dpr')) {
dpr("setting cache for {$cache_key}");
}
}
elseif ($google_debug == 1) {
watchdog('google_appliance', "setting cache for !cache_key at !url", array(
'!cache_key' => $cache_key,
'!url' => $_GET['q'],
));
}
}
return $google_results;
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalGoogleMini:: |
property | |||
DrupalGoogleMini:: |
function | |||
DrupalGoogleMini:: |
function |
Overrides GoogleMini:: |
||
DrupalGoogleMini:: |
function |
Overrides GoogleMini:: |
||
DrupalGoogleMini:: |
function |
Overrides GoogleMini:: |
||
GoogleMini:: |
public | property | ||
GoogleMini:: |
public | property | ||
GoogleMini:: |
public | property | ||
GoogleMini:: |
private | property | ||
GoogleMini:: |
protected | property | ||
GoogleMini:: |
public | function | Adds a meta data filter to the query. Currently has limited flexibility. Pass a key as a meta field and values as an array of values to be OR'd together. or you can pass a value as a string to be the only value (for ease of use). | |
GoogleMini:: |
public | function | Fires the query to google | |
GoogleMini:: |
public | function | Helper function, returns a pre-assigned query part. | |
GoogleMini:: |
function | |||
GoogleMini:: |
public | function | Creates a date filter | |
GoogleMini:: |
public | function | Sets sorting type (date or relevancy) and direction | |
GoogleMini:: |
public | function | Adds a site restriction. Useful if just querying by date, as that won't work unless you search for words or at least one other keyword search. | |
GoogleMini:: |
public | function | Set the encoding for data going into the search | |
GoogleMini:: |
public | function | Set the keywords used for keyword search | |
GoogleMini:: |
public | function | Sets the languages to be used in the search, if none specified, searches all languages | |
GoogleMini:: |
public | function | Set fields to show in results. For all fields, send an asterisk (*) | |
GoogleMini:: |
public | function | Set the encoding for data coming out of the search | |
GoogleMini:: |
public | function | Set page of result set to be shown and sets number of results per page | |
GoogleMini:: |
public | function | Helper function, just builds the array for processing, may have validation later. |