ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilContainerRenderer Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilContainerRenderer:

Public Member Functions

 addTypeBlock (string $a_type, string $a_prefix=null, string $a_postfix=null)
 
 hasTypeBlock (string $a_type)
 
 addCustomBlock ( $a_id, string $a_caption, string $a_actions=null, array $a_data=[])
 Add custom block. More...
 
 hasCustomBlock ($a_id)
 Custom block already exists? More...
 
 isValidBlock ($a_id)
 Any block with id exists? More...
 
 hideItem ($a_id)
 Mark item id as used, but do not render. More...
 
 removeItem ($a_id)
 Remove item (from any block) More...
 
 hasItem ($a_id)
 Item with id exists? More...
 
 addItemToBlock ( $a_block_id, string $a_item_type, $a_item_id, $a_item_html, bool $a_force=false)
 Add item to existing block. More...
 
 addItemId ($a_item_id)
 
 addShowMoreButton ($a_block_id)
 Add show more button to a block. More...
 
 addDetailsLevel (int $a_level, string $a_url, bool $a_active=false)
 
 resetDetails ()
 
 setBlockPosition ( $a_block_id, int $a_pos)
 
 getHTML ()
 
 renderSingleTypeBlock (string $a_type)
 
 renderSingleCustomBlock ($a_id)
 
 renderDetails (ilTemplate $a_tpl)
 

Protected Member Functions

 getViewMode ()
 
 processBlockPositions ()
 
 renderHelperCustomBlock (ilTemplate $a_block_tpl, $a_block_id, bool $a_is_single=false)
 
 renderHelperTypeBlock (ilTemplate $a_block_tpl, string $a_type, bool $a_is_single=false)
 
 renderHelperGeneric (ilTemplate $a_block_tpl, $a_block_id, array $a_block, bool $a_is_single=false)
 
 initBlockTemplate ()
 
 addHeaderRow (ilTemplate $a_tpl, string $a_type="", string $a_text="", array $a_types_in_block=null, string $a_commands_html="", string $a_order_id="", array $a_data=[])
 Render block header. More...
 
 addStandardRow (ilTemplate $a_tpl, string $a_html, int $a_ref_id=0)
 
 renderSelectAllBlock (ilTemplate $a_tpl)
 Render "select all". More...
 
 addSeparatorRow (ilTemplate $a_tpl)
 
 getDownloadableTypes ()
 Get downloadable repository object types. More...
 

Protected Attributes

const UNIQUE_SEPARATOR = "-"
 
bool $admin_panel
 
ilLanguage $lng
 
ilSetting $settings
 
ilObjectDefinition $obj_definition
 
ilContainerGUI $container_gui
 
bool $enable_manage_select_all
 
bool $enable_multi_download
 
bool $active_block_ordering
 
array $type_blocks = []
 
array $custom_blocks = []
 
array $items = []
 
array $hidden_items = []
 
array $block_items = []
 
array $details = []
 
array $item_ids = []
 
array $rendered_blocks = []
 
int $bl_cnt = 0
 
array $block_pos = []
 
array $block_custom_pos = []
 
int $order_cnt = 0
 
array $show_more = []
 
int $view_mode
 
ILIAS DI UIServices $ui
 
ilCtrl $ctrl
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilContainerRenderer

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 24 of file class.ilContainerRenderer.php.

Member Function Documentation

◆ addCustomBlock()

ilContainerRenderer::addCustomBlock (   $a_id,
string  $a_caption,
string  $a_actions = null,
array  $a_data = [] 
)

Add custom block.

Parameters
mixed$a_id

Definition at line 123 of file class.ilContainerRenderer.php.

References hasCustomBlock().

128  : bool {
129  if (!$this->hasCustomBlock($a_id)) {
130  $this->custom_blocks[$a_id] = [
131  "caption" => $a_caption
132  ,"actions" => $a_actions
133  ,"data" => $a_data
134  ];
135  return true;
136  }
137  return false;
138  }
hasCustomBlock($a_id)
Custom block already exists?
+ Here is the call graph for this function:

◆ addDetailsLevel()

ilContainerRenderer::addDetailsLevel ( int  $a_level,
string  $a_url,
bool  $a_active = false 
)

Definition at line 281 of file class.ilContainerRenderer.php.

285  : void {
286  $this->details[$a_level] = [
287  "url" => $a_url
288  ,"active" => $a_active
289  ];
290  }

◆ addHeaderRow()

