Starting to work through image style edit form
parent
aea01c1c9d
commit
a803505f4a
|
|
@ -38,13 +38,6 @@ function image_style_form($form, &$form_state, $style) {
|
||||||
$title = t('Edit %name style', array('%name' => $style['name']));
|
$title = t('Edit %name style', array('%name' => $style['name']));
|
||||||
drupal_set_title($title, PASS_THROUGH);
|
drupal_set_title($title, PASS_THROUGH);
|
||||||
|
|
||||||
// Adjust this form for styles that must be overridden to edit.
|
|
||||||
$editable = (bool) ($style['storage'] & IMAGE_STORAGE_EDITABLE);
|
|
||||||
|
|
||||||
if (!$editable && empty($form_state['input'])) {
|
|
||||||
drupal_set_message(t('This image style is currently being provided by a module. Click the "Override defaults" button to change its settings.'), 'warning');
|
|
||||||
}
|
|
||||||
|
|
||||||
$form_state['image_style'] = $style;
|
$form_state['image_style'] = $style;
|
||||||
$form['#tree'] = TRUE;
|
$form['#tree'] = TRUE;
|
||||||
$form['#attached']['css'][drupal_get_path('module', 'image') . '/image.admin.css'] = array();
|
$form['#attached']['css'][drupal_get_path('module', 'image') . '/image.admin.css'] = array();
|
||||||
|
|
@ -56,17 +49,6 @@ function image_style_form($form, &$form_state, $style) {
|
||||||
'#markup' => theme('image_style_preview', array('style' => $style)),
|
'#markup' => theme('image_style_preview', array('style' => $style)),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Allow the name of the style to be changed, unless this style is
|
|
||||||
// provided by a module's hook_default_image_styles().
|
|
||||||
if ($style['storage'] & IMAGE_STORAGE_MODULE) {
|
|
||||||
$form['name'] = array(
|
|
||||||
'#type' => 'item',
|
|
||||||
'#title' => t('Image style name'),
|
|
||||||
'#markup' => $style['name'],
|
|
||||||
'#description' => t('This image style is being provided by %module module and may not be renamed.', array('%module' => $style['module'])),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$form['name'] = array(
|
$form['name'] = array(
|
||||||
'#type' => 'textfield',
|
'#type' => 'textfield',
|
||||||
'#size' => '64',
|
'#size' => '64',
|
||||||
|
|
@ -76,7 +58,6 @@ function image_style_form($form, &$form_state, $style) {
|
||||||
'#element_validate' => array('image_style_name_validate'),
|
'#element_validate' => array('image_style_name_validate'),
|
||||||
'#required' => TRUE,
|
'#required' => TRUE,
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
// Build the list of existing image effects for this image style.
|
// Build the list of existing image effects for this image style.
|
||||||
$form['effects'] = array(
|
$form['effects'] = array(
|
||||||
|
|
@ -95,26 +76,20 @@ function image_style_form($form, &$form_state, $style) {
|
||||||
'#title' => t('Weight for @title', array('@title' => $effect['label'])),
|
'#title' => t('Weight for @title', array('@title' => $effect['label'])),
|
||||||
'#title_display' => 'invisible',
|
'#title_display' => 'invisible',
|
||||||
'#default_value' => $effect['weight'],
|
'#default_value' => $effect['weight'],
|
||||||
'#access' => $editable,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Only attempt to display these fields for editable styles as the 'ieid'
|
|
||||||
// key is not set for styles defined in code.
|
|
||||||
if ($editable) {
|
|
||||||
$form['effects'][$key]['configure'] = array(
|
$form['effects'][$key]['configure'] = array(
|
||||||
'#type' => 'link',
|
'#type' => 'link',
|
||||||
'#title' => t('edit'),
|
'#title' => t('edit'),
|
||||||
'#href' => 'admin/config/media/image-styles/edit/' . $style['name'] . '/effects/' . $effect['ieid'],
|
'#href' => 'admin/config/media/image-styles/edit/' . $style['name'] . '/effects/' . $effect['ieid'],
|
||||||
'#access' => $editable && isset($effect['form callback']),
|
'#access' => isset($effect['form callback']),
|
||||||
);
|
);
|
||||||
$form['effects'][$key]['remove'] = array(
|
$form['effects'][$key]['remove'] = array(
|
||||||
'#type' => 'link',
|
'#type' => 'link',
|
||||||
'#title' => t('delete'),
|
'#title' => t('delete'),
|
||||||
'#href' => 'admin/config/media/image-styles/edit/' . $style['name'] . '/effects/' . $effect['ieid'] . '/delete',
|
'#href' => 'admin/config/media/image-styles/edit/' . $style['name'] . '/effects/' . $effect['ieid'] . '/delete',
|
||||||
'#access' => $editable,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Build the new image effect addition form and add it to the effect list.
|
// Build the new image effect addition form and add it to the effect list.
|
||||||
$new_effect_options = array();
|
$new_effect_options = array();
|
||||||
|
|
@ -124,7 +99,6 @@ function image_style_form($form, &$form_state, $style) {
|
||||||
$form['effects']['new'] = array(
|
$form['effects']['new'] = array(
|
||||||
'#tree' => FALSE,
|
'#tree' => FALSE,
|
||||||
'#weight' => isset($form_state['input']['weight']) ? $form_state['input']['weight'] : NULL,
|
'#weight' => isset($form_state['input']['weight']) ? $form_state['input']['weight'] : NULL,
|
||||||
'#access' => $editable,
|
|
||||||
);
|
);
|
||||||
$form['effects']['new']['new'] = array(
|
$form['effects']['new']['new'] = array(
|
||||||
'#type' => 'select',
|
'#type' => 'select',
|
||||||
|
|
@ -148,17 +122,9 @@ function image_style_form($form, &$form_state, $style) {
|
||||||
|
|
||||||
// Show the Override or Submit button for this style.
|
// Show the Override or Submit button for this style.
|
||||||
$form['actions'] = array('#type' => 'actions');
|
$form['actions'] = array('#type' => 'actions');
|
||||||
$form['actions']['override'] = array(
|
|
||||||
'#type' => 'submit',
|
|
||||||
'#value' => t('Override defaults'),
|
|
||||||
'#validate' => array(),
|
|
||||||
'#submit' => array('image_style_form_override_submit'),
|
|
||||||
'#access' => !$editable,
|
|
||||||
);
|
|
||||||
$form['actions']['submit'] = array(
|
$form['actions']['submit'] = array(
|
||||||
'#type' => 'submit',
|
'#type' => 'submit',
|
||||||
'#value' => t('Update style'),
|
'#value' => t('Update style'),
|
||||||
'#access' => $editable,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue