Commit 1494e867 authored by Dave Reid's avatar Dave Reid

by Dave Reid: Lotsa updates and cleanups to try and get tests in better working order.

parent 684a2c7c
......@@ -8,6 +8,9 @@
* @ingroup xmlsitemap
*/
/**
* Render a tableselect list of XML sitemaps for the main admin page.
*/
function xmlsitemap_sitemap_list_form() {
$destination = drupal_get_destination();
......@@ -161,25 +164,7 @@ function xmlsitemap_sitemap_list_form_submit($form, &$form_state) {
}
}
/**
* Workaround for missing breadcrumbs on callback and action paths.
*
* @todo Remove when http://drupal.org/node/576290 is fixed.
*/
function _xmlsitemap_set_breadcrumb($path = 'admin/config/search/xmlsitemap') {
$breadcrumb = array();
$path = explode('/', $path);
do {
$menu_path = implode('/', $path);
$menu_item = menu_get_item($menu_path);
array_unshift($breadcrumb, l($menu_item['title'], $menu_path));
} while (array_pop($path) && !empty($path));
array_unshift($breadcrumb, l(t('Home'), NULL));
drupal_set_breadcrumb($breadcrumb);
}
function xmlsitemap_sitemap_edit_form(&$form, $form_state, array $sitemap = array()) {
// @todo Remove when http://drupal.org/node/576290 is fixed.
_xmlsitemap_set_breadcrumb();
$sitemap += array(
......@@ -249,7 +234,6 @@ function xmlsitemap_sitemap_edit_form_submit($form, &$form_state) {
}
function xmlsitemap_sitemap_delete_form(&$form, $form_state, array $sitemap) {
// @todo Remove when http://drupal.org/node/576290 is fixed.
_xmlsitemap_set_breadcrumb();
$count = (int) db_query("SELECT COUNT(smid) FROM {xmlsitemap_sitemap}")->fetchField();
......
......@@ -40,8 +40,8 @@ function hook_xmlsitemap_link_info() {
'access arguments' => array('administer mymodule'),
),
'xmlsitemap' => array(
'status' => 1,
'priority' => 0.5,
'status' => XMLSITEMAP_STATUS_DEFAULT,
'priority' => XMLSITEMAP_PRIORITY_DEFAULT,
),
),
),
......@@ -70,6 +70,114 @@ function hook_xmlsitemap_link_alter(&$link) {
}
}
/**
* Index links for the XML sitemaps.
*/
function hook_xmlsitemap_index_links($limit) {
}
/**
* Provide information about contexts available to XML sitemap.
*
* @see hook_xmlsitemap_context_info_alter().
*/
function hook_xmlsitemap_context_info() {
$info['vocabulary'] = array(
'label' => t('Vocabulary'),
'summary callback' => 'mymodule_xmlsitemap_vocabulary_context_summary',
'settings callback' => 'mymodule_xmlsitemap_vocabulary_context_settings',
'default' => 0,
);
return $info;
}
/**
* Alter XML sitemap context info.
*
* @see hook_xmlsitemap_context_info().
*/
function hook_xmlsitemap_context_info_alter(&$info) {
$info['vocabulary']['label'] = t('Site vocabularies');
}
/**
* Provide information about the current context on the site.
*
* @see hook_xmlsitemap_context_alter()
*/
function hook_xmlsitemap_context() {
$context = array();
if ($vid = mymodule_get_current_vocabulary()) {
$context['vocabulary'] = $vid;
}
return $context;
}
/**
* Alter the current context information.
*
* @see hook_xmlsitemap_context()
*/
function hook_xmlsitemap_context_alter(&$context) {
if (user_access('administer taxonomy')) {
unset($context['vocabulary']);
}
}
/**
* Provide options for the url() function based on an XML sitemap context.
*/
function hook_xmlsitemap_context_url_options(array $context) {
}
/**
* Alter the url() options based on an XML sitemap context.
*/
function hook_xmlsitemap_context_url_options_alter(array &$options, array $context) {
}
/**
* Alter the query selecting data from {xmlsitemap} during sitemap generation.
*
* @param $query
* A Query object describing the composite parts of a SQL query.
*
* @see hook_query_TAG_alter()
*/
function hook_query_xmlsitemap_generate_alter(QueryAlterableInterface $query) {
$sitemap = $query->getMetaData('sitemap');
if (!empty($sitemap['context']['vocabulary'])) {
$node_condition = db_and();
$node_condition->condition('type', 'taxonomy_term');
$node_condition->condition('subtype', $sitemap['context']['vocabulary']);
$normal_condition = db_and();
$normal_condition->condition('type', 'taxonomy_term', '<>');
$condition = db_or();
$condition->condition($node_condition);
$condition->condition($normal_condition);
$query->condition($condition);
}
}
/**
* Provide information about XML sitemap bulk operations.
*/
function hook_xmlsitemap_sitemap_operations() {
}
/**
* Respond to XML sitemap deletion.
*
* This hook is invoked from xmlsitemap_sitemap_delete_multiple() after the XML
* siteamp has been removed from the table in the database.
*
* @param $sitemap
* The XML sitemap array that was deleted.
*/
function hook_xmlsitemap_siteamp_delete(array $sitemap) {
db_query("DELETE FROM {mytable} WHERE smid = '%s'", $sitemap['smid']);
}
/**
* @} End of "addtogroup hooks".
*/
......@@ -44,15 +44,6 @@ function xmlsitemap_get_path_alias($path, $language) {
}
}
/**
* @todo Move to xmlsitemap.context.inc
*/
function xmlsitemap_get_url_options_from_context(array $context) {
$options = module_invoke_all('xmlsitemap_context_url_options', $context);
drupal_alter('xmlsitemap_context_url_options', $options, $context);
return $options;
}
/**
* Perform operations before rebuilding the sitemap.
*/
......@@ -64,8 +55,13 @@ function _xmlsitemap_regenerate_before() {
// Set a timer so we can track how long this takes.
timer_start('xmlsitemap_regenerate');
// Get the current memory usage so we can track how much memory is used.
_xmlsitemap_get_memory_usage(TRUE);
if (variable_get('xmlsitemap_developer_mode', 0)) {
watchdog('xmlsitemap', 'Starting XML sitemap generation. Memory usage: @memory-peak.', array(
'@memory-peak' => format_size(memory_get_peak_usage(TRUE)),
),
WATCHDOG_DEBUG
);
}
// Clear the maximum chunk and file size variables.
variable_set('xmlsitemap_max_chunks', 0);
......@@ -81,8 +77,14 @@ function _xmlsitemap_get_memory_usage($start = FALSE) {
return $current - $memory_start;
}
/**
* Calculate the optimal PHP memory limit for sitemap generation.
*
* This function just makes a guess. It does not take into account
* the currently loaded modules.
*/
function _xmlsitemap_get_optimal_memory_limit() {
static $optimal_limit;
$optimal_limit = &drupal_static(__FUNCTION__);
if (!isset($optimal_limit)) {
// Set the base memory amount from the provided core constant.
$optimal_limit = parse_size(DRUPAL_MINIMUM_PHP_MEMORY_LIMIT);
......@@ -91,21 +93,29 @@ function _xmlsitemap_get_optimal_memory_limit() {
$optimal_limit += xmlsitemap_get_chunk_size() * 500;
// Add memory for storing the url aliases.
$aliases = db_query("SELECT COUNT(pid) FROM {url_alias}")->fetchField();
$optimal_limit += $aliases * 250;
if (variable_get('xmlsitemap_prefetch_aliases', 1)) {
$aliases = db_query("SELECT COUNT(pid) FROM {url_alias}")->fetchField();
$optimal_limit += $aliases * 250;
}
}
return $optimal_limit;
}
/**
* Calculate the optimal memory level for sitemap generation.
*
* @param $new_limit
* An optional PHP memory limit in bytes. If not provided, the value of
* _xmlsitemap_get_optimal_memory_limit() will be used.
*/
function _xmlsitemap_set_memory_limit() {
$memory_limit = @ini_get('memory_limit');
if ($memory_limit && $memory_limit != -1) {
$optimal_limit = _xmlsitemap_get_optimal_memory_limit();
if (parse_size($memory_limit) < $optimal_limit) {
@ini_set('memory_limit', $optimal_limit);
function _xmlsitemap_set_memory_limit($new_limit = NULL) {
$current_limit = @ini_get('memory_limit');
if ($current_limit && $current_limit != -1) {
if (!is_null($new_limit)) {
$new_limit = _xmlsitemap_get_optimal_memory_limit();
}
if (parse_size($current_limit) < $new_limit) {
return @ini_set('memory_limit', $new_limit);
}
}
}
......@@ -116,13 +126,12 @@ function _xmlsitemap_set_memory_limit() {
function _xmlsitemap_regenerate_after() {
// Show a watchdog message that the sitemap was regenerated.
watchdog('xmlsitemap',
'XML sitemap files regenerated in @timer ms. Peak memory usage: @memory-peak.',
'Finished XML sitemap generation in @timer ms. Memory usage: @memory-peak.',
array(
'@timer' => timer_read('xmlsitemap_regenerate'),
'@memory-peak' => format_size(memory_get_peak_usage(TRUE)),
),
WATCHDOG_NOTICE,
l(t('View sitemap'), 'sitemap.xml')
WATCHDOG_NOTICE
);
// Unset the regenerate flag.
......@@ -201,9 +210,7 @@ function xmlsitemap_generate_chunk_header($type, array $sitemap, $handle, &$stat
// Add the stylesheet link.
if (variable_get('xmlsitemap_xsl', 1)) {
$url_options = xmlsitemap_get_url_options_from_context($sitemap['context']);
$url_options['alias'] = TRUE;
$xsl_url = url('sitemap.xsl', $url_options);
$xsl_url = url('sitemap.xsl', $sitemap['uri']['options'] + array('alias' => TRUE));
$output .= '<?xml-stylesheet type="text/xsl" href="' . $xsl_url . '"?>' . PHP_EOL;
}
......@@ -236,7 +243,7 @@ function xmlsitemap_generate_chunk_header($type, array $sitemap, $handle, &$stat
function xmlsitemap_generate_chunk(array $sitemap, $handle, &$status, $chunk) {
$lastmod_format = variable_get('xmlsitemap_lastmod_format', XMLSITEMAP_LASTMOD_MEDIUM);
$url_options = xmlsitemap_get_url_options_from_context($sitemap['context']);
$url_options = $sitemap['uri']['options'];
$url_options += array(
'absolute' => TRUE,
'base_url' => variable_get('xmlsitemap_base_url', $GLOBALS['base_url']),
......@@ -253,8 +260,8 @@ function xmlsitemap_generate_chunk(array $sitemap, $handle, &$status, $chunk) {
$query->condition('status', 1);
$query->orderBy('language', 'DESC');
$query->orderBy('loc');
$query->addTag('xmlsitemap');
$query->addMetaData('context', $sitemap['context']);
$query->addTag('xmlsitemap_generate');
$query->addMetaData('sitemap', $sitemap);
$offset = max($chunk - 1, 0) * xmlsitemap_get_chunk_size();
$limit = xmlsitemap_get_chunk_size();
......@@ -323,7 +330,7 @@ function xmlsitemap_generate_chunk(array $sitemap, $handle, &$status, $chunk) {
function xmlsitemap_generate_index(array $sitemap, $handle, &$status) {
$lastmod_format = variable_get('xmlsitemap_lastmod_format', XMLSITEMAP_LASTMOD_MEDIUM);
$url_options = xmlsitemap_get_url_options_from_context($sitemap['context']);
$url_options = $sitemap['uri']['options'];
$url_options += array(
'absolute' => TRUE,
'base_url' => variable_get('xmlsitemap_base_url', $GLOBALS['base_url']),
......
......@@ -43,3 +43,48 @@ function _xmlsitemap_get_version() {
}
return $version;
}
/**
* Check the status of all hook_requirements() from any xmlsitemap modules.
*/
function xmlsitemap_check_status() {
$messages = &drupal_static(__FUNCTION__);
if (!isset($messages)) {
// Cache the list of modules that are checked.
if ($cache = cache_get('xmlsitemap:registry:requirements')) {
$modules = $cache->data;
}
else {
$modules = array();
module_load_all_includes('install');
foreach (module_implements('requirements') as $module) {
if (strpos($module, 'xmlsitemap') !== FALSE) {
$modules[] = $module;
}
}
cache_set('xmlsitemap:registry:requirements', $modules);
}
$messages = array();
foreach ($modules as $module) {
module_load_install($module);
$requirements = module_invoke($module, 'requirements', 'runtime');
foreach ($requirements as $requirement) {
if (isset($requirement['severity']) && max(REQUIREMENT_OK, $requirement['severity'])) {
$messages[] = $requirement['description'];
}
}
}
if ($messages) {
$message = t('One or more problems were detected with your XML sitemap configuration: !messages', array('!messages' => theme('item_list', array('items' => $messages))));
if (user_access('access site reports')) {
$message .= t('Check the <a href="@status-report">status report</a> for more information.', array('@status-report' => url('admin/reports/status')));
}
drupal_set_message($message, 'warning', FALSE);
}
}
return !empty($messages);
}
......@@ -303,7 +303,6 @@ function xmlsitemap_install() {
->fields(array(
'context' => $context,
'context_hash' => md5($context),
//'queued' => REQUEST_TIME,
))
->execute();
......@@ -335,50 +334,6 @@ function xmlsitemap_uninstall() {
xmlsitemap_clear_directory(NULL, TRUE);
}
/**
* Check the status of all hook_requirements() from xmlsitemap modules.
*/
function xmlsitemap_check_status() {
$messages = &drupal_static(__FUNCTION__);
if (!isset($messages)) {
// Cache the list of modules that are checked.
if ($cache = cache_get('xmlsitemap:status:modules')) {
$modules = $cache->data;
}
else {
$modules = array();
foreach (module_implements('requirements') as $module) {
if (strpos($module, 'xmlsitemap') !== FALSE) {
$modules[] = $module;
}
}
cache_set('xmlsitemap:status:modules', $modules);
}
$messages = array();
foreach ($modules as $module) {
module_load_install($module);
$requirements = module_invoke($module, 'requirements', 'runtime');
foreach ($requirements as $requirement) {
if (isset($requirement['severity']) && max(REQUIREMENT_OK, $requirement['severity'])) {
$messages[] = $requirement['description'];
}
}
}
if ($messages) {
$message = t('One or more problems were detected with your XML sitemap configuration: !messages', array('!messages' => theme('item_list', array('items' => $messages))));
if (user_access('access site reports')) {
$message .= t('Check the <a href="@status-report">status report</a> for more information.', array('@status-report' => url('admin/reports/status')));
}
drupal_set_message($message, 'warning', FALSE);
}
}
return !empty($messages);
}
/**
* Implements hook_update_last_removed().
*/
......@@ -396,6 +351,7 @@ function xmlsitemap_update_6202() {
'smid' => array(
'description' => 'Sitemap ID',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'context_hash' => array(
......@@ -439,8 +395,9 @@ function xmlsitemap_update_6202() {
// Add the default sitemap(s) and use language contexts if possible.
if (!db_query("SELECT COUNT(smid) FROM {xmlsitemap_sitemap}")->fetchField()) {
// Refresh the schema.
// Refresh the schema and load the module if it's disabled.
drupal_get_schema(NULL, TRUE);
drupal_load('module', 'xmlsitemap');
if (module_exists('xmlsitemap_i18n') && $languages = variable_get('xmlsitemap_languages', array())) {
foreach ($languages as $language) {
......
This diff is collapsed.
......@@ -44,8 +44,10 @@ function xmlsitemap_output_chunk() {
$file = xmlsitemap_sitemap_get_file($sitemap, $chunk);
// Provide debugging information if enabled.
if (variable_get('xmlsitemap_developer_mode', 0) || isset($_GET['debug'])) {
if (variable_get('xmlsitemap_developer_mode', 0) && isset($_GET['debug'])) {
$output = array();
$context = xmlsitemap_get_current_context();
$output[] = "Current context: " . print_r($context, TRUE);
$output[] = "Sitemap: " . print_r($sitemap, TRUE);
$output[] = "Chunk: $chunk";
$output[] = "Cache file location: $file";
......
......@@ -62,8 +62,7 @@ class XMLSitemapTestHelper extends DrupalWebTestCase {
protected function regenerateSitemap() {
variable_set('xmlsitemap_regenerate_needed', TRUE);
variable_set('xmlsitemap_generated_last', 0);
module_load_include('inc', 'xmlsitemap', 'xmlsitemap.generate');
xmlsitemap_regenerate();
$this->cronRun();
$this->assertTrue(variable_get('xmlsitemap_generated_last', 0) && !variable_get('xmlsitemap_regenerate_needed', FALSE), t('XML sitemaps regenerated and flag cleared.'));
}
......@@ -161,12 +160,14 @@ class XMLSitemapTestHelper extends DrupalWebTestCase {
$link += array(
'type' => 'testing',
'id' => $last_id,
'access' => 1,
'status' => 1,
);
// Make the default path easier to read than a random string.
$link += array('loc' => $link['type'] . '-' . $link['id']);
$last_id = $link['id'] + 1;
$last_id = max($last_id, $link['id']) + 1;
xmlsitemap_save_link($link);
return $link;
}
......
<?php
// $Id$
/**
* @file
* XML sitemap integration functions for xmlsitemap.module.
*/
/**
* Implements hook_xmlsitemap_link_info().
*/
......@@ -44,8 +49,8 @@ function xmlsitemap_link_frontpage_settings(&$form) {
function xmlsitemap_xmlsitemap_link_alter(&$link) {
// Alter the frontpage priority.
if ($link['type'] == 'frontpage' || $link['loc'] == '' || $link['loc'] == drupal_get_normal_path(variable_get('site_frontpage', 'node'))) {
$link['priority'] = xmlsitemap_var('frontpage_priority');
$link['changefreq'] = xmlsitemap_var('frontpage_changefreq');
$link['priority'] = variable_get('xmlsitemap_frontpage_priority', 1.0);
$link['changefreq'] = variable_get('xmlsitemap_frontpage_changefreq', XMLSITEMAP_FREQUENCY_DAILY);
}
}
......@@ -75,7 +80,7 @@ function xmlsitemap_xmlsitemap_sitemap_operations() {
}
/**
* Sitemap operation callback; regenerate sitemap files using the batch API.
* XML sitemap operation callback; regenerate sitemap files using the batch API.
*
* @param $smids
* An array of XML sitemap IDs.
......@@ -87,17 +92,3 @@ function xmlsitemap_sitemap_multiple_update(array $smids) {
$batch = xmlsitemap_regenerate_batch($smids);
batch_set($batch);
}
function _xmlsitemap_sitemap_context_summary(array $sitemap, $context_key, array $context_info) {
$context_value = isset($sitemap['context'][$context_key]) ? $sitemap['context'][$context_key] : NULL;
if (!isset($context_value)) {
return t('Default');
}
elseif (!empty($context_info['summary callback'])) {
return $context_info['summary callback']($context_value);
}
else {
return $context_value;
}
}
......@@ -71,14 +71,12 @@ function xmlsitemap_custom_list_links() {
function xmlsitemap_custom_edit_link_form($form, &$form_state, $link = array()) {
module_load_include('inc', 'xmlsitemap', 'xmlsitemap.admin');
// @todo Remove when http://drupal.org/node/576290 is fixed.
_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' => 0.5,
'priority' => XMLSITEMAP_PRIORITY_DEFAULT,
'lastmod' => 0,
'changefreq' => 0,
'changecount' => 0,
......@@ -178,7 +176,6 @@ function xmlsitemap_custom_edit_link_form_submit($form, &$form_state) {
function xmlsitemap_custom_delete_link_form($form, &$form_state, array $link) {
// @todo Remove when http://drupal.org/node/576290 is fixed.
module_load_include('inc', 'xmlsitemap', 'xmlsitemap.admin');
_xmlsitemap_set_breadcrumb('admin/config/search/xmlsitemap/custom');
$form['link'] = array(
......
......@@ -9,6 +9,7 @@ function xmlsitemap_i18n_xmlsitemap_context_info() {
'label' => t('Language'),
'summary callback' => 'locale_language_name',
'settings callback' => 'xmlsitemap_i18n_xmlsitemap_language_context_settings',
'default' => language_default('language'),
);
return $context;
}
......@@ -17,17 +18,7 @@ function xmlsitemap_i18n_xmlsitemap_context_info() {
* Implements hook_xmlsitemap_context().
*/
function xmlsitemap_i18n_xmlsitemap_context() {
global $language;
$context['language'] = $language->language;
return $context;
}
/**
* Implements hook_xmlsitemap_context_fallback().
*/
function xmlsitemap_i18n_xmlsitemap_context_fallback() {
$context['language'] = language_default('language');
$context['language'] = $GLOBALS['language']->language;
return $context;
}
......@@ -77,16 +68,16 @@ function xmlsitemap_i18n_form_i18n_admin_settings_alter(&$form, $form_state) {
*
* @see i18n_db_rewrite_where()
*/
function xmlsitemap_i18n_query_xmlsitemap_alter(QueryAlterableInterface $query) {
function xmlsitemap_i18n_query_xmlsitemap_generate_alter(QueryAlterableInterface $query) {
$mode = variable_get('i18n_selection_mode', 'simple');
$context = $query->getMetaData('context');
$sitemap = $query->getMetaData('sitemap');
if (!isset($context['language']) || $mode == 'off') {
if (!isset($sitemap['context']['language']) || $mode == 'off') {
return;
}
// Get languages to simplify query building.
$current = $context['language'];
$current = $sitemap['context']['language'];
$default = i18n_default_language();
if ($mode == 'mixed' && $current == $default) {
......
......@@ -18,66 +18,17 @@ function xmlsitemap_menu_uninstall() {
}
}
// @todo Remove these update functions before alpha.
function xmlsitemap_menu_update_1() {
$value = xmlsitemap_menu_var('menus');
variable_set('xmlsitemap_menu_menus', array_filter($value));
}
function xmlsitemap_menu_update_2() {
$field = array(
'description' => 'The {menu_links}.menu_name of this menu link.',
'type' => 'varchar',
'length' => 32,
'default' => NULL,
);
db_add_field('xmlsitemap', 'menu_name', $field);
db_add_index('xmlsitemap', 'menu_name', array('menu_name'));
db_query("UPDATE {xmlsitemap} SET menu_name = (SELECT menu_name FROM {menu_links} WHERE mlid = {xmlsitemap}.id) WHERE type = 'menu'");
}
function xmlsitemap_menu_update_3() {
$menus = variable_get('xmlsitemap_menu_menus', array());
foreach ($menus as $menu) {
variable_set('xmlsitemap_menu_status_' . $menu, TRUE);
}
variable_del('xmlsitemap_menu_menus');
}
function xmlsitemap_menu_update_4() {
}
function xmlsitemap_menu_update_5() {
}
// Skip to 6 since I was stupid and had xmlsitemap_menu_update_5() in xmlsitemap_node.install
function xmlsitemap_menu_update_6() {
db_update('system')
->fields(array('weight' => 0))
->condition('type', 'module')
->condition('name', 'xmlsitemap_menu')
->execute();
}
function xmlsitemap_menu_update_7() {
$menus = array_keys(menu_get_menus());
foreach ($menus as $menu) {
if (variable_get('xmlsitemap_menu_priority_' . $menu, 'default') === 'default') {
variable_set('xmlsitemap_menu_priority_' . $menu, 0.5);
}
}
}
/**
* Cleanup variables.
*/
function xmlsitemap_menu_update_6200() {
drupal_load('module', 'menu');
drupal_load('module', 'xmlsitemap');
$menus = array_keys(menu_get_menus());
foreach ($menus as $menu) {
$settings = array(
'status' => variable_get('xmlsitemap_menu_status_' . $menu, 0),
'priority' => variable_get('xmlsitemap_menu_priority_' . $menu, 0.5),
'status' => variable_get('xmlsitemap_menu_status_' . $menu, XMLSITEMAP_STATUS_DEFAULT),
'priority' => variable_get('xmlsitemap_menu_priority_' . $menu, XMLSITEMAP_PRIORITY_DEFAULT),
);
variable_set('xmlsitemap_settings_menu_' . $menu, $settings);
variable_del('xmlsitemap_menu_status_' . $menu);
......
......@@ -190,12 +190,6 @@ function xmlsitemap_menu_create_link(array $menu_item) {
'priority_override' => 0,
);
//if (!isset($menu_item['access'])) {
// xmlsitemap_switch_user(0);
// $menu_item = menu_link_load($menu_item['mlid']);
// xmlsitemap_restore_user();
//}
// The following values must always be checked because they are volatile.
$menu_item['xmlsitemap']['subtype'] = $menu_item['menu_name'];
$menu_item['xmlsitemap']['access'] = $menu_item['access'] && !$menu_item['external'] && !$menu_item['hidden'];
......@@ -221,8 +215,8 @@ function xmlsitemap_menu_variables() {
$menus = array_keys(menu_get_menus());
foreach ($menus as $menu) {
$defaults['xmlsitemap_settings_menu_' . $menu] = array(
'status' => 0,
'priority' => 0.5,
'status' => XMLSITEMAP_STATUS_DEFAULT,
'priority' => XMLSITEMAP_PRIORITY_DEFAULT,
);
}
return $defaults;
......
......@@ -18,59 +18,17 @@ function xmlsitemap_node_uninstall() {
}
}
// @todo Remove these update functions before alpha.
function xmlsitemap_node_update_1() {
$field = array(
'description' => "The {node_type}.type of this link's node.",
'type' => 'varchar',
'length' => 32,
);
db_add_field('xmlsitemap', 'node_type', $field);
db_add_index('xmlsitemap', 'node_type', array('node_type'));
db_query("UPDATE {xmlsitemap} SET node_type = (SELECT type FROM {node} WHERE nid = {xmlsitemap}.id) WHERE type = 'node'");
}
function xmlsitemap_node_update_2() {
$node_types = array_keys(node_type_get_names());
foreach ($node_types as $node_type) {
if (variable_get('xmlsitemap_node_priority_' . $node_type, 'default') === 'default') {
variable_set('xmlsitemap_node_priority_' . $node_type, 0.5);
}
}
}
function xmlsitemap_node_update_3() {
db_update('system')
->fields(array('weight' => 0))
->condition('type', 'module')
->condition('name', 'xmlsitemap_node')
->execute();
}
function xmlsitemap_node_update_4() {
return array();
}
/**
* Update node languages.
*
* @after xmlsitemap_update_16()
* Must run after the {xmlsitemap}.language field has been added.
*/
function xmlsitemap_node_update_5() {
db_query("UPDATE {xmlsitemap} SET language = (SELECT {node}.language FROM {node} WHERE {node}.nid = {xmlsitemap}.id) WHERE {xmlsitemap}.type = 'node'");
}