/[drupal]/contributions/modules/views/handlers/views_handler_field_url.inc
ViewVC logotype

Contents of /contributions/modules/views/handlers/views_handler_field_url.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Wed Sep 3 19:21:28 2008 UTC (14 months, 3 weeks ago) by merlinofchaos
Branch: MAIN
CVS Tags: DRUPAL-6--2-7, DRUPAL-6--2-6, DRUPAL-6--2-5, DRUPAL-6--2-4, DRUPAL-6--2-3, DRUPAL-6--2-2, DRUPAL-6--2-1, DRUPAL-6--2-0, DRUPAL-6--3-0-ALPHA1, DRUPAL-6--2-0-RC5, DRUPAL-6--2-0-RC4, DRUPAL-6--2-0-RC3, DRUPAL-6--2-0-RC2, HEAD
Branch point for: DRUPAL-6--2, DRUPAL-6--3, DRUPAL-7--3
File MIME type: text/x-php
Major re-organization of handlers. PLEASE NOTE: This drastically affected the Views module API and until modules are updated to match, they will stop working. Efforts have been made to ensure that this won't cause your site to crash, but that's partly up to the individual module as well.
1 <?php
2 // $Id$
3
4 /**
5 * Field handler to provide simple renderer that turns a URL into a clickable link.
6 *
7 * @ingroup views_field_handlers
8 */
9 class views_handler_field_url extends views_handler_field {
10 function option_definition() {
11 $options = parent::option_definition();
12
13 $options['display_as_link'] = array('default' => TRUE);
14
15 return $options;
16 }
17
18 /**
19 * Provide link to the page being visited.
20 */
21 function options_form(&$form, &$form_state) {
22 parent::options_form($form, $form_state);
23 $form['display_as_link'] = array(
24 '#title' => t('Display as link'),
25 '#type' => 'checkbox',
26 '#default_value' => !empty($this->options['display_as_link']),
27 );
28 }
29
30 function render($values) {
31 $value = $values->{$this->field_alias};
32 if (!empty($this->options['display_as_link'])) {
33 return l(check_plain($value), $value, array('html' => TRUE));
34 }
35 else {
36 return $value;
37 }
38 }
39 }

  ViewVC Help
Powered by ViewVC 1.1.2