Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 52 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| OlzPanini2024Params | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | n/a |
0 / 0 |
|||
| OlzPanini2024 | |
0.00% |
0 / 52 |
|
0.00% |
0 / 3 |
42 | |
0.00% |
0 / 1 |
| getSearchTitle | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getSearchResults | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getHtml | |
0.00% |
0 / 50 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Olz\Apps\Panini2024\Components\OlzPanini2024; |
| 4 | |
| 5 | use Olz\Apps\Panini2024\Metadata; |
| 6 | use Olz\Apps\Panini2024\Panini2024Constants; |
| 7 | use Olz\Components\Apps\OlzNoAppAccess\OlzNoAppAccess; |
| 8 | use Olz\Components\Common\OlzRootComponent; |
| 9 | use Olz\Components\Page\OlzFooter\OlzFooter; |
| 10 | use Olz\Components\Page\OlzHeader\OlzHeader; |
| 11 | use Olz\Entity\Panini2024\Panini2024Picture; |
| 12 | use Olz\Utils\HttpParams; |
| 13 | |
| 14 | /** @extends HttpParams<array{}> */ |
| 15 | class OlzPanini2024Params extends HttpParams { |
| 16 | } |
| 17 | |
| 18 | /** @extends OlzRootComponent<array<string, mixed>> */ |
| 19 | class OlzPanini2024 extends OlzRootComponent { |
| 20 | public function getSearchTitle(): string { |
| 21 | return 'TODO'; |
| 22 | } |
| 23 | |
| 24 | public function getSearchResults(array $terms): array { |
| 25 | return []; |
| 26 | } |
| 27 | |
| 28 | public function getHtml(mixed $args): string { |
| 29 | $this->httpUtils()->validateGetParams(OlzPanini2024Params::class); |
| 30 | $current_user = $this->authUtils()->getCurrentUser(); |
| 31 | $code_href = $this->envUtils()->getCodeHref(); |
| 32 | $entity_manager = $this->dbUtils()->getEntityManager(); |
| 33 | $data_path = $this->envUtils()->getDataPath(); |
| 34 | $metadata = new Metadata(); |
| 35 | $now_datetime = new \DateTime($this->dateUtils()->getIsoNow()); |
| 36 | $deadline_datetime = new \DateTime(Panini2024Constants::UPDATE_DEADLINE); |
| 37 | |
| 38 | $has_admin_access = $this->authUtils()->hasPermission('all'); |
| 39 | $is_read_only = ($now_datetime > $deadline_datetime && !$has_admin_access); |
| 40 | |
| 41 | $out = OlzHeader::render([ |
| 42 | 'back_link' => "{$code_href}service/", |
| 43 | 'title' => "Panini '24", |
| 44 | 'norobots' => true, |
| 45 | ]); |
| 46 | |
| 47 | $out .= "<div class='content-full'>"; |
| 48 | |
| 49 | if ($current_user) { |
| 50 | $esc_first_name = json_encode($current_user->getFirstName()); |
| 51 | $esc_last_name = json_encode($current_user->getLastName()); |
| 52 | $esc_panini_2024_picture = json_encode(null); |
| 53 | $esc_is_read_only = json_encode($is_read_only); |
| 54 | $panini_repo = $entity_manager->getRepository(Panini2024Picture::class); |
| 55 | $picture = $panini_repo->findOneBy(['owner_user' => $current_user]); |
| 56 | if ($picture) { |
| 57 | $esc_panini_2024_picture = json_encode([ |
| 58 | 'id' => intval($picture->getId()), |
| 59 | 'line1' => $picture->getLine1(), |
| 60 | 'line2' => $picture->getLine2(), |
| 61 | 'association' => $picture->getAssociation(), |
| 62 | 'imgSrc' => $picture->getImgSrc(), |
| 63 | 'infos' => $picture->getInfos(), |
| 64 | ]); |
| 65 | $portraits_path = "{$data_path}panini_data/portraits/"; |
| 66 | $portrait_path = "{$portraits_path}{$picture->getId()}/{$picture->getImgSrc()}"; |
| 67 | $temp_path = "{$data_path}temp/{$picture->getImgSrc()}"; |
| 68 | copy($portrait_path, $temp_path); |
| 69 | } |
| 70 | $out .= <<<ZZZZZZZZZZ |
| 71 | <script> |
| 72 | window.olzPanini2024FirstName = {$esc_first_name}; |
| 73 | window.olzPanini2024LastName = {$esc_last_name}; |
| 74 | window.olzPanini2024Picture = {$esc_panini_2024_picture}; |
| 75 | window.olzPanini2024IsReadOnly = {$esc_is_read_only}; |
| 76 | </script> |
| 77 | <div id='panini-react-root'> |
| 78 | Lädt... |
| 79 | </div> |
| 80 | ZZZZZZZZZZ; |
| 81 | } else { |
| 82 | $out .= OlzNoAppAccess::render([ |
| 83 | 'app' => $metadata, |
| 84 | ]); |
| 85 | } |
| 86 | |
| 87 | $out .= "</div>"; |
| 88 | |
| 89 | $out .= $metadata->getJsCssImports(); |
| 90 | $out .= OlzFooter::render(); |
| 91 | |
| 92 | return $out; |
| 93 | } |
| 94 | } |