You are here

openlayers_ui.module in Openlayers 6.2

File

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

/**
 * Implementation of hook_help
 */
function openlayers_ui_help($path, $arg) {
  switch ($path) {
    case 'admin/help#openlayers_ui':
      return '<p>' . t('Provides a user interface to manage OpenLayers maps.') . '</p>';
    case 'admin/build/openlayers':
      return '<p>' . t('Configure where Drupal finds
        the OpenLayers javascript library. Using a local or <a href="@olb">compacted
        version</a> of OpenLayers can reduce filesize, but remember to set the Image Path and
        CSS Path options in every preset, because OpenLayers is not able to find these resources
        automatically. See the included documentation in /doc for
        more details.', array(
        '@olb' => 'http://trac.openlayers.org/wiki/Profiles',
      )) . '</p>';
    case 'admin/build/openlayers/styles':
      return '<p>' . t('OpenLayer styles are stored versions of
        <a href="@ols">javascript StyleMap objects</a>, but are much easier to
        configure through an interface. Styles will typically define the icon,
        fill color, border, and radius of points or polygons, so they are used
        on overlays more often than base layers, which are not affected by vector
        styles.', array(
        "@ols" => 'http://trac.openlayers.org/wiki/Styles',
      )) . '</p>';
    case 'admin/build/openlayers/styles/add':
      return '<p>' . t('The name, title, and description you give a style is for Drupal\'s
        interal storage. The rest of the properties are documented on openlayers.org') . '</p>';
    case 'admin/build/openlayers/presets':
      return '<p>' . t('Presets are combinations of the layers, styles, and behaviors
        which constitute maps. They also contain basic configuration like the
        width and centerpoint of the map - everything except for a mechanism
        to put a map on a page. For that, use the Views OpenLayers Map style.') . '</p>';
    case 'admin/build/openlayers/layers':
      return '<p>' . t('Layers are stored versions of javascript OpenLayers layer
        objects. They point at a data source, like OpenStreetMap, Google Maps,
        or Drupal itself, and sometimes define the zoom levels for which they apply.') . '</p>';
    case 'admin/build/openlayers/layers/settings':
      return '<p>' . t('Commercial layer providers like Google will require API keys
        to ensure that users are\'t abusing the service and to enforce limits. Not all
        of these keys are required, of course, only those that are used on a site.') . '</p>';
  }
}

/**
 * Implementation of hook_perm
 */
function openlayers_ui_perm() {
  return array(
    'administer openlayers',
  );
}

/**
 * Implementation of hook_menu
 */
function openlayers_ui_menu() {
  $items = array();

  // Core OpenLayers settings pages.
  $items['admin/build/openlayers'] = array(
    'title' => 'OpenLayers',
    'description' => 'Manage maps, layers, styles, and map behaviors.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_admin_settings',
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.admin.inc',
    'type' => MENU_NORMAL_ITEM,
  );
  $items['admin/build/openlayers/settings'] = array(
    'title' => 'Settings',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -20,
  );

  // Layers.
  $items['admin/build/openlayers/layers'] = array(
    'title' => 'Layers',
    'page callback' => 'openlayers_ui_object_list',
    'page arguments' => array(
      3,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.layers.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => -10,
  );
  $items['admin/build/openlayers/layers/list'] = array(
    'title' => 'List',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -20,
  );

  // Layer type drilldown
  $items['admin/build/openlayers/layers/add'] = array(
    'title' => 'Add',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_layers_types',
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.layers.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => -10,
  );

  // Actual add-layer form
  $items['admin/build/openlayers/layers/add/%openlayers_layer_type'] = array(
    'title' => 'Add',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_layers_form',
      5,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.layers.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => -15,
  );
  $items['admin/build/openlayers/layers/clone/%openlayers_layer'] = array(
    'title' => 'Clone layer',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_layers_form',
      5,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.layers.inc',
    'type' => MENU_NORMAL_ITEM,
    'tab_parent' => 'admin/build/openlayers/layers',
  );
  $items['admin/build/openlayers/layers/import'] = array(
    'title' => 'Import',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_layers_import_form',
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.layers.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => -10,
  );

  // Edit-layer form
  $items['admin/build/openlayers/layers/%openlayers_layer/edit'] = array(
    'title' => 'Edit layer',
    'description' => 'Edit OpenLayers layer.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_layers_form',
      4,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.layers.inc',
    'type' => MENU_NORMAL_ITEM,
  );
  $items['admin/build/openlayers/layers/%openlayers_layer_export/delete'] = array(
    'title' => 'Delete layer',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_object_delete',
      3,
      4,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.layers.inc',
    'type' => MENU_NORMAL_ITEM,
  );
  $items['admin/build/openlayers/layers/%openlayers_layer_export/export'] = array(
    'title' => 'Export layer',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_object_export',
      3,
      4,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.layers.inc',
    'type' => MENU_NORMAL_ITEM,
  );

  // Layer-type-wide settings form
  $items['admin/build/openlayers/layers/settings'] = array(
    'title' => 'API Keys',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_layers_settings',
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.layers.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => -10,
  );

  // Styles.
  $items['admin/build/openlayers/styles'] = array(
    'title' => 'Styles',
    'page callback' => 'openlayers_ui_object_list',
    'page arguments' => array(
      3,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.styles.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => -10,
  );
  $items['admin/build/openlayers/styles/list'] = array(
    'title' => 'List',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -20,
  );
  $items['admin/build/openlayers/styles/add'] = array(
    'title' => 'Add',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_styles_form',
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.styles.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => -10,
  );

  /*
  * Feature not completed
    $items['admin/build/openlayers/styles/import'] = array(
   'title' => 'Import',
   'page callback' => 'drupal_get_form',
   'page arguments' => array('openlayers_ui_styles_import_form'),
   'access arguments' => array('administer openlayers'),
   'file' => 'includes/openlayers_ui.styles.inc',
   'type' => MENU_LOCAL_TASK,
   'weight' => -10,
    );
  */
  $items['admin/build/openlayers/styles/add/%openlayers_style'] = array(
    'title' => 'Add',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_styles_form',
      5,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.styles.inc',
    'type' => MENU_NORMAL_ITEM,
    'weight' => -10,
  );
  $items['admin/build/openlayers/styles/clone/%openlayers_style'] = array(
    'title' => 'Clone style',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_styles_form',
      5,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.styles.inc',
    'type' => MENU_LOCAL_TASK,
  );
  $items['admin/build/openlayers/styles/%openlayers_style/edit'] = array(
    'title' => 'Edit style',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_styles_form',
      4,
      TRUE,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.styles.inc',
    'type' => MENU_LOCAL_TASK,
  );
  $items['admin/build/openlayers/styles/%openlayers_style/delete'] = array(
    'title' => 'Delete style',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_object_delete',
      3,
      4,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.styles.inc',
    'type' => MENU_LOCAL_TASK,
  );
  $items['admin/build/openlayers/styles/%openlayers_style/export'] = array(
    'title' => 'Export style',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_object_export',
      3,
      4,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.styles.inc',
    'type' => MENU_LOCAL_TASK,
  );

  // Presets.
  $items['admin/build/openlayers/presets'] = array(
    'title' => 'Presets',
    'description' => 'Create OpenLayers map presets.',
    'page callback' => 'openlayers_ui_object_list',
    'page arguments' => array(
      3,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.presets.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => -10,
  );
  $items['admin/build/openlayers/presets/list'] = array(
    'title' => 'List',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -20,
  );
  $items['admin/build/openlayers/presets/add'] = array(
    'title' => 'Add',
    'description' => 'Add OpenLayers map preset.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_presets_form',
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.presets.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => -10,
  );
  $items['admin/build/openlayers/presets/add/%openlayers_preset'] = array(
    'title' => 'Clone Preset',
    'description' => 'Add OpenLayers map preset.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_presets_form',
      5,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.presets.inc',
    'type' => MENU_NORMAL_ITEM,
    'weight' => -10,
  );
  $items['admin/build/openlayers/presets/clone/%openlayers_preset'] = array(
    'title' => 'Clone preset',
    'description' => 'Clone OpenLayers map preset.',
    'page callback' => 'openlayers_ui_presets_clone',
    'page arguments' => array(
      5,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.presets.inc',
    'type' => MENU_LOCAL_TASK,
  );
  $items['admin/build/openlayers/presets/%openlayers_preset/edit'] = array(
    'title' => 'Edit preset',
    'description' => 'Edit OpenLayers map preset.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_presets_form',
      4,
      TRUE,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.presets.inc',
    'type' => MENU_LOCAL_TASK,
    'tab_parent' => 'admin/build/openlayers/presets',
  );
  $items['admin/build/openlayers/presets/%openlayers_preset/delete'] = array(
    'title' => 'Delete preset',
    'description' => 'Delete OpenLayers map preset.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_object_delete',
      3,
      4,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.presets.inc',
    'type' => MENU_LOCAL_TASK,
    'tab_parent' => 'admin/build/openlayers/presets',
  );
  $items['admin/build/openlayers/presets/%openlayers_preset/export'] = array(
    'title' => 'Export preset',
    'description' => 'Export OpenLayers map preset.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'openlayers_ui_object_export',
      3,
      4,
    ),
    'access arguments' => array(
      'administer openlayers',
    ),
    'file' => 'includes/openlayers_ui.presets.inc',
    'type' => MENU_LOCAL_TASK,
    'tab_parent' => 'admin/build/openlayers/presets',
  );
  $items['openlayers/ahah/preset'] = array(
    'title' => 'OpenLayers AHAH',
    'page callback' => 'openlayers_ui_preset_ahah',
    'access callback' => TRUE,
    'file' => 'includes/openlayers_ui.presets.inc',
    'type' => MENU_CALLBACK,
  );
  $items['openlayers/ahah/style_plugin/%'] = array(
    'title' => 'OpenLayers Style Plugin AHAH',
    'page callback' => 'openlayers_ui_style_plugin_ahah',
    'page arguments' => array(
      3,
    ),
    // 3rd url item (the '%') is first arg
    'access callback' => TRUE,
    'file' => 'includes/openlayers_ui.styles.inc',
    'type' => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Implementation of hook_theme().
 */
function openlayers_ui_theme($existing, $type, $theme, $path) {
  return array(
    'openlayers_ui_form_layer_description' => array(
      'arguments' => array(
        'layer_title' => '',
        'layer_description' => '',
      ),
      'file' => 'includes/openlayers_ui.theme.inc',
    ),
    'openlayers_ui_form_projection_description' => array(
      'arguments' => array(
        'projection_title' => '',
        'available_layers' => array(),
        'layers' => array(),
      ),
      'file' => 'includes/openlayers_ui.theme.inc',
    ),
    'openlayers_ui_presets_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
      'file' => 'includes/openlayers_ui.theme.inc',
    ),
    'openlayers_ui_presets_form_layers' => array(
      'arguments' => array(
        'form' => array(),
      ),
      'file' => 'includes/openlayers_ui.theme.inc',
    ),
    'openlayers_ui_presets_form_behaviors' => array(
      'arguments' => array(
        'form' => array(),
      ),
      'file' => 'includes/openlayers_ui.theme.inc',
    ),
  );
}

/**
 * Menu callback for Layers.
 */
function openlayers_ui_object_list($type) {
  $rows = array();
  switch ($type) {
    case 'styles':
      $objects = openlayers_styles(TRUE);
      break;
    case 'layers':
      $objects = openlayers_layers_load(TRUE);
      break;
    case 'presets':
      $objects = openlayers_presets(TRUE);
      break;
  }

  // Make table of presets and actions
  if ($type == 'layers') {
    $header = array(
      t('Title'),
      t('Type'),
      t('Description'),
      t('Actions'),
    );
    $layer_types = openlayers_layer_types();
  }
  elseif ($type == 'presets') {
    $header = array(
      t('Title'),
      t('Layers'),
      t('Description'),
      t('Actions'),
    );
    $layers = openlayers_layers_load();
  }
  else {
    $header = array(
      t('Title'),
      t('Description'),
      t('Actions'),
    );
  }

  // Create table rows
  foreach ($objects as $object) {
    $row = array();
    $links = array();
    switch ($object->export_type) {
      case EXPORT_IN_DATABASE | EXPORT_IN_CODE:
        $row[] = filter_xss_admin($object->title) . ' <em><small>(' . t('Overridden') . ')</small></em>';
        break;
      case EXPORT_IN_DATABASE:
        $row[] = filter_xss_admin($object->title) . ' <em><small>(' . t('Normal') . ')</small></em>';
        break;
      case EXPORT_IN_CODE:
        $row[] = filter_xss_admin($object->title) . ' <em><small>(' . t('Default') . ')</small></em>';
        break;
    }
    if ($type == 'layers') {
      $row[] = filter_xss_admin($layer_types[$object->data['layer_type']]['title']);
    }
    elseif ($type == 'presets') {
      if (!empty($object->data['layers'])) {
        $layer_names = array();
        foreach ($object->data['layers'] as $layer) {
          $layer_names[] = empty($layers[$layer]->title) ? $layer : filter_xss_admin($layers[$layer]->title);
        }
        $row[] = '<small>' . implode(', ', $layer_names) . '</small>';
      }
      else {
        $row[] = '';
      }
    }
    $row[] = filter_xss_admin($object->description);

    // Check preset type and create links accordingly.
    if ($object->export_type == (EXPORT_IN_CODE | EXPORT_IN_DATABASE)) {
      $links[] = l(t('Edit'), "admin/build/openlayers/{$type}/{$object->name}/edit");
      $links[] = l(t('Revert'), "admin/build/openlayers/{$type}/{$object->name}/delete");
    }
    elseif ($object->export_type == EXPORT_IN_DATABASE) {
      $links[] = l(t('Edit'), "admin/build/openlayers/{$type}/{$object->name}/edit");
      $links[] = l(t('Delete'), "admin/build/openlayers/{$type}/{$object->name}/delete");
    }
    $links[] = l(t('Export'), "admin/build/openlayers/{$type}/{$object->name}/export");
    $links[] = l(t('Clone'), "admin/build/openlayers/{$type}/clone/{$object->name}");
    $row[] = implode(' | ', $links);
    $rows[] = $row;
  }

  // Output themed table
  $output = theme('table', $header, $rows);
  return $output;
}

/**
 * Menu callback for object delete form.
 */
function openlayers_ui_object_delete(&$form_state, $type, $object) {
  if ($object->export_type & EXPORT_IN_DATABASE) {

    // Create delete form
    $form = array(
      'type' => array(
        '#type' => 'value',
        '#value' => $type,
      ),
      'object' => array(
        '#type' => 'value',
        '#value' => $object,
      ),
    );
    $message = $object->export_type & EXPORT_IN_CODE ? t('Are you sure you want to revert %object?', array(
      '%object' => $object->title,
    )) : t('Are you sure you want to delete %object?', array(
      '%object' => $object->title,
    ));
    return confirm_form($form, $message, 'admin/build/openlayers/' . $type);
  }
}

/**
 * Form Submit Callback for Preset Delete Form
 */
function openlayers_ui_object_delete_submit($form, &$form_state) {
  $type = $form_state['values']['type'];
  $object = $form_state['values']['object'];
  switch ($type) {
    case 'styles':
      $result = openlayers_style_delete($object);
      break;
    case 'layers':
      $result = openlayers_layer_delete($object);
      break;
    case 'presets':
      $result = openlayers_preset_delete($object);
      break;
  }

  // Check query results
  if ($result) {
    drupal_set_message(t('%name was deleted.', array(
      '%name' => $object->name,
    )));
  }
  else {
    drupal_set_message(t('Error when attempting to delete %name.', array(
      '%name' => $object->name,
    )), 'error');
  }

  // Redirect
  $form_state['redirect'] = 'admin/build/openlayers/' . $type;
}

/**
 * Menu callback for object export form.
 */
function openlayers_ui_object_export(&$form_state, $type, $object) {

  // Determine type
  switch ($type) {
    case 'styles':
      $api = 'openlayers_styles';
      break;
    case 'layers':
      $api = 'openlayers_layers';
      break;
    case 'presets':
      $api = 'openlayers_map_presets';
      break;
  }

  // Use CTools to create export code
  ctools_include('export');
  $schema = ctools_export_get_schema($api);
  $identifier = $schema['export']['identifier'];
  $code = '$items = array();' . "\n";
  $code .= ctools_export_object($api, $object, '');
  $code .= '$items["' . $object->name . '"] = $' . $identifier . ';' . "\n";
  $code .= 'return $items;';
  $rows = substr_count($code, "\n") + 1;

  // Create form
  $form = array();
  $form['export'] = array(
    '#type' => 'textarea',
    '#default_value' => $code,
    '#rows' => $rows,
    '#resizable' => FALSE,
  );
  $form['done'] = array(
    '#type' => 'submit',
    '#value' => t('Done'),
  );
  $form['#redirect'] = 'admin/build/openlayers/' . $type;
  return $form;
}

/**
 * Import a preset from cut & paste
 */
function openlayers_ui_import_page(&$form_state) {
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Preset name'),
    '#description' => t('Enter the name to use for this preset if it is different from the source preset. Leave blank to use the name of the preset.'),
  );
  $form['view'] = array(
    '#type' => 'textarea',
    '#title' => t('Paste preset code here'),
    '#required' => TRUE,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Import'),
    '#submit' => array(
      'openlayers_ui_import_submit',
    ),
    '#validate' => array(
      'openlayers_ui_import_validate',
    ),
  );
  return $form;
}

/**
 * Validate handler to import a preset
 */
function openlayers_ui_import_validate($form, &$form_state) {
  $view = '';
  ob_start();
  eval($form_state['values']['preset']);
  ob_end_clean();
  if (!is_object($preset)) {
    return form_error($form['view'], t('Unable to interpret preset code.'));
  }

  // View name must be alphanumeric or underscores, no other punctuation.
  if (!empty($form_state['values']['name']) && preg_match('/[^a-zA-Z0-9_]/', $form_state['values']['name'])) {
    form_error($form['name'], t('Preset name must be alphanumeric or underscores only.'));
  }
  if ($form_state['values']['name']) {
    $preset->name = $form_state['values']['name'];
  }
  $test = openlayers_preset_load($preset->name);
  if ($test && $test->type != t('Default')) {
    form_set_error('', t('A preset by that name already exists; please choose a different name'));
  }

  // TODO: The import process should test layer existence
  $form_state['preset'] =& $preset;
}

/**
 * Get projection options.
 *
 * @return
 *   Array of projection options suitable for use in a FormAPI element.
 */
function openlayers_ui_get_projection_options() {
  $options = array();
  foreach (openlayers_layers_load() as $key => $layer) {
    if ($layer->data['projection']) {
      foreach ($layer->data['projection'] as $projection) {
        $options[$projection] = $projection;
      }
    }
  }
  return $options;
}

/**
 * Get layer options.
 */
function openlayers_ui_get_layer_options($type = 'baselayer', $projection = NULL) {
  $options = array();
  $layers = array();

  // Get layers in an array
  foreach (openlayers_layers_load() as $l) {
    $layers[$l->name] = openlayers_get_layer_object($l);
  }

  // Go through layers to theme output.
  foreach ($layers as $key => $layer) {

    // not filtering by projection
    // this layer has an appropriate projection
    // this layer can be reprojected because it is vector
    if (!isset($projection) || in_array($projection, $layer->data['projection']) || !empty($layer->data['vector'])) {
      if ($type == 'baselayer' && $layer->data['baselayer']) {
        $options[$key] = theme('openlayers_ui_form_layer_description', $layer->title, $layer->description);
      }
      elseif ($type != 'baselayer' && empty($layer->data['baselayer'])) {
        $options[$key] = theme('openlayers_ui_form_layer_description', $layer->title, $layer->description);
      }
    }
  }
  return $options;
}

/**
 * Get style options.
 *
 * @return
 *   Array of style options suitable for use in a FormAPI element.
 */
function openlayers_ui_get_style_options() {
  $options = array();
  foreach (openlayers_styles() as $key => $style) {
    $options[$key] = $style->title;
  }
  return $options;
}

/**
 * dependencies widget helper
 * @param $dependencies
 *  Array of Javascript dependencies as strings of function names
 * @return $form
 *  Form element of dependencies if any
 */
function openlayers_dependency_widget($dependencies) {
  if (is_array($dependencies) > 0) {
    $dependency_form = array();
    foreach ($dependencies as $dependency) {
      $dependency_form[] = array(
        '#type' => 'markup',
        '#value' => "<div class='openlayers-dependency-flag'>\n             <span class='openlayers-dependency-value'>{$dependency}</span>" . "<span class='openlayers-dependency-broken'>" . t('Dependency not found:') . ' ' . $dependency . "</span>" . "</div>",
      );
    }
    return $dependency_form;
  }
}

Functions

Namesort descending Description
openlayers_dependency_widget dependencies widget helper
openlayers_ui_get_layer_options Get layer options.
openlayers_ui_get_projection_options Get projection options.
openlayers_ui_get_style_options Get style options.
openlayers_ui_help Implementation of hook_help
openlayers_ui_import_page Import a preset from cut & paste
openlayers_ui_import_validate Validate handler to import a preset
openlayers_ui_menu Implementation of hook_menu
openlayers_ui_object_delete Menu callback for object delete form.
openlayers_ui_object_delete_submit Form Submit Callback for Preset Delete Form
openlayers_ui_object_export Menu callback for object export form.
openlayers_ui_object_list Menu callback for Layers.
openlayers_ui_perm Implementation of hook_perm
openlayers_ui_theme Implementation of hook_theme().