ilContainerRenderer::addHeaderRow ( ilTemplate  $a_tpl,
string  $a_type = "",
string  $a_text = "",
array  $a_types_in_block = null,
string  $a_commands_html = "",
string  $a_order_id = "",
array  $a_data = [] 
)
protected

Render block header.

Parameters
string$a_order_iditem group id or type, e.g. "crs"
Exceptions
ilTemplateException

Definition at line 602 of file class.ilContainerRenderer.php.

References $ilSetting, $lng, $obj_definition, $settings, $type, ilItemGroupBehaviour\EXPANDABLE_CLOSED, getDownloadableTypes(), ilUtil\getImagePath(), ilObjectPlugin\getPluginObjectByType(), ILIAS\Repository\lng(), ilTemplate\parseCurrentBlock(), renderSelectAllBlock(), ilTemplate\setCurrentBlock(), HTML_Template_IT\setVariable(), ilTemplate\touchBlock(), and ilLanguage\txt().

Referenced by renderHelperGeneric().

610  : void {
611  $lng = $this->lng;
613  $objDefinition = $this->obj_definition;
614 
615  $a_tpl->setVariable("CB_ID", ' id="bl_cntr_' . (++$this->bl_cnt) . '"');
616 
617  if ($this->enable_manage_select_all) {
618  $this->renderSelectAllBlock($a_tpl);
619  } elseif ($this->enable_multi_download) {
620  if ($a_type) {
621  $a_types_in_block = [$a_type];
622  }
623  foreach ($a_types_in_block as $type) {
624  if (in_array($type, $this->getDownloadableTypes(), true)) {
625  $this->renderSelectAllBlock($a_tpl);
626  break;
627  }
628  }
629  }
630 
631  if ($a_text === "" && $a_type !== "") {
632  if (!$objDefinition->isPlugin($a_type)) {
633  $title = $lng->txt("objs_" . $a_type);
634  } else {
636  $title = $pl->txt("objs_" . $a_type);
637  }
638  } else {
639  $title = $a_text;
640  }
641 
642  if (is_array($a_data)) {
643  foreach ($a_data as $k => $v) {
644  $a_tpl->setCurrentBlock("cb_data");
645  $a_tpl->setVariable("DATA_KEY", $k);
646  $a_tpl->setVariable("DATA_VALUE", $v);
647  $a_tpl->parseCurrentBlock();
648 
649  if ($k === "behaviour" && $v == ilItemGroupBehaviour::EXPANDABLE_CLOSED) {
650  $a_tpl->touchBlock("container_items_hide");
651  }
652  }
653  }
654 
655  if ($a_type !== "" && $ilSetting->get("icon_position_in_lists") !== "item_rows") {
656  $icon = ilUtil::getImagePath("icon_" . $a_type . ".svg");
657 
658  $a_tpl->setCurrentBlock("container_header_row_image");
659  $a_tpl->setVariable("HEADER_IMG", $icon);
660  $a_tpl->setVariable("HEADER_ALT", $title);
661  } else {
662  $a_tpl->setCurrentBlock("container_header_row");
663  }
664 
665  if ($a_order_id !== "") {
666  $a_tpl->setVariable("BLOCK_HEADER_ORDER_NAME", "position[blocks][" . $a_order_id . "]");
667  $a_tpl->setVariable("BLOCK_HEADER_ORDER_NUM", (++$this->order_cnt) * 10);
668  }
669 
670  $presentation_title = $title;
671  $sr_only = "";
672  if (trim($title) === "") {
673  $presentation_title = $this->lng->txt("cont_no_title");
674  $sr_only = "sr-only";
675  }
676  $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $presentation_title);
677  $a_tpl->setVariable("SR_ONLY", $sr_only);
678  $a_tpl->setVariable("CHR_COMMANDS", $a_commands_html);
679  $a_tpl->parseCurrentBlock();
680  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
$type
getDownloadableTypes()
Get downloadable repository object types.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
touchBlock(string $block)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
ilObjectDefinition $obj_definition
static getPluginObjectByType(string $type)
Return either a repoObject plugin or a orgunit extension plugin or null if the type is not a plugin...
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
global $ilSetting
Definition: privfeed.php:17
renderSelectAllBlock(ilTemplate $a_tpl)
Render "select all".
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addItemId()

ilContainerRenderer::addItemId (   $a_item_id)
Parameters
mixed$a_item_id

Definition at line 267 of file class.ilContainerRenderer.php.

Referenced by addItemToBlock().

267  : void
268  {
269  $this->item_ids[$a_item_id] = true;
270  }
+ Here is the caller graph for this function:

◆ addItemToBlock()

