'Storage for User defined OpenLayers maps.', 'export' => array( 'key' => 'name', 'key name' => 'Name', 'primary key' => 'name', 'identifier' => 'openlayers_maps', 'default hook' => 'openlayers_maps', 'api' => array( 'owner' => 'openlayers', 'api' => 'openlayers_maps', 'minimum_version' => 1, 'current_version' => 1, ), ), 'fields' => array( 'name' => array( 'description' => 'The primary identifier for the map.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, ), 'title' => array( 'description' => 'The title of the map.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, ), 'description' => array( 'description' => 'The description of the map.', 'type' => 'text', 'not null' => TRUE, ), 'data' => array( 'description' => 'The serialized map.', 'type' => 'text', 'not null' => TRUE, 'serialize' => TRUE, ), ), 'primary key' => array('name'), ); // Layer table (ctools extras) $schema['openlayers_layers'] = array( 'description' => 'Storage for user defined OpenLayers layers.', 'export' => array( 'key' => 'name', 'key name' => 'Name', 'primary key' => 'name', 'identifier' => 'openlayers_layers', 'default hook' => 'openlayers_layers', 'api' => array( 'owner' => 'openlayers', 'api' => 'openlayers_layers', 'minimum_version' => 1, 'current_version' => 1, ), ), 'fields' => array( 'name' => array( 'type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => '', 'description' => 'Layer name.', ), 'title' => array( 'type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => '', 'description' => 'Layer title.', ), 'description' => array( 'type' => 'text', 'not null' => TRUE, 'description' => 'Layer description.', ), 'data' => array( 'type' => 'text', 'not null' => FALSE, 'description' => 'Layer data serialized.', 'serialize' => TRUE, ), ), 'primary key' => array('name'), ); // Styles table (ctools extras) $schema['openlayers_styles'] = array( 'description' => 'Storage for user defined OpenLayers styles.', 'export' => array( 'key' => 'name', 'key name' => 'Name', 'primary key' => 'name', 'identifier' => 'openlayers_styles', 'default hook' => 'openlayers_styles', 'api' => array( 'owner' => 'openlayers', 'api' => 'openlayers_styles', 'minimum_version' => 1, 'current_version' => 1, ), ), 'fields' => array( 'name' => array( 'type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => '', 'description' => 'Style name.', ), 'title' => array( 'type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => '', 'description' => 'Style title.', ), 'description' => array( 'type' => 'text', 'not null' => TRUE, 'description' => 'Style description.', ), 'data' => array( 'type' => 'text', 'not null' => FALSE, 'description' => 'Style data serialized.', 'serialize' => TRUE, ), ), 'primary key' => array('name'), ); return $schema; } /** * Implements hook_requirements(). */ function openlayers_requirements($phase) { $req = array(); $t = get_t(); // We should not require a specfic version of the OpenLayers library, but // we should tell the administrator that specific versions are more // compatible than others. if ($phase == 'runtime') { $ol_library_version = 0; $current_library = variable_get('openlayers_source', OPENLAYERS_DEFAULT_LIBRARY); // As of 2.11, the hosted version supports the newest hosted // stable with an actual version number. This used to be just under // the 'api' path. if (strpos($current_library, (string) OPENLAYERS_SUGGESTED_LIBRARY) !== FALSE) { $ol_library_version = OPENLAYERS_SUGGESTED_LIBRARY; } // Check if it is the default hosted. if ($current_library == 'http://openlayers.org/api/OpenLayers.js') { $ol_library_version = OPENLAYERS_HOSTED_API_LIBRARY; } // Finally, let's see if the client has sent us a value // from the UI module AJAX magic. $client = variable_get('openlayers_ui_version_check', ''); if (strpos($client, (string) OPENLAYERS_SUGGESTED_LIBRARY) !== FALSE) { $ol_library_version = OPENLAYERS_SUGGESTED_LIBRARY; } // Check if suggest version. if ($ol_library_version == OPENLAYERS_SUGGESTED_LIBRARY) { $req['openlayers_old_presets'] = array( 'title' => $t('OpenLayers library version'), 'value' => $t('Using suggested compatible version %suggested.', array( '%suggested' => OPENLAYERS_SUGGESTED_LIBRARY, )), 'severity' => REQUIREMENT_OK, ); } else { $req['openlayers_old_presets'] = array( 'title' => $t('OpenLayers library version'), 'value' => $t('Not suggested compatible version.'), 'description' => $t('Though you are very welcome to use whatever version of the OpenLayers library you want, it is suggested that you use version %suggested. You are currently not using that version or we are unable to determine which version you are using. Update your library settings at !settings.', array( '%suggested' => OPENLAYERS_SUGGESTED_LIBRARY, '!settings' => l(t('OpenLayers settings'), 'admin/structure/openlayers'), )), 'severity' => REQUIREMENT_WARNING, ); } } // There are some backwards compability for the shift from // preset to maps. We want to communicate to administrators // that this will not be there forever. if ($phase == 'runtime') { // Check preset hook $presets = module_invoke_all('openlayers_presets'); $found_presets = (count($presets) > 0) ? TRUE : FALSE; // Check features $feature_names = array(); $found_features = FALSE; if (module_exists('features')) { $features = features_get_features(); foreach ($features as $feature) { // Only utilize enabled features and look for presets if ($feature->status > 0 && !empty($feature->info['features']['openlayers_map_presets'])) { $feature_names[] = $feature->name; $found_features = TRUE; } } } // Create requirement entries if ($found_presets) { $req['openlayers_old_presets'] = array( 'title' => $t('OpenLayers Presets'), 'value' => $t('Found old presets.'), 'description' => $t('With the 7.x-2.x version of the OpenLayers module, map presets were renamed to just maps. This has some implications on APIs and hooks. One or more of of the modules installed on this site is utilizing the deprecated %hook. Please read the upgrade page, then contact the module owner or fix the custom module yourself.', array( '%hook' => 'hook_openlayers_presets()', '@url' => url('http://drupal.org/node/1136810'), )), 'severity' => REQUIREMENT_ERROR, ); } if ($found_features) { $req['openlayers_old_features'] = array( 'title' => $t('OpenLayers Presets'), 'value' => $t('Found Features with presets.'), 'description' => $t('With the 7.x-2.x version of the OpenLayers module, map presets were renamed to just maps. This has some implications on APIs and hooks. There are Features on this site that contain the old map presets. Please read the upgrade page, and rebuild the following Features: %features', array( '@url' => url('http://drupal.org/node/1136810'), '%features' => implode(',', $feature_names), )), 'severity' => REQUIREMENT_ERROR, ); } } return $req; } /** * Implements hook_update_N(). * * Rename of presets to maps. */ function openlayers_update_7201() { // Change table name db_rename_table('openlayers_map_presets', 'openlayers_maps'); // Set default map variable variable_set('openlayers_default_map', variable_get('openlayers_default_preset', 'default')); variable_del('openlayers_default_preset'); } /** * Drop name indexes duplicates of primary key. */ function openlayers_update_7202() { db_drop_index('openlayers_layers', 'name'); db_drop_index('openlayers_styles', 'name'); } /** * Renamme the 'baselayer' in 'isBaseLayer' in layers. */ function openlayers_update_7204() { foreach (openlayers_layers_load() as $key => $layer) { if ($layer->export_type != 1) continue; if (isset($layer->data['baselayer'])) { $layer->data['isBaseLayer'] = $layer->data['baselayer']; unset($layer->data['baselayer']); ctools_export_crud_save('openlayers_layers', $layer); } } } /** * Change the case of machine_name for layers, maps and styles. * Warning, it can break things. */ function openlayers_update_7205() { db_query('UPDATE {openlayers_layers} SET name = LOWER(name);'); db_query('UPDATE {openlayers_styles} SET name = LOWER(name);'); db_query('UPDATE {openlayers_maps} SET name = LOWER(name);'); }