xref: /webtrees/resources/views/layouts/default.phtml (revision 30e63383b10bafff54347985dcdbd10c40c33f62)
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="sr-only sr-only-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="sr-only" 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                                    <div class="input-group-append">
94                                        <button type="submit" class="btn btn-primary wt-header-search-button">
95                                            <?= view('icons/search') ?>
96                                        </button>
97                                    </div>
98                                </div>
99                            </form>
100                        </div>
101                    <?php endif ?>
102
103                    <div class="col wt-secondary-navigation">
104                        <ul class="nav wt-user-menu">
105                            <?php foreach (app(ModuleThemeInterface::class)->userMenu($tree) as $menu) : ?>
106                                <?= view('components/menu-item', ['menu' => $menu]) ?>
107                            <?php endforeach ?>
108                        </ul>
109                    </div>
110
111                    <?php if ($tree !== null) : ?>
112                        <nav class="col wt-primary-navigation">
113                            <ul class="nav wt-genealogy-menu">
114                                <?php foreach (app(ModuleThemeInterface::class)->genealogyMenu($tree) as $menu) : ?>
115                                    <?= view('components/menu-item', ['menu' => $menu]) ?>
116                                <?php endforeach ?>
117                            </ul>
118                        </nav>
119                    <?php endif ?>
120                </div>
121            </div>
122        </header>
123
124        <main id="content" class="wt-main-wrapper">
125            <div class="container-lg wt-main-container">
126                <div class="flash-messages">
127                    <?php foreach (FlashMessages::getMessages() as $message) : ?>
128                        <div class="alert alert-<?= e($message->status) ?> alert-dismissible" role="alert">
129                            <button type="button" class="close" data-dismiss="alert"
130                                    aria-label="<?= I18N::translate('close') ?>">
131                                <span aria-hidden="true">&times;</span>
132                            </button>
133                            <?= $message->text ?>
134                        </div>
135                    <?php endforeach ?>
136                </div>
137
138                <?= $content ?>
139            </div>
140        </main>
141
142        <footer class="container-lg wt-footers d-print-none">
143            <?= app(ModuleService::class)->findByInterface(ModuleFooterInterface::class)->map(static function (ModuleFooterInterface $module) use ($request): string {
144                return $module->getFooter($request);
145            })->implode('') ?>
146        </footer>
147
148        <script src="<?= e(asset('js/vendor.min.js')) ?>"></script>
149        <script src="<?= e(asset('js/webtrees.min.js')) ?>"></script>
150
151        <script>
152            // Trigger an event when we click on an (any) image
153            $('body').on('click', 'a.gallery', function () {
154                // Enable colorbox for images
155                $("a[type^=image].gallery").colorbox({
156                    // Don't scroll window with document
157                    fixed: true,
158                    width: "85%",
159                    height: "85%",
160                    current: "",
161                    previous: '<i class="fas fa-arrow-left wt-icon-flip-rtl" title="<?= I18N::translate('previous') ?>"></i>',
162                    next: '<i class="fas fa-arrow-right wt-icon-flip-rtl" title="<?= I18N::translate('next') ?>"></i>',
163                    slideshowStart: '<i class="fas fa-play" title="<?= I18N::translate('Play') ?>"></i>',
164                    slideshowStop: '<i class="fas fa-stop" title="<?= I18N::translate('Stop') ?>"></i>',
165                    close: '<i class="fas fa-times" title="<?= I18N::translate('close') ?>"></i>',
166                    title: function () {
167                        return this.dataset.title;
168                    },
169                    photo: true,
170                    rel: "gallery", // Turn all images on the page into a slideshow
171                    slideshow: true,
172                    slideshowAuto: false,
173                    // Add wheelzoom to the displayed image
174                    onComplete: function () {
175                        // Disable click on image triggering next image
176                        // https://github.com/jackmoore/colorbox/issues/668
177                        $(".cboxPhoto").unbind("click");
178                        // Enable wheel/pinch zooming
179                        $('.cboxPhoto').wrap("<pinch-zoom></pinch-zoom>");
180                    }
181                });
182            });
183        </script>
184
185        <?= View::stack('javascript') ?>
186
187        <?= app(ModuleService::class)->findByInterface(ModuleGlobalInterface::class)->map(static function (ModuleGlobalInterface $module): string {
188            return $module->bodyContent();
189        })->implode('') ?>
190
191        <?= DebugBar::render() ?>
192    </body>
193</html>
194