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