You are here

function xmlsitemap_link_bundle_settings_form_submit in XML sitemap 7.2

Same name and namespace in other branches
  1. 8 xmlsitemap.module \xmlsitemap_link_bundle_settings_form_submit()
  2. 6.2 xmlsitemap.module \xmlsitemap_link_bundle_settings_form_submit()
  3. 2.x xmlsitemap.module \xmlsitemap_link_bundle_settings_form_submit()

Link bundle settings form submit.

1 string reference to 'xmlsitemap_link_bundle_settings_form_submit'
xmlsitemap_add_link_bundle_settings in ./xmlsitemap.admin.inc
Add the link type XML sitemap options to the link type's form.

File

./xmlsitemap.module, line 1499
xmlsitemap XML sitemap

Code

function xmlsitemap_link_bundle_settings_form_submit($form, &$form_state) {
  $entity = $form['xmlsitemap']['#entity'];
  $bundle = $form['xmlsitemap']['#bundle'];

  // Handle new bundles by fetching the proper bundle key value from the form
  // state values.
  if (empty($bundle)) {
    $entity_info = $form['xmlsitemap']['#entity_info'];
    if (isset($entity_info['bundle keys']['bundle'])) {
      $bundle_key = $entity_info['bundle keys']['bundle'];
      if (isset($form_state['values'][$bundle_key])) {
        $bundle = $form_state['values'][$bundle_key];
        $form['xmlsitemap']['#bundle'] = $bundle;
      }
    }
  }
  xmlsitemap_link_bundle_settings_save($entity, $bundle, $form_state['values']['xmlsitemap']);
  $entity_info = $form['xmlsitemap']['#entity_info'];
  if (!empty($form['xmlsitemap']['#show_message'])) {
    drupal_set_message(t('XML sitemap settings for the @bundle-label %bundle have been saved.', array(
      '@bundle-label' => drupal_strtolower($entity_info['bundle label']),
      '%bundle' => $entity_info['bundles'][$bundle]['label'],
    )));
  }

  // Unset the form values since we have already saved the bundle settings and
  // we don't want these values to get saved as variables in-case this form
  // Also uses system_settings_form().
  unset($form_state['values']['xmlsitemap']);
}