xref: /webtrees/resources/views/layouts/default.phtml (revision 52288ec72a577b9a3a455ccc0f26d11b0df31667)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\FlashMessages;
6use Fisharebest\Webtrees\Http\RequestHandlers\AppleTouchIconPng;
7use Fisharebest\Webtrees\Http\RequestHandlers\BrowserconfigXml;
8use Fisharebest\Webtrees\Http\RequestHandlers\SearchQuickAction;
9use Fisharebest\Webtrees\Http\RequestHandlers\WebmanifestJson;
10use Fisharebest\Webtrees\I18N;
11use Fisharebest\Webtrees\Module\ModuleFooterInterface;
12use Fisharebest\Webtrees\Module\ModuleGlobalInterface;
13use Fisharebest\Webtrees\Module\ModuleThemeInterface;
14use Fisharebest\Webtrees\Services\ModuleService;
15use Fisharebest\Webtrees\Tree;
16use Fisharebest\Webtrees\Validator;
17use Fisharebest\Webtrees\View;
18use Fisharebest\Webtrees\Webtrees;
19use Psr\Http\Message\ServerRequestInterface;
20
21/**
22 * @var string                 $content
23 * @var ServerRequestInterface $request
24 * @var string                 $title
25 * @var Tree                   $tree
26 */
27
28?>
29
30<!DOCTYPE html>
31<html dir="<?= I18N::locale()->direction() ?>" lang="<?= I18N::locale()->languageTag() ?>">
32    <head>
33        <meta charset="UTF-8">
34        <meta name="csrf" content="<?= e(csrf_token()) ?>">
35        <meta name="viewport" content="width=device-width, initial-scale=1">
36        <meta name="robots" content="<?= e($meta_robots ?? 'noindex') ?>">
37        <meta name="generator" content="<?= e(Webtrees::NAME) ?> <?= e(Webtrees::VERSION) ?>">
38        <meta name="description" content="<?= $meta_description ?? '' ?>">
39
40        <title>
41            <?= strip_tags($title) ?>
42            <?php if ($tree !== null && $tree->getPreference('META_TITLE') !== '') : ?>
43<?= e($tree->getPreference('META_TITLE')) ?>
44            <?php endif ?>
45        </title>
46
47        <!--iOS-->
48        <link rel="apple-touch-icon" sizes="180x180" href="<?= e(route(AppleTouchIconPng::class)) ?>">
49        <!--Generic favicons-->
50        <link rel="icon" sizes="32x32" href="<?= e(asset('favicon-32.png')) ?>">
51        <link rel="icon" sizes="192x192" href="<?= e(asset('favicon-192.png')) ?>">
52        <!--IE11/Edge-->
53        <meta name="msapplication-config" content="<?= e(route(BrowserconfigXml::class)) ?>">
54
55        <link rel="manifest" href="<?= e(route(WebmanifestJson::class)) ?>" crossorigin="use-credentials">
56
57        <link rel="stylesheet" href="<?= e(asset('css/vendor.min.css')) ?>">
58        <?php foreach (app(ModuleThemeInterface::class)->stylesheets() as $stylesheet) : ?>
59            <link rel="stylesheet" href="<?= e($stylesheet) ?>">
60        <?php endforeach ?>
61
62        <?= View::stack('styles') ?>
63
64        <?= app(ModuleService::class)->findByInterface(ModuleGlobalInterface::class)->map(static function (ModuleGlobalInterface $module): string {
65            return $module->headContent();
66        })->implode('') ?>
67    </head>
68
69    <body class="wt-global wt-theme-<?= e(app(ModuleThemeInterface::class)->name()) ?> wt-route-<?= e(basename(strtr(Validator::attributes($request)->route()->name ?? '/', ['\\' => '/']))) ?>">
70        <header class="wt-header-wrapper d-print-none">
71            <div class="container-lg wt-header-container">
72                <div class="row wt-header-content">
73                    <div class="wt-accessibility-links position-fixed">
74                        <a class="visually-hidden visually-hidden-focusable btn btn-info btn-sm" href="#content">
75                            <?= /* I18N: Skip over the headers and menus, to the main content of the page */
76                            I18N::translate('Skip to content') ?>
77                        </a>
78                    </div>
79                    <div class="col wt-site-logo"></div>
80
81                    <?php if ($tree !== null) : ?>
82                        <h1 class="col wt-site-title"><?= e($tree->title()) ?></h1>
83
84                        <div class="col wt-header-search">
85                            <form method="post" action="<?= e(route(SearchQuickAction::class, ['tree' => $tree->name()])) ?>" class="wt-header-search-form" role="search">
86                                <div class="input-group">
87                                    <label class="visually-hidden" for="quick-search"><?= I18N::translate('Search') ?></label>
88
89                                    <input type="search" class="form-control wt-header-search-field" id="quick-search" name="query" size="15" placeholder="<?= I18N::translate('Search') ?>">
90
91                                    <button type="submit" class="btn btn-primary wt-header-search-button" aria-label="<?= I18N::translate('Search') ?>">
92                                        <?= view('icons/search') ?>
93                                    </button>
94                                </div>
95
96                                <?= csrf_field() ?>
97                            </form>
98                        </div>
99                    <?php endif ?>
100
101                    <div class="col wt-secondary-navigation">
102                        <ul class="nav wt-user-menu">
103                            <?php foreach (app(ModuleThemeInterface::class)->userMenu($tree) as $menu) : ?>
104                                <?= view('components/menu-item', ['menu' => $menu]) ?>
105                            <?php endforeach ?>
106                        </ul>
107                    </div>
108
109                    <?php if ($tree !== null) : ?>
110                        <nav class="col wt-primary-navigation">
111                            <ul class="nav wt-genealogy-menu">
112                                <?php foreach (app(ModuleThemeInterface::class)->genealogyMenu($tree) as $menu) : ?>
113                                    <?= view('components/menu-item', ['menu' => $menu]) ?>
114                                <?php endforeach ?>
115                            </ul>
116                        </nav>
117                    <?php endif ?>
118                </div>
119            </div>
120        </header>
121
122        <main id="content" class="wt-main-wrapper">
123            <div class="container-lg wt-main-container">
124                <div class="flash-messages">
125                    <?php foreach (FlashMessages::getMessages() as $message) : ?>
126                        <div class="alert alert-<?= e($message->status) ?> alert-dismissible" role="alert">
127                            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="<?= I18N::translate('close') ?>">
128                            </button>
129                            <?= $message->text ?>
130                        </div>
131                    <?php endforeach ?>
132                </div>
133
134                <?= $content ?>
135            </div>
136        </main>
137
138        <footer class="container-lg wt-footers d-print-none">
139            <?= app(ModuleService::class)->findByInterface(ModuleFooterInterface::class)->map(static function (ModuleFooterInterface $module) use ($request): string {
140                return $module->getFooter($request);
141            })->implode('') ?>
142        </footer>
143
144        <script src="<?= e(asset('js/vendor.min.js')) ?>"></script>
145        <script src="<?= e(asset('js/webtrees.min.js')) ?>"></script>
146
147        <script>
148            // Trigger an event when we click on an (any) image
149            $('body').on('click', 'a.gallery', function () {
150                // Enable colorbox for images
151                $("a[type^=image].gallery").colorbox({
152                    // Don't scroll window with document
153                    fixed: true,
154                    width: "85%",
155                    height: "85%",
156                    current: "",
157                    previous: '<i class="fa-solid fa-arrow-left wt-icon-flip-rtl" title="<?= I18N::translate('previous') ?>"></i>',
158                    next: '<i class="fa-solid fa-arrow-right wt-icon-flip-rtl" title="<?= I18N::translate('next') ?>"></i>',
159                    slideshowStart: '<i class="fa-solid fa-play" title="<?= I18N::translate('Play') ?>"></i>',
160                    slideshowStop: '<i class="fa-solid fa-stop" title="<?= I18N::translate('Stop') ?>"></i>',
161                    close: '<i class="fa-solid fa-times" title="<?= I18N::translate('close') ?>"></i>',
162                    title: function () {
163                        return this.dataset.title;
164                    },
165                    photo: true,
166                    rel: "gallery", // Turn all images on the page into a slideshow
167                    slideshow: true,
168                    slideshowAuto: false,
169                    slideshowSpeed: 4000,
170                    // Add wheelzoom to the displayed image
171                    onComplete: function () {
172                        // Disable click on image triggering next image
173                        // https://github.com/jackmoore/colorbox/issues/668
174                        $(".cboxPhoto").unbind("click");
175                        // Enable wheel/pinch zooming
176                        $('.cboxPhoto').wrap("<pinch-zoom></pinch-zoom>");
177                    }
178                });
179            });
180        </script>
181
182        <?= View::stack('javascript') ?>
183
184        <?= app(ModuleService::class)->findByInterface(ModuleGlobalInterface::class)->map(static function (ModuleGlobalInterface $module): string {
185            return $module->bodyContent();
186        })->implode('') ?>
187    </body>
188</html>
189