...
 
Commits (2)
......@@ -2,6 +2,7 @@
namespace Drupal\simple_sitemap_views\Controller;
use Drupal\simple_sitemap\Form\FormHelper;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\simple_sitemap_views\SimpleSitemapViews;
use Drupal\Core\Controller\ControllerBase;
......@@ -80,7 +81,12 @@ class SimpleSitemapViewsController extends ControllerBase {
}
// Show information about indexed displays.
$build['indexed_displays'] = $table;
$build['simple_sitemap_views'] = [
'#prefix' => FormHelper::getDonationText(),
'#title' => $this->t('Indexed view displays'),
'#type' => 'fieldset',
'table' => $table,
];
return $build;
}
......
......@@ -87,6 +87,20 @@ class FormHelper {
'never',
];
protected static $cronIntervals = [
1,
3,
6,
12,
24,
48,
72,
96,
120,
144,
168,
];
/**
* FormHelper constructor.
* @param \Drupal\simple_sitemap\Simplesitemap $generator
......@@ -570,4 +584,25 @@ class FormHelper {
public static function isValidChangefreq($changefreq) {
return in_array($changefreq, self::$changefreqValues);
}
/**
* @return array
*/
public static function getCronIntervalOptions() {
/** @var \Drupal\Core\Datetime\DateFormatter $formatter */
$formatter = \Drupal::service('date.formatter');
$intervals = array_flip(self::$cronIntervals);
foreach ($intervals as $interval => &$label) {
$label = $formatter->formatInterval($interval * 60 * 60);
}
return [0 => t('On every cron run')] + $intervals;
}
/**
* @return string
*/
public static function getDonationText() {
return '<div class="description">' . t('If you would like to say thanks and support the development of this module, a <a target="_blank" href="@url">donation</a> will be much appreciated.', ['@url' => 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5AFYRSBLGSC3W']) . '</div>';
}
}
......@@ -63,7 +63,7 @@ class SimplesitemapCustomLinksForm extends SimplesitemapFormBase {
'#title' => $this->t('Custom links'),
'#type' => 'fieldset',
'#markup' => '<div class="description">' . $this->t('Add custom internal drupal paths to the XML sitemap.') . '</div>',
'#prefix' => $this->getDonationText(),
'#prefix' => FormHelper::getDonationText(),
];
$form['simple_sitemap_custom']['custom_links'] = [
......
......@@ -59,7 +59,7 @@ class SimplesitemapEntitiesForm extends SimplesitemapFormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['simple_sitemap_entities']['#prefix'] = $this->getDonationText();
$form['simple_sitemap_entities']['#prefix'] = FormHelper::getDonationText();
$form['simple_sitemap_entities']['entities'] = [
'#title' => $this->t('Sitemap entities'),
......
......@@ -52,11 +52,4 @@ abstract class SimplesitemapFormBase extends ConfigFormBase {
return ['simple_sitemap.settings'];
}
/**
*
*/
protected function getDonationText() {
return '<div class="description">' . $this->t('If you would like to say thanks and support the development of this module, a <a target="_blank" href="@url">donation</a> will be much appreciated.', ['@url' => 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5AFYRSBLGSC3W']) . '</div>';
}
}
......@@ -70,7 +70,7 @@ class SimplesitemapSettingsForm extends SimplesitemapFormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['simple_sitemap_settings']['#prefix'] = $this->getDonationText();
$form['simple_sitemap_settings']['#prefix'] = FormHelper::getDonationText();
$form['simple_sitemap_settings']['#attached']['library'][] = 'simple_sitemap/sitemapSettings';
$queue_worker = $this->generator->getQueueWorker();
......@@ -222,24 +222,9 @@ class SimplesitemapSettingsForm extends SimplesitemapFormBase {
'#title' => $this->t('Sitemap generation interval'),
'#description' => $this->t('The sitemap will be generated according to this interval.'),
'#default_value' => $this->generator->getSetting('cron_generate_interval', 0),
'#options' => [
0 => $this->t('On every cron run'),
1 => $this->t('Once an hour'),
3 => $this->t('Once every @hours hours', ['@hours' => 3]),
6 => $this->t('Once every @hours hours', ['@hours' => 6]),
12 => $this->t('Once every @hours hours', ['@hours' => 12]),
24 => $this->t('Once a day'),
48 => $this->t('Once every @days days', ['@days' => 48/24]),
72 => $this->t('Once every @days days', ['@days' => 72/24]),
96 => $this->t('Once every @days days', ['@days' => 96/24]),
120 => $this->t('Once every @days days', ['@days' => 120/24]),
144 => $this->t('Once every @days days', ['@days' => 144/24]),
168 => $this->t('Once a week'),
],
'#options' => FormHelper::getCronIntervalOptions(),
'#states' => [
'visible' => [
':input[name="cron_generate"]' => ['checked' => TRUE],
],
'visible' => [':input[name="cron_generate"]' => ['checked' => TRUE]],
],
];
......
......@@ -27,7 +27,7 @@ class SimplesitemapVariantsForm extends SimplesitemapFormBase {
'#title' => $this->t('Sitemap variants'),
'#type' => 'fieldset',
'#markup' => '<div class="description">' . $this->t('Define sitemap variants. A sitemap variant is a sitemap instance of a certain type (specific sitemap generator and URL generators) accessible under a certain URL.<br>Each variant can have its own entity bundle settings (to be defined on bundle edit pages).') . '</div>',
'#prefix' => $this->getDonationText(),
'#prefix' => FormHelper::getDonationText(),
];
$form['simple_sitemap_variants']['variants'] = [
......