function mmenu_admin_settings_form_submit in Mobile sliding menu 7.3
Same name and namespace in other branches
- 7 mmenu.admin.inc \mmenu_admin_settings_form_submit()
- 7.2 mmenu.admin.inc \mmenu_admin_settings_form_submit()
Form submission handler for mmenu_admin_settings_form().
File
- ./
mmenu.admin.inc, line 1299 - Mmenu administration menu items.
Code
function mmenu_admin_settings_form_submit($form_id, &$form_state) {
$values = $form_state['values'];
switch ($values['op']) {
case t('Save'):
$blocks = array();
// Updates the blocks.
foreach ($values['blocks'] as $k => $block) {
if (!empty($block['module_delta'])) {
$v = explode('|', $block['module_delta']);
$blocks[$k] = $block;
$blocks[$k] += array(
'module' => $v[0],
'delta' => $v[1],
);
}
}
// Add extension options.
$extensions = mmenu_extension_list();
$extension_values = array();
foreach ($extensions as $extension) {
if (!empty($values['options'][$extension['name']]['options'])) {
if (is_array($values['options'][$extension['name']]['options'])) {
$options = array_filter($values['options'][$extension['name']]['options']);
$extension_values = array_merge($extension_values, array_values($options));
}
else {
$extension_values[] = $values['options'][$extension['name']]['options'];
}
}
}
$values['options']['extensions'] = $extension_values;
$navbars = array();
// Add header.
if ($values['options']['navbarElements']['header']['add'] === 'true') {
$navbars[] = array(
'position' => 'top',
'content' => array(
'prev',
'title',
'next',
),
'height' => $values['options']['navbarElements']['header']['height'],
);
$values['options']['navbar']['title'] = $values['options']['navbarElements']['header']['title'];
}
else {
$navbars[] = array(
'position' => 'top',
'content' => array(
'prev',
'next',
),
);
}
// Add footer.
if ($values['options']['navbarElements']['footer']['add'] === 'true') {
$navbars[] = array(
'position' => 'bottom',
'content' => [
'<div class="mm-title">' . $values['options']['navbarElements']['footer']['title'] . '</div>',
],
'height' => $values['options']['navbarElements']['footer']['height'],
);
}
$values['options']['navbars'] = $navbars;
$mmenu = array(
'enabled' => $values['general']['enabled'],
'title' => $values['general']['title'],
'name' => $values['general']['name'],
'blocks' => $blocks,
'options' => mmenu_convert_settings('options', $values['options']),
'configurations' => mmenu_convert_settings('configurations', $values['configurations']),
);
variable_set('mmenu_item_' . $values['general']['name'], $mmenu);
// Clears mmenus cache.
cache_clear_all('mmenus', 'cache');
drupal_set_message(t('The settings have been saved.'));
break;
case t('Reset'):
// Deletes the mmenu settings from database.
variable_del('mmenu_item_' . $values['general']['name']);
// Clears mmenus cache.
cache_clear_all('mmenus', 'cache');
drupal_set_message(t('The settings have been reset.'));
break;
}
}