views_handler_field_accesslog_path.inc

  1. 3.x modules/statistics/views_handler_field_accesslog_path.inc
  2. 2.x modules/statistics/views_handler_field_accesslog_path.inc

File

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