function search_log_report_form in Search Log 6
Same name and namespace in other branches
- 7 search_log.admin.inc \search_log_report_form()
Report filter form.
1 string reference to 'search_log_report_form'
- search_log_report in ./
search_log.admin.inc - Display search log report.
File
- ./
search_log.admin.inc, line 231 - Admin page callbacks file for the search_log module.
Code
function search_log_report_form(&$form_state, $from_date = NULL, $to_date = NULL, $modules = array(), $status = NULL, $rows = 50) {
$form = array();
// Search period
$today = date('Y-m-d', _search_log_get_time());
$form['period'] = array(
'#type' => 'fieldset',
'#title' => t('Search period'),
);
$links[] = array(
'title' => t('Today'),
'href' => 'admin/reports/search/today',
);
$links[] = array(
'title' => t('This week'),
'href' => 'admin/reports/search/week',
);
$links[] = array(
'title' => t('This month'),
'href' => 'admin/reports/search/month',
);
$links[] = array(
'title' => t('This year'),
'href' => 'admin/reports/search/year',
);
$form['period']['links']['#value'] = theme('links', $links, array(
'class' => 'search-log-links',
));
$form['period']['from_date'] = array(
'#type' => 'textfield',
'#title' => t('From'),
'#default_value' => $from_date ? $from_date : $today,
'#attributes' => array(
'class' => 'jscalendar',
),
);
$form['period']['to_date'] = array(
'#type' => 'textfield',
'#title' => t('To'),
'#default_value' => $to_date ? $to_date : $today,
'#description' => t('Enter custom period for search reporting.'),
'#attributes' => array(
'class' => 'jscalendar',
),
);
// Search modules.
$module_options = array();
$query = db_query('SELECT DISTINCT module FROM {search_log}');
while ($row = db_fetch_object($query)) {
$module_options[$row->module] = $row->module;
}
if (!empty($module_options)) {
$module_default = !empty($modules) ? $modules : array_keys($module_options);
$form['modules'] = array(
'#type' => 'fieldset',
'#title' => t('Search modules'),
);
$form['modules']['modules'] = array(
'#type' => 'checkboxes',
'#description' => t('Select modules to include in search reporting.'),
'#options' => $module_options,
'#default_value' => $module_default,
);
}
// Search status.
if (db_result(db_query_range('SELECT qid FROM {search_log} WHERE result < 0', 0, 1))) {
$status_options = array(
SEARCH_LOG_STATUS_ALL => t('All'),
SEARCH_LOG_STATUS_SUCCESS => t('Success'),
SEARCH_LOG_STATUS_FAILED => t('Failed'),
);
$form['status'] = array(
'#type' => 'fieldset',
'#title' => t('Search status'),
);
$form['status']['status'] = array(
'#type' => 'radios',
'#description' => t('Select status to include in search reporting.'),
'#options' => $status_options,
'#default_value' => $status ? $status : SEARCH_LOG_STATUS_ALL,
'#required' => TRUE,
);
}
else {
$form['status'] = array(
'#type' => 'hidden',
'#default_value' => SEARCH_LOG_STATUS_ALL,
);
}
$form['settings'] = array(
'#type' => 'fieldset',
'#title' => t('Report settings'),
);
$form['settings']['rows'] = array(
'#type' => 'textfield',
'#title' => t('Rows in report'),
'#size' => 4,
'#default_value' => $rows,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Update Report'),
);
$form['#action'] = url('admin/reports/search');
return $form;
}