1 layout.admin.inc | layout_condition_add_form_submit($form, &$form_state) |
Submit handler for layout_condition_add_form().
Saves a condition into the layout, block, or menu item.
File
- core/
modules/ layout/ layout.admin.inc, line 2262 - Admin page callbacks for the Layout module.
Code
function layout_condition_add_form_submit($form, &$form_state) {
/* @var Layout $layout */
$layout = $form_state['layout'];
/* @var Block $block */
$block = $form_state['block'];
/* @var LayoutMenuItem $menu_item */
$menu_item = $form_state['menu_item'];
if (!isset($form_state['handler'])) {
return;
}
/* @var LayoutAccess $handler */
$handler = $form_state['handler'];
$handler->formSubmit($form, $form_state);
if (!empty($handler->is_new)) {
$handler->is_new = FALSE;
if ($menu_item) {
$menu_item->conditions[] = $handler;
}
elseif ($block) {
$block->conditions[] = $handler;
}
else {
$layout->conditions[] = $handler;
}
}
if ($menu_item) {
layout_set_layout_tempstore($menu_item, 'menu_item');
}
else {
layout_set_layout_tempstore($layout);
}
// Update the portion of the page for menu item access.
if ($menu_item) {
$form_state['ajax_rebuild_form'] = 'layout_menu_item_form';
$form_state['ajax_rebuild_args'] = array($menu_item);
$form_state['ajax_update'] = array('conditions');
$form_state['redirect'] = 'admin/structure/layouts/menu/' . $menu_item->name;
}
// Blocks return to the dialog/page for editing that block.
elseif ($block) {
$renderer_name = isset($layout->in_progress['renderer_name']) ? $layout->in_progress['renderer_name'] : 'editor';
$renderer = layout_create_renderer($renderer_name, $layout);
$form_state['redirect'] = $renderer->getUrl('configure-block', $block->uuid);
}
// Set the portion of the page to be updated for layouts.
else {
$form_state['ajax_rebuild_form'] = 'layout_settings_form';
$form_state['ajax_rebuild_args'] = array($layout);
$form_state['ajax_update'] = array('conditions');
$form_state['redirect'] = 'admin/structure/layouts/manage/' . $layout->name . '/configure';
}
}