Commit abbaba1f authored by Dave Reid's avatar Dave Reid

by Dave Reid: Removed old update functions.

parent 1ae2d059
...@@ -35,24 +35,25 @@ function xmlsitemap_sitemap_list_form() { ...@@ -35,24 +35,25 @@ function xmlsitemap_sitemap_list_form() {
'#submit' => array('xmlsitemap_sitemap_list_submit'), '#submit' => array('xmlsitemap_sitemap_list_submit'),
); );
$query = db_select('xmlsitemap_sitemap');
$query->fields('xmlsitemap_sitemap', array('smid'));
$smids = $query->execute()->fetchCol();
$contexts = xmlsitemap_get_context_info(); $contexts = xmlsitemap_get_context_info();
$header = array(); $header = array();
$header['url'] = array('data' => t('URL'), 'field' => 'url'); $header['url'] = array('data' => t('URL'));
foreach ($contexts as $context_key => $context_info) { foreach ($contexts as $context_key => $context_info) {
if (!empty($context_info['summary callback'])) { if (!empty($context_info['summary callback'])) {
$header['context_' . $context_key] = $context_info['label']; $header['context_' . $context_key] = $context_info['label'];
} }
} }
$header['updated'] = array('data' => t('Last updated'), 'field' => 'updated'); $header['updated'] = array('data' => t('Last updated'), 'field' => 'updated', 'sort' => 'asc');
$header['links'] = array('data' => t('Links'), 'field' => 'links'); $header['links'] = array('data' => t('Links'), 'field' => 'links');
$header['chunks'] = array('data' => t('Pages'), 'field' => 'chunks'); $header['chunks'] = array('data' => t('Pages'), 'field' => 'chunks');
$header['operations'] = array('data' => t('Operations')); $header['operations'] = array('data' => t('Operations'));
$query = db_select('xmlsitemap_sitemap');
$query->fields('xmlsitemap_sitemap', array('smid'));
$query->extend('TableSort')->orderByHeader($header);
$smids = $query->execute()->fetchCol();
$options = array(); $options = array();
$destination = drupal_get_destination(); $destination = drupal_get_destination();
foreach ($smids as $smid) { foreach ($smids as $smid) {
...@@ -62,7 +63,7 @@ function xmlsitemap_sitemap_list_form() { ...@@ -62,7 +63,7 @@ function xmlsitemap_sitemap_list_form() {
$options[$smid]['url'] = array( $options[$smid]['url'] = array(
'data' => array( 'data' => array(
'#type' => 'link', '#type' => 'link',
'#title' => url($sitemap['uri']['path'], $sitemap['uri']['options']), '#title' => $sitemap['uri']['url'],
'#href' => $sitemap['uri']['path'], '#href' => $sitemap['uri']['path'],
'#options' => $sitemap['uri']['options'], '#options' => $sitemap['uri']['options'],
), ),
...@@ -77,13 +78,11 @@ function xmlsitemap_sitemap_list_form() { ...@@ -77,13 +78,11 @@ function xmlsitemap_sitemap_list_form() {
$options[$smid]['chunks'] = $sitemap['updated'] ? $sitemap['chunks'] : '-'; $options[$smid]['chunks'] = $sitemap['updated'] ? $sitemap['chunks'] : '-';
$operations = array(); $operations = array();
//if (!empty($sitemap['context'])) { $operations['edit'] = array(
$operations['edit'] = array( 'title' => t('Edit'),
'title' => t('Edit'), 'href' => 'admin/settings/xmlsitemap/edit/' . $smid,
'href' => 'admin/config/search/xmlsitemap/edit/' . $smid, 'query' => $destination,
'query' => $destination, );
);
//}
$operations['delete'] = array( $operations['delete'] = array(
'title' => t('Delete'), 'title' => t('Delete'),
'href' => 'admin/config/search/xmlsitemap/delete/' . $smid, 'href' => 'admin/config/search/xmlsitemap/delete/' . $smid,
...@@ -153,7 +152,7 @@ function xmlsitemap_sitemap_list_submit($form, &$form_state) { ...@@ -153,7 +152,7 @@ function xmlsitemap_sitemap_list_submit($form, &$form_state) {
call_user_func_array($function, $args); call_user_func_array($function, $args);
$count = count($form_state['values']['sitemaps']); $count = count($form_state['values']['sitemaps']);
watchdog('xmlsitemap', '@action @count XML sitemaps.', array('@action' => $operation['action past'], '@count' => $count)); //watchdog('xmlsitemap', '@action @count XML sitemaps.', array('@action' => $operation['action past'], '@count' => $count));
drupal_set_message(format_plural(count($sitemaps), '@action @count XML sitemap.', '@action @count XML sitemaps.', array('@action' => $operation['action past'], '@count' => $count))); drupal_set_message(format_plural(count($sitemaps), '@action @count XML sitemap.', '@action @count XML sitemaps.', array('@action' => $operation['action past'], '@count' => $count)));
//$form_state['redirect'] = 'admin/config/search/xmlsitemap'; //$form_state['redirect'] = 'admin/config/search/xmlsitemap';
} }
...@@ -222,7 +221,7 @@ function xmlsitemap_sitemap_edit_form_submit($form, &$form_state) { ...@@ -222,7 +221,7 @@ function xmlsitemap_sitemap_edit_form_submit($form, &$form_state) {
form_state_values_clean($form_state); form_state_values_clean($form_state);
xmlsitemap_sitemap_save($form_state['values']); xmlsitemap_sitemap_save($form_state['values']);
$uri = xmlsitemap_sitemap_uri($form_state['values']); $uri = xmlsitemap_sitemap_uri($form_state['values']);
drupal_set_message(t('The sitemap %sitemap was saved.', array('%sitemap' => url($uri['path'], $uri['options'])))); drupal_set_message(t('The sitemap %sitemap was saved.', array('%sitemap' => $uri['url'])));
$form_state['redirect'] = 'admin/config/search/xmlsitemap'; $form_state['redirect'] = 'admin/config/search/xmlsitemap';
} }
...@@ -250,7 +249,7 @@ function xmlsitemap_sitemap_delete_form(&$form, $form_state, array $sitemap) { ...@@ -250,7 +249,7 @@ function xmlsitemap_sitemap_delete_form(&$form, $form_state, array $sitemap) {
function xmlsitemap_sitemap_delete_form_submit($form, $form_state) { function xmlsitemap_sitemap_delete_form_submit($form, $form_state) {
xmlsitemap_sitemap_delete($form_state['values']['smid']); xmlsitemap_sitemap_delete($form_state['values']['smid']);
$uri = xmlsitemap_sitemap_uri($form['#sitemap']); $uri = xmlsitemap_sitemap_uri($form['#sitemap']);
drupal_set_message(t('The sitemap %sitemap was deleted.', array('%sitemap' => url($uri['path'], $uri['options'])))); drupal_set_message(t('The sitemap %sitemap was deleted.', array('%sitemap' => $uri['url'])));
$form_state['redirect'] = 'admin/config/search/xmlsitemap'; $form_state['redirect'] = 'admin/config/search/xmlsitemap';
} }
......
...@@ -190,7 +190,6 @@ function xmlsitemap_generate(array $sitemap, $chunk) { ...@@ -190,7 +190,6 @@ function xmlsitemap_generate(array $sitemap, $chunk) {
return $status; return $status;
} }
/** /**
* Write the proper XML sitemap header. * Write the proper XML sitemap header.
* *
...@@ -308,7 +307,6 @@ function xmlsitemap_generate_chunk(array $sitemap, $handle, &$status, $chunk) { ...@@ -308,7 +307,6 @@ function xmlsitemap_generate_chunk(array $sitemap, $handle, &$status, $chunk) {
} }
$link_output .= '</url>' . PHP_EOL; $link_output .= '</url>' . PHP_EOL;
$status &= (bool) fwrite($handle, $link_output); $status &= (bool) fwrite($handle, $link_output);
} }
// Close the XML file. // Close the XML file.
......
...@@ -353,226 +353,17 @@ function xmlsitemap_schema() { ...@@ -353,226 +353,17 @@ function xmlsitemap_schema() {
return $schema; return $schema;
} }
// @todo Remove these update functions before alpha.
function xmlsitemap_update_1() {
db_drop_unique_key('xmlsitemap', 'loc');
}
function xmlsitemap_update_2() {
if (!variable_get('xmlsitemap_base_url', '')) {
variable_set('xmlsitemap_base_url', $GLOBALS['base_url']);
}
}
function xmlsitemap_update_3() {
db_add_index('xmlsitemap', 'loc', array('loc'));
}
function xmlsitemap_update_4() {
$field = array(
'type' => 'int',
'size' => 'tiny',
'default' => 1,
'unsigned' => TRUE,
);
db_change_field('xmlsitemap', 'status', 'status', $field);
db_add_index('xmlsitemap', 'status', array('status'));
}
function xmlsitemap_update_5() {
db_drop_primary_key('xmlsitemap');
db_add_primary_key('xmlsitemap', array('id', 'type'));
}
function xmlsitemap_update_6() {
if (db_field_exists('xmlsitemap', 'language')) {
db_drop_index('xmlsitemap', 'language');
db_drop_field('xmlsitemap', 'language');
}
variable_set('xmlsitemap_generated_last', variable_get('xmlsitemap_regenerate_last', 0));
variable_del('xmlsitemap_regenerate_last');
}
function xmlsitemap_update_7() {
if (db_query_range("SELECT 1 FROM {xmlsitemap} WHERE type = 'custom'", 0, 1)->fetchField()) {
drupal_install_modules(array('xmlsitemap_custom'));
}
variable_del('xmlsitemap_custom_links');
}
function xmlsitemap_update_8() {
$field = array(
'type' => 'float',
'default' => NULL,
);
db_add_field('xmlsitemap', 'priority_override', $field);
}
function xmlsitemap_update_9() {
$field = array(
'type' => 'int',
'default' => 0,
'unsigned' => TRUE,
'not null' => TRUE,
);
db_change_field('xmlsitemap', 'lastmod', 'lastmod', $field);
}
function xmlsitemap_update_10() {
db_update('system')
->fields(array('weight' => 1))
->condition('type', 'module')
->condition('name', 'xmlsitemap')
->execute();
}
function xmlsitemap_update_11() {
// Delete any items with NULL status and drop the status index.
db_delete('xmlsitemap')
->isNull('status')
->execute();
db_drop_index('xmlsitemap', 'status');
// Rename status to access.
$field = array(
'type' => 'int',
'size' => 'tiny',
'default' => 1,
'unsigned' => TRUE,
'not null' => TRUE,
);
db_change_field('xmlsitemap', 'status', 'access', $field);
// Add a status field.
$field = array(
'type' => 'int',
'size' => 'tiny',
'default' => 1,
);
db_add_field('xmlsitemap', 'status', $field);
db_add_index('xmlsitemap', 'access_status', array('access', 'status'));
}
function xmlsitemap_update_12() {
db_drop_index('xmlsitemap', 'access_status');
db_add_index('xmlsitemap', 'access_status_loc', array('access', 'status', 'loc'));
}
function xmlsitemap_update_13() {
db_change_field('xmlsitemap', 'priority_override', 'priority_override_value', array('type' => 'float', 'default' => NULL));
$override_field = array(
'type' => 'int',
'size' => 'tiny',
'default' => 0,
'not null' => TRUE,
);
db_add_field('xmlsitemap', 'status_override', $override_field);
db_add_field('xmlsitemap', 'priority_override', $override_field);
db_update('xmlsitemap')
->fields(array('priority_override' => 1))
->expression('priority', 'priority_override_value')
->isNotNull('priority_override_value')
->execute();
db_update('xmlsitemap')
->fields(array('priority' => 0.5))
->isNull('priority_override_value')
->execute();
db_drop_field('xmlsitemap', 'priority_override_value');
}
function xmlsitemap_update_14() {
db_add_field('xmlsitemap', 'subtype', array('type' => 'varchar', 'length' => 32, 'default' => NULL));
$fields = array('node' => 'node_type', 'menu' => 'menu_name', 'taxonomy' => 'term_vid');
foreach ($fields as $type => $field) {
if (db_field_exists('xmlsitemap', $field)) {
db_update('xmlsitemap')
->fields(array('subtype', $field))
->condition('type', $type)
->execute();
db_drop_index('xmlsitemap', $field);
db_drop_field('xmlsitemap', $field);
}
}
db_add_index('xmlsitemap', 'type_subtype', array('type', 'subtype'));
}
function xmlsitemap_update_15() {
$or = db_or();
$or->isNull('status');
$or->isNull('access');
db_delete('xmlsitemap')
->condition($or)
->execute();
$field = array(
'type' => 'int',
'size' => 'tiny',
'default' => 1,
'not null' => TRUE,
);
db_change_field('xmlsitemap', 'access', 'access', $field);
db_change_field('xmlsitemap', 'status', 'status', $field);
}
function xmlsitemap_update_16() {
$field = array(
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
);
db_add_field('xmlsitemap', 'language', $field);
db_add_index('xmlsitemap', 'language', array('language'));
}
function xmlsitemap_update_17() {
db_update('xmlsitemap')
->fields(array('access' => 1))
->condition('access', 1, '>')
->execute();
db_update('xmlsitemap')
->fields(array('status' => 1))
->condition('status', 1, '>')
->execute();
}
function xmlsitemap_update_18() {
db_update('xmlsitemap')
->fields(array('subtype' => ''))
->isNull('subtype')
->execute();
$field = array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
);
db_change_field('xmlsitemap', 'type', 'type', $field);
$field['length'] = 128;
db_change_field('xmlsitemap', 'subtype', 'subtype', $field);
}
/** /**
* Empty update. * Implements hook_update_last_removed().
*/ */
function xmlsitemap_update_6200() { function xmlsitemap_update_last_removed() {
} return 6201;
/**
* Update empty string languages to LANGUAGE_NONE.
*/
function xmlsitemap_update_7200() {
db_update('xmlsitemap')
->fields(array('language' => LANGUAGE_NONE))
->condition('language', '')
->execute();
} }
/** /**
* Create the {xmlsitemap_sitemap} table. * Create the {xmlsitemap_sitemap} table.
*/ */
function xmlsitemap_update_7201() { function xmlsitemap_update_6202() {
if (db_table_exists('xmlsitemap_sitemap')) { if (db_table_exists('xmlsitemap_sitemap')) {
return; return;
} }
...@@ -622,3 +413,13 @@ function xmlsitemap_update_7201() { ...@@ -622,3 +413,13 @@ function xmlsitemap_update_7201() {
); );
db_create_table('xmlsitemap_sitemap', $schema['xmlsitemap_sitemap']); db_create_table('xmlsitemap_sitemap', $schema['xmlsitemap_sitemap']);
} }
/**
* Update empty string languages to LANGUAGE_NONE.
*/
function xmlsitemap_update_7200() {
db_update('xmlsitemap')
->fields(array('language' => LANGUAGE_NONE))
->condition('language', '')
->execute();
}
...@@ -151,6 +151,7 @@ function xmlsitemap_sitemap_uri(array $sitemap) { ...@@ -151,6 +151,7 @@ function xmlsitemap_sitemap_uri(array $sitemap) {
'absolute' => TRUE, 'absolute' => TRUE,
'base_url' => xmlsitemap_var('base_url'), 'base_url' => xmlsitemap_var('base_url'),
); );
$uri['url'] = url($uri['path'], $uri['options']);
return $uri; return $uri;
} }
...@@ -170,6 +171,7 @@ function xmlsitemap_sitemap_delete($smid) { ...@@ -170,6 +171,7 @@ function xmlsitemap_sitemap_delete($smid) {
db_delete('xmlsitemap_sitemap') db_delete('xmlsitemap_sitemap')
->condition('smid', $smid) ->condition('smid', $smid)
->execute(); ->execute();
// @todo Delete context files.
} }
/** /**
...@@ -286,7 +288,7 @@ function xmlsitemap_robotstxt() { ...@@ -286,7 +288,7 @@ function xmlsitemap_robotstxt() {
$context = xmlsitemap_get_current_context(); $context = xmlsitemap_get_current_context();
if ($sitemap = xmlsitemap_sitemap_load_by_context($context)) { if ($sitemap = xmlsitemap_sitemap_load_by_context($context)) {
$uri = xmlsitemap_sitemap_uri($sitemap); $uri = xmlsitemap_sitemap_uri($sitemap);
$robotstxt[] = 'Sitemap: ' . url($uri['path'], $uri['options']); $robotstxt[] = 'Sitemap: ' . $uri['url'];
return $robotstxt; return $robotstxt;
} }
} }
......
...@@ -19,7 +19,7 @@ function xmlsitemap_xmlsitemap_link_info() { ...@@ -19,7 +19,7 @@ function xmlsitemap_xmlsitemap_link_info() {
* XML sitemap link type settings callback for frontpage link entity. * XML sitemap link type settings callback for frontpage link entity.
*/ */
function xmlsitemap_link_frontpage_settings(&$form) { function xmlsitemap_link_frontpage_settings(&$form) {
module_load_include('inc', 'xmlsitemap', 'xmlsitemap.admin'); module_load_include('admin.inc', 'xmlsitemap');
if (user_access('administer site configuration')) { if (user_access('administer site configuration')) {
$form['#description'] = t('The front page path can be changed at <a href="@url-frontpage">@url-frontpage</a>.', array('@url-frontpage' => url('admin/settings/site-information'))); $form['#description'] = t('The front page path can be changed at <a href="@url-frontpage">@url-frontpage</a>.', array('@url-frontpage' => url('admin/settings/site-information')));
} }
......
...@@ -31,45 +31,8 @@ function xmlsitemap_engines_uninstall() { ...@@ -31,45 +31,8 @@ function xmlsitemap_engines_uninstall() {
} }
/** /**
* Filter the xmlsitemap_engines_submit variable. * Implements hook_update_last_removed().
*/ */
function xmlsitemap_engines_update_1() { function xmlsitemap_engines_update_last_removed() {
variable_set('xmlsitemap_engines_submit', array_filter(variable_get('xmlsitemap_engines_submit', array()))); return 6201;
}
/**
* Rename the xmlsitemap_engines_engines variable to xmlsitemap_engines_submit.
*/
function xmlsitemap_engines_update_2() {
variable_set('xmlsitemap_engines_engines', variable_get('xmlsitemap_engines_submit', array()));
variable_del('xmlsitemap_engines_submit');
}
/**
* Increase the module weight so it always runs after sitemap generation.
*/
function xmlsitemap_engines_update_3() {
db_update('system')
->fields(array('weight' => 2))
->condition('type', 'module')
->condition('name', 'xmlsitemap_engines')
->execute();
}
/**
* Update Windows Live search to Bing.
*/
function xmlsitemap_engines_update_4() {
$engines = variable_get('xmlsitemap_engines_engines', array());
$index = array_search('windows_live', $engines);
if ($index !== FALSE) {
$engines[$index] = 'bing';
}
variable_set('xmlsitemap_engines_engines', $engines);
}
/**
* Empty update.
*/
function xmlsitemap_engines_update_6200() {
} }
...@@ -140,7 +140,8 @@ function xmlsitemap_engines_submit_engines(array $smids = array()) { ...@@ -140,7 +140,8 @@ function xmlsitemap_engines_submit_engines(array $smids = array()) {
*/ */
function xmlsitemap_engines_submit_sitemaps($url, array $sitemaps = array()) { function xmlsitemap_engines_submit_sitemaps($url, array $sitemaps = array()) {
foreach ($sitemaps as $sitemap) { foreach ($sitemaps as $sitemap) {
$submit_url = xmlsitemap_engines_prepare_url($url, $sitemap); $sitemap_url = xmlsitemap_sitemap_uri($sitemap);
$submit_url = xmlsitemap_engines_prepare_url($url, $sitemap_url['url']);
$request = drupal_http_request($submit_url); $request = drupal_http_request($submit_url);
watchdog('xmlsitemap', 'Submitted the sitemap to %url and received response @code.', array('%url' => $submit_url, '@code' => $request->code)); watchdog('xmlsitemap', 'Submitted the sitemap to %url and received response @code.', array('%url' => $submit_url, '@code' => $request->code));
} }
......
<?php <?php
// $Id$ // $Id$
/**
* Implements hook_xmlsitemap_context_info().
*/
function xmlsitemap_i18n_xmlsitemap_context_info() {
$context['language'] = array(
'label' => t('Language'),
'summary callback' => 'locale_language_name',
'settings callback' => 'xmlsitemap_i18n_xmlsitemap_language_context_settings',
);
return $context;
}
/** /**
* Implements hook_xmlsitemap_context(). * Implements hook_xmlsitemap_context().
*/ */
...@@ -11,17 +23,6 @@ function xmlsitemap_i18n_xmlsitemap_context() { ...@@ -11,17 +23,6 @@ function xmlsitemap_i18n_xmlsitemap_context() {
return $context; return $context;
} }
/**
* Implements xmlsitemap_context_url_options().
*/
function xmlsitemap_i18n_xmlsitemap_context_url_options(array $context) {
$options = array();
if (isset($context['language'])) {
$options['language'] = xmlsitemap_language_load($context['language']);
}
return $options;
}
/** /**
* Implements hook_xmlsitemap_context_fallback(). * Implements hook_xmlsitemap_context_fallback().
*/ */
...@@ -31,15 +32,14 @@ function xmlsitemap_i18n_xmlsitemap_context_fallback() { ...@@ -31,15 +32,14 @@ function xmlsitemap_i18n_xmlsitemap_context_fallback() {
} }
/** /**
* Implements hook_xmlsitemap_context_info(). * Implements xmlsitemap_context_url_options().
*/ */
function xmlsitemap_i18n_xmlsitemap_context_info() { function xmlsitemap_i18n_xmlsitemap_context_url_options(array $context) {
$context['language'] = array( $options = array();
'label' => t('Language'), if (isset($context['language'])) {
'summary callback' => 'locale_language_name', $options['language'] = xmlsitemap_language_load($context['language']);
'settings callback' => 'xmlsitemap_i18n_xmlsitemap_language_context_settings', }
); return $options;
return $context;
} }
/** /**
...@@ -54,6 +54,15 @@ function xmlsitemap_i18n_form_xmlsitemap_sitemap_edit_form_alter(&$form, $form_s ...@@ -54,6 +54,15 @@ function xmlsitemap_i18n_form_xmlsitemap_sitemap_edit_form_alter(&$form, $form_s
); );
} }
/**
* Implements hook_form_FORM_ID_alter().
*
* Set the regeneration needed flag if settings are changed.
*/
function xmlsitemap_form_locale_languages_overview_form_alter(&$form, $form_state) {
array_unshift($form['#submit'], 'xmlsitemap_form_submit_flag_regenerate');
}
/** /**
* Implements hook_form_FORM_ID_alter(). * Implements hook_form_FORM_ID_alter().
* *
...@@ -116,12 +125,3 @@ function xmlsitemap_i18n_query_xmlsitemap_alter(QueryAlterableInterface $query) ...@@ -116,12 +125,3 @@ function xmlsitemap_i18n_query_xmlsitemap_alter(QueryAlterableInterface $query)
break; break;
} }
} }
/**
* Implements hook_form_FORM_ID_alter().
*
* Set the regeneration needed flag if settings are changed.
*/
function xmlsitemap_form_locale_languages_overview_form_alter(&$form, $form_state) {
array_unshift($form['#submit'], 'xmlsitemap_form_submit_flag_regenerate');
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment