You are here

function openlayers_ui_init in Openlayers 7.2

Implements hook_init().

File

modules/openlayers_ui/openlayers_ui.module, line 12
Main Drupal module file for the OpenLayers UI module

Code

function openlayers_ui_init() {

  // For backwards compability for the change from maps to presets
  // in the 7.x-2.x version, we want to make it really obvious that
  // administrators and developers should be updating their maps
  //
  // There are also other requirement checks like the compatible
  // suggestlibrary version.
  if (strpos($_GET['q'], 'admin/structure/openlayers') === 0) {
    include_once DRUPAL_ROOT . '/includes/install.inc';
    drupal_load_updates();
    module_load_include('install', 'openlayers', 'openlayers');
    $reqs = openlayers_requirements('runtime');
    foreach ($reqs as $r) {
      if ($r['severity'] != REQUIREMENT_OK) {
        $severity = $r['severity'] == REQUIREMENT_WARNING ? 'warning' : 'error';
        drupal_set_message(t('<strong>!title</strong> !message', array(
          '!title' => $r['value'],
          '!message' => isset($r['description']) ? $r['description'] : '',
        )), $severity);
      }
    }

    // We also want to do some nice AJAX magic to get the library
    // version to the system.
    $check = variable_get('openlayers_ui_version_check', '');
    if (empty($check)) {

      // Load AJAX libraries
      drupal_add_library('system', 'drupal.ajax');
      drupal_add_library('system', 'jquery.form');

      // Ensure that the library is included
      openlayers_include();

      // Add custom client JS
      drupal_add_js(drupal_get_path('module', 'openlayers_ui') . '/js/openlayers_ui.admin.js');

      // We shouldn't, but we are just gonna put a message up there
      // to get replaced.
      drupal_set_message('<div class="openlayers-ui-version-check-message">' . t('Checking client library via Javascript...') . '</div>', 'none');
    }
  }
}