xref: /webtrees/app/Module/SlideShowModule.php (revision 7413816e6dd2d50e569034fb804f3dce7471bb94)
18c2e8227SGreg Roach<?php
23976b470SGreg Roach
38c2e8227SGreg Roach/**
48c2e8227SGreg Roach * webtrees: online genealogy
5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
68c2e8227SGreg Roach * This program is free software: you can redistribute it and/or modify
78c2e8227SGreg Roach * it under the terms of the GNU General Public License as published by
88c2e8227SGreg Roach * the Free Software Foundation, either version 3 of the License, or
98c2e8227SGreg Roach * (at your option) any later version.
108c2e8227SGreg Roach * This program is distributed in the hope that it will be useful,
118c2e8227SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
128c2e8227SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
138c2e8227SGreg Roach * GNU General Public License for more details.
148c2e8227SGreg Roach * You should have received a copy of the GNU General Public License
1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
168c2e8227SGreg Roach */
17fcfa147eSGreg Roach
18e7f56f2aSGreg Roachdeclare(strict_types=1);
19e7f56f2aSGreg Roach
2076692c8bSGreg Roachnamespace Fisharebest\Webtrees\Module;
2176692c8bSGreg Roach
22*6f4ec3caSGreg Roachuse Fisharebest\Webtrees\DB;
23e1d48734SGreg Roachuse Fisharebest\Webtrees\Elements\SourceMediaType;
240e62c4b8SGreg Roachuse Fisharebest\Webtrees\I18N;
250e62c4b8SGreg Roachuse Fisharebest\Webtrees\Media;
2609482a55SGreg Roachuse Fisharebest\Webtrees\Registry;
274991f205SGreg Roachuse Fisharebest\Webtrees\Services\LinkedRecordService;
28e490cd80SGreg Roachuse Fisharebest\Webtrees\Tree;
293f810b5bSGreg Roachuse Fisharebest\Webtrees\Validator;
3031e43e2fSGreg Roachuse Illuminate\Database\Query\JoinClause;
311e7a7a28SGreg Roachuse Illuminate\Support\Str;
326ccdf4f0SGreg Roachuse Psr\Http\Message\ServerRequestInterface;
333976b470SGreg Roach
34455a30feSGreg Roachuse function array_filter;
359e8577e7SGreg Roachuse function in_array;
36dec352c1SGreg Roachuse function str_contains;
373f810b5bSGreg Roachuse function strtolower;
388c2e8227SGreg Roach
398c2e8227SGreg Roach/**
408c2e8227SGreg Roach * Class SlideShowModule
418c2e8227SGreg Roach */
4237eb8894SGreg Roachclass SlideShowModule extends AbstractModule implements ModuleBlockInterface
43c1010edaSGreg Roach{
4449a243cbSGreg Roach    use ModuleBlockTrait;
4549a243cbSGreg Roach
467ff867dcSGreg Roach    // Show media linked to events or individuals.
477ff867dcSGreg Roach    private const LINK_ALL        = 'all';
487ff867dcSGreg Roach    private const LINK_EVENT      = 'event';
497ff867dcSGreg Roach    private const LINK_INDIVIDUAL = 'indi';
507ff867dcSGreg Roach
517ff867dcSGreg Roach    // How long to show each slide (seconds)
527ff867dcSGreg Roach    private const DELAY = 6;
537ff867dcSGreg Roach
54f484f365SGreg Roach    // New data is normalized.  Old data may contain jpg/jpeg, tif/tiff.
55f484f365SGreg Roach    private const SUPPORTED_FORMATS = ['bmp', 'gif', 'jpeg', 'jpg', 'png', 'tif', 'tiff', 'webp'];
56f484f365SGreg Roach
574991f205SGreg Roach    private LinkedRecordService $linked_record_service;
584991f205SGreg Roach
594991f205SGreg Roach    /**
604991f205SGreg Roach     * @param LinkedRecordService $linked_record_service
614991f205SGreg Roach     */
624991f205SGreg Roach    public function __construct(LinkedRecordService $linked_record_service)
634991f205SGreg Roach    {
644991f205SGreg Roach        $this->linked_record_service = $linked_record_service;
654991f205SGreg Roach    }
664991f205SGreg Roach
6749a243cbSGreg Roach    public function description(): string
68c1010edaSGreg Roach    {
69bbb76c12SGreg Roach        /* I18N: Description of the “Slide show” module */
70bbb76c12SGreg Roach        return I18N::translate('Random images from the current family tree.');
718c2e8227SGreg Roach    }
728c2e8227SGreg Roach
7376692c8bSGreg Roach    /**
7476692c8bSGreg Roach     * Generate the HTML content of this block.
7576692c8bSGreg Roach     *
76e490cd80SGreg Roach     * @param Tree                 $tree
7776692c8bSGreg Roach     * @param int                  $block_id
783caaa4d2SGreg Roach     * @param string               $context
7976d39c55SGreg Roach     * @param array<string,string> $config
8076692c8bSGreg Roach     *
8176692c8bSGreg Roach     * @return string
8276692c8bSGreg Roach     */
833caaa4d2SGreg Roach    public function getBlock(Tree $tree, int $block_id, string $context, array $config = []): string
84c1010edaSGreg Roach    {
85d35568b4SGreg Roach        $request       = Registry::container()->get(ServerRequestInterface::class);
86748dbe15SGreg Roach        $default_start = (bool) $this->getBlockSetting($block_id, 'start');
877ff867dcSGreg Roach        $filter_links  = $this->getBlockSetting($block_id, 'filter', self::LINK_ALL);
88e2a378d3SGreg Roach        $controls      = $this->getBlockSetting($block_id, 'controls', '1');
89748dbe15SGreg Roach        $start         = Validator::queryParams($request)->boolean('start', $default_start);
908c2e8227SGreg Roach
917ff867dcSGreg Roach        $filter_types = [
9288a03560SGreg Roach            $this->getBlockSetting($block_id, 'filter_audio', '0') ? SourceMediaType::VALUE_AUDIO : null,
9388a03560SGreg Roach            $this->getBlockSetting($block_id, 'filter_book', '1') ? SourceMediaType::VALUE_BOOK : null,
9488a03560SGreg Roach            $this->getBlockSetting($block_id, 'filter_card', '1') ? SourceMediaType::VALUE_CARD : null,
9588a03560SGreg Roach            $this->getBlockSetting($block_id, 'filter_certificate', '1') ? SourceMediaType::VALUE_CERTIFICATE : null,
9688a03560SGreg Roach            $this->getBlockSetting($block_id, 'filter_coat', '1') ? SourceMediaType::VALUE_COAT : null,
9788a03560SGreg Roach            $this->getBlockSetting($block_id, 'filter_document', '1') ? SourceMediaType::VALUE_DOCUMENT : null,
9888a03560SGreg Roach            $this->getBlockSetting($block_id, 'filter_electronic', '1') ? SourceMediaType::VALUE_ELECTRONIC : null,
9988a03560SGreg Roach            $this->getBlockSetting($block_id, 'filter_fiche', '1') ? SourceMediaType::VALUE_FICHE : null,
10088a03560SGreg Roach            $this->getBlockSetting($block_id, 'filter_film', '1') ? SourceMediaType::VALUE_FILM : null,
10188a03560SGreg Roach            $this->getBlockSetting($block_id, 'filter_magazine', '1') ? SourceMediaType::VALUE_MAGAZINE : null,
10288a03560SGreg Roach            $this->getBlockSetting($block_id, 'filter_manuscript', '1') ? SourceMediaType::VALUE_MANUSCRIPT : null,
10388a03560SGreg Roach            $this->getBlockSetting($block_id, 'filter_map', '1') ? SourceMediaType::VALUE_MAP : null,
10488a03560SGreg Roach            $this->getBlockSetting($block_id, 'filter_newspaper', '1') ? SourceMediaType::VALUE_NEWSPAPER : null,
10588a03560SGreg Roach            $this->getBlockSetting($block_id, 'filter_other', '1') ? SourceMediaType::VALUE_OTHER : null,
10688a03560SGreg Roach            $this->getBlockSetting($block_id, 'filter_painting', '1') ? SourceMediaType::VALUE_PAINTING : null,
10788a03560SGreg Roach            $this->getBlockSetting($block_id, 'filter_photo', '1') ? SourceMediaType::VALUE_PHOTO : null,
10888a03560SGreg Roach            $this->getBlockSetting($block_id, 'filter_tombstone', '1') ? SourceMediaType::VALUE_TOMBSTONE : null,
10988a03560SGreg Roach            $this->getBlockSetting($block_id, 'filter_video', '0') ? SourceMediaType::VALUE_VIDEO : null,
11031e43e2fSGreg Roach        ];
11131e43e2fSGreg Roach
1127ff867dcSGreg Roach        $filter_types = array_filter($filter_types);
11331e43e2fSGreg Roach
1149e8577e7SGreg Roach        // The type "other" includes media without a type.
11588a03560SGreg Roach        if (in_array(SourceMediaType::VALUE_OTHER, $filter_types, true)) {
1167ff867dcSGreg Roach            $filter_types[] = '';
1179e8577e7SGreg Roach        }
1189e8577e7SGreg Roach
1195136fb17SGreg Roach        // We can apply the filters using SQL, but it is more efficient to shuffle in PHP.
1205136fb17SGreg Roach        $random_row = DB::table('media')
1210b5fd0a6SGreg Roach            ->join('media_file', static function (JoinClause $join): void {
12231e43e2fSGreg Roach                $join
12331e43e2fSGreg Roach                    ->on('media_file.m_file', '=', 'media.m_file')
12431e43e2fSGreg Roach                    ->on('media_file.m_id', '=', 'media.m_id');
12531e43e2fSGreg Roach            })
12631e43e2fSGreg Roach            ->where('media.m_file', '=', $tree->id())
127f484f365SGreg Roach            ->whereIn('media_file.multimedia_format', self::SUPPORTED_FORMATS)
1287ff867dcSGreg Roach            ->whereIn('media_file.source_media_type', $filter_types)
129059898c9SGreg Roach            ->select(['media.*'])
1305136fb17SGreg Roach            ->get()
1315136fb17SGreg Roach            ->shuffle()
1324991f205SGreg Roach            ->first(function (object $row) use ($filter_links, $tree): bool {
1336b9cb339SGreg Roach                $media = Registry::mediaFactory()->make($row->m_id, $tree, $row->m_gedcom);
1347ff867dcSGreg Roach
135e1d48734SGreg Roach                if ($media === null || !$media->canShow() || $media->firstImageFile() === null) {
1367ff867dcSGreg Roach                    return false;
1377ff867dcSGreg Roach                }
1388c2e8227SGreg Roach
1394991f205SGreg Roach                foreach ($this->linked_record_service->linkedIndividuals($media) as $individual) {
1407ff867dcSGreg Roach                    switch ($filter_links) {
1417ff867dcSGreg Roach                        case self::LINK_ALL:
1425136fb17SGreg Roach                            return true;
1437ff867dcSGreg Roach
1447ff867dcSGreg Roach                        case self::LINK_INDIVIDUAL:
145dec352c1SGreg Roach                            return str_contains($individual->gedcom(), "\n1 OBJE @" . $media->xref() . '@');
1467ff867dcSGreg Roach
1477ff867dcSGreg Roach                        case self::LINK_EVENT:
148dec352c1SGreg Roach                            return str_contains($individual->gedcom(), "\n2 OBJE @" . $media->xref() . '@');
1498c2e8227SGreg Roach                    }
1508c2e8227SGreg Roach                }
1518c2e8227SGreg Roach
1525136fb17SGreg Roach                return false;
1535136fb17SGreg Roach            });
1545136fb17SGreg Roach
155ae7e1e94SGreg Roach        $random_media = null;
156ae7e1e94SGreg Roach
157ae7e1e94SGreg Roach        if ($random_row !== null) {
1586b9cb339SGreg Roach            $random_media = Registry::mediaFactory()->make($random_row->m_id, $tree, $random_row->m_gedcom);
159ae7e1e94SGreg Roach        }
1605136fb17SGreg Roach
1615136fb17SGreg Roach        if ($random_media instanceof Media) {
162147e99aaSGreg Roach            $content = view('modules/random_media/slide-show', [
163a1fe7073SGreg Roach                'block_id'            => $block_id,
1647ff867dcSGreg Roach                'delay'               => self::DELAY,
1654991f205SGreg Roach                'linked_families'     => $this->linked_record_service->linkedFamilies($random_media),
1664991f205SGreg Roach                'linked_individuals'  => $this->linked_record_service->linkedIndividuals($random_media),
1674991f205SGreg Roach                'linked_sources'      => $this->linked_record_service->linkedSources($random_media),
168a1fe7073SGreg Roach                'media'               => $random_media,
169495cefeaSGreg Roach                'media_file'          => $random_media->firstImageFile(),
170a1fe7073SGreg Roach                'show_controls'       => $controls,
171a1fe7073SGreg Roach                'start_automatically' => $start,
172911f5683SGreg Roach                'tree'                => $tree,
173a1fe7073SGreg Roach            ]);
1748c2e8227SGreg Roach        } else {
1758c2e8227SGreg Roach            $content = I18N::translate('This family tree has no images to display.');
1768c2e8227SGreg Roach        }
177a1fe7073SGreg Roach
1783caaa4d2SGreg Roach        if ($context !== self::CONTEXT_EMBED) {
179147e99aaSGreg Roach            return view('modules/block-template', [
1801e7a7a28SGreg Roach                'block'      => Str::kebab($this->name()),
1819c6524dcSGreg Roach                'id'         => $block_id,
1823caaa4d2SGreg Roach                'config_url' => $this->configUrl($tree, $context, $block_id),
18349a243cbSGreg Roach                'title'      => $this->title(),
1849c6524dcSGreg Roach                'content'    => $content,
1859c6524dcSGreg Roach            ]);
1868c2e8227SGreg Roach        }
187b2ce94c6SRico Sonntag
188b2ce94c6SRico Sonntag        return $content;
1898c2e8227SGreg Roach    }
1908c2e8227SGreg Roach
1916ccdf4f0SGreg Roach    /**
1926ccdf4f0SGreg Roach     * How should this module be identified in the control panel, etc.?
1936ccdf4f0SGreg Roach     *
1946ccdf4f0SGreg Roach     * @return string
1956ccdf4f0SGreg Roach     */
1966ccdf4f0SGreg Roach    public function title(): string
1976ccdf4f0SGreg Roach    {
1986ccdf4f0SGreg Roach        /* I18N: Name of a module */
1996ccdf4f0SGreg Roach        return I18N::translate('Slide show');
2006ccdf4f0SGreg Roach    }
2016ccdf4f0SGreg Roach
2023caaa4d2SGreg Roach    /**
2033caaa4d2SGreg Roach     * Should this block load asynchronously using AJAX?
2043caaa4d2SGreg Roach     *
2053caaa4d2SGreg Roach     * Simple blocks are faster in-line, more complex ones can be loaded later.
2063caaa4d2SGreg Roach     *
2073caaa4d2SGreg Roach     * @return bool
2083caaa4d2SGreg Roach     */
209c1010edaSGreg Roach    public function loadAjax(): bool
210c1010edaSGreg Roach    {
2118c2e8227SGreg Roach        return true;
2128c2e8227SGreg Roach    }
2138c2e8227SGreg Roach
2143caaa4d2SGreg Roach    /**
2153caaa4d2SGreg Roach     * Can this block be shown on the user’s home page?
2163caaa4d2SGreg Roach     *
2173caaa4d2SGreg Roach     * @return bool
2183caaa4d2SGreg Roach     */
219c1010edaSGreg Roach    public function isUserBlock(): bool
220c1010edaSGreg Roach    {
2218c2e8227SGreg Roach        return true;
2228c2e8227SGreg Roach    }
2238c2e8227SGreg Roach
2243caaa4d2SGreg Roach    /**
2253caaa4d2SGreg Roach     * Can this block be shown on the tree’s home page?
2263caaa4d2SGreg Roach     *
2273caaa4d2SGreg Roach     * @return bool
2283caaa4d2SGreg Roach     */
22963276d8fSGreg Roach    public function isTreeBlock(): bool
230c1010edaSGreg Roach    {
2318c2e8227SGreg Roach        return true;
2328c2e8227SGreg Roach    }
2338c2e8227SGreg Roach
23476692c8bSGreg Roach    /**
235a45f9889SGreg Roach     * Update the configuration for a block.
236a45f9889SGreg Roach     *
2376ccdf4f0SGreg Roach     * @param ServerRequestInterface $request
238a45f9889SGreg Roach     * @param int                    $block_id
239a45f9889SGreg Roach     *
240a45f9889SGreg Roach     * @return void
241a45f9889SGreg Roach     */
2426ccdf4f0SGreg Roach    public function saveBlockConfiguration(ServerRequestInterface $request, int $block_id): void
243a45f9889SGreg Roach    {
2443f810b5bSGreg Roach        $this->setBlockSetting($block_id, 'filter', Validator::parsedBody($request)->string('filter'));
2453f810b5bSGreg Roach        $this->setBlockSetting($block_id, 'controls', Validator::parsedBody($request)->string('controls'));
2463f810b5bSGreg Roach        $this->setBlockSetting($block_id, 'start', Validator::parsedBody($request)->string('start'));
24788a03560SGreg Roach        $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_AUDIO), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_AUDIO, false));
24888a03560SGreg Roach        $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_BOOK), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_BOOK, false));
24988a03560SGreg Roach        $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_CARD), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_CARD, false));
25088a03560SGreg Roach        $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_CERTIFICATE), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_CERTIFICATE, false));
25188a03560SGreg Roach        $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_COAT), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_COAT, false));
25288a03560SGreg Roach        $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_DOCUMENT), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_DOCUMENT, false));
25388a03560SGreg Roach        $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_ELECTRONIC), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_ELECTRONIC, false));
25488a03560SGreg Roach        $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_FICHE), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_FICHE, false));
25588a03560SGreg Roach        $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_FILM), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_FILM, false));
25688a03560SGreg Roach        $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_MAGAZINE), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_MAGAZINE, false));
25788a03560SGreg Roach        $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_MANUSCRIPT), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_MANUSCRIPT, false));
25888a03560SGreg Roach        $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_MAP), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_MAP, false));
25988a03560SGreg Roach        $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_NEWSPAPER), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_NEWSPAPER, false));
26088a03560SGreg Roach        $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_OTHER), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_OTHER, false));
26188a03560SGreg Roach        $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_PAINTING), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_PAINTING, false));
26288a03560SGreg Roach        $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_PHOTO), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_PHOTO, false));
26388a03560SGreg Roach        $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_TOMBSTONE), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_TOMBSTONE, false));
26488a03560SGreg Roach        $this->setBlockSetting($block_id, 'filter_' . strtolower(SourceMediaType::VALUE_VIDEO), (string) Validator::parsedBody($request)->boolean(SourceMediaType::VALUE_VIDEO, false));
265a45f9889SGreg Roach    }
266a45f9889SGreg Roach
267a45f9889SGreg Roach    /**
26876692c8bSGreg Roach     * An HTML form to edit block settings
26976692c8bSGreg Roach     *
270e490cd80SGreg Roach     * @param Tree $tree
27176692c8bSGreg Roach     * @param int  $block_id
272a9430be8SGreg Roach     *
2733caaa4d2SGreg Roach     * @return string
27476692c8bSGreg Roach     */
2753caaa4d2SGreg Roach    public function editBlockConfiguration(Tree $tree, int $block_id): string
276c1010edaSGreg Roach    {
2777ff867dcSGreg Roach        $filter   = $this->getBlockSetting($block_id, 'filter', self::LINK_ALL);
278e2a378d3SGreg Roach        $controls = $this->getBlockSetting($block_id, 'controls', '1');
27915d603e7SGreg Roach        $start    = $this->getBlockSetting($block_id, 'start', '0');
2808c2e8227SGreg Roach
28113abd6f3SGreg Roach        $filters = [
28288a03560SGreg Roach            SourceMediaType::VALUE_AUDIO       => $this->getBlockSetting($block_id, 'filter_audio', '0'),
28388a03560SGreg Roach            SourceMediaType::VALUE_BOOK        => $this->getBlockSetting($block_id, 'filter_book', '1'),
28488a03560SGreg Roach            SourceMediaType::VALUE_CARD        => $this->getBlockSetting($block_id, 'filter_card', '1'),
28588a03560SGreg Roach            SourceMediaType::VALUE_CERTIFICATE => $this->getBlockSetting($block_id, 'filter_certificate', '1'),
28688a03560SGreg Roach            SourceMediaType::VALUE_COAT       => $this->getBlockSetting($block_id, 'filter_coat', '1'),
28788a03560SGreg Roach            SourceMediaType::VALUE_DOCUMENT   => $this->getBlockSetting($block_id, 'filter_document', '1'),
28888a03560SGreg Roach            SourceMediaType::VALUE_ELECTRONIC => $this->getBlockSetting($block_id, 'filter_electronic', '1'),
28988a03560SGreg Roach            SourceMediaType::VALUE_FICHE      => $this->getBlockSetting($block_id, 'filter_fiche', '1'),
29088a03560SGreg Roach            SourceMediaType::VALUE_FILM       => $this->getBlockSetting($block_id, 'filter_film', '1'),
29188a03560SGreg Roach            SourceMediaType::VALUE_MAGAZINE   => $this->getBlockSetting($block_id, 'filter_magazine', '1'),
29288a03560SGreg Roach            SourceMediaType::VALUE_MANUSCRIPT => $this->getBlockSetting($block_id, 'filter_manuscript', '1'),
29388a03560SGreg Roach            SourceMediaType::VALUE_MAP        => $this->getBlockSetting($block_id, 'filter_map', '1'),
29488a03560SGreg Roach            SourceMediaType::VALUE_NEWSPAPER  => $this->getBlockSetting($block_id, 'filter_newspaper', '1'),
29588a03560SGreg Roach            SourceMediaType::VALUE_OTHER      => $this->getBlockSetting($block_id, 'filter_other', '1'),
29688a03560SGreg Roach            SourceMediaType::VALUE_PAINTING   => $this->getBlockSetting($block_id, 'filter_painting', '1'),
29788a03560SGreg Roach            SourceMediaType::VALUE_PHOTO      => $this->getBlockSetting($block_id, 'filter_photo', '1'),
29888a03560SGreg Roach            SourceMediaType::VALUE_TOMBSTONE  => $this->getBlockSetting($block_id, 'filter_tombstone', '1'),
29988a03560SGreg Roach            SourceMediaType::VALUE_VIDEO      => $this->getBlockSetting($block_id, 'filter_video', '0'),
30013abd6f3SGreg Roach        ];
3018c2e8227SGreg Roach
302455a30feSGreg Roach        $formats = array_filter(Registry::elementFactory()->make('OBJE:FILE:FORM:TYPE')->values());
30315d603e7SGreg Roach
3043caaa4d2SGreg Roach        return view('modules/random_media/config', [
305c385536dSGreg Roach            'controls' => $controls,
306c385536dSGreg Roach            'filter'   => $filter,
307c385536dSGreg Roach            'filters'  => $filters,
308c385536dSGreg Roach            'formats'  => $formats,
309c385536dSGreg Roach            'start'    => $start,
310c385536dSGreg Roach        ]);
3118c2e8227SGreg Roach    }
3128c2e8227SGreg Roach}
313