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) {
......
......@@ -42,6 +42,16 @@ define('XMLSITEMAP_LASTMOD_MEDIUM', 'Y-m-d\TH:i\Z');
*/
define('XMLSITEMAP_LASTMOD_LONG', 'c');
/**
* The default inclusion status for link types in the sitemaps.
*/
define('XMLSITEMAP_STATUS_DEFAULT', 0);
/**
* The default priority for link types in the sitemaps.
*/
define('XMLSITEMAP_PRIORITY_DEFAULT', 0.5);
/**
* Implements hook_hook_info().
*/
......@@ -73,6 +83,9 @@ function xmlsitemap_hook_info() {
$hooks['xmlsitemap_sitemap_operations'] = array(
'group' => 'xmlsitemap',
);
$hooks['xmlsitemap_sitemap_delete'] = array(
'group' => 'xmlsitemap',
);
return $hooks;
}
......@@ -94,15 +107,13 @@ function xmlsitemap_help($path, $arg) {
$output .= '<p>' . t("This action rebuilds your site's XML sitemap and regenerates the cached files, and may be a lengthy process. If you just installed XML sitemap, this can be helpful to import all your site's content into the sitemap. Otherwise, this should only be used in emergencies.") . '</p>';
}
if (arg(0) == 'admin' && strpos($path, 'xmlsitemap') !== FALSE) {
if ($arg[1] == 'config' && user_access('administer xmlsitemap')) {
module_load_install('xmlsitemap');
xmlsitemap_check_status();
}
if (arg(0) == 'admin' && strpos($path, 'xmlsitemap') !== FALSE && user_access('administer xmlsitemap')) {
module_load_include('inc', 'xmlsitemap');
if ($blurb = _xmlsitemap_get_blurb()) {
$output .= $blurb;
if ($arg[1] == 'config') {
// Alert the user to any potential problems detected by hook_requirements.
xmlsitemap_check_status();
}
$output .= _xmlsitemap_get_blurb();
}
return $output;
......@@ -112,27 +123,50 @@ function xmlsitemap_help($path, $arg) {
* Implements hook_perm().
*/
function xmlsitemap_permission() {
return array(
'administer xmlsitemap' => array(
'title' => t('Administer XML sitemap settings.'),
),
$permissions['administer xmlsitemap'] = array(
'title' => t('Administer XML sitemap settings.'),
);
return $permissions;
}
function xmlsitemap_sitemap_load_multiple(array $smids) {
$sitemaps = !empty($smids) ? db_query("SELECT * FROM {xmlsitemap_sitemap} WHERE smid IN (:smids)", array(':smids' => $smids))->fetchAllAssoc('smid', PDO::FETCH_ASSOC) : array();
foreach ($sitemaps as $smid => $sitemap) {
$sitemaps[$smid]['context'] = unserialize($sitemap['context']);
$sitemaps[$smid]['uri'] = xmlsitemap_sitemap_uri($sitemaps[$smid]);
}
return $sitemaps;
}
/**
* Load an XML sitemap array from the database.
*
* @param $smid
* An XML sitemap ID.
*/
function xmlsitemap_sitemap_load($smid) {
$sitemap = xmlsitemap_sitemap_load_multiple(array($smid));
return $sitemap ? reset($sitemap) : FALSE;
}
/**
* Load multiple XML sitemaps from the database.
*
* @param $smids
* An array of XML sitemap IDs.
*/
function xmlsitemap_sitemap_load_multiple(array $smids) {
$sitemaps = array();
if ($smids) {
$sitemaps = db_query("SELECT * FROM {xmlsitemap_sitemap} WHERE smid IN (:smids)", array(':smids' => $smids))->fetchAllAssoc('smid', PDO::FETCH_ASSOC);
foreach ($sitemaps as $smid => $sitemap) {
$sitemaps[$smid]['context'] = unserialize($sitemap['context']);
$sitemaps[$smid]['uri'] = xmlsitemap_sitemap_uri($sitemaps[$smid]);
}
}
return $sitemaps;
}
/**
* Load an XML sitemap array from the database based on its context.
*
* @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.
*
* @see xmlsitemap_get_current_context()
*/
function xmlsitemap_sitemap_load_by_context(array $context = NULL) {
if (!isset($context)) {
$context = xmlsitemap_get_current_context();
......@@ -142,6 +176,58 @@ function xmlsitemap_sitemap_load_by_context(array $context = NULL) {
return xmlsitemap_sitemap_load($smid);
}
/**
* Save changes to an XML sitemap or add a new XML sitemap.
*
* @param $sitemap
* The XML sitemap array to be saved. If $sitemap['smid'] is omitted, a new
* XML sitemap will be added.
*
* @todo Save the sitemap's URL as a column?
*/
function xmlsitemap_sitemap_save(array $sitemap) {
// Make sure context is sorted before saving the hash.
asort($sitemap['context']);
$sitemap['context_hash'] = md5(serialize($sitemap['context']));
if (!empty($sitemap['smid'])) {
drupal_write_record('xmlsitemap_sitemap', $sitemap, array('smid'));
}
else {
drupal_write_record('xmlsitemap_sitemap', $sitemap);
}
}
/**
* Delete an XML sitemap.
*
* @param $smid
* An XML sitemap ID.
*/
function xmlsitemap_sitemap_delete($smid) {
xmlsitemap_sitemap_delete_multiple(array($smid));
}
/**
* Delete multiple XML sitemaps.
*
* @param $smids
* An array of XML sitemap IDs.
*/
function xmlsitemap_sitemap_delete_multiple(array $smids) {
if (!empty($smids)) {
$sitemaps = xmlsitemap_sitemap_load_multiple($smids);
db_delete('xmlsitemap_sitemap')
->condition('smid', $smids)
->execute();
foreach ($sitemaps as $sitemap) {
xmlsitemap_clear_directory($sitemap, TRUE);
module_invoke_all('xmlsitemap_sitemap_delete', $sitemap);
}
}
}
/**
* Return the expected file path for a specific sitemap chunk.
*
......@@ -164,11 +250,9 @@ function xmlsitemap_sitemap_get_file(array $sitemap, $chunk = 'index') {
* the XML sitemap, and matching the signature of url().
*/
function xmlsitemap_sitemap_uri(array $sitemap) {
// @todo Why aren't all modules invoked sometimes? Why is this include needed?
module_load_all_includes('xmlsitemap.inc');
$uri['path'] = 'sitemap.xml';
$uri['options'] = module_invoke_all('xmlsitemap_context_url_options', $sitemap['context']);
drupal_alter('xmlsitemap_context_url_options', $uri['options'], $sitemap['context']);
$uri['options'] += array(
'absolute' => TRUE,
'base_url' => variable_get('xmlsitemap_base_url', $GLOBALS['base_url']),
......@@ -176,26 +260,6 @@ function xmlsitemap_sitemap_uri(array $sitemap) {
return $uri;
}
// @todo Save $sitemap['url']?
function xmlsitemap_sitemap_save(array $sitemap) {
asort($sitemap['context']);
$sitemap['context_hash'] = md5(serialize($sitemap['context']));
if (!empty($sitemap['smid'])) {
drupal_write_record('xmlsitemap_sitemap', $sitemap, array('smid'));
}
else {
drupal_write_record('xmlsitemap_sitemap', $sitemap);
}
}
function xmlsitemap_sitemap_delete(array $sitemap) {
db_delete('xmlsitemap_sitemap')
->condition('smid', $sitemap['smid'])
->execute();
xmlsitemap_clear_directory($sitemap, TRUE);
}
/**
* Implements hook_menu().
*/
......@@ -305,6 +369,20 @@ function xmlsitemap_cron() {
xmlsitemap_run_progressive_batch('xmlsitemap_regenerate_batch');
}
/**
* Implements hook_modules_enabled().
*/
function xmlsitemap_modules_enabled(array $modules) {
cache_clear_all('xmlsitemap:', 'cache', TRUE);
}
/**
* Implements hook_modules_disabled().
*/
function xmlsitemap_modules_disabled(array $modules) {
cache_clear_all('xmlsitemap:', 'cache', TRUE);
}
/**
* Implements hook_robotstxt().
*/
......@@ -541,10 +619,10 @@ function xmlsitemap_link_load_multiple(array $conditions = array()) {
function xmlsitemap_save_link(array $link) {
$link += array(
'access' => 1,
'status' => 1,
'status' => XMLSITEMAP_STATUS_DEFAULT,
'status_override' => 0,
'lastmod' => 0,
'priority' => 0.5,
'priority' => XMLSITEMAP_PRIORITY_DEFAULT,
'priority_override' => 0,
'changefreq' => 0,
'changecount' => 0,
......@@ -790,7 +868,7 @@ function xmlsitemap_restore_user() {
function xmlsitemap_process_form_link_options($form, &$form_state) {
$link = &$form_state['values']['xmlsitemap'];
$fields = array('status' => 0, 'priority' => 0.5);
$fields = array('status' => XMLSITEMAP_STATUS_DEFAULT, 'priority' => XMLSITEMAP_PRIORITY_DEFAULT);
foreach ($fields as $field => $default) {
if ($link[$field] === 'default') {
......@@ -834,7 +912,6 @@ function xmlsitemap_get_changefreq_options() {
function xmlsitemap_get_link_info($type = NULL, $reset = FALSE) {
global $language;
$link_info = &drupal_static(__FUNCTION__);
module_load_all_includes('xmlsitemap.inc');
if ($reset) {
$link_info = NULL;
......@@ -1032,7 +1109,7 @@ 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' => 0, 'priority' => 0.5);
$settings += array('status' => XMLSITEMAP_STATUS_DEFAULT, 'priority' => XMLSITEMAP_PRIORITY_DEFAULT);
return $settings;
}
......@@ -1082,9 +1159,6 @@ function xmlsitemap_get_context_info($context = NULL, $reset = FALSE) {
global $language;
$info = &drupal_static(__FUNCTION__);
// @todo Why aren't all modules invoked sometimes? Why is this include needed?
module_load_all_includes('xmlsitemap.inc');
if ($reset) {
$info = NULL;
}
......@@ -1113,9 +1187,6 @@ function xmlsitemap_get_context_info($context = NULL, $reset = FALSE) {
function xmlsitemap_get_current_context() {
$context = &drupal_static(__FUNCTION__);
// @todo Why aren't all modules invoked sometimes? Why is this include needed?
module_load_all_includes('xmlsitemap.inc');
if (!isset($context)) {
$context = module_invoke_all('xmlsitemap_context');
drupal_alter('xmlsitemap_context', $context);
......@@ -1125,42 +1196,6 @@ function xmlsitemap_get_current_context() {
return $context;
}
function xmlsitemap_get_default_context() {
$context = &drupal_static(__FUNCTION__);
// @todo Why aren't all modules invoked sometimes? Why is this include needed?
module_load_all_includes('xmlsitemap.inc');
if (!isset($context)) {
$context = module_invoke_all('xmlsitemap_context_fallback');
drupal_alter('xmlsitemap_context_fallback', $context);