Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
59.18% covered (warning)
59.18%
29 / 49
80.00% covered (warning)
80.00%
4 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
OlzServiceParams
n/a
0 / 0
n/a
0 / 0
0
n/a
0 / 0
OlzService
59.18% covered (warning)
59.18%
29 / 49
80.00% covered (warning)
80.00%
4 / 5
6.70
0.00% covered (danger)
0.00%
0 / 1
 hasAccess
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 searchSqlWhenHasAccess
100.00% covered (success)
100.00%
26 / 26
100.00% covered (success)
100.00%
1 / 1
1
 getPageTitle
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getPageDescription
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getHtmlWhenHasAccess
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Olz\Service\Components\OlzService;
4
5use Olz\Components\Apps\OlzAppsList\OlzAppsList;
6use Olz\Components\Common\OlzRootComponent;
7use Olz\Components\Page\OlzFooter\OlzFooter;
8use Olz\Components\Page\OlzHeader\OlzHeader;
9use Olz\Service\Components\OlzDownloads\OlzDownloads;
10use Olz\Service\Components\OlzLinks\OlzLinks;
11use Olz\Utils\HttpParams;
12
13/** @extends HttpParams<array{}> */
14class OlzServiceParams extends HttpParams {
15}
16
17/** @extends OlzRootComponent<array<string, mixed>> */
18class OlzService extends OlzRootComponent {
19    public function hasAccess(): bool {
20        return true;
21    }
22
23    public function searchSqlWhenHasAccess(array $terms): string|array|null {
24        $code_href = $this->envUtils()->getCodeHref();
25        $downloads_where = implode(' AND ', array_map(function ($term) {
26            return "name LIKE '%{$term}%'";
27        }, $terms));
28        $links_where = implode(' AND ', array_map(function ($term) {
29            return "(name LIKE '%{$term}%' OR url LIKE '%{$term}%')";
30        }, $terms));
31        // TODO better icons
32        $static_page_query = $this->searchUtils()->getStaticResultQuery([
33            'link' => "{$code_href}karten",
34            'icon' => "{$code_href}assets/icns/link_map_16.svg",
35            'title' => $this->getPageTitle(),
36            'text' => $this->getPageDescription(),
37        ], $terms);
38        return [
39            'with' => $static_page_query['with'],
40            'query' => <<<ZZZZZZZZZZ
41                    SELECT
42                        '{$code_href}service' AS link,
43                        '{$code_href}assets/icns/link_internal_16.svg' AS icon,
44                        NULL AS date,
45                        CONCAT('Download: ', name) AS title,
46                        NULL AS text,
47                        0.9 AS time_relevance
48                    FROM downloads
49                    WHERE
50                        on_off = '1'
51                        AND {$downloads_where}
52                UNION ALL
53                    SELECT
54                        '{$code_href}service' AS link,
55                        '{$code_href}assets/icns/link_internal_16.svg' AS icon,
56                        NULL AS date,
57                        CONCAT('Link: ', name) AS title,
58                        url AS text,
59                        0.9 AS time_relevance
60                    FROM links
61                    WHERE
62                        on_off = '1'
63                        AND {$links_where}
64                UNION ALL
65                    {$static_page_query['query']}
66                ZZZZZZZZZZ,
67        ];
68    }
69
70    public function getPageTitle(): string {
71        return "Service";
72    }
73
74    public function getPageDescription(): string {
75        return "Diverse Online-Tools rund um OL und die OL Zimmerberg.";
76    }
77
78    public function getHtmlWhenHasAccess(mixed $args): string {
79        $this->httpUtils()->validateGetParams(OlzServiceParams::class);
80
81        $out = OlzHeader::render([
82            'title' => $this->getPageTitle(),
83            'description' => $this->getPageDescription(),
84        ]);
85
86        $out .= "<div class='content-full'>";
87
88        $out .= "<h1>Service</h1>";
89        $out .= "<h2>Apps</h2>";
90        $out .= OlzAppsList::render();
91        $out .= "<br /><br />";
92
93        $out .= "<div class='responsive-flex'>";
94        $out .= "<div class='responsive-flex-2'>";
95        $out .= OlzLinks::render();
96        $out .= "</div>";
97        $out .= "<div class='responsive-flex-2'>";
98        $out .= OlzDownloads::render();
99        $out .= "</div></div><br><br>";
100
101        $out .= "</div>";
102
103        $out .= OlzFooter::render();
104
105        return $out;
106    }
107}