You are here

node_field_gmap.module in Node Field 7.2

File

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

/**
 * @file
 * This module provides Google GMap node field.
 */
require_once 'includes/node_field_gmap.api.inc';

/**
 * Implements hook_node_field_info_alter().
 */
function node_field_gmap_node_field_info_alter(&$items) {
  $items += array(
    'gmap' => array(
      'type' => 'gmap',
      'label' => t('Google map'),
      'widget' => 'node_field_gmap_field_widget',
      'formatter' => 'node_field_gmap_field_formatter',
      'settings' => 'node_field_default_field_settings',
    ),
  );
}

/**
 * Implements hook_node_field_node_submit_alter().
 */
function node_field_gmap_node_field_node_submit_alter(&$form_state) {
  foreach ($form_state['values']['node_fields'] as $fid => $value) {
    if (is_array($value) && isset($value['gmap'])) {
      unset($value['gmap']);
      $serialized = serialize($value);
      $form_state['values']['node_fields'][$fid] = $serialized;
    }
  }
}

/**
 * Implements hook_form_FORM_ID_alter().
 */
function node_field_gmap_form_node_field_admin_settings_form_alter(&$form, &$form_state, $form_id) {
  $options = array(
    '@url' => url('https://developers.google.com/maps/documentation/javascript/get-api-key'),
  );
  $form['node_field_gmap_api_key'] = array(
    '#type' => 'textfield',
    '#title' => t('Google Maps API Key'),
    '#description' => t('See <a href="@url">Google Maps API documentation</a> for more info.', $options),
    '#default_value' => variable_get('node_field_gmap_api_key', ''),
    '#required' => FALSE,
  );
  $form = system_settings_form($form);
  $requirements['node_field_gmap'] = array(
    'title' => t('Node Field Gmap'),
    'value' => 'Google Maps API Key is configured',
  );
}

Functions

Namesort descending Description
node_field_gmap_form_node_field_admin_settings_form_alter Implements hook_form_FORM_ID_alter().
node_field_gmap_node_field_info_alter Implements hook_node_field_info_alter().
node_field_gmap_node_field_node_submit_alter Implements hook_node_field_node_submit_alter().