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