19 declare(strict_types=1);
54 $this->
http = $DIC->http();
56 $this->logging = $DIC->logger()->root();
58 $this->object_cache = $DIC[
'ilObjDataCache'];
59 $this->tree = $DIC->repositoryTree();
60 $this->objDefinition = $DIC[
'objDefinition'];
61 $this->rbacsystem = $DIC->rbac()->system();
63 $this->parent = $this->
ctrl->getCurrentClassPath()[0] ??
'';
69 abstract public function initData(): void;
81 $card = $itemListGui->getAsCard(
97 foreach ($group as $datum) {
103 $groupedCards[] = $this->
factory->item()->group((
string)
$title, $items);
106 return $groupedCards;
113 $list_item = $itemListGui->getAsListItem(
121 $list_item = $list_item->withProperties($list_item->getProperties() + $data->
getAdditionalData());
137 $groupedCards[] = $this->
ui->factory()->panel()->sub(
139 $this->
factory->deck($cards)->withNormalCardsSize()
145 return $this->
renderer->render($groupedCards);
154 foreach ($data as $group) {
155 foreach ($group as $datum) {
156 $obj_ids[] = $datum->getObjId();
160 parent::preloadData($data);
175 $this->
lng->loadLanguageModule(
'dash');
176 $this->
lng->loadLanguageModule(
'rep');
177 $this->
lng->loadLanguageModule(
'pd');
179 $this->viewSettings->parse();
180 $this->requested_item_ref_id = (
int) ($this->
http->request()->getQueryParams()[
'item_ref_id'] ?? 0);
183 $this->
ctrl->setParameter($this,
'view', $this->viewSettings->getCurrentView());
184 if ($this->viewSettings->isTilePresentation()) {
194 if ($this->parent === ilDashboardGUI::class) {
195 $this->
ctrl->redirectByClass(ilDashboardGUI::class,
'show');
204 $this->
lng->txt(
'dash_' . $this->viewSettings->getViewName($this->viewSettings->getCurrentView()))
214 return parent::getHTML();
222 $this->data = array_filter(
224 static fn($group) => array_filter($group,
static fn($item) => $item instanceof
BlockDTO),
235 return parent::getData();
241 public function groupItemsByStartDate(): array
245 $items = array_merge(...array_values($data));
253 foreach ($items as $item) {
254 if ($item->isDated()) {
255 if ($item->hasNotStarted()) {
256 $groups[
'upcoming'][] = $item;
257 } elseif ($item->isRunning()) {
258 $groups[
'ongoing'][] = $item;
260 $groups[
'ended'][] = $item;
263 $groups[
'not_dated'][] = $item;
267 foreach ($groups as $key => $group) {
269 if ($key !==
'not_dated') {
270 $group = $this->
sortByDate($group, $key ===
'upcoming');
272 $groups[$this->
lng->txt(
'pd_' . $key)] = $group;
273 unset($groups[$key]);
281 protected function groupItemsByType(): array
283 $object_types_by_container = $this->objDefinition->getGroupedRepositoryObjectTypes(
284 [
'cat',
'crs',
'grp',
'fold']
289 $data = array_merge(...array_values($data));
291 foreach ($object_types_by_container as $type_title => $type) {
292 if (!$this->objDefinition->isPlugin($type_title)) {
293 $title = $this->
lng->txt(
'objs_' . $type_title);
296 $title = $pl->txt(
'objs_' . $type_title);
299 foreach ($data as $item) {
300 if (in_array($item->getType(), $type[
'objs'])) {
301 $grouped_items[
$title][] = $item;
306 foreach ($grouped_items as $key => $group) {
310 return $grouped_items;
316 protected function groupItemsByLocation(): array
321 $data = array_merge(...array_values($data));
323 $parent_ref_ids = array_values(array_unique(
326 $this->object_cache->preloadReferenceCache($parent_ref_ids);
328 foreach ($data as $item) {
329 $parent_ref = $this->tree->getParentId($item->getRefId());
333 $title = $this->object_cache->lookupTitle($this->object_cache->lookupObjId($parent_ref));
335 $grouped_items[
$title][] = $item;
337 ksort($grouped_items);
339 return $grouped_items;
344 return $this->tree->getRootId() ===
$refId;
349 $nd = $this->tree->getNodeData($this->tree->getRootId());
361 $sortings = $this->viewSettings->getSelectableSortingModes();
362 if (count($sortings) > 1) {
363 foreach ($sortings as $sorting) {
367 $sorting === $this->viewSettings->getEffectiveSortingMode()
373 $presentations = $this->viewSettings->getSelectablePresentationModes();
375 $this->
ctrl->setParameter($this,
'presentation', $presentation);
377 $this->
ui->renderer()->render($this->
ui->factory()->symbol()->glyph()->{$presentation .
'View'}()),
378 $this->
ctrl->getLinkTarget($this,
'changePDItemPresentation'),
379 $presentation === $this->viewSettings->getEffectivePresentationMode()
381 $this->
ctrl->setParameter($this,
'presentation',
null);
386 $this->
ctrl->getLinkTarget($this,
'manage'),
398 if ($this->viewSettings->isSelectedItemsViewActive()) {
399 $question = $this->
lng->txt(
'dash_info_sure_remove_from_favs');
401 $this->
lng->loadLanguageModule(
'mmbr');
402 $question = $this->
lng->txt(
'mmbr_info_delete_sure_unsubscribe');
404 $modal = $this->
ui->factory()->modal()->roundtrip(
407 $this->
ui->factory()->messageBox()->confirmation($question),
408 $this->
ui->factory()->messageBox()->info($this->
lng->txt(
'select_one')),
411 $this->
ctrl->getLinkTargetByClass([ilDashboardGUI::class, $this::class],
'confirmedRemove')
414 $modal = $modal->withOnLoadCode(
static fn(
$id) =>
"il.Dashboard.confirmModal($id)");
416 $modal = $this->
ui->factory()->modal()->roundtrip(
418 $this->
ui->factory()->messageBox()->info($this->
lng->txt(
'pd_no_items_to_manage'))
430 foreach ($item_group as $item) {
431 $icon = $this->
ui->renderer()->render($this->
ui->factory()->symbol()->icon()->custom(
ilObject::_getIcon($item->getObjId()),
''));
433 if ($this->rbacsystem->checkAccess(
'leave', $item->getRefId())) {
434 if ($item->getType() ===
'crs' || $item->getType() ===
'grp') {
436 if (!$members_obj->checkLastAdmin([$this->user->getId()])) {
440 $options[$item->getRefId()] = $icon . $item->getTitle();
443 $options[$item->getRefId()] = $icon . $item->getTitle();
446 if ($options !== []) {
447 $inputs[] = $this->
ui->factory()->input()->field()->multiSelect((
string) $key, $options)
448 ->withAdditionalTransformation($this->
refinery->to()->listOf($this->
refinery->kindlyTo()->int()));
457 $next_class = $this->
ctrl->getNextClass();
458 $cmd = $this->
ctrl->getCmd(
'getHTML');
460 switch ($next_class) {
461 case strtolower(ilCommonActionDispatcherGUI::class):
464 $this->
ctrl->forwardCommand($gui);
470 case 'confirmedRemove':
471 $form = $this->
ui->factory()->input()->container()->form()->standard(
'', $this->
getManageFields())->withRequest($this->
http->request());
472 $this->
confirmedRemove(array_merge(...array_filter($form->getData())));
475 if (method_exists($this, $cmd .
'Object')) {
476 return $this->{$cmd .
'Object'}();
490 $this->viewSettings->storeActorSortingMode(
499 $this->viewSettings->storeActorPresentationMode(
510 switch ($this->viewSettings->getEffectiveSortingMode()) {
515 return [
'' =>
$data];
517 return $this->groupItemsByStartDate();
519 return $this->groupItemsByType();
522 return $this->groupItemsByLocation();
529 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'rep_added_to_favourites'),
true);
530 $this->
ctrl->redirectByClass(ilDashboardGUI::class,
'show');
536 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'rep_removed_from_favourites'),
true);
537 $this->
ctrl->redirectByClass(ilDashboardGUI::class,
'show');
553 $class = $this->objDefinition->getClassName($a_type);
555 throw new ilException(sprintf(
'Could not find a class for object type: %s', $a_type));
558 $location = $this->objDefinition->getLocation($a_type);
560 throw new ilException(sprintf(
'Could not find a class location for object type: %s', $a_type));
563 $full_class =
'ilObj' . $class .
'ListGUI';
564 $item_list_gui =
new $full_class();
566 $item_list_gui->setContainerObject($this);
567 $item_list_gui->enableNotes(
false);
568 $item_list_gui->enableComments(
false);
569 $item_list_gui->enableTags(
false);
571 $item_list_gui->enableIcon(
true);
572 $item_list_gui->enableDelete(
false);
573 $item_list_gui->enableCut(
false);
574 $item_list_gui->enableCopy(
false);
575 $item_list_gui->enableLink(
false);
576 $item_list_gui->enableInfoScreen(
true);
578 $item_list_gui->enableCommands(
true,
true);
580 return $item_list_gui;
ilFavouritesManager $favourites_manager
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
addPresentation(string $label, string $target, bool $active)
changePDItemPresentationObject()
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static getInstance(int $a_ref_id)
static preloadListGUIData(array $a_obj_ids)
setSortTarget(string $target)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
confirmedRemove(array $ids)
addCustomCommandsToActionMenu(ilObjectListGUI $itemListGui, int $ref_id)
Common interface to all items.
int $requested_item_ref_id
changePDItemSortingObject()
getCardForData(BlockDTO $data)
getRemoveMultipleActionText()
getListItemForDataDTO(BlockDTO $data)
static getPluginObjectByType(string $type)
Return either a repoObject plugin or a orgunit extension plugin or null if the type is not a plugin...
sortByDate(array $data, bool $asc=true)
loadData()
Load data for current page.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
__construct(Container $dic, ilPlugin $plugin)
setTitle(string $a_title)
This class represents a block method of a block.
addBlockCommand(string $a_href, string $a_text, string $a_onclick="", ?RoundTrip $modal=null)
addSortOption(string $option, string $label, bool $active)
setPresentation(int $type)
Class ilCommonActionDispatcherGUI.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
ilPDSelectedItemsBlockViewSettings $viewSettings