You are here

function openlayers_get_presets in Openlayers 6

Get Formatted Presets

Get Presets and formats accordingly

Parameters

$format: String to determine format of results

  • simple: 'preset_name' => 'Preset Title'
  • full: 'preset_name' => array( full preset data )

$reset: Boolean whether to reset or not

Return value

Return formatted data

Related topics

10 calls to openlayers_get_presets()
openlayers_cck_field_formatter_info in modules/openlayers_cck/openlayers_cck.module
Implementation of hook_field_formatter_info().
openlayers_cck_theme in modules/openlayers_cck/openlayers_cck.module
Implementation of hook_theme().
openlayers_cck_widget_settings in modules/openlayers_cck/openlayers_cck.module
Implementation of hook_widget_settings().
openlayers_features_export_options in includes/openlayers.features.inc
Implementation of hook_features_export_options().
openlayers_features_revert in includes/openlayers.features.inc
Implementation of hook_features_revert().

... See full list

File

./openlayers.module, line 517
Main OpenLayers API File

Code

function openlayers_get_presets($format = 'simple', $reset = FALSE) {
  static $data = array();
  static $simple = array();
  static $full = array();

  // Check if data has already been pulled
  // (there should at least be the default)
  if (empty($data) || $reset == TRUE) {
    $data = openlayers_presets($reset);
  }

  // Check if format variable has data
  if (empty(${$format}) || $reset == TRUE) {
    $return = array();

    // Go through results
    foreach ($data as $name => $preset) {

      // Determine how to format data
      switch ($format) {
        case 'simple':
          $return[$preset['preset_name']] = $preset['preset_title'];
          break;
        case 'full':
          $return[$preset['preset_name']] = $preset;
          break;
      }
    }
    return $return;
  }
  else {
    return ${$format};
  }
}