[svn r21519] minor - logic changes - allow see human message error - (partial FS#4346)

skala
Isaac Flores 16 years ago
parent 1eb4931462
commit cd11f01812
  1. 33
      main/inc/lib/search/DokeosQuery.php
  2. 36
      main/inc/lib/search/xapian/XapianQuery.php

@ -38,22 +38,25 @@ function dokeos_get_boolean_query($term) {
function dokeos_preprocess_results($results) {
// group by toolid
$results_by_tool = array();
foreach ($results as $key => $row) {
$results_by_tool[$row['toolid']][] = $row;
if (count($results)>0) {
foreach ($results as $key => $row) {
$results_by_tool[$row['toolid']][] = $row;
}
$processed_results = array();
foreach ($results_by_tool as $toolid => $rows) {
$tool_processor_class = $toolid .'_processor';
$tool_processor_path = api_get_path(LIBRARY_PATH) .'search/tool_processors/'. $tool_processor_class .'.class.php';
if (file_exists($tool_processor_path)) {
require_once($tool_processor_path);
$tool_processor = new $tool_processor_class($rows);
$processed_results = array_merge($tool_processor->process(), $processed_results);
}
}
return array(count($processed_results), $processed_results);
}
$processed_results = array();
foreach ($results_by_tool as $toolid => $rows) {
$tool_processor_class = $toolid .'_processor';
$tool_processor_path = api_get_path(LIBRARY_PATH) .'search/tool_processors/'. $tool_processor_class .'.class.php';
if (file_exists($tool_processor_path)) {
require_once($tool_processor_path);
$tool_processor = new $tool_processor_class($rows);
$processed_results = array_merge($tool_processor->process(), $processed_results);
}
}
return array(count($processed_results), $processed_results);
}
/**

@ -105,8 +105,8 @@ function xapian_query($query_string, $db = NULL, $start = 0, $length = 10,
return array($count, $results);
}
catch (Exception $e) {
Display::display_error_message('xapian error message: '. $e->getMessage());
return NULL;
display_xapian_error($e->getMessage());
return NULL;
}
}
@ -149,7 +149,7 @@ function xapian_get_all_terms($count=0, $prefix, $db=NULL) {
return $terms;
}
catch (Exception $e) {
Display::display_error_message('xapian error message: '. $e->getMessage());
display_xapian_error($e->getMessage());
return NULL;
}
}
@ -183,7 +183,7 @@ function xapian_get_doc_terms($doc=NULL, $prefix) {
return $terms;
}
catch (Exception $e) {
Display::display_error_message('xapian error message: '. $e->getMessage());
display_xapian_error($e->getMessage());
return NULL;
}
}
@ -218,4 +218,32 @@ function xapian_join_queries($query1, $query2=NULL, $op='or') {
return new XapianQuery($op, array_merge($query1, $query2));
}
/**
* @author Isaac flores paz <florespaz@bidsoftperu.com>
* @param String The xapian error message
* @return String The dokeos error message
*/
function display_xapian_error($xapian_error_message) {
$message=explode(':',$xapian_error_message);
$type_error_message=$message[0];
if ($type_error_message=='DatabaseOpeningError') {
$message_error=get_lang('SearchDatabaseOpeningError');
} elseif ($type_error_message=='DatabaseVersionError') {
$message_error=get_lang('SearchDatabaseVersionError');
} elseif ($type_error_message=='DatabaseModifiedError') {
$message_error=get_lang('SearchDatabaseModifiedError');
} elseif ($type_error_message=='DatabaseLockError') {
$message_error=get_lang('SearchDatabaseLockError');
} elseif ($type_error_message=='DatabaseCreateError') {
$message_error=get_lang('SearchDatabaseCreateError');
} elseif ($type_error_message=='DatabaseCorruptError') {
$message_error=get_lang('SearchDatabaseCorruptError');
} elseif ($type_error_message=='NetworkTimeoutError') {
$message_error=get_lang('SearchNetworkTimeoutError');
} else {
$message_error=get_lang('SearchOtherXapianError');
}
$display_message=get_lang('Error').' : '. $message_error;
Display::display_error_message($display_message);
}
?>

Loading…
Cancel
Save