You are here

function xmlsitemap_custom_edit_link_form in XML sitemap 7.2

Same name and namespace in other branches
  1. 6.2 xmlsitemap_custom/xmlsitemap_custom.admin.inc \xmlsitemap_custom_edit_link_form()

Edit Link Form.

1 string reference to 'xmlsitemap_custom_edit_link_form'
xmlsitemap_custom_menu in xmlsitemap_custom/xmlsitemap_custom.module
Implements hook_menu().

File

xmlsitemap_custom/xmlsitemap_custom.admin.inc, line 71
Administrative page callbacks for the xmlsitemap_custom.

Code

function xmlsitemap_custom_edit_link_form($form, &$form_state, $link = array()) {
  module_load_include('inc', 'xmlsitemap', 'xmlsitemap.admin');
  _xmlsitemap_set_breadcrumb('admin/config/search/xmlsitemap/custom');
  $link += array(
    'id' => db_query("SELECT MAX(id) FROM {xmlsitemap} WHERE type = 'custom'")
      ->fetchField() + 1,
    'loc' => '',
    'priority' => XMLSITEMAP_PRIORITY_DEFAULT,
    'lastmod' => 0,
    'changefreq' => 0,
    'changecount' => 0,
    'language' => LANGUAGE_NONE,
  );
  $form['type'] = array(
    '#type' => 'value',
    '#value' => 'custom',
  );
  $form['id'] = array(
    '#type' => 'value',
    '#value' => $link['id'],
  );
  $form['loc'] = array(
    '#type' => 'textfield',
    '#title' => t('Path to link'),
    '#field_prefix' => url('', array(
      'absolute' => TRUE,
    )),
    '#default_value' => $link['loc'] ? drupal_get_path_alias($link['loc'], $link['language']) : '',
    '#required' => TRUE,
    '#size' => 30,
  );
  $form['priority'] = array(
    '#type' => 'select',
    '#title' => t('Priority'),
    '#options' => xmlsitemap_get_priority_options(),
    '#default_value' => number_format($link['priority'], 1),
    '#description' => t('The priority of this URL relative to other URLs on your site.'),
  );
  $form['changefreq'] = array(
    '#type' => 'select',
    '#title' => t('Change frequency'),
    '#options' => array(
      0 => t('None'),
    ) + xmlsitemap_get_changefreq_options(),
    '#default_value' => $link['changefreq'],
    '#description' => t('How frequently the page is likely to change. This value provides general information to search engines and may not correlate exactly to how often they crawl the page.'),
  );
  $languages = module_exists('locale') ? locale_language_list() : array();
  $form['language'] = array(
    '#type' => 'select',
    '#title' => t('Language'),
    '#default_value' => $link['language'],
    '#options' => array(
      LANGUAGE_NONE => t('Language neutral'),
    ) + $languages,
    '#access' => $languages,
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 5,
  );
  $form['actions']['cancel'] = array(
    '#markup' => l(t('Cancel'), 'admin/config/search/xmlsitemap/custom'),
    '#weight' => 10,
  );
  return $form;
}