ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilContainerContentGUI.php
Go to the documentation of this file.
1 <?php
2 
23 
32 abstract class ilContainerContentGUI
33 {
34  public const DETAILS_DEACTIVATED = 0;
35  public const DETAILS_TITLE = 1;
36  public const DETAILS_ALL = 2;
37 
38  public const VIEW_MODE_LIST = 0;
39  public const VIEW_MODE_TILE = 1;
40  protected \ILIAS\Container\Content\ItemPresentationManager $item_presentation;
41 
43  protected ilCtrl $ctrl;
44  protected ilObjUser $user;
45  protected ilLanguage $lng;
47  protected ilDBInterface $db;
49  protected ilSetting $settings;
51  protected int $details_level = self::DETAILS_DEACTIVATED;
55  protected ilLogger $log;
56  protected int $view_mode;
57  protected array $embedded_block = [];
58  protected array $items = [];
60  protected array $list_gui = [];
65  protected int $block_limit = 0;
66  protected array $type_grps = [];
67  protected int $force_details;
69 
70  public function __construct(
71  ilContainerGUI $container_gui_obj,
72  \ILIAS\Container\Content\ItemPresentationManager $item_presentation
73  ) {
74  global $DIC;
75 
76  $this->tpl = $DIC["tpl"];
77  $this->ctrl = $DIC->ctrl();
78  $this->user = $DIC->user();
79  $this->lng = $DIC->language();
80  $this->access = $DIC->access();
81  $this->db = $DIC->database();
82  $this->rbacsystem = $DIC->rbac()->system();
83  $this->settings = $DIC->settings();
84  $this->obj_definition = $DIC["objDefinition"];
85  $tpl = $DIC["tpl"];
86 
87  $this->container_gui = $container_gui_obj;
89  $obj = $this->container_gui->getObject();
90  $this->container_obj = $obj;
91 
92  $tpl->addJavaScript("assets/js/Container.js");
93  $tpl->addJavaScript("assets/js/repository.js");
94 
95  $this->log = ilLoggerFactory::getLogger('cont');
96 
97  $this->view_mode = (ilContainer::_lookupContainerSetting($this->container_obj->getId(), "list_presentation") === "tile" && !$this->container_gui->isActiveAdministrationPanel() && !$this->container_gui->isActiveOrdering())
98  ? self::VIEW_MODE_TILE
99  : self::VIEW_MODE_LIST;
100 
101  $this->clipboard = $DIC
102  ->repository()
103  ->internal()
104  ->domain()
105  ->clipboard();
106  $this->request = $DIC
107  ->container()
108  ->internal()
109  ->gui()
110  ->standardRequest();
111  $this->item_manager = $DIC
112  ->container()
113  ->internal()
114  ->domain()
115  ->content()
116  ->items($this->container_obj);
117  $this->block_repo = $DIC
118  ->container()
119  ->internal()
120  ->repo()
121  ->content()
122  ->block();
123  $this->item_presentation = $item_presentation;
124 
125  $this->block_limit = (int) ilContainer::_lookupContainerSetting($container_gui_obj->getObject()->getId(), "block_limit");
126  }
127 
128  protected function getViewMode(): int
129  {
130  return $this->view_mode;
131  }
132 
133 
134  public function getContainerObject(): ilContainer
135  {
136  return $this->container_obj;
137  }
138 
139  public function getContainerGUI(): ilContainerGUI
140  {
141  return $this->container_gui;
142  }
143 
148  public function setOutput(): void
149  {
150  $tpl = $this->tpl;
151  $ilCtrl = $this->ctrl;
152 
153  // note: we do not want to get the center html in case of
154  // asynchronous calls to blocks in the right column (e.g. news)
155  // see #13012
156  if ($ilCtrl->getNextClass() === "ilcolumngui" &&
157  $ilCtrl->isAsynch()) {
158  $tpl->setRightContent($this->getRightColumnHTML());
159  }
160 
161  // BEGIN ChangeEvent: record read event.
162  $ilUser = $this->user;
163 
164  $obj_id = ilObject::_lookupObjId($this->getContainerObject()->getRefId());
166  $this->getContainerObject()->getType(),
167  $this->getContainerObject()->getRefId(),
168  $obj_id,
169  $ilUser->getId()
170  );
171  // END ChangeEvent: record read event.
172 
173  $html = $this->getCenterColumnHTML();
174  if ($html !== '') {
175  $tpl->setContent($html);
176  }
177 
178  // see above, all other cases (this was the old position of setRightContent,
179  // maybe the position above is ok and all ifs can be removed)
180  if ($ilCtrl->getNextClass() !== "ilcolumngui" ||
181  !$ilCtrl->isAsynch()) {
182  $tpl->setRightContent($this->getRightColumnHTML());
183  }
184  }
185 
186  protected function getRightColumnHTML(): string
187  {
188  $ilCtrl = $this->ctrl;
189  $html = "";
190 
191  $ilCtrl->saveParameterByClass("ilcolumngui", "col_return");
192 
193  $obj_id = ilObject::_lookupObjId($this->getContainerObject()->getRefId());
194  $obj_type = ilObject::_lookupType($obj_id);
195 
196  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
197 
198  if ($column_gui::getScreenMode() === IL_SCREEN_FULL) {
199  return "";
200  }
201 
202  $this->getContainerGUI()->setColumnSettings($column_gui);
203 
204  if ($ilCtrl->getNextClass() === "ilcolumngui" &&
205  $column_gui::getCmdSide() === IL_COL_RIGHT &&
206  $column_gui::getScreenMode() === IL_SCREEN_SIDE) {
207  $html = $ilCtrl->forwardCommand($column_gui);
208  } else {
209  if (!$ilCtrl->isAsynch()) {
210  $html = "";
211 
212  // user interface plugin slot + default rendering
213  $uip = new ilUIHookProcessor(
214  "components/ILIAS/Container",
215  "right_column",
216  ["container_content_gui" => $this]
217  );
218  if (!$uip->replaced()) {
219  $html = $ilCtrl->getHTML($column_gui);
220  }
221  $html = $uip->getHTML($html);
222  }
223  }
224 
225  return $html;
226  }
227 
228  protected function getCenterColumnHTML(): string
229  {
230  $ilCtrl = $this->ctrl;
231  $tpl = $this->tpl;
232  $ilDB = $this->db;
233 
234  $ilCtrl->saveParameterByClass("ilcolumngui", "col_return");
235 
236  $tpl->addOnLoadCode("il.Object.setRedrawListItemUrl('" .
237  $ilCtrl->getLinkTarget($this->container_gui, "redrawListItem", "", true) . "');");
238 
239  $tpl->addOnLoadCode("il.Object.setRatingUrl('" .
240  $ilCtrl->getLinkTargetByClass(
241  [get_class($this->container_gui), "ilcommonactiondispatchergui", "ilratinggui"],
242  "saveRating",
243  "",
244  true,
245  false
246  ) . "');");
247 
248  switch ($ilCtrl->getNextClass()) {
249  case "ilcolumngui":
250  $this->container_gui->setSideColumnReturn();
251  $html = $this->forwardToColumnGUI();
252  break;
253 
254  default:
255  $ilDB->useSlave(true);
256  $html = $this->getMainContent();
257  $ilDB->useSlave(false);
258  break;
259  }
260 
261  return $html;
262  }
263 
268  public function getMainContent(): string
269  {
270  $ilAccess = $this->access;
271 
272  $tpl = new ilTemplate(
273  "tpl.container_page.html",
274  true,
275  true,
276  "components/ILIAS/Container"
277  );
278  // Show introduction, if repository is empty
279  if (!$this->item_presentation->hasItems() &&
280  $this->getContainerObject()->getRefId() == ROOT_FOLDER_ID &&
281  $ilAccess->checkAccess("write", "", $this->getContainerObject()->getRefId())) {
282  $html = $this->getIntroduction();
283  } else { // show item list otherwise
284  $html = $this->renderItemList();
285  }
286  $tpl->setVariable("CONTAINER_PAGE_CONTENT", $html);
287 
288  return $tpl->get();
289  }
290 
294  protected function initRenderer(): void
295  {
297 
298  $this->renderer = new ilContainerRenderer(
299  $this->item_presentation,
300  ($this->getContainerGUI()->isActiveAdministrationPanel() && !$this->clipboard->hasEntries()),
301  $this->getContainerGUI()->isMultiDownloadEnabled(),
302  $this->getContainerGUI()->isActiveOrdering() && (get_class($this) !== "ilContainerObjectiveGUI") // no block sorting in objective view
303  ,
304  $sorting->getBlockPositions(),
306  $this->getViewMode(),
307  $this->getContainerGUI()->isActiveAdministrationPanel()
308  );
309 
310  // all event items are included per session rendering
311  // and should return true for hasItem
312  $event_items = ilEventItems::_getItemsOfContainer($this->container_obj->getRefId());
313  foreach ($event_items as $ev) {
314  $this->renderer->addItemId($ev);
315  }
316  }
317 
321  private function forwardToColumnGUI(): string
322  {
323  $ilCtrl = $this->ctrl;
324  $html = "";
325 
326  // this gets us the subitems we need in setColumnSettings()
327  // todo: this should be done in ilCourseGUI->getSubItems
328 
329  $obj_id = ilObject::_lookupObjId($this->getContainerObject()->getRefId());
330  $obj_type = ilObject::_lookupType($obj_id);
331 
332  if (!$ilCtrl->isAsynch()) {
334  // right column wants center
336  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
337  $this->getContainerGUI()->setColumnSettings($column_gui);
338  $html = $ilCtrl->forwardCommand($column_gui);
339  }
340  // left column wants center
342  $column_gui = new ilColumnGUI($obj_type, IL_COL_LEFT);
343  $this->getContainerGUI()->setColumnSettings($column_gui);
344  $html = $ilCtrl->forwardCommand($column_gui);
345  }
346  } else {
347  $html = $this->getMainContent();
348  }
349  }
350 
351  return $html;
352  }
353 
354  protected function getItemGUI(array $item_data): ilObjectListGUI
355  {
356  // get item list gui object
357  if (!isset($this->list_gui[$item_data["type"]])) {
358  $item_list_gui = ilObjectListGUIFactory::_getListGUIByType($item_data["type"]);
359  $item_list_gui->setContainerObject($this->getContainerGUI());
360  $this->list_gui[$item_data["type"]] = &$item_list_gui;
361  } else {
362  $item_list_gui = &$this->list_gui[$item_data["type"]];
363  }
364 
365  // unique js-ids
366  $item_list_gui->setParentRefId((int) ($item_data["parent"] ?? 0));
367 
368  $item_list_gui->setDefaultCommandParameters([]);
369  $item_list_gui->disableTitleLink(false);
370  $item_list_gui->resetConditionTarget();
371 
372  if ($this->container_obj->isClassificationFilterActive()) {
373  $item_list_gui->enablePath(
374  true,
375  $this->container_obj->getRefId(),
377  );
378  }
379 
380  // activate common social commands
381  $item_list_gui->enableComments(true);
382  $item_list_gui->enableNotes(true);
383  $item_list_gui->enableTags(true);
384  $item_list_gui->enableRating(true);
385 
386  // reset
387  $item_list_gui->forceVisibleOnly(false);
388 
389  // container specific modifications
390  $this->getContainerGUI()->modifyItemGUI($item_list_gui, $item_data);
391 
392  return $item_list_gui;
393  }
394 
399  string $a_container_page_html
400  ): void {
401  $type_grps = $this->getGroupedObjTypes();
402 
403  // iterate all types
404  foreach ($type_grps as $type => $v) {
405  // set template (overall or type specific)
406  if (is_int(strpos($a_container_page_html, "[list-" . $type . "]"))) {
407  $this->addEmbeddedBlock("type", $type);
408  }
409  }
410 
411  // determine item groups
412  while (preg_match('~\[(item-group-([0-9]*))\]~i', $a_container_page_html, $found)) {
413  $this->addEmbeddedBlock("itgr", (int) $found[2]);
414 
415  $html = ''; // This was never defined before
416  $a_container_page_html = preg_replace('~\[' . $found[1] . '\]~i', $html, $a_container_page_html);
417  }
418  }
419 
425  public function addEmbeddedBlock(
426  string $block_type,
427  $block_parameter
428  ): void {
429  $this->embedded_block[$block_type][] = $block_parameter;
430  }
431 
432  public function getEmbeddedBlocks(): array
433  {
434  return $this->embedded_block;
435  }
436 
437  public function renderPageEmbeddedBlocks(): void
438  {
439  // item groups
440  if (isset($this->embedded_block["itgr"]) && is_array($this->embedded_block["itgr"])) {
441  $item_groups = [];
442  if (isset($this->items["itgr"]) && is_array($this->items["itgr"])) {
443  foreach ($this->items["itgr"] as $ig) {
444  $item_groups[$ig["ref_id"]] = $ig;
445  }
446  }
447 
448  foreach ($this->embedded_block["itgr"] as $ref_id) {
449  if (isset($item_groups[$ref_id])) {
450  $this->renderItemGroup($item_groups[$ref_id]);
451  }
452  }
453  }
454 
455  // type specific blocks
456  if (isset($this->embedded_block["type"]) && is_array($this->embedded_block["type"])) {
457  foreach ($this->embedded_block["type"] as $type) {
458  if (isset($this->items[$type]) && is_array($this->items[$type]) && $this->renderer->addTypeBlock($type)) {
459  if ($this->hasForcedOrderByStartDate($type)) {
460  $this->items['sess'] = ilArrayUtil::sortArray($this->items['sess'], 'start', 'ASC', true, true);
461  }
462 
463  $position = 1;
464 
465  foreach ($this->items[$type] as $item_data) {
466  if (!$this->renderer->hasItem($item_data["child"])) {
467  $html = $this->renderItem($item_data, $position++);
468  if ($html != "") {
469  $this->renderer->addItemToBlock($type, $item_data["type"], $item_data["child"], $html);
470  }
471  }
472  }
473  }
474  }
475  }
476  }
477 
478  protected function hasForcedOrderByStartDate(string $type): bool
479  {
480  return $type === 'sess' && get_class($this) === ilContainerSessionsContentGUI::class;
481  }
482 
483  protected function getUniqueItemId(array $a_item_data): string
484  {
485  $item_list_gui = $this->getItemGUI($a_item_data);
486  return $item_list_gui->getUniqueItemId();
487  }
488 
493  public function renderItem(
494  array $a_item_data,
495  int $a_position = 0,
496  bool $a_force_icon = false,
497  string $a_pos_prefix = "",
498  string $item_group_list_presentation = ""
499  ) {
501  $ilAccess = $this->access;
502  $ilCtrl = $this->ctrl;
503  // Pass type, obj_id and tree to checkAccess method to improve performance
504  if (!$ilAccess->checkAccess('visible', '', $a_item_data['ref_id'], $a_item_data['type'], $a_item_data['obj_id'], $a_item_data['tree'])) {
505  return '';
506  }
507 
508  $view_mode = $this->getViewMode();
509  if ($item_group_list_presentation != "") {
510  $view_mode = ($item_group_list_presentation === "tile")
511  ? self::VIEW_MODE_TILE
512  : self::VIEW_MODE_LIST;
513  }
514  if ($view_mode === self::VIEW_MODE_TILE) {
515  return $this->renderCard($a_item_data, $a_position, $a_force_icon, $a_pos_prefix);
516  }
517 
518  $item_list_gui = $this->getItemGUI($a_item_data);
519  if ($a_item_data["type"] === "sess" ||
520  $a_force_icon ||
521  $ilSetting->get("icon_position_in_lists") === "item_rows") {
522  $item_list_gui->enableIcon(true);
523  }
524 
525  if ($this->getContainerGUI()->isActiveAdministrationPanel() && !$this->clipboard->hasEntries()) {
526  $item_list_gui->enableCheckbox(true);
527  } elseif ($this->getContainerGUI()->isMultiDownloadEnabled()) {
528  // display multi download checkboxes
529  $item_list_gui->enableDownloadCheckbox((int) $a_item_data["ref_id"]);
530  }
531 
532  if ($this->getContainerGUI()->isActiveItemOrdering() && !$this->hasForcedOrderByStartDate($a_item_data['type'])) {
533  $item_list_gui->setPositionInputField(
534  $a_pos_prefix . "[" . $a_item_data["ref_id"] . "]",
535  sprintf('%d', $a_position * 10)
536  );
537  }
538 
539  if ($a_item_data['type'] === 'sess' && get_class($this) !== 'ilContainerObjectiveGUI') {
540  switch ($this->getDetailsLevel($a_item_data['obj_id'])) {
541  case self::DETAILS_TITLE:
542  $item_list_gui->setDetailsLevel(ilObjectListGUI::DETAILS_MINIMAL);
543  $item_list_gui->enableExpand(true);
544  $item_list_gui->setExpanded(false);
545  $item_list_gui->enableDescription(false);
546  $item_list_gui->enableProperties(true);
547  break;
548 
549  case self::DETAILS_ALL:
550  $item_list_gui->setDetailsLevel(ilObjectListGUI::DETAILS_ALL);
551  $item_list_gui->enableExpand(true);
552  $item_list_gui->setExpanded(true);
553  $item_list_gui->enableDescription(true);
554  $item_list_gui->enableProperties(true);
555  break;
556 
557  default:
558  $item_list_gui->setDetailsLevel(ilObjectListGUI::DETAILS_ALL);
559  $item_list_gui->enableExpand(true);
560  $item_list_gui->enableDescription(true);
561  $item_list_gui->enableProperties(true);
562  break;
563  }
564  }
565 
566  if (method_exists($this, "addItemDetails")) {
567  $this->addItemDetails($item_list_gui, $a_item_data);
568  }
569 
570  // show subitems
571  if ($a_item_data['type'] === 'sess' && (
572  $this->getDetailsLevel($a_item_data['obj_id']) !== self::DETAILS_TITLE ||
573  $this->getContainerGUI()->isActiveAdministrationPanel() ||
574  $this->getContainerGUI()->isActiveItemOrdering()
575  )) {
576  $pos = 1;
577  $items = ilObjectActivation::getItemsByEvent($a_item_data['obj_id']);
578  $items = ilContainerSorting::_getInstance($this->getContainerObject()->getId())->sortSubItems('sess', $a_item_data['obj_id'], $items);
579  $items = ilContainer::getCompleteDescriptions($items);
580 
581  $item_readable = $ilAccess->checkAccess('read', '', $a_item_data['ref_id']);
582 
583  foreach ($items as $item) {
584  // TODO: this should be removed and be handled by if(strlen($sub_item_html))
585  // see mantis: 0003944
586  if (!$ilAccess->checkAccess('visible', '', $item['ref_id'])) {
587  continue;
588  }
589 
590  $item_list_gui2 = $this->getItemGUI($item);
591  $item_list_gui2->enableIcon(true);
592  $item_list_gui2->enableItemDetailLinks(false);
593 
594  // unique js-ids
595  $item_list_gui2->setParentRefId((int) ($a_item_data['ref_id'] ?? 0));
596 
597  // @see mantis 10488
598  if (!$item_readable && !$ilAccess->checkAccess('write', '', $item['ref_id'])) {
599  $item_list_gui2->forceVisibleOnly(true);
600  }
601 
602  if ($this->getContainerGUI()->isActiveAdministrationPanel() && !$this->clipboard->hasEntries()) {
603  $item_list_gui2->enableCheckbox(true);
604  } elseif ($this->getContainerGUI()->isMultiDownloadEnabled()) {
605  // display multi download checkbox
606  $item_list_gui2->enableDownloadCheckbox((int) $item['ref_id']);
607  }
608 
609  if ($this->getContainerGUI()->isActiveItemOrdering()) {
610  $item_list_gui2->setPositionInputField(
611  "[sess][" . $a_item_data['obj_id'] . "][" . $item["ref_id"] . "]",
612  sprintf('%d', $pos * 10)
613  );
614  $pos++;
615  }
616 
617  // #10611
618  ilObjectActivation::addListGUIActivationProperty($item_list_gui2, $item);
619 
620  $sub_item_html = $item_list_gui2->getListItemHTML(
621  $item['ref_id'],
622  $item['obj_id'],
623  $item['title'],
624  $item['description']
625  );
626 
627  $this->determineAdminCommands($item["ref_id"], $item_list_gui2->adminCommandsIncluded());
628  if ($sub_item_html !== '') {
629  $item_list_gui->addSubItemHTML($sub_item_html);
630  }
631  }
632  }
633 
634  ilObjectActivation::addListGUIActivationProperty($item_list_gui, $a_item_data);
635 
636  $html = $item_list_gui->getListItemHTML(
637  (int) $a_item_data['ref_id'],
638  (int) $a_item_data['obj_id'],
639  (string) $a_item_data['title'],
640  (string) $a_item_data['description'],
641  );
642  return $html;
643  }
644 
645  public function renderCard(
646  array $a_item_data,
647  int $a_position = 0,
648  bool $a_force_icon = false,
649  string $a_pos_prefix = ""
651  $item_list_gui = $this->getItemGUI($a_item_data);
652  $item_list_gui->setAjaxHash(ilCommonActionDispatcherGUI::buildAjaxHash(
654  $a_item_data['ref_id'],
655  $a_item_data['type'],
656  (int) $a_item_data['obj_id']
657  ));
658  $item_list_gui->initItem(
659  (int) $a_item_data['ref_id'],
660  (int) $a_item_data['obj_id'],
661  (string) $a_item_data['type'],
662  (string) $a_item_data['title'],
663  (string) $a_item_data['description']
664  );
665 
666  return $item_list_gui->getAsCard(
667  $a_item_data['ref_id'],
668  (int) $a_item_data['obj_id'],
669  (string) $a_item_data['type'],
670  (string) $a_item_data['title'],
671  (string) $a_item_data['description']
672  );
673  }
674 
678  public function insertPageEmbeddedBlocks(string $a_output_html): string
679  {
680  $this->determinePageEmbeddedBlocks($a_output_html);
681  $this->renderPageEmbeddedBlocks();
682 
683  // iterate all types
684  foreach ($this->getGroupedObjTypes() as $type => $v) {
685  // set template (overall or type specific)
686  if (is_int(strpos($a_output_html, "[list-" . $type . "]"))) {
687  $a_output_html = preg_replace(
688  '~\[list-' . $type . '\]~i',
689  $this->renderer->renderSingleTypeBlock($type),
690  $a_output_html
691  );
692  }
693  }
694 
695  // insert all item groups
696  while (preg_match('~\[(item-group-([0-9]*))\]~i', $a_output_html, $found)) {
697  $itgr_ref_id = (int) $found[2];
698 
699  $a_output_html = preg_replace(
700  '~\[' . $found[1] . '\]~i',
701  $this->renderer->renderSingleCustomBlock($itgr_ref_id),
702  $a_output_html
703  );
704  }
705 
706  return $a_output_html;
707  }
708 
712  public function getSingleTypeBlockAsynch(
713  string $type
714  ): string {
715  $this->initRenderer();
716  // get all sub items
717  $this->items = $this->getContainerObject()->getSubItems(
718  $this->getContainerGUI()->isActiveAdministrationPanel()
719  );
720 
721  $exhausted = false;
722  $ref_ids = $this->request->getAlreadyRenderedRefIds();
723 
724  // iterate all types
725  if (is_array($this->items[$type]) &&
726  $this->renderer->addTypeBlock($type)) {
727  //$this->renderer->setBlockPosition($type, ++$pos);
728 
729  $position = 1;
730  $counter = 1;
731  foreach ($this->items[$type] as $item_data) {
732  $item_ref_id = $item_data["child"];
733 
734  if (in_array($item_ref_id, $ref_ids)) {
735  continue;
736  }
737  if ($this->block_limit > 0 && $counter == $this->block_limit + 1) {
738  if ($counter == $this->block_limit + 1) {
739  // render more button
740  $this->renderer->addShowMoreButton($type);
741  $exhausted = true;
742  }
743  continue;
744  }
745 
746  if (!$this->renderer->hasItem($item_ref_id)) {
747  $html = $this->renderItem($item_data, $position++);
748 
749  if ($html != "") {
750  $counter++;
751  $this->renderer->addItemToBlock($type, $item_data["type"], $item_ref_id, $html);
752  }
753  }
754  }
755  }
756 
757  return $this->renderer->renderSingleTypeBlock($type, $exhausted);
758  }
759 
763  public function getGroupedObjTypes(): array
764  {
765  $objDefinition = $this->obj_definition;
766 
767  if (empty($this->type_grps)) {
768  $this->type_grps =
769  $objDefinition::getGroupedRepositoryObjectTypes($this->getContainerObject()->getType());
770  }
771  return $this->type_grps;
772  }
773 
774  public function getIntroduction(): string
775  {
776  $lng = $this->lng;
777 
778  $lng->loadLanguageModule("rep");
779 
780  $tpl = new ilTemplate("tpl.rep_intro.html", true, true, "components/ILIAS/Repository");
781  $tpl->setVariable("IMG_REP_LARGE", ilObject::_getIcon(0, "big", "root"));
782  $tpl->setVariable("TXT_WELCOME", $lng->txt("rep_intro"));
783  $tpl->setVariable("TXT_INTRO_1", $lng->txt("rep_intro1"));
784  $tpl->setVariable("TXT_INTRO_2", $lng->txt("rep_intro2"));
785  $tpl->setVariable("TXT_INTRO_3", sprintf($lng->txt("rep_intro3"), $lng->txt("add")));
786  $tpl->setVariable("TXT_INTRO_4", sprintf($lng->txt("rep_intro4"), $lng->txt("cat_add")));
787  $tpl->setVariable("TXT_INTRO_5", $lng->txt("rep_intro5"));
788  $tpl->setVariable("TXT_INTRO_6", $lng->txt("rep_intro6"));
789 
790  return $tpl->get();
791  }
792 
793  public function getItemGroupsHTML(int $a_pos = 0): int
794  {
795  if (isset($this->items["itgr"]) && is_array($this->items["itgr"])) {
796  foreach ($this->items["itgr"] as $itgr) {
797  if (!$this->renderer->hasCustomBlock($itgr["child"])) {
798  $this->renderItemGroup($itgr);
799 
800  $this->renderer->setBlockPosition($itgr["ref_id"], ++$a_pos);
801  }
802  }
803  }
804  return $a_pos;
805  }
806 
807  public function renderItemGroup(array $a_itgr): void
808  {
809  $ilAccess = $this->access;
810  $ilUser = $this->user;
811  // #16493
812  $perm_ok = ($ilAccess->checkAccess("visible", "", $a_itgr['ref_id']) &&
813  $ilAccess->checkAccess("read", "", $a_itgr['ref_id']));
814 
815  $items = ilObjectActivation::getItemsByItemGroup($a_itgr['ref_id']);
816 
817  // get all valid ids (this is filtered)
818  $all_ids = array_map(static function (array $i): int {
819  return (int) $i["child"];
820  }, $this->items["_all"]);
821 
822  // remove filtered items
823  $items = array_filter($items, static function (array $i) use ($all_ids): bool {
824  return in_array($i["ref_id"], $all_ids);
825  });
826 
827  // if no permission is given, set the items to "rendered" but
828  // do not display the whole block
829  if (!$perm_ok) {
830  foreach ($items as $item) {
831  $this->renderer->hideItem($item["child"]);
832  }
833  return;
834  }
835 
836  $item_list_gui = $this->getItemGUI($a_itgr);
837  $item_list_gui->enableNotes(false);
838  $item_list_gui->enableTags(false);
839  $item_list_gui->enableComments(false);
840  $item_list_gui->enableTimings(false);
841  $item_list_gui->getListItemHTML(
842  $a_itgr["ref_id"],
843  $a_itgr["obj_id"],
844  $a_itgr["title"],
845  $a_itgr["description"]
846  );
847  $commands_html = $item_list_gui->getCommandsHTML($a_itgr["title"], false);
848 
849  // determine behaviour
850  $item_group = new ilObjItemGroup($a_itgr["ref_id"]);
851  $beh = $item_group->getBehaviour();
852  $stored_val = $this->block_repo->getProperty(
853  "itgr_" . $a_itgr["ref_id"],
854  $ilUser->getId(),
855  "opened"
856  );
857  if ($stored_val !== "" && $beh !== ilItemGroupBehaviour::ALWAYS_OPEN) {
858  $beh = ($stored_val === "1")
861  }
862 
863  $data = [
864  "behaviour" => $beh,
865  "store-url" => "./ilias.php?baseClass=ilcontainerblockpropertiesstoragegui&cmd=store" .
866  "&cont_block_id=itgr_" . $a_itgr['ref_id']
867  ];
868  if (ilObjItemGroup::lookupHideTitle($a_itgr["obj_id"]) &&
869  !$this->getContainerGUI()->isActiveAdministrationPanel()) {
870  $this->renderer->addCustomBlock($a_itgr["ref_id"], "", $commands_html, $data);
871  } else {
872  $this->renderer->addCustomBlock($a_itgr["ref_id"], $a_itgr["title"], $commands_html, $data);
873  }
874 
875 
876  // render item group sub items
877 
879  $this->getContainerObject()->getId()
880  )->sortSubItems('itgr', $a_itgr['obj_id'], $items);
881 
882  // #18285
883  $items = ilContainer::getCompleteDescriptions($items);
884 
885  $position = 1;
886  foreach ($items as $item) {
887  // we are NOT using hasItem() here, because item might be in multiple item groups
888 
889  $it_pres = $item_group->getListPresentation();
890  if ($this->getContainerGUI()->isActiveOrdering() ||
891  $this->getContainerGUI()->isActiveAdministrationPanel()) {
892  $it_pres = "list";
893  }
894 
895  $html2 = $this->renderItem($item, $position++, false, "[itgr][" . $a_itgr['obj_id'] . "]", $it_pres);
896  if ($html2 != "") {
897  // :TODO: show it multiple times?
898  $this->renderer->addItemToBlock($a_itgr["ref_id"], $item["type"], $item["child"], $html2, true);
899  }
900  }
901  }
902 }
setRightContent(string $a_html)
Sets content of right column.
ilContainerUserFilter $container_user_filter
static getCmdSide()
Get Column Side of Current Command.
getSingleTypeBlockAsynch(string $type)
Render single block.
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
determinePageEmbeddedBlocks(string $a_container_page_html)
Determine all blocks that are embedded in the container page.
static getLogger(string $a_component_id)
Get component logger.
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...
static getItemsByEvent(int $event_id)
Get session material / event items.
const ROOT_FOLDER_ID
Definition: constants.php:32
ilGlobalTemplateInterface $tpl
Interface Observer Contains several chained tasks and infos about them.
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
renderer()
static lookupHideTitle(int $a_id)
setContent(string $a_html)
Sets content for standard template.
const IL_COL_RIGHT
loadLanguageModule(string $a_module)
Load language module.
initRenderer()
Init container renderer.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
static _getItemsOfContainer(int $a_ref_id)
static _lookupObjId(int $ref_id)
Parent class of all container content GUIs.
static buildAjaxHash(int $node_type, ?int $node_id, string $obj_type, int $obj_id, ?string $sub_type=null, ?int $sub_id=null, int $news_id=0)
Build ajax hash.
getMainContent()
Get content HTML for main column, this one may be overwritten in derived classes. ...
$ref_id
Definition: ltiauth.php:65
const IL_SCREEN_FULL
ILIAS Container Content ItemPresentationManager $item_presentation
renderItem(array $a_item_data, int $a_position=0, bool $a_force_icon=false, string $a_pos_prefix="", string $item_group_list_presentation="")
Render an item.
Column user interface class.
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, bool $isCatchupWriteEvents=true, $a_ext_rc=null, $a_ext_time=null)
global $DIC
Definition: shib_login.php:26
forwardToColumnGUI()
Get columngui output.
static addListGUIActivationProperty(ilObjectListGUI $list_gui, array &$item)
Get timing details for list gui.
Class ilContainer.
Manages items in repository clipboard.
static _getListGUIByType(string $type, int $context=ilObjectListGUI::CONTEXT_REPOSITORY)
PathGUI which handles materials assigned to sessions.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
static getItemsByItemGroup(int $item_group_ref_id)
Get materials of item group.
Class ilObjItemGroup.
static getScreenMode()
global $ilSetting
Definition: privfeed.php:31
__construct(Container $dic, ilPlugin $plugin)
addJavaScript(string $a_js_file, bool $a_add_version_parameter=true, int $a_batch=2)
Add a javascript file that should be included in the header.
static _getInstance(int $a_obj_id)
renderCard(array $a_item_data, int $a_position=0, bool $a_force_icon=false, string $a_pos_prefix="")
saveParameterByClass(string $a_class, $a_parameter)
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
static _lookupType(int $id, bool $reference=false)
BlockSessionRepository $block_repo
const IL_SCREEN_SIDE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getCompleteDescriptions(array $objects)
overwrites description fields to long or short description in an assoc array keys needed (obj_id and ...
getGroupedObjTypes()
Get grouped repository object types.
addEmbeddedBlock(string $block_type, $block_parameter)
Add embedded block.
insertPageEmbeddedBlocks(string $a_output_html)
Insert blocks into container page.
const IL_COL_LEFT
setOutput()
This method sets the output of the right and main column in the global standard template.
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)