ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
15  public function render(Component\Component $component, RendererInterface $default_renderer) {
16 
17  $tpl_card = $this->getTemplate("tpl.deck_card.html", true, true);
18  $tpl_row = $this->getTemplate("tpl.deck_row.html", true, true);
19 
20  $size = $component->getCardsSize();
21  $icons_per_row = 12/$size;
22 
23  $i=1;
24 
25  foreach($component->getCards() as $card){
26  $tpl_card->setCurrentBlock("card");
27  $tpl_card->setVariable("CARD",$default_renderer->render($card,$default_renderer));
28  $tpl_card->setVariable("SIZE",$size);
29  $tpl_card->parseCurrentBlock();
30 
31  if(($i % $icons_per_row ) == 0){
32  $this->parseRow($tpl_row,$tpl_card->get());
33  $tpl_card = $this->getTemplate("tpl.deck_card.html", true, true);
34  $i=0;
35  }
36  $i++;
37  }
38 
39  $this->parseRow($tpl_row,$tpl_card->get());
40 
41  return $tpl_row->get();
42  }
43 
44  protected function parseRow($tpl_row,$content){
45  $tpl_row->setCurrentBlock("row");
46  $tpl_row->setVariable("CARDS",$content);
47  $tpl_row->parseCurrentBlock();
48  }
49 
53  protected function getComponentInterfaceName() {
54  return array(Component\Deck\Deck::class);
55  }
56 }
$size
Definition: RandomTest.php:79
render(Component\Component $component, RendererInterface $default_renderer)
Definition: Renderer.php:15
Create styles array
The data for the language used.
getTemplate($name, $purge_unfilled_vars, $purge_unused_blocks)
Get template of component this renderer is made for.