[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/xmlsitemap/xmlsitemap_engines/ -> xmlsitemap_engines.admin.inc (source)

   1  <?php
   2  // $Id: xmlsitemap_engines.admin.inc,v 1.1.4.14 2010/02/04 23:15:18 davereid Exp $
   3  
   4  /**
   5   * @file
   6   * Administrative page callbacks for the xmlsitemap_engines module.
   7   */
   8  
   9  /**
  10   * Form builder; Administration settings form.
  11   */
  12  function xmlsitemap_engines_settings_form() {
  13    // Build the list of support engines for the checkboxes options.
  14    $engines = xmlsitemap_engines_get_engine_info();
  15    $engine_options = array();
  16    foreach ($engines as $engine => $engine_info) {
  17      $engine_options[$engine] = $engine_info['name'];
  18    }
  19    asort($engine_options);
  20  
  21    $form['xmlsitemap_engines_engines'] = array(
  22      '#type' => 'checkboxes',
  23      '#title' => t('Submit the sitemap to the following engines'),
  24      '#default_value' => variable_get('xmlsitemap_engines_engines', array()),
  25      '#options' => $engine_options,
  26    );
  27    $form['xmlsitemap_engines_minimum_lifetime'] = array(
  28      '#type' => 'select',
  29      '#title' => t('Do not submit more often than every'),
  30      '#options' => drupal_map_assoc(array(300, 900, 1800, 3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 604800 * 2, 604800 * 4), 'format_interval'),
  31      '#default_value' => variable_get('xmlsitemap_engines_minimum_lifetime', 86400),
  32    );
  33    $form['xmlsitemap_engines_submit_updated'] = array(
  34      '#type' => 'checkbox',
  35      '#title' => t('Only submit if the sitemap has been updated since the last submission.'),
  36      '#default_value' => variable_get('xmlsitemap_engines_submit_updated', TRUE),
  37    );
  38    $form['xmlsitemap_engines_custom_urls'] = array(
  39      '#type' => 'textarea',
  40      '#title' => t('Custom submission URLs'),
  41      '#description' => t('Enter one URL per line. The token [sitemap] will be replaced with the URL to your sitemap. For example: %example-before would become %example-after.', array('%example-before' => 'http://example.com/ping?[sitemap]', '%example-after' => xmlsitemap_engines_prepare_url('http://example.com/ping?[sitemap]', url('sitemap.xml', array('absolute' => TRUE))))),
  42      '#default_value' => variable_get('xmlsitemap_engines_custom_urls', ''),
  43      '#rows' => 2,
  44      '#wysiwyg' => FALSE,
  45      '#element_validate' => array('xmlsitemap_engines_validate_custom_urls'),
  46    );
  47  
  48    // Ensure the xmlsitemap_engines variable gets filterd to a simple array.
  49    $form['array_filter'] = array('#type' => 'value', '#value' => TRUE);
  50  
  51    return system_settings_form($form);
  52  }
  53  
  54  /**
  55   * Validate the custom submission URL element.
  56   */
  57  function xmlsitemap_engines_validate_custom_urls($element, &$form_state) {
  58    $custom_urls = preg_split('/[\r\n]+/', $element['#value'], -1, PREG_SPLIT_NO_EMPTY);
  59    foreach ($custom_urls as $custom_url) {
  60      $url = xmlsitemap_engines_prepare_url($custom_url, '');
  61      if (!valid_url($url, TRUE)) {
  62        form_error($element, t('Invalid URL %url.', array('%url' => $custom_url)));
  63      }
  64    }
  65    $form_state['values']['xmlsitemap_engines_custom_urls'] = implode("\n", $custom_urls);
  66  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7