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

Definition of views_handler_field_accesslog_path.

File

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