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