class views_handler_field_watchdog_severity in Views Watchdog 6
Same name and namespace in other branches
- 6.3 views/handlers/views_handler_field_watchdog_severity.inc \views_handler_field_watchdog_severity
- 6.2 views/handlers/views_handler_field_watchdog_severity.inc \views_handler_field_watchdog_severity
- 7.3 views/handlers/views_handler_field_watchdog_severity.inc \views_handler_field_watchdog_severity
Hierarchy
- class \views_handler_field_watchdog extends \views_handler_field
Expanded class hierarchy of views_handler_field_watchdog_severity
1 string reference to 'views_handler_field_watchdog_severity'
- views_watchdog_views_data in views/
views_watchdog.views.inc - Implementation of hook_views_data().
File
- views/
handlers/ views_handler_field_watchdog_severity.inc, line 12 - Views callbacks for the "Views watchdog" module.
View source
class views_handler_field_watchdog_severity extends views_handler_field_watchdog {
function option_definition() {
$options = parent::option_definition();
$options['watchdog_severity_icon'] = array(
'default' => TRUE,
);
foreach (views_watchdog_get_severity() as $key => $value) {
$options['watchdog_severity_icon_' . $value['arg']] = array(
'default' => $value['icon'],
'translatable' => FALSE,
);
}
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['watchdog_severity_icon'] = array(
'#title' => t('Display severity level as icon'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['watchdog_severity_icon']),
);
foreach (views_watchdog_get_severity() as $key => $value) {
$form['watchdog_severity_icon_' . $value['arg']] = array(
'#type' => 'textfield',
'#title' => $value['title'],
'#description' => t('The path to the image file you would like to use as icon.'),
'#default_value' => $this->options['watchdog_severity_icon_' . $value['arg']],
'#process' => array(
'views_process_dependency',
),
'#dependency' => array(
'edit-options-watchdog-severity-icon' => array(
1,
),
),
);
}
}
function options_validate(&$form, &$form_state) {
parent::options_validate($form, $form_state);
foreach (views_watchdog_get_severity() as $key => $value) {
$path = trim($form_state['values']['options']['watchdog_severity_icon_' . $value['arg']]);
$field = $form['watchdog_severity_icon_' . $value['arg']];
if (!empty($path) && !is_file($path)) {
form_error($field, t("File doesn't exist."));
}
}
}
function render($values) {
if ($this->options['watchdog_severity_icon']) {
$arg = views_watchdog_get_severity($values->watchdog_severity, 'arg');
$output = views_watchdog_get_severity_icon($values->watchdog_severity, $this->options['watchdog_severity_icon_' . $arg]);
}
else {
$output = views_watchdog_get_severity($values->watchdog_severity, 'title');
}
return $output;
}
}