Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 23 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| OlzHtmlSitemapParams | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | n/a |
0 / 0 |
|||
| OlzHtmlSitemap | |
0.00% |
0 / 23 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| getHtmlWhenHasAccess | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
6 | |||
| getEntry | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Olz\Components\OlzHtmlSitemap; |
| 4 | |
| 5 | use Olz\Components\OlzSitemap\OlzSitemap; |
| 6 | use Olz\Components\Page\OlzFooter\OlzFooter; |
| 7 | use Olz\Components\Page\OlzHeader\OlzHeader; |
| 8 | use Olz\Utils\HttpParams; |
| 9 | |
| 10 | /** @extends HttpParams<array{}> */ |
| 11 | class OlzHtmlSitemapParams extends HttpParams { |
| 12 | } |
| 13 | |
| 14 | class OlzHtmlSitemap extends OlzSitemap { |
| 15 | public static string $title = "Sitemap"; |
| 16 | public static string $description = "Eine Übersicht über alle aktiven Inhalte der Website der OL Zimmerberg."; |
| 17 | |
| 18 | public function getHtmlWhenHasAccess(mixed $args): string { |
| 19 | $this->httpUtils()->validateGetParams(OlzHtmlSitemapParams::class); |
| 20 | |
| 21 | $out = OlzHeader::render([ |
| 22 | 'title' => self::$title, |
| 23 | 'description' => self::$description, |
| 24 | ]); |
| 25 | $out .= "<div class='content-full olz-html-sitemap'>"; |
| 26 | $out .= "<h1>Sitemap</h1>"; |
| 27 | |
| 28 | $entries = $this->getEntries(); |
| 29 | foreach ($entries as $entry) { |
| 30 | $out .= self::getEntry($entry); |
| 31 | } |
| 32 | |
| 33 | $out .= "</div>"; |
| 34 | $out .= OlzFooter::render(); |
| 35 | return $out; |
| 36 | } |
| 37 | |
| 38 | /** @param array{title: string, description: string, url: string, updates: string, importance: float, level: int} $entry */ |
| 39 | private static function getEntry(array $entry): string { |
| 40 | $url = $entry['url']; |
| 41 | $title = $entry['title']; |
| 42 | $description = $entry['description']; |
| 43 | $level = $entry['level']; |
| 44 | return <<<ZZZZZZZZZZ |
| 45 | <div class="entry level-{$level}"> |
| 46 | <a href="{$url}"> |
| 47 | <span class="title">{$title}</span><br /> |
| 48 | <span class="description">{$description}</span> |
| 49 | </a> |
| 50 | </div> |
| 51 | ZZZZZZZZZZ; |
| 52 | } |
| 53 | } |