function openlayers_ui_object_export in Openlayers 6.2
Menu callback for object export form.
2 string references to 'openlayers_ui_object_export'
- openlayers_ui_menu in modules/
openlayers_ui/ openlayers_ui.module - Implementation of hook_menu
- openlayers_views_form_alter in modules/
openlayers_views/ openlayers_views.module - Implementation of hook_form_alter()
File
- modules/
openlayers_ui/ openlayers_ui.module, line 510
Code
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;
}