| 1 |
<?php |
<?php |
| 2 |
// $Id: apachesolr.module,v 1.1.2.12.2.170 2009/10/26 02:04:12 pwolanin Exp $ |
// $Id: apachesolr.module,v 1.1.2.12.2.171 2009/10/26 19:17:34 robertDouglass Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 115 |
} |
} |
| 116 |
|
|
| 117 |
/** |
/** |
|
* Implementation of hook_requirements(). |
|
|
*/ |
|
|
function apachesolr_requirements($phase) { |
|
|
// Ensure translations don't break at install time |
|
|
$t = get_t(); |
|
|
if ($phase == 'runtime') { |
|
|
$host = variable_get('apachesolr_host', 'localhost'); |
|
|
$port = variable_get('apachesolr_port', 8983); |
|
|
$path = variable_get('apachesolr_path', '/solr'); |
|
|
$ping = FALSE; |
|
|
try { |
|
|
$solr = apachesolr_get_solr(); |
|
|
$ping = @$solr->ping(variable_get('apachesolr_ping_timeout', 4)); |
|
|
// If there is no $solr object, there is no server available, so don't continue. |
|
|
if (!$ping) { |
|
|
throw new Exception(t('No Solr instance available when checking requirements.')); |
|
|
} |
|
|
} |
|
|
catch (Exception $e) { |
|
|
watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); |
|
|
} |
|
|
$value = $ping ? $t('Your site has contacted the Apache Solr server.') : $t('Your site was unable to contact the Apache Solr server.'); |
|
|
$severity = $ping ? 0: 2; |
|
|
$description = theme('item_list', array($t('Host: %host', array('%host' => $host)), |
|
|
$t('Port: %port', array('%port' => $port)), |
|
|
$t('Path: %path', array('%path' => $path)))); |
|
|
$requirements['apachesolr'] = array( |
|
|
'title' => $t('Apache Solr'), |
|
|
'value' => $value, |
|
|
'description' => $description, |
|
|
'severity' => $severity, |
|
|
); |
|
|
return $requirements; |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
| 118 |
* Like $site_key in _update_refresh() - returns a site-specific hash. |
* Like $site_key in _update_refresh() - returns a site-specific hash. |
| 119 |
*/ |
*/ |
| 120 |
function apachesolr_site_hash() { |
function apachesolr_site_hash() { |