You are here

yamaps_views.module in Yandex.Maps 7

Adds a formatter for view and create view button.

File

modules/yamaps_views/yamaps_views.module
View source
<?php

/**
 * @file
 * Adds a formatter for view and create view button.
 */

/**
 * Implements hook_views_api().
 */
function yamaps_views_views_api() {
  return [
    'api' => 3,
  ];
}

/**
 * Implements hook_page_alter().
 */
function yamaps_views_page_alter(&$page) {
  if (substr_count(current_path(), 'admin/structure/views/view/')) {
    global $language;
    $api_url = url(YAMAPS_API_URL, [
      'absolute' => TRUE,
      'query' => [
        'load' => 'package.full',
        'lang' => YAMAPS_API_LANGUAGE,
        'wizard' => 'Drupal_yamaps_' . $language->language,
        'apikey' => variable_get('yamaps_api_key', ''),
      ],
    ]);

    // Load 'Yandex.Maps' API in views admin UI to make sure that it is
    // fully loaded before calling it during views ajax operations.
    $page['content']['#attached']['js'][] = $api_url;
  }
}

/**
 * Implements hook_help().
 */
function yamaps_views_help($path, $arg) {
  switch ($path) {
    case 'admin/help#yamaps_views':
      return t('Check !link for tutorials and videos on how to use this module.', [
        '!link' => l(t('Yandex Maps page'), 'admin/help/yamaps'),
      ]);
  }
}

Functions