colorized_gmap.install in Colorized google maps block 7
Contains requirements and uninstall functions for colorized_gmap.
File
colorized_gmap.installView source
<?php
/**
* @file
* Contains requirements and uninstall functions for colorized_gmap.
*/
/**
* Implements hook_requirements().
*/
function colorized_gmap_requirements($phase) {
$requirements = array();
if ($phase == 'install') {
if (!function_exists('libraries_get_path')) {
module_load_include('module', 'libraries');
}
$path = libraries_get_path('colorpicker') ? libraries_get_path('colorpicker') : 'sites/all/libraries/colorpicker';
if (!is_file($path . '/js/colorpicker.js')) {
$t = get_t();
$link = l('http://www.eyecon.ro/colorpicker', 'http://www.eyecon.ro/colorpicker', array(
'absolute' => TRUE,
'attributes' => array(
'target' => '_blank',
),
));
$description = $t('<h2>Colorized_Gmap is not installed</h2><br /> Missing dependency detected. Please download the colorpicker.zip from !link and unzip the CSS, JS and IMAGES folders to <strong>!path</strong>.<br />Your colorpicker.js file should be in the following folder: <strong>!path/js/colorpicker.js</strong>.', array(
'!link' => $link,
'!path' => $path,
));
$requirements['colorized_gmap_missing_files'] = array(
'title' => 'Required files missing',
'description' => $description,
'severity' => REQUIREMENT_ERROR,
);
}
}
if ($phase == 'runtime') {
$colorized_gmap_api_key = variable_get('colorized_gmap_api_key', '');
if (empty($colorized_gmap_api_key)) {
$t = get_t();
$description = $t('Google maps are no longer working without !info. Please visit !get-key page to get API key and follow further instructions. After that, please enter your api key on !settings-page.', array(
'!info' => l("api key", "http://googlegeodevelopers.blogspot.ru/2016/06/building-for-scale-updates-to-google.html", array(
'external' => TRUE,
'attributes' => array(
'target' => '_blank',
),
)),
'!get-key' => l('this', 'https://developers.google.com/maps/documentation/javascript/get-api-key', array(
'external' => TRUE,
'attributes' => array(
'target' => '_blank',
),
)),
'!settings-page' => l('module settings page', '/admin/config/content/colorized_gmap'),
));
$requirements['colorized_gmap_api_key'] = array(
'title' => 'Google maps API key is missing',
'value' => '',
'description' => $description,
'severity' => REQUIREMENT_ERROR,
);
}
}
return $requirements;
}
/**
* Implements hook_schema().
*/
function colorized_gmap_schema() {
$schema = array();
$schema['colorized_gmap_units'] = array(
'description' => 'The base table for Colorized Gmap.',
'fields' => array(
'id' => array(
'description' => 'Primary Key: Identifier for a map.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'name' => array(
'description' => 'The name of the Map - a machine name.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'created' => array(
'description' => 'The Unix timestamp when the Map was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'changed' => array(
'description' => 'The Unix timestamp when the Map was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'uid' => array(
'description' => 'The {users}.uid that created this map',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'latitude' => array(
'description' => 'Latitude position',
'type' => 'numeric',
'precision' => 18,
'scale' => 12,
'not null' => TRUE,
),
'longitude' => array(
'description' => 'Longitude position',
'type' => 'numeric',
'precision' => 18,
'scale' => 12,
'not null' => TRUE,
),
'additional_settings' => array(
'type' => 'text',
'not null' => FALSE,
'serialize' => TRUE,
'description' => 'A serialized array of additional map settings.',
),
'style' => array(
'type' => 'text',
'not null' => FALSE,
'serialize' => TRUE,
'description' => 'A serialized array of map stylers data.',
),
'block_settings' => array(
'type' => 'text',
'not null' => FALSE,
'serialize' => TRUE,
'description' => 'Block settings.',
),
) + entity_exportable_schema_fields(),
'primary key' => array(
'id',
'name',
),
'indexes' => array(
'mapcenter' => array(
'latitude',
'longitude',
),
'mapauthor' => array(
'name',
'uid',
),
),
);
return $schema;
}
/**
* Implements hook_uninstall().
*/
function colorized_gmap_uninstall() {
$result = db_select('variable', 'v')
->fields('v', array(
'name',
))
->condition('name', db_like('colorized_gmap') . '%', 'LIKE')
->execute();
foreach ($result as $row) {
variable_del($row->name);
}
}
Functions
Name | Description |
---|---|
colorized_gmap_requirements | Implements hook_requirements(). |
colorized_gmap_schema | Implements hook_schema(). |
colorized_gmap_uninstall | Implements hook_uninstall(). |