You are here

function openlayers_ui_style_plugin_ahah in Openlayers 6.2

1 string reference to 'openlayers_ui_style_plugin_ahah'
openlayers_ui_menu in modules/openlayers_ui/openlayers_ui.module
Implementation of hook_menu

File

modules/openlayers_ui/includes/openlayers_ui.styles.inc, line 505
This file holds the functions handling styles in the Openlayers UI.

Code

function openlayers_ui_style_plugin_ahah($propname) {
  $posted = $_POST["data"][$propname];
  $plugname = $posted['uses_plugin'];

  // Get cached form
  $form_state = array(
    'storage' => NULL,
    'submitted' => FALSE,
  );
  $form_build_id = $_POST['form_build_id'];
  $form_cached = form_get_cache($form_build_id, $form_state);

  // Get style_data from cached form, and defaults
  $style_data = $form_cached['style_data']['#value'];
  $defaults = $style_data['defaults'];
  if (!$plugname) {

    // Find default value
    $property = $style_data['definitions'][$propname];
    $def_value = $property['default'];
    if (isset($defaults[$propname]) && !is_array($defaults[$propname])) {
      $def_value = $defaults[$propname];
    }
    $form = array(
      '#type' => !isset($property['options']) ? 'textfield' : 'select',
      '#default_value' => $def_value,
    );

    // Add options if needed
    if (isset($property['options']) && is_array($property['options'])) {
      $form['value']['#options'] = $property['options'];
    }
    $form['#parents'] = array(
      'data',
      $propname,
      'value',
    );
  }
  else {

    // Find default value
    $defs = array();
    if (isset($defaults[$propname]) && is_array($defaults[$propname]) && $defaults[$propname]['plugin'] == $plugname) {
      $defs = $defaults[$propname]['conf'];
    }
    $form = openlayers_ui_get_style_plugin_form($plugname, $defs);
    $form['#parents'] = array(
      'data',
      $propname,
      'plugin',
    );
  }
  $form_state = array();

  // TODO: what to do with this ?
  $plugin_form_built = form_builder('style_plugin_form', $form, $form_state);
  $output = drupal_render($plugin_form_built);

  // Final rendering callback.
  drupal_json(array(
    'status' => TRUE,
    'data' => $output,
  ));
}