| 1 |
<?php |
<?php |
| 2 |
// $Id: xapian.module,v 1.10.2.8 2009/02/06 18:27:05 jeremy Exp $ |
// $Id: xapian.module,v 1.10.2.9 2009/04/01 13:12:42 jeremy Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 395 |
try { |
try { |
| 396 |
$database_type = variable_get('xapian_database_type', XAPIAN_LOCAL); |
$database_type = variable_get('xapian_database_type', XAPIAN_LOCAL); |
| 397 |
|
|
| 398 |
if ($database_type == XAPIAN_LOCAL) { // Local database |
switch ($database_type) { |
|
$database_path = variable_get('xapian_database_path', NULL); |
|
| 399 |
|
|
| 400 |
if (empty($database_path)) { |
case XAPIAN_LOCAL: |
| 401 |
watchdog('xapian', 'No database path given.'); |
$database_path = variable_get('xapian_database_path', NULL); |
| 402 |
return NULL; |
if (empty($database_path)) { |
| 403 |
} |
watchdog('xapian', 'No database path given.'); |
| 404 |
|
return NULL; |
| 405 |
$db_source = $database_path; |
} |
| 406 |
} |
$db_source = $database_path; |
| 407 |
elseif ($database_type == XAPIAN_REMOTE) { |
if ($writable) { |
| 408 |
$database_host = variable_get('xapian_database_hostname', ''); |
$writable_database = new XapianWritableDatabase($db_source, Xapian::DB_CREATE_OR_OPEN); |
| 409 |
$database_port = variable_get('xapian_database_port', 6431); |
return $writable_database; |
| 410 |
|
} |
| 411 |
if (empty($database_host)) { |
else { |
| 412 |
watchdog('xapian', 'No database host given.'); |
$database = new XapianDatabase($db_source); |
| 413 |
return NULL; |
return $database; |
| 414 |
} |
} |
| 415 |
|
break; |
| 416 |
|
|
| 417 |
$db_source = Xapian::remote_open($database_host, (int)$database_port); |
case XAPIAN_REMOTE: |
| 418 |
} |
$database_host = variable_get('xapian_database_hostname', ''); |
| 419 |
|
$database_port = variable_get('xapian_database_port', 6431); |
| 420 |
|
|
| 421 |
|
if (empty($database_host)) { |
| 422 |
|
watchdog('xapian', 'No database host has been configured, unable to connect to remote database.'); |
| 423 |
|
return NULL; |
| 424 |
|
} |
| 425 |
|
if ($writable) { |
| 426 |
|
$writable_database = Xapian::remote_open_writable($database_host, (int)$database_port); |
| 427 |
|
return $writable_database; |
| 428 |
|
} |
| 429 |
|
else { |
| 430 |
|
$db_source = Xapian::remote_open($database_host, (int)$database_port); |
| 431 |
|
$database = new XapianDatabase($db_source); |
| 432 |
|
return $database; |
| 433 |
|
} |
| 434 |
|
break; |
| 435 |
|
|
|
if ($writable) { |
|
|
$writable_database = new XapianWritableDatabase($db_source, Xapian::DB_CREATE_OR_OPEN); |
|
|
return $writable_database; |
|
|
} |
|
|
else { |
|
|
$database = new XapianDatabase($db_source); |
|
|
return $database; |
|
| 436 |
} |
} |
| 437 |
} |
} |
| 438 |
catch (Exception $e) { |
catch (Exception $e) { |