yandex_metrics_reports.views.inc in Yandex.Metrics 6.2
Same filename and directory in other branches
Provides support for the Views module.
File
yandex_metrics_reports/views/yandex_metrics_reports.views.incView source
<?php
/**
* @file
* Provides support for the Views module.
*/
/**
* Implementation of hook_views_handlers() to register all of the basic handlers
* views uses.
*/
function yandex_metrics_reports_views_handlers() {
return array(
'info' => array(
'path' => drupal_get_path('module', 'yandex_metrics_reports') . '/views/handlers',
),
'handlers' => array(
// field handlers
'views_handler_field_ym_title' => array(
'parent' => 'views_handler_field',
),
),
);
}
/**
* Implements hook_views_data().
*/
function yandex_metrics_reports_views_data() {
$data['yandex_metrics_reports_popular_content']['table']['group'] = t('Yandex.Metrics');
$data['yandex_metrics_reports_popular_content']['table']['base'] = array(
'field' => 'yid',
'title' => t('The data obtained from Yandex.metrika.'),
'help' => t('The data obtained from Yandex.metrika.'),
'weight' => -10,
);
$data['yandex_metrics_reports_popular_content']['url'] = array(
'title' => t('Popular url'),
'help' => t('The url obtained from Yandex.metrika.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
);
$data['yandex_metrics_reports_popular_content']['page_title'] = array(
'title' => t('Title for url'),
'help' => t('The page title of the url.'),
'field' => array(
'handler' => 'views_handler_field_ym_title',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
);
$data['yandex_metrics_reports_popular_content']['page_views'] = array(
'title' => t('Count of views'),
'help' => t('Page views of this url.'),
'field' => array(
'handler' => 'views_handler_field_numeric',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_numeric',
),
'argument' => array(
'handler' => 'views_handler_argument_numeric',
),
);
return $data;
}
/**
* Implements hook_views_default_views().
*/
function yandex_metrics_reports_views_default_views() {
$view = new view();
$view->name = 'popular_content';
$view->description = 'Popular content from Yandex.Metrics';
$view->tag = 'Yandex.Metrics';
$view->base_table = 'yandex_metrics_reports_popular_content';
$view->human_name = 'Popular content';
$view->core = 6;
$view->api_version = 2;
// However it works with Views 3 as well.
$view->disabled = FALSE;
/* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view
->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Popular content (Yandex.Metrics)';
$handler->display->display_options['use_ajax'] = TRUE;
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['items_per_page'] = 5;
$handler->display->display_options['use_pager'] = TRUE;
$handler->display->display_options['style_plugin'] = 'list';
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: Yandex.Metrics: Title for url */
$handler->display->display_options['fields']['page_title']['id'] = 'page_title';
$handler->display->display_options['fields']['page_title']['table'] = 'yandex_metrics_reports_popular_content';
$handler->display->display_options['fields']['page_title']['field'] = 'page_title';
$handler->display->display_options['fields']['page_title']['label'] = '';
$handler->display->display_options['fields']['page_title']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['page_title']['link_to_ym_url'] = TRUE;
/* Field: Yandex.Metrics: Count of views */
$handler->display->display_options['fields']['page_views']['id'] = 'page_views';
$handler->display->display_options['fields']['page_views']['table'] = 'yandex_metrics_reports_popular_content';
$handler->display->display_options['fields']['page_views']['field'] = 'page_views';
$handler->display->display_options['fields']['page_views']['label'] = '';
$handler->display->display_options['fields']['page_views']['exclude'] = TRUE;
$handler->display->display_options['fields']['page_views']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['page_views']['separator'] = '';
/* Display: Block */
$handler = $view
->new_display('block', 'Block', 'block');
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['block_description'] = 'Popular content (Yandex.Metrics)';
$views[$view->name] = $view;
return $views;
}
Functions
Name | Description |
---|---|
yandex_metrics_reports_views_data | Implements hook_views_data(). |
yandex_metrics_reports_views_default_views | Implements hook_views_default_views(). |
yandex_metrics_reports_views_handlers | Implementation of hook_views_handlers() to register all of the basic handlers views uses. |