hosting_task_handler_field_status.inc

Classes

File

task/includes/views/handlers/hosting_task_handler_field_status.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. */
  5. /**
  6. * @ingroup views_field_handlers
  7. */
  8. class hosting_task_handler_field_status extends views_handler_field {
  9. function option_definition() {
  10. $options = parent::option_definition();
  11. $options['alter']['contains']['status_mode'] = array('default' => 'raw');
  12. return $options;
  13. }
  14. function options_form(&$form, &$form_state) {
  15. parent::options_form($form, $form_state);
  16. if ($this->allow_advanced_render()) {
  17. $form['alter']['status_mode'] = array(
  18. '#type' => 'radios',
  19. '#title' => t('Display mode'),
  20. '#options' => array(
  21. 'raw' => t('Raw value'),
  22. 'text' => t('Text value'),
  23. 'class' => t('CSS class'),
  24. ),
  25. '#default_value' => $this->options['alter']['status_mode'],
  26. '#description' => t(''),
  27. );
  28. }
  29. }
  30. function render($values) {
  31. $value = $values->{$this->field_alias};
  32. switch ($this->options['alter']['status_mode']) {
  33. case 'text':
  34. return _hosting_parse_error_code($value);
  35. case 'class':
  36. return hosting_task_status_class($value);
  37. }
  38. return $value;
  39. }
  40. }