function elasticsearch_connector_statistics_access_log in Elasticsearch Connector 7
Same name and namespace in other branches
- 7.5 modules/elasticsearch_connector_statistics/elasticsearch_connector_statistics.admin.inc \elasticsearch_connector_statistics_access_log()
- 7.2 modules/elasticsearch_connector_statistics/elasticsearch_connector_statistics.admin.inc \elasticsearch_connector_statistics_access_log()
Page callback: Gathers page access statistics suitable for rendering.
Parameters
$aid: The unique accesslog ID.
Return value
A render array containing page access statistics. If information for the page was not found, drupal_not_found() is called.
1 string reference to 'elasticsearch_connector_statistics_access_log'
- elasticsearch_connector_statistics_menu in modules/
elasticsearch_connector_statistics/ elasticsearch_connector_statistics.module - Implements hook_menu().
File
- modules/
elasticsearch_connector_statistics/ elasticsearch_connector_statistics.admin.inc, line 412 - Admin page callbacks for the Statistics module.
Code
function elasticsearch_connector_statistics_access_log($aid) {
$client_id = elasticsearch_connector_statistics_get_cluster_vars();
if (!empty($client_id)) {
$client = elasticsearch_connector_get_client_by_id($client_id);
if ($client) {
try {
$params['index'] = elasticsearch_connector_statistics_get_cluster_vars('index');
$params['type'] = variable_get('elasticsearch_connector_statistics_type', ELASTICSEARCH_CONNECTOR_STATS_DEFAULT_TYPE);
$params['id'] = $aid;
$rows = array();
if ($client
->exists($params)) {
$result = $client
->get($params);
if (!empty($result['_id'])) {
$rows[] = array(
array(
'data' => t('URL'),
'header' => TRUE,
),
l(url($result['_source']['path'], array(
'absolute' => TRUE,
)), $result['_source']['path']),
);
// It is safe to avoid filtering $access->title through check_plain because
// it comes from drupal_get_title().
$rows[] = array(
array(
'data' => t('Title'),
'header' => TRUE,
),
$result['_source']['title'],
);
$rows[] = array(
array(
'data' => t('Referrer'),
'header' => TRUE,
),
$result['_source']['referer'] ? l($result['_source']['referer'], $result['_source']['referer']) : '',
);
$rows[] = array(
array(
'data' => t('Date'),
'header' => TRUE,
),
format_date($result['_source']['timestamp'], 'long'),
);
$rows[] = array(
array(
'data' => t('User'),
'header' => TRUE,
),
$result['_source']['username'],
);
$rows[] = array(
array(
'data' => t('Hostname'),
'header' => TRUE,
),
check_plain($result['_source']['ip']),
);
$build['statistics_table'] = array(
'#theme' => 'table',
'#rows' => $rows,
);
return $build;
}
}
} catch (Exception $e) {
// Show the error message to the user.
drupal_set_message($e
->getMessage(), 'error');
}
}
}
return MENU_NOT_FOUND;
}