Commit 62a9446d authored by gbyte.co's avatar gbyte.co

Small code cleanup.

parent 6ea2c151
custom:
-
path: /
priority: 1
priority: 1.0
entity_types: []
......
......@@ -5,13 +5,13 @@ simple_sitemap.settings:
type: mapping
mapping:
max_links:
label: 'Max Links'
label: 'Max links'
type: integer
cron_generate:
label: 'Cron Generate'
label: 'Cron generate'
type: boolean
remove_duplicates:
label: 'Remove Duplicates'
label: 'Remove duplicates'
type: boolean
batch_process_limit:
label: 'Batch process limit'
......@@ -29,7 +29,7 @@ simple_sitemap.settings:
label: 'Priority'
type: float
entity_types:
label: 'Entity Types'
label: 'Entity types'
type: sequence
sequence:
type: sequence
......
......@@ -86,4 +86,3 @@ function simple_sitemap_install() {
$base_url = $GLOBALS['base_url'];
drupal_set_message(t("You can now include content into the <a href='@sitemap_url' target='_blank'>XML sitemap</a> by visiting the corresponding entity type edit pages (e.g. <a href='@content_type_url' target='_blank'>content type</a>, <a href='@taxonomy_vocabulary_url' target='_blank'>taxonomy vocabulary</a>, <a href='@menu_url' target='_blank'>menu</a> and <a href='@user_url' target='_blank'>user</a> pages.)<br/>Custom links can be added on <a href='@config_url' target='_blank'>this configuration page</a>.", array('@sitemap_url' => "$base_url/sitemap.xml", '@content_type_url' => "$base_url/admin/structure/types", '@taxonomy_vocabulary_url' => "$base_url/admin/structure/taxonomy", '@menu_url' => "$base_url/admin/structure/menu", '@user_url' => "$base_url/admin/config/people/accounts", '@config_url' => "$base_url/admin/config/search/simplesitemap/custom")));
}
......@@ -47,20 +47,21 @@ class Batch {
* Starts the batch process depending on where it was requested from.
*/
public function start() {
batch_set($this->batch);
switch ($this->batch_info['from']) {
case 'form':
batch_set($this->batch);
break;
case 'drush':
$this->batch['progressive'] = FALSE;
batch_set($this->batch);
drush_log($this->batch['init_message'], 'status');
drush_backend_batch_process();
break;
break;
case 'cron':
print $this->batch['init_message'] . "\r\n";
// drush_log($this->batch['init_message']);
$this->batch =& batch_get();
$this->batch['progressive'] = FALSE;
if (function_exists('drush_backend_batch_process'))
drush_backend_batch_process();
else
batch_process();
batch_set($this->batch);
batch_process(); //todo: Does not take advantage of batch API and eventually runs out of memory on very large sites.
break;
}
}
......
......@@ -179,18 +179,6 @@ class Simplesitemap {
$generator->start_batch();
}
/**
* Saves the sitemap to the db.
*/
public static function save_sitemap($values) {
db_insert('simple_sitemap')
->fields(array(
'id' => $values['id'],
'sitemap_string' => $values['sitemap_string'],
'sitemap_created' => $values['sitemap_created'],
))->execute();
}
/**
* Generates and returns the sitemap index as string.
*
......
......@@ -111,11 +111,12 @@ class SitemapGenerator {
* All links with their multilingual versions and settings.
*/
public static function generate_sitemap($links) {
Simplesitemap::save_sitemap(array(
'id' => db_query('SELECT MAX(id) FROM {simple_sitemap}')->fetchField() + 1,
'sitemap_string' => self::generate_sitemap_chunk($links),
'sitemap_created' => REQUEST_TIME)
$values = array(
'id' => db_query('SELECT MAX(id) FROM {simple_sitemap}')->fetchField() + 1,
'sitemap_string' => self::generate_sitemap_chunk($links),
'sitemap_created' => REQUEST_TIME,
);
db_insert('simple_sitemap')->fields($values)->execute();
}
/**
......
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