1 layout.flexible.inc | layout_flexible_template_delete_form($form, &$form_state, LayoutFlexibleTemplate $flexible_template) |
Menu callback; Delete a flexible template.
Related topics
File
- core/
modules/ layout/ layout.flexible.inc, line 859 - Provides configurable (flexible) layout templates.
Code
function layout_flexible_template_delete_form($form, &$form_state, LayoutFlexibleTemplate $flexible_template) {
$form_state['flexible_template'] = &$flexible_template;
$question = t('Delete flexible template @title?', array('@title' => $flexible_template->title));
$description = t('This action cannot be undone.');
backdrop_set_title($question, PASS_THROUGH);
// Check if this template is in use.
$errors = array();
foreach (layout_load_all() as $layout) {
if ($layout->layout_template == $flexible_template->name) {
$errors[] = check_plain($layout->title);
}
}
if (!empty($errors)) {
backdrop_set_message(t('The "@title" layout template is currently in use in the following layouts and may not be deleted: !list', array('@title' => $flexible_template->title, '!list' => theme('item_list', array('items' => $errors)))), 'error');
}
else {
$form['description'] = array(
'#markup' => $description
);
}
$form['actions'] = array(
'#type' => 'actions'
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#disabled' => !empty($errors),
'#value' => t('Delete template'),
'#attributes' => array('class' => array('button-danger')),
);
$form['actions']['cancel'] = array(
'#type' => 'link',
'#title' => t('Cancel'),
'#href' => 'admin/structure/layouts/settings',
);
$form['#attributes']['class'][] = 'confirmation';
$form['#theme'] = 'confirm_form';
return $form;
}