xref: /web-php/include/header.inc (revision 850039a5)
1<?php
2$css_files = [
3    '/fonts/Fira/fira.css',
4    '/fonts/Font-Awesome/css/fontello.css',
5    '/styles/theme-base.css',
6    '/styles/theme-medium.css',
7];
8
9if (isset($config['css'])) {
10    $css_files = array_merge($css_files, (array) $config['css']);
11}
12if (isset($config["css_overwrite"])) {
13    $css_files = $config["css_overwrite"];
14}
15
16foreach($css_files as $filename) {
17    // files that do not start with / are assumed to be located in the /styles
18    // directory
19    if ($filename[0] !== '/') {
20        $filename = "/styles/$filename";
21    }
22    $path = dirname(__DIR__) . $filename;
23    $CSS[$filename] = @filemtime($path);
24}
25
26if (isset($shortname) && $shortname) {
27    header("Link: <$shorturl>; rel=shorturl");
28}
29
30if ($config["cache"]) {
31    if (is_numeric($config["cache"])) {
32        $timestamp = $config["cache"];
33    } else {
34        $timestamp = filemtime($_SERVER["DOCUMENT_ROOT"] . "/" . $_SERVER["BASE_PAGE"]);
35    }
36    $tsstring = gmdate("D, d M Y H:i:s ", $timestamp) . "GMT";
37
38    if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && $_SERVER["HTTP_IF_MODIFIED_SINCE"] == $tsstring) {
39        header("HTTP/1.1 304 Not Modified");
40        exit;
41    }
42    header("Last-Modified: " . $tsstring);
43}
44if (!isset($config["languages"])) {
45    $config["languages"] = [];
46}
47
48?>
49<!DOCTYPE html>
50<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php echo $lang?>">
51<head>
52
53  <meta charset="utf-8">
54  <meta name="viewport" content="width=device-width, initial-scale=1.0">
55
56  <title>PHP: <?php echo $title ?></title>
57
58 <link rel="icon" type="image/svg+xml" sizes="any" href="<?php echo $MYSITE ?>favicon.svg?v=2">
59 <link rel="icon" type="image/png" sizes="196x196" href="<?php echo $MYSITE ?>favicon-196x196.png?v=2">
60 <link rel="icon" type="image/png" sizes="32x32" href="<?php echo $MYSITE ?>favicon-32x32.png?v=2">
61 <link rel="icon" type="image/png" sizes="16x16" href="<?php echo $MYSITE ?>favicon-16x16.png?v=2">
62 <link rel="shortcut icon" href="<?php echo $MYSITE ?>favicon.ico?v=2">
63
64 <link rel="search" type="application/opensearchdescription+xml" href="http://php.net/phpnetimprovedsearch.src" title="Add PHP.net search">
65 <link rel="alternate" type="application/atom+xml" href="<?php echo $MYSITE ?>releases/feed.php" title="PHP Release feed">
66 <link rel="alternate" type="application/atom+xml" href="<?php echo $MYSITE ?>feed.atom" title="PHP: Hypertext Preprocessor">
67
68<?php if (isset($_SERVER['BASE_PAGE'])): ?>
69 <link rel="canonical" href="https://www.php.net/<?php echo $_SERVER['BASE_PAGE']?>">
70<?php if ($shortname): ?>
71 <link rel="shorturl" href="<?php echo $shorturl ?>">
72 <link rel="alternate" href="<?php echo $shorturl ?>" hreflang="x-default">
73<?php endif ?>
74<?php endif ?>
75
76<?php foreach($config["meta-navigation"] as $rel => $page): ?>
77 <link rel="<?php echo $rel ?>" href="<?php echo $MYSITE ?><?php echo $page ?>">
78<?php endforeach ?>
79
80<?php foreach($config["languages"] as $code): ?>
81 <link rel="alternate" href="<?php echo $MYSITE ?>manual/<?php echo $code?>/<?php echo $config["thispage"] ?>" hreflang="<?php echo $code?>">
82<?php endforeach ?>
83
84<?php foreach($CSS as $filename => $modified): ?>
85<link rel="stylesheet" type="text/css" href="/cached.php?t=<?php echo $modified?>&amp;f=<?php echo $filename?>" media="screen">
86<?php endforeach ?>
87
88<?php if (!empty($_SERVER["BASE_HREF"])): ?>
89 <base href="<?php echo $_SERVER["BASE_HREF"] ?>">
90<?php endif ?>
91
92<?php if (isset($config['meta_tags'])) { echo $config['meta_tags']; } ?>
93
94<?php if (is_primary_site()) { ?>
95<!-- Matomo -->
96<script>
97    var _paq = window._paq = window._paq || [];
98    /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
99    _paq.push(["setDoNotTrack", true]);
100    _paq.push(["disableCookies"]);
101    _paq.push(['trackPageView']);
102    _paq.push(['enableLinkTracking']);
103    (function() {
104        var u="https://analytics.php.net/";
105        _paq.push(['setTrackerUrl', u+'matomo.php']);
106        _paq.push(['setSiteId', '1']);
107        var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
108        g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
109    })();
110</script>
111<!-- End Matomo Code -->
112<?php } ?>
113</head>
114<body class="<?php echo $curr; ?> <?php echo $classes; ?>">
115
116<nav class="navbar navbar-fixed-top">
117  <div class="navbar__inner">
118    <a href="/" aria-label="PHP Home" class="navbar__brand">
119      <img
120        src="/images/logos/php-logo-white.svg"
121        aria-hidden="true"
122        width="80"
123        height="40"
124      >
125    </a>
126
127    <div
128      id="navbar__offcanvas"
129      tabindex="-1"
130      class="navbar__offcanvas"
131      aria-label="Menu"
132    >
133      <button
134        id="navbar__close-button"
135        class="navbar__icon-item navbar_icon-item--visually-aligned navbar__close-button"
136      >
137        <svg xmlns="http://www.w3.org/2000/svg" width="24" viewBox="0 0 24 24" fill="currentColor"><path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" /></svg>
138      </button>
139
140      <ul class="navbar__nav">
141        <?php foreach (get_nav_items() as $entry): ?>
142          <?php
143            $isActive = $curr == $entry->id;
144            $activeClass = $isActive ? 'navbar__link--active' : '';
145            $releaseClass = $entry->image ? 'navbar__release' : '';
146          ?>
147          <li class="navbar__item">
148              <a
149                href="<?= $entry->href ?>"
150                <?= $isActive ? 'aria-current="page"' : '' ?>
151                class="navbar__link <?= "$activeClass $releaseClass" ?>"
152              >
153                <?php if ($entry->image): ?>
154                  <img src="<?= $entry->image ?>" alt="<?= $entry->name ?>">
155                <?php else: ?>
156                  <?= $entry->name ?>
157                <?php endif; ?>
158              </a>
159          </li>
160        <?php endforeach; ?>
161      </ul>
162    </div>
163
164    <div class="navbar__right">
165      <?php
166          // https://feathericons.com search
167          $searchIcon = <<<SVG
168          <svg
169            xmlns="http://www.w3.org/2000/svg"
170            aria-hidden="true"
171            width="24"
172            viewBox="0 0 24 24"
173            fill="none"
174            stroke="currentColor"
175            stroke-width="2"
176            stroke-linecap="round"
177            stroke-linejoin="round"
178          >
179            <circle cx="11" cy="11" r="8"></circle>
180            <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
181          </svg>
182          SVG;
183
184          // https://pictogrammers.com/library/mdi/icon/menu/
185          $menuIcon = <<<SVG
186          <svg xmlns="http://www.w3.org/2000/svg"
187            aria-hidden="true"
188            width="24"
189            viewBox="0 0 24 24"
190            fill="currentColor"
191          >
192            <path d="M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z" />
193          </svg>
194          SVG;
195      ?>
196
197      <!-- Desktop default search -->
198      <form
199        action="/manual-lookup.php"
200        class="navbar__search-form"
201      >
202        <label for="navbar__search-input" aria-label="Search docs">
203          <?= $searchIcon ?>
204        </label>
205        <input
206          type="search"
207          name="pattern"
208          id="navbar__search-input"
209          class="navbar__search-input"
210          placeholder="Search docs"
211          accesskey="s"
212        >
213        <input type="hidden" name="scope" value="quickref">
214      </form>
215
216      <!-- Desktop encanced search -->
217      <button
218        id="navbar__search-button"
219        class="navbar__search-button"
220        hidden
221      >
222        <?= $searchIcon ?>
223        Search docs
224      </button>
225
226      <!-- Mobile default items -->
227      <a
228        id="navbar__search-link"
229        href="/lookup-form.php"
230        aria-label="Search docs"
231        class="navbar__icon-item navbar__search-link"
232      >
233        <?= $searchIcon ?>
234      </a>
235      <a
236        id="navbar__menu-link"
237        href="/menu.php"
238        aria-label="Menu"
239        class="navbar__icon-item navbar_icon-item--visually-aligned navbar_menu-link"
240      >
241        <?= $menuIcon ?>
242      </a>
243
244      <!-- Mobile enhanced items -->
245      <button
246        id="navbar__search-button-mobile"
247        aria-label="Search docs"
248        class="navbar__icon-item navbar__search-button-mobile"
249        hidden
250      >
251        <?= $searchIcon ?>
252      </button>
253      <button
254        id="navbar__menu-button"
255        aria-label="Menu"
256        class="navbar__icon-item navbar_icon-item--visually-aligned"
257        hidden
258      >
259        <?= $menuIcon ?>
260      </button>
261    </div>
262
263    <div
264      id="navbar__backdrop"
265      class="navbar__backdrop"
266    ></div>
267  </div>
268
269  <div id="flash-message"></div>
270</nav>
271<?php if (!empty($config["headsup"])): ?>
272<div class="headsup"><?php echo $config["headsup"]?></div>
273<?php endif ?>
274<nav id="trick"><div><?php doc_toc("en") ?></div></nav>
275<div id="goto">
276    <div class="search">
277         <div class="text"></div>
278         <div class="results"><ul></ul></div>
279   </div>
280</div>
281
282<?php if (!empty($config['breadcrumbs'])): ?>
283  <div id="breadcrumbs" class="clearfix">
284    <div id="breadcrumbs-inner">
285    <?php if (isset($config['next'])): ?>
286      <div class="next">
287        <a href="<?php echo $config['next'][0]; ?>">
288          <?php echo $config['next'][1]; ?> &raquo;
289        </a>
290      </div>
291    <?php endif; ?>
292    <?php if (isset($config['prev'])): ?>
293      <div class="prev">
294        <a href="<?php echo $config['prev'][0]; ?>">
295          &laquo; <?php echo $config['prev'][1]; ?>
296        </a>
297      </div>
298    <?php endif; ?>
299      <ul>
300      <?php
301          $breadcrumbs = $config['breadcrumbs'];
302          $last = array_pop($breadcrumbs);
303          foreach ($breadcrumbs as $crumb) {
304              echo "      <li><a href='{$crumb['link']}'>{$crumb['title']}</a></li>";
305          }
306          echo "      <li><a href='{$last['link']}'>{$last['title']}</a></li>";
307
308      ?>
309      </ul>
310    </div>
311  </div>
312<?php endif; ?>
313
314
315<?php if (!empty($config['intro'])):?>
316<div id="intro" class="clearfix">
317  <div class="container">
318    <?php echo $config['intro'];?>
319  </div>
320</div>
321<?php endif;?>
322
323
324<div id="layout" class="clearfix">
325  <section id="layout-content">
326