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

V2 initial commit.

parent 4aac9619
......@@ -8,3 +8,5 @@ entity_types: []
settings:
max_links: 2000
cron_generate: true
remove_duplicates: true
batch_process_limit: 1500
/**
* @file
* Attaches simplesitemap behaviors to the entity form.
* Attaches simple_sitemap behaviors to the entity form.
*/
(function($) {
"use strict";
Drupal.behaviors.simplesitemapFieldsetSummaries = {
Drupal.behaviors.simple_sitemapFieldsetSummaries = {
attach: function(context) {
$(context).find('#edit-simplesitemap').drupalSetSummary(function (context) {
$(context).find('#edit-simple-sitemap').drupalSetSummary(function (context) {
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.
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 {
// Display summary of the settings in tabs.
......
/**
* @file
* Attaches simplesitemap behaviors to the entity form.
* Attaches simple_sitemap behaviors to the entity form.
*
* @todo: Tidy up.
*/
......@@ -9,33 +9,33 @@
"use strict";
// 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) {
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.
$('.form-item-simplesitemap-priority').show();
$('.form-item-simple-sitemap-priority').show();
}
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.
$( "#edit-simplesitemap-index-content" ).change(function() {
$('.form-item-simplesitemap-regenerate-now').show();
if ($(context).find('#edit-simplesitemap-index-content').is(':checked')) {
$( "#edit-simple-sitemap-index-content" ).change(function() {
$('.form-item-simple-sitemap-regenerate-now').show();
if ($(context).find('#edit-simple-sitemap-index-content').is(':checked')) {
// 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.
$('.form-item-simplesitemap-priority').hide();
$('.form-item-simple-sitemap-priority').hide();
}
});
// Show 'Regenerate sitemap' field if setting has changed.
$( "#edit-simplesitemap-priority" ).change(function() {
$('.form-item-simplesitemap-regenerate-now').show();
$( "#edit-simple-sitemap-priority" ).change(function() {
$('.form-item-simple-sitemap-regenerate-now').show();
});
}
};
......
......@@ -4,16 +4,16 @@
* Drush integration.
*/
use Drupal\simplesitemap\Simplesitemap;
use Drupal\simple_sitemap\Simplesitemap;
/**
* Implements hook_drush_command().
*/
function simplesitemap_drush_command() {
$items['simplesitemap-generate'] = array(
function simple_sitemap_drush_command() {
$items['simple_sitemap-generate'] = array(
'description' => 'Regenerate XML sitemaps for all languages according to the module settings.',
'callback' => 'drush_simplesitemap_generate',
'drupal dependencies' => array('simplesitemap'),
'callback' => 'drush_simple_sitemap_generate',
'drupal dependencies' => array('simple_sitemap'),
);
return $items;
}
......@@ -23,7 +23,7 @@ function simplesitemap_drush_command() {
*
* Regenerate sitemap for all languages.
*/
function drush_simplesitemap_generate() {
function drush_simple_sitemap_generate() {
$sitemap = new Simplesitemap;
$sitemap->generate_sitemap();
$sitemap->generate_sitemap('drush');
}
name: Simple XML Sitemap
type: module
description: 'This module creates a standard conform xml sitemap of your content.'
configure: simplesitemap.settings
configure: simple_sitemap.settings
package: SEO
core: 8.x
......@@ -4,14 +4,16 @@
* Module install and update procedures.
*/
use Drupal\simple_sitemap\Simplesitemap;
/**
* Implements hook_requirements().
*/
function simplesitemap_requirements($phase) {
function simple_sitemap_requirements($phase) {
$requirements = array();
if (!extension_loaded('xmlwriter')) {
$requirements['simplesitemap_php_extensions'] = array(
$requirements['simple_sitemap_php_extensions'] = array(
'title' => t('Simple XML sitemap PHP extensions'),
'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."),
......@@ -21,19 +23,19 @@ function simplesitemap_requirements($phase) {
switch($phase) {
case 'runtime':
$sitemap = new \Drupal\simplesitemap\Simplesitemap();
$sitemap = new \Drupal\simple_sitemap\Simplesitemap();
$generated_ago = $sitemap->get_generated_ago();
if (!$generated_ago) {
$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;
}
else {
$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;
}
$requirements['simplesitemap_generated'] = array(
$requirements['simple_sitemap_generated'] = array(
'title' => 'Simple XML sitemap',
'value' => $value,
'description' => $description,
......@@ -47,8 +49,8 @@ function simplesitemap_requirements($phase) {
/**
* Implements hook_schema().
*/
function simplesitemap_schema() {
$schema['simplesitemap'] = array(
function simple_sitemap_schema() {
$schema['simple_sitemap'] = array(
'description' => 'Holds XML sitemaps as strings for quick retrieval.',
'fields' => array(
'id' => array(
......@@ -78,93 +80,10 @@ function simplesitemap_schema() {
/**
* Implements hook_install().
*/
function simplesitemap_install() {
function simple_sitemap_install() {
$sitemap = new Simplesitemap;
$sitemap->generate_sitemap('drush');
$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")));
}
/**
* 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();
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")));
}
fieldsetSummaries:
version: VERSION
js:
js/simplesitemap.fieldsetSummaries.js: {}
js/simple_sitemap.fieldsetSummaries.js: {}
dependencies:
- core/jquery
form:
version: VERSION
js:
js/simplesitemap.form.js: {}
js/simple_sitemap.form.js: {}
dependencies:
- core/jquery
simplesitemap.settings:
simple_sitemap.settings:
title: 'Simple XML sitemap'
description: 'Configure and generate the XML sitemap, add custom links to it.'
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 @@
* Main module file containing hooks.
*/
use Drupal\simplesitemap\Simplesitemap;
use Drupal\simplesitemap\SitemapGenerator;
use Drupal\simple_sitemap\Simplesitemap;
use Drupal\simple_sitemap\SitemapGenerator;
/**
* Implements hook_form_alter.
*
* 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);
if (empty($sitemap_form_entity_data))
return;
......@@ -24,9 +24,7 @@ function simplesitemap_form_alter(&$form, $form_state, $form_id) {
// Get current entity type sitemap settings.
$entity_types = $sitemap->get_config('entity_types');
$form['simplesitemap'] = array(
$form['simple_sitemap'] = array(
'#type' => 'details',
'#group' => 'additional_settings',
'#title' => t('Simple XML sitemap'),
......@@ -34,20 +32,20 @@ function simplesitemap_form_alter(&$form, $form_state, $form_id) {
// Attach some js magic to forms.
// 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'])) {
$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;
$form['simplesitemap']['simplesitemap_index_content'] = array(
$form['simple_sitemap']['simple_sitemap_index_content'] = array(
'#type' => 'checkbox',
'#title' => t('Index content of this type'),
'#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;
$form['simplesitemap']['simplesitemap_priority'] = array(
$form['simple_sitemap']['simple_sitemap_priority'] = array(
'#type' => 'select',
'#title' => t('Priority'),
'#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) {
'#default_value' => $priority,
);
$form['simplesitemap']['simplesitemap_regenerate_now'] = array(
$form['simple_sitemap']['simple_sitemap_regenerate_now'] = array(
'#type' => 'checkbox',
'#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.'),
'#default_value' => FALSE,
);
$form['#simplesitemap']['entity_type_id'] = $entity_type_id;
$form['#simplesitemap']['bundle_name'] = $bundle_name;
$form['#simple_sitemap']['entity_type_id'] = $entity_type_id;
$form['#simple_sitemap']['bundle_name'] = $bundle_name;
// Add submission handler.
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.
$form['#submit'][] = 'simplesitemap_entity_form_submit';
$form['#submit'][] = 'simple_sitemap_entity_form_submit';
}
}
/**
* 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;
$values = $form_state->getValues();
// Only make changes in DB if sitemap settings actually changed.
if ($values['simplesitemap_index_content'] != $form['simplesitemap']['simplesitemap_index_content']['#default_value']
|| $values['simplesitemap_priority'] != $form['simplesitemap']['simplesitemap_priority']['#default_value']) {
if ($values['simple_sitemap_index_content'] != $form['simple_sitemap']['simple_sitemap_index_content']['#default_value']
|| $values['simple_sitemap_priority'] != $form['simple_sitemap']['simple_sitemap_priority']['#default_value']) {
$entity_type_id = $form['#simplesitemap']['entity_type_id'];
$bundle_name = $form['#simplesitemap']['bundle_name'];
$entity_type_id = $form['#simple_sitemap']['entity_type_id'];
$bundle_name = $form['#simple_sitemap']['bundle_name'];
// Get current entity type sitemap settings.
$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]['priority'] = $values['simplesitemap_priority'];
$entity_types[$entity_type_id][$bundle_name]['index'] = $values['simple_sitemap_index_content'];
$entity_types[$entity_type_id][$bundle_name]['priority'] = $values['simple_sitemap_priority'];
// Save new entity type settings.
$sitemap->save_config('entity_types', $entity_types);
}
// Regenerate sitemaps according to user setting.
if ($values['simplesitemap_regenerate_now']) {
if ($values['simple_sitemap_regenerate_now']) {
$sitemap->generate_sitemap();
}
}
......@@ -108,11 +106,11 @@ function simplesitemap_entity_form_submit($form, &$form_state) {
/**
* Implements hook_cron.
*/
function simplesitemap_cron() {
function simple_sitemap_cron() {
$sitemap = new Simplesitemap;
if ($sitemap->get_setting('cron_generate')) {
// Regenerate sitemap for all languages.
$sitemap->generate_sitemap();
$sitemap->generate_sitemap('cron');
}
}
......@@ -121,7 +119,7 @@ function simplesitemap_cron() {
*
* 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;
$entity_types = $sitemap->get_config('entity_types');
$bundle_entity_type_id = \Drupal::entityManager()->getDefinition($entity_type_id)->getBundleEntityType();
......@@ -131,6 +129,6 @@ function simplesitemap_entity_bundle_delete($entity_type_id, $bundle) {
$sitemap->save_config('entity_types', $entity_types);
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.",
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'
defaults:
_controller: '\Drupal\simplesitemap\Controller\SimplesitemapController::get_sitemap'
_controller: '\Drupal\simple_sitemap\Controller\SimplesitemapController::get_sitemap'
requirements:
_access: 'TRUE'
simplesitemap.chunk:
simple_sitemap.chunk:
path: '/sitemaps/{sitemap_id}/sitemap.xml'
defaults:
_controller: '\Drupal\simplesitemap\Controller\SimplesitemapController::get_sitemap'
_controller: '\Drupal\simple_sitemap\Controller\SimplesitemapController::get_sitemap'
requirements:
_access: 'TRUE'
simplesitemap.settings:
path: '/admin/config/search/simplesitemap'
simple_sitemap.settings:
path: '/admin/config/search/simple_sitemap'
defaults:
_form: '\Drupal\simplesitemap\Form\SimplesitemapSettingsForm'
_form: '\Drupal\simple_sitemap\Form\SimplesitemapSettingsForm'
_title: 'Simple XML Sitemap Settings'
requirements:
_permission: 'administer sitemap settings'
simplesitemap.settings_custom:
path: '/admin/config/search/simplesitemap/custom'
simple_sitemap.settings_custom:
path: '/admin/config/search/simple_sitemap/custom'
defaults:
_form: '\Drupal\simplesitemap\Form\SimplesitemapCustomLinksForm'
_form: '\Drupal\simple_sitemap\Form\SimplesitemapCustomLinksForm'
_title: 'Simple XML Sitemap Settings'
requirements:
_permission: 'administer sitemap settings'
services:
plugin.manager.simplesitemap:
class: Drupal\simplesitemap\SimplesitemapManager
plugin.manager.simple_sitemap:
class: Drupal\simple_sitemap\SimplesitemapManager
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
/**
* @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;
/**
* Defines a LinkGenerator item annotation object.
*
* @see \Drupal\simplesitemap\Plugin\SimplesitemapManager
* @see \Drupal\simple_sitemap\Plugin\SimplesitemapManager
* @see plugin_api
*
* @Annotation
......
This diff is collapsed.
<?php
/**
* @file
* Contains \Drupal\simplesitemap\Controller\SimplesitemapController.
* Contains \Drupal\simple_sitemap\Controller\SimplesitemapController.
*/
namespace Drupal\simplesitemap\Controller;
namespace Drupal\simple_sitemap\Controller;
use Drupal\Core\Cache\CacheableResponse;
use Symfony\Component\HttpFoundation\Response;
use Drupal\simplesitemap\Simplesitemap;
use Drupal\simple_sitemap\Simplesitemap;
/**
* SimplesitemapController.
......
<?php
/**
* @file
* Contains \Drupal\simplesitemap\LinkGenerators\CustomLinkGenerator.
* Contains \Drupal\simple_sitemap\LinkGenerators\CustomLinkGenerator.
*
* Generates custom sitemap paths provided by the user.
*/
namespace Drupal\simplesitemap;
namespace Drupal\simple_sitemap;
/**
* CustomLinkGenerator class.
*/
class CustomLinkGenerator extends LinkGeneratorBase {
class CustomLinkGenerator {
/**
* Returns an array of all urls of the custom paths.
......@@ -21,15 +21,13 @@ class CustomLinkGenerator extends LinkGeneratorBase {
* @return array $urls
*
*/
public function get_paths($custom_paths) {
public function get_custom_paths($custom_paths) {
$paths = array();
foreach($custom_paths as $i => $custom_path) {
if (FALSE !== $path_data = $this->get_multilang_urls_from_user_input($custom_path['path'])) {
$paths[$i]['path_data'] = $path_data;
$paths[$i]['path'] = $custom_path['path'];
$paths[$i]['priority'] = isset($custom_path['priority']) ? $custom_path['priority'] : NULL;
$paths[$i]['lastmod'] = NULL; //todo: implement lastmod
}
}
return $paths;
}
}
......@@ -2,14 +2,14 @@
/**
* @file
* Contains \Drupal\simplesitemap\Form\SimplesitemapCustomLinksForm.
* Contains \Drupal\simple_sitemap\Form\SimplesitemapCustomLinksForm.
*/
namespace Drupal\simplesitemap\Form;
namespace Drupal\simple_sitemap\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\simplesitemap\Simplesitemap;
use Drupal\simple_sitemap\Simplesitemap;
/**
* SimplesitemapCustomLinksFrom
......@@ -20,14 +20,14 @@ class SimplesitemapCustomLinksForm extends ConfigFormBase {
* {@inheritdoc}
*/
public function getFormID() {
return 'simplesitemap_custom_links_form';
return 'simple_sitemap_custom_links_form';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return ['simplesitemap.settings_custom'];
return ['simple_sitemap.settings_custom'];
}
/**
......@@ -47,20 +47,20 @@ class SimplesitemapCustomLinksForm extends ConfigFormBase {
$setting_string .= "\r\n";
}
$form['simplesitemap_custom'] = array(
$form['simple_sitemap_custom'] = array(
'#title' => t('Custom links'),
'#type' => 'fieldset',
'#markup' => '<p>' . t('Add custom internal drupal paths and their priorities to the XML sitemap.') . '</p>',
);
$form['simplesitemap_custom']['custom_links'] = array(
$form['simple_sitemap_custom']['custom_links'] = array(
'#type' => 'textarea',
'#title' => t('Relative Drupal paths'),
'#default_value' => $setting_string,
'#description' => t("Please specify drupal internal (relative) paths, one per line. Do not forget to prepend the paths with a '/'. You can optionally add a priority (0.0 - 1.0) by appending it to the path after a space. The home page with the highest priority would be <em>/ 1</em>, the contact page with a medium priority would be <em>/contact 0.5</em>."),
);
$form['simplesitemap_custom']['simplesitemap_regenerate_now'] = array(
$form['simple_sitemap_custom']['simple_sitemap_regenerate_now'] = array(
'#type' => 'checkbox',
'#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.'),
......@@ -117,7 +117,7 @@ class SimplesitemapCustomLinksForm extends ConfigFormBase {
parent::submitForm($form, $form_state);
// Regenerate sitemaps according to user setting.
if ($form_state->getValue('simplesitemap_regenerate_now')) {
if ($form_state->getValue('simple_sitemap_regenerate_now')) {
$sitemap->generate_sitemap();
}
}
......
......@@ -2,14 +2,14 @@
/**
* @file
* Contains \Drupal\simplesitemap\Form\SimplesitemapSettingsForm.
* Contains \Drupal\simple_sitemap\Form\SimplesitemapSettingsForm.
*/
namespace Drupal\simplesitemap\Form;
namespace Drupal\simple_sitemap\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\simplesitemap\Simplesitemap;
use Drupal\simple_sitemap\Simplesitemap;
/**
* SimplesitemapSettingsFrom
......@@ -20,14 +20,14 @@ class SimplesitemapSettingsForm extends ConfigFormBase {
* {@inheritdoc}
*/
public function getFormID() {
return 'simplesitemap_settings_form';
return 'simple_sitemap_settings_form';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return ['simplesitemap.settings'];
return ['simple_sitemap.settings'];
}
/**
......@@ -37,26 +37,46 @@ class SimplesitemapSettingsForm extends ConfigFormBase {
$sitemap = new Simplesitemap;
$form['simplesitemap_settings']['regenerate'] = array(
$form['simple_sitemap_settings']['regenerate'] = array(
'#title' => t('Regenerate sitemap'),
'#type' => 'fieldset',
'#markup' => '<p>' . t('This will regenerate the XML sitemap for all languages.') . '</p>',
);
$form['simplesitemap_settings']['regenerate']['regenerate_submit'] = array(
$form['simple_sitemap_settings']['regenerate']['regenerate_submit'] = array(
'#type' => 'submit',
'#value' => t('Regenerate sitemap'),
'#submit' => array('::generate_sitemap'),
'#validate' => array(), // Skip form-level validator.
);
$form['simplesitemap_settings']['settings'] = array(