You are here

function om_maximenu_admin_submit in OM Maximenu 6

Same name and namespace in other branches
  1. 8 inc/om_maximenu.admin.inc \om_maximenu_admin_submit()
  2. 7 inc/om_maximenu.admin.inc \om_maximenu_admin_submit()

1 Submit for all settings

File

inc/om_maximenu.admin.inc, line 839
OM Maximenu Admin Configuration

Code

function om_maximenu_admin_submit($form, $form_state) {
  global $_om_maximenu_variable;
  $om_maximenu = $_om_maximenu_variable;
  $form_values = $form_state['values'];
  $om_maximenu_array = $form_state['values']['om_maximenus'];

  //dsm($om_maximenu_array);
  foreach ($om_maximenu_array as $menu_id => $maximenu_content) {

    // menu will not be included in the array if the title is not modified and delete field is checked
    if (!empty($maximenu_content['title']) && $maximenu_content['title'] != 'New Menu' && $maximenu_content['delete'] != 1) {
      $om_maximenu[$menu_id] = array(
        'code' => $maximenu_content['code'],
        'title' => $maximenu_content['title'],
        'action' => $maximenu_content['action'],
        'skin' => $maximenu_content['skin'],
        'style' => $maximenu_content['style'],
        'output' => $maximenu_content['output'],
      );
      if ($maximenu_content['style'] == '') {
        if (isset($maximenu_content['style_options']['disabled']) && $maximenu_content['style_options']['disabled'] == 1) {
          $om_maximenu[$menu_id]['disabled'] = 1;
        }
        if (isset($maximenu_content['style_options']['displace']) && $maximenu_content['style_options']['displace'] == 1) {
          $om_maximenu[$menu_id]['displace'] = 1;
        }
        if (isset($maximenu_content['style_options']['delay']) && $maximenu_content['style_options']['delay'] != '') {
          $om_maximenu[$menu_id]['delay'] = $maximenu_content['style_options']['delay'];
        }
        if (isset($maximenu_content['style_options']['fadeout']) && $maximenu_content['style_options']['fadeout'] == 0) {
          $om_maximenu[$menu_id]['fadeout'] = 0;
        }
      }
      if ($maximenu_content['style'] != 'roundabout' && $maximenu_content['style'] != 'accordion') {
        if (isset($maximenu_content['other_options']['active']) && $maximenu_content['other_options']['active'] == 1) {
          $om_maximenu[$menu_id]['active'] = 1;
        }
        if (isset($maximenu_content['other_options']['longmenu']) && !empty($maximenu_content['other_options']['longmenu'])) {
          $om_maximenu[$menu_id]['longmenu'] = $maximenu_content['other_options']['longmenu'];
        }
        if (isset($maximenu_content['other_options']['animated_bg']) && $maximenu_content['other_options']['animated_bg'] == 1) {
          $om_maximenu[$menu_id]['animated_bg'] = 1;
        }
        if (isset($maximenu_content['other_options']['animated_link']) && $maximenu_content['other_options']['animated_link'] == 1) {
          $om_maximenu[$menu_id]['animated_link'] = 1;
        }
        if (isset($maximenu_content['other_options']['jiggle']) && $maximenu_content['other_options']['jiggle'] == 1) {
          $om_maximenu[$menu_id]['jiggle'] = 1;
        }
        if (isset($maximenu_content['other_options']['modal_content']) && $maximenu_content['other_options']['modal_content'] == 1) {
          $om_maximenu[$menu_id]['modal_content'] = 1;
        }
      }
      if (isset($maximenu_content['scroll']) && $maximenu_content['scroll'] == 1) {
        $om_maximenu[$menu_id]['scroll'] = 1;
      }
      $om_maximenu[$menu_id]['menu_visibility']['visibility'] = isset($maximenu_content['menu_visibility']['visibility']) && !empty($maximenu_content['menu_visibility']['visibility']) ? $maximenu_content['menu_visibility']['visibility'] : 0;
      $om_maximenu[$menu_id]['menu_visibility']['pages'] = isset($maximenu_content['menu_visibility']['pages']) && !empty($maximenu_content['menu_visibility']['pages']) ? $maximenu_content['menu_visibility']['pages'] : '';
      if ($maximenu_content['output'] == 'block') {
        $om_maximenu[$menu_id]['block_options']['stacking'] = $maximenu_content['block_options']['stacking'];
        $om_maximenu[$menu_id]['block_options']['direction'] = $maximenu_content['block_options']['direction'];
        $om_maximenu[$menu_id]['block_options']['region'] = $maximenu_content['block_options']['region'];
        $om_maximenu[$menu_id]['block_options']['weight'] = $maximenu_content['block_options']['weight'];

        // because we are handling the visibility, etc., we have to handle everything to synch with blocks settings
        om_maximenu_update_blocks_db($menu_id, $maximenu_content);
      }
      elseif ($maximenu_content['output'] == 'float') {
        $om_maximenu[$menu_id]['float_options']['position'] = $maximenu_content['float_options']['position'];
        $om_maximenu[$menu_id]['float_options']['y_origin'] = $maximenu_content['float_options']['y_origin'];
        $om_maximenu[$menu_id]['float_options']['y_value'] = $maximenu_content['float_options']['y_value'];
        $om_maximenu[$menu_id]['float_options']['x_origin'] = $maximenu_content['float_options']['x_origin'];
        if ($maximenu_content['float_options']['x_origin'] != 'middle') {
          $om_maximenu[$menu_id]['float_options']['x_value'] = $maximenu_content['float_options']['non_middle_options']['x_value'];
          $om_maximenu[$menu_id]['float_options']['stacking'] = $maximenu_content['float_options']['non_middle_options']['stacking'];
          $om_maximenu[$menu_id]['float_options']['orientation'] = $maximenu_content['float_options']['non_middle_options']['orientation'];
        }
        if ($maximenu_content['float_options']['dock']) {
          $om_maximenu[$menu_id]['float_options']['dock'] = 1;
        }

        // menu as float must be deleted from block table
        om_maximenu_update_blocks_db($menu_id, $maximenu_content);
      }
      elseif ($maximenu_content['output'] == 'main_menu') {

        // menu as main_menu must be deleted from blocks table
        om_maximenu_update_blocks_db($menu_id, $maximenu_content);
      }
      foreach ($maximenu_content['links'] as $link => $link_prop) {

        // links will not be included in the array if the title is not modified and delete field is checked
        if (!empty($link_prop['link_title']) && $link_prop['link_title'] != 'New Link' && $link_prop['link_delete'] != 1 && is_numeric($link)) {
          $om_maximenu[$menu_id]['links'][$link] = array(
            'link_title' => $link_prop['link_title'],
            'link_title_option' => $link_prop['title_options']['link_title_option'],
            'path_icon' => $link_prop['title_options']['path_icon'],
            'icon_option' => $link_prop['title_options']['icon_option'],
            'php_option' => $link_prop['title_options']['php_option'],
            'path' => $link_prop['path'],
            'path_query' => $link_prop['path_query'],
            'path_fragment' => $link_prop['path_fragment'],
            'weight' => $link_prop['weight'],
            'id' => $link_prop['attributes']['id'],
            'class' => $link_prop['attributes']['class'],
            'rel' => $link_prop['attributes']['rel'],
            'target' => $link_prop['attributes']['target'],
            'description' => $link_prop['attributes']['description'],
            'description_option' => $link_prop['attributes']['description_option'],
            'roles' => $link_prop['permission']['roles'],
            'content' => isset($link_prop['content']) ? $link_prop['content'] : '',
          );
        }
      }
      if ($form_values['op'] == t('Cancel')) {
        drupal_goto('admin/settings/om-maximenu');
      }
      drupal_set_message(t($om_maximenu[$menu_id]['title'] . ' has been saved.'));
    }
    elseif (isset($maximenu_content['delete']) && $maximenu_content['delete'] == 1) {
      if ($form_values['op'] == t('Cancel')) {
        drupal_goto('admin/settings/om-maximenu');
      }
      drupal_set_message(t($om_maximenu[$menu_id]['title'] . ' has been deleted.'));
      unset($om_maximenu[$menu_id]);
    }
  }

  // Save all settings in 1 variable
  variable_set('om_maximenu', $om_maximenu);
  if ($_GET['q'] != 'admin/settings/om-maximenu/maxedit') {
    drupal_goto('admin/settings/om-maximenu');
  }
}