xref: /web-php/include/header.inc (revision b62f99f6)
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</head>
95<body class="<?php echo $curr; ?> <?php echo $classes; ?>">
96
97<nav class="navbar navbar-fixed-top">
98  <div class="navbar__inner">
99    <a href="/" aria-label="PHP Home" class="navbar__brand">
100      <img
101        src="/images/logos/php-logo-white.svg"
102        aria-hidden="true"
103        width="80"
104        height="40"
105      >
106    </a>
107
108    <div
109      id="navbar__offcanvas"
110      tabindex="-1"
111      class="navbar__offcanvas"
112      aria-label="Menu"
113    >
114      <button
115        id="navbar__close-button"
116        class="navbar__icon-item navbar_icon-item--visually-aligned navbar__close-button"
117      >
118        <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>
119      </button>
120
121      <ul class="navbar__nav">
122        <?php foreach (get_nav_items() as $entry): ?>
123          <?php
124            $isActive = $curr == $entry->id;
125            $activeClass = $isActive ? 'navbar__link--active' : '';
126            $releaseClass = $entry->image ? 'navbar__release' : '';
127          ?>
128          <li class="navbar__item">
129              <a
130                href="<?= $entry->href ?>"
131                <?= $isActive ? 'aria-current="page"' : '' ?>
132                class="navbar__link <?= "$activeClass $releaseClass" ?>"
133              >
134                <?php if ($entry->image): ?>
135                  <img src="<?= $entry->image ?>" alt="<?= $entry->name ?>">
136                <?php else: ?>
137                  <?= $entry->name ?>
138                <?php endif; ?>
139              </a>
140          </li>
141        <?php endforeach; ?>
142      </ul>
143    </div>
144
145    <div class="navbar__right">
146      <?php
147          // https://feathericons.com search
148          $searchIcon = <<<SVG
149          <svg
150            xmlns="http://www.w3.org/2000/svg"
151            aria-hidden="true"
152            width="24"
153            viewBox="0 0 24 24"
154            fill="none"
155            stroke="currentColor"
156            stroke-width="2"
157            stroke-linecap="round"
158            stroke-linejoin="round"
159          >
160            <circle cx="11" cy="11" r="8"></circle>
161            <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
162          </svg>
163          SVG;
164
165          // https://pictogrammers.com/library/mdi/icon/menu/
166          $menuIcon = <<<SVG
167          <svg xmlns="http://www.w3.org/2000/svg"
168            aria-hidden="true"
169            width="24"
170            viewBox="0 0 24 24"
171            fill="currentColor"
172          >
173            <path d="M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z" />
174          </svg>
175          SVG;
176      ?>
177
178      <!-- Desktop default search -->
179      <form
180        action="/manual-lookup.php"
181        class="navbar__search-form"
182      >
183        <label for="navbar__search-input" aria-label="Search docs">
184          <?= $searchIcon ?>
185        </label>
186        <input
187          type="search"
188          name="pattern"
189          id="navbar__search-input"
190          class="navbar__search-input"
191          placeholder="Search docs"
192          accesskey="s"
193        >
194        <input type="hidden" name="scope" value="quickref">
195      </form>
196
197      <!-- Desktop encanced search -->
198      <button
199        id="navbar__search-button"
200        class="navbar__search-button"
201        hidden
202      >
203        <?= $searchIcon ?>
204        Search docs
205      </button>
206
207      <!-- Mobile default items -->
208      <a
209        id="navbar__search-link"
210        href="/lookup-form.php"
211        aria-label="Search docs"
212        class="navbar__icon-item navbar__search-link"
213      >
214        <?= $searchIcon ?>
215      </a>
216      <a
217        id="navbar__menu-link"
218        href="/menu.php"
219        aria-label="Menu"
220        class="navbar__icon-item navbar_icon-item--visually-aligned navbar_menu-link"
221      >
222        <?= $menuIcon ?>
223      </a>
224
225      <!-- Mobile enhanced items -->
226      <button
227        id="navbar__search-button-mobile"
228        aria-label="Search docs"
229        class="navbar__icon-item navbar__search-button-mobile"
230        hidden
231      >
232        <?= $searchIcon ?>
233      </button>
234      <button
235        id="navbar__menu-button"
236        aria-label="Menu"
237        class="navbar__icon-item navbar_icon-item--visually-aligned"
238        hidden
239      >
240        <?= $menuIcon ?>
241      </button>
242    </div>
243
244    <div
245      id="navbar__backdrop"
246      class="navbar__backdrop"
247    ></div>
248  </div>
249
250  <div id="flash-message"></div>
251</nav>
252<?php if (!empty($config["headsup"])): ?>
253<div class="headsup"><?php echo $config["headsup"]?></div>
254<?php endif ?>
255<nav id="trick"><div><?php doc_toc("en") ?></div></nav>
256<div id="goto">
257    <div class="search">
258         <div class="text"></div>
259         <div class="results"><ul></ul></div>
260   </div>
261</div>
262
263<?php if (!empty($config['breadcrumbs'])): ?>
264  <div id="breadcrumbs" class="clearfix">
265    <div id="breadcrumbs-inner">
266    <?php if (isset($config['next'])): ?>
267      <div class="next">
268        <a href="<?php echo $config['next'][0]; ?>">
269          <?php echo $config['next'][1]; ?> &raquo;
270        </a>
271      </div>
272    <?php endif; ?>
273    <?php if (isset($config['prev'])): ?>
274      <div class="prev">
275        <a href="<?php echo $config['prev'][0]; ?>">
276          &laquo; <?php echo $config['prev'][1]; ?>
277        </a>
278      </div>
279    <?php endif; ?>
280      <ul>
281      <?php
282          $breadcrumbs = $config['breadcrumbs'];
283          $last = array_pop($breadcrumbs);
284          foreach ($breadcrumbs as $crumb) {
285              echo "      <li><a href='{$crumb['link']}'>{$crumb['title']}</a></li>";
286          }
287          echo "      <li><a href='{$last['link']}'>{$last['title']}</a></li>";
288
289      ?>
290      </ul>
291    </div>
292  </div>
293<?php endif; ?>
294
295
296<?php if (!empty($config['intro'])):?>
297<div id="intro" class="clearfix">
298  <div class="container">
299    <?php echo $config['intro'];?>
300  </div>
301</div>
302<?php endif;?>
303
304
305<div id="layout" class="clearfix">
306  <section id="layout-content">
307