Commit 8136913f authored by gbyte.co's avatar gbyte.co

Adjusting schema definition, improving some field descriptions, fixing not...

Adjusting schema definition, improving some field descriptions, fixing not being able to add 0 as link priority.
parent 2a7447c9
...@@ -48,8 +48,9 @@ simple_sitemap.settings: ...@@ -48,8 +48,9 @@ simple_sitemap.settings:
sequence: sequence:
type: mapping type: mapping
mapping: mapping:
label: 'Index' index:
type: integer label: 'Index'
priority: type: integer
label: 'Priority' priority:
type: float label: 'Priority'
type: float
...@@ -73,8 +73,8 @@ function simple_sitemap_form_alter(&$form, $form_state, $form_id) { ...@@ -73,8 +73,8 @@ function simple_sitemap_form_alter(&$form, $form_state, $form_id) {
'#type' => 'radios', '#type' => 'radios',
'#default_value' => $index, '#default_value' => $index,
'#options' => [ '#options' => [
0 => $f->entityType == 'bundle_instance' ? t('Do not index this entity') : t('Do not index content of this type'), 0 => $f->entityType == 'bundle_instance' ? t('Do not index this entity') : t('Do not index entities of this type'),
1 => $f->entityType == 'bundle_instance' ? t('Index this entity') : t('Index content of this type'), 1 => $f->entityType == 'bundle_instance' ? t('Index this entity') : t('Index entities of this type'),
] ]
); );
if ($f->entityType == 'bundle_instance' && isset($bundle_index)) { if ($f->entityType == 'bundle_instance' && isset($bundle_index)) {
...@@ -94,12 +94,12 @@ function simple_sitemap_form_alter(&$form, $form_state, $form_id) { ...@@ -94,12 +94,12 @@ function simple_sitemap_form_alter(&$form, $form_state, $form_id) {
$form['simple_sitemap']['simple_sitemap_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 <em>Save</em>'),
'#description' => t('This setting will regenerate the whole sitemap including the above changes.'), '#description' => t('This setting will regenerate the whole sitemap including the above changes.'),
'#default_value' => FALSE, '#default_value' => FALSE,
); );
if ($sitemap->getSetting('cron_generate')) { if ($sitemap->getSetting('cron_generate')) {
$form['simple_sitemap']['simple_sitemap_regenerate_now']['#description'] .= '</br>' . t('Otherwise the sitemap will be rebuilt on next cron run.'); $form['simple_sitemap']['simple_sitemap_regenerate_now']['#description'] .= '</br>' . t('Otherwise the sitemap will be regenerated on the next cron run.');
} }
$form['#simple_sitemap'] = $f; $form['#simple_sitemap'] = $f;
...@@ -162,7 +162,7 @@ function simple_sitemap_entity_form_submit($form, &$form_state) { ...@@ -162,7 +162,7 @@ function simple_sitemap_entity_form_submit($form, &$form_state) {
// Regenerate sitemaps according to user setting. // Regenerate sitemaps according to user setting.
if ($values['simple_sitemap_regenerate_now']) { if ($values['simple_sitemap_regenerate_now']) {
$sitemap->generateSitemap(); //todo: generates changes? $sitemap->generateSitemap();
} }
} }
} }
...@@ -192,7 +192,7 @@ function simple_sitemap_entity_bundle_delete($entity_type_id, $bundle) { ...@@ -192,7 +192,7 @@ function simple_sitemap_entity_bundle_delete($entity_type_id, $bundle) {
$sitemap->saveConfig('entity_types', $entity_types); $sitemap->saveConfig('entity_types', $entity_types);
$message = t("You may want to <a href='@url'>regenerate</a> your XML sitemap now.", array('@url' => $GLOBALS['base_url'] . '/admin/config/search/simplesitemap')); $message = t("You may want to <a href='@url'>regenerate</a> your XML sitemap now.", array('@url' => $GLOBALS['base_url'] . '/admin/config/search/simplesitemap'));
if ($sitemap->getSetting('cron_generate')) { if ($sitemap->getSetting('cron_generate')) {
$message .= '</br>' . t('Otherwise the sitemap will be rebuilt on next cron run.'); $message .= '</br>' . t('Otherwise the sitemap will be regenerated on the next cron run.');
} }
drupal_set_message($message); drupal_set_message($message);
} }
......
...@@ -228,7 +228,7 @@ class Batch { ...@@ -228,7 +228,7 @@ class Batch {
'urls' => $urls, 'urls' => $urls,
'options' => $url_object->getOptions(), 'options' => $url_object->getOptions(),
'lastmod' => !empty($info['field_info']['lastmod']) ? date_iso8601($row->{$info['field_info']['lastmod']}) : NULL, 'lastmod' => !empty($info['field_info']['lastmod']) ? date_iso8601($row->{$info['field_info']['lastmod']}) : NULL,
'priority' => !empty($priority) ? $priority : (!empty($info['bundle_settings']['priority']) ? $info['bundle_settings']['priority'] : NULL), 'priority' => isset($priority) ? $priority : (isset($info['bundle_settings']['priority']) ? $info['bundle_settings']['priority'] : NULL),
); );
$priority = NULL; $priority = NULL;
} }
...@@ -288,7 +288,7 @@ class Batch { ...@@ -288,7 +288,7 @@ class Batch {
'path' => $path, 'path' => $path,
'urls' => $urls, 'urls' => $urls,
'options' => $url_object->getOptions(), 'options' => $url_object->getOptions(),
'priority' => !empty($custom_path['priority']) ? $custom_path['priority'] : NULL, 'priority' => isset($custom_path['priority']) ? $custom_path['priority'] : NULL,
); );
} }
self::setProgressInfo($context, $batch_info); self::setProgressInfo($context, $batch_info);
......
...@@ -49,24 +49,24 @@ class SimplesitemapCustomLinksForm extends ConfigFormBase { ...@@ -49,24 +49,24 @@ class SimplesitemapCustomLinksForm extends ConfigFormBase {
$form['simple_sitemap_custom'] = array( $form['simple_sitemap_custom'] = array(
'#title' => t('Custom links'), '#title' => t('Custom links'),
'#type' => 'fieldset', '#type' => 'fieldset',
'#markup' => '<p>' . t('Add custom internal drupal paths and their priorities to the XML sitemap.') . '</p>', '#markup' => '<p>' . t('Add custom internal drupal paths to the XML sitemap.') . '</p>',
); );
$form['simple_sitemap_custom']['custom_links'] = array( $form['simple_sitemap_custom']['custom_links'] = array(
'#type' => 'textarea', '#type' => 'textarea',
'#title' => t('Relative Drupal paths'), '#title' => t('Relative Drupal paths'),
'#default_value' => $setting_string, '#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>."), '#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.0</em>, the contact page with the default priority would be <em>/contact 0.5</em>."),
); );
$form['simple_sitemap_custom']['simple_sitemap_regenerate_now'] = array( $form['simple_sitemap_custom']['simple_sitemap_regenerate_now'] = array(
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => t('Regenerate sitemap after hitting Save'), '#title' => t('Regenerate sitemap after hitting <em>Save</em>'),
'#description' => t('This setting will regenerate the whole sitemap including the above changes.'), '#description' => t('This setting will regenerate the whole sitemap including the above changes.'),
'#default_value' => FALSE, '#default_value' => FALSE,
); );
if ($sitemap->getSetting('cron_generate')) { if ($sitemap->getSetting('cron_generate')) {
$form['simple_sitemap_custom']['simple_sitemap_regenerate_now']['#description'] .= '</br>' . t('Otherwise the sitemap will be rebuilt on next cron run.'); $form['simple_sitemap_custom']['simple_sitemap_regenerate_now']['#description'] .= '</br>' . t('Otherwise the sitemap will be regenerated on the next cron run.');
} }
return parent::buildForm($form, $form_state); return parent::buildForm($form, $form_state);
...@@ -85,11 +85,11 @@ class SimplesitemapCustomLinksForm extends ConfigFormBase { ...@@ -85,11 +85,11 @@ class SimplesitemapCustomLinksForm extends ConfigFormBase {
$form_state->setErrorByName('', t("The path <em>@path</em> does not exist.", array('@path' => $link_config['path']))); $form_state->setErrorByName('', t("The path <em>@path</em> does not exist.", array('@path' => $link_config['path'])));
} }
if ($link_config['path'][0] != '/') { if ($link_config['path'][0] != '/') {
$form_state->setErrorByName('', t("The path <em>@path</em> needs to start with an '/'.", array('@path' => $link_config['path']))); $form_state->setErrorByName('', t("The path <em>@path</em> needs to start with a '/'.", array('@path' => $link_config['path'])));
} }
if (isset($link_config['priority'])) { if (isset($link_config['priority'])) {
if (!is_numeric($link_config['priority']) || $link_config['priority'] < 0 || $link_config['priority'] > 1) { if (!is_numeric($link_config['priority']) || $link_config['priority'] < 0 || $link_config['priority'] > 1) {
$form_state->setErrorByName('', t("Priority setting on line <em>@priority</em> is incorrect. Set priority from 0.0 to 1.0.", array('@priority' => $link_config['priority']))); $form_state->setErrorByName('', t("The priority setting on line <em>@priority</em> is incorrect. Set the priority from 0.0 to 1.0.", array('@priority' => $link_config['priority'])));
} }
} }
} }
......
...@@ -54,7 +54,6 @@ class SimplesitemapSettingsForm extends ConfigFormBase { ...@@ -54,7 +54,6 @@ class SimplesitemapSettingsForm extends ConfigFormBase {
$form['simple_sitemap_settings']['settings'] = array( $form['simple_sitemap_settings']['settings'] = array(
'#title' => t('Settings'), '#title' => t('Settings'),
'#type' => 'fieldset', '#type' => 'fieldset',
// '#markup' => '<p>' . t('Various sitemap settings.') . '</p>',
); );
$form['simple_sitemap_settings']['settings']['cron_generate'] = array( $form['simple_sitemap_settings']['settings']['cron_generate'] = array(
...@@ -67,13 +66,12 @@ class SimplesitemapSettingsForm extends ConfigFormBase { ...@@ -67,13 +66,12 @@ class SimplesitemapSettingsForm extends ConfigFormBase {
$form['simple_sitemap_settings']['advanced'] = array( $form['simple_sitemap_settings']['advanced'] = array(
'#title' => t('Advanced settings'), '#title' => t('Advanced settings'),
'#type' => 'details', '#type' => 'details',
// '#markup' => '<p>' . t('Various performance settings.') . '</p>',
); );
$form['simple_sitemap_settings']['advanced']['remove_duplicates'] = array( $form['simple_sitemap_settings']['advanced']['remove_duplicates'] = array(
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => t('Remove duplicate links'), '#title' => t('Remove duplicate links'),
'#description' => t('Uncheck this to significantly speed up the sitemap generation process on a huge site (>20 000 entities).'), '#description' => t('Uncheck this to significantly speed up the sitemap generation process on a huge site (more than 20 000 indexed entities).'),
'#default_value' => $sitemap->getSetting('remove_duplicates'), '#default_value' => $sitemap->getSetting('remove_duplicates'),
); );
...@@ -88,7 +86,7 @@ class SimplesitemapSettingsForm extends ConfigFormBase { ...@@ -88,7 +86,7 @@ class SimplesitemapSettingsForm extends ConfigFormBase {
$form['simple_sitemap_settings']['advanced']['batch_process_limit'] = array( $form['simple_sitemap_settings']['advanced']['batch_process_limit'] = array(
'#title' => t('Refresh batch every n links'), '#title' => t('Refresh batch every n links'),
'#description' => t("During sitemap generation, the batch process will issue a page refresh after n links processed to prevent PHP timeout and memory exhaustion. Increasing this number will reduce the number of times Drupal has to bootstrap (thus speeding up the generation process), but will require more memory and less strict PHP timeout settings."), '#description' => t("During sitemap generation, the batch process will issue a page refresh after n links processed to prevent PHP timeouts and memory exhaustion. Increasing this number will reduce the number of times Drupal has to bootstrap (thus speeding up the generation process), but will require more memory and less strict PHP timeout settings."),
'#type' => 'textfield', '#type' => 'textfield',
'#maxlength' => 5, '#maxlength' => 5,
'#size' => 5, '#size' => 5,
...@@ -105,13 +103,13 @@ class SimplesitemapSettingsForm extends ConfigFormBase { ...@@ -105,13 +103,13 @@ class SimplesitemapSettingsForm extends ConfigFormBase {
$max_links = $form_state->getValue('max_links'); $max_links = $form_state->getValue('max_links');
if ($max_links != '') { if ($max_links != '') {
if (!is_numeric($max_links) || $max_links < 1 || $max_links != round($max_links)) { if (!is_numeric($max_links) || $max_links < 1 || $max_links != round($max_links)) {
$form_state->setErrorByName('', t("The value of the max links field must be a positive integer greater than 0.")); $form_state->setErrorByName('', t("The value of the <em>Maximum links in a sitemap</em> field must be empty, or a positive integer greater than 0."));
} }
} }
$batch_process_limit = $form_state->getValue('batch_process_limit'); $batch_process_limit = $form_state->getValue('batch_process_limit');
if (!is_numeric($batch_process_limit) || $batch_process_limit < 1 || $batch_process_limit != round($batch_process_limit)) { if (!is_numeric($batch_process_limit) || $batch_process_limit < 1 || $batch_process_limit != round($batch_process_limit)) {
$form_state->setErrorByName('', t("The value of the batch refresh rate field must be a positive integer greater than 0.")); $form_state->setErrorByName('', t("The value of the <em>Refresh batch every n links</em> field must be a positive integer greater than 0."));
} }
} }
......
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