function styles_ui_preset_edit_form in Styles 6.2
Same name and namespace in other branches
- 6 contrib/styles_ui/includes/styles_ui.admin.inc \styles_ui_preset_edit_form()
- 7 contrib/styles_ui/styles_ui.admin.inc \styles_ui_preset_edit_form()
Callback for the preset edit form.
File
- contrib/
styles_ui/ includes/ styles_ui.admin.inc, line 94 - styles/contrib/styles_ui/includes/styles_ui.admin.inc Administrative page callbacks for the Styles UI module.
Code
function styles_ui_preset_edit_form($form, $form_state, $field_type, $preset_name) {
$field_types = _content_field_types();
$presets = styles_presets();
$preset = $presets[$field_type][$preset_name];
$styles_containers = styles_containers();
$containers = $styles_containers[$field_type]['containers'];
drupal_set_title(t('Edit @field_type style preset: @preset', array(
'@field_type' => $field_types[$field_type]['label'],
'@preset' => $preset_name,
)));
$form = array();
$form['containers'] = array(
'#type' => 'vertical_tabs',
);
// Begin the settings array to send to jQuery.
$settings = array(
'stylesUI' => array(
'url' => url('styles-ui/preview'),
'fieldType' => check_plain($field_type),
),
);
foreach ($containers as $container_name => $container) {
$form['containers'][$container_name] = array(
'#type' => 'fieldset',
'#title' => $container['label'],
);
$this_preset = array_pop($preset[$container_name]);
$options = array();
foreach ($container['available styles'] as $style_name => $style) {
$options[$style_name] = $style_name;
}
// Store the container name in the 'rel' attribute for later AJAX previews.
$rel = check_plain($container_name);
$form['containers'][$container_name]['preset_' . $container_name] = array(
'#type' => 'radios',
'#title' => t('Style preset'),
'#default_value' => $this_preset['name'],
'#options' => $options,
'#attributes' => array(
'class' => array(
'styles-ui-preset',
),
'rel' => $rel,
),
);
// Add a preview.
if (isset($containers[$container_name]['themes']['preview'])) {
$preview = '<div id="styles-ui-preview-wrapper-' . $rel . '" class="styles-ui-preview-wrapper">' . theme($containers[$container_name]['themes']['preview'], array(
'field_type' => $field_type,
'container_name' => $container_name,
'style_name' => $this_preset['name'],
)) . '</div>';
$form['containers'][$container_name]['preview_' . $container_name] = array(
'#type' => 'item',
'#title' => t('Style preview'),
'#markup' => $preview,
);
}
}
// Add the javascript for live previews on radio select.
drupal_add_js(drupal_get_path('module', 'styles_ui') . '/themes/js/styles_ui.admin.js');
drupal_add_js($settings, 'setting');
return $form;
}