SlideShowModule::configureBlock()   F
last analyzed

Complexity

Conditions 18
Paths 12

Size

Total Lines 199
Code Lines 118

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 18
eloc 118
nc 12
nop 1
dl 0
loc 199
rs 3.8933
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * webtrees: online genealogy
4
 * Copyright (C) 2019 webtrees development team
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
 * GNU General Public License for more details.
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15
 */
16
namespace Fisharebest\Webtrees\Module;
17
18
use Fisharebest\Webtrees\Auth;
19
use Fisharebest\Webtrees\Database;
20
use Fisharebest\Webtrees\Filter;
21
use Fisharebest\Webtrees\Functions\FunctionsEdit;
22
use Fisharebest\Webtrees\Functions\FunctionsPrint;
23
use Fisharebest\Webtrees\GedcomTag;
24
use Fisharebest\Webtrees\I18N;
25
use Fisharebest\Webtrees\Media;
26
use Fisharebest\Webtrees\Theme;
27
28
/**
29
 * Class SlideShowModule
30
 */
31
class SlideShowModule extends AbstractModule implements ModuleBlockInterface
32
{
33
    /** {@inheritdoc} */
34
    public function getTitle()
35
    {
36
        return /* I18N: Name of a module */ I18N::translate('Slide show');
37
    }
38
39
    /** {@inheritdoc} */
40
    public function getDescription()
41
    {
42
        return /* I18N: Description of the “Slide show” module */ I18N::translate('Random images from the current family tree.');
43
    }
44
45
    /**
46
     * Generate the HTML content of this block.
47
     *
48
     * @param int      $block_id
49
     * @param bool     $template
50
     * @param string[] $cfg
51
     *
52
     * @return string
53
     */
54
    public function getBlock($block_id, $template = true, $cfg = array())
55
    {
56
        global $ctype, $WT_TREE;
57
58
        $filter   = $this->getBlockSetting($block_id, 'filter', 'all');
59
        $controls = $this->getBlockSetting($block_id, 'controls', '1');
60
        $start    = $this->getBlockSetting($block_id, 'start', '0') || Filter::getBool('start');
61
62
        // We can apply the filters using SQL
63
        // Do not use "ORDER BY RAND()" - it is very slow on large tables. Use PHP::array_rand() instead.
64
        $all_media = Database::prepare(
65
            "SELECT m_id FROM `##media`" .
66
            " WHERE m_file = ?" .
67
            " AND m_ext  IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '')" .
68
            " AND m_type IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '')"
69
        )->execute(array(
70
            $WT_TREE->getTreeId(),
71
            $this->getBlockSetting($block_id, 'filter_avi', '0') ? 'avi' : null,
72
            $this->getBlockSetting($block_id, 'filter_bmp', '1') ? 'bmp' : null,
73
            $this->getBlockSetting($block_id, 'filter_gif', '1') ? 'gif' : null,
74
            $this->getBlockSetting($block_id, 'filter_jpeg', '1') ? 'jpg' : null,
75
            $this->getBlockSetting($block_id, 'filter_jpeg', '1') ? 'jpeg' : null,
76
            $this->getBlockSetting($block_id, 'filter_mp3', '0') ? 'mp3' : null,
77
            $this->getBlockSetting($block_id, 'filter_ole', '1') ? 'ole' : null,
78
            $this->getBlockSetting($block_id, 'filter_pcx', '1') ? 'pcx' : null,
79
            $this->getBlockSetting($block_id, 'filter_pdf', '0') ? 'pdf' : null,
80
            $this->getBlockSetting($block_id, 'filter_png', '1') ? 'png' : null,
81
            $this->getBlockSetting($block_id, 'filter_tiff', '1') ? 'tiff' : null,
82
            $this->getBlockSetting($block_id, 'filter_wav', '0') ? 'wav' : null,
83
            $this->getBlockSetting($block_id, 'filter_audio', '0') ? 'audio' : null,
84
            $this->getBlockSetting($block_id, 'filter_book', '1') ? 'book' : null,
85
            $this->getBlockSetting($block_id, 'filter_card', '1') ? 'card' : null,
86
            $this->getBlockSetting($block_id, 'filter_certificate', '1') ? 'certificate' : null,
87
            $this->getBlockSetting($block_id, 'filter_coat', '1') ? 'coat' : null,
88
            $this->getBlockSetting($block_id, 'filter_document', '1') ? 'document' : null,
89
            $this->getBlockSetting($block_id, 'filter_electronic', '1') ? 'electronic' : null,
90
            $this->getBlockSetting($block_id, 'filter_fiche', '1') ? 'fiche' : null,
91
            $this->getBlockSetting($block_id, 'filter_film', '1') ? 'film' : null,
92
            $this->getBlockSetting($block_id, 'filter_magazine', '1') ? 'magazine' : null,
93
            $this->getBlockSetting($block_id, 'filter_manuscript', '1') ? 'manuscript' : null,
94
            $this->getBlockSetting($block_id, 'filter_map', '1') ? 'map' : null,
95
            $this->getBlockSetting($block_id, 'filter_newspaper', '1') ? 'newspaper' : null,
96
            $this->getBlockSetting($block_id, 'filter_other', '1') ? 'other' : null,
97
            $this->getBlockSetting($block_id, 'filter_painting', '1') ? 'painting' : null,
98
            $this->getBlockSetting($block_id, 'filter_photo', '1') ? 'photo' : null,
99
            $this->getBlockSetting($block_id, 'filter_tombstone', '1') ? 'tombstone' : null,
100
            $this->getBlockSetting($block_id, 'filter_video', '0') ? 'video' : null,
101
        ))->fetchOneColumn();
102
103
        // Keep looking through the media until a suitable one is found.
104
        $random_media = null;
105
        while ($all_media) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $all_media of type string[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
106
            $n     = array_rand($all_media);
107
            $media = Media::getInstance($all_media[$n], $WT_TREE);
108
            if ($media->canShow() && !$media->isExternal()) {
0 ignored issues
show
Bug introduced by
The method isExternal() does not exist on Fisharebest\Webtrees\Source. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

108
            if ($media->canShow() && !$media->/** @scrutinizer ignore-call */ isExternal()) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method isExternal() does not exist on Fisharebest\Webtrees\Individual. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

108
            if ($media->canShow() && !$media->/** @scrutinizer ignore-call */ isExternal()) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method isExternal() does not exist on Fisharebest\Webtrees\Note. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

108
            if ($media->canShow() && !$media->/** @scrutinizer ignore-call */ isExternal()) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method isExternal() does not exist on Fisharebest\Webtrees\GedcomRecord. It seems like you code against a sub-type of Fisharebest\Webtrees\GedcomRecord such as Fisharebest\Webtrees\Media. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

108
            if ($media->canShow() && !$media->/** @scrutinizer ignore-call */ isExternal()) {
Loading history...
Bug introduced by
The method isExternal() does not exist on Fisharebest\Webtrees\Family. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

108
            if ($media->canShow() && !$media->/** @scrutinizer ignore-call */ isExternal()) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method isExternal() does not exist on Fisharebest\Webtrees\Repository. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

108
            if ($media->canShow() && !$media->/** @scrutinizer ignore-call */ isExternal()) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
109
                // Check if it is linked to a suitable individual
110
                foreach ($media->linkedIndividuals('OBJE') as $indi) {
111
                    if (
112
                        $filter === 'all' ||
113
                        $filter === 'indi' && strpos($indi->getGedcom(), "\n1 OBJE @" . $media->getXref() . '@') !== false ||
114
                        $filter === 'event' && strpos($indi->getGedcom(), "\n2 OBJE @" . $media->getXref() . '@') !== false
115
                    ) {
116
                        // Found one :-)
117
                        $random_media = $media;
118
                        break 2;
119
                    }
120
                }
121
            }
122
            unset($all_media[$n]);
123
        };
124
125
        $id    = $this->getName() . $block_id;
126
        $class = $this->getName() . '_block';
127
        if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) {
0 ignored issues
show
introduced by
Consider adding parentheses for clarity. Current Interpretation: ($ctype === 'gedcom' && ...\Webtrees\Auth::check(), Probably Intended Meaning: $ctype === 'gedcom' && (...Webtrees\Auth::check())
Loading history...
128
            $title = '<a class="icon-admin" title="' . I18N::translate('Preferences') . '" href="block_edit.php?block_id=' . $block_id . '&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;ctype=' . $ctype . '"></a>';
129
        } else {
130
            $title = '';
131
        }
132
        $title .= $this->getTitle();
133
134
        if ($random_media) {
135
            $content = "<div id=\"random_picture_container$block_id\">";
136
            if ($controls) {
137
                if ($start) {
138
                    $icon_class = 'icon-media-stop';
139
                } else {
140
                    $icon_class = 'icon-media-play';
141
                }
142
                $content .= '<div dir="ltr" class="center" id="random_picture_controls' . $block_id . '"><br>';
143
                $content .= "<a href=\"#\" onclick=\"togglePlay(); return false;\" id=\"play_stop\" class=\"" . $icon_class . "\" title=\"" . I18N::translate('Play') . "/" . I18N::translate('Stop') . '"></a>';
144
                $content .= '<a href="#" onclick="jQuery(\'#block_' . $block_id . '\').load(\'index.php?ctype=' . $ctype . '&amp;action=ajax&amp;block_id=' . $block_id . '\');return false;" title="' . I18N::translate('Next image') . '" class="icon-media-next"></a>';
145
                $content .= '</div><script>
146
					var play = false;
147
						function togglePlay() {
148
							if (play) {
149
								play = false;
150
								jQuery("#play_stop").removeClass("icon-media-stop").addClass("icon-media-play");
151
							}
152
							else {
153
								play = true;
154
								playSlideShow();
155
								jQuery("#play_stop").removeClass("icon-media-play").addClass("icon-media-stop");
156
							}
157
						}
158
159
						function playSlideShow() {
160
							if (play) {
161
								window.setTimeout("reload_image()", 6000);
162
							}
163
						}
164
						function reload_image() {
165
							if (play) {
166
								jQuery("#block_' . $block_id . '").load("index.php?ctype=' . $ctype . '&action=ajax&block_id=' . $block_id . '&start=1");
167
							}
168
						}
169
					</script>';
170
            }
171
            if ($start) {
172
                $content .= '<script>togglePlay();</script>';
173
            }
174
            $content .= '<div class="center" id="random_picture_content' . $block_id . '">';
175
            $content .= '<table id="random_picture_box"><tr><td class="details1">';
176
            $content .= $random_media->displayImage();
0 ignored issues
show
Bug introduced by
The method displayImage() does not exist on Fisharebest\Webtrees\Family. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

176
            $content .= $random_media->/** @scrutinizer ignore-call */ displayImage();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method displayImage() does not exist on Fisharebest\Webtrees\Note. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

176
            $content .= $random_media->/** @scrutinizer ignore-call */ displayImage();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method displayImage() does not exist on Fisharebest\Webtrees\Source. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

176
            $content .= $random_media->/** @scrutinizer ignore-call */ displayImage();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method displayImage() does not exist on Fisharebest\Webtrees\GedcomRecord. It seems like you code against a sub-type of Fisharebest\Webtrees\GedcomRecord such as Fisharebest\Webtrees\Individual or Fisharebest\Webtrees\Media. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

176
            $content .= $random_media->/** @scrutinizer ignore-call */ displayImage();
Loading history...
Bug introduced by
The method displayImage() does not exist on Fisharebest\Webtrees\Repository. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

176
            $content .= $random_media->/** @scrutinizer ignore-call */ displayImage();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
177
178
            $content .= '<br>';
179
            $content .= '<a href="' . $random_media->getHtmlUrl() . '"><b>' . $random_media->getFullName() . '</b></a><br>';
180
            foreach ($random_media->linkedIndividuals('OBJE') as $individual) {
181
                $content .= '<a href="' . $individual->getHtmlUrl() . '">' . I18N::translate('View this individual') . ' — ' . $individual->getFullName() . '</a><br>';
182
            }
183
            foreach ($random_media->linkedFamilies('OBJE') as $family) {
184
                $content .= '<a href="' . $family->getHtmlUrl() . '">' . I18N::translate('View this family') . ' — ' . $family->getFullName() . '</a><br>';
185
            }
186
            foreach ($random_media->linkedSources('OBJE') as $source) {
187
                $content .= '<a href="' . $source->getHtmlUrl() . '">' . I18N::translate('View this source') . ' — ' . $source->getFullName() . '</a><br>';
188
            }
189
            $content .= '<br><div class="indent">';
190
            $content .= FunctionsPrint::printFactNotes($random_media->getGedcom(), "1", false);
191
            $content .= '</div>';
192
            $content .= '</td></tr></table>';
193
            $content .= '</div>'; // random_picture_content
194
            $content .= '</div>'; // random_picture_container
195
        } else {
196
            $content = I18N::translate('This family tree has no images to display.');
197
        }
198
        if ($template) {
199
            return Theme::theme()->formatBlock($id, $title, $class, $content);
200
        } else {
201
            return $content;
202
        }
203
    }
204
205
    /** {@inheritdoc} */
206
    public function loadAjax()
207
    {
208
        return true;
209
    }
210
211
    /** {@inheritdoc} */
212
    public function isUserBlock()
213
    {
214
        return true;
215
    }
216
217
    /** {@inheritdoc} */
218
    public function isGedcomBlock()
219
    {
220
        return true;
221
    }
222
223
    /**
224
     * An HTML form to edit block settings
225
     *
226
     * @param int $block_id
227
     */
228
    public function configureBlock($block_id)
229
    {
230
        if (Filter::postBool('save') && Filter::checkCsrf()) {
231
            $this->setBlockSetting($block_id, 'filter', Filter::post('filter', 'indi|event|all', 'all'));
232
            $this->setBlockSetting($block_id, 'controls', Filter::postBool('controls'));
233
            $this->setBlockSetting($block_id, 'start', Filter::postBool('start'));
234
            $this->setBlockSetting($block_id, 'filter_avi', Filter::postBool('filter_avi'));
235
            $this->setBlockSetting($block_id, 'filter_bmp', Filter::postBool('filter_bmp'));
236
            $this->setBlockSetting($block_id, 'filter_gif', Filter::postBool('filter_gif'));
237
            $this->setBlockSetting($block_id, 'filter_jpeg', Filter::postBool('filter_jpeg'));
238
            $this->setBlockSetting($block_id, 'filter_mp3', Filter::postBool('filter_mp3'));
239
            $this->setBlockSetting($block_id, 'filter_ole', Filter::postBool('filter_ole'));
240
            $this->setBlockSetting($block_id, 'filter_pcx', Filter::postBool('filter_pcx'));
241
            $this->setBlockSetting($block_id, 'filter_pdf', Filter::postBool('filter_pdf'));
242
            $this->setBlockSetting($block_id, 'filter_png', Filter::postBool('filter_png'));
243
            $this->setBlockSetting($block_id, 'filter_tiff', Filter::postBool('filter_tiff'));
244
            $this->setBlockSetting($block_id, 'filter_wav', Filter::postBool('filter_wav'));
245
            $this->setBlockSetting($block_id, 'filter_audio', Filter::postBool('filter_audio'));
246
            $this->setBlockSetting($block_id, 'filter_book', Filter::postBool('filter_book'));
247
            $this->setBlockSetting($block_id, 'filter_card', Filter::postBool('filter_card'));
248
            $this->setBlockSetting($block_id, 'filter_certificate', Filter::postBool('filter_certificate'));
249
            $this->setBlockSetting($block_id, 'filter_coat', Filter::postBool('filter_coat'));
250
            $this->setBlockSetting($block_id, 'filter_document', Filter::postBool('filter_document'));
251
            $this->setBlockSetting($block_id, 'filter_electronic', Filter::postBool('filter_electronic'));
252
            $this->setBlockSetting($block_id, 'filter_fiche', Filter::postBool('filter_fiche'));
253
            $this->setBlockSetting($block_id, 'filter_film', Filter::postBool('filter_film'));
254
            $this->setBlockSetting($block_id, 'filter_magazine', Filter::postBool('filter_magazine'));
255
            $this->setBlockSetting($block_id, 'filter_manuscript', Filter::postBool('filter_manuscript'));
256
            $this->setBlockSetting($block_id, 'filter_map', Filter::postBool('filter_map'));
257
            $this->setBlockSetting($block_id, 'filter_newspaper', Filter::postBool('filter_newspaper'));
258
            $this->setBlockSetting($block_id, 'filter_other', Filter::postBool('filter_other'));
259
            $this->setBlockSetting($block_id, 'filter_painting', Filter::postBool('filter_painting'));
260
            $this->setBlockSetting($block_id, 'filter_photo', Filter::postBool('filter_photo'));
261
            $this->setBlockSetting($block_id, 'filter_tombstone', Filter::postBool('filter_tombstone'));
262
            $this->setBlockSetting($block_id, 'filter_video', Filter::postBool('filter_video'));
263
        }
264
265
        $filter   = $this->getBlockSetting($block_id, 'filter', 'all');
266
        $controls = $this->getBlockSetting($block_id, 'controls', '1');
267
        $start    = $this->getBlockSetting($block_id, 'start', '0') || Filter::getBool('start');
268
269
        echo '<tr><td class="descriptionbox wrap width33">';
270
        echo /* I18N: Label for a configuration option */ I18N::translate('Show only individuals, events, or all');
271
        echo '</td><td class="optionbox">';
272
        echo FunctionsEdit::selectEditControl('filter', array('indi' => I18N::translate('Individuals'), 'event' => I18N::translate('Facts and events'), 'all' => I18N::translate('All')), null, $filter, '');
273
        echo '</td></tr>';
274
275
        $filters = array(
276
            'avi'         => $this->getBlockSetting($block_id, 'filter_avi', '0'),
277
            'bmp'         => $this->getBlockSetting($block_id, 'filter_bmp', '1'),
278
            'gif'         => $this->getBlockSetting($block_id, 'filter_gif', '1'),
279
            'jpeg'        => $this->getBlockSetting($block_id, 'filter_jpeg', '1'),
280
            'mp3'         => $this->getBlockSetting($block_id, 'filter_mp3', '0'),
281
            'ole'         => $this->getBlockSetting($block_id, 'filter_ole', '1'),
282
            'pcx'         => $this->getBlockSetting($block_id, 'filter_pcx', '1'),
283
            'pdf'         => $this->getBlockSetting($block_id, 'filter_pdf', '0'),
284
            'png'         => $this->getBlockSetting($block_id, 'filter_png', '1'),
285
            'tiff'        => $this->getBlockSetting($block_id, 'filter_tiff', '1'),
286
            'wav'         => $this->getBlockSetting($block_id, 'filter_wav', '0'),
287
            'audio'       => $this->getBlockSetting($block_id, 'filter_audio', '0'),
288
            'book'        => $this->getBlockSetting($block_id, 'filter_book', '1'),
289
            'card'        => $this->getBlockSetting($block_id, 'filter_card', '1'),
290
            'certificate' => $this->getBlockSetting($block_id, 'filter_certificate', '1'),
291
            'coat'        => $this->getBlockSetting($block_id, 'filter_coat', '1'),
292
            'document'    => $this->getBlockSetting($block_id, 'filter_document', '1'),
293
            'electronic'  => $this->getBlockSetting($block_id, 'filter_electronic', '1'),
294
            'fiche'       => $this->getBlockSetting($block_id, 'filter_fiche', '1'),
295
            'film'        => $this->getBlockSetting($block_id, 'filter_film', '1'),
296
            'magazine'    => $this->getBlockSetting($block_id, 'filter_magazine', '1'),
297
            'manuscript'  => $this->getBlockSetting($block_id, 'filter_manuscript', '1'),
298
            'map'         => $this->getBlockSetting($block_id, 'filter_map', '1'),
299
            'newspaper'   => $this->getBlockSetting($block_id, 'filter_newspaper', '1'),
300
            'other'       => $this->getBlockSetting($block_id, 'filter_other', '1'),
301
            'painting'    => $this->getBlockSetting($block_id, 'filter_painting', '1'),
302
            'photo'       => $this->getBlockSetting($block_id, 'filter_photo', '1'),
303
            'tombstone'   => $this->getBlockSetting($block_id, 'filter_tombstone', '1'),
304
            'video'       => $this->getBlockSetting($block_id, 'filter_video', '0'),
305
        );
306
307
        ?>
308
    <tr>
309
    <td class="descriptionbox wrap width33">
310
        <?php echo I18N::translate('Filter'); ?>
311
    </td>
312
    <td class="optionbox">
313
        <center><b><?php echo GedcomTag::getLabel('FORM'); ?></b></center>
314
        <table class="width100">
315
            <tr>
316
                <td class="width33">
317
                    <label>
318
                        <input type="checkbox" value="yes" name="filter_avi" <?php echo $filters['avi'] ? 'checked' : ''; ?>>
319
                        avi
320
                </td>
321
                <td class="width33">
322
                    <label>
323
                        <input type="checkbox" value="yes" name="filter_bmp" <?php echo $filters['bmp'] ? 'checked' : ''; ?>>
324
                        bmp
325
                    </label>
326
                </td>
327
                <td class="width33">
328
                    <label>
329
                        <input type="checkbox" value="yes" name="filter_gif" <?php echo $filters['gif'] ? 'checked' : ''; ?>>
330
                        gif
331
                    </label>
332
                </td>
333
            </tr>
334
            <tr>
335
                <td class="width33">
336
                    <label>
337
                        <input type="checkbox" value="yes" name="filter_jpeg" <?php echo $filters['jpeg'] ? 'checked' : ''; ?>>
338
                        jpeg
339
                    </label>
340
                </td>
341
                <td class="width33">
342
                    <label>
343
                        <input type="checkbox" value="yes" name="filter_mp3" <?php echo $filters['mp3'] ? 'checked' : ''; ?>>
344
                        mp3
345
                    </label>
346
                </td>
347
                    <td class="width33">
348
                    <label>
349
                        <input type="checkbox" value="yes" name="filter_ole" <?php echo $filters['ole'] ? 'checked' : ''; ?>>
350
                        ole
351
                    </label>
352
                </td>
353
            </tr>
354
            <tr>
355
                <td class="width33">
356
                    <label>
357
                        <input type="checkbox" value="yes" name="filter_pcx" <?php echo $filters['pcx'] ? 'checked' : ''; ?>>
358
                        pcx
359
                    </label>
360
                </td>
361
                <td class="width33">
362
                    <label>
363
                        <input type="checkbox" value="yes" name="filter_pdf" <?php echo $filters['pdf'] ? 'checked' : ''; ?>>
364
                        pdf
365
                    </label>
366
                </td>
367
                <td class="width33">
368
                    <label>
369
                        <input type="checkbox" value="yes" name="filter_png" <?php echo $filters['png'] ? 'checked' : ''; ?>>
370
                        png
371
                    </label>
372
                </td>
373
            </tr>
374
            <tr>
375
                <td class="width33">
376
                    <label>
377
                        <input type="checkbox" value="yes" name="filter_tiff" <?php echo $filters['tiff'] ? 'checked' : ''; ?>>
378
                        tiff
379
                    </label>
380
                </td>
381
                <td class="width33">
382
                    <label>
383
                        <input type="checkbox" value="yes" name="filter_wav" <?php echo $filters['wav'] ? 'checked' : ''; ?>>
384
                        wav
385
                    </label>
386
                </td>
387
                <td class="width33"></td>
388
                <td class="width33"></td>
389
            </tr>
390
        </table>
391
            <br>
392
            <center><b><?php echo GedcomTag::getLabel('TYPE'); ?></b></center>
393
                <table class="width100">
394
                    <tr>
395
                    <?php
396
                    //-- Build the list of checkboxes
397
                    $i = 0;
398
                    foreach (GedcomTag::getFileFormTypes() as $typeName => $typeValue) {
399
                        $i++;
400
                        if ($i > 3) {
401
                            $i = 1;
402
                            echo '</tr><tr>';
403
                        }
404
                        echo '<td class="width33"><label><input type="checkbox" value="yes" name="filter_' . $typeName . '" ';
405
                        echo $filters[$typeName] ? 'checked' : '';
406
                        echo '> ' . $typeValue . '</label></td>';
407
                    }
408
                    ?>
409
                </tr>
410
            </table>
411
        </td>
412
    </tr>
413
414
        <?php
415
416
        echo '<tr><td class="descriptionbox wrap width33">';
417
        echo /* I18N: Label for a configuration option */ I18N::translate('Show slide show controls');
418
        echo '</td><td class="optionbox">';
419
        echo FunctionsEdit::editFieldYesNo('controls', $controls);
0 ignored issues
show
Bug introduced by
$controls of type string is incompatible with the type boolean expected by parameter $selected of Fisharebest\Webtrees\Fun...sEdit::editFieldYesNo(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

419
        echo FunctionsEdit::editFieldYesNo('controls', /** @scrutinizer ignore-type */ $controls);
Loading history...
420
        echo '</td></tr>';
421
422
        echo '<tr><td class="descriptionbox wrap width33">';
423
        echo /* I18N: Label for a configuration option */ I18N::translate('Start slide show on page load');
424
        echo '</td><td class="optionbox">';
425
        echo FunctionsEdit::editFieldYesNo('start', $start);
426
        echo '</td></tr>';
427
    }
428
}
429