Commit 24c16c9b authored by gbyte.co's avatar gbyte.co

V2 initial commit.

parent 4aac9619
...@@ -8,3 +8,5 @@ entity_types: [] ...@@ -8,3 +8,5 @@ entity_types: []
settings: settings:
max_links: 2000 max_links: 2000
cron_generate: true cron_generate: true
remove_duplicates: true
batch_process_limit: 1500
/** /**
* @file * @file
* Attaches simplesitemap behaviors to the entity form. * Attaches simple_sitemap behaviors to the entity form.
*/ */
(function($) { (function($) {
"use strict"; "use strict";
Drupal.behaviors.simplesitemapFieldsetSummaries = { Drupal.behaviors.simple_sitemapFieldsetSummaries = {
attach: function(context) { attach: function(context) {
$(context).find('#edit-simplesitemap').drupalSetSummary(function (context) { $(context).find('#edit-simple-sitemap').drupalSetSummary(function (context) {
var vals = []; var vals = [];
if ($(context).find('#edit-simplesitemap-index-content').is(':checked')) { if ($(context).find('#edit-simple-sitemap-index-content').is(':checked')) {
// Display summary of the settings in tabs. // Display summary of the settings in tabs.
vals.push(Drupal.t('Included in sitemap')); vals.push(Drupal.t('Included in sitemap'));
vals.push(Drupal.t('Priority') + ' ' + $('#edit-simplesitemap-priority option:selected', context).text()); vals.push(Drupal.t('Priority') + ' ' + $('#edit-simple-sitemap-priority option:selected', context).text());
} }
else { else {
// Display summary of the settings in tabs. // Display summary of the settings in tabs.
......
/** /**
* @file * @file
* Attaches simplesitemap behaviors to the entity form. * Attaches simple_sitemap behaviors to the entity form.
* *
* @todo: Tidy up. * @todo: Tidy up.
*/ */
...@@ -9,33 +9,33 @@ ...@@ -9,33 +9,33 @@
"use strict"; "use strict";
// Hide the 'Regenerate sitemap' field to only display it if settings have changed. // Hide the 'Regenerate sitemap' field to only display it if settings have changed.
$('.form-item-simplesitemap-regenerate-now').hide(); $('.form-item-simple-sitemap-regenerate-now').hide();
Drupal.behaviors.simplesitemapForm = { Drupal.behaviors.simple_sitemapForm = {
attach: function(context) { attach: function(context) {
if ($(context).find('#edit-simplesitemap-index-content').is(':checked')) { if ($(context).find('#edit-simple-sitemap-index-content').is(':checked')) {
// Show 'Priority' field if 'Index sitemap' is ticked. // Show 'Priority' field if 'Index sitemap' is ticked.
$('.form-item-simplesitemap-priority').show(); $('.form-item-simple-sitemap-priority').show();
} }
else { // Hide 'Priority' field if 'Index sitemap' is unticked. else { // Hide 'Priority' field if 'Index sitemap' is unticked.
$('.form-item-simplesitemap-priority').hide(); $('.form-item-simple-sitemap-priority').hide();
} }
// Show 'Regenerate sitemap' field if setting has changed. // Show 'Regenerate sitemap' field if setting has changed.
$( "#edit-simplesitemap-index-content" ).change(function() { $( "#edit-simple-sitemap-index-content" ).change(function() {
$('.form-item-simplesitemap-regenerate-now').show(); $('.form-item-simple-sitemap-regenerate-now').show();
if ($(context).find('#edit-simplesitemap-index-content').is(':checked')) { if ($(context).find('#edit-simple-sitemap-index-content').is(':checked')) {
// Show 'Priority' field if 'Index sitemap' is ticked. // Show 'Priority' field if 'Index sitemap' is ticked.
$('.form-item-simplesitemap-priority').show(); $('.form-item-simple-sitemap-priority').show();
} }
else { // Hide 'Priority' field if 'Index sitemap' is unticked. else { // Hide 'Priority' field if 'Index sitemap' is unticked.
$('.form-item-simplesitemap-priority').hide(); $('.form-item-simple-sitemap-priority').hide();
} }
}); });
// Show 'Regenerate sitemap' field if setting has changed. // Show 'Regenerate sitemap' field if setting has changed.
$( "#edit-simplesitemap-priority" ).change(function() { $( "#edit-simple-sitemap-priority" ).change(function() {
$('.form-item-simplesitemap-regenerate-now').show(); $('.form-item-simple-sitemap-regenerate-now').show();
}); });
} }
}; };
......
...@@ -4,16 +4,16 @@ ...@@ -4,16 +4,16 @@
* Drush integration. * Drush integration.
*/ */
use Drupal\simplesitemap\Simplesitemap; use Drupal\simple_sitemap\Simplesitemap;
/** /**
* Implements hook_drush_command(). * Implements hook_drush_command().
*/ */
function simplesitemap_drush_command() { function simple_sitemap_drush_command() {
$items['simplesitemap-generate'] = array( $items['simple_sitemap-generate'] = array(
'description' => 'Regenerate XML sitemaps for all languages according to the module settings.', 'description' => 'Regenerate XML sitemaps for all languages according to the module settings.',
'callback' => 'drush_simplesitemap_generate', 'callback' => 'drush_simple_sitemap_generate',
'drupal dependencies' => array('simplesitemap'), 'drupal dependencies' => array('simple_sitemap'),
); );
return $items; return $items;
} }
...@@ -23,7 +23,7 @@ function simplesitemap_drush_command() { ...@@ -23,7 +23,7 @@ function simplesitemap_drush_command() {
* *
* Regenerate sitemap for all languages. * Regenerate sitemap for all languages.
*/ */
function drush_simplesitemap_generate() { function drush_simple_sitemap_generate() {
$sitemap = new Simplesitemap; $sitemap = new Simplesitemap;
$sitemap->generate_sitemap(); $sitemap->generate_sitemap('drush');
} }
name: Simple XML Sitemap name: Simple XML Sitemap
type: module type: module
description: 'This module creates a standard conform xml sitemap of your content.' description: 'This module creates a standard conform xml sitemap of your content.'
configure: simplesitemap.settings configure: simple_sitemap.settings
package: SEO package: SEO
core: 8.x core: 8.x
...@@ -4,14 +4,16 @@ ...@@ -4,14 +4,16 @@
* Module install and update procedures. * Module install and update procedures.
*/ */
use Drupal\simple_sitemap\Simplesitemap;
/** /**
* Implements hook_requirements(). * Implements hook_requirements().
*/ */
function simplesitemap_requirements($phase) { function simple_sitemap_requirements($phase) {
$requirements = array(); $requirements = array();
if (!extension_loaded('xmlwriter')) { if (!extension_loaded('xmlwriter')) {
$requirements['simplesitemap_php_extensions'] = array( $requirements['simple_sitemap_php_extensions'] = array(
'title' => t('Simple XML sitemap PHP extensions'), 'title' => t('Simple XML sitemap PHP extensions'),
'value' => t('Missing PHP xmlwriter extension'), 'value' => t('Missing PHP xmlwriter extension'),
'description' => t("In order to be able to generate sitemaps, the Simple XML sitemap module requires the <em>xmlwriter</em> PHP extension to be enabled."), 'description' => t("In order to be able to generate sitemaps, the Simple XML sitemap module requires the <em>xmlwriter</em> PHP extension to be enabled."),
...@@ -21,19 +23,19 @@ function simplesitemap_requirements($phase) { ...@@ -21,19 +23,19 @@ function simplesitemap_requirements($phase) {
switch($phase) { switch($phase) {
case 'runtime': case 'runtime':
$sitemap = new \Drupal\simplesitemap\Simplesitemap(); $sitemap = new \Drupal\simple_sitemap\Simplesitemap();
$generated_ago = $sitemap->get_generated_ago(); $generated_ago = $sitemap->get_generated_ago();
if (!$generated_ago) { if (!$generated_ago) {
$value = t('Not available'); $value = t('Not available');
$description = t("The sitemap has not been generated yet. Run cron, or <a href='@generate'>generate</a> the sitemap manually.", array('@generate' => $GLOBALS['base_url'] . '/admin/config/search/simplesitemap')); $description = t("The sitemap has not been generated yet. Run cron, or <a href='@generate'>generate</a> the sitemap manually.", array('@generate' => $GLOBALS['base_url'] . '/admin/config/search/simple_sitemap'));
$severity = REQUIREMENT_WARNING; $severity = REQUIREMENT_WARNING;
} }
else { else {
$value = t('XML sitemap is available'); $value = t('XML sitemap is available');
$description = t("The <a href='@sitemap'>XML sitemap</a> was generated @ago ago. <a href='@generate'>Regenerate</a>.", array('@ago' => $generated_ago, '@sitemap' => $GLOBALS['base_url'] . '/sitemap.xml', '@generate' => $GLOBALS['base_url'] . '/admin/config/search/simplesitemap')); $description = t("The <a href='@sitemap'>XML sitemap</a> was generated @ago ago. <a href='@generate'>Regenerate</a>.", array('@ago' => $generated_ago, '@sitemap' => $GLOBALS['base_url'] . '/sitemap.xml', '@generate' => $GLOBALS['base_url'] . '/admin/config/search/simple_sitemap'));
$severity = REQUIREMENT_INFO; $severity = REQUIREMENT_INFO;
} }
$requirements['simplesitemap_generated'] = array( $requirements['simple_sitemap_generated'] = array(
'title' => 'Simple XML sitemap', 'title' => 'Simple XML sitemap',
'value' => $value, 'value' => $value,
'description' => $description, 'description' => $description,
...@@ -47,8 +49,8 @@ function simplesitemap_requirements($phase) { ...@@ -47,8 +49,8 @@ function simplesitemap_requirements($phase) {
/** /**
* Implements hook_schema(). * Implements hook_schema().
*/ */
function simplesitemap_schema() { function simple_sitemap_schema() {
$schema['simplesitemap'] = array( $schema['simple_sitemap'] = array(
'description' => 'Holds XML sitemaps as strings for quick retrieval.', 'description' => 'Holds XML sitemaps as strings for quick retrieval.',
'fields' => array( 'fields' => array(
'id' => array( 'id' => array(
...@@ -78,93 +80,10 @@ function simplesitemap_schema() { ...@@ -78,93 +80,10 @@ function simplesitemap_schema() {
/** /**
* Implements hook_install(). * Implements hook_install().
*/ */
function simplesitemap_install() { function simple_sitemap_install() {
$sitemap = new Simplesitemap;
$sitemap->generate_sitemap('drush');
$base_url = $GLOBALS['base_url']; $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"))); 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/simple_sitemap/custom")));
}
/**
* Update: Altering the {simplesitemap} language_code table field to hold longer strings.
*/
function simplesitemap_update_8101() {
db_change_field('simplesitemap', 'language_code', 'language_code', array(
'type' => 'varchar',
'not null' => TRUE,
'length' => 12,));
}
/**
* Changing config settings according to new config structure.
*/
function simplesitemap_update_8102() {
$entity_types = \Drupal::config('simplesitemap.settings')->get('entity_types');
$entity_types = is_array($entity_types) ? $entity_types : array();
if (isset($entity_types['node'])) {
$entity_types['node_type'] = $entity_types['node'];
unset($entity_types['node']);
}
if (isset($entity_types['taxonomy_term'])) {
$entity_types['taxonomy_vocabulary'] = $entity_types['taxonomy_term'];
unset($entity_types['taxonomy_term']);
}
\Drupal::service('config.factory')->getEditable('simplesitemap.settings')
->set('entity_types', $entity_types)->save();
}
/**
* Modifying database structure to hold one multilingual sitemap.
*/
function simplesitemap_update_8103() {
db_truncate('simplesitemap')->execute();
db_drop_primary_key('simplesitemap');
db_change_field('simplesitemap', 'language_code', 'id', array(
'type' => 'serial',
'not null' => TRUE
), array('primary key' => array('id')));
return t('Before the sitemap can be accessed, it must be regenerated manually or via cron run.');
}
/**
* Modifying database structure to accommodate sitemap chunks.
*/
function simplesitemap_update_8104() {
db_truncate('simplesitemap')->execute();
db_change_field('simplesitemap', 'id', 'id', array(
'type' => 'int',
'size' => 'small',
'not null' => TRUE,
));
\Drupal::service('config.factory')->getEditable('simplesitemap.settings')
->set('settings', array('max_links' => 2000))->save();
return t('Before the sitemap can be accessed, it must be regenerated manually or via cron run.');
}
/**
* Modifying database structure to accommodate sitemap chunk timestamps.
*/
function simplesitemap_update_8105() {
db_add_field('simplesitemap', 'generated', array(
'description' => 'Timestamp of sitemap chunk generation.',
'type' => 'int',
'default' => 0,
'not null' => TRUE,
));
}
/**
* Changing column name to 'sitemap_created', as 'generated' is a reserved word since MySQL 5.7.6.
*/
function simplesitemap_update_8106() {
// Omitting the high level DB API to be able to escape the column name.
Drupal\Core\Database\Database::getConnection()
->query("alter table {simplesitemap} CHANGE `generated` sitemap_created int(11) NOT NULL");
}
/**
* Setting the new cron generation setting to TRUE by default.
*/
function simplesitemap_update_8107() {
\Drupal::service('config.factory')->getEditable('simplesitemap.settings')
->set('settings', array('cron_generate' => TRUE))->save();
} }
fieldsetSummaries: fieldsetSummaries:
version: VERSION version: VERSION
js: js:
js/simplesitemap.fieldsetSummaries.js: {} js/simple_sitemap.fieldsetSummaries.js: {}
dependencies: dependencies:
- core/jquery - core/jquery
form: form:
version: VERSION version: VERSION
js: js:
js/simplesitemap.form.js: {} js/simple_sitemap.form.js: {}
dependencies: dependencies:
- core/jquery - core/jquery
simplesitemap.settings: simple_sitemap.settings:
title: 'Simple XML sitemap' title: 'Simple XML sitemap'
description: 'Configure and generate the XML sitemap, add custom links to it.' description: 'Configure and generate the XML sitemap, add custom links to it.'
parent: system.admin_config_search parent: system.admin_config_search
route_name: simplesitemap.settings route_name: simple_sitemap.settings
simple_sitemap.settings:
route_name: simple_sitemap.settings
title: 'Settings'
base_route: simple_sitemap.settings
weight: -1
simple_sitemap.settings_custom:
route_name: simple_sitemap.settings_custom
title: 'Custom links'
base_route: simple_sitemap.settings
...@@ -4,15 +4,15 @@ ...@@ -4,15 +4,15 @@
* Main module file containing hooks. * Main module file containing hooks.
*/ */
use Drupal\simplesitemap\Simplesitemap; use Drupal\simple_sitemap\Simplesitemap;
use Drupal\simplesitemap\SitemapGenerator; use Drupal\simple_sitemap\SitemapGenerator;
/** /**
* Implements hook_form_alter. * Implements hook_form_alter.
* *
* Adds sitemap settings to entity types that are supported via plugins. * Adds sitemap settings to entity types that are supported via plugins.
*/ */
function simplesitemap_form_alter(&$form, $form_state, $form_id) { function simple_sitemap_form_alter(&$form, $form_state, $form_id) {
$sitemap_form_entity_data = Simplesitemap::get_sitemap_form_entity_data($form_state, $form_id); $sitemap_form_entity_data = Simplesitemap::get_sitemap_form_entity_data($form_state, $form_id);
if (empty($sitemap_form_entity_data)) if (empty($sitemap_form_entity_data))
return; return;
...@@ -24,9 +24,7 @@ function simplesitemap_form_alter(&$form, $form_state, $form_id) { ...@@ -24,9 +24,7 @@ function simplesitemap_form_alter(&$form, $form_state, $form_id) {
// Get current entity type sitemap settings. // Get current entity type sitemap settings.
$entity_types = $sitemap->get_config('entity_types'); $entity_types = $sitemap->get_config('entity_types');
$form['simple_sitemap'] = array(
$form['simplesitemap'] = array(
'#type' => 'details', '#type' => 'details',
'#group' => 'additional_settings', '#group' => 'additional_settings',
'#title' => t('Simple XML sitemap'), '#title' => t('Simple XML sitemap'),
...@@ -34,20 +32,20 @@ function simplesitemap_form_alter(&$form, $form_state, $form_id) { ...@@ -34,20 +32,20 @@ function simplesitemap_form_alter(&$form, $form_state, $form_id) {
// Attach some js magic to forms. // Attach some js magic to forms.
// Only attach fieldset summary js to 'additional settings' vertical tabs. // Only attach fieldset summary js to 'additional settings' vertical tabs.
$form['simplesitemap']['#attached']['library'][] = 'simplesitemap/form'; $form['simple_sitemap']['#attached']['library'][] = 'simple_sitemap/form';
if (isset($form['additional_settings'])) { if (isset($form['additional_settings'])) {
$form['simplesitemap']['#attached']['library'][] = 'simplesitemap/fieldsetSummaries'; $form['simple_sitemap']['#attached']['library'][] = 'simple_sitemap/fieldsetSummaries';
} }
$index_content_checked = isset($entity_types[$entity_type_id][$bundle_name]['index']) ? $entity_types[$entity_type_id][$bundle_name]['index'] : FALSE; $index_content_checked = isset($entity_types[$entity_type_id][$bundle_name]['index']) ? $entity_types[$entity_type_id][$bundle_name]['index'] : FALSE;
$form['simplesitemap']['simplesitemap_index_content'] = array( $form['simple_sitemap']['simple_sitemap_index_content'] = array(
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => t('Index content of this type'), '#title' => t('Index content of this type'),
'#default_value' => $index_content_checked, '#default_value' => $index_content_checked,
); );
$priority = isset($entity_types[$entity_type_id][$bundle_name]['priority']) ? $entity_types[$entity_type_id][$bundle_name]['priority'] : SitemapGenerator::PRIORITY_DEFAULT; $priority = isset($entity_types[$entity_type_id][$bundle_name]['priority']) ? $entity_types[$entity_type_id][$bundle_name]['priority'] : SitemapGenerator::PRIORITY_DEFAULT;
$form['simplesitemap']['simplesitemap_priority'] = array( $form['simple_sitemap']['simple_sitemap_priority'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => t('Priority'), '#title' => t('Priority'),
'#description' => t('The priority entities of this bundle will have in the eyes of search engine bots.'), '#description' => t('The priority entities of this bundle will have in the eyes of search engine bots.'),
...@@ -55,52 +53,52 @@ function simplesitemap_form_alter(&$form, $form_state, $form_id) { ...@@ -55,52 +53,52 @@ function simplesitemap_form_alter(&$form, $form_state, $form_id) {
'#default_value' => $priority, '#default_value' => $priority,
); );
$form['simplesitemap']['simplesitemap_regenerate_now'] = array( $form['simple_sitemap']['simple_sitemap_regenerate_now'] = array(
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => t('Regenerate sitemap after hitting Save'), '#title' => t('Regenerate sitemap after hitting Save'),
'#description' => t('This setting will regenerate the whole sitemap including the above changes.<br/>Otherwise the sitemap will be rebuilt on next cron run.'), '#description' => t('This setting will regenerate the whole sitemap including the above changes.<br/>Otherwise the sitemap will be rebuilt on next cron run.'),
'#default_value' => FALSE, '#default_value' => FALSE,
); );
$form['#simplesitemap']['entity_type_id'] = $entity_type_id; $form['#simple_sitemap']['entity_type_id'] = $entity_type_id;
$form['#simplesitemap']['bundle_name'] = $bundle_name; $form['#simple_sitemap']['bundle_name'] = $bundle_name;
// Add submission handler. // Add submission handler.
if (isset($form['actions']['submit']['#submit'])) { if (isset($form['actions']['submit']['#submit'])) {
$form['actions']['submit']['#submit'][] = 'simplesitemap_entity_form_submit'; $form['actions']['submit']['#submit'][] = 'simple_sitemap_entity_form_submit';
} }
else { // Fix for account page which rendered other submit handlers not usable. else { // Fix for account page which rendered other submit handlers not usable.
$form['#submit'][] = 'simplesitemap_entity_form_submit'; $form['#submit'][] = 'simple_sitemap_entity_form_submit';
} }
} }
/** /**
* Form submission handler called in hook_form_alter. * Form submission handler called in hook_form_alter.
*/ */
function simplesitemap_entity_form_submit($form, &$form_state) { function simple_sitemap_entity_form_submit($form, &$form_state) {
$sitemap = new Simplesitemap; $sitemap = new Simplesitemap;
$values = $form_state->getValues(); $values = $form_state->getValues();
// Only make changes in DB if sitemap settings actually changed. // Only make changes in DB if sitemap settings actually changed.
if ($values['simplesitemap_index_content'] != $form['simplesitemap']['simplesitemap_index_content']['#default_value'] if ($values['simple_sitemap_index_content'] != $form['simple_sitemap']['simple_sitemap_index_content']['#default_value']
|| $values['simplesitemap_priority'] != $form['simplesitemap']['simplesitemap_priority']['#default_value']) { || $values['simple_sitemap_priority'] != $form['simple_sitemap']['simple_sitemap_priority']['#default_value']) {
$entity_type_id = $form['#simplesitemap']['entity_type_id']; $entity_type_id = $form['#simple_sitemap']['entity_type_id'];
$bundle_name = $form['#simplesitemap']['bundle_name']; $bundle_name = $form['#simple_sitemap']['bundle_name'];
// Get current entity type sitemap settings. // Get current entity type sitemap settings.
$entity_types = $sitemap->get_config('entity_types'); $entity_types = $sitemap->get_config('entity_types');
$entity_types[$entity_type_id][$bundle_name]['index'] = $values['simplesitemap_index_content']; $entity_types[$entity_type_id][$bundle_name]['index'] = $values['simple_sitemap_index_content'];
$entity_types[$entity_type_id][$bundle_name]['priority'] = $values['simplesitemap_priority']; $entity_types[$entity_type_id][$bundle_name]['priority'] = $values['simple_sitemap_priority'];
// Save new entity type settings. // Save new entity type settings.
$sitemap->save_config('entity_types', $entity_types); $sitemap->save_config('entity_types', $entity_types);
} }
// Regenerate sitemaps according to user setting. // Regenerate sitemaps according to user setting.
if ($values['simplesitemap_regenerate_now']) { if ($values['simple_sitemap_regenerate_now']) {
$sitemap->generate_sitemap(); $sitemap->generate_sitemap();
} }
} }
...@@ -108,11 +106,11 @@ function simplesitemap_entity_form_submit($form, &$form_state) { ...@@ -108,11 +106,11 @@ function simplesitemap_entity_form_submit($form, &$form_state) {
/** /**
* Implements hook_cron. * Implements hook_cron.
*/ */
function simplesitemap_cron() { function simple_sitemap_cron() {
$sitemap = new Simplesitemap; $sitemap = new Simplesitemap;
if ($sitemap->get_setting('cron_generate')) { if ($sitemap->get_setting('cron_generate')) {
// Regenerate sitemap for all languages. // Regenerate sitemap for all languages.
$sitemap->generate_sitemap(); $sitemap->generate_sitemap('cron');
} }
} }
...@@ -121,7 +119,7 @@ function simplesitemap_cron() { ...@@ -121,7 +119,7 @@ function simplesitemap_cron() {
* *
* Removes settings of the removed bundle. * Removes settings of the removed bundle.
*/ */
function simplesitemap_entity_bundle_delete($entity_type_id, $bundle) { function simple_sitemap_entity_bundle_delete($entity_type_id, $bundle) {
$sitemap = new Simplesitemap; $sitemap = new Simplesitemap;
$entity_types = $sitemap->get_config('entity_types'); $entity_types = $sitemap->get_config('entity_types');
$bundle_entity_type_id = \Drupal::entityManager()->getDefinition($entity_type_id)->getBundleEntityType(); $bundle_entity_type_id = \Drupal::entityManager()->getDefinition($entity_type_id)->getBundleEntityType();
...@@ -131,6 +129,6 @@ function simplesitemap_entity_bundle_delete($entity_type_id, $bundle) { ...@@ -131,6 +129,6 @@ function simplesitemap_entity_bundle_delete($entity_type_id, $bundle) {
$sitemap->save_config('entity_types', $entity_types); $sitemap->save_config('entity_types', $entity_types);
drupal_set_message(t("You may want to <a href='@url'>regenerate</a> your XML sitemap now. drupal_set_message(t("You may want to <a href='@url'>regenerate</a> your XML sitemap now.
Otherwise it will be rebuilt on the next cron run.", Otherwise it will be rebuilt on the next cron run.",
array('@url' => $GLOBALS['base_url'] . '/admin/config/search/simplesitemap'))); array('@url' => $GLOBALS['base_url'] . '/admin/config/search/simple_sitemap')));
} }
} }
simplesitemap.sitemap: simple_sitemap.sitemap:
path: '/sitemap.xml' path: '/sitemap.xml'
defaults: defaults:
_controller: '\Drupal\simplesitemap\Controller\SimplesitemapController::get_sitemap' _controller: '\Drupal\simple_sitemap\Controller\SimplesitemapController::get_sitemap'
requirements: requirements:
_access: 'TRUE' _access: 'TRUE'
simplesitemap.chunk: simple_sitemap.chunk:
path: '/sitemaps/{sitemap_id}/sitemap.xml' path: '/sitemaps/{sitemap_id}/sitemap.xml'
defaults: defaults:
_controller: '\Drupal\simplesitemap\Controller\SimplesitemapController::get_sitemap' _controller: '\Drupal\simple_sitemap\Controller\SimplesitemapController::get_sitemap'
requirements: requirements:
_access: 'TRUE' _access: 'TRUE'
simplesitemap.settings: simple_sitemap.settings:
path: '/admin/config/search/simplesitemap' path: '/admin/config/search/simple_sitemap'
defaults: defaults:
_form: '\Drupal\simplesitemap\Form\SimplesitemapSettingsForm' _form: '\Drupal\simple_sitemap\Form\SimplesitemapSettingsForm'
_title: 'Simple XML Sitemap Settings' _title: 'Simple XML Sitemap Settings'
requirements: requirements:
_permission: 'administer sitemap settings' _permission: 'administer sitemap settings'
simplesitemap.settings_custom: simple_sitemap.settings_custom:
path: '/admin/config/search/simplesitemap/custom' path: '/admin/config/search/simple_sitemap/custom'
defaults: defaults:
_form: '\Drupal\simplesitemap\Form\SimplesitemapCustomLinksForm' _form: '\Drupal\simple_sitemap\Form\SimplesitemapCustomLinksForm'
_title: 'Simple XML Sitemap Settings' _title: 'Simple XML Sitemap Settings'
requirements: requirements:
_permission: 'administer sitemap settings' _permission: 'administer sitemap settings'
services: services:
plugin.manager.simplesitemap: plugin.manager.simple_sitemap:
class: Drupal\simplesitemap\SimplesitemapManager class: Drupal\simple_sitemap\SimplesitemapManager
parent: default_plugin_manager parent: default_plugin_manager
simplesitemap.settings:
route_name: simplesitemap.settings
title: 'Settings'
base_route: simplesitemap.settings
weight: -1
simplesitemap.settings_custom:
route_name: simplesitemap.settings_custom
title: 'Custom links'
base_route: simplesitemap.settings
<?php <?php
/** /**
* @file * @file
* Contains \Drupal\simplesitemap\Annotation\LinkGenerator. * Contains \Drupal\simple_sitemap\Annotation\LinkGenerator.
*/ */
namespace Drupal\simplesitemap\Annotation; namespace Drupal\simple_sitemap\Annotation;
use Drupal\Component\Annotation\Plugin; use Drupal\Component\Annotation\Plugin;
/** /**
* Defines a LinkGenerator item annotation object. * Defines a LinkGenerator item annotation object.
* *
* @see \Drupal\simplesitemap\Plugin\SimplesitemapManager * @see \Drupal\simple_sitemap\Plugin\SimplesitemapManager
* @see plugin_api * @see plugin_api
* *
* @Annotation * @Annotation
......
src/Batch.php 0 → 100644