You are here

function xmlsitemap_rebuild_form in XML sitemap 7.2

Same name and namespace in other branches
  1. 6.2 xmlsitemap.admin.inc \xmlsitemap_rebuild_form()

Menu callback; Confirm rebuilding of the sitemap.

See also

xmlsitemap_rebuild_form_submit()

1 string reference to 'xmlsitemap_rebuild_form'
xmlsitemap_menu in ./xmlsitemap.module
Implements hook_menu().

File

./xmlsitemap.admin.inc, line 506
Administrative page callbacks for the xmlsitemap module.

Code

function xmlsitemap_rebuild_form() {
  if (!$_POST && !variable_get('xmlsitemap_rebuild_needed', FALSE)) {
    if (!variable_get('xmlsitemap_regenerate_needed', FALSE)) {
      drupal_set_message(t('Your sitemap is up to date and does not need to be rebuilt.'), 'error');
    }
    else {
      $_REQUEST += array(
        'destination' => 'admin/config/search/xmlsitemap',
      );
      drupal_set_message(t('A rebuild is not necessary. If you are just wanting to regenerate the XML sitemap files, you can <a href="@link-cron">run cron manually</a>.', array(
        '@link-cron' => url('admin/reports/status/run-cron', array(
          'query' => drupal_get_destination(),
        )),
      )), 'warning');
    }
  }

  // Build a list of rebuildable link types.
  module_load_include('generate.inc', 'xmlsitemap');
  $rebuild_types = xmlsitemap_get_rebuildable_link_types();
  $form['entities'] = array(
    '#type' => 'select',
    '#title' => t("Select which link types you would like to rebuild"),
    '#description' => t('If no link types are selected, the sitemap files will just be regenerated.'),
    '#multiple' => TRUE,
    '#options' => drupal_map_assoc($rebuild_types),
    '#default_value' => variable_get('xmlsitemap_rebuild_needed', FALSE) || !variable_get('xmlsitemap_developer_mode', 0) ? $rebuild_types : array(),
    '#access' => variable_get('xmlsitemap_developer_mode', 0),
  );
  $form['save_custom'] = array(
    '#type' => 'checkbox',
    '#title' => t('Save and restore any custom inclusion and priority links.'),
    '#default_value' => TRUE,
  );
  return confirm_form($form, t('Are you sure you want to rebuild the XML sitemap?'), 'admin/config/search/xmlsitemap', '', t('Rebuild sitemap'), t('Cancel'));
}