Commit 6a14f0a8 authored by gbyte.co's avatar gbyte.co Committed by gbyte.co

Issue #3091970 by gbyte.co: Improve settings UI and tab structure

parent 08547002
#simple-sitemap-settings-form .progress__bar {
#simple-sitemap-sitemaps-form .progress__bar {
background-image: none;
}
simple_sitemap.engines:
title: 'Search engines'
parent: simple_sitemap.sitemaps
route_name: simple_sitemap.engines.status
weight: 2
simple_sitemap_engines:
route_name: entity.simple_sitemap_engine.status
simple_sitemap.engines:
route_name: simple_sitemap.engines.status
title: 'Search engines'
base_route: simple_sitemap.settings
weight: 5
base_route: simple_sitemap.sitemaps
weight: 2
simple_sitemap_engines.status:
route_name: entity.simple_sitemap_engine.status
simple_sitemap.engines.status:
route_name: simple_sitemap.engines.status
title: 'Status'
parent_id: simple_sitemap_engines
weight: 1
parent_id: simple_sitemap.engines
weight: 0
simple_sitemap_engines.settings:
route_name: simple_sitemap_engines.settings
simple_sitemap.engines.settings:
route_name: simple_sitemap.engines.settings
title: 'Settings'
parent_id: simple_sitemap_engines
weight: 2
parent_id: simple_sitemap.engines
weight: 1
entity.simple_sitemap_engine.status:
simple_sitemap.engines.status:
path: '/admin/config/search/simplesitemap/engines'
defaults:
_entity_list: 'simple_sitemap_engine'
_title: 'Simple XML Sitemap Settings'
_title: 'Simple XML Sitemap'
requirements:
_permission: 'administer sitemap settings'
simple_sitemap_engines.settings:
simple_sitemap.engines.settings:
path: '/admin/config/search/simplesitemap/engines/settings'
defaults:
_form: '\Drupal\simple_sitemap_engines\Form\SimplesitemapEnginesForm'
_title: 'Simple XML Sitemap Settings'
_title: 'Simple XML Sitemap'
requirements:
_permission: 'administer sitemap settings'
......@@ -87,53 +87,56 @@ class SimplesitemapEnginesForm extends ConfigFormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('simple_sitemap_engines.settings');
$engines = $this->entityTypeManager->getStorage('simple_sitemap_engine')->loadMultiple();
$variants = array_map(
function ($variant) { return $this->t($variant['label']); },
$this->sitemapManager->getSitemapVariants(NULL, FALSE)
);
$form['#tree'] = TRUE;
$form['engines'] = [
'#type' => 'fieldset',
'#title' => $this->t('Search engines'),
'#markup' => '<div class="description">' . $this->t('Configure sitemap variants to submit to search engines.') . '</div>',
'#prefix' => FormHelper::getDonationText(),
];
foreach ($engines as $engine_id => $engine) {
$form['engines'][$engine_id] = [
'#type' => 'details',
'#title' => $engine->label(),
'#open' => !empty($engine->sitemap_variants) || count($engines) == 1,
];
$form['engines'][$engine_id]['variants'] = [
'#type' => 'select',
'#title' => $this->t('Sitemap variants'),
'#options' => $variants,
'#default_value' => $engine->sitemap_variants,
'#multiple' => TRUE,
];
}
$form['settings'] = [
'#type' => 'fieldset',
'#title' => $this->t('Submission settings'),
'#title' => $this->t('General submission settings'),
'#prefix' => FormHelper::getDonationText(),
];
$form['settings']['enabled'] = [
'#type' => 'checkbox',
'#title' => $this->t('Submit the sitemap to search engines'),
'#default_value' => $config->get('enabled'),
];
$form['settings']['submission_interval'] = [
'#type' => 'select',
'#title' => $this->t('Submission interval'),
'#options' => FormHelper::getCronIntervalOptions(),
'#default_value' => $config->get('submission_interval'),
'#states' => [
'visible' => [':input[name="enabled"]' => ['checked' => TRUE]],
'visible' => [':input[name="settings[enabled]"]' => ['checked' => TRUE]],
],
];
$form['engines'] = [
'#type' => 'fieldset',
'#title' => $this->t('Variant specific settings'),
'#markup' => '<div class="description">' . $this->t('Choose which sitemap variants are to be submitted to which search search engines.<br>Variants can be configured <a href="@url">here</a>.', ['@url' => $GLOBALS['base_url'] . '/admin/config/search/simplesitemap/variants']) . '</div>',
];
$engines = $this->entityTypeManager->getStorage('simple_sitemap_engine')->loadMultiple();
foreach ($engines as $engine_id => $engine) {
$form['engines'][$engine_id] = [
'#type' => 'details',
'#title' => $engine->label(),
'#open' => !empty($engine->sitemap_variants) || count($engines) === 1,
];
$form['engines'][$engine_id]['variants'] = [
'#type' => 'select',
'#title' => $this->t('Sitemap variants'),
'#options' => array_map(
function ($variant) { return $this->t($variant['label']); },
$this->sitemapManager->getSitemapVariants(NULL, FALSE)
),
'#default_value' => $engine->sitemap_variants,
'#multiple' => TRUE,
];
}
return parent::buildForm($form, $form_state);
}
......@@ -141,12 +144,18 @@ class SimplesitemapEnginesForm extends ConfigFormBase {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$engines = $this->entityTypeManager->getStorage('simple_sitemap_engine')->loadMultiple();
foreach ($engines as $engine_id => $engine) {
$engine->sitemap_variants = $form_state->getValue(['engines', $engine_id, 'variants']);
foreach ($this->entityTypeManager->getStorage('simple_sitemap_engine')->loadMultiple() as $engine_id => $engine) {
if (!empty($values = $form_state->getValue(['engines', $engine_id, 'variants']))) {
$submit = TRUE;
}
$engine->sitemap_variants = $values;
$engine->save();
}
if (empty($submit)) {
$this->messenger()->addWarning($this->t('No sitemap variants have been selected for submission.'));
}
$config = $this->config('simple_sitemap_engines.settings');
$config->set('enabled', $form_state->getValue(['settings', 'enabled']));
$config->set('submission_interval', $form_state->getValue(['settings', 'submission_interval']));
......
simple_sitemap.settings_views:
route_name: simple_sitemap.settings_views
title: 'Sitemap views'
base_route: simple_sitemap.settings
weight: 1
simple_sitemap.views:
route_name: simple_sitemap.views
title: 'Views'
parent_id: simple_sitemap.inclusion
weight: 2
simple_sitemap.settings_views:
simple_sitemap.views:
path: '/admin/config/search/simplesitemap/views'
defaults:
_controller: '\Drupal\simple_sitemap_views\Controller\SimpleSitemapViewsController::content'
_title: 'Simple XML Sitemap Settings'
_title: 'Simple XML Sitemap'
requirements:
_permission: 'administer sitemap settings'
name: 'Simple XML Sitemap'
type: module
description: 'Generates standard conform hreflang XML sitemaps of the site content and provides a framework for developing other sitemap types.'
configure: simple_sitemap.settings
configure: simple_sitemap.sitemaps
package: SEO
core: 8.x
......@@ -11,8 +11,8 @@ sitemapEntities:
dependencies:
- core/jquery
- core/drupalSettings
sitemapSettings:
sitemaps:
version: VERSION
css:
theme:
css/simple_sitemap.settings.css: {}
css/simple_sitemap.sitemaps.css: {}
simple_sitemap.settings:
simple_sitemap.sitemaps:
title: 'Simple XML Sitemap'
description: 'Configure and generate the XML sitemap, add custom links to it.'
parent: system.admin_config_search
route_name: simple_sitemap.sitemaps
simple_sitemap.settings:
title: 'Settings'
parent: simple_sitemap.sitemaps
route_name: simple_sitemap.settings
weight: 0
simple_sitemap.inclusion:
title: 'Inclusion'
parent: simple_sitemap.sitemaps
route_name: simple_sitemap.entities
weight: 1
simple_sitemap.sitemaps:
route_name: simple_sitemap.sitemaps
title: 'Sitemaps'
base_route: simple_sitemap.sitemaps
weight: -1
simple_sitemap.status:
route_name: simple_sitemap.sitemaps
title: 'Status'
parent_id: simple_sitemap.sitemaps
weight: -1
simple_sitemap.variants:
route_name: simple_sitemap.variants
title: 'Variants'
parent_id: simple_sitemap.sitemaps
weight: 0
simple_sitemap.settings:
route_name: simple_sitemap.settings
title: 'Settings'
base_route: simple_sitemap.settings
weight: -1
simple_sitemap.settings_entities:
route_name: simple_sitemap.settings_entities
title: 'Sitemap entities'
base_route: simple_sitemap.settings
base_route: simple_sitemap.sitemaps
weight: 0
simple_sitemap.variants:
route_name: simple_sitemap.settings_variants
title: 'Sitemap variants'
base_route: simple_sitemap.settings
weight: 2
simple_sitemap.inclusion:
route_name: simple_sitemap.entities
title: 'Inclusion'
base_route: simple_sitemap.sitemaps
weight: 1
simple_sitemap.entities:
route_name: simple_sitemap.entities
title: 'Entities'
parent_id: simple_sitemap.inclusion
weight: 0
simple_sitemap.settings_custom:
route_name: simple_sitemap.settings_custom
simple_sitemap.custom:
route_name: simple_sitemap.custom
title: 'Custom links'
base_route: simple_sitemap.settings
weight: 3
parent_id: simple_sitemap.inclusion
weight: 1
......@@ -18,42 +18,50 @@ simple_sitemap.sitemap_variant:
requirements:
_access: 'TRUE'
simple_sitemap.settings:
simple_sitemap.sitemap_xsl:
path: '/sitemap.xsl'
defaults:
_controller: '\Drupal\simple_sitemap\Controller\SimplesitemapController::getSitemapXsl'
_title: 'Sitemap XSL'
requirements:
_access: 'TRUE'
simple_sitemap.sitemaps:
path: '/admin/config/search/simplesitemap'
defaults:
_form: '\Drupal\simple_sitemap\Form\SimplesitemapSitemapsForm'
_title: 'Simple XML Sitemap'
requirements:
_permission: 'administer sitemap settings'
simple_sitemap.settings:
path: '/admin/config/search/simplesitemap/settings'
defaults:
_form: '\Drupal\simple_sitemap\Form\SimplesitemapSettingsForm'
_title: 'Simple XML Sitemap Settings'
_title: 'Simple XML Sitemap'
requirements:
_permission: 'administer sitemap settings'
simple_sitemap.settings_entities:
simple_sitemap.entities:
path: '/admin/config/search/simplesitemap/entities'
defaults:
_form: '\Drupal\simple_sitemap\Form\SimplesitemapEntitiesForm'
_title: 'Simple XML Sitemap Settings'
_title: 'Simple XML Sitemap'
requirements:
_permission: 'administer sitemap settings'
simple_sitemap.settings_custom:
simple_sitemap.custom:
path: '/admin/config/search/simplesitemap/custom'
defaults:
_form: '\Drupal\simple_sitemap\Form\SimplesitemapCustomLinksForm'
_title: 'Simple XML Sitemap Settings'
_title: 'Simple XML Sitemap'
requirements:
_permission: 'administer sitemap settings'
simple_sitemap.settings_variants:
simple_sitemap.variants:
path: '/admin/config/search/simplesitemap/variants'
defaults:
_form: '\Drupal\simple_sitemap\Form\SimplesitemapVariantsForm'
_title: 'Simple XML Sitemap Settings'
_title: 'Simple XML Sitemap'
requirements:
_permission: 'administer sitemap settings'
simple_sitemap.sitemap_xsl:
path: '/sitemap.xsl'
defaults:
_controller: '\Drupal\simple_sitemap\Controller\SimplesitemapController::getSitemapXsl'
_title: 'Sitemap XSL'
requirements:
_access: 'TRUE'
This diff is collapsed.
This diff is collapsed.
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