xref: /webtrees/resources/views/layouts/default.phtml (revision 2ebcf907ed34213f816592af04e6c160335d6311)
1<?php
2
3use Fisharebest\Webtrees\DebugBar;
4use Fisharebest\Webtrees\FlashMessages;
5use Fisharebest\Webtrees\Http\RequestHandlers\AppleTouchIconPng;
6use Fisharebest\Webtrees\Http\RequestHandlers\BrowserconfigXml;
7use Fisharebest\Webtrees\Http\RequestHandlers\SearchQuickAction;
8use Fisharebest\Webtrees\Http\RequestHandlers\WebmanifestJson;
9use Fisharebest\Webtrees\I18N;
10use Fisharebest\Webtrees\Module\ModuleFooterInterface;
11use Fisharebest\Webtrees\Module\ModuleGlobalInterface;
12use Fisharebest\Webtrees\Module\ModuleThemeInterface;
13use Fisharebest\Webtrees\Services\ModuleService;
14use Fisharebest\Webtrees\Tree;
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
66        <?= DebugBar::renderHead() ?>
67    </head>
68
69    <body class="wt-global wt-theme-<?= e(app(ModuleThemeInterface::class)->name()) ?> wt-route-<?= e(substr(strrchr($request->getAttribute('route')->name, '\\'),1)) ?>">
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"
86                                  action="<?= e(route(SearchQuickAction::class, ['tree' => $tree->name()])) ?>"
87                                  class="wt-header-search-form" role="search">
88                                <?= csrf_field() ?>
89                                <div class="input-group">
90                                    <label class="visually-hidden" for="quick-search"><?= I18N::translate('Search') ?></label>
91                                    <input type="search" class="form-control wt-header-search-field" id="quick-search"
92                                           name="query" size="15" placeholder="<?= I18N::translate('Search') ?>">
93                                    <button type="submit" class="btn btn-primary wt-header-search-button">
94                                        <?= view('icons/search') ?>
95                                    </button>
96                                </div>
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="fas fa-arrow-left wt-icon-flip-rtl" title="<?= I18N::translate('previous') ?>"></i>',
158                    next: '<i class="fas fa-arrow-right wt-icon-flip-rtl" title="<?= I18N::translate('next') ?>"></i>',
159                    slideshowStart: '<i class="fas fa-play" title="<?= I18N::translate('Play') ?>"></i>',
160                    slideshowStop: '<i class="fas fa-stop" title="<?= I18N::translate('Stop') ?>"></i>',
161                    close: '<i class="fas 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                    // Add wheelzoom to the displayed image
170                    onComplete: function () {
171                        // Disable click on image triggering next image
172                        // https://github.com/jackmoore/colorbox/issues/668
173                        $(".cboxPhoto").unbind("click");
174                        // Enable wheel/pinch zooming
175                        $('.cboxPhoto').wrap("<pinch-zoom></pinch-zoom>");
176                    }
177                });
178            });
179        </script>
180
181        <?= View::stack('javascript') ?>
182
183        <?= app(ModuleService::class)->findByInterface(ModuleGlobalInterface::class)->map(static function (ModuleGlobalInterface $module): string {
184            return $module->bodyContent();
185        })->implode('') ?>
186
187        <?= DebugBar::render() ?>
188    </body>
189</html>
190