Tripal v1.0 (6.x-1.0)
|
00001 <?php 00002 00011 class chado_views_handler_field_boolean extends views_handler_field_boolean { 00012 00013 function init(&$view, $options) { 00014 include_once('chado_wrapper_functions.inc'); 00015 parent::init($view, $options); 00016 } 00017 00021 function option_definition() { 00022 $options = parent::option_definition(); 00023 00024 $options['type'] = array('default' => 'separator'); 00025 $options['separator'] = array('default' => ', '); 00026 00027 return $options; 00028 } 00029 00033 function options_form(&$form, &$form_state) { 00034 parent::options_form($form, $form_state); 00035 00036 $form['type'] = array( 00037 '#type' => 'radios', 00038 '#title' => t('Display type'), 00039 '#options' => array( 00040 'ul' => t('Unordered list'), 00041 'ol' => t('Ordered list'), 00042 'separator' => t('Simple separator'), 00043 ), 00044 '#default_value' => $this->options['type'], 00045 ); 00046 00047 $form['separator'] = array( 00048 '#type' => 'textfield', 00049 '#title' => t('Separator'), 00050 '#default_value' => $this->options['separator'], 00051 '#process' => array('views_process_dependency'), 00052 '#dependency' => array('radio:options[type]' => array('separator')), 00053 ); 00054 } 00055 00060 function query() { 00061 parent::query(); 00062 $this->aggregated = chado_wrapper_is_aggregated_by_join($this); 00063 } 00064 00068 function pre_render(&$values) { 00069 00070 // further check the results to see if this field is a postgresql array 00071 $this->aggregated = chado_wrapper_is_aggregated_by_result($this, $values); 00072 00073 // Split Aggregated Results 00074 chado_wrapper_split_array_agg_results($this, $values); 00075 00076 } 00077 00087 function render($values) { 00088 00089 // check to see if this is a t/f boolean field or a 1/0 boolean field 00090 // parent render expects 1/0 so need to translate to that form before rendering 00091 if (!is_array($values->{$this->field_alias})) { 00092 if (!preg_match('/[01]/', $values->{$this->field_alias})) { 00093 if (preg_match('/^[tT]/', $values->{$this->field_alias})) { 00094 $values->{$this->field_alias} = 1; 00095 } 00096 elseif (preg_match('/^[fF]/', $values->{$this->field_alias})) { 00097 $values->{$this->field_alias} = 0; 00098 } 00099 } 00100 } 00101 else { 00102 if (!preg_match('/[01]/', $values->{$this->field_alias}[0])) { 00103 foreach ($values->{$this->field_alias} as $k => $v) { 00104 if (preg_match('/^[tT]/', $v)) { 00105 $values->{$this->field_alias}[$k] = 1; 00106 } 00107 elseif (preg_match('/^[fF]/', $v)) { 00108 $values->{$this->field_alias}[$k] = 0; 00109 } 00110 } 00111 } 00112 } 00113 00114 return chado_wrapper_render_items($this, $values); 00115 } 00116 00117 function parent_render($val) { 00118 return parent::render($val); 00119 } 00120 00121 }