hosting_site_handler_field_status.inc

Classes

Namesort descending Description
hosting_site_handler_field_status A handler for the Site status field.

File

site/includes/views/handlers/hosting_site_handler_field_status.inc
View source
  1. <?php
  2. /**
  3. * A handler for the Site status field.
  4. *
  5. * @ingroup views_field_handlers
  6. */
  7. class hosting_site_handler_field_status extends views_handler_field {
  8. /**
  9. * Constructor; calls to base object constructor.
  10. */
  11. function construct() {
  12. parent::construct();
  13. $this->additional_fields = array('verified');
  14. }
  15. function option_definition() {
  16. $options = parent::option_definition();
  17. $options['status_mode'] = array('default' => 'text');
  18. return $options;
  19. }
  20. function options_form(&$form, &$form_state) {
  21. $form['status_mode'] = array(
  22. '#type' => 'radios',
  23. '#title' => t('Display mode'),
  24. '#options' => array(
  25. 'text' => t('Text'),
  26. 'image' => t('Image'),
  27. 'text_image' => t('Text & Image'),
  28. 'class' => t('CSS class'),
  29. ),
  30. '#default_value' => isset($this->options['status_mode']) ? $this->options['status_mode'] : 'text',
  31. '#description' => t("Display mode of status values.")
  32. );
  33. parent::options_form($form, $form_state);
  34. }
  35. function render($values) {
  36. $value = $values->{$this->field_alias};
  37. $output = _hosting_site_status($value);
  38. switch ($this->options['status_mode']) {
  39. case 'image':
  40. return "<span class='hosting-status hosting-status-icon'></span>";
  41. case 'text_image':
  42. return "<span class='hosting-status'>{$output}</span>";
  43. case 'class':
  44. return _hosting_site_list_class($value, $values->{$this->aliases['verified']});
  45. }
  46. return $output;
  47. }
  48. }