Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 59 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
OlzHeaderWithoutRouting | |
0.00% |
0 / 59 |
|
0.00% |
0 / 1 |
72 | |
0.00% |
0 / 1 |
getHtml | |
0.00% |
0 / 59 |
|
0.00% |
0 / 1 |
72 |
1 | <?php |
2 | |
3 | namespace Olz\Components\Page\OlzHeaderWithoutRouting; |
4 | |
5 | use Olz\Components\Common\OlzComponent; |
6 | use Olz\Components\Page\OlzHeaderBar\OlzHeaderBar; |
7 | use Olz\Components\Schema\OlzOrganizationData\OlzOrganizationData; |
8 | use Olz\Utils\StandardSession; |
9 | |
10 | /** @extends OlzComponent<array<string, mixed>> */ |
11 | class OlzHeaderWithoutRouting extends OlzComponent { |
12 | public function getHtml(mixed $args): string { |
13 | global $_SESSION; |
14 | |
15 | StandardSession::session_start_if_cookie_set(); |
16 | |
17 | $code_href = $this->envUtils()->getCodeHref(); |
18 | $data_href = $this->envUtils()->getDataHref(); |
19 | $data_path = $this->envUtils()->getDataPath(); |
20 | $css_path = "{$data_path}jsbuild/olz/main.min.css"; |
21 | $js_path = "{$data_path}jsbuild/olz/main.min.js"; |
22 | $css_modified = is_file($css_path) ? filemtime($css_path) : 0; |
23 | $js_modified = is_file($js_path) ? filemtime($js_path) : 0; |
24 | $css_href = "/jsbuild/olz/main.min.css?modified={$css_modified}"; |
25 | $js_href = "/jsbuild/olz/main.min.js?modified={$js_modified}"; |
26 | $code_href_json = json_encode($code_href); |
27 | $data_href_json = json_encode($data_href); |
28 | $user_json = json_encode([ |
29 | 'permissions' => $_SESSION['auth'] ?? null, |
30 | 'root' => $_SESSION['root'] ?? null, |
31 | 'username' => $_SESSION['user'] ?? null, |
32 | 'id' => intval($_SESSION['user_id'] ?? null), |
33 | ]); |
34 | $iso_now_json = json_encode($this->dateUtils()->getIsoNow()); |
35 | |
36 | $html_title = "OL Zimmerberg"; |
37 | if (isset($args['title'])) { |
38 | $title_arg = htmlspecialchars($args['title']); |
39 | $html_title = "{$title_arg} - OL Zimmerberg"; |
40 | } |
41 | $html_description = ""; |
42 | if (isset($args['description'])) { |
43 | $description_arg = htmlspecialchars(str_replace("\n", " ", $args['description'])); |
44 | $html_description = "<meta name='Description' content='{$description_arg}'>"; |
45 | } |
46 | $html_canonical = ""; |
47 | if (isset($args['canonical_url'])) { |
48 | $host = str_replace(['www.', '/'], ['', ''], $_SERVER['HTTP_HOST']); |
49 | $canonical_url = "https://{$host}{$args['canonical_url']}"; |
50 | $esc_canonical_url = htmlspecialchars($canonical_url); |
51 | $html_canonical = "<link rel='canonical' href='{$esc_canonical_url}'/>"; |
52 | } |
53 | $no_robots = isset($_GET['archiv']) || ($args['norobots'] ?? false); |
54 | $robots_html = $no_robots ? "<meta name='robots' content='noindex, nofollow'>" : ""; |
55 | $olz_organization_data = OlzOrganizationData::render([], $this); |
56 | $additional_headers = implode("\n", $args['additional_headers'] ?? []); |
57 | $header_bar = OlzHeaderBar::render([ |
58 | 'back_link' => $args['back_link'] ?? null, |
59 | 'skip_auth_menu' => $args['skip_auth_menu'] ?? false, |
60 | ], $this); |
61 | |
62 | return <<<ZZZZZZZZZZ |
63 | <!DOCTYPE html> |
64 | <html lang='de'> |
65 | <head> |
66 | <meta http-equiv='cache-control' content='public'> |
67 | <meta http-equiv='content-type' content='text/html;charset=utf-8'> |
68 | <meta name='Keywords' content='OL, Orientierungslauf, Sport, Laufsport, Gruppe, Klub, Verein, Zimmerberg, linkes Zürichseeufer, Sihltal, Kilchberg, Rüschlikon, Thalwil, Gattikon, Oberrieden, Horgen, Au ZH, Wädenswil, Richterswil, Schönenberg, Hirzel, Langnau am Albis, Adliswil, Stadt Zürich, Leimbach, Wollishofen, Enge, Friesenberg, Üetliberg, Entlisberg, Albis, Buchenegg, Landforst, Kopfholz, Chopfholz, Reidholz, Schweiz, OLZ, OLG'> |
69 | {$html_description} |
70 | <meta name='Content-Language' content='de'> |
71 | {$robots_html} |
72 | <meta name='viewport' content='width=device-width, initial-scale=1.0'> |
73 | <title>{$html_title}</title> |
74 | <link rel='icon' href='{$code_href}favicon.ico' type='image/x-icon' /> |
75 | {$html_canonical} |
76 | {$olz_organization_data} |
77 | {$additional_headers} |
78 | <link rel='stylesheet' href='{$css_href}' /> |
79 | <script type='text/javascript'> |
80 | window.olzCodeHref = {$code_href_json}; |
81 | window.olzDataHref = {$data_href_json}; |
82 | window.olzUser = {$user_json}; |
83 | window.olzIsoNow = {$iso_now_json}; |
84 | </script> |
85 | <script type='text/javascript' src='{$js_href}' onload='olz.loaded()'></script> |
86 | </head> |
87 | <body class='olz-override-root'> |
88 | <a name='top'></a> |
89 | {$header_bar} |
90 | <div class='site-container'> |
91 | <div class='site-background'> |
92 | ZZZZZZZZZZ; |
93 | } |
94 | } |