ilContainerRenderer::addItemToBlock (   $a_block_id,
string  $a_item_type,
  $a_item_id,
  $a_item_html,
bool  $a_force = false 
)

Add item to existing block.

Parameters
mixed$a_block_id
mixed$a_item_id
mixed$a_item_html

Definition at line 229 of file class.ilContainerRenderer.php.

References addItemId(), hasItem(), and isValidBlock().

235  : bool {
236  if ($a_item_type !== "itgr" &&
237  $this->isValidBlock($a_block_id) &&
238  (!$this->hasItem($a_item_id) || $a_force)) {
239  if (is_string($a_item_html) && trim($a_item_html) === "") {
240  return false;
241  }
242  if (!$a_item_html) {
243  return false;
244  }
245 
246 
247  // #16563 - item_id (== ref_id) is NOT unique, adding parent block id
248  $uniq_id = $a_block_id . self::UNIQUE_SEPARATOR . $a_item_id;
249 
250  $this->items[$uniq_id] = [
251  "type" => $a_item_type
252  ,"html" => $a_item_html
253  ];
254 
255  // #18326
256  $this->addItemId($a_item_id);
257 
258  $this->block_items[$a_block_id][] = $uniq_id;
259  return true;
260  }
261  return false;
262  }
hasItem($a_id)
Item with id exists?
isValidBlock($a_id)
Any block with id exists?
+ Here is the call graph for this function:

◆ addSeparatorRow()

ilContainerRenderer::addSeparatorRow ( ilTemplate  $a_tpl)
protected

Definition at line 717 of file class.ilContainerRenderer.php.

References ilTemplate\parseCurrentBlock(), and ilTemplate\setCurrentBlock().

Referenced by getHTML().

717  : void
718  {
719  $a_tpl->setCurrentBlock("container_block");
720  $a_tpl->parseCurrentBlock();
721  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addShowMoreButton()

ilContainerRenderer::addShowMoreButton (   $a_block_id)

Add show more button to a block.

Parameters
mixed$a_block_id

Definition at line 276 of file class.ilContainerRenderer.php.

276  : void
277  {
278  $this->show_more[] = $a_block_id;
279  }

◆ addStandardRow()

ilContainerRenderer::addStandardRow ( ilTemplate  $a_tpl,
string  $a_html,
int  $a_ref_id = 0 
)
protected

Definition at line 682 of file class.ilContainerRenderer.php.

References ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), HTML_Template_IT\setVariable(), and ilTemplate\touchBlock().

Referenced by renderHelperGeneric().

