ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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("./Services/Container/js/Container.js");
93 
94  $this->log = ilLoggerFactory::getLogger('cont');
95 
96  $this->view_mode = (ilContainer::_lookupContainerSetting($this->container_obj->getId(), "list_presentation") === "tile" && !$this->container_gui->isActiveAdministrationPanel() && !$this->container_gui->isActiveOrdering())
97  ? self::VIEW_MODE_TILE
98  : self::VIEW_MODE_LIST;
99 
100  $this->clipboard = $DIC
101  ->repository()
102  ->internal()
103  ->domain()
104  ->clipboard();
105  $this->request = $DIC
106  ->container()
107  ->internal()
108  ->gui()
109  ->standardRequest();
110  $this->item_manager = $DIC
111  ->container()
112  ->internal()
113  ->domain()
114  ->content()
115  ->items($this->container_obj);
116  $this->block_repo = $DIC
117  ->container()
118  ->internal()
119  ->repo()
120  ->content()
121  ->block();
122  $this->item_presentation = $item_presentation;
123 
124  $this->block_limit = (int) ilContainer::_lookupContainerSetting($container_gui_obj->getObject()->getId(), "block_limit");
125  }
126 
127  protected function getViewMode(): int
128  {
129  return $this->view_mode;
130  }
131 
132 
133  public function getContainerObject(): ilContainer
134  {
135  return $this->container_obj;
136  }
137 
138  public function getContainerGUI(): ilContainerGUI
139  {
140  return $this->container_gui;
141  }
142 
147  public function setOutput(): void
148  {
149  $tpl = $this->tpl;
150  $ilCtrl = $this->ctrl;
151 
152  // note: we do not want to get the center html in case of
153  // asynchronous calls to blocks in the right column (e.g. news)
154  // see #13012
155  if ($ilCtrl->getNextClass() === "ilcolumngui" &&
156  $ilCtrl->isAsynch()) {
157  $tpl->setRightContent($this->getRightColumnHTML());
158  }
159 
160  // BEGIN ChangeEvent: record read event.
161  $ilUser = $this->user;
162 
163  $obj_id = ilObject::_lookupObjId($this->getContainerObject()->getRefId());
165  $this->getContainerObject()->getType(),
166  $this->getContainerObject()->getRefId(),
167  $obj_id,
168  $ilUser->getId()
169  );
170  // END ChangeEvent: record read event.
171 
172  $html = $this->getCenterColumnHTML();
173  if ($html !== '') {
174  $tpl->setContent($html);
175  }
176 
177  // see above, all other cases (this was the old position of setRightContent,
178  // maybe the position above is ok and all ifs can be removed)
179  if ($ilCtrl->getNextClass() !== "ilcolumngui" ||
180  !$ilCtrl->isAsynch()) {
181  $tpl->setRightContent($this->getRightColumnHTML());
182  }
183  }
184 
185  protected function getRightColumnHTML(): string
186  {
187  $ilCtrl = $this->ctrl;
188  $html = "";
189 
190  $ilCtrl->saveParameterByClass("ilcolumngui", "col_return");
191 
192  $obj_id = ilObject::_lookupObjId($this->getContainerObject()->getRefId());
193  $obj_type = ilObject::_lookupType($obj_id);
194 
195  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
196 
197  if ($column_gui::getScreenMode() === IL_SCREEN_FULL) {
198  return "";
199  }
200 
201  $this->getContainerGUI()->setColumnSettings($column_gui);
202 
203  if ($ilCtrl->getNextClass() === "ilcolumngui" &&
204  $column_gui::getCmdSide() === IL_COL_RIGHT &&
205  $column_gui::getScreenMode() === IL_SCREEN_SIDE) {
206  $html = $ilCtrl->forwardCommand($column_gui);
207  } else {
208  if (!$ilCtrl->isAsynch()) {
209  $html = "";
210 
211  // user interface plugin slot + default rendering
212  $uip = new ilUIHookProcessor(
213  "Services/Container",
214  "right_column",
215  ["container_content_gui" => $this]
216  );
217  if (!$uip->replaced()) {
218  $html = $ilCtrl->getHTML($column_gui);
219  }
220  $html = $uip->getHTML($html);
221  }
222  }
223 
224  return $html;
225  }
226 
227  protected function getCenterColumnHTML(): string
228  {
229  $ilCtrl = $this->ctrl;
230  $tpl = $this->tpl;
231  $ilDB = $this->db;
232 
233  $ilCtrl->saveParameterByClass("ilcolumngui", "col_return");
234 
235  $tpl->addOnLoadCode("il.Object.setRedrawListItemUrl('" .
236  $ilCtrl->getLinkTarget($this->container_gui, "redrawListItem", "", true) . "');");
237 
238  $tpl->addOnLoadCode("il.Object.setRatingUrl('" .
239  $ilCtrl->getLinkTargetByClass(
240  [get_class($this->container_gui), "ilcommonactiondispatchergui", "ilratinggui"],
241  "saveRating",
242  "",
243  true,
244  false
245  ) . "');");
246 
247  switch ($ilCtrl->getNextClass()) {
248  case "ilcolumngui":
249  $this->container_gui->setSideColumnReturn();
250  $html = $this->forwardToColumnGUI();
251  break;
252 
253  default:
254  $ilDB->useSlave(true);
255  $html = $this->getMainContent();
256  $ilDB->useSlave(false);
257  break;
258  }
259 
260  return $html;
261  }
262 
267  public function getMainContent(): string
268  {
269  $ilAccess = $this->access;
270 
271  $tpl = new ilTemplate(
272  "tpl.container_page.html",
273  true,
274  true,
275  "Services/Container"
276  );
277  // Show introduction, if repository is empty
278  if (!$this->item_presentation->hasItems() &&
279  $this->getContainerObject()->getRefId() == ROOT_FOLDER_ID &&
280  $ilAccess->checkAccess("write", "", $this->getContainerObject()->getRefId())) {
281  $html = $this->getIntroduction();
282  } else { // show item list otherwise
283  $html = $this->renderItemList();
284  }
285  $tpl->setVariable("CONTAINER_PAGE_CONTENT", $html);
286 
287  return $tpl->get();
288  }
289 
293  protected function initRenderer(): void
294  {
296 
297  $this->renderer = new ilContainerRenderer(
298  $this->item_presentation,
299  ($this->getContainerGUI()->isActiveAdministrationPanel() && !$this->clipboard->hasEntries()),
300  $this->getContainerGUI()->isMultiDownloadEnabled(),
301  $this->getContainerGUI()->isActiveOrdering() && (get_class($this) !== "ilContainerObjectiveGUI") // no block sorting in objective view
302  ,
303  $sorting->getBlockPositions(),
305  $this->getViewMode(),
306  $this->getContainerGUI()->isActiveAdministrationPanel()
307  );
308 
309  // all event items are included per session rendering
310  // and should return true for hasItem
311  $event_items = ilEventItems::_getItemsOfContainer($this->container_obj->getRefId());
312  foreach ($event_items as $ev) {
313  $this->renderer->addItemId($ev);
314  }
315  }
316 
320  private function forwardToColumnGUI(): string
321  {
322  $ilCtrl = $this->ctrl;
323  $html = "";
324 
325  // this gets us the subitems we need in setColumnSettings()
326  // todo: this should be done in ilCourseGUI->getSubItems
327 
328  $obj_id = ilObject::_lookupObjId($this->getContainerObject()->getRefId());
329  $obj_type = ilObject::_lookupType($obj_id);
330 
331  if (!$ilCtrl->isAsynch()) {
333  // right column wants center
335  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
336  $this->getContainerGUI()->setColumnSettings($column_gui);
337  $html = $ilCtrl->forwardCommand($column_gui);
338  }
339  // left column wants center
341  $column_gui = new ilColumnGUI($obj_type, IL_COL_LEFT);
342  $this->getContainerGUI()->setColumnSettings($column_gui);
343  $html = $ilCtrl->forwardCommand($column_gui);
344  }
345  } else {
346  $html = $this->getMainContent();
347  }
348  }
349 
350  return $html;
351  }
352 
353  protected function getItemGUI(array $item_data): ilObjectListGUI
354  {
355  // get item list gui object
356  if (!isset($this->list_gui[$item_data["type"]])) {
357  $item_list_gui = ilObjectListGUIFactory::_getListGUIByType($item_data["type"]);
358  $item_list_gui->setContainerObject($this->getContainerGUI());
359  $this->list_gui[$item_data["type"]] = &$item_list_gui;
360  } else {
361  $item_list_gui = &$this->list_gui[$item_data["type"]];
362  }
363 
364  // unique js-ids
365  $item_list_gui->setParentRefId((int) ($item_data["parent"] ?? 0));
366 
367  $item_list_gui->setDefaultCommandParameters([]);
368  $item_list_gui->disableTitleLink(false);
369  $item_list_gui->resetConditionTarget();
370 
371  if ($this->container_obj->isClassificationFilterActive()) {
372  $item_list_gui->enablePath(
373  true,
374  $this->container_obj->getRefId(),
376  );
377  }
378 
379  // activate common social commands
380  $item_list_gui->enableComments(true);
381  $item_list_gui->enableNotes(true);
382  $item_list_gui->enableTags(true);
383  $item_list_gui->enableRating(true);
384 
385  // reset
386  $item_list_gui->forceVisibleOnly(false);
387 
388  // container specific modifications
389  $this->getContainerGUI()->modifyItemGUI($item_list_gui, $item_data);
390 
391  return $item_list_gui;
392  }
393 
398  string $a_container_page_html
399  ): void {
400  $type_grps = $this->getGroupedObjTypes();
401 
402  // iterate all types
403  foreach ($type_grps as $type => $v) {
404  // set template (overall or type specific)
405  if (is_int(strpos($a_container_page_html, "[list-" . $type . "]"))) {
406  $this->addEmbeddedBlock("type", $type);
407  }
408  }
409 
410  // determine item groups
411  while (preg_match('~\[(item-group-([0-9]*))\]~i', $a_container_page_html, $found)) {
412  $this->addEmbeddedBlock("itgr", (int) $found[2]);
413 
414  $html = ''; // This was never defined before
415  $a_container_page_html = preg_replace('~\[' . $found[1] . '\]~i', $html, $a_container_page_html);
416  }
417  }
418 
424  public function addEmbeddedBlock(
425  string $block_type,
426  $block_parameter
427  ): void {
428  $this->embedded_block[$block_type][] = $block_parameter;
429  }
430 
431  public function getEmbeddedBlocks(): array
432  {
433  return $this->embedded_block;
434  }
435 
436  public function renderPageEmbeddedBlocks(): void
437  {
438  // item groups
439  if (isset($this->embedded_block["itgr"]) && is_array($this->embedded_block["itgr"])) {
440  $item_groups = [];
441  if (isset($this->items["itgr"]) && is_array($this->items["itgr"])) {
442  foreach ($this->items["itgr"] as $ig) {
443  $item_groups[$ig["ref_id"]] = $ig;
444  }
445  }
446 
447  foreach ($this->embedded_block["itgr"] as $ref_id) {
448  if (isset($item_groups[$ref_id])) {
449  $this->renderItemGroup($item_groups[$ref_id]);
450  }
451  }
452  }
453 
454  // type specific blocks
455  if (isset($this->embedded_block["type"]) && is_array($this->embedded_block["type"])) {
456  foreach ($this->embedded_block["type"] as $type) {
457  if (isset($this->items[$type]) && is_array($this->items[$type]) && $this->renderer->addTypeBlock($type)) {
458  if ($this->hasForcedOrderByStartDate($type)) {
459  $this->items['sess'] = ilArrayUtil::sortArray($this->items['sess'], 'start', 'ASC', true, true);
460  }
461 
462  $position = 1;
463 
464  foreach ($this->items[$type] as $item_data) {
465  if (!$this->renderer->hasItem($item_data["child"])) {
466  $html = $this->renderItem($item_data, $position++);
467  if ($html != "") {
468  $this->renderer->addItemToBlock($type, $item_data["type"], $item_data["child"], $html);
469  }
470  }
471  }
472  }
473  }
474  }
475  }
476 
477  protected function hasForcedOrderByStartDate(string $type): bool
478  {
479  return $type === 'sess' && get_class($this) === ilContainerSessionsContentGUI::class;
480  }
481 
482  protected function getUniqueItemId(array $a_item_data): string
483  {
484  $item_list_gui = $this->getItemGUI($a_item_data);
485  return $item_list_gui->getUniqueItemId();
486  }
487 
492  public function renderItem(
493  array $a_item_data,
494  int $a_position = 0,
495  bool $a_force_icon = false,
496  string $a_pos_prefix = "",
497  string $item_group_list_presentation = ""
498  ) {
500  $ilAccess = $this->access;
501  $ilCtrl = $this->ctrl;
502 
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 
578  $items = ilObjectActivation::getItemsByEvent($a_item_data['obj_id']);
579  $items = ilContainerSorting::_getInstance($this->getContainerObject()->getId())->sortSubItems('sess', $a_item_data['obj_id'], $items);
580  $items = ilContainer::getCompleteDescriptions($items);
581 
582  $item_readable = $ilAccess->checkAccess('read', '', $a_item_data['ref_id']);
583 
584  foreach ($items as $item) {
585  // TODO: this should be removed and be handled by if(strlen($sub_item_html))
586  // see mantis: 0003944
587  if (!$ilAccess->checkAccess('visible', '', $item['ref_id'])) {
588  continue;
589  }
590 
591  $item_list_gui2 = $this->getItemGUI($item);
592  $item_list_gui2->enableIcon(true);
593  $item_list_gui2->enableItemDetailLinks(false);
594 
595  // unique js-ids
596  $item_list_gui2->setParentRefId((int) ($a_item_data['ref_id'] ?? 0));
597 
598  // @see mantis 10488
599  if (!$item_readable && !$ilAccess->checkAccess('write', '', $item['ref_id'])) {
600  $item_list_gui2->forceVisibleOnly(true);
601  }
602 
603  if ($this->getContainerGUI()->isActiveAdministrationPanel() && !$this->clipboard->hasEntries()) {
604  $item_list_gui2->enableCheckbox(true);
605  } elseif ($this->getContainerGUI()->isMultiDownloadEnabled()) {
606  // display multi download checkbox
607  $item_list_gui2->enableDownloadCheckbox((int) $item['ref_id']);
608  }
609 
610  if ($this->getContainerGUI()->isActiveItemOrdering()) {
611  $item_list_gui2->setPositionInputField(
612  "[sess][" . $a_item_data['obj_id'] . "][" . $item["ref_id"] . "]",
613  sprintf('%d', $pos * 10)
614  );
615  $pos++;
616  }
617 
618  // #10611
619  ilObjectActivation::addListGUIActivationProperty($item_list_gui2, $item);
620 
621  $sub_item_html = $item_list_gui2->getListItemHTML(
622  $item['ref_id'],
623  $item['obj_id'],
624  $item['title'],
625  $item['description']
626  );
627 
628  $this->determineAdminCommands($item["ref_id"], $item_list_gui2->adminCommandsIncluded());
629  if ($sub_item_html !== '') {
630  $item_list_gui->addSubItemHTML($sub_item_html);
631  }
632  }
633  }
634 
635  $asynch = false;
636  $asynch_url = '';
637  if ($ilSetting->get("item_cmd_asynch")) {
638  $asynch = true;
639  $ilCtrl->setParameter($this->container_gui, "cmdrefid", $a_item_data['ref_id']);
640  $asynch_url = $ilCtrl->getLinkTarget(
641  $this->container_gui,
642  "getAsynchItemList",
643  "",
644  true,
645  false
646  );
647  $ilCtrl->setParameter($this->container_gui, "cmdrefid", "");
648  }
649 
650  ilObjectActivation::addListGUIActivationProperty($item_list_gui, $a_item_data);
651 
652  $html = $item_list_gui->getListItemHTML(
653  (int) $a_item_data['ref_id'],
654  (int) $a_item_data['obj_id'],
655  (string) $a_item_data['title'],
656  (string) $a_item_data['description'],
657  $asynch,
658  false,
659  $asynch_url
660  );
661  return $html;
662  }
663 
664  public function renderCard(
665  array $a_item_data,
666  int $a_position = 0,
667  bool $a_force_icon = false,
668  string $a_pos_prefix = ""
670  $item_list_gui = $this->getItemGUI($a_item_data);
671  $item_list_gui->setAjaxHash(ilCommonActionDispatcherGUI::buildAjaxHash(
673  $a_item_data['ref_id'],
674  $a_item_data['type'],
675  (int) $a_item_data['obj_id']
676  ));
677  $item_list_gui->initItem(
678  (int) $a_item_data['ref_id'],
679  (int) $a_item_data['obj_id'],
680  (string) $a_item_data['type'],
681  (string) $a_item_data['title'],
682  (string) $a_item_data['description']
683  );
684 
685  // actions
686  $item_list_gui->insertCommands();
687  return $item_list_gui->getAsCard(
688  $a_item_data['ref_id'],
689  (int) $a_item_data['obj_id'],
690  (string) $a_item_data['type'],
691  (string) $a_item_data['title'],
692  (string) $a_item_data['description']
693  );
694  }
695 
699  public function insertPageEmbeddedBlocks(string $a_output_html): string
700  {
701  $this->determinePageEmbeddedBlocks($a_output_html);
702  $this->renderPageEmbeddedBlocks();
703 
704  // iterate all types
705  foreach ($this->getGroupedObjTypes() as $type => $v) {
706  // set template (overall or type specific)
707  if (is_int(strpos($a_output_html, "[list-" . $type . "]"))) {
708  $a_output_html = preg_replace(
709  '~\[list-' . $type . '\]~i',
710  $this->renderer->renderSingleTypeBlock($type),
711  $a_output_html
712  );
713  }
714  }
715 
716  // insert all item groups
717  while (preg_match('~\[(item-group-([0-9]*))\]~i', $a_output_html, $found)) {
718  $itgr_ref_id = (int) $found[2];
719 
720  $a_output_html = preg_replace(
721  '~\[' . $found[1] . '\]~i',
722  $this->renderer->renderSingleCustomBlock($itgr_ref_id),
723  $a_output_html
724  );
725  }
726 
727  return $a_output_html;
728  }
729 
733  public function getSingleTypeBlockAsynch(
734  string $type
735  ): string {
736  $this->initRenderer();
737  // get all sub items
738  $this->items = $this->getContainerObject()->getSubItems(
739  $this->getContainerGUI()->isActiveAdministrationPanel()
740  );
741 
742  $exhausted = false;
743  $ref_ids = $this->request->getAlreadyRenderedRefIds();
744 
745  // iterate all types
746  if (is_array($this->items[$type]) &&
747  $this->renderer->addTypeBlock($type)) {
748  //$this->renderer->setBlockPosition($type, ++$pos);
749 
750  $position = 1;
751  $counter = 1;
752  foreach ($this->items[$type] as $item_data) {
753  $item_ref_id = $item_data["child"];
754 
755  if (in_array($item_ref_id, $ref_ids)) {
756  continue;
757  }
758  if ($this->block_limit > 0 && $counter == $this->block_limit + 1) {
759  if ($counter == $this->block_limit + 1) {
760  // render more button
761  $this->renderer->addShowMoreButton($type);
762  $exhausted = true;
763  }
764  continue;
765  }
766 
767  if (!$this->renderer->hasItem($item_ref_id)) {
768  $html = $this->renderItem($item_data, $position++);
769  if ($html != "") {
770 
771  $unique_id = $this->getUniqueItemId($item_data);
772  // workaround for legacy adv selection lists asynch loading start...
773  $js_tpl = new ilTemplate(
774  "tpl.adv_selection_list_js_init.js",
775  true,
776  true,
777  "Services/UIComponent/AdvancedSelectionList",
778  "DEFAULT",
779  false,
780  true
781  );
782  $this->ctrl->setParameter($this->container_gui, "cmdrefid", $item_data['ref_id']);
783  $asynch_url = $this->ctrl->getLinkTarget(
784  $this->container_gui,
785  "getAsynchItemList",
786  "",
787  true,
788  false
789  );
790  $this->ctrl->setParameter($this->container_gui, "cmdrefid", "");
791  $unique_id = 'act_' . $unique_id;
792  $js_tpl->setVariable("ID", $unique_id);
793  $js_tpl->setCurrentBlock("asynch_bl");
794  $js_tpl->setVariable("ASYNCH_URL", $asynch_url);
795  $js_tpl->setVariable("ASYNCH_ID", $unique_id);
796  $js_tpl->setVariable("ASYNCH_TRIGGER_ID", $unique_id);
797  $js_tpl->parseCurrentBlock();
798  if (is_string($html)) {
799  $html .= "<script>" . $js_tpl->get() . "</script>";
800  }
801  // ...end
802 
803 
804  $counter++;
805  $this->renderer->addItemToBlock($type, $item_data["type"], $item_ref_id, $html);
806  }
807  }
808  }
809  }
810 
811  return $this->renderer->renderSingleTypeBlock($type, $exhausted);
812  }
813 
817  public function getGroupedObjTypes(): array
818  {
819  $objDefinition = $this->obj_definition;
820 
821  if (empty($this->type_grps)) {
822  $this->type_grps =
823  $objDefinition::getGroupedRepositoryObjectTypes($this->getContainerObject()->getType());
824  }
825  return $this->type_grps;
826  }
827 
828  public function getIntroduction(): string
829  {
830  $lng = $this->lng;
831 
832  $lng->loadLanguageModule("rep");
833 
834  $tpl = new ilTemplate("tpl.rep_intro.html", true, true, "Services/Repository");
835  $tpl->setVariable("IMG_REP_LARGE", ilObject::_getIcon(0, "big", "root"));
836  $tpl->setVariable("TXT_WELCOME", $lng->txt("rep_intro"));
837  $tpl->setVariable("TXT_INTRO_1", $lng->txt("rep_intro1"));
838  $tpl->setVariable("TXT_INTRO_2", $lng->txt("rep_intro2"));
839  $tpl->setVariable("TXT_INTRO_3", sprintf($lng->txt("rep_intro3"), $lng->txt("add")));
840  $tpl->setVariable("TXT_INTRO_4", sprintf($lng->txt("rep_intro4"), $lng->txt("cat_add")));
841  $tpl->setVariable("TXT_INTRO_5", $lng->txt("rep_intro5"));
842  $tpl->setVariable("TXT_INTRO_6", $lng->txt("rep_intro6"));
843 
844  return $tpl->get();
845  }
846 
847  public function getItemGroupsHTML(int $a_pos = 0): int
848  {
849  if (isset($this->items["itgr"]) && is_array($this->items["itgr"])) {
850  foreach ($this->items["itgr"] as $itgr) {
851  if (!$this->renderer->hasCustomBlock($itgr["child"])) {
852  $this->renderItemGroup($itgr);
853 
854  $this->renderer->setBlockPosition($itgr["ref_id"], ++$a_pos);
855  }
856  }
857  }
858  return $a_pos;
859  }
860 
861  public function renderItemGroup(array $a_itgr): void
862  {
863  $ilAccess = $this->access;
864  $ilUser = $this->user;
865  // #16493
866  $perm_ok = ($ilAccess->checkAccess("visible", "", $a_itgr['ref_id']) &&
867  $ilAccess->checkAccess("read", "", $a_itgr['ref_id']));
868 
869  $items = ilObjectActivation::getItemsByItemGroup($a_itgr['ref_id']);
870 
871  // get all valid ids (this is filtered)
872  $all_ids = array_map(static function (array $i): int {
873  return (int) $i["child"];
874  }, $this->items["_all"]);
875 
876  // remove filtered items
877  $items = array_filter($items, static function (array $i) use ($all_ids): bool {
878  return in_array($i["ref_id"], $all_ids);
879  });
880 
881  // if no permission is given, set the items to "rendered" but
882  // do not display the whole block
883  if (!$perm_ok) {
884  foreach ($items as $item) {
885  $this->renderer->hideItem($item["child"]);
886  }
887  return;
888  }
889 
890  $item_list_gui = $this->getItemGUI($a_itgr);
891  $item_list_gui->enableNotes(false);
892  $item_list_gui->enableTags(false);
893  $item_list_gui->enableComments(false);
894  $item_list_gui->enableTimings(false);
895  $item_list_gui->getListItemHTML(
896  $a_itgr["ref_id"],
897  $a_itgr["obj_id"],
898  $a_itgr["title"],
899  $a_itgr["description"]
900  );
901  $commands_html = $item_list_gui->getCommandsHTML();
902 
903  // determine behaviour
904  $item_group = new ilObjItemGroup($a_itgr["ref_id"]);
905  $beh = $item_group->getBehaviour();
906  $stored_val = $this->block_repo->getProperty(
907  "itgr_" . $a_itgr["ref_id"],
908  $ilUser->getId(),
909  "opened"
910  );
911  if ($stored_val !== "" && $beh !== ilItemGroupBehaviour::ALWAYS_OPEN) {
912  $beh = ($stored_val === "1")
915  }
916 
917  $data = [
918  "behaviour" => $beh,
919  "store-url" => "./ilias.php?baseClass=ilcontainerblockpropertiesstoragegui&cmd=store" .
920  "&cont_block_id=itgr_" . $a_itgr['ref_id']
921  ];
922  if (ilObjItemGroup::lookupHideTitle($a_itgr["obj_id"]) &&
923  !$this->getContainerGUI()->isActiveAdministrationPanel()) {
924  $this->renderer->addCustomBlock($a_itgr["ref_id"], "", $commands_html, $data);
925  } else {
926  $this->renderer->addCustomBlock($a_itgr["ref_id"], $a_itgr["title"], $commands_html, $data);
927  }
928 
929 
930  // render item group sub items
931 
933  $this->getContainerObject()->getId()
934  )->sortSubItems('itgr', $a_itgr['obj_id'], $items);
935 
936  // #18285
937  $items = ilContainer::getCompleteDescriptions($items);
938 
939  $position = 1;
940  foreach ($items as $item) {
941  // we are NOT using hasItem() here, because item might be in multiple item groups
942 
943  $it_pres = $item_group->getListPresentation();
944  if ($this->getContainerGUI()->isActiveOrdering() ||
945  $this->getContainerGUI()->isActiveAdministrationPanel()) {
946  $it_pres = "list";
947  }
948 
949  $html2 = $this->renderItem($item, $position++, false, "[itgr][" . $a_itgr['obj_id'] . "]", $it_pres);
950  if ($html2 != "") {
951  // :TODO: show it multiple times?
952  $this->renderer->addItemToBlock($a_itgr["ref_id"], $item["type"], $item["child"], $html2, true);
953  }
954  }
955  }
956 }
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
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
static lookupHideTitle(int $a_id)
const IL_COL_RIGHT
loadLanguageModule(string $a_module)
Load language module.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
initRenderer()
Init container renderer.
static _getItemsOfContainer(int $a_ref_id)
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
static _lookupObjId(int $ref_id)
Parent class of all container content GUIs.
global $DIC
Definition: feed.php:28
getMainContent()
Get content HTML for main column, this one may be overwritten in derived classes. ...
parses the objects.xml it handles the xml-description of all ilias objects
$ref_id
Definition: ltiauth.php:67
const IL_SCREEN_FULL
__construct(VocabulariesInterface $vocabularies)
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.
setContent(string $a_html)
Sets content for standard template.
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)
forwardToColumnGUI()
Get columngui output.
static addListGUIActivationProperty(ilObjectListGUI $list_gui, array &$item)
Get timing details for list gui.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
Manages items in repository clipboard.
static _getListGUIByType(string $type, int $context=ilObjectListGUI::CONTEXT_REPOSITORY)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.
static getItemsByItemGroup(int $item_group_ref_id)
Get materials of item group.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
static getScreenMode()
global $ilSetting
Definition: privfeed.php:18
static _getInstance(int $a_obj_id)
Class ilContainerGUI This is a base GUI class for all container objects in ILIAS: root folder...
setRightContent(string $a_html)
Sets content of right column.
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 _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)