00001 <?php 00002 00008 class views_handler_field_file_filemime extends views_handler_field_file { 00009 function option_definition() { 00010 $options = parent::option_definition(); 00011 $options['filemime_image'] = array('default' => FALSE); 00012 return $options; 00013 } 00014 00015 function options_form(&$form, &$form_state) { 00016 $form['filemime_image'] = array( 00017 '#title' => t('Display an icon representing the file type, instead of the MIME text (such as "image/jpeg")'), 00018 '#type' => 'checkbox', 00019 '#default_value' => !empty($this->options['filemime_image']), 00020 ); 00021 parent::options_form($form, $form_state); 00022 } 00023 00024 function render($values) { 00025 $data = $values->{$this->field_alias}; 00026 if (!empty($this->options['filemime_image']) && $data !== NULL && $data !== '') { 00027 $fake_file = (object) array('filemime' => $data); 00028 $data = theme('file_icon', array('file' => $fake_file)); 00029 } 00030 00031 return $this->render_link($data, $values); 00032 } 00033 }