summaryrefslogtreecommitdiffstats
path: root/modules/hosting/site/views_handler_field_hosting_site_status.inc
blob: 13e56f8224ed99c500ad1d6e3a33ed4ccda5c0cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php


class views_handler_field_hosting_site_status extends views_handler_field {
  function option_definition() {
    $options = parent::option_definition();

    $options['status_icon'] = array('default' => '0');

    return $options;
  }

  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);

    $form['status_icon'] = array(
      '#type' => 'radios',
      '#title' => t('Display icon'),
      '#options' => array('Text', 'Image', 'Both'),
      '#default_value' => isset($this->options['status_icon']) ? $this->options['status_icon'] : '0',
      '#description' => t("Display icons instead of status values.")
    );
  }

  function render($values) {
    $value = $values->{$this->field_alias};
    $output = _hosting_site_status($value);

    if ($this->options['status_icon'] == 1) {
      $output = "<span class='hosting-status hosting-status-icon'></span>";
    }
    elseif ($this->options['status_icon'] == 2) {
      $output = "<span class='hosting-status'>{$output}</span>";
    }
    return $output;
  }
}