Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 36 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| OlzFilesParams | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | n/a |
0 / 0 |
|||
| OlzFiles | |
0.00% |
0 / 36 |
|
0.00% |
0 / 5 |
56 | |
0.00% |
0 / 1 |
| hasAccess | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| searchSqlWhenHasAccess | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| getPageTitle | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getPageDescription | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getHtmlWhenHasAccess | |
0.00% |
0 / 26 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Olz\Apps\Files\Components\OlzFiles; |
| 4 | |
| 5 | use Olz\Apps\Files\Metadata; |
| 6 | use Olz\Components\Common\OlzRootComponent; |
| 7 | use Olz\Components\Page\OlzFooter\OlzFooter; |
| 8 | use Olz\Components\Page\OlzHeader\OlzHeader; |
| 9 | use Olz\Utils\HttpParams; |
| 10 | |
| 11 | /** @extends HttpParams<array{}> */ |
| 12 | class OlzFilesParams extends HttpParams { |
| 13 | } |
| 14 | |
| 15 | /** @extends OlzRootComponent<array<string, mixed>> */ |
| 16 | class OlzFiles extends OlzRootComponent { |
| 17 | public function hasAccess(): bool { |
| 18 | return (new Metadata())->isAccessibleToUser($this->authUtils()->getCurrentUser()); |
| 19 | } |
| 20 | |
| 21 | public function searchSqlWhenHasAccess(array $terms): string|array|null { |
| 22 | $metadata = new Metadata(); |
| 23 | return $this->searchUtils()->getStaticResultQuery([ |
| 24 | 'link' => $metadata->getHref(), |
| 25 | 'icon' => $metadata->getIconHref(), |
| 26 | 'title' => "Apps: {$this->getPageTitle()}", |
| 27 | 'text' => $this->getPageDescription(), |
| 28 | ], $terms); |
| 29 | } |
| 30 | |
| 31 | public function getPageTitle(): string { |
| 32 | return "Dateien"; |
| 33 | } |
| 34 | |
| 35 | public function getPageDescription(): string { |
| 36 | return ""; |
| 37 | } |
| 38 | |
| 39 | public function getHtmlWhenHasAccess(mixed $args): string { |
| 40 | $this->httpUtils()->validateGetParams(OlzFilesParams::class); |
| 41 | $base_href = $this->envUtils()->getBaseHref(); |
| 42 | $code_href = $this->envUtils()->getCodeHref(); |
| 43 | |
| 44 | $user = $this->authUtils()->getCurrentUser(); |
| 45 | if (!$user) { |
| 46 | $this->httpUtils()->dieWithHttpError(401); |
| 47 | throw new \Exception('should already have failed'); |
| 48 | } |
| 49 | $user_root = $user->getRoot(); |
| 50 | if (!$user_root) { |
| 51 | $this->httpUtils()->dieWithHttpError(403); |
| 52 | throw new \Exception('should already have failed'); |
| 53 | } |
| 54 | |
| 55 | $out = OlzHeader::render([ |
| 56 | 'back_link' => "{$code_href}service/", |
| 57 | 'title' => $this->getPageTitle(), |
| 58 | 'description' => $this->getPageDescription(), |
| 59 | 'norobots' => true, |
| 60 | ]); |
| 61 | |
| 62 | $iframe_url = "{$base_href}/apps/files/artgris/?conf=default&tree=0"; |
| 63 | |
| 64 | $out .= <<<ZZZZZZZZZZ |
| 65 | <div class='content-full'> |
| 66 | <iframe class='files-iframe' src='{$iframe_url}'></iframe> |
| 67 | </div> |
| 68 | ZZZZZZZZZZ; |
| 69 | |
| 70 | $metadata = new Metadata(); |
| 71 | $out .= $metadata->getJsCssImports(); |
| 72 | |
| 73 | $out .= OlzFooter::render(); |
| 74 | |
| 75 | return $out; |
| 76 | } |
| 77 | } |