Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 61 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| OlzHeaderWithoutRouting | |
0.00% |
0 / 61 |
|
0.00% |
0 / 1 |
72 | |
0.00% |
0 / 1 |
| getHtml | |
0.00% |
0 / 61 |
|
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\Session; |
| 9 | |
| 10 | /** @extends OlzComponent<array<string, mixed>> */ |
| 11 | class OlzHeaderWithoutRouting extends OlzComponent { |
| 12 | public function getHtml(mixed $args): string { |
| 13 | global $_SESSION; |
| 14 | |
| 15 | Session::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 | $bot_regexes_json = json_encode($this->httpUtils()->getBotRegexes()); |
| 36 | |
| 37 | $html_title = "OL Zimmerberg"; |
| 38 | if (isset($args['title'])) { |
| 39 | $title_arg = htmlspecialchars($args['title']); |
| 40 | $html_title = "{$title_arg} - OL Zimmerberg"; |
| 41 | } |
| 42 | $html_description = ""; |
| 43 | if (isset($args['description'])) { |
| 44 | $description_arg = htmlspecialchars(str_replace("\n", " ", $args['description'])); |
| 45 | $html_description = "<meta name='Description' content='{$description_arg}'>"; |
| 46 | } |
| 47 | $html_canonical = ""; |
| 48 | if (isset($args['canonical_url'])) { |
| 49 | $host = str_replace(['www.', '/'], ['', ''], $_SERVER['HTTP_HOST']); |
| 50 | $canonical_url = "https://{$host}{$args['canonical_url']}"; |
| 51 | $esc_canonical_url = htmlspecialchars($canonical_url); |
| 52 | $html_canonical = "<link rel='canonical' href='{$esc_canonical_url}'/>"; |
| 53 | } |
| 54 | $no_robots = isset($_GET['archiv']) || ($args['norobots'] ?? false); |
| 55 | $robots_html = $no_robots ? "<meta name='robots' content='noindex, nofollow'>" : ""; |
| 56 | $olz_organization_data = OlzOrganizationData::render([], $this); |
| 57 | $additional_headers = implode("\n", $args['additional_headers'] ?? []); |
| 58 | $header_bar = OlzHeaderBar::render([ |
| 59 | 'back_link' => $args['back_link'] ?? null, |
| 60 | 'skip_auth_menu' => $args['skip_auth_menu'] ?? false, |
| 61 | ], $this); |
| 62 | |
| 63 | return <<<ZZZZZZZZZZ |
| 64 | <!DOCTYPE html> |
| 65 | <html lang='de'> |
| 66 | <head> |
| 67 | <meta http-equiv='cache-control' content='public'> |
| 68 | <meta http-equiv='content-type' content='text/html;charset=utf-8'> |
| 69 | <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'> |
| 70 | {$html_description} |
| 71 | <meta name='Content-Language' content='de'> |
| 72 | {$robots_html} |
| 73 | <meta name='viewport' content='width=device-width, initial-scale=1.0'> |
| 74 | <title>{$html_title}</title> |
| 75 | <link rel='icon' href='{$code_href}favicon.ico' type='image/x-icon' /> |
| 76 | {$html_canonical} |
| 77 | {$olz_organization_data} |
| 78 | {$additional_headers} |
| 79 | <link rel='stylesheet' href='{$css_href}' /> |
| 80 | <script type='text/javascript'> |
| 81 | window.olzCodeHref = {$code_href_json}; |
| 82 | window.olzDataHref = {$data_href_json}; |
| 83 | window.olzUser = {$user_json}; |
| 84 | window.olzIsoNow = {$iso_now_json}; |
| 85 | window.olzBotRegexes = {$bot_regexes_json}; |
| 86 | </script> |
| 87 | <script type='text/javascript' src='{$js_href}' onload='olz.loaded()'></script> |
| 88 | </head> |
| 89 | <body class='olz-override-root'> |
| 90 | <a name='top'></a> |
| 91 | {$header_bar} |
| 92 | <div class='site-container'> |
| 93 | <div class='site-background'> |
| 94 | ZZZZZZZZZZ; |
| 95 | } |
| 96 | } |