1 layout.admin.inc | layout_delete_form($form, &$form_state, $layout) |
Form callback. Delete or revert a layout.
Related topics
File
- core/
modules/ layout/ layout.admin.inc, line 2600 - Admin page callbacks for the Layout module.
Code
function layout_delete_form($form, &$form_state, $layout) {
$form_state['layout'] = $layout;
$delete_layout = ($layout->storage === LAYOUT_STORAGE_NORMAL);
if ($delete_layout) {
$question = t('Delete layout @title?', array('@title' => $layout->title));
if (layout_removal_removes_page($layout)) {
$path = $layout->getPath();
$site_config = config('system.core');
if ($path == $site_config->get('site_frontpage')) {
$text = t('This layout creates a page at %path that is used as the home page of the site.', array('%path' => $path)) . ' ' . t(' If you delete or disable this layout, that page will be removed.') . ' ' . _layout_site_info_page_message('edit-front-page', t('home page'));
}
elseif ($path == $site_config->get('site_403')) {
$text = t('This layout creates a page at %path that is used as the default 403 (access denied) page of the site.', array('%path' => $path)) . ' ' . t(' If you delete or disable this layout, that page will be removed.') . ' ' . _layout_site_info_page_message('edit-error-page', t('403 page'));
}
elseif ($path == $site_config->get('site_404')) {
$url = url('admin/config/system/site-information') . '#edit-error-page';
$text = t('This layout creates a page at %path that is used as the default 404 (not found) page of the site.', array('%path' => $path)) . ' ' . t(' If you delete or disable this layout, that page will be removed.') . ' ' . _layout_site_info_page_message('edit-error-page', t('404 page'));
}
else {
$text = t('Are you sure you want to delete this layout?') . ' ' . t('The page at %path will be completely removed.') . ' ' . t('This action cannot be undone. You may prefer to disable the layout instead.', array('%path' => $path));
}
}
else {
// We're deleting the layout, but there will still be a page at its path.
$text = t('Are you sure you want to delete this layout?') . ' ' . t('This action cannot be undone. You may prefer to disable the layout instead.');
}
$button_text = t('Delete layout');
}
else {
$question = t('Revert layout @title?', array('@title' => $layout->title));
$text = t('Reverting the layout will delete any changes, reverting it to the original default layout provided by the %module module.', array('%module' => $layout->module));
$button_text = t('Revert layout');
}
$form = confirm_form($form, $question, 'admin/structure/layouts', $text, $button_text);
if ($delete_layout) {
// Add a disable layout button to the standard confirmation form.
$cancel = array_pop($form['actions']);
$form['actions']['disable'] = array(
'#type' => 'submit',
'#value' => t('Disable layout'),
);
$form['actions']['cancel'] = $cancel;
}
return $form;
}