You are here

function xmlsitemap_node_form_alter in XML sitemap 5

Same name and namespace in other branches
  1. 5.2 xmlsitemap_node/xmlsitemap_node.module \xmlsitemap_node_form_alter()
  2. 6.2 xmlsitemap_node/xmlsitemap_node.module \xmlsitemap_node_form_alter()
  3. 6 xmlsitemap_node/xmlsitemap_node.module \xmlsitemap_node_form_alter()

Implementation of hook_form_alter().

Related topics

File

xmlsitemap_node/xmlsitemap_node.module, line 169
Adds nodes to the site map.

Code

function xmlsitemap_node_form_alter($form_id, &$form) {
  switch ($form_id) {
    case $form['type']['#value'] . '_node_form':
      if (isset($form['type'])) {
        $node = $form['#node'];
        if (user_access('override node priority')) {
          $form['xmlsitemap_node'] = array(
            '#type' => 'fieldset',
            '#title' => t('Site map settings'),
            '#collapsible' => TRUE,
            '#collapsed' => TRUE,
            '#weight' => 30,
          );
          $options = xmlsitemap_priority_options('both');
          $default = variable_get("xmlsitemap_node_type_priority_{$node->type}", '0.5');
          $form['xmlsitemap_node']['priority_override'] = array(
            '#type' => 'select',
            '#title' => t('Site map priority'),
            '#default_value' => $node->priority_override,
            '#options' => $options,
            '#description' => t('The default priority is %priority.', array(
              '%priority' => $options[$default],
            )),
          );
        }
        else {
          $form['priority_override'] = array(
            '#type' => 'value',
            '#value' => $node->priority_override,
          );
        }
        $form['xmlsitemap_node_status'] = array(
          '#type' => 'value',
          '#value' => $node->status,
        );
      }
      break;
    case 'node_type_form':
      if (isset($form['identity']['type'])) {
        $form['xmlsitemap_node'] = array(
          '#type' => 'fieldset',
          '#title' => t('Site map'),
          '#collapsible' => TRUE,
          '#collapsed' => TRUE,
        );
        $form['xmlsitemap_node']['xmlsitemap_node_type_priority'] = array(
          '#type' => 'select',
          '#title' => t('Priority adjustment'),
          '#default_value' => variable_get("xmlsitemap_node_type_priority_{$form['#node_type']->type}", 0.5),
          '#options' => xmlsitemap_priority_options('exclude'),
          '#description' => t('This number will be added to the priority of this content type.'),
        );
        $form['xmlsitemap_old_priority'] = array(
          '#type' => 'value',
          '#value' => variable_get("xmlsitemap_node_type_priority_{$form['#node_type']->type}", 0.5),
        );
        $form['#submit']['_xmlsitemap_node_submit'] = array();
        $form['submit']['#weight'] = 1;
        $form['reset']['#weight'] = 1;
      }
      break;
    case 'xmlsitemap_settings_sitemap':
      $form['xmlsitemap_node'] = array(
        '#type' => 'fieldset',
        '#title' => t('Content priority'),
        '#description' => t('The default priority for specific content types can be set on the !link pages.', array(
          '!link' => l(t('content type settings'), 'admin/content/types'),
        )),
      );
      $form['xmlsitemap_node']['xmlsitemap_node_promote_priority'] = array(
        '#type' => 'select',
        '#title' => t('Promotion adjustment'),
        '#default_value' => variable_get('xmlsitemap_node_promote_priority', 0.3),
        '#options' => xmlsitemap_priority_options(),
        '#description' => t('This number will be added to the priority of each post that is promoted to the front page.'),
      );
      $form['xmlsitemap_node']['xmlsitemap_node_comment_priority'] = array(
        '#type' => 'select',
        '#title' => t('Comment ratio weight'),
        '#default_value' => variable_get('xmlsitemap_node_comment_priority', 0.5),
        '#options' => xmlsitemap_priority_options(),
        '#description' => t('This number will be multiplied by the ratio of the number of comments on a post to the highest number of comments on any post—that is, this number will be added to the priority of the post with the most comments.'),
      );
      $form['xmlsitemap_node']['xmlsitemap_node_count_comments'] = array(
        '#type' => 'checkbox',
        '#title' => t('Count comments in change date and frequency'),
        '#default_value' => variable_get('xmlsitemap_node_count_comments', TRUE),
        '#description' => t('If enabled, the frequency of comments on a post will affect its change frequency and last modification date.'),
      );
      $form['buttons']['#weight'] = 1;
      break;
  }
}