-
Notifications
You must be signed in to change notification settings - Fork 347
/
layout.phtml
176 lines (165 loc) · 7.57 KB
/
layout.phtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?=$this->doctype()?>
<?php
// Set up the search box -- there are three possible cases:
// 1. No search box was set; we should default to the normal box
// 2. It was set to false; we should display nothing
// 3. It is set to a custom string; we should display the provided version
// Set up default search box if no data was provided from the template;
// this covers case 1. Cases 2 and 3 are then covered by logic below.
// Note: The searchbox needs to be rendered before the HTML header is build.
// Otherwise, the Javascript will not be loaded correctly.
if (!isset($this->layout()->searchbox)) {
$this->layout()->searchbox = $this->context($this)->renderInContext('search/searchbox.phtml', []);
}
?>
<html lang="<?=$this->layout()->userLang?>"<?php if ($this->layout()->rtl): ?> dir="rtl"<?php endif; ?>>
<head>
<?php $this->setupThemeResources(); ?>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<?=$this->headMeta()?>
<?=$this->googleTagManager()->getHeadCode()?>
<?php
// Format the page title using the translation system:
$siteConfig = $this->config()->get('config')->Site;
// Disabled escaping of title temporarily so that we get it unescaped first:
$this->headTitle()->setAutoEscape(false);
$fullTitle = $this->translate(
'title_wrapper',
[
'%%pageTitle%%' => $this->headTitle()->renderTitle(),
'%%siteTitle%%' => $siteConfig->title,
'%%titleSeparator%%' => $siteConfig->titleSeparator ?? '::',
]
);
// Enable escaping again for proper output:
$this->headTitle()->setAutoEscape(true);
echo $this->headTitle($fullTitle, \Laminas\View\Helper\Placeholder\Container\AbstractContainer::SET);
// Set up OpenSearch link:
$this->headLink(
[
'href' => $this->url('search-opensearch') . '?method=describe',
'type' => 'application/opensearchdescription+xml',
'title' => $this->transEsc('Library Catalog Search'),
'rel' => 'search',
]
);
// We need to generate the icons early, because they may add some stylesheets;
// if we render them after the headLink / headStyle calls, some dependencies
// may not load correctly. Thus, we render early, but use this later.
$icons = !isset($this->renderingError) ? $this->render('js-icons.phtml') : '{}';
?>
<?php if ($this->layout()->rtl) {
// RTL styling
$this->headLink()->appendStylesheet('vendor/bootstrap-rtl.min.css');
} ?>
<?=$this->headLink()?>
<?=$this->headStyle()?>
<?php
// Collect small scripts together and append as one block:
$appendScripts = [];
if (!isset($this->renderingError)) {
// Deal with cart stuff:
$cart = $this->cart();
if ($cart->isActive()) {
$this->headScript()->appendFile('vendor/js.cookie.js');
$this->headScript()->appendFile('cart.js');
if ($domain = $cart->getCookieDomain()) {
$appendScripts[] = 'VuFind.cart.setDomain("' . $domain . '");';
}
if ($cookiePath = $cart->getCookiePath()) {
$appendScripts[] = 'VuFind.cart.setCookiePath("' . $cookiePath . '");';
}
if ($cookieSameSite = $cart->getCookieSameSite()) {
$appendScripts[] = 'VuFind.cart.setCookieSameSite("' . $cookieSameSite . '");';
}
}
$this->headScript()->prependScript(
'var userIsLoggedIn = ' . ($this->auth()->getIdentity() ? 'true' : 'false') . ';'
);
}
// Session keep-alive
if ($this->keepAlive()) {
$appendScripts[] = 'var keepAliveInterval = ' . $this->keepAlive() . ';';
$this->headScript()->appendFile('keep_alive.js');
}
// If account ajax is active, load script and add language strings
$account = $this->auth()->getManager();
if ($account->ajaxEnabled()) {
$this->headScript()->appendFile('account_ajax.js');
if ($this->session()->put('reset_account_status', null)) {
$this->headScript()->setAllowArbitraryAttributes(true);
$this->headScript()->appendScript('VuFind.account.clearAllCaches();', 'text/javascript', ['data-lightbox-run' => 'always']);
}
}
$root = rtrim($this->url('home'), '/');
$jsConfig = !isset($this->renderingError) ? $this->render('js-configs.phtml') : '{}';
$translations = !isset($this->renderingError) ? $this->render('js-translations.phtml') : '{}';
$dsb = DEFAULT_SEARCH_BACKEND;
$cspNonce = $this->csp()->getNonce();
$searchId = json_encode($this->layout()->searchId);
$appendScripts[] = <<<JS
VuFind.path = '{$root}';
VuFind.defaultSearchBackend = '{$dsb}';
VuFind.config.add({$jsConfig});
VuFind.addTranslations({$translations});
VuFind.addIcons({$icons});
VuFind.setCspNonce('{$cspNonce}');
VuFind.setCurrentSearchId($searchId);
JS;
if (!empty($lightboxParent)) {
$lightboxParent = json_encode((string)$lightboxParent);
$appendScripts[] = 'VuFind.lightbox.parent = ' . $lightboxParent;
}
if (!empty($lightboxChild)) {
$lightboxChild = json_encode((string)$lightboxChild);
$appendScripts[] = 'VuFind.lightbox.child = ' . $lightboxChild;
}
$this->headScript()->appendScript(implode("\n", $appendScripts));
if ($this->config()->ajaxCoversEnabled()) {
$this->headScript()->appendFile('covers.js');
}
?>
<?=$this->cookieConsent()->render()?>
<?=$this->headScript() ?>
</head>
<body class="template-dir-<?=$this->templateDir?> template-name-<?=$this->templateName?> <?=$this->layoutClass('offcanvas-row')?><?php if ($this->layout()->rtl): ?> rtl<?php endif; ?>">
<header class="hidden-print">
<?php if (isset($this->layout()->srmessage)): // message for benefit of screen-reader users ?>
<span class="sr-only" role="heading" aria-level="1"><?=$this->layout()->srmessage ?></span>
<?php endif; ?>
<a class="sr-only sr-only-focusable" href="#content"><?=$this->transEsc('Skip to content') ?></a>
<?=$this->render('header.phtml')?>
</header>
<?php if (($this->layout()->showBreadcrumbs ?? true) && $this->layout()->breadcrumbs !== false): ?>
<nav class="breadcrumbs" aria-label="<?=$this->transEscAttr('Breadcrumbs') ?>">
<div class="container">
<ul class="breadcrumb hidden-print"><?=$this->layout()->breadcrumbs ?></ul>
</div>
</nav>
<?php endif; ?>
<div role="main" class="main">
<div id="content" class="container">
<?=$this->layout()->content ?>
</div>
</div>
<?=$this->render('footer.phtml')?>
<!-- MODAL IN CASE WE NEED ONE -->
<div id="modal" class="modal fade hidden-print" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<button type="button" class="close" data-dismiss="modal">
<?=$this->icon('lightbox-close', ['aria-label' => $this->transEscAttr('Close')]) ?>
</button>
<div class="modal-body"></div>
</div>
</div>
</div>
<div class="vufind-offcanvas-overlay" data-toggle="vufind-offcanvas"></div>
<?=$this->render('Helpers/analytics.phtml')?>
<?php foreach ($this->captcha()->js() as $jsInclude):?>
<?=$this->inlineScript(\Laminas\View\Helper\HeadScript::FILE, $jsInclude, 'SET')?>
<?php endforeach; ?>
<?=$this->footScript() ?>
</body>
</html>