function apachesolr_status_page in Apache Solr Search 7
Same name and namespace in other branches
- 8 apachesolr.admin.inc \apachesolr_status_page()
- 6.3 apachesolr.admin.inc \apachesolr_status_page()
Gets information about the fields already in solr index.
Parameters
array $environment: The environment for which we need to ask the status from
Return value
array page render array
1 string reference to 'apachesolr_status_page'
- apachesolr_menu in ./
apachesolr.module - Implements hook_menu().
File
- ./
apachesolr.admin.inc, line 546 - Administrative pages for the Apache Solr framework.
Code
function apachesolr_status_page($environment = array()) {
if (empty($environment)) {
$env_id = apachesolr_default_environment();
$environment = apachesolr_environment_load($env_id);
}
else {
$env_id = $environment['env_id'];
}
// Check for availability
if (!apachesolr_server_status($environment['url'], $environment['service_class'])) {
drupal_set_message(t('The server seems to be unavailable. Please verify the server settings at the <a href="!settings_page">settings page</a>', array(
'!settings_page' => url("admin/config/search/apachesolr/settings/{$environment['env_id']}/edit", array(
'query' => drupal_get_destination(),
)),
)), 'warning');
return '';
}
try {
$solr = apachesolr_get_solr($environment["env_id"]);
$solr
->clearCache();
$data = $solr
->getLuke();
} catch (Exception $e) {
apachesolr_log_exception($environment['env_id'], $e);
drupal_set_message(nl2br(check_plain($e
->getMessage())), "warning");
$data = new stdClass();
$data->fields = array();
}
$messages = array();
if (isset($data->index->numDocs)) {
try {
// Collect the stats
$stats_summary = $solr
->getStatsSummary();
module_load_include('inc', 'apachesolr', 'apachesolr.index');
$status = apachesolr_index_status($environment["env_id"]);
// We need a schema version greater than beta3. This is mostly to catch
// people using the Drupal 6 schema.
if (preg_match('/^drupal-[13]/', $stats_summary['@schema_version'])) {
$minimum = 'drupal-3.0-beta4';
if (version_compare($stats_summary['@schema_version'], $minimum, '<')) {
drupal_set_message(t('Your schema.xml version is too old. You must update it to at least %minimum and re-index your content.', array(
'%minimum' => $minimum,
)), 'error');
}
}
$pending_msg = $stats_summary['@pending_docs'] ? t('(@pending_docs sent but not yet processed)', $stats_summary) : '';
$index_msg = $stats_summary['@index_size'] ? t('(@index_size on disk)', $stats_summary) : '';
$indexed_message = t('@num Items !pending !index_msg', array(
'@num' => $data->index->numDocs,
'!pending' => $pending_msg,
'!index_msg' => $index_msg,
));
$messages[] = array(
t('Indexed'),
$indexed_message,
);
$remaining_message = t('@items (@percentage% has been sent to the server)', array(
'@items' => format_plural($status['remaining'], t('1 item'), t('@count items')),
'@percentage' => (int) min(100, 100 * ($status['total'] - $status['remaining']) / max(1, $status['total'])),
));
$messages[] = array(
t('Remaining'),
$remaining_message,
);
$messages[] = array(
t('Schema'),
t('@schema_version', $stats_summary),
);
if (!empty($stats_summary['@core_name'])) {
$messages[] = array(
t('Solr Core Name'),
t('@core_name', $stats_summary),
);
}
$messages[] = array(
t('Delay'),
t('@autocommit_time before updates are processed.', $stats_summary),
);
$messages[] = array(
t('Pending Deletions'),
t('@deletes_total', $stats_summary),
);
} catch (Exception $e) {
apachesolr_log_exception($environment['env_id'], $e);
}
}
if (empty($messages)) {
$messages[] = array(
t('Error'),
t('No data was returned from the server. Check your log messages.'),
);
}
// Initializes output with information about which server's setting we are
// editing, as it is otherwise not transparent to the end user.
$output['apachesolr_index_action_status'] = array(
'#prefix' => '<h3>' . t('@environment: Search Index Content', array(
'@environment' => $environment['name'],
)) . '</h3>',
'#theme' => 'table',
'#header' => array(
t('Type'),
t('Value'),
),
'#rows' => $messages,
);
$output['viewmore'] = array(
'#markup' => l(t('View more details on the search index contents'), 'admin/reports/apachesolr'),
);
$write_status = apachesolr_environment_variable_get($env_id, 'apachesolr_read_only', APACHESOLR_READ_WRITE);
if ($write_status == APACHESOLR_READ_WRITE) {
$output['index_action_form'] = drupal_get_form('apachesolr_index_action_form', $env_id);
$output['index_config_form'] = drupal_get_form('apachesolr_index_config_form', $env_id);
}
else {
drupal_set_message(t('Options for deleting and re-indexing are not available because the index is read-only. This can be changed on the <a href="!settings_page">settings page</a>', array(
'!settings_page' => url('admin/config/search/apachesolr/settings/' . $env_id . '/edit', array(
'query' => drupal_get_destination(),
)),
)), 'warning');
}
return $output;
}