Commit 41bc0ab8 authored by Dave Reid's avatar Dave Reid
Browse files

#786384 by Dave Reid: Remove modal dialog dependency on dialog.module and add...

#786384 by Dave Reid: Remove modal dialog dependency on dialog.module and add re-usable modal link API.
by Dave Reid: Fixed recursive bug with xmlsitemap_get_entity_info() and xmlsitemap_link_bundle_load().
parent aae90fea
......@@ -84,16 +84,8 @@ function xmlsitemap_sitemap_list_form() {
//$options[$smid]['#attributes']['class'][] = 'warning';
$operations = array();
$operations['edit'] = array(
'title' => t('Edit'),
'href' => 'admin/config/search/xmlsitemap/edit/' . $smid,
'query' => $destination,
);
$operations['delete'] = array(
'title' => t('Delete'),
'href' => 'admin/config/search/xmlsitemap/delete/' . $smid,
'query' => $destination,
);
$operations['edit'] = xmlsitemap_get_operation_link('admin/config/search/xmlsitemap/edit/' . $smid, array('title' => t('Edit'), 'modal' => TRUE));
$operations['delete'] = xmlsitemap_get_operation_link('admin/config/search/xmlsitemap/delete/' . $smid, array('title' => t('Delete'), 'modal' => TRUE));
if ($operations) {
$options[$smid]['operations'] = array(
'data' => array(
......@@ -184,9 +176,7 @@ function xmlsitemap_sitemap_edit_form($form, &$form_state, array $sitemap = arra
);
$form['actions'] = array(
'#type' => 'container',
'#attributes' => array('class' => array('form-actions')),
'#weight' => 100,
'#type' => 'actions',
);
$form['actions']['save'] = array(
'#type' => 'submit',
......@@ -248,7 +238,7 @@ function xmlsitemap_sitemap_delete_form($form, &$form_state, array $sitemap) {
);
return confirm_form(
$form,
t('Are you sure you want to delete the sitemap?'),
t('Are you sure you want to delete the XML sitemap?'),
'admin/config/search/xmlsitemap',
'',
t('Delete'),
......@@ -257,7 +247,7 @@ function xmlsitemap_sitemap_delete_form($form, &$form_state, array $sitemap) {
}
function xmlsitemap_sitemap_delete_form_submit($form, $form_state) {
xmlsitemap_sitemap_delete($form['#sitemap']);
xmlsitemap_sitemap_delete($form_state['values']['smid']);
drupal_set_message(t('The sitemap has been deleted.'));
$form_state['redirect'] = 'admin/config/search/xmlsitemap';
}
......@@ -274,19 +264,19 @@ function xmlsitemap_settings_form($form, &$form_state) {
'#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' => 0,
'#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' => 1,
'#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 alises 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' => 1,
'#default_value' => variable_get('xmlsitemap_prefetch_aliases', 1),
);
$form['advanced'] = array(
......@@ -334,7 +324,7 @@ function xmlsitemap_settings_form($form, &$form_state) {
$form['advanced']['xmlsitemap_base_url'] = array(
'#type' => 'textfield',
'#title' => t('Default base URL'),
'#default_value' => $GLOBALS['base_url'],
'#default_value' => variable_get('xmlsitemap_base_url', $GLOBALS['base_url']),
'#size' => 30,
'#description' => t('This is the default base URL used for sitemaps and sitemap links.'),
'#required' => TRUE,
......@@ -347,7 +337,7 @@ function xmlsitemap_settings_form($form, &$form_state) {
XMLSITEMAP_LASTMOD_MEDIUM => t('Medium'),
XMLSITEMAP_LASTMOD_LONG => t('Long'),
),
'#default_value' => XMLSITEMAP_LASTMOD_MEDIUM,
'#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) . ')';
......@@ -463,7 +453,7 @@ function xmlsitemap_rebuild_form() {
return confirm_form(
$form,
t('Are you sure you want to rebuild the sitemap?'),
t('Are you sure you want to rebuild the XML sitemap?'),
'admin/config/search/xmlsitemap',
'',
t('Rebuild sitemap'),
......@@ -502,14 +492,9 @@ function xmlsitemap_add_form_entity_summary(&$form, $entity, array $entity_info)
$totals['visible'] += $status['visible'];
$row = array();
if (xmlsitemap_can_admin_bundle($entity, $bundle) && $path = xmlsitemap_get_bundle_path($entity, $bundle)) {
$options = array('query' => $destination);
if (module_exists('dialog')) {
$form['#attached']['library']['dialog'] = array('dialog', 'dialog');
$path = "admin/config/search/xmlsitemap/settings/$entity/$bundle/nojs";
$options['attributes']['class'] = array('use-dialog', 'use-ajax');
}
$row[] = l($bundle_info['label'], $path, $options);
$edit_link = xmlsitemap_get_operation_link("admin/config/search/xmlsitemap/settings/$entity/$bundle", array('modal' => TRUE));
if (!empty($edit_link['router info']['access'])) {
$row[] = l($bundle_info['label'], $edit_link['href'], $edit_link);
}
else {
$row[] = $bundle_info['label'];
......@@ -565,16 +550,10 @@ function xmlsitemap_add_form_entity_summary(&$form, $entity, array $entity_info)
* is called during submission.
*/
function xmlsitemap_add_link_bundle_settings(array &$form, array &$form_state, $entity, $bundle) {
xmlsitemap_link_bundle_settings_form($form, $form_state, $entity, $bundle, FALSE);
// Manually call drupal_alter() on the $options form since it was not called
// using drupal_get_form().
$form_id = 'xmlsitemap_link_bundle_settings_form';
drupal_alter('form_' . $form_id, $form, $form_state);
drupal_alter('form', $form, $form_state, $form_id);
$entity_info = xmlsitemap_get_link_info($entity);
$bundle_info = xmlsitemap_link_bundle_load($entity, $bundle);
// Make the base element a fieldset.
$form['xmlsitemap'] += array(
$form['xmlsitemap'] = array(
'#type' => 'fieldset',
'#title' => t('XML sitemap'),
'#collapsible' => TRUE,
......@@ -586,22 +565,18 @@ function xmlsitemap_add_link_bundle_settings(array &$form, array &$form_state, $
'vertical-tabs' => drupal_get_path('module', 'xmlsitemap') . '/xmlsitemap.js',
),
),
'#tree' => TRUE,
'#entity' => $entity,
'#bundle' => $bundle,
'#entity_info' => $entity_info,
'#bundle_info' => $bundle_info,
);
// Hack to remove fieldset summary if Vertical tabs is not enabled.
if (!isset($form['additional_settings'])) {
unset($form['xmlsitemap']['#attached']['js']['vertical-tabs']);
}
}
function xmlsitemap_link_bundle_settings_form(array &$form, array $form_state, $entity, $bundle, $buttons = TRUE) {
$settings = xmlsitemap_link_bundle_load($entity, $bundle);
$form['xmlsitemap'] = array(
'#tree' => TRUE,
'#entity' => $entity,
'#bundle' => $bundle,
);
$form['xmlsitemap']['description'] = array(
'#prefix' => '<div class="description">',
'#suffix' => '</div>',
......@@ -611,13 +586,13 @@ function xmlsitemap_link_bundle_settings_form(array &$form, array $form_state, $
'#type' => 'select',
'#title' => t('Inclusion'),
'#options' => xmlsitemap_get_status_options(),
'#default_value' => $settings['status'],
'#default_value' => $bundle_info['status'],
);
$form['xmlsitemap']['priority'] = array(
'#type' => 'select',
'#title' => t('Default priority'),
'#options' => xmlsitemap_get_priority_options(),
'#default_value' => $settings['priority'],
'#default_value' => $bundle_info['priority'],
'#states' => array(
'invisible' => array(
'select[name="xmlsitemap[status]"]' => array('value' => '0'),
......@@ -625,53 +600,64 @@ function xmlsitemap_link_bundle_settings_form(array &$form, array $form_state, $
),
);
if ($buttons) {
$form['actions'] = array(
'#type' => 'container',
'#attributes' => array('class' => array('form-actions')),
'#weight' => 100,
);
$form['actions']['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
$form += array('#submit' => array());
array_unshift($form['#submit'], 'xmlsitemap_link_bundle_settings_form_submit');
if (isset($form['submit'])) {
$form['submit'] += array('#weight' => 40);
}
if (isset($form['delete'])) {
$form['delete'] += array('#weight' => 50);
}
}
function xmlsitemap_link_bundle_settings_form(array $form, array &$form_state, array $bundle) {
if (empty($form_state['ajax']) && !empty($bundle['info']['admin']['real path'])) {
// If this is a non-ajax form, redirect to the bundle administration page.
$destination = drupal_get_destination();
unset($_GET['destination']);
drupal_goto($bundle['info']['admin']['real path'], array('query' => $destination));
}
else {
drupal_set_title( t('@bundle XML sitemap settings', array('@bundle' => $bundle['info']['label'])));
}
$form = array();
xmlsitemap_add_link_bundle_settings($form, $form_state, $bundle['entity'], $bundle['bundle']);
$form['xmlsitemap']['#type'] = 'markup';
$form['xmlsitemap']['#value'] = '';
$form['xmlsitemap']['#access'] = TRUE;
$form['xmlsitemap']['#show_message'] = TRUE;
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
$form['actions']['cancel'] = array(
'#value' => l(t('Cancel'), isset($_GET['destination']) ? $_GET['destination'] : 'admin/config/search/xmlsitemap/settings'),
'#weight' => 10,
);
return $form;
}
function xmlsitemap_link_bundle_settings_form_submit($form, $form_state) {
function xmlsitemap_link_bundle_settings_form_submit($form, &$form_state) {
$entity = $form['xmlsitemap']['#entity'];
$bundle = $form['xmlsitemap']['#bundle'];
$info = xmlsitemap_get_link_info($entity);
xmlsitemap_link_bundle_settings_save($entity, $bundle, $form_state['values']['xmlsitemap']);
drupal_set_message(t('Settings for the @bundle-label %bundle have been saved.', array('@bundle-label' => drupal_strtolower($info['bundle label']), '%bundle' => $info['bundles'][$bundle]['label'])));
}
function xmlsitemap_bundle_settings_dialog($entity, $bundle, $ajax = FALSE) {
$info = xmlsitemap_get_link_info($entity);
if (!$ajax) {
if ($path = xmlsitemap_get_bundle_path($entity, $bundle)) {
$destination = drupal_get_destination();
unset($_GET['destination']);
drupal_goto($path, array('query' => $destination));
}
return MENU_NOT_FOUND;
$entity_info = $form['xmlsitemap']['#entity_info'];
if (!empty($form['xmlsitemap']['#show_message'])) {
drupal_set_message(t('XML sitemap settings for the @bundle-label %bundle have been saved.', array('@bundle-label' => drupal_strtolower($entity_info['bundle label']), '%bundle' => $entity_info['bundles'][$bundle]['label'])));
}
if (!isset($info['bundles'][$bundle]) || !xmlsitemap_can_admin_bundle($entity, $bundle)) {
$output = array();
$output[] = dialog_command_display(t('You are not authorized to access this page.'), array('title' => t('Access denied')));
ajax_render($output);
}
$content = drupal_get_form('xmlsitemap_link_bundle_settings_form', $entity, $bundle);
$options = array(
'title' => t('@bundle XML sitemap settings', array('@bundle' => $info['bundles'][$bundle]['label'])),
);
$output[] = dialog_command_display($content, $options);
ajax_render($output);
// Unset the form values since we have already saved the bundle settings and
// we don't want these values to get saved as variables in-case this form
// also uses system_settings_form().
unset($form_state['values']['xmlsitemap']);
}
/**
......@@ -690,14 +676,14 @@ function xmlsitemap_add_form_link_options(&$form, $entity, $bundle, $id) {
$link = array();
}
$settings = xmlsitemap_link_bundle_load($entity, $bundle);
$bundle_info = xmlsitemap_link_bundle_load($entity, $bundle);
$link += array(
'access' => 1,
'status' => $settings['status'],
'status_default' => $settings['status'],
'status' => $bundle_info['status'],
'status_default' => $bundle_info['status'],
'status_override' => 0,
'priority' => $settings['priority'],
'priority_default' => $settings['priority'],
'priority' => $bundle_info['priority'],
'priority_default' => $bundle_info['priority'],
'priority_override' => 0,
);
......@@ -707,7 +693,7 @@ function xmlsitemap_add_form_link_options(&$form, $entity, $bundle, $id) {
'#title' => t('XML sitemap'),
'#collapsible' => TRUE,
'#collapsed' => !$link['status_override'] && !$link['priority_override'],
'#access' => user_access('administer xmlsitemap') || xmlsitemap_can_admin_bundle($entity, $bundle),
'#access' => user_access('administer xmlsitemap') || xmlsitemap_link_bundle_access($bundle_info),
'#group' => 'additional_settings',
'#attached' => array(
'js' => array(
......@@ -721,8 +707,7 @@ function xmlsitemap_add_form_link_options(&$form, $entity, $bundle, $id) {
unset($form['xmlsitemap']['#attached']['js']['vertical-tabs']);
}
$bundle_info = $info['bundles'][$bundle];
if (xmlsitemap_can_admin_bundle($entity, $bundle) && $path = xmlsitemap_get_bundle_path($entity, $bundle)) {
if (xmlsitemap_link_bundle_access($bundle_info) && $path = xmlsitemap_get_bundle_path($entity, $bundle)) {
$form['xmlsitemap']['description'] = array(
'#prefix' => '<div class="description">',
'#suffix' => '</div>',
......
......@@ -210,7 +210,7 @@ function xmlsitemap_generate_chunk_header($type, array $sitemap, $handle, &$stat
// Add the stylesheet link.
if (variable_get('xmlsitemap_xsl', 1)) {
$xsl_url = url('sitemap.xsl', $sitemap['uri']['options'] + array('alias' => TRUE));
$xsl_url = url('sitemap.xsl');
$output .= '<?xml-stylesheet type="text/xsl" href="' . $xsl_url . '"?>' . PHP_EOL;
}
......@@ -417,7 +417,7 @@ function xmlsitemap_regenerate_batch_generate($smid, array &$context) {
else {
// Cleanup the 'extra' empty file.
$file = xmlsitemap_sitemap_get_file($sitemap, $sitemap['chunks']);
if (file_exists($file)) {
if (file_exists($file) && $sitemap['chunks'] > 1) {
file_unmanaged_delete($file);
}
$sitemap['chunks']--;
......
......@@ -56,36 +56,26 @@ define('XMLSITEMAP_PRIORITY_DEFAULT', 0.5);
* Implements hook_hook_info().
*/
function xmlsitemap_hook_info() {
$hooks['xmlsitemap_link_info'] = array(
'group' => 'xmlsitemap',
);
$hooks['xmlsitemap_link_info_alter'] = array(
'group' => 'xmlsitemap',
);
$hooks['xmlsitemap_link_alter'] = array(
'group' => 'xmlsitemap',
);
$hooks['xmlsitemap_index_links'] = array(
'group' => 'xmlsitemap',
);
$hooks['xmlsitemap_context_info'] = array(
'group' => 'xmlsitemap',
);
$hooks['xmlsitemap_context'] = array(
'group' => 'xmlsitemap',
);
$hooks['xmlsitemap_context_fallback'] = array(
'group' => 'xmlsitemap',
);
$hooks['xmlsitemap_context_url_options'] = array(
'group' => 'xmlsitemap',
);
$hooks['xmlsitemap_sitemap_operations'] = array(
'group' => 'xmlsitemap',
);
$hooks['xmlsitemap_sitemap_delete'] = array(
'group' => 'xmlsitemap',
$hooks = array(
'xmlsitemap_link_info',
'xmlsitemap_link_info_alter',
'xmlsitemap_link_alter',
'xmlsitemap_index_links',
'xmlsitemap_context_info',
'xmlsitemap_context_info_alter',
'xmlsitemap_context',
'xmlsitemap_sitemap_operations',
'xmlsitemap_sitemap_delete',
'xmlsitemap_sitemap_uri_alter',
'xmlsitemap_sitemap_link_url_options_alter',
'query_xmlsitemap_generate_alter',
'form_xmlsitemap_sitemap_edit_form_alter',
);
$hooks = array_combine($hooks, $hooks);
foreach ($hooks as $hook => $info) {
$hooks[$hook] = array('group' => 'xmlsitemap');
}
return $hooks;
}
......@@ -155,6 +145,7 @@ function xmlsitemap_menu() {
'access arguments' => array('administer xmlsitemap'),
'type' => MENU_LOCAL_ACTION,
'file' => 'xmlsitemap.admin.inc',
'modal' => TRUE,
);
$items['admin/config/search/xmlsitemap/edit/%xmlsitemap_sitemap'] = array(
'page callback' => 'drupal_get_form',
......@@ -162,6 +153,7 @@ function xmlsitemap_menu() {
'access arguments' => array('administer xmlsitemap'),
'type' => MENU_CALLBACK,
'file' => 'xmlsitemap.admin.inc',
'modal' => TRUE,
);
$items['admin/config/search/xmlsitemap/delete/%xmlsitemap_sitemap'] = array(
'page callback' => 'drupal_get_form',
......@@ -169,7 +161,9 @@ function xmlsitemap_menu() {
'access arguments' => array('administer xmlsitemap'),
'type' => MENU_CALLBACK,
'file' => 'xmlsitemap.admin.inc',
'modal' => TRUE,
);
$items['admin/config/search/xmlsitemap/settings'] = array(
'title' => 'Settings',
'page callback' => 'drupal_get_form',
......@@ -179,6 +173,16 @@ function xmlsitemap_menu() {
'file' => 'xmlsitemap.admin.inc',
'weight' => 10,
);
$items['admin/config/search/xmlsitemap/settings/%xmlsitemap_link_bundle/%'] = array(
'load arguments' => array(6),
'page callback' => 'drupal_get_form',
'page arguments' => array('xmlsitemap_link_bundle_settings_form', 5),
'access callback' => 'xmlsitemap_link_bundle_access',
'access arguments' => array(5),
'file' => 'xmlsitemap.admin.inc',
'modal' => TRUE,
);
$items['admin/config/search/xmlsitemap/rebuild'] = array(
'title' => 'Rebuild links',
'description' => 'Rebuild the site map.',
......@@ -203,17 +207,6 @@ function xmlsitemap_menu() {
'file' => 'xmlsitemap.pages.inc',
);
// CTools/Dialog API callback for editing bundle settings.
if (module_exists('dialog')) {
$items['admin/config/search/xmlsitemap/settings/%/%/%dialog_js'] = array(
'page callback' => 'xmlsitemap_bundle_settings_dialog',
'page arguments' => array(5, 6, 7),
'access arguments' => array('administer xmlsitemap'),
'type' => MENU_CALLBACK,
'file' => 'xmlsitemap.admin.inc',
);
}
return $items;
}
......@@ -361,7 +354,7 @@ function xmlsitemap_sitemap_load_multiple(array $smids) {
*
* @param $context
* An optional XML sitemap context array to use to find the correct XML
* siteamp. If not provided, the current site's context will be used.
* sitemap. If not provided, the current site's context will be used.
*
* @see xmlsitemap_get_current_context()
*/
......@@ -620,7 +613,7 @@ function xmlsitemap_link_delete_multiple(array $conditions) {
// Because this function is called from sub-module uninstall hooks, we have
// to manually check if the table exists since it could have been removed
// in xmlsitemap_uninstall().
// @todo Remove this check when http://drupal.org/node/15145 is fixed.
// @todo Remove this check when http://drupal.org/node/151452 is fixed.
if (!db_table_exists('xmlsitemap')) {
return FALSE;
}
......@@ -829,7 +822,7 @@ function xmlsitemap_get_link_info($type = NULL, $reset = FALSE) {
$bundle_info += array(
'xmlsitemap' => array(),
);
$bundle_info['xmlsitemap'] += xmlsitemap_link_bundle_load($key, $bundle);
$bundle_info['xmlsitemap'] += xmlsitemap_link_bundle_load($key, $bundle, FALSE);
}
}
drupal_alter('xmlsitemap_link_info', $link_info);
......@@ -908,10 +901,21 @@ function xmlsitemap_link_bundle_rename($entity, $bundle_old, $bundle_new) {
}
}
function xmlsitemap_link_bundle_load($entity, $bundle) {
$settings = variable_get("xmlsitemap_settings_{$entity}_{$bundle}", array());
$settings += array('status' => XMLSITEMAP_STATUS_DEFAULT, 'priority' => XMLSITEMAP_PRIORITY_DEFAULT);
return $settings;
function xmlsitemap_link_bundle_load($entity, $bundle, $load_bundle_info = TRUE) {
$info = array(
'entity' => $entity,
'bundle' => $bundle,
);
if ($load_bundle_info) {
$entity_info = xmlsitemap_get_link_info($entity);
$info['info'] = $entity_info['bundles'][$bundle];
}
$info += variable_get("xmlsitemap_settings_{$entity}_{$bundle}", array());
$info += array(
'status' => XMLSITEMAP_STATUS_DEFAULT,
'priority' => XMLSITEMAP_PRIORITY_DEFAULT,
);
return $info;
}
function xmlsitemap_link_bundle_delete($entity, $bundle, $delete_links = TRUE) {
......@@ -923,11 +927,16 @@ function xmlsitemap_link_bundle_delete($entity, $bundle, $delete_links = TRUE) {
//xmlsitemap_get_link_info(NULL, TRUE);
}
function xmlsitemap_can_admin_bundle($entity, $bundle) {
$info = xmlsitemap_get_link_info($entity);
function xmlsitemap_link_bundle_access($entity, $bundle = NULL) {
if (is_array($entity) && !isset($bundle)) {
$bundle = $entity;
}
else {
$bundle = xmlsitemap_link_bundle_load($entity, $bundle);
}
if (isset($info['bundles'][$bundle]['admin'])) {
$admin = $info['bundles'][$bundle]['admin'];
if (isset($bundle['info']['admin'])) {
$admin = $bundle['info']['admin'];
$admin += array('access arguments' => array());
if (!isset($admin['access callback']) && count($admin['access arguments']) == 1) {
......@@ -1305,3 +1314,20 @@ function _xmlsitemap_set_breadcrumb($path = 'admin/config/search/xmlsitemap') {
array_unshift($breadcrumb, l(t('Home'), NULL));
drupal_set_breadcrumb($breadcrumb);
}
function xmlsitemap_get_operation_link($url, $options = array()) {
static $destination;
if (!isset($destination)) {
$destination = drupal_get_destination();
}
$link = array('href' => $url) + $options;
// Fetch the item's menu router link info and title.
$item = menu_get_item($url);
$link += array('title' => $item['title'], 'router info' => $item, 'query' => $destination);
drupal_alter('xmlsitemap_operation_link', $link);
return $link;
}
......@@ -38,16 +38,8 @@ function xmlsitemap_custom_list_links() {
$row['language'] = module_invoke('locale', 'language_name', $link->language);
}
$operations = array();
$operations['edit'] = array(
'title' => t('Edit'),
'href' => 'admin/config/search/xmlsitemap/custom/edit/' . $link->id,
'query' => $destination,
);
$operations['delete'] = array(
'title' => t('Delete'),
'href' => 'admin/config/search/xmlsitemap/custom/delete/' . $link->id,
'query' => $destination,
);
$operations['edit'] = xmlsitemap_get_operation_link('admin/config/search/xmlsitemap/custom/edit/' . $link->id, array('title' => t('Edit'), 'modal' => TRUE));
$operations['delete'] = xmlsitemap_get_operation_link('admin/config/search/xmlsitemap/custom/delete/' . $link->id, array('title' => t('Delete'), 'modal' => TRUE));
$row['operations'] = array(
'data' => array(
'#theme' => 'links',
......@@ -123,9 +115,7 @@ function xmlsitemap_custom_edit_link_form($form, &$form_state, $link = array())
);
$form['actions'] = array(
'#type' => 'container',
'#attributes' => array('class' => array('form-actions')),
'#weight' => 100,
'#type' => 'actions'
);
$form['actions']['submit'] = array(
'#type' => 'submit',
......@@ -178,6 +168,11 @@ function xmlsitemap_custom_delete_link_form($form, &$form_state, array $link) {
// @todo Remove when http://drupal.org/node/576290 is fixed.
_xmlsitemap_set_breadcrumb('admin/config/search/xmlsitemap/custom');
$form['#link'] = $link;
$form['id'] = array(
'#type' => 'value',
'#value' => $link['id'],
);
$form['link'] = array(
'#type' => 'value',
'#value' => $link,
......
......@@ -19,6 +19,7 @@ function xmlsitemap_custom_menu() {
'access arguments' => array('administer xmlsitemap'),
'type' => MENU_LOCAL_ACTION,
'file' => 'xmlsitemap_custom.admin.inc',
'modal' => TRUE,
);
$items['admin/config/search/xmlsitemap/custom/edit/%xmlsitemap_custom'] = array(
'title' => 'Edit custom link',
......@@ -27,14 +28,16 @@ function xmlsitemap_custom_menu() {
'access arguments' => array('administer xmlsitemap'),
'type' => MENU_CALLBACK,
'file' => 'xmlsitemap_custom.admin.inc',
'modal' => TRUE,
);
$items['admin/config/search/xmlsitemap/custom/delete/%xmlsitemap_custom'] = array(
'title' => 'Edit custom link',
'title' => 'Delete custom link',
'page callback' => 'drupal_get_form',
'page arguments' => array('xmlsitemap_custom_delete_link_form', 6),
'access arguments' => array('administer xmlsitemap'),
'type' => MENU_CALLBACK,
'file' => 'xmlsitemap_custom.admin.inc',
'modal' => TRUE,
);
return $items;
}
......
......@@ -142,21 +142,8 @@ function xmlsitemap_node_field_extra_fields() {
*/
function xmlsitemap_node_form_node_type_form_alter(&$form, $form_state) {
$node_type = isset($form['#node_type']->type) ? $form['#node_type']->type : '';
module_load_include('inc', 'xmlsitemap', 'xmlsitemap.admin');
xmlsitemap_add_link_bundle_settings($form, $form_state, 'node', $node_type);
// Add our submit handler before node_type_form_submit() so we can compare
// the old and new values.