openlayers.install in Openlayers 6
Same filename and directory in other branches
This file holds the functions for the installing and enabling of the openlayers module.
File
openlayers.installView source
<?php
/**
* @file
* This file holds the functions for the installing
* and enabling of the openlayers module.
*
* @ingroup openlayers
*/
/**
* Implementation of hook_enable().
*/
function openlayers_enable() {
// As needed for upgrading to 2.x (while accounting
// for 0.x), we set a variable that can help
// the upgrade function in 2.x understand what needs
// to be done. Note, it is not meant to actually
// maintain the schema version.
variable_set('openlayers_schema_version', 6100);
}
/**
* Implementation of hook_install().
*/
function openlayers_install() {
// Create tables
drupal_install_schema('openlayers');
}
/**
* Implementation of hook_uninstall().
*/
function openlayers_uninstall() {
// Remove tables
drupal_uninstall_schema('openlayers');
// Get module variables
$results = db_query("SELECT v.name FROM {variable} AS v WHERE v.name LIKE '%s%%'", 'openlayers_');
// Remove variables
while ($row = db_fetch_array($results)) {
variable_del($row['name']);
}
}
/**
* Implementation of hook_schema().
*/
function openlayers_schema() {
$schema['openlayers_map_presets'] = array(
'fields' => array(
'preset_id' => array(
'description' => t('The primary identifier for an OpenLayers preset.'),
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'preset_name' => array(
'description' => t('The primary identifier for the preset.'),
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'preset_title' => array(
'description' => t('The title of the preset.'),
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'preset_description' => array(
'description' => t('The description of the preset.'),
'type' => 'text',
'not null' => TRUE,
),
'preset_data' => array(
'description' => t('The serialized map.'),
'type' => 'text',
'not null' => TRUE,
),
),
'primary key' => array(
'preset_id',
),
'unique key' => array(
'preset_name',
),
);
return $schema;
}
/**
* Implementation of hook_update_N().
*
* No need for translation in update function:
* http://drupal.org/node/322731
*/
function openlayers_update_6100(&$sandbox) {
// As needed for upgrading to 2.x (while accounting
// for 0.x), we set a variable that can help
// the upgrade function in 2.x understand what needs
// to be done. Note, it is not meant to actually
// maintain the schema version.
variable_set('openlayers_schema_version', 6100);
return array(
0 => array(
'success' => TRUE,
'query' => 'Setup for upgrading to 2.x: openlayers_schema_version',
),
);
}
Functions
Name | Description |
---|---|
openlayers_enable | Implementation of hook_enable(). |
openlayers_install | Implementation of hook_install(). |
openlayers_schema | Implementation of hook_schema(). |
openlayers_uninstall | Implementation of hook_uninstall(). |
openlayers_update_6100 | Implementation of hook_update_N(). |