Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 58 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
OlzNewsAktuellKaderblogTile | |
0.00% |
0 / 58 |
|
0.00% |
0 / 2 |
42 | |
0.00% |
0 / 1 |
getRelevance | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getHtml | |
0.00% |
0 / 57 |
|
0.00% |
0 / 1 |
30 |
1 | <?php |
2 | |
3 | // ============================================================================= |
4 | // Zeigt eine Startseiten-Kachel mit kürzlich veröffentlichten News an. |
5 | // ============================================================================= |
6 | |
7 | namespace Olz\Startseite\Components\OlzNewsAktuellKaderblogTile; |
8 | |
9 | use Olz\Entity\News\NewsEntry; |
10 | use Olz\Entity\Users\User; |
11 | use Olz\Startseite\Components\AbstractOlzTile\AbstractOlzTile; |
12 | |
13 | class OlzNewsAktuellKaderblogTile extends AbstractOlzTile { |
14 | public function getRelevance(?User $user): float { |
15 | return 0.65; |
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 | $aktuell_url = $news_utils->getUrl(['format' => 'aktuell']); |
24 | $kaderblog_url = $news_utils->getUrl(['format' => 'kaderblog']); |
25 | $out = <<<ZZZZZZZZZZ |
26 | <h3> |
27 | <a href='{$aktuell_url}&von=startseite'> |
28 | <img src='{$code_href}assets/icns/entry_type_aktuell_20.svg' alt='Aktuell' class='link-icon'> |
29 | Aktuell |
30 | </a> |
31 | & |
32 | <a href='{$kaderblog_url}&von=startseite'> |
33 | <img src='{$code_href}assets/icns/entry_type_kaderblog_20.svg' alt='Kaderblog' class='link-icon'> |
34 | Kaderblog |
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 ('aktuell', 'kaderblog') |
45 | ORDER BY n.published_date DESC, n.published_time DESC |
46 | ZZZZZZZZZZ); |
47 | $query->setMaxResults(4); |
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); |
56 | |
57 | $image = ''; |
58 | $is_image_right = ($index % 2) === 0; |
59 | if (count($image_ids) > 0) { |
60 | $class = $is_image_right ? 'right' : 'left'; |
61 | $olz_image = $this->imageUtils()->olzImage( |
62 | 'news', |
63 | $id, |
64 | $image_ids[0] ?? null, |
65 | 80, |
66 | null, |
67 | ' class="noborder"' |
68 | ); |
69 | $image = "<div class='link-image-{$class}'>{$olz_image}</div>"; |
70 | } |
71 | $image_left = ''; |
72 | $image_right = ''; |
73 | if ($is_image_right) { |
74 | $image_right = $image; |
75 | } else { |
76 | $image_left = $image; |
77 | } |
78 | |
79 | $out .= <<<ZZZZZZZZZZ |
80 | <li> |
81 | <a href='{$code_href}news/{$id}?von=startseite' class='flex min-two-lines aktuell-kaderblog-tile'> |
82 | {$image_left} |
83 | <img src='{$icon}' alt='{$format}' class='link-icon'> |
84 | <div style='flex-grow:1;'> |
85 | <span class='title'>{$title}</span> |
86 | <span class='secondary'>({$date})</span> |
87 | </div> |
88 | {$image_right} |
89 | </a> |
90 | </li> |
91 | ZZZZZZZZZZ; |
92 | |
93 | $index++; |
94 | } |
95 | $out .= "</ul>"; |
96 | |
97 | return $out; |
98 | } |
99 | } |