• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

modules/system/views_handler_field_file.inc

00001 <?php
00007 class views_handler_field_file extends views_handler_field {
00011   function init(&$view, &$options) {
00012     parent::init($view, $options);
00013     if (!empty($options['link_to_file'])) {
00014       $this->additional_fields['uri'] = 'uri';
00015     }
00016   }
00017 
00018   function option_definition() {
00019     $options = parent::option_definition();
00020     $options['link_to_file'] = array('default' => FALSE);
00021     return $options;
00022   }
00023 
00027   function options_form(&$form, &$form_state) {
00028     $form['link_to_file'] = array(
00029       '#title' => t('Link this field to download the file'),
00030       '#description' => t("Enable to override this field's links."),
00031       '#type' => 'checkbox',
00032       '#default_value' => !empty($this->options['link_to_file']),
00033     );
00034     parent::options_form($form, $form_state);
00035   }
00036 
00042   function render_link($data, $values) {
00043     if (!empty($this->options['link_to_file']) && $data !== NULL && $data !== '') {
00044       $this->options['alter']['make_link'] = TRUE;
00045       $this->options['alter']['path'] = file_create_url($this->get_value($values, 'uri'));
00046     }
00047 
00048     return $data;
00049   }
00050 
00051   function render($values) {
00052     $value = $this->get_value($values);
00053     return $this->render_link($this->sanitize_value($value), $values);
00054   }
00055 }

Generated on Sun Feb 26 2012 12:52:51 for Views by  doxygen 1.7.1