views_handler_field_ym_title.inc in Yandex.Metrics 6.2
Same filename and directory in other branches
Contains the basic 'page_title' field handler.
File
yandex_metrics_reports/views/handlers/views_handler_field_ym_title.incView source
<?php
/**
* @file
* Contains the basic 'page_title' field handler.
*/
/**
* Field handler to provide simple renderer that allows linking to a page title.
* Definition terms:
* - link_to_ym_url default: Should this field have the checkbox "link to url from Yandex.Metricks" enabled by default.
* This handler supports Views 2 as well as Views 3.
*
* @ingroup views_field_handlers
*/
class views_handler_field_ym_title extends views_handler_field {
function init(&$view, &$options) {
parent::init($view, $options);
// Don't add the additional fields to groupby.
if (!empty($this->options['link_to_ym_url'])) {
$this->additional_fields['url'] = array(
'table' => 'yandex_metrics_reports_popular_content',
'field' => 'url',
);
}
}
function option_definition() {
$options = parent::option_definition();
$options['link_to_ym_url'] = array(
'default' => isset($this->definition['link_to_ym_url default']) ? $this->definition['link_to_ym_url default'] : FALSE,
'bool' => TRUE,
);
return $options;
}
/**
* Provide link to url.
*/
function options_form(&$form, &$form_state) {
$form['link_to_ym_url'] = array(
'#title' => t('Link this field to URL from Yandex.Metrics'),
'#description' => t("Enable to override this field's links."),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['link_to_ym_url']),
);
parent::options_form($form, $form_state);
}
/**
* Render whatever the data is as a link to the node.
*
* Data should be made XSS safe prior to calling this function.
*/
function render_link($data, $values) {
if (!empty($this->options['link_to_ym_url']) && !empty($this->additional_fields['url'])) {
if ($data !== NULL && $data !== '') {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = $values->yandex_metrics_reports_popular_content_url;
}
else {
$this->options['alter']['make_link'] = FALSE;
}
}
return $data;
}
function render($values) {
$value = $values->{$this->field_alias};
return $this
->render_link(check_url($value), $values);
}
}
Classes
Name![]() |
Description |
---|---|
views_handler_field_ym_title | Field handler to provide simple renderer that allows linking to a page title. Definition terms: |