19declare(strict_types=1);
58 $this->
http = $DIC->http();
60 $this->logging =
$DIC->logger()->root();
62 $this->object_cache =
$DIC[
'ilObjDataCache'];
63 $this->tree =
$DIC->repositoryTree();
64 $this->objDefinition =
$DIC[
'objDefinition'];
65 $this->rbacsystem =
$DIC->rbac()->system();
67 $this->parent = $this->
ctrl->getCurrentClassPath()[0] ??
'';
86 $card = $itemListGui->getAsCard(
91 $data->getDescription()
102 foreach ($group as $datum) {
104 if ($item !==
null) {
108 $groupedCards[] = $this->
factory->item()->group((
string)
$title, $items);
111 return $groupedCards;
118 $list_item = $itemListGui->getAsListItem(
123 $data->getDescription()
126 $list_item = $list_item->withProperties($list_item->getProperties() +
$data->getAdditionalData());
140 $cards = array_filter(array_map($this->
getCardForData(...), $group));
142 $groupedCards[] = $this->
ui->factory()->panel()->sub(
144 $this->
factory->deck($cards)->withNormalCardsSize()
150 return $this->
renderer->render($groupedCards);
159 foreach (
$data as $group) {
160 foreach ($group as $datum) {
161 $obj_ids[] = $datum->getObjId();
165 parent::preloadData(
$data);
180 $this->
lng->loadLanguageModule(
'dash');
181 $this->
lng->loadLanguageModule(
'rep');
182 $this->
lng->loadLanguageModule(
'pd');
184 $this->viewSettings->parse();
185 $this->requested_item_ref_id = (
int) ($this->
http->request()->getQueryParams()[
'item_ref_id'] ?? 0);
188 $this->
ctrl->setParameter($this,
'view', $this->viewSettings->getCurrentView());
189 if ($this->viewSettings->isTilePresentation()) {
199 if ($this->parent === ilDashboardGUI::class) {
200 $this->
ctrl->redirectByClass(ilDashboardGUI::class,
'show');
209 $this->
lng->txt(
'dash_' . $this->viewSettings->getViewName($this->viewSettings->getCurrentView()))
219 $modal = $this->manual_sort_modal ? $this->
ui->renderer()->render($this->manual_sort_modal) :
'';
220 return parent::getHTML() . $modal;
228 $this->data = array_filter(
230 static fn($group) => array_filter($group,
static fn($item) => $item instanceof
BlockDTO),
241 return parent::getData();
247 public function groupItemsByStartDate(): array
251 $items = array_merge(...array_values(
$data));
259 foreach ($items as $item) {
260 if ($item->isDated()) {
261 if ($item->hasNotStarted()) {
262 $groups[
'upcoming'][] = $item;
263 } elseif ($item->isRunning()) {
264 $groups[
'ongoing'][] = $item;
266 $groups[
'ended'][] = $item;
269 $groups[
'not_dated'][] = $item;
273 foreach ($groups as $key => $group) {
275 if ($key !==
'not_dated') {
276 $group = $this->
sortByDate($group, $key ===
'upcoming');
278 $groups[$this->
lng->txt(
'pd_' . $key)] = $group;
279 unset($groups[$key]);
287 protected function groupItemsByType(): array
289 $object_types_by_container = $this->objDefinition->getGroupedRepositoryObjectTypes(
290 [
'cat',
'crs',
'grp',
'fold']
295 $data = array_merge(...array_values(
$data));
297 foreach ($object_types_by_container as $type_title => $type) {
298 if (!$this->objDefinition->isPlugin($type_title)) {
299 $title = $this->
lng->txt(
'objs_' . $type_title);
302 $title = $pl->txt(
'objs_' . $type_title);
305 foreach (
$data as $item) {
306 if (in_array($item->getType(), $type[
'objs'])) {
307 $grouped_items[
$title][] = $item;
312 foreach ($grouped_items as $key => $group) {
316 return $grouped_items;
322 protected function groupItemsByLocation(): array
327 $data = array_merge(...array_values(
$data));
329 $parent_ref_ids = array_values(array_unique(
332 $this->object_cache->preloadReferenceCache($parent_ref_ids);
334 foreach (
$data as $item) {
335 $parent_ref = $this->tree->getParentId($item->getRefId());
339 $title = $this->object_cache->lookupTitle($this->object_cache->lookupObjId($parent_ref));
341 $grouped_items[
$title][] = $item;
343 ksort($grouped_items);
344 $grouped_items = array_map($this->
sortByTitle(...), $grouped_items);
345 return $grouped_items;
350 return $this->tree->getRootId() ===
$refId;
355 $nd = $this->tree->getNodeData($this->tree->getRootId());
367 $sortings = $this->viewSettings->getSelectableSortingModes();
368 if (count($sortings) > 1) {
369 foreach ($sortings as $sorting) {
372 $signal = $this->signal_generator->create();
374 $this->manual_sort_modal = $this->
ui->factory()->modal()->roundtrip(
375 $this->
lng->txt(
'dash_manual_sorting_title'),
377 )->withAdditionalOnLoadCode(fn(
$id) =>
"document.getElementById('$id').addEventListener('close', () => {window.location = window.location;});");
379 $this->manual_sort_modal = $this->manual_sort_modal->withAdditionalOnLoadCode(fn(
$id) => (
380 "il.Dashboard.moveModalButtons($id)"
386 $sorting === $this->viewSettings->getEffectiveSortingMode()
392 $presentations = $this->viewSettings->getSelectablePresentationModes();
396 $this->
ui->renderer()->render($this->ui->factory()->symbol()->glyph()->{
$presentation .
'View'}()),
397 $this->
ctrl->getLinkTarget($this,
'changePDItemPresentation'),
398 $presentation === $this->viewSettings->getEffectivePresentationMode()
400 $this->
ctrl->setParameter($this,
'presentation',
null);
405 $this->
ctrl->getLinkTarget($this,
'manage'),
406 $this->getRemoveMultipleActionText(),
408 $this->getRemoveModal()
415 $items = $this->getManageFields();
417 if ($this->viewSettings->isSelectedItemsViewActive()) {
418 $question = $this->
lng->txt(
'dash_info_sure_remove_from_favs');
420 $this->
lng->loadLanguageModule(
'mmbr');
421 $question = $this->
lng->txt(
'mmbr_info_delete_sure_unsubscribe');
423 $modal = $this->
ui->factory()->modal()->roundtrip(
424 $this->getRemoveMultipleActionText(),
426 $this->
ui->factory()->messageBox()->confirmation($question),
427 $this->ui->factory()->messageBox()->info($this->lng->txt(
'select_one')),
430 $this->ctrl->getLinkTargetByClass([ilDashboardGUI::class, $this::class],
'confirmedRemove')
431 )->withSubmitLabel($this->getRemoveMultipleActionText());
433 $modal = $modal->withOnLoadCode(
static fn(
$id) =>
"il.Dashboard.confirmModal($id)");
435 $modal = $this->
ui->factory()->modal()->roundtrip(
436 $this->getRemoveMultipleActionText(),
437 $this->
ui->factory()->messageBox()->info($this->lng->txt(
'pd_no_items_to_manage'))
447 foreach ($this->getItemGroups() as $key => $item_group) {
449 foreach ($item_group as $item) {
450 $icon = $this->
ui->renderer()->render($this->
ui->factory()->symbol()->icon()->custom(
ilObject::_getIcon($item->getObjId()),
''));
452 if ($this->rbacsystem->checkAccess(
'leave', $item->getRefId())) {
453 if ($item->getType() ===
'crs' || $item->getType() ===
'grp') {
455 if (!$members_obj->checkLastAdmin([$this->user->getId()])) {
459 $options[$item->getRefId()] = $icon . $item->getTitle();
462 $options[$item->getRefId()] = $icon . $item->getTitle();
465 if ($options !== []) {
466 $inputs[] = $this->
ui->factory()->input()->field()->multiSelect((
string) $key, $options)
467 ->withAdditionalTransformation($this->
refinery->to()->listOf($this->refinery->kindlyTo()->int()));
476 $next_class = $this->
ctrl->getNextClass();
477 $cmd = $this->
ctrl->getCmd(
'getHTML');
479 switch ($next_class) {
480 case strtolower(ilCommonActionDispatcherGUI::class):
483 $this->
ctrl->forwardCommand($gui);
489 case 'confirmedRemove':
490 $form = $this->
ui->factory()->input()->container()->form()->standard(
'', $this->getManageFields())->withRequest($this->
http->request());
491 $this->confirmedRemove(array_merge(...array_filter($form->getData())));
494 if (method_exists($this, $cmd .
'Object')) {
495 return $this->{$cmd .
'Object'}();
504 $request = $this->
http->request();
506 'title' => $this->
factory->table()->column()->text(
'Title')
510 $proc =
function (
$b) use (&$records) {
511 return yield
from array_map(fn($x) =>
$b->buildOrderingRow((
string) $x[
'id'], $x), $records);
514 $uri =
new URI((
string) $request->getUri());
515 parse_str($uri->getQuery(), $query);
516 $uri = $uri->withQuery(http_build_query(array_merge(
518 [
'view' => $this->viewSettings->getCurrentView()]
520 $table = $this->
factory->table()
521 ->ordering(
new \
ILIAS\Dashboard\TableData($proc), $uri,
'', $columns)
522 ->withRequest($request);
524 $int = $this->
refinery->byTrying([$this->
refinery->kindlyTo()->int(), $this->refinery->always(
null)]);
526 if ($request->getMethod() ===
'POST' && $this->viewSettings->getCurrentView() === $this->http->wrapper()->query()->retrieve(
'view', $int)) {
527 $data = $table->getData();
529 $this->viewSettings->storeActorSortingMode(
'manually');
530 $this->viewSettings->storeActorSortingData(array_flip(
$data));
531 $this->
ctrl->redirectByClass(ilDashboardGUI::class);
535 $icon_for = fn(
int $obj_id) => $this->
renderer->render(
539 $records = array_map(fn($x) => [
540 'id' => $x->getRefId(),
541 'title' => $icon_for($x->getObjId()) . $x->getTitle(),
542 ], array_values($this->sortManually($this->getItemGroups())));
550 if (!$this->manual_sort_modal) {
551 return parent::getViewControlsForPanel();
553 $show = $this->manual_sort_modal->getShowSignal();
554 $modal_signals = json_encode([
'manually' => (
string) $show]);
555 $url = json_encode($this->
ctrl->getLinkTarget($this,
'changePDItemSorting'));
556 $signal = $this->signal_generator->create();
557 $code = fn(
$id) =>
"il.Dashboard.showModalOnSort($id, $url, '$signal', $modal_signals)";
558 $compontents = array_map(
559 fn($x) => $x instanceof
Sortation ? $x->
withOnSort($signal)->withAdditionalOnLoadCode($code) : $x,
560 parent::getViewControlsForPanel()
568 $this->initAndShow();
573 $this->viewSettings->storeActorSortingMode(
577 return $this->initAndShow();
582 $this->viewSettings->storeActorPresentationMode(
585 return $this->initAndShow();
593 switch ($this->viewSettings->getEffectiveSortingMode()) {
595 $data = $this->getData();
598 return [
'' =>
$data];
600 return $this->groupItemsByStartDate();
602 return $this->groupItemsByType();
604 return [
'' => $this->sortManually($this->getData())];
607 return $this->groupItemsByLocation();
613 $this->favourites_manager->add($this->
user->getId(), $this->requested_item_ref_id);
614 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'rep_added_to_favourites'),
true);
615 $this->
ctrl->redirectByClass(ilDashboardGUI::class,
'show');
620 $this->favourites_manager->remove($this->
user->getId(), $this->requested_item_ref_id);
621 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'rep_removed_from_favourites'),
true);
622 $this->
ctrl->redirectByClass(ilDashboardGUI::class,
'show');
638 $class = $this->objDefinition->getClassName($a_type);
640 throw new ilException(sprintf(
'Could not find a class for object type: %s', $a_type));
643 $location = $this->objDefinition->getLocation($a_type);
645 throw new ilException(sprintf(
'Could not find a class location for object type: %s', $a_type));
648 $full_class =
'ilObj' . $class .
'ListGUI';
649 $item_list_gui =
new $full_class();
651 $item_list_gui->setContainerObject($this);
652 $item_list_gui->enableNotes(
false);
653 $item_list_gui->enableComments(
false);
654 $item_list_gui->enableTags(
false);
656 $item_list_gui->enableIcon(
true);
657 $item_list_gui->enableDelete(
false);
658 $item_list_gui->enableCut(
false);
659 $item_list_gui->enableCopy(
false);
660 $item_list_gui->enableLink(
false);
661 $item_list_gui->enableInfoScreen(
true);
663 $item_list_gui->enableCommands(
true,
true);
665 return $item_list_gui;
697 $new_at_botton =
'bot' === ($this->viewSettings->getEffectiveSortingOptions()[
'new_items'] ??
'bot');
698 $default = $new_at_botton ? INF : -INF;
699 $manual_sorting = $this->viewSettings->getEffectiveSortingData();
701 ($manual_sorting[$l->
getRefId()] ?? $default) <=> ($manual_sorting[$r->
getRefId()] ?? $default)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
The scope of this class is split ilias-conform URI's into components.
Stream factory which enables the user to create streams without the knowledge of the concrete class.
This class represents a block method of a block.
addPresentation(string $label, string $target, bool $active)
setTitle(string $a_title)
setPresentation(int $type)
loadData()
Load data for current page.
addBlockCommand(string $a_href, string $a_text, string $a_onclick="", ?RoundTrip $modal=null)
addSortOption(string $option, string $label, bool $active)
setSortTarget(string $target)
Class ilCommonActionDispatcherGUI.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
getLegacyContent()
Get legacy content.
sortManually(array $data)
int $requested_item_ref_id
getListItemGroups()
Get items.
RoundTrip $manual_sort_modal
getRemoveMultipleActionText()
isRepositoryObject()
Returns whether block has a corresponding repository object.
getCardForData(BlockDTO $data)
changePDItemPresentationObject()
confirmedRemove(array $ids)
getViewControlsForPanel()
getListItemForDataDTO(BlockDTO $data)
changePDItemSortingObject()
addCustomCommandsToActionMenu(ilObjectListGUI $itemListGui, int $ref_id)
preloadData(array $data)
Can be overwritten in subclasses.
ilPDSelectedItemsBlockViewSettings $viewSettings
sortByDate(array $data, bool $asc=true)
readonly SignalGenerator $signal_generator
ilFavouritesManager $favourites_manager
Base class for ILIAS Exception handling.
Manages favourites, currently the interface for other components, needs discussion.
static preloadListGUIData(array $a_obj_ids)
Component logger with individual log levels by component id.
static getPluginObjectByType(string $type)
Return either a repoObject plugin or a orgunit extension plugin or null if the type is not a plugin.
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static getInstance(int $a_ref_id)
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
Common interface to all items.
This describes a Table to specify the order of its data (rows).
This describes a Sortation Control.
withOnSort(Signal $signal)
Get a component like this, triggering a signal of another component.
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.