Skip to content

Commit

Permalink
Issue #3: cleanup more variable functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Finnarn committed Dec 3, 2016
1 parent 3d70fe2 commit 1432f45
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 41 deletions.
4 changes: 2 additions & 2 deletions xmlsitemap.generate.inc
Expand Up @@ -284,7 +284,7 @@ function xmlsitemap_regenerate_batch(array $smids = array()) {
);

// Set the regenerate flag in case something fails during file generation.
$batch['operations'][] = array('xmlsitemap_batch_config_set', array(array('xmlsitemap_regenerate_needed' => TRUE)));
$batch['operations'][] = array('xmlsitemap_batch_config_set', array(array('regenerate_needed' => TRUE)));

// @todo Get rid of this batch operation.
$batch['operations'][] = array('_xmlsitemap_regenerate_before', array());
Expand All @@ -296,7 +296,7 @@ function xmlsitemap_regenerate_batch(array $smids = array()) {
}

// Clear the regeneration flag.
$batch['operations'][] = array('xmlsitemap_batch_config_set', array(array('xmlsitemap_regenerate_needed' => FALSE)));
$batch['operations'][] = array('xmlsitemap_batch_config_set', array(array('regenerate_needed' => FALSE)));

return $batch;
}
Expand Down
36 changes: 18 additions & 18 deletions xmlsitemap.install
Expand Up @@ -406,26 +406,26 @@ function xmlsitemap_update_1000() {

// Convert any overridden variables to config.
$convert = array(
'xmlsitemap_rebuild_needed',
'xmlsitemap_regenerate_needed',
'xmlsitemap_minimum_lifetime',
'xmlsitemap_generated_last',
'xmlsitemap_xsl',
'xmlsitemap_prefetch_aliases',
'xmlsitemap_chunk_size',
'xmlsitemap_batch_limit',
'xmlsitemap_path',
'xmlsitemap_base_url',
'xmlsitemap_developer_mode',
'xmlsitemap_frontpage_priority',
'xmlsitemap_frontpage_changefreq',
'xmlsitemap_lastmod_format',
'xmlsitemap_gz',
'xmlsitemap_disable_cron_regeneration',
'xmlsitemap_output_elements',
'rebuild_needed',
'regenerate_needed',
'minimum_lifetime',
'generated_last',
'xsl',
'prefetch_aliases',
'chunk_size',
'batch_limit',
'path',
'base_url',
'developer_mode',
'frontpage_priority',
'frontpage_changefreq',
'lastmod_format',
'gz',
'disable_cron_regeneration',
'output_elements',
);
foreach ($convert as $name) {
$value = variable_get($name, FALSE);
$value = $config->get($name, FALSE);
if ($value) {
$new_key = substr($name, 11);
$config->set($new_key, $value);
Expand Down
16 changes: 10 additions & 6 deletions xmlsitemap.module
Expand Up @@ -202,6 +202,7 @@ function xmlsitemap_menu() {
'type' => MENU_CALLBACK,
'file' => 'xmlsitemap.pages.inc',
);

$items['sitemap.xsl'] = array(
'page callback' => 'xmlsitemap_output_xsl',
'access callback' => TRUE,
Expand Down Expand Up @@ -392,7 +393,7 @@ function xmlsitemap_sitemap_save(stdClass $sitemap) {
->execute();

// Mark the sitemaps as needing regeneration.
config_set('xmlsitemap.settings', 'xmlsitemap_regenerate_needed', TRUE);
config_set('xmlsitemap.settings', 'regenerate_needed', TRUE);
}

if ($sitemap->is_new) {
Expand Down Expand Up @@ -599,7 +600,7 @@ function xmlsitemap_link_save(array $link, array $context = array()) {
function xmlsitemap_link_update_multiple($updates = array(), $conditions = array(), $check_flag = TRUE) {
// If we are going to modify a visible sitemap link, we will need to set
// the regenerate needed flag.
if ($check_flag && !configget('xmlsitemap.settings', 'regenerate_needed', FALSE)) {
if ($check_flag && !config_get('xmlsitemap.settings', 'regenerate_needed')) {
_xmlsitemap_check_changed_links($conditions, $updates, TRUE);
}

Expand Down Expand Up @@ -1042,15 +1043,18 @@ function xmlsitemap_link_bundle_load($entity, $bundle, $load_bundle_info = TRUE)
$info['info'] = $entity_info['bundles'][$bundle];
}
}
$settings = config_get('xmlsitemap.settings', "settings_{$entity}_{$bundle}");
if (is_array($settings)) {
$info = array_merge($info, $settings);
}

$defaults = array(
'status' => XMLSITEMAP_STATUS_DEFAULT,
'priority' => XMLSITEMAP_PRIORITY_DEFAULT,
);
$info = array_merge($info, $defaults);

$settings = config_get('xmlsitemap.settings', "settings_{$entity}_{$bundle}");
if (is_array($settings)) {
$info = array_merge($info, $settings);
}

return $info;
}

Expand Down
8 changes: 7 additions & 1 deletion xmlsitemap.xmlsitemap.inc
Expand Up @@ -56,16 +56,22 @@ class XMLSitemapWriter extends XMLWriter {
}

public function getSitemapUrl($path, array $options = array()) {

$options += $this->sitemap->uri['options'];
$options += array(
'absolute' => TRUE,
'base_url' => config_get('xmlsitemap.settings', 'base_url', $GLOBALS['base_url']),
//'base_url' => config_get('xmlsitemap.settings', 'base_url', $GLOBALS['base_url']),
'language' => language_default(),
'alias' => TRUE,
);

// Add base_url here since using the addition operator above results in blank string.
$options['base_url'] = config_get('xmlsitemap.settings', 'base_url', $GLOBALS['base_url']);

if (!empty($options['protocol_relative'])) {
$options['base_url'] = preg_replace('~^https?:~', '', $options['base_url']);
}

return url($path, $options);
}

Expand Down
14 changes: 0 additions & 14 deletions xmlsitemap_menu/xmlsitemap_menu.module
Expand Up @@ -136,20 +136,6 @@ function xmlsitemap_menu_form_menu_edit_menu_alter(&$form, $form_state) {
xmlsitemap_add_link_bundle_settings($form, $form_state, 'menu_link', $menu);
}

//function xmlsitemap_menu_form_menu_overview_form_alter(&$form, $form_state) {
// $form['#submit'][] = 'xmlsitemap_menu_menu_overview_form_submit';
//}
//
//function xmlsitemap_menu_menu_overview_form_submit($form, $form_state) {
// $mlids = array();
// foreach (element_children($form) as $mlid) {
// if (isset($form[$mlid]['#item'])) {
// $mlids[] = $form[$mlid]['#item']['mlid'];
// }
// }
// xmlsitemap_menu_xmlsitemap_process_menu_links($mlids);
//}

/**
* Implements hook_form_FORM_ID_alter().
*
Expand Down

0 comments on commit 1432f45

Please sign in to comment.