ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Renderer.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2016 Timon Amstutz <timon.amstutz@ilub.unibe.ch> Extended GPL, see docs/LICENSE */
4 
6 
10 
12 {
16  public function render(Component\Component $component, RendererInterface $default_renderer)
17  {
18  $tpl_card = $this->getTemplate("tpl.deck_card.html", true, true);
19  $tpl_row = $this->getTemplate("tpl.deck_row.html", true, true);
20 
21  $size = $component->getCardsSize();
22  $small_size = $component->getCardsSizeSmallDisplays();
23  $cards_per_row = 12/$size;
24 
25  $i=1;
26 
27  foreach ($component->getCards() as $card) {
28  $tpl_card->setCurrentBlock("card");
29  $tpl_card->setVariable("CARD", $default_renderer->render($card, $default_renderer));
30  $tpl_card->setVariable("SIZE", $size);
31  $tpl_card->setVariable("SMALL_SIZE", $small_size);
32  $tpl_card->parseCurrentBlock();
33 
34  if (($i % $cards_per_row) == 0) {
35  $this->parseRow($tpl_row, $tpl_card->get());
36  $tpl_card = $this->getTemplate("tpl.deck_card.html", true, true);
37  $i=0;
38  }
39  $i++;
40  }
41 
42  $this->parseRow($tpl_row, $tpl_card->get());
43 
44  return $tpl_row->get();
45  }
46 
47  protected function parseRow($tpl_row, $content)
48  {
49  $tpl_row->setCurrentBlock("row");
50  $tpl_row->setVariable("CARDS", $content);
51  $tpl_row->parseCurrentBlock();
52  }
53 
57  protected function getComponentInterfaceName()
58  {
59  return array(Component\Deck\Deck::class);
60  }
61 }
$size
Definition: RandomTest.php:84
render(Component\Component $component, RendererInterface $default_renderer)
Definition: Renderer.php:16
Create styles array
The data for the language used.
$i
Definition: disco.tpl.php:19
getTemplate($name, $purge_unfilled_vars, $purge_unused_blocks)
Get template of component this renderer is made for.