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