function path_breadcrumbs_ui_argument_context_form_submit in Path Breadcrumbs 7.2
Same name and namespace in other branches
- 7.3 path_breadcrumbs_ui/path_breadcrumbs_ui.module \path_breadcrumbs_ui_argument_context_form_submit()
Submit callback for contexts selection form.
_state
Parameters
$form:
File
- path_breadcrumbs_ui/
path_breadcrumbs_ui.module, line 1023 - Provide user interface for CRUD operations with path breadcrumbs.
Code
function path_breadcrumbs_ui_argument_context_form_submit($form, &$form_state) {
$values = $form_state['values'];
$actions = $form_state['values']['actions'];
$keyword = $form_state['storage']['keyword'];
$path_name = $form_state['storage']['path_name'];
// Load breadcrumb from cache storage.
$breadcrumb = path_breadcrumbs_object_cache_get($path_name);
if (!$breadcrumb) {
return;
}
// Save keyword's argument.
if (!empty($values['argument'])) {
// Unset argument's settings and selection rules if it was changed.
if (!empty($breadcrumb->arguments[$keyword]['argument']) && $breadcrumb->arguments[$keyword]['argument'] != $values['argument']) {
// Unset arguments settings.
unset($breadcrumb->arguments[$keyword]['settings']);
// Search for selection rules for old argument.
if (!empty($breadcrumb->access['plugins'])) {
foreach ($breadcrumb->access['plugins'] as $key => $access) {
if ($access['context'] == $keyword) {
unset($breadcrumb->access['plugins'][$key]);
}
}
}
}
// Save new argument.
$breadcrumb->arguments[$keyword]['argument'] = $values['argument'];
// Save argument in storage.
$form_state['storage']['argument'] = $values['argument'];
}
// Save argument's settings.
if (!empty($values['settings'])) {
$breadcrumb->arguments[$keyword]['settings'] = $values['settings'];
}
// Save breadcrumb in cache.
path_breadcrumbs_object_cache_set($path_name, $breadcrumb);
// Switch current step.
if (isset($actions['next']) && $values['op'] == $actions['next']) {
$form_state['storage']['step']++;
}
elseif (isset($actions['prev']) && $values['op'] == $actions['prev']) {
$form_state['storage']['step']--;
}
elseif (isset($actions['finish']) && $values['op'] == $actions['finish']) {
$form_state['rebuild'] = FALSE;
}
$form_state['rebuild'] = TRUE;
}