You are here

function _openlayers_upgrade_1xto2x_convert_styles in Openlayers 6.2

Converting styles for the upgrade from 1.x to 2.x

Parameters

$map: Reference to map array

$ret: Reference to return array

1 call to _openlayers_upgrade_1xto2x_convert_styles()
_openlayers_upgrade_1xto2x in ./openlayers.install
Function to handle upgrading from 1.x to 2.x

File

./openlayers.install, line 486
This file holds the functions for the installing and enabling of the openlayers module.

Code

function _openlayers_upgrade_1xto2x_convert_styles(&$map = array(), &$ret = array()) {

  // Go through styles
  if (isset($map['styles']) && is_array($map['style'])) {
    foreach ($map['styles'] as $id => $style) {

      // Named styles are the same
      // Convert style arrays and store in DB
      if (is_array($style)) {

        // Create new object
        $new_style = new stdClass();
        $new_style->api_version = 1;
        $new_style->name = $id;
        $new_style->title = ucwords(str_replace('_', ' ', $id));
        $new_style->description = ucwords(str_replace('_', ' ', $id));
        $new_style->data = $style;

        // Save new style object
        $success = drupal_write_record('openlayers_styles', $style);
        $ret[] = array(
          'success' => $success ? TRUE : FALSE,
          'query' => 'Attempt to save style: ' . $id,
        );

        // Now put back in map array
        if ($success) {
          $map['style'][$id] = $id;
        }
      }
    }
  }
}