ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilContainerContentGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 
16 abstract class ilContainerContentGUI
17 {
21  protected $tpl;
22 
26  protected $ctrl;
27 
31  protected $user;
32 
36  protected $lng;
37 
41  protected $access;
42 
46  protected $plugin_admin;
47 
51  protected $db;
52 
56  protected $rbacsystem;
57 
61  protected $settings;
62 
66  protected $obj_definition;
67 
69  const DETAILS_TITLE = 1;
70  const DETAILS_ALL = 2;
71 
72  const VIEW_MODE_LIST = 0;
73  const VIEW_MODE_TILE = 1;
74 
75  protected $details_level = self::DETAILS_DEACTIVATED;
76 
80  protected $renderer;
81 
84 
88  protected $log;
89 
93  protected $view_mode;
94 
99  public function __construct(&$container_gui_obj)
100  {
101  global $DIC;
102 
103  $this->tpl = $DIC["tpl"];
104  $this->ctrl = $DIC->ctrl();
105  $this->user = $DIC->user();
106  $this->lng = $DIC->language();
107  $this->access = $DIC->access();
108  $this->plugin_admin = $DIC["ilPluginAdmin"];
109  $this->db = $DIC->database();
110  $this->rbacsystem = $DIC->rbac()->system();
111  $this->settings = $DIC->settings();
112  $this->obj_definition = $DIC["objDefinition"];
113  $tpl = $DIC["tpl"];
114 
115  $this->container_gui = $container_gui_obj;
116  $this->container_obj = $this->container_gui->object;
117 
118  $tpl->addJavaScript("./Services/Container/js/Container.js");
119 
120  $this->log = ilLoggerFactory::getLogger('cont');
121 
122  $this->view_mode = (ilContainer::_lookupContainerSetting($this->container_obj->getId(), "list_presentation") == "tile" && !$this->container_gui->isActiveAdministrationPanel() && !$this->container_gui->isActiveOrdering())
123  ? self::VIEW_MODE_TILE
124  : self::VIEW_MODE_LIST;
125  }
126 
130  protected function getViewMode()
131  {
132  return $this->view_mode;
133  }
134 
135 
143  protected function getDetailsLevel($a_item_id)
144  {
145  return $this->details_level;
146  }
147 
153  public function getContainerObject()
154  {
155  return $this->container_obj;
156  }
157 
163  public function getContainerGUI()
164  {
165  return $this->container_gui;
166  }
167 
174  public function setOutput()
175  {
176  $tpl = $this->tpl;
177  $ilCtrl = $this->ctrl;
178 
179  // note: we do not want to get the center html in case of
180  // asynchronous calls to blocks in the right column (e.g. news)
181  // see #13012
182  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
183  $ilCtrl->isAsynch()) {
184  $tpl->setRightContent($this->getRightColumnHTML());
185  }
186 
187  // BEGIN ChangeEvent: record read event.
188  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
190 
191  $obj_id = ilObject::_lookupObjId($this->getContainerObject()->getRefId());
193  $this->getContainerObject()->getType(),
194  $this->getContainerObject()->getRefId(),
195  $obj_id,
196  $ilUser->getId()
197  );
198  // END ChangeEvent: record read event.
199 
200  $html = $this->getCenterColumnHTML();
201  if (strlen($html)) {
202  $tpl->setContent($html);
203  }
204 
205  // see above, all other cases (this was the old position of setRightContent,
206  // maybe the position above is ok and all ifs can be removed)
207  if ($ilCtrl->getNextClass() != "ilcolumngui" ||
208  !$ilCtrl->isAsynch()) {
209  $tpl->setRightContent($this->getRightColumnHTML());
210  }
211  }
212 
216  protected function getRightColumnHTML()
217  {
219  $lng = $this->lng;
220  $ilCtrl = $this->ctrl;
221  $ilAccess = $this->access;
222  $ilPluginAdmin = $this->plugin_admin;
223 
224  $ilCtrl->saveParameterByClass("ilcolumngui", "col_return");
225 
226  $obj_id = ilObject::_lookupObjId($this->getContainerObject()->getRefId());
227  $obj_type = ilObject::_lookupType($obj_id);
228 
229  include_once("Services/Block/classes/class.ilColumnGUI.php");
230  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
231 
232  if ($column_gui->getScreenMode() == IL_SCREEN_FULL) {
233  return "";
234  }
235 
236  $this->getContainerGUI()->setColumnSettings($column_gui);
237 
238  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
239  $column_gui->getCmdSide() == IL_COL_RIGHT &&
240  $column_gui->getScreenMode() == IL_SCREEN_SIDE) {
241  $html = $ilCtrl->forwardCommand($column_gui);
242  } else {
243  $render_content = ($ilCtrl->getNextClass() == "" &&
244  in_array($ilCtrl->getCmd(), ["view", "render"]));
245  $render_content = false;
246  if (!$ilCtrl->isAsynch() || $render_content) {
247  $html = "";
248 
249  // user interface plugin slot + default rendering
250  include_once("./Services/UIComponent/classes/class.ilUIHookProcessor.php");
251  $uip = new ilUIHookProcessor(
252  "Services/Container",
253  "right_column",
254  array("container_content_gui" => $this)
255  );
256  if (!$uip->replaced()) {
257  $html = $ilCtrl->getHTML($column_gui);
258  }
259  $html = $uip->getHTML($html);
260  }
261  }
262 
263  return $html;
264  }
265 
269  protected function getCenterColumnHTML()
270  {
271  $ilCtrl = $this->ctrl;
272  $tpl = $this->tpl;
273  $ilDB = $this->db;
274 
275  $ilCtrl->saveParameterByClass("ilcolumngui", "col_return");
276 
277  $tpl->addOnLoadCode("il.Object.setRedrawListItemUrl('" .
278  $ilCtrl->getLinkTarget($this->container_gui, "redrawListItem", "", true) . "');");
279 
280  $tpl->addOnLoadCode("il.Object.setRatingUrl('" .
281  $ilCtrl->getLinkTargetByClass(
282  array(get_class($this->container_gui), "ilcommonactiondispatchergui", "ilratinggui"),
283  "saveRating",
284  "",
285  true,
286  false
287  ) . "');");
288 
289  switch ($ilCtrl->getNextClass()) {
290  case "ilcolumngui":
291  $this->container_gui->setSideColumnReturn();
292  $html = $this->__forwardToColumnGUI();
293  break;
294 
295  default:
296  $ilDB->useSlave(true);
297  $html = $this->getMainContent();
298  $ilDB->useSlave(false);
299  break;
300  }
301 
302  return $html;
303  }
304 
309  abstract public function getMainContent();
310 
314  protected function initRenderer()
315  {
316  include_once('./Services/Container/classes/class.ilContainerSorting.php');
317  $sorting = ilContainerSorting::_getInstance($this->getContainerObject()->getId());
318 
319  include_once "Services/Container/classes/class.ilContainerRenderer.php";
320  $this->renderer = new ilContainerRenderer(
321  ($this->getContainerGUI()->isActiveAdministrationPanel() && !$_SESSION["clipboard"]),
322  $this->getContainerGUI()->isMultiDownloadEnabled(),
323  $this->getContainerGUI()->isActiveOrdering() && (get_class($this) != "ilContainerObjectiveGUI") // no block sorting in objective view
324  ,
325  $sorting->getBlockPositions(),
327  $this->getViewMode()
328  );
329 
330  // all event items are included per session rendering
331  // and should return true for hasItem
332  $event_items = ilEventItems::_getItemsOfContainer($this->container_obj->getRefId());
333  foreach ($event_items as $ev) {
334  $this->renderer->addItemId($ev);
335  }
336  }
337 
341  private function __forwardToColumnGUI()
342  {
343  $ilCtrl = $this->ctrl;
344  $ilAccess = $this->access;
345 
346  include_once("Services/Block/classes/class.ilColumnGUI.php");
347 
348  // this gets us the subitems we need in setColumnSettings()
349  // todo: this should be done in ilCourseGUI->getSubItems
350 
351  $obj_id = ilObject::_lookupObjId($this->getContainerObject()->getRefId());
352  $obj_type = ilObject::_lookupType($obj_id);
353 
354  if (!$ilCtrl->isAsynch()) {
355  //if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
357  // right column wants center
359  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
360  $this->getContainerGUI()->setColumnSettings($column_gui);
361  $html = $ilCtrl->forwardCommand($column_gui);
362  }
363  // left column wants center
365  $column_gui = new ilColumnGUI($obj_type, IL_COL_LEFT);
366  $this->getContainerGUI()->setColumnSettings($column_gui);
367  $html = $ilCtrl->forwardCommand($column_gui);
368  }
369  } else {
370  $html = $this->getMainContent();
371  }
372  }
373 
374  return $html;
375  }
376 
380  protected function clearAdminCommandsDetermination()
381  {
382  $this->adminCommands = false;
383  }
384 
388  protected function determineAdminCommands($a_ref_id, $a_admin_com_included_in_list = false)
389  {
391 
392  //echo "-".$a_admin_com_included_in_list."-";
393 
394  if (!$this->adminCommands) {
395  if (!$this->getContainerGUI()->isActiveAdministrationPanel()) {
396  if ($rbacsystem->checkAccess("delete", $a_ref_id)) {
397  $this->adminCommands = true;
398  }
399  } else {
400  $this->adminCommands = $a_admin_com_included_in_list;
401  }
402  }
403  }
404 
408  protected function getItemGUI($item_data, $a_show_path = false)
409  {
410  include_once 'Services/Object/classes/class.ilObjectListGUIFactory.php';
411 
412  // get item list gui object
413  if (!is_object($this->list_gui[$item_data["type"]])) {
414  $item_list_gui = &ilObjectListGUIFactory::_getListGUIByType($item_data["type"]);
415  $item_list_gui->setContainerObject($this->getContainerGUI());
416  $this->list_gui[$item_data["type"]] = &$item_list_gui;
417  } else {
418  $item_list_gui = &$this->list_gui[$item_data["type"]];
419  }
420 
421  // unique js-ids
422  $item_list_gui->setParentRefId($item_data["parent"]);
423 
424  $item_list_gui->setDefaultCommandParameters(array());
425  $item_list_gui->disableTitleLink(false);
426  $item_list_gui->resetConditionTarget();
427 
428  if ($this->container_obj->isClassificationFilterActive()) {
429  $item_list_gui->enablePath(
430  true,
431  $this->container_obj->getRefId(),
432  new \ilSessionClassificationPathGUI()
433  );
434  }
435 
436  // show administration command buttons (or not)
437  if (!$this->getContainerGUI()->isActiveAdministrationPanel()) {
438  // $item_list_gui->enableDelete(false);
439 // $item_list_gui->enableLink(false);
440 // $item_list_gui->enableCut(false);
441  }
442 
443  // activate common social commands
444  $item_list_gui->enableComments(true);
445  $item_list_gui->enableNotes(true);
446  $item_list_gui->enableTags(true);
447  $item_list_gui->enableRating(true);
448 
449  // reset
450  $item_list_gui->forceVisibleOnly(false);
451 
452  // container specific modifications
453  $this->getContainerGUI()->modifyItemGUI($item_list_gui, $item_data, $a_show_path);
454 
455  return $item_list_gui;
456  }
457 
461  public function determinePageEmbeddedBlocks($a_container_page_html)
462  {
463  $type_grps = $this->getGroupedObjTypes();
464 
465  // iterate all types
466  foreach ($type_grps as $type => $v) {
467  // set template (overall or type specific)
468  if (is_int(strpos($a_container_page_html, "[list-" . $type . "]"))) {
469  $this->addEmbeddedBlock("type", $type);
470  }
471  }
472 
473  // determine item groups
474  while (preg_match('~\[(item-group-([0-9]*))\]~i', $a_container_page_html, $found)) {
475  $this->addEmbeddedBlock("itgr", (int) $found[2]);
476 
477  $a_container_page_html = preg_replace('~\[' . $found[1] . '\]~i', $html, $a_container_page_html);
478  }
479  }
480 
486  public function addEmbeddedBlock($block_type, $block_parameter)
487  {
488  $this->embedded_block[$block_type][] = $block_parameter;
489  }
490 
494  public function getEmbeddedBlocks()
495  {
496  return $this->embedded_block;
497  }
498 
502  public function renderPageEmbeddedBlocks()
503  {
504  $lng = $this->lng;
505 
506  // item groups
507  if (is_array($this->embedded_block["itgr"])) {
508  $item_groups = array();
509  if (is_array($this->items["itgr"])) {
510  foreach ($this->items["itgr"] as $ig) {
511  $item_groups[$ig["ref_id"]] = $ig;
512  }
513  }
514 
515  foreach ($this->embedded_block["itgr"] as $ref_id) {
516  if (isset($item_groups[$ref_id])) {
517  $this->renderItemGroup($item_groups[$ref_id]);
518  }
519  }
520  }
521 
522  // type specific blocks
523  if (is_array($this->embedded_block["type"])) {
524  foreach ($this->embedded_block["type"] as $k => $type) {
525  if (is_array($this->items[$type]) &&
526  $this->renderer->addTypeBlock($type)) {
527  if ($this->hasForcedOrderByStartDate($type)) {
528  $this->items[$type] = ilUtil::sortArray($this->items[$type], 'start', 'ASC', true, true);
529  }
530 
531  $position = 1;
532 
533  foreach ($this->items[$type] as $k => $item_data) {
534  if (!$this->renderer->hasItem($item_data["child"])) {
535  $html = $this->renderItem($item_data, $position++);
536  if ($html != "") {
537  $this->renderer->addItemToBlock($type, $item_data["type"], $item_data["child"], $html);
538  }
539  }
540  }
541  }
542  }
543  }
544  }
545 
546  protected function hasForcedOrderByStartDate(string $type) : bool
547  {
548  return $type === 'sess' && get_class($this) === ilContainerSessionsContentGUI::class;
549  }
550 
559  public function renderItem($a_item_data, $a_position = 0, $a_force_icon = false, $a_pos_prefix = "")
560  {
562  $ilAccess = $this->access;
563  $ilCtrl = $this->ctrl;
564 
565  // Pass type, obj_id and tree to checkAccess method to improve performance
566  if (!$ilAccess->checkAccess('visible', '', $a_item_data['ref_id'], $a_item_data['type'], $a_item_data['obj_id'], $a_item_data['tree'])) {
567  return '';
568  }
569 
570  if ($this->getViewMode() == self::VIEW_MODE_TILE) {
571  return $this->renderCard($a_item_data, $a_position, $a_force_icon, $a_pos_prefix);
572  }
573 
574  $item_list_gui = $this->getItemGUI($a_item_data);
575  if ($ilSetting->get("icon_position_in_lists") == "item_rows" ||
576  $a_item_data["type"] == "sess" || $a_force_icon) {
577  $item_list_gui->enableIcon(true);
578  }
579 
580  if ($this->getContainerGUI()->isActiveAdministrationPanel() && !$_SESSION["clipboard"]) {
581  $item_list_gui->enableCheckbox(true);
582  } elseif ($this->getContainerGUI()->isMultiDownloadEnabled()) {
583  // display multi download checkboxes
584  $item_list_gui->enableDownloadCheckbox($a_item_data["ref_id"], true);
585  }
586 
587  if ($this->getContainerGUI()->isActiveItemOrdering() && !$this->hasForcedOrderByStartDate($a_item_data['type'])) {
588  $item_list_gui->setPositionInputField(
589  $a_pos_prefix . "[" . $a_item_data["ref_id"] . "]",
590  sprintf('%d', (int) $a_position * 10)
591  );
592  }
593 
594  if ($a_item_data['type'] == 'sess' and get_class($this) != 'ilContainerObjectiveGUI') {
595  switch ($this->getDetailsLevel($a_item_data['obj_id'])) {
596  case self::DETAILS_TITLE:
597  $item_list_gui->setDetailsLevel(ilObjectListGUI::DETAILS_MINIMAL);
598  $item_list_gui->enableExpand(true);
599  $item_list_gui->setExpanded(false);
600  $item_list_gui->enableDescription(false);
601  $item_list_gui->enableProperties(true);
602  break;
603 
604  case self::DETAILS_ALL:
605  $item_list_gui->setDetailsLevel(ilObjectListGUI::DETAILS_ALL);
606  $item_list_gui->enableExpand(true);
607  $item_list_gui->setExpanded(true);
608  $item_list_gui->enableDescription(true);
609  $item_list_gui->enableProperties(true);
610  break;
611 
612  default:
613  $item_list_gui->setDetailsLevel(ilObjectListGUI::DETAILS_ALL);
614  $item_list_gui->enableExpand(true);
615  $item_list_gui->enableDescription(true);
616  $item_list_gui->enableProperties(true);
617  break;
618  }
619  }
620 
621  if (method_exists($this, "addItemDetails")) {
622  $this->addItemDetails($item_list_gui, $a_item_data);
623  }
624 
625  // show subitems
626  if ($a_item_data['type'] == 'sess' and (
627  $this->getDetailsLevel($a_item_data['obj_id']) != self::DETAILS_TITLE or
628  $this->getContainerGUI()->isActiveAdministrationPanel() or
629  $this->getContainerGUI()->isActiveItemOrdering()
630  )
631  ) {
632  $pos = 1;
633 
634  include_once('./Services/Container/classes/class.ilContainerSorting.php');
635  include_once('./Services/Object/classes/class.ilObjectActivation.php');
636  $items = ilObjectActivation::getItemsByEvent($a_item_data['obj_id']);
637  $items = ilContainerSorting::_getInstance($this->getContainerObject()->getId())->sortSubItems('sess', $a_item_data['obj_id'], $items);
638  $items = ilContainer::getCompleteDescriptions($items);
639 
640  $item_readable = $ilAccess->checkAccess('read', '', $a_item_data['ref_id']);
641 
642  foreach ($items as $item) {
643  // TODO: this should be removed and be handled by if(strlen($sub_item_html))
644  // see mantis: 0003944
645  if (!$ilAccess->checkAccess('visible', '', $item['ref_id'])) {
646  continue;
647  }
648 
649  $item_list_gui2 = $this->getItemGUI($item);
650  $item_list_gui2->enableIcon(true);
651  $item_list_gui2->enableItemDetailLinks(false);
652 
653  // unique js-ids
654  $item_list_gui2->setParentRefId($a_item_data['ref_id']);
655 
656  // @see mantis 10488
657  if (!$item_readable and !$ilAccess->checkAccess('write', '', $item['ref_id'])) {
658  $item_list_gui2->forceVisibleOnly(true);
659  }
660 
661  if ($this->getContainerGUI()->isActiveAdministrationPanel() && !$_SESSION["clipboard"]) {
662  $item_list_gui2->enableCheckbox(true);
663  } elseif ($this->getContainerGUI()->isMultiDownloadEnabled()) {
664  // display multi download checkbox
665  $item_list_gui2->enableDownloadCheckbox($item['ref_id'], true);
666  }
667 
668  if ($this->getContainerGUI()->isActiveItemOrdering()) {
669  $item_list_gui2->setPositionInputField(
670  "[sess][" . $a_item_data['obj_id'] . "][" . $item["ref_id"] . "]",
671  sprintf('%d', (int) $pos * 10)
672  );
673  $pos++;
674  }
675 
676  // #10611
677  ilObjectActivation::addListGUIActivationProperty($item_list_gui2, $item);
678 
679  $sub_item_html = $item_list_gui2->getListItemHTML(
680  $item['ref_id'],
681  $item['obj_id'],
682  $item['title'],
683  $item['description']
684  );
685 
686  $this->determineAdminCommands($item["ref_id"], $item_list_gui2->adminCommandsIncluded());
687  if (strlen($sub_item_html)) {
688  $item_list_gui->addSubItemHTML($sub_item_html);
689  }
690  }
691  }
692 
693 
694  if ($ilSetting->get("item_cmd_asynch")) {
695  $asynch = true;
696  $ilCtrl->setParameter($this->container_gui, "cmdrefid", $a_item_data['ref_id']);
697  $asynch_url = $ilCtrl->getLinkTarget(
698  $this->container_gui,
699  "getAsynchItemList",
700  "",
701  true,
702  false
703  );
704  $ilCtrl->setParameter($this->container_gui, "cmdrefid", "");
705  }
706 
707  include_once "Services/Object/classes/class.ilObjectActivation.php";
708  ilObjectActivation::addListGUIActivationProperty($item_list_gui, $a_item_data);
709 
710  $html = $item_list_gui->getListItemHTML(
711  $a_item_data['ref_id'],
712  $a_item_data['obj_id'],
713  $a_item_data['title'],
714  $a_item_data['description'],
715  $asynch,
716  false,
717  $asynch_url
718  );
719  $this->determineAdminCommands(
720  $a_item_data["ref_id"],
721  $item_list_gui->adminCommandsIncluded()
722  );
723 
724 
725  return $html;
726  }
727 
736  public function renderCard($a_item_data, $a_position = 0, $a_force_icon = false, $a_pos_prefix = "")
737  {
738  global $DIC;
739  $f = $DIC->ui()->factory();
740  $user = $DIC->user();
741 
742  $item_list_gui = $this->getItemGUI($a_item_data);
743  $item_list_gui->setAjaxHash(ilCommonActionDispatcherGUI::buildAjaxHash(
745  $a_item_data['ref_id'],
746  $a_item_data['type'],
747  $a_item_data['obj_id']
748  ));
749  $item_list_gui->initItem(
750  $a_item_data['ref_id'],
751  $a_item_data['obj_id'],
752  $a_item_data['type'],
753  $a_item_data['title'],
754  $a_item_data['description']
755  );
756 
757  // actions
758  $item_list_gui->insertCommands();
759  return $item_list_gui->getAsCard(
760  $a_item_data['ref_id'],
761  (int) $a_item_data['obj_id'],
762  (string) $a_item_data['type'],
763  (string) $a_item_data['title'],
764  (string) $a_item_data['description']
765  );
766  }
767 
771  public function insertPageEmbeddedBlocks($a_output_html)
772  {
773  $this->determinePageEmbeddedBlocks($a_output_html);
774  $this->renderPageEmbeddedBlocks($this->items);
775 
776  // iterate all types
777  foreach ($this->getGroupedObjTypes() as $type => $v) {
778  // set template (overall or type specific)
779  if (is_int(strpos($a_output_html, "[list-" . $type . "]"))) {
780  $a_output_html = preg_replace(
781  '~\[list-' . $type . '\]~i',
782  $this->renderer->renderSingleTypeBlock($type),
783  $a_output_html
784  );
785  }
786  }
787 
788  // insert all item groups
789  while (preg_match('~\[(item-group-([0-9]*))\]~i', $a_output_html, $found)) {
790  $itgr_ref_id = (int) $found[2];
791 
792  $a_output_html = preg_replace(
793  '~\[' . $found[1] . '\]~i',
794  $this->renderer->renderSingleCustomBlock($itgr_ref_id),
795  $a_output_html
796  );
797  }
798 
799  return $a_output_html;
800  }
801 
809  {
810  $this->initRenderer();
811  // get all sub items
812  $this->items = $this->getContainerObject()->getSubItems(
813  $this->getContainerGUI()->isActiveAdministrationPanel()
814  );
815 
816 
817  $ref_ids = array_map(function ($i) {
818  $parts = explode("_", $i);
819  return $parts[2];
820  }, $_POST["ids"]);
821 
822  // iterate all types
823  if (is_array($this->items[$type]) &&
824  $this->renderer->addTypeBlock($type)) {
825  //$this->renderer->setBlockPosition($type, ++$pos);
826 
827  $position = 1;
828  foreach ($this->items[$type] as $item_data) {
829  $item_ref_id = $item_data["child"];
830 
831  if (in_array($item_ref_id, $ref_ids)) {
832  continue;
833  }
834 
835  if ($this->block_limit > 0 && $position == $this->block_limit + 1) {
836  if ($position == $this->block_limit + 1) {
837  // render more button
838  $this->renderer->addShowMoreButton($type);
839  }
840  continue;
841  }
842 
843  if (!$this->renderer->hasItem($item_ref_id)) {
844  $html = $this->renderItem($item_data, $position);
845  if ($html != "") {
846  $position++;
847  $this->renderer->addItemToBlock($type, $item_data["type"], $item_ref_id, $html);
848  }
849  }
850  }
851  }
852 
853  return $this->renderer->renderSingleTypeBlock($type);
854  }
855 
861  public function getGroupedObjTypes()
862  {
863  $objDefinition = $this->obj_definition;
864 
865  if (empty($this->type_grps)) {
866  $this->type_grps =
867  $objDefinition->getGroupedRepositoryObjectTypes($this->getContainerObject()->getType());
868  }
869  return $this->type_grps;
870  }
871 
875  public function getIntroduction()
876  {
878  $lng = $this->lng;
879  $ilCtrl = $this->ctrl;
880 
881  $lng->loadLanguageModule("rep");
882 
883  $tpl = new ilTemplate("tpl.rep_intro.html", true, true, "Services/Repository");
884  $tpl->setVariable("IMG_REP_LARGE", ilObject::_getIcon("", "big", "root"));
885  $tpl->setVariable("TXT_WELCOME", $lng->txt("rep_intro"));
886  $tpl->setVariable("TXT_INTRO_1", $lng->txt("rep_intro1"));
887  $tpl->setVariable("TXT_INTRO_2", $lng->txt("rep_intro2"));
888  $tpl->setVariable("TXT_INTRO_3", sprintf($lng->txt("rep_intro3"), $lng->txt("add")));
889  $tpl->setVariable("TXT_INTRO_4", sprintf($lng->txt("rep_intro4"), $lng->txt("cat_add")));
890  $tpl->setVariable("TXT_INTRO_5", $lng->txt("rep_intro5"));
891  $tpl->setVariable("TXT_INTRO_6", $lng->txt("rep_intro6"));
892 
893  return $tpl->get();
894  }
895 
902  public function getItemGroupsHTML($a_pos = 0)
903  {
904  if (is_array($this->items["itgr"])) {
905  foreach ($this->items["itgr"] as $itgr) {
906  if (!$this->renderer->hasCustomBlock($itgr["child"])) {
907  $this->renderItemGroup($itgr);
908 
909  $this->renderer->setBlockPosition($itgr["ref_id"], ++$a_pos);
910  }
911  }
912  }
913  return $a_pos;
914  }
915 
922  public function renderItemGroup($a_itgr)
923  {
924  $ilAccess = $this->access;
926 
927  // #16493
928  $perm_ok = ($ilAccess->checkAccess("visible", "", $a_itgr['ref_id']) &&
929  $ilAccess->checkAccess("read", "", $a_itgr['ref_id']));
930 
931  include_once('./Services/Container/classes/class.ilContainerSorting.php');
932  include_once('./Services/Object/classes/class.ilObjectActivation.php');
933  $items = ilObjectActivation::getItemsByItemGroup($a_itgr['ref_id']);
934 
935  // get all valid ids (this is filtered)
936  $all_ids = array_map(function ($i) {
937  return $i["child"];
938  }, $this->items["_all"]);
939 
940  // remove filtered items
941  $items = array_filter($items, function ($i) use ($all_ids) {
942  return in_array($i["ref_id"], $all_ids);
943  });
944 
945  // if no permission is given, set the items to "rendered" but
946  // do not display the whole block
947  if (!$perm_ok) {
948  foreach ($items as $item) {
949  $this->renderer->hideItem($item["child"]);
950  }
951  return;
952  }
953 
954  $item_list_gui = $this->getItemGUI($a_itgr);
955  $item_list_gui->enableNotes(false);
956  $item_list_gui->enableTags(false);
957  $item_list_gui->enableComments(false);
958  $item_list_gui->enableTimings(false);
959  $item_list_gui->getListItemHTML(
960  $a_itgr["ref_id"],
961  $a_itgr["obj_id"],
962  $a_itgr["title"],
963  $a_itgr["description"]
964  );
965  $commands_html = $item_list_gui->getCommandsHTML();
966 
967  // determine behaviour
968  include_once("./Modules/ItemGroup/classes/class.ilObjItemGroup.php");
969  include_once("./Modules/ItemGroup/classes/class.ilItemGroupBehaviour.php");
970  $beh = ilObjItemGroup::lookupBehaviour($a_itgr["obj_id"]);
971  include_once("./Services/Container/classes/class.ilContainerBlockPropertiesStorageGUI.php");
973  "itgr_" . $a_itgr["ref_id"],
974  $ilUser->getId(),
975  "opened"
976  );
977  if ($stored_val !== false && $beh != ilItemGroupBehaviour::ALWAYS_OPEN) {
978  $beh = ($stored_val == "1")
981  }
982 
983  $this->ctrl->setParameterByClass(
984  ilContainerBlockPropertiesStorageGUI::class,
985  'cont_block_id',
986  'itgr_' . $a_itgr['ref_id']
987  );
988  $target_url = $this->ctrl->getLinkTargetByClass(
989  ilContainerBlockPropertiesStorageGUI::class,
990  "store",
991  "",
992  true
993  );
994  $data = array(
995  "behaviour" => $beh,
996  "store-url" => $target_url,
997  );
998  if (ilObjItemGroup::lookupHideTitle($a_itgr["obj_id"]) &&
999  !$this->getContainerGUI()->isActiveAdministrationPanel()) {
1000  $this->renderer->addCustomBlock($a_itgr["ref_id"], "", $commands_html, $data);
1001  } else {
1002  $this->renderer->addCustomBlock($a_itgr["ref_id"], $a_itgr["title"], $commands_html, $data);
1003  }
1004 
1005 
1006  // render item group sub items
1007 
1009  $this->getContainerObject()->getId()
1010  )->sortSubItems('itgr', $a_itgr['obj_id'], $items);
1011 
1012  // #18285
1013  $items = ilContainer::getCompleteDescriptions($items);
1014 
1015  $position = 1;
1016  foreach ($items as $item) {
1017  // we are NOT using hasItem() here, because item might be in multiple item groups
1018  $html2 = $this->renderItem($item, $position++, false, "[itgr][" . $a_itgr['obj_id'] . "]");
1019  if ($html2 != "") {
1020  // :TODO: show it multiple times?
1021  $this->renderer->addItemToBlock($a_itgr["ref_id"], $item["type"], $item["child"], $html2, true);
1022  }
1023  }
1024  }
1025 }
static lookupHideTitle($a_id)
Lookup hide title.
determineAdminCommands($a_ref_id, $a_admin_com_included_in_list=false)
determin admin commands
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
determinePageEmbeddedBlocks($a_container_page_html)
Determine all blocks that are embedded in the container page.
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static _recordReadEvent( $a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
static getCmdSide()
Get Column Side of Current Command.
settings()
Definition: settings.php:2
$data
Definition: storeScorm.php:23
static getItemsByEvent($a_event_id)
Get session material / event items.
getEmbeddedBlocks()
Get page embedded blocks.
$_SESSION["AccountId"]
static getProperty($a_block_id, $a_user_id, $a_property)
Get property in session or db.
$type
static _getItemsOfContainer($a_ref_id)
renderCard($a_item_data, $a_position=0, $a_force_icon=false, $a_pos_prefix="")
Render card.
static _getListGUIByType( $type, $context=ilObjectListGUI::CONTEXT_REPOSITORY)
getItemGUI($item_data, $a_show_path=false)
Get ListGUI object for item.
static lookupBehaviour($a_id)
Lookup behaviour.
getSingleTypeBlockAsynch($type)
Render single block.
const IL_COL_RIGHT
getItemGroupsHTML($a_pos=0)
Get item groups HTML.
renderPageEmbeddedBlocks()
Render Page Embedded Blocks.
initRenderer()
Init container renderer.
__forwardToColumnGUI()
Get columngui output.
user()
Definition: user.php:4
insertPageEmbeddedBlocks($a_output_html)
Insert blocks into container page.
Parent class of all container content GUIs.
getMainContent()
Get content HTML for main column, this one must be overwritten in derived classes.
const IL_SCREEN_FULL
getContainerGUI()
Get container GUI object.
Column user interface class.
getDetailsLevel($a_item_id)
get details level
static _lookupObjId($a_id)
global $DIC
Definition: goto.php:24
getContainerObject()
Get container object.
renderItem($a_item_data, $a_position=0, $a_force_icon=false, $a_pos_prefix="")
Render an item.
static addListGUIActivationProperty(ilObjectListGUI $a_list_gui, array &$a_item)
Get timing details for list gui.
static buildAjaxHash( $a_node_type, $a_node_id, $a_obj_type, $a_obj_id, $a_sub_type=null, $a_sub_id=null, $a_news_id=0)
Build ajax hash.
static _lookupType($a_id, $a_reference=false)
lookup object type
clearAdminCommandsDetermination()
cleaer administration commands determination
renderItemGroup($a_itgr)
Render item group.
static getScreenMode()
Get Screen Mode for current command.
getCenterColumnHTML()
Get HTML for center column.
global $ilSetting
Definition: privfeed.php:17
global $ilDB
static getItemsByItemGroup($a_item_group_ref_id)
Get materials of item group.
static getLogger($a_component_id)
Get component logger.
static _getInstance($a_obj_id)
get instance by obj_id
__construct(&$container_gui_obj)
Constructor.
$ilUser
Definition: imgupload.php:18
const IL_SCREEN_SIDE
Class ilContainerRenderer.
static getCompleteDescriptions(array $objects)
overwrites description fields to long or short description in an assoc array keys needed (obj_id and ...
addEmbeddedBlock($block_type, $block_parameter)
Add embedded block.
getRightColumnHTML()
Get HTML for right column.
$_POST["username"]
getGroupedObjTypes()
Get grouped repository object types.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
const IL_COL_LEFT
$i
Definition: metadata.php:24
setOutput()
Sets view output into column layout.