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