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 ($data as $group) {
98 foreach ($group as $datum) {
99 $obj_ids[] = $datum->getObjId();
104 foreach ($data as
$title => $group) {
106 foreach ($group as $datum) {
108 if ($item !==
null) {
112 $groupedCards[] = $this->
factory->item()->group((
string)
$title, $items);
115 return $groupedCards;
122 $list_item = $itemListGui->getAsListItem(
130 $list_item = $list_item->withProperties($list_item->getProperties() + $data->
getAdditionalData());
146 $groupedCards[] = $this->
ui->factory()->panel()->sub(
148 $this->
factory->deck($cards)->withNormalCardsSize()
154 return $this->
renderer->render($groupedCards);
172 $this->
lng->loadLanguageModule(
'dash');
173 $this->
lng->loadLanguageModule(
'rep');
174 $this->
lng->loadLanguageModule(
'pd');
176 $this->viewSettings->parse();
177 $this->requested_item_ref_id = (
int) ($this->
http->request()->getQueryParams()[
'item_ref_id'] ?? 0);
180 $this->
ctrl->setParameter($this,
'view', $this->viewSettings->getCurrentView());
181 if ($this->viewSettings->isTilePresentation()) {
191 if ($this->parent === ilDashboardGUI::class) {
192 $this->
ctrl->redirectByClass(ilDashboardGUI::class,
'show');
201 $this->
lng->txt(
'dash_' . $this->viewSettings->getViewName($this->viewSettings->getCurrentView()))
211 return parent::getHTML();
219 $this->data = array_filter(
221 static fn($group) => array_filter($group,
static fn($item) => $item instanceof
BlockDTO),
232 return parent::getData();
238 public function groupItemsByStartDate(): array
242 $items = array_merge(...array_values($data));
250 foreach ($items as $item) {
251 if ($item->isDated()) {
252 if ($item->hasNotStarted()) {
253 $groups[
'upcoming'][] = $item;
254 } elseif ($item->isRunning()) {
255 $groups[
'ongoing'][] = $item;
257 $groups[
'ended'][] = $item;
260 $groups[
'not_dated'][] = $item;
264 foreach ($groups as $key => $group) {
266 if ($key !==
'not_dated') {
267 $group = $this->
sortByDate($group, $key ===
'upcoming');
269 $groups[$this->
lng->txt(
'pd_' . $key)] = $group;
270 unset($groups[$key]);
278 protected function groupItemsByType(): array
280 $object_types_by_container = $this->objDefinition->getGroupedRepositoryObjectTypes(
281 [
'cat',
'crs',
'grp',
'fold']
286 $data = array_merge(...array_values($data));
288 foreach ($object_types_by_container as $type_title => $type) {
289 if (!$this->objDefinition->isPlugin($type_title)) {
290 $title = $this->
lng->txt(
'objs_' . $type_title);
293 $title = $pl->txt(
'objs_' . $type_title);
296 foreach ($data as $item) {
297 if (in_array($item->getType(), $type[
'objs'])) {
298 $grouped_items[
$title][] = $item;
303 foreach ($grouped_items as $key => $group) {
307 return $grouped_items;
313 protected function groupItemsByLocation(): array
318 $data = array_merge(...array_values($data));
320 $parent_ref_ids = array_values(array_unique(
323 $this->object_cache->preloadReferenceCache($parent_ref_ids);
325 foreach ($data as $item) {
326 $parent_ref = $this->tree->getParentId($item->getRefId());
330 $title = $this->object_cache->lookupTitle($this->object_cache->lookupObjId($parent_ref));
332 $grouped_items[
$title][] = $item;
334 ksort($grouped_items);
336 return $grouped_items;
341 return $this->tree->getRootId() ===
$refId;
346 $nd = $this->tree->getNodeData($this->tree->getRootId());
358 $sortings = $this->viewSettings->getSelectableSortingModes();
359 if (count($sortings) > 1) {
360 foreach ($sortings as $sorting) {
364 $sorting === $this->viewSettings->getEffectiveSortingMode()
370 $presentations = $this->viewSettings->getSelectablePresentationModes();
372 $this->
ctrl->setParameter($this,
'presentation', $presentation);
374 $this->
ui->renderer()->render($this->
ui->factory()->symbol()->glyph()->{$presentation .
'View'}()),
375 $this->
ctrl->getLinkTarget($this,
'changePDItemPresentation'),
376 $presentation === $this->viewSettings->getEffectivePresentationMode()
378 $this->
ctrl->setParameter($this,
'presentation',
null);
383 $this->
ctrl->getLinkTarget($this,
'manage'),
395 if ($this->viewSettings->isSelectedItemsViewActive()) {
396 $question = $this->
lng->txt(
'dash_info_sure_remove_from_favs');
398 $question = $this->
lng->txt(
'mmbr_info_delete_sure_unsubscribe');
400 $modal = $this->
ui->factory()->modal()->roundtrip(
403 $this->
ui->factory()->messageBox()->confirmation($question),
404 $this->
ui->factory()->messageBox()->info($this->
lng->txt(
'select_one')),
407 $this->
ctrl->getLinkTargetByClass([ilDashboardGUI::class, $this::class],
'confirmedRemove')
410 $modal = $modal->withOnLoadCode(
static fn(
$id) =>
"il.Dashboard.confirmModal($id)");
412 $modal = $this->
ui->factory()->modal()->roundtrip(
414 $this->
ui->factory()->messageBox()->info($this->
lng->txt(
'pd_no_items_to_manage'))
426 foreach ($item_group as $item) {
427 $icon = $this->
ui->renderer()->render($this->
ui->factory()->symbol()->icon()->custom(
ilObject::_getIcon($item->getObjId()),
''));
429 if ($this->rbacsystem->checkAccess(
'leave', $item->getRefId())) {
430 if ($item->getType() ===
'crs' || $item->getType() ===
'grp') {
432 if (!$members_obj->checkLastAdmin([$this->user->getId()])) {
436 $options[$item->getRefId()] = $icon . $item->getTitle();
439 $options[$item->getRefId()] = $icon . $item->getTitle();
442 if ($options !== []) {
443 $inputs[] = $this->
ui->factory()->input()->field()->multiSelect((
string) $key, $options)
444 ->withAdditionalTransformation($this->
refinery->to()->listOf($this->
refinery->kindlyTo()->int()));
453 $next_class = $this->
ctrl->getNextClass();
454 $cmd = $this->
ctrl->getCmd(
'getHTML');
456 switch ($next_class) {
457 case strtolower(ilCommonActionDispatcherGUI::class):
460 $this->
ctrl->forwardCommand($gui);
466 case 'confirmedRemove':
467 $form = $this->
ui->factory()->input()->container()->form()->standard(
'', $this->
getManageFields())->withRequest($this->
http->request());
468 $this->
confirmedRemove(array_merge(...array_filter($form->getData())));
471 if (method_exists($this, $cmd .
'Object')) {
472 return $this->{$cmd .
'Object'}();
486 $this->viewSettings->storeActorSortingMode(
495 $this->viewSettings->storeActorPresentationMode(
506 switch ($this->viewSettings->getEffectiveSortingMode()) {
511 return [
'' =>
$data];
513 return $this->groupItemsByStartDate();
515 return $this->groupItemsByType();
518 return $this->groupItemsByLocation();
525 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'rep_added_to_favourites'),
true);
526 $this->
ctrl->redirectByClass(ilDashboardGUI::class,
'show');
532 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'rep_removed_from_favourites'),
true);
533 $this->
ctrl->redirectByClass(ilDashboardGUI::class,
'show');
549 $class = $this->objDefinition->getClassName($a_type);
551 throw new ilException(sprintf(
'Could not find a class for object type: %s', $a_type));
554 $location = $this->objDefinition->getLocation($a_type);
556 throw new ilException(sprintf(
'Could not find a class location for object type: %s', $a_type));
559 $full_class =
'ilObj' . $class .
'ListGUI';
560 $item_list_gui =
new $full_class();
562 $item_list_gui->setContainerObject($this);
563 $item_list_gui->enableNotes(
false);
564 $item_list_gui->enableComments(
false);
565 $item_list_gui->enableTags(
false);
567 $item_list_gui->enableIcon(
true);
568 $item_list_gui->enableDelete(
false);
569 $item_list_gui->enableCut(
false);
570 $item_list_gui->enableCopy(
false);
571 $item_list_gui->enableLink(
false);
572 $item_list_gui->enableInfoScreen(
true);
574 $item_list_gui->enableCommands(
true,
true);
576 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)
Manages favourites, currently the interface for other components, needs discussion.
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