Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 50 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
OlzNewsGalerieTile | |
0.00% |
0 / 50 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
getRelevance | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getHtml | |
0.00% |
0 / 49 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | // ============================================================================= |
4 | // Zeigt eine Startseiten-Kachel mit kürzlich veröffentlichten News an. |
5 | // ============================================================================= |
6 | |
7 | namespace Olz\Startseite\Components\OlzNewsGalerieTile; |
8 | |
9 | use Olz\Entity\News\NewsEntry; |
10 | use Olz\Entity\Users\User; |
11 | use Olz\Startseite\Components\AbstractOlzTile\AbstractOlzTile; |
12 | |
13 | class OlzNewsGalerieTile extends AbstractOlzTile { |
14 | public function getRelevance(?User $user): float { |
15 | return 0.55; |
16 | } |
17 | |
18 | public function getHtml(mixed $args): string { |
19 | $entity_manager = $this->dbUtils()->getEntityManager(); |
20 | $code_href = $this->envUtils()->getCodeHref(); |
21 | $news_utils = $this->newsUtils(); |
22 | |
23 | $galerie_url = $news_utils->getUrl(['format' => 'galerie']); |
24 | $video_url = $news_utils->getUrl(['format' => 'video']); |
25 | $out = <<<ZZZZZZZZZZ |
26 | <h3> |
27 | <a href='{$galerie_url}&von=startseite'> |
28 | <img src='{$code_href}assets/icns/entry_type_gallery_20.svg' alt='Galerie' class='link-icon'> |
29 | Galerie |
30 | </a> |
31 | & |
32 | <a href='{$video_url}&von=startseite'> |
33 | <img src='{$code_href}assets/icns/entry_type_movie_20.svg' alt='Video' class='link-icon'> |
34 | Video |
35 | </a> |
36 | </h3> |
37 | ZZZZZZZZZZ; |
38 | |
39 | $out .= "<ul class='links'>"; |
40 | $news_entry_class = NewsEntry::class; |
41 | $query = $entity_manager->createQuery(<<<ZZZZZZZZZZ |
42 | SELECT n |
43 | FROM {$news_entry_class} n |
44 | WHERE n.on_off = '1' and n.format IN ('galerie', 'video') |
45 | ORDER BY n.published_date DESC, n.published_time DESC |
46 | ZZZZZZZZZZ); |
47 | $query->setMaxResults(3); |
48 | $index = 0; |
49 | foreach ($query->getResult() as $news_entry) { |
50 | $id = $news_entry->getId(); |
51 | $date = $this->dateUtils()->compactDate($news_entry->getPublishedDate()); |
52 | $title = $news_entry->getTitle(); |
53 | $format = $news_entry->getFormat(); |
54 | $image_ids = $news_entry->getImageIds(); |
55 | $icon = $this->newsUtils()->getNewsFormatIcon($format, 'white'); |
56 | |
57 | $images = ""; |
58 | for ($i = 0; $i < min(count($image_ids), 3); $i++) { |
59 | $olz_image = $this->imageUtils()->olzImage( |
60 | 'news', |
61 | $id, |
62 | $image_ids[$i], |
63 | 80, |
64 | null, |
65 | ' class="noborder"' |
66 | ); |
67 | $images .= "{$olz_image}"; |
68 | } |
69 | |
70 | $out .= <<<ZZZZZZZZZZ |
71 | <li class='flex gallery min-two-lines'> |
72 | <a href='{$code_href}news/{$id}?von=startseite'> |
73 | <div class='overlay'> |
74 | <img src='{$icon}' alt='{$format}' class='link-icon'> |
75 | <span class='date'>{$date}</span> |
76 | <span class='title'>{$title}</span> |
77 | </div> |
78 | <div class='images'> |
79 | {$images} |
80 | </div> |
81 | </a> |
82 | </li> |
83 | ZZZZZZZZZZ; |
84 | |
85 | $index++; |
86 | } |
87 | $out .= "</ul>"; |
88 | |
89 | return $out; |
90 | } |
91 | } |