function xmlsitemap_settings_form in XML sitemap 7.2
Same name and namespace in other branches
- 6.2 xmlsitemap.admin.inc \xmlsitemap_settings_form()
Form builder; Administration settings form.
See also
xmlsitemap_settings_form_validate()
1 string reference to 'xmlsitemap_settings_form'
- xmlsitemap_menu in ./
xmlsitemap.module - Implements hook_menu().
File
- ./
xmlsitemap.admin.inc, line 283 - Administrative page callbacks for the xmlsitemap module.
Code
function xmlsitemap_settings_form($form, &$form_state) {
global $base_url;
$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['xmlsitemap_robotstxt'] = array(
'#type' => 'checkbox',
'#title' => t('Enable RobotsTxt support'),
'#description' => t('When enabled, this will add all sitemaps to the robots.txt generated by <a href="@drupal-robotstxt">the RobotsTxt</a>.', array(
'@drupal-robotstxt' => 'https://www.drupal.org/project/robotstxt',
)),
'#default_value' => variable_get('xmlsitemap_robotstxt', 1),
);
// Allow to skip pages that might have 301 redirect set.
if (module_exists('redirect')) {
$form['xmlsitemap_redirect'] = array(
'#type' => 'checkbox',
'#title' => t('Skip pages that have 301 redirects set.'),
'#description' => t('Prevents pages which are 301 redirects to be saved in sitemap.'),
'#default_value' => variable_get('xmlsitemap_redirect', 0),
);
}
$form['advanced'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced settings'),
'#collapsible' => TRUE,
'#collapsed' => !variable_get('xmlsitemap_developer_mode', 0),
'#weight' => 10,
);
$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.'),
);
if (!xmlsitemap_check_directory()) {
form_set_error('xmlsitemap_path', t('The directory %directory does not exist or is not writable.', array(
'%directory' => xmlsitemap_get_directory(),
)));
}
$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_build_uri(''),
'#required' => TRUE,
);
$form['advanced']['xmlsitemap_base_url'] = array(
'#type' => 'textfield',
'#title' => t('Default base URL'),
'#default_value' => variable_get('xmlsitemap_base_url', $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>.'),
);
$form['advanced']['xmlsitemap_output_elements'] = array(
'#type' => 'checkboxes',
'#title' => t('Enable or disable the individual @loc elements from output', array(
'@loc' => '<loc>',
)),
'#options' => array(
'lastmod' => t('Last modification date: @lastmod', array(
'@lastmod' => '<lastmod>',
)),
'changefreq' => t('Change frequency: @changfreq', array(
'@changfreq' => '<changefreq>',
)),
'priority' => t('Priority: @priority', array(
'@priority' => '<priority>',
)),
),
'#default_value' => drupal_map_assoc(variable_get('xmlsitemap_output_elements', array(
'lastmod',
'changefreq',
'priority',
))),
);
$form['xmlsitemap_settings'] = array(
'#type' => 'vertical_tabs',
'#weight' => 20,
);
$entities = xmlsitemap_get_link_info(NULL, TRUE);
module_load_all_includes('xmlsitemap.inc');
foreach ($entities as $entity => $entity_info) {
$form[$entity] = array(
'#type' => 'fieldset',
'#title' => $entity_info['label'],
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'xmlsitemap_settings',
);
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) element_get_visible_children($form[$entity]);
}
$form['#validate'][] = 'xmlsitemap_settings_form_validate';
$form['#submit'][] = 'xmlsitemap_settings_form_submit';
array_unshift($form['#submit'], 'xmlsitemap_form_submit_flag_regenerate');
$form['array_filter'] = array(
'#type' => 'value',
'#value' => TRUE,
);
$form = system_settings_form($form);
return $form;
}