| 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 |
}
|