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