diff options
| author | Bert Koorengevel <BertKoor@users.noreply.github.com> | 2026-02-06 18:59:52 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-06 17:59:52 +0000 |
| commit | 823da595e59c27ac89729b3640941a014a634b8b (patch) | |
| tree | 22812ea112a23fa0cca913becb4b29f443a7ca9c | |
| parent | 00761d2727abd24cf3a9b8d6f176d180151602fc (diff) | |
| download | webtrees-823da595e59c27ac89729b3640941a014a634b8b.tar.gz webtrees-823da595e59c27ac89729b3640941a014a634b8b.tar.bz2 webtrees-823da595e59c27ac89729b3640941a014a634b8b.zip | |
SlideShow module - configurable delay time as block setting (#5303)
* fix #5302: SlideShow module - configurable delay time as block setting
* fixed PR code review issues
* Use input-group addon for units
* Change text label
* Code style - whitespace
---------
Co-authored-by: Greg Roach <greg@subaqua.co.uk>
| -rw-r--r-- | app/Module/SlideShowModule.php | 37 | ||||
| -rw-r--r-- | resources/views/modules/random_media/config.phtml | 13 |
2 files changed, 34 insertions, 16 deletions
diff --git a/app/Module/SlideShowModule.php b/app/Module/SlideShowModule.php index 4b55783dd8..306a52d725 100644 --- a/app/Module/SlideShowModule.php +++ b/app/Module/SlideShowModule.php @@ -46,7 +46,7 @@ class SlideShowModule extends AbstractModule implements ModuleBlockInterface private const string LINK_INDIVIDUAL = 'indi'; // How long to show each slide (seconds) - private const int DELAY = 6; + private const string DEFAULT_DELAY = '6'; // New data is normalized. Old data may contain jpg/jpeg, tif/tiff. private const array SUPPORTED_FORMATS = ['bmp', 'gif', 'jpeg', 'jpg', 'png', 'tif', 'tiff', 'webp']; @@ -81,9 +81,11 @@ class SlideShowModule extends AbstractModule implements ModuleBlockInterface { $request = Registry::container()->get(ServerRequestInterface::class); $default_start = (bool) $this->getBlockSetting($block_id, 'start'); + $default_delay = (int) $this->getBlockSetting($block_id, 'delay', self::DEFAULT_DELAY); $filter_links = $this->getBlockSetting($block_id, 'filter', self::LINK_ALL); $controls = $this->getBlockSetting($block_id, 'controls', '1'); $start = Validator::queryParams($request)->boolean('start', $default_start); + $delay = Validator::queryParams($request)->isBetween(1, 999)->integer('delay', $default_delay); $filter_types = [ $this->getBlockSetting($block_id, 'filter_audio', '0') ? SourceMediaType::VALUE_AUDIO : null, @@ -158,7 +160,7 @@ class SlideShowModule extends AbstractModule implements ModuleBlockInterface if ($random_media instanceof Media) { $content = view('modules/random_media/slide-show', [ 'block_id' => $block_id, - 'delay' => self::DELAY, + 'delay' => $delay, 'linked_families' => $this->linked_record_service->linkedFamilies($random_media), 'linked_individuals' => $this->linked_record_service->linkedIndividuals($random_media), 'linked_sources' => $this->linked_record_service->linkedSources($random_media), @@ -236,6 +238,7 @@ class SlideShowModule extends AbstractModule implements ModuleBlockInterface $this->setBlockSetting($block_id, 'filter', Validator::parsedBody($request)->string('filter')); $this->setBlockSetting($block_id, 'controls', Validator::parsedBody($request)->string('controls')); $this->setBlockSetting($block_id, 'start', Validator::parsedBody($request)->string('start')); + $this->setBlockSetting($block_id, 'delay', (string) Validator::parsedBody($request)->isBetween(1, 999)->integer('delay')); $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_AUDIO), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_AUDIO, false)); $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_BOOK), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_BOOK, false)); $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_CARD), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_CARD, false)); @@ -269,26 +272,27 @@ class SlideShowModule extends AbstractModule implements ModuleBlockInterface $filter = $this->getBlockSetting($block_id, 'filter', self::LINK_ALL); $controls = $this->getBlockSetting($block_id, 'controls', '1'); $start = $this->getBlockSetting($block_id, 'start', '0'); + $delay = (int) $this->getBlockSetting($block_id, 'delay', self::DEFAULT_DELAY); $filters = [ SourceMediaType::VALUE_AUDIO => $this->getBlockSetting($block_id, 'filter_audio', '0'), SourceMediaType::VALUE_BOOK => $this->getBlockSetting($block_id, 'filter_book', '1'), SourceMediaType::VALUE_CARD => $this->getBlockSetting($block_id, 'filter_card', '1'), SourceMediaType::VALUE_CERTIFICATE => $this->getBlockSetting($block_id, 'filter_certificate', '1'), - SourceMediaType::VALUE_COAT => $this->getBlockSetting($block_id, 'filter_coat', '1'), - SourceMediaType::VALUE_DOCUMENT => $this->getBlockSetting($block_id, 'filter_document', '1'), - SourceMediaType::VALUE_ELECTRONIC => $this->getBlockSetting($block_id, 'filter_electronic', '1'), - SourceMediaType::VALUE_FICHE => $this->getBlockSetting($block_id, 'filter_fiche', '1'), - SourceMediaType::VALUE_FILM => $this->getBlockSetting($block_id, 'filter_film', '1'), - SourceMediaType::VALUE_MAGAZINE => $this->getBlockSetting($block_id, 'filter_magazine', '1'), - SourceMediaType::VALUE_MANUSCRIPT => $this->getBlockSetting($block_id, 'filter_manuscript', '1'), - SourceMediaType::VALUE_MAP => $this->getBlockSetting($block_id, 'filter_map', '1'), - SourceMediaType::VALUE_NEWSPAPER => $this->getBlockSetting($block_id, 'filter_newspaper', '1'), - SourceMediaType::VALUE_OTHER => $this->getBlockSetting($block_id, 'filter_other', '1'), - SourceMediaType::VALUE_PAINTING => $this->getBlockSetting($block_id, 'filter_painting', '1'), - SourceMediaType::VALUE_PHOTO => $this->getBlockSetting($block_id, 'filter_photo', '1'), - SourceMediaType::VALUE_TOMBSTONE => $this->getBlockSetting($block_id, 'filter_tombstone', '1'), - SourceMediaType::VALUE_VIDEO => $this->getBlockSetting($block_id, 'filter_video', '0'), + SourceMediaType::VALUE_COAT => $this->getBlockSetting($block_id, 'filter_coat', '1'), + SourceMediaType::VALUE_DOCUMENT => $this->getBlockSetting($block_id, 'filter_document', '1'), + SourceMediaType::VALUE_ELECTRONIC => $this->getBlockSetting($block_id, 'filter_electronic', '1'), + SourceMediaType::VALUE_FICHE => $this->getBlockSetting($block_id, 'filter_fiche', '1'), + SourceMediaType::VALUE_FILM => $this->getBlockSetting($block_id, 'filter_film', '1'), + SourceMediaType::VALUE_MAGAZINE => $this->getBlockSetting($block_id, 'filter_magazine', '1'), + SourceMediaType::VALUE_MANUSCRIPT => $this->getBlockSetting($block_id, 'filter_manuscript', '1'), + SourceMediaType::VALUE_MAP => $this->getBlockSetting($block_id, 'filter_map', '1'), + SourceMediaType::VALUE_NEWSPAPER => $this->getBlockSetting($block_id, 'filter_newspaper', '1'), + SourceMediaType::VALUE_OTHER => $this->getBlockSetting($block_id, 'filter_other', '1'), + SourceMediaType::VALUE_PAINTING => $this->getBlockSetting($block_id, 'filter_painting', '1'), + SourceMediaType::VALUE_PHOTO => $this->getBlockSetting($block_id, 'filter_photo', '1'), + SourceMediaType::VALUE_TOMBSTONE => $this->getBlockSetting($block_id, 'filter_tombstone', '1'), + SourceMediaType::VALUE_VIDEO => $this->getBlockSetting($block_id, 'filter_video', '0'), ]; $formats = array_filter(Registry::elementFactory()->make('OBJE:FILE:FORM:TYPE')->values()); @@ -299,6 +303,7 @@ class SlideShowModule extends AbstractModule implements ModuleBlockInterface 'filters' => $filters, 'formats' => $formats, 'start' => $start, + 'delay' => $delay, ]); } } diff --git a/resources/views/modules/random_media/config.phtml b/resources/views/modules/random_media/config.phtml index f587b18df6..7bfd86c14d 100644 --- a/resources/views/modules/random_media/config.phtml +++ b/resources/views/modules/random_media/config.phtml @@ -10,6 +10,7 @@ use Fisharebest\Webtrees\I18N; * @var array<string,string> $filters * @var array<string,string> $formats * @var string $start + * @var int $delay */ ?> @@ -51,3 +52,15 @@ use Fisharebest\Webtrees\I18N; <?= view('components/radios-inline', ['name' => 'start', 'options' => [I18N::translate('no'), I18N::translate('yes')], 'selected' => (int) $start]) ?> </div> </div> + +<div class="row mb-3"> + <label for="delay" class="col-sm-3 col-form-label"> + <?= I18N::translate('Slide show interval') ?> + </label> + <div class="col-sm-9"> + <div class="input-group"> + <input type="number" name="delay" id="delay" class="form-control" value="<?= $delay ?>" min="1" max="999"> + <span class="input-group-text"><?= I18N::translate('seconds') ?></span> + </div> + </div> +</div> |
