You are here

function xmlsitemap_settings_form in XML sitemap 6.2

Same name and namespace in other branches
  1. 7.2 xmlsitemap.admin.inc \xmlsitemap_settings_form()

Form builder; Administration settings form.

See also

system_settings_form()

xmlsitemap_settings_form_validate()

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

File

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

Code

function xmlsitemap_settings_form() {
  $form['xmlsitemap_minimum_lifetime'] = array(
    '#type' => 'select',
    '#title' => t('Minimum sitemap lifetime'),
    '#options' => array(
      0 => t('No minimum'),
    ) + drupal_map_assoc(array(
      300,
      900,
      1800,
      3600,
      10800,
      21600,
      43200,
      86400,
      172800,
      259200,
      604800,
    ), 'format_interval'),
    '#description' => t('The minimum amount of time that will elapse before the sitemaps are regenerated. The sitemaps will also only be regenerated on cron if any links have been added, updated, or deleted.') . '<br />' . t('Recommended value: %value.', array(
      '%value' => t('1 day'),
    )),
    '#default_value' => variable_get('xmlsitemap_minimum_lifetime', 0),
  );
  $form['xmlsitemap_xsl'] = array(
    '#type' => 'checkbox',
    '#title' => t('Include a stylesheet in the sitemaps for humans.'),
    '#description' => t('When enabled, this will add formatting and tables with sorting to make it easier to view the XML sitemap data instead of viewing raw XML output. Search engines will ignore this.'),
    '#default_value' => variable_get('xmlsitemap_xsl', 1),
  );
  $form['xmlsitemap_prefetch_aliases'] = array(
    '#type' => 'checkbox',
    '#title' => t('Prefetch URL aliases during sitemap generation.'),
    '#description' => t('When enabled, this will fetch all URL aliases at once instead of one at a time during sitemap generation. For medium or large sites, it is recommended to disable this feature as it uses a lot of memory.'),
    '#default_value' => variable_get('xmlsitemap_prefetch_aliases', 1),
  );
  $form['advanced'] = array(
    '#type' => 'fieldset',
    '#title' => t('Advanced settings'),
    '#collapsible' => TRUE,
    '#collapsed' => !variable_get('xmlsitemap_developer_mode', 0),
    '#weight' => 10,
    '#group' => FALSE,
  );

  //$form['advanced']['xmlsitemap_gz'] = array(

  //  '#type' => 'checkbox',
  //  '#title' => t('Generate additional compressed sitemaps using gzip.'),
  //  '#default_value' => xmlsitemap_var('gz'),
  //  '#disabled' => !function_exists('gzencode'),

  //);
  $form['advanced']['xmlsitemap_chunk_size'] = array(
    '#type' => 'select',
    '#title' => t('Number of links in each sitemap page'),
    '#options' => array(
      'auto' => t('Automatic (recommended)'),
    ) + drupal_map_assoc(array(
      100,
      500,
      1000,
      2500,
      5000,
      10000,
      25000,
      XMLSITEMAP_MAX_SITEMAP_LINKS,
    )),
    '#default_value' => xmlsitemap_var('chunk_size'),
    // @todo This description is not clear.
    '#description' => t('If there are problems with rebuilding the sitemap, you may want to manually set this value. If you have more than @max links, an index with multiple sitemap pages will be generated. There is a maximum of @max sitemap pages.', array(
      '@max' => XMLSITEMAP_MAX_SITEMAP_LINKS,
    )),
  );
  $form['advanced']['xmlsitemap_batch_limit'] = array(
    '#type' => 'select',
    '#title' => t('Maximum number of sitemap links to process at once'),
    '#options' => drupal_map_assoc(array(
      5,
      10,
      25,
      50,
      100,
      250,
      500,
      1000,
      2500,
      5000,
    )),
    '#default_value' => xmlsitemap_var('batch_limit'),
    '#description' => t('If you have problems running cron or rebuilding the sitemap, you may want to lower this value.'),
  );
  $directory = xmlsitemap_get_directory();
  file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS, 'xmlsitemap_path');
  $form['advanced']['xmlsitemap_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Sitemap cache directory'),
    '#default_value' => variable_get('xmlsitemap_path', 'xmlsitemap'),
    '#size' => 30,
    '#maxlength' => 255,
    '#description' => t('Subdirectory where the sitemap data will be stored. This folder <strong>must not be shared</strong> with any other Drupal site or install using XML sitemap.'),
    '#field_prefix' => file_directory_path() . '/',
    '#required' => TRUE,
  );
  $form['advanced']['xmlsitemap_base_url'] = array(
    '#type' => 'textfield',
    '#title' => t('Default base URL'),
    '#default_value' => variable_get('xmlsitemap_base_url', $GLOBALS['base_url']),
    '#size' => 30,
    '#description' => t('This is the default base URL used for sitemaps and sitemap links.'),
    '#required' => TRUE,
  );
  $form['advanced']['xmlsitemap_lastmod_format'] = array(
    '#type' => 'select',
    '#title' => t('Last modification date format'),
    '#options' => array(
      XMLSITEMAP_LASTMOD_SHORT => t('Short'),
      XMLSITEMAP_LASTMOD_MEDIUM => t('Medium'),
      XMLSITEMAP_LASTMOD_LONG => t('Long'),
    ),
    '#default_value' => variable_get('xmlsitemap_lastmod_format', XMLSITEMAP_LASTMOD_MEDIUM),
  );
  foreach ($form['advanced']['xmlsitemap_lastmod_format']['#options'] as $key => &$label) {
    $label .= ' (' . gmdate($key, REQUEST_TIME) . ')';
  }
  $form['advanced']['xmlsitemap_developer_mode'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable developer mode to expose additional settings.'),
    '#default_value' => variable_get('xmlsitemap_developer_mode', 0),
  );
  $form['advanced']['xmlsitemap_disable_cron_regeneration'] = array(
    '#type' => 'checkbox',
    '#title' => t('Disable cron generation of sitemap files.'),
    '#default_value' => variable_get('xmlsitemap_disable_cron_regeneration', 0),
    '#description' => t('This can be disabled if other methods are being used to generate the sitemap files, like <em>drush xmlsitemap-regenerate</em>.'),
  );
  $entities = xmlsitemap_get_link_info(NULL, TRUE);
  module_load_all_includes('inc', 'xmlsitemap');
  foreach ($entities as $entity => $entity_info) {
    $form[$entity] = array(
      '#type' => 'fieldset',
      '#title' => $entity_info['label'],
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#group' => 'xmlsitemap_settings',
      '#weight' => 20,
    );
    if (!empty($entity_info['bundles'])) {

      // If this entity has bundles, show a bundle setting summary.
      xmlsitemap_add_form_entity_summary($form[$entity], $entity, $entity_info);
    }
    if (!empty($entity_info['xmlsitemap']['settings callback'])) {

      // Add any entity-specific settings.
      $entity_info['xmlsitemap']['settings callback']($form[$entity]);
    }

    // Ensure that the entity fieldset is not shown if there are no accessible
    // sub-elements.
    $form[$entity]['#access'] = (bool) xmlsitemap_element_get_visible_children($form[$entity]);
  }
  $form['#pre_render'][] = 'vertical_tabs_form_pre_render';
  $form['#validate'][] = 'xmlsitemap_settings_form_validate';
  $form['#submit'][] = 'xmlsitemap_settings_form_submit';
  $form['array_filter'] = array(
    '#type' => 'value',
    '#value' => TRUE,
  );
  $form = system_settings_form($form);
  $form['buttons']['#weight'] = 100;
  return $form;
}