686  : void {
687  if ($a_ref_id > 0) {
688  $a_tpl->setCurrentBlock("row");
689  $a_tpl->setVariable("ROW_ID", 'id="item_row_' . $a_ref_id . '"');
690  $a_tpl->parseCurrentBlock();
691  } else {
692  $a_tpl->touchBlock("row");
693  }
694 
695  $a_tpl->setCurrentBlock("container_standard_row");
696  $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
697  $a_tpl->parseCurrentBlock();
698 
699  $a_tpl->touchBlock("container_row");
700  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
touchBlock(string $block)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addTypeBlock()

ilContainerRenderer::addTypeBlock ( string  $a_type,
string  $a_prefix = null,
string  $a_postfix = null 
)

Definition at line 98 of file class.ilContainerRenderer.php.

References hasTypeBlock().

102  : bool {
103  if ($a_type !== "itgr" &&
104  !$this->hasTypeBlock($a_type)) {
105  $this->type_blocks[$a_type] = [
106  "prefix" => $a_prefix
107  ,"postfix" => $a_postfix
108  ];
109  return true;
110  }
111  return false;
112  }
+ Here is the call graph for this function:

◆ getDownloadableTypes()

ilContainerRenderer::getDownloadableTypes ( )
protected

Get downloadable repository object types.

Definition at line 726 of file class.ilContainerRenderer.php.

Referenced by addHeaderRow().

726  : array
727  {
728  return ["fold", "file"];
729  }
+ Here is the caller graph for this function:

◆ getHTML()

ilContainerRenderer::getHTML ( )

Definition at line 314 of file class.ilContainerRenderer.php.

References $valid, addSeparatorRow(), initBlockTemplate(), processBlockPositions(), renderDetails(), renderHelperCustomBlock(), and renderHelperTypeBlock().

314  : string
315  {
316  $valid = false;
317 
318  $block_tpl = $this->initBlockTemplate();
319 
320  foreach ($this->processBlockPositions() as $block_id) {
321  if (array_key_exists($block_id, $this->custom_blocks) && $this->renderHelperCustomBlock(
322  $block_tpl,
323  $block_id
324  )) {
325  $this->addSeparatorRow($block_tpl);
326  $valid = true;
327  }
328  if (array_key_exists($block_id, $this->type_blocks) && $this->renderHelperTypeBlock(
329  $block_tpl,
330  $block_id
331  )) {
332  $this->addSeparatorRow($block_tpl);
333  $valid = true;
334  }
335  }
336 
337  if ($valid) {
338  $this->renderDetails($block_tpl);
339 
340  return $block_tpl->get();
341  }
342  return "";
343  }
renderHelperCustomBlock(ilTemplate $a_block_tpl, $a_block_id, bool $a_is_single=false)
$valid
addSeparatorRow(ilTemplate $a_tpl)
renderDetails(ilTemplate $a_tpl)
renderHelperTypeBlock(ilTemplate $a_block_tpl, string $a_type, bool $a_is_single=false)
+ Here is the call graph for this function:

◆ getViewMode()

ilContainerRenderer::getViewMode ( )
protected

Definition at line 89 of file class.ilContainerRenderer.php.

References $view_mode.

Referenced by renderHelperGeneric().

89  : int
90  {
91  return $this->view_mode;
92  }
+ Here is the caller graph for this function:

◆ hasCustomBlock()

ilContainerRenderer::hasCustomBlock (   $a_id)

Custom block already exists?

Parameters
mixed$a_id

Definition at line 144 of file class.ilContainerRenderer.php.

Referenced by addCustomBlock(), isValidBlock(), and renderHelperCustomBlock().

144  : bool
145  {
146  return array_key_exists($a_id, $this->custom_blocks);
147  }
+ Here is the caller graph for this function:

◆ hasItem()

ilContainerRenderer::hasItem (   $a_id)

Item with id exists?

Parameters
mixed$a_id

Definition at line 216 of file class.ilContainerRenderer.php.

Referenced by addItemToBlock(), and removeItem().

216  : bool
217  {
218  return (array_key_exists($a_id, $this->item_ids) ||
219  array_key_exists($a_id, $this->hidden_items));
220  }
+ Here is the caller graph for this function:

◆ hasTypeBlock()

ilContainerRenderer::hasTypeBlock ( string  $a_type)

Definition at line 114 of file class.ilContainerRenderer.php.

Referenced by addTypeBlock(), isValidBlock(), and renderHelperTypeBlock().

114  : bool
115  {
116  return array_key_exists($a_type, $this->type_blocks);
117  }
+ Here is the caller graph for this function:

◆ hideItem()

ilContainerRenderer::hideItem (   $a_id)

Mark item id as used, but do not render.

Parameters
mixed$a_id

Definition at line 169 of file class.ilContainerRenderer.php.

169  : void
170  {
171  // see hasItem();
172  $this->hidden_items[$a_id] = true;
173 
174  // #16629 - do not remove hidden items from other blocks
175  // $this->removeItem($a_id);
176  }

◆ initBlockTemplate()

ilContainerRenderer::initBlockTemplate ( )
protected

Definition at line 592 of file class.ilContainerRenderer.php.

Referenced by getHTML(), renderSingleCustomBlock(), and renderSingleTypeBlock().

592  : ilTemplate
593  {
594  return new ilTemplate("tpl.container_list_block.html", true, true, "Services/Container");
595  }
+ Here is the caller graph for this function:

◆ isValidBlock()

ilContainerRenderer::isValidBlock (   $a_id)

Any block with id exists?

Parameters
mixed$a_id

Definition at line 153 of file class.ilContainerRenderer.php.

References hasCustomBlock(), and hasTypeBlock().

Referenced by addItemToBlock(), processBlockPositions(), and setBlockPosition().

153  : bool
154  {
155  return ($this->hasTypeBlock($a_id) ||
156  $this->hasCustomBlock($a_id));
157  }
hasCustomBlock($a_id)
Custom block already exists?
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processBlockPositions()

ilContainerRenderer::processBlockPositions ( )
protected

Definition at line 373 of file class.ilContainerRenderer.php.

References $block_pos, and isValidBlock().

Referenced by getHTML().

373  : array
374  {
375  // manual order
376  if (is_array($this->block_custom_pos) && count($this->block_custom_pos)) {
377  $tmp = $this->block_pos;
378  $this->block_pos = [];
379  foreach ($this->block_custom_pos as $idx => $block_id) {
380  if ($this->isValidBlock($block_id)) {
381  $this->block_pos[$block_id] = $idx;
382  }
383  }
384 
385  // at least some manual are valid
386  if (count($this->block_pos)) {
387  // append missing blocks from default order
388  $last = max($this->block_pos);
389  foreach (array_keys($tmp) as $block_id) {
390  if (!array_key_exists($block_id, $this->block_pos)) {
391  $this->block_pos[$block_id] = ++$last;
392  }
393  }
394  }
395  // all manual invalid, use default
396  else {
397  $this->block_pos = $tmp;
398  }
399  }
400 
401  // add missing blocks to order
402  $last = count($this->block_pos)
403  ? max($this->block_pos)
404  : 0;
405  foreach (array_keys($this->custom_blocks) as $block_id) {
406  if (!array_key_exists($block_id, $this->block_pos)) {
407  $this->block_pos[$block_id] = ++$last;
408  }
409  }
410  foreach (array_keys($this->type_blocks) as $block_id) {
411  if (!array_key_exists($block_id, $this->block_pos)) {
412  $this->block_pos[$block_id] = ++$last;
413  }
414  }
415 
416  asort($this->block_pos);
417  return array_keys($this->block_pos);
418  }
isValidBlock($a_id)
Any block with id exists?
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeItem()

ilContainerRenderer::removeItem (   $a_id)

Remove item (from any block)

Parameters
mixed$a_id

Definition at line 182 of file class.ilContainerRenderer.php.

References $parts, and hasItem().

182  : void
183  {
184  if (!$this->hasItem($a_id)) {
185  return;
186  }
187 
188  unset($this->item_ids[$a_id], $this->hidden_items[$a_id]);
189 
190  foreach (array_keys($this->items) as $item_id) {
191  $parts = explode(self::UNIQUE_SEPARATOR, $item_id);
192  if (array_pop($parts) == $a_id) {
193  unset($this->items[$item_id]);
194  }
195  }
196 
197  foreach ($this->block_items as $block_id => $items) {
198  foreach ($items as $idx => $item_id) {
199  $parts = explode(self::UNIQUE_SEPARATOR, $item_id);
200  if (array_pop($parts) == $a_id) {
201  unset($this->block_items[$block_id][$idx]);
202  if (!count($this->block_items[$block_id])) {
203  unset($this->block_items[$block_id]);
204  }
205  break;
206  }
207  }
208  }
209  }
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64
hasItem($a_id)
Item with id exists?
+ Here is the call graph for this function:

◆ renderDetails()

ilContainerRenderer::renderDetails ( ilTemplate  $a_tpl)

Definition at line 731 of file class.ilContainerRenderer.php.

References $lng, ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), HTML_Template_IT\setVariable(), and ilLanguage\txt().

Referenced by getHTML().

731  : void
732  {
733  $lng = $this->lng;
734 
735  if (count($this->details)) {
736  $a_tpl->setCurrentBlock('container_details_row');
737  $a_tpl->setVariable('TXT_DETAILS', $lng->txt('details'));
738  $a_tpl->parseCurrentBlock();
739  }
740  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderHelperCustomBlock()

ilContainerRenderer::renderHelperCustomBlock ( ilTemplate  $a_block_tpl,
  $a_block_id,
bool  $a_is_single = false 
)
protected
Parameters
mixed$a_block_id

Definition at line 423 of file class.ilContainerRenderer.php.

References hasCustomBlock(), and renderHelperGeneric().

Referenced by getHTML(), and renderSingleCustomBlock().

427  : bool {
428  if ($this->hasCustomBlock($a_block_id)) {
429  return $this->renderHelperGeneric($a_block_tpl, $a_block_id, $this->custom_blocks[$a_block_id], $a_is_single);
430  }
431  return false;
432  }
renderHelperGeneric(ilTemplate $a_block_tpl, $a_block_id, array $a_block, bool $a_is_single=false)
hasCustomBlock($a_id)
Custom block already exists?
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderHelperGeneric()

ilContainerRenderer::renderHelperGeneric ( ilTemplate  $a_block_tpl,
  $a_block_id,
array  $a_block,
bool  $a_is_single = false 
)
protected
Parameters
mixed$a_block_id

Definition at line 450 of file class.ilContainerRenderer.php.

References $active_block_ordering, $admin_panel, $ctrl, Vendor\Package\$f, $id, $url, ilContainer\_lookupContainerSetting(), addHeaderRow(), addStandardRow(), ilCtrl\getLinkTarget(), getViewMode(), ilCtrl\isAsynch(), ILIAS\Repository\lng(), ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), ilCtrl\setParameter(), HTML_Template_IT\setVariable(), ilContainer\TILE_EXTRA_LARGE, ilContainer\TILE_FULL, ilContainer\TILE_LARGE, ilContainer\TILE_SMALL, ILIAS\Repository\ui(), ilContainerContentGUI\VIEW_MODE_LIST, ilContainerContentGUI\VIEW_MODE_TILE, and ILIAS\UI\Implementation\Component\Button\withLoadingAnimationOnClick().

Referenced by renderHelperCustomBlock(), and renderHelperTypeBlock().

455  : bool {
456  $ctrl = $this->ctrl;
457  if (!in_array($a_block_id, $this->rendered_blocks)) {
458  $this->rendered_blocks[] = $a_block_id;
459 
460  $block_types = [];
461  if (isset($this->block_items[$a_block_id]) && is_array($this->block_items[$a_block_id])) {
462  foreach ($this->block_items[$a_block_id] as $item_id) {
463  if (isset($this->items[$item_id]["type"])) {
464  $block_types[] = $this->items[$item_id]["type"];
465  }
466  }
467  }
468 
469  // determine view mode and tile size
470  $tile_size = ilContainer::TILE_SMALL;
471  $view_mode = $this->getViewMode();
473  $tile_size = ilContainer::_lookupContainerSetting($this->container_gui->getObject()->getId(), "tile_size");
474  }
475  if (is_numeric($a_block_id)) {
476  $item_group = new ilObjItemGroup($a_block_id);
477  if ($item_group->getListPresentation() !== "") {
478  $view_mode = ($item_group->getListPresentation() === "tile" && !$this->active_block_ordering && !$this->admin_panel)
481  $tile_size = $item_group->getTileSize();
482  }
483  }
484 
485 
486  // #14610 - manage empty item groups
487  if ((isset($this->block_items[$a_block_id]) && is_array($this->block_items[$a_block_id])) ||
488  is_numeric($a_block_id)) {
489  $cards = [];
490 
491  $order_id = (!$a_is_single && $this->active_block_ordering)
492  ? $a_block_id
493  : "";
494  $this->addHeaderRow(
495  $a_block_tpl,
496  $a_block["type"] ?? '',
497  $a_block["caption"] ?? '',
498  array_unique($block_types),
499  $a_block["actions"] ?? '',
500  $order_id,
501  $a_block["data"] ?? []
502  );
503 
505  if (isset($a_block["prefix"]) && $a_block["prefix"]) {
506  $this->addStandardRow($a_block_tpl, $a_block["prefix"]);
507  }
508  }
509 
510  if (isset($this->block_items[$a_block_id])) {
511  foreach ($this->block_items[$a_block_id] as $item_id) {
513  $this->addStandardRow($a_block_tpl, $this->items[$item_id]["html"], (int) $item_id);
514  } else {
515  $cards[] = $this->items[$item_id]["html"];
516  }
517  }
518  }
519 
521  if (isset($a_block["postfix"]) && $a_block["postfix"]) {
522  $this->addStandardRow($a_block_tpl, $a_block["postfix"]);
523  }
524  }
525 
527  $f = $this->ui->factory();
528  $renderer = $this->ui->renderer();
529 
530  //Create a deck with large cards
531  switch ($tile_size) {
533  $deck = $f->deck($cards)->withSmallCardsSize();
534  break;
535 
537  $deck = $f->deck($cards)->withLargeCardsSize();
538  break;
539 
541  $deck = $f->deck($cards)->withExtraLargeCardsSize();
542  break;
543 
545  $deck = $f->deck($cards)->withFullSizedCardsSize();
546  break;
547 
548  default:
549  $deck = $f->deck($cards)->withNormalCardsSize();
550  break;
551  }
552 
553 
554  $html = $renderer->render($deck);
555  $a_block_tpl->setCurrentBlock("tile_rows");
556  $a_block_tpl->setVariable("TILE_ROWS", $html);
557  $a_block_tpl->parseCurrentBlock();
558  }
559 
560  // show more
561  if (in_array($a_block_id, $this->show_more)) {
562  $a_block_tpl->setCurrentBlock("show_more");
563 
564  $ctrl->setParameter($this->container_gui, "type", $a_block_id);
565  $url = $ctrl->getLinkTarget($this->container_gui, "renderBlockAsynch", "", true);
566  $ctrl->setParameter($this->container_gui, "type", "");
567 
568  $f = $this->ui->factory();
569  $renderer = $this->ui->renderer();
570  $button = $f->button()->standard($this->lng->txt("cont_show_more"), "")
572  ->withOnLoadCode(function ($id) use ($a_block_id, $url) {
573  return "il.Container.initShowMore('$id', '$a_block_id', '" . $url . "');";
574  });
575  if ($ctrl->isAsynch()) {
576  $a_block_tpl->setVariable("SHOW_MORE_BUTTON", $renderer->renderAsync($button));
577  } else {
578  $a_block_tpl->setVariable("SHOW_MORE_BUTTON", $renderer->render($button));
579  }
580  $a_block_tpl->parseCurrentBlock();
581  $a_block_tpl->setCurrentBlock("show_more");
582  $a_block_tpl->parseCurrentBlock();
583  }
584 
585  return true;
586  }
587  }
588 
589  return false;
590  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
withLoadingAnimationOnClick(bool $loading_animation_on_click=true)
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
addHeaderRow(ilTemplate $a_tpl, string $a_type="", string $a_text="", array $a_types_in_block=null, string $a_commands_html="", string $a_order_id="", array $a_data=[])
Render block header.
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
getLinkTarget(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$url
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
addStandardRow(ilTemplate $a_tpl, string $a_html, int $a_ref_id=0)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderHelperTypeBlock()

ilContainerRenderer::renderHelperTypeBlock ( ilTemplate  $a_block_tpl,
string  $a_type,
bool  $a_is_single = false 
)
protected

Definition at line 434 of file class.ilContainerRenderer.php.

References hasTypeBlock(), and renderHelperGeneric().

Referenced by getHTML(), and renderSingleTypeBlock().

438  : bool {
439  if ($this->hasTypeBlock($a_type)) {
440  $block = $this->type_blocks[$a_type];
441  $block["type"] = $a_type;
442  return $this->renderHelperGeneric($a_block_tpl, $a_type, $block, $a_is_single);
443  }
444  return false;
445  }
renderHelperGeneric(ilTemplate $a_block_tpl, $a_block_id, array $a_block, bool $a_is_single=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderSelectAllBlock()

ilContainerRenderer::renderSelectAllBlock ( ilTemplate  $a_tpl)
protected

Render "select all".

Definition at line 705 of file class.ilContainerRenderer.php.

References $lng, ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), HTML_Template_IT\setVariable(), and ilLanguage\txt().

Referenced by addHeaderRow().

705  : void
706  {
707  $lng = $this->lng;
708 
709  $a_tpl->setCurrentBlock("select_all_row");
710  $a_tpl->setVariable("CHECKBOXNAME", "bl_cb_" . $this->bl_cnt);
711  $a_tpl->setVariable("SEL_ALL_PARENT", "bl_cntr_" . $this->bl_cnt);
712  $a_tpl->setVariable("SEL_ALL_PARENT", "bl_cntr_" . $this->bl_cnt);
713  $a_tpl->setVariable("TXT_SELECT_ALL", $lng->txt("select_all"));
714  $a_tpl->parseCurrentBlock();
715  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderSingleCustomBlock()

ilContainerRenderer::renderSingleCustomBlock (   $a_id)
Parameters
mixed$a_id

Definition at line 358 of file class.ilContainerRenderer.php.

References initBlockTemplate(), and renderHelperCustomBlock().

358  : string
359  {
360  $block_tpl = $this->initBlockTemplate();
361 
362  if ($this->renderHelperCustomBlock($block_tpl, $a_id, true)) {
363  return $block_tpl->get();
364  }
365  return "";
366  }
renderHelperCustomBlock(ilTemplate $a_block_tpl, $a_block_id, bool $a_is_single=false)
+ Here is the call graph for this function:

◆ renderSingleTypeBlock()

ilContainerRenderer::renderSingleTypeBlock ( string  $a_type)

Definition at line 345 of file class.ilContainerRenderer.php.

References initBlockTemplate(), and renderHelperTypeBlock().

345  : string
346  {
347  $block_tpl = $this->initBlockTemplate();
348 
349  if ($this->renderHelperTypeBlock($block_tpl, $a_type, true)) {
350  return $block_tpl->get();
351  }
352  return "";
353  }
renderHelperTypeBlock(ilTemplate $a_block_tpl, string $a_type, bool $a_is_single=false)
+ Here is the call graph for this function:

◆ resetDetails()

ilContainerRenderer::resetDetails ( )

Definition at line 292 of file class.ilContainerRenderer.php.

292  : void
293  {
294  $this->details = [];
295  }

◆ setBlockPosition()

ilContainerRenderer::setBlockPosition (   $a_block_id,
int  $a_pos 
)
Parameters
mixed$a_block_id

Definition at line 305 of file class.ilContainerRenderer.php.

References isValidBlock().

308  : void {
309  if ($this->isValidBlock($a_block_id)) {
310  $this->block_pos[$a_block_id] = $a_pos;
311  }
312  }
isValidBlock($a_id)
Any block with id exists?
+ Here is the call graph for this function:

Field Documentation

◆ $active_block_ordering

bool ilContainerRenderer::$active_block_ordering
protected

Definition at line 37 of file class.ilContainerRenderer.php.

Referenced by renderHelperGeneric().

◆ $admin_panel

bool ilContainerRenderer::$admin_panel
protected

Definition at line 27 of file class.ilContainerRenderer.php.

Referenced by renderHelperGeneric().

◆ $bl_cnt

int ilContainerRenderer::$bl_cnt = 0
protected

Definition at line 50 of file class.ilContainerRenderer.php.

◆ $block_custom_pos

array ilContainerRenderer::$block_custom_pos = []
protected

Definition at line 54 of file class.ilContainerRenderer.php.

◆ $block_items

array ilContainerRenderer::$block_items = []
protected

Definition at line 44 of file class.ilContainerRenderer.php.

◆ $block_pos

array ilContainerRenderer::$block_pos = []
protected

Definition at line 53 of file class.ilContainerRenderer.php.

Referenced by processBlockPositions().

◆ $container_gui

ilContainerGUI ilContainerRenderer::$container_gui
protected

Definition at line 32 of file class.ilContainerRenderer.php.

◆ $ctrl

ilCtrl ilContainerRenderer::$ctrl
protected

Definition at line 60 of file class.ilContainerRenderer.php.

Referenced by renderHelperGeneric().

◆ $custom_blocks

array ilContainerRenderer::$custom_blocks = []
protected

Definition at line 41 of file class.ilContainerRenderer.php.

◆ $details

array ilContainerRenderer::$details = []
protected

Definition at line 45 of file class.ilContainerRenderer.php.

◆ $enable_manage_select_all

bool ilContainerRenderer::$enable_manage_select_all
protected

Definition at line 35 of file class.ilContainerRenderer.php.

◆ $enable_multi_download

bool ilContainerRenderer::$enable_multi_download
protected

Definition at line 36 of file class.ilContainerRenderer.php.

◆ $hidden_items

array ilContainerRenderer::$hidden_items = []
protected

Definition at line 43 of file class.ilContainerRenderer.php.

◆ $item_ids

array ilContainerRenderer::$item_ids = []
protected

Definition at line 46 of file class.ilContainerRenderer.php.

◆ $items

array ilContainerRenderer::$items = []
protected

Definition at line 42 of file class.ilContainerRenderer.php.

◆ $lng

ilLanguage ilContainerRenderer::$lng
protected

Definition at line 29 of file class.ilContainerRenderer.php.

Referenced by addHeaderRow(), renderDetails(), and renderSelectAllBlock().

◆ $obj_definition

ilObjectDefinition ilContainerRenderer::$obj_definition
protected

Definition at line 31 of file class.ilContainerRenderer.php.

Referenced by addHeaderRow().

◆ $order_cnt

int ilContainerRenderer::$order_cnt = 0
protected

Definition at line 55 of file class.ilContainerRenderer.php.

◆ $rendered_blocks

array ilContainerRenderer::$rendered_blocks = []
protected

Definition at line 49 of file class.ilContainerRenderer.php.

◆ $settings

ilSetting ilContainerRenderer::$settings
protected

Definition at line 30 of file class.ilContainerRenderer.php.

Referenced by addHeaderRow().

◆ $show_more

array ilContainerRenderer::$show_more = []
protected

Definition at line 57 of file class.ilContainerRenderer.php.

◆ $type_blocks

array ilContainerRenderer::$type_blocks = []
protected

Definition at line 40 of file class.ilContainerRenderer.php.

◆ $ui

ILIAS DI UIServices ilContainerRenderer::$ui
protected

Definition at line 59 of file class.ilContainerRenderer.php.

◆ $view_mode

int ilContainerRenderer::$view_mode
protected

Definition at line 58 of file class.ilContainerRenderer.php.

Referenced by getViewMode().

◆ UNIQUE_SEPARATOR

const ilContainerRenderer::UNIQUE_SEPARATOR = "-"
protected

Definition at line 26 of file class.ilContainerRenderer.php.


The documentation for this class was generated from the following file: