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