[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/views/handlers/ -> views_handler_field_url.inc (source)

   1  <?php
   2  
   3  /**
   4   * Field handler to provide simple renderer that turns a URL into a clickable link.
   5   *
   6   * @ingroup views_field_handlers
   7   */
   8  class views_handler_field_url extends views_handler_field {
   9    function option_definition() {
  10      $options = parent::option_definition();
  11  
  12      $options['display_as_link'] = array('default' => TRUE);
  13  
  14      return $options;
  15    }
  16  
  17    /**
  18     * Provide link to the page being visited.
  19     */
  20    function options_form(&$form, &$form_state) {
  21      parent::options_form($form, $form_state);
  22      $form['display_as_link'] = array(
  23        '#title' => t('Display as link'),
  24        '#type' => 'checkbox',
  25        '#default_value' => !empty($this->options['display_as_link']),
  26      );
  27    }
  28  
  29    function render($values) {
  30      $value = $values->{$this->field_alias};
  31      if (!empty($this->options['display_as_link'])) {
  32        return l(check_plain($value), $value, array('html' => TRUE));
  33      }
  34      else {
  35        return check_url($value);
  36      }
  37    }
  38  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7