function xmlsitemap_add_form_link_options in XML sitemap 6.2
Same name and namespace in other branches
- 8 xmlsitemap.module \xmlsitemap_add_form_link_options()
- 7.2 xmlsitemap.admin.inc \xmlsitemap_add_form_link_options()
- 2.x xmlsitemap.module \xmlsitemap_add_form_link_options()
Add a link's XML sitemap options to the link's form.
@todo Add changefreq overridability.
5 calls to xmlsitemap_add_form_link_options()
- xmlsitemap_menu_form_menu_edit_item_alter in xmlsitemap_menu/
xmlsitemap_menu.module - Implements hook_form_FORM_ID_alter().
- xmlsitemap_node_form_alter in xmlsitemap_node/
xmlsitemap_node.module - Implements hook_form_alter().
- xmlsitemap_taxonomy_form_taxonomy_form_term_alter in xmlsitemap_taxonomy/
xmlsitemap_taxonomy.module - Implements hook_form_FORM_ID_alter().
- xmlsitemap_user_form_user_profile_form_alter in xmlsitemap_user/
xmlsitemap_user.module - Implements hook_form_FORM_ID_alter().
- xmlsitemap_user_form_user_register_alter in xmlsitemap_user/
xmlsitemap_user.module - Implements hook_form_FORM_ID_alter().
File
- ./
xmlsitemap.admin.inc, line 669 - Administrative page callbacks for the xmlsitemap module.
Code
function xmlsitemap_add_form_link_options(array &$form, $entity, $bundle, $id) {
$info = xmlsitemap_get_link_info($entity);
if (!$info || empty($info['bundles'][$bundle])) {
return;
}
if (!($link = xmlsitemap_link_load($entity, $id))) {
$link = array();
}
$bundle_info = xmlsitemap_link_bundle_load($entity, $bundle);
$link += array(
'access' => 1,
'status' => $bundle_info['status'],
'status_default' => $bundle_info['status'],
'status_override' => 0,
'priority' => $bundle_info['priority'],
'priority_default' => $bundle_info['priority'],
'priority_override' => 0,
);
$form['xmlsitemap'] = array(
'#type' => 'fieldset',
'#tree' => TRUE,
'#title' => t('XML sitemap'),
'#collapsible' => TRUE,
'#collapsed' => !$link['status_override'] && !$link['priority_override'],
'#access' => user_access('administer xmlsitemap') || xmlsitemap_link_bundle_access($bundle_info),
'#group' => 'additional_settings',
'#attached' => array(
'js' => array(
'vertical-tabs' => drupal_get_path('module', 'xmlsitemap') . '/xmlsitemap.js',
),
),
);
if (xmlsitemap_link_bundle_access($bundle_info) && ($path = xmlsitemap_get_bundle_path($entity, $bundle))) {
$form['xmlsitemap']['description'] = array(
'#prefix' => '<div class="description">',
'#suffix' => '</div>',
'#value' => t('The default XML sitemap settings for this @bundle can be changed <a href="@link-type">here</a>.', array(
'@bundle' => drupal_strtolower($info['bundle label']),
'@link-type' => url($path, array(
'query' => drupal_get_destination(),
)),
)),
);
}
// Show a warning if the link is not accessible and will not be included in
// the sitemap.
if ($id && !$link['access']) {
$form['xmlsitemap']['warning'] = array(
'#type' => 'markup',
'#prefix' => '<p><strong>',
'#suffix' => '</strong></p>',
'#value' => 'This item is not currently visible to anonymous users, so it will not be included in the sitemap.',
);
}
// Status field (inclusion/exclusion)
$form['xmlsitemap']['status'] = array(
'#type' => 'select',
'#title' => t('Inclusion'),
'#options' => xmlsitemap_get_status_options($link['status_default']),
'#default_value' => $link['status_override'] ? $link['status'] : 'default',
);
$form['xmlsitemap']['status_default'] = array(
'#type' => 'value',
'#value' => $link['status_default'],
);
$form['xmlsitemap']['status_override'] = array(
'#type' => 'value',
'#value' => $link['status_override'],
);
// Priority field
$form['xmlsitemap']['priority'] = array(
'#type' => 'select',
'#title' => t('Priority'),
'#options' => xmlsitemap_get_priority_options($link['priority_default']),
'#default_value' => $link['priority_override'] ? number_format($link['priority'], 1) : 'default',
'#description' => t('The priority of this URL relative to other URLs on your site.'),
'#process' => array(
'form_expand_ahah',
'ctools_dependent_process',
),
'#dependency' => array(
'edit-xmlsitemap-status' => array(
1,
),
),
);
if ($link['status_default']) {
$form['xmlsitemap']['priority']['#dependency']['edit-xmlsitemap-status'][] = 'default';
}
$form['xmlsitemap']['priority_default'] = array(
'#type' => 'value',
'#value' => $link['priority_default'],
);
$form['xmlsitemap']['priority_override'] = array(
'#type' => 'value',
'#value' => $link['priority_override'],
);
// Other persistent fields.
//$form['xmlsitemap']['lastmod'] = array(
// '#type' => 'value',
// '#value' => $node->xmlsitemap['lastmod'],
//);
//$form['xmlsitemap']['changefreq'] = array(
// '#type' => 'value',
// '#value' => $node->xmlsitemap['changefreq'],
//);
//$form['xmlsitemap']['changecount'] = array(
// '#type' => 'value',
// '#value' => $node->xmlsitemap['changecount'],
//);
// Hide the priority field if the link is excluded.
if (module_exists('ctools')) {
ctools_include('dependent');
}
// Add the submit handler to adjust the default values if selected.
$form += array(
'#submit' => array(),
);
if (!in_array('xmlsitemap_process_form_link_options', $form['#submit'])) {
array_unshift($form['#submit'], 'xmlsitemap_process_form_link_options');
}
}