xref: /webtrees/resources/views/layouts/default.phtml (revision 439bf5cf1289938b542fc78d5ee56a8ac6ea533d)
1<?php
2
3use Fisharebest\Webtrees\DebugBar;
4use Fisharebest\Webtrees\FlashMessages;
5use Fisharebest\Webtrees\Http\RequestHandlers\SearchQuickAction;
6use Fisharebest\Webtrees\Http\RequestHandlers\WebmanifestJson;
7use Fisharebest\Webtrees\I18N;
8use Fisharebest\Webtrees\Module\ModuleFooterInterface;
9use Fisharebest\Webtrees\Module\ModuleGlobalInterface;
10use Fisharebest\Webtrees\Module\ModuleThemeInterface;
11use Fisharebest\Webtrees\Services\ModuleService;
12use Fisharebest\Webtrees\Tree;
13use Fisharebest\Webtrees\View;
14use Fisharebest\Webtrees\Webtrees;
15use Psr\Http\Message\ServerRequestInterface;
16
17/**
18 * @var string                 $content
19 * @var ServerRequestInterface $request
20 * @var string                 $title
21 * @var Tree                   $tree
22 */
23
24?>
25
26<!DOCTYPE html>
27<html dir="<?= I18N::locale()->direction() ?>" lang="<?= I18N::locale()->languageTag() ?>">
28    <head>
29        <meta charset="UTF-8">
30        <meta name="csrf" content="<?= e(csrf_token()) ?>">
31        <meta name="viewport" content="width=device-width, initial-scale=1">
32        <meta name="robots" content="<?= e($meta_robots ?? 'noindex') ?>">
33        <meta name="generator" content="<?= e(Webtrees::NAME) ?> <?= e(Webtrees::VERSION) ?>">
34        <meta name="description" content="<?= $meta_description ?? '' ?>">
35
36        <title>
37            <?= strip_tags($title) ?>
38            <?php if ($tree !== null && $tree->getPreference('META_TITLE') !== '') : ?>
39<?= e($tree->getPreference('META_TITLE')) ?>
40            <?php endif ?>
41        </title>
42
43        <!--iOS-->
44        <link rel="apple-touch-icon" sizes="180x180" href="<?= e(asset('apple-touch-icon.png')) ?>">
45        <!--Generic favicons-->
46        <link rel="icon" sizes="32x32" href="<?= e(asset('favicon-32.png')) ?>">
47        <link rel="icon" sizes="192x192" href="<?= e(asset('favicon-192.png')) ?>">
48        <!--IE11/Edge-->
49        <meta name="msapplication-config" content="<?= e(asset('browserconfig.xml')) ?>">
50
51        <link rel="manifest" href="<?= e(route(WebmanifestJson::class)) ?>">
52
53        <link rel="stylesheet" href="<?= e(asset('css/vendor.min.css')) ?>">
54        <?php foreach (app(ModuleThemeInterface::class)->stylesheets() as $stylesheet) : ?>
55            <link rel="stylesheet" href="<?= e($stylesheet) ?>">
56        <?php endforeach ?>
57
58        <?= View::stack('styles') ?>
59
60        <?= app(ModuleService::class)->findByInterface(ModuleGlobalInterface::class)->map(static function (ModuleGlobalInterface $module): string {
61            return $module->headContent();
62        })->implode('') ?>
63
64        <?= DebugBar::renderHead() ?>
65    </head>
66
67    <body class="wt-global wt-theme-<?= e(app(ModuleThemeInterface::class)->name()) ?> wt-route-<?= e(substr(strrchr($request->getAttribute('route')->name, '\\'),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="sr-only sr-only-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"
84                                  action="<?= e(route(SearchQuickAction::class, ['tree' => $tree->name()])) ?>"
85                                  class="wt-header-search-form" role="search">
86                                <?= csrf_field() ?>
87                                <div class="input-group">
88                                    <label class="sr-only" for="quick-search"><?= I18N::translate('Search') ?></label>
89                                    <input type="search" class="form-control wt-header-search-field" id="quick-search"
90                                           name="query" size="15" placeholder="<?= I18N::translate('Search') ?>">
91                                    <div class="input-group-append">
92                                        <button type="submit" class="btn btn-primary wt-header-search-button">
93                                            <?= view('icons/search') ?>
94                                        </button>
95                                    </div>
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="close" data-dismiss="alert"
128                                    aria-label="<?= I18N::translate('close') ?>">
129                                <span aria-hidden="true">&times;</span>
130                            </button>
131                            <?= $message->text ?>
132                        </div>
133                    <?php endforeach ?>
134                </div>
135
136                <?= $content ?>
137            </div>
138        </main>
139
140        <footer class="container-lg wt-footers d-print-none">
141            <?= app(ModuleService::class)->findByInterface(ModuleFooterInterface::class)->map(static function (ModuleFooterInterface $module) use ($request): string {
142                return $module->getFooter($request);
143            })->implode('') ?>
144        </footer>
145
146        <script src="<?= e(asset('js/vendor.min.js')) ?>"></script>
147        <script src="<?= e(asset('js/webtrees.min.js')) ?>"></script>
148
149        <script>
150            // Trigger an event when we click on an (any) image
151            $('body').on('click', 'a.gallery', function () {
152                // Enable colorbox for images
153                $("a[type^=image].gallery").colorbox({
154                    // Don't scroll window with document
155                    fixed: true,
156                    width: "85%",
157                    height: "85%",
158                    current: "",
159                    previous: '<i class="fas fa-arrow-left wt-icon-flip-rtl" title="<?= I18N::translate('previous') ?>"></i>',
160                    next: '<i class="fas fa-arrow-right wt-icon-flip-rtl" title="<?= I18N::translate('next') ?>"></i>',
161                    slideshowStart: '<i class="fas fa-play" title="<?= I18N::translate('Play') ?>"></i>',
162                    slideshowStop: '<i class="fas fa-stop" title="<?= I18N::translate('Stop') ?>"></i>',
163                    close: '<i class="fas fa-times" title="<?= I18N::translate('close') ?>"></i>',
164                    title: function () {
165                        return this.dataset.title;
166                    },
167                    photo: true,
168                    rel: "gallery", // Turn all images on the page into a slideshow
169                    slideshow: true,
170                    slideshowAuto: false,
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        <?= app(ModuleService::class)->findByInterface(ModuleGlobalInterface::class)->map(static function (ModuleGlobalInterface $module): string {
186            return $module->bodyContent();
187        })->implode('') ?>
188
189        <?= DebugBar::render() ?>
190    </body>
191</html>
192