ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilPDObjectsTileRenderer.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
3
5
10{
14 public function render(array $groupedItems, bool $showHeader) : string
15 {
16 $tpl = new ilTemplate('tpl.block_tiles.html', true, true, 'Services/Dashboard');
17
18 $itemRendered = false;
19
20 foreach ($groupedItems as $group) {
21 $items = $group->getItems();
22 if (count($items) > 0) {
23 $cards = [];
24 foreach ($group->getItems() as $item) {
25 $c = $this->getCard($item);
26 if ($c !== null) {
27 $cards[] = $c;
28 }
29 }
30
31 $tpl->setCurrentBlock('head');
32 $tpl->setVariable('HEAD', $group->getLabel());
33 $tpl->parseCurrentBlock();
34
35 $deck = $this->uiFactory
36 ->deck($cards)
37 ->withNormalCardsSize();
38
39 $tpl->setCurrentBlock('tiles');
40 if ($this->ctrl->isAsynch()) {
41 $tpl->setVariable('TILES', $this->uiRenderer->renderAsync($deck));
42 } else {
43 $tpl->setVariable('TILES', $this->uiRenderer->render($deck));
44 }
45 $tpl->parseCurrentBlock();
46
47 $tpl->setCurrentBlock('grouped_tiles');
48 $tpl->parseCurrentBlock();
49
50 $itemRendered = true;
51 }
52 }
53
54 if (!$itemRendered) {
55 return '';
56 }
57
58 $html = $tpl->get();
59 if ($this->ctrl->isAsynch()) {
60 $html .= $tpl->getOnLoadCodeForAsynch();
61 }
62
63 $this->tpl->touchBlock('row_type_1');
64 $this->tpl->setCurrentBlock('container_standard_row');
65 $this->tpl->setVariable('BLOCK_ROW_CONTENT', $html);
66 $this->tpl->parseCurrentBlock();
67
68 $this->tpl->touchBlock('container_row');
69
70 return $this->tpl->get();
71 }
72
79 protected function getCard(array $item) : ?Card
80 {
81 $itemListGui = $this->listItemFactory->byType($item['type']);
83
84
85 return $itemListGui->getAsCard(
86 (int) $item['ref_id'],
87 (int) $item['obj_id'],
88 (string) $item['type'],
89 (string) $item['title'],
90 (string) $item['description']
91 );
92 }
93}
An exception for terminatinating execution or to throw for unit testing.
static addListGUIActivationProperty(ilObjectListGUI $a_list_gui, array &$a_item)
Get timing details for list gui.
Class ilPDBaseObjectsRenderer.
Class ilPDObjectsTileRenderer.
render(array $groupedItems, bool $showHeader)
@inheritDoc
special template class to simplify handling of ITX/PEAR
Interface ilPDObjectsRenderer.