Tripal v1.0 (6.x-1.0)
|
00001 <?php 00002 00011 class chado_views_handler_field_date extends views_handler_field_date { 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 the format of the date is a UNIX timestamp and otherwise convert 00090 if (!is_array($values->{$this->field_alias})) { 00091 if (!preg_match('/^\d+$/', $values->{$this->field_alias})) { 00092 $values->{$this->field_alias} = strtotime($values->{$this->field_alias}); 00093 } 00094 } 00095 else { 00096 if (!preg_match('/^\d+$/', $values->{$this->field_alias}[0])) { 00097 foreach ($values->{$this->field_alias} as $k => $v) { 00098 $values->{$this->field_alias}[$k] = strtotime($v); 00099 } 00100 } 00101 } 00102 00103 // render the items 00104 return chado_wrapper_render_items($this, $values); 00105 } 00106 00107 function parent_render($val) { 00108 return parent::render($val); 00109 } 00110 00111 }