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->obj_definition =
$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(
'pd');
183 $this->view_settings->parse();
184 $this->requested_item_ref_id = (
int) ($this->
http->request()->getQueryParams()[
'item_ref_id'] ?? 0);
187 $this->
ctrl->setParameter($this,
'view', $this->view_settings->getView());
188 if ($this->view_settings->isTilePresentation()) {
198 if ($this->parent === ilDashboardGUI::class) {
199 $this->
ctrl->redirectByClass(ilDashboardGUI::class,
'show');
208 $this->
lng->txt(
'dash_' . $this->view_settings->getViewName($this->view_settings->getView()))
218 $modal = $this->manual_sort_modal ? $this->
ui->renderer()->render($this->manual_sort_modal) :
'';
219 return parent::getHTML() . $modal;
227 $this->data = array_filter(
229 static fn($group) => array_filter($group,
static fn($item) => $item instanceof
BlockDTO),
240 return parent::getData();
246 public function groupItemsByStartDate(): array
250 $items = array_merge(...array_values(
$data));
258 foreach ($items as $item) {
259 if ($item->isDated()) {
260 if ($item->hasNotStarted()) {
261 $groups[
'upcoming'][] = $item;
262 } elseif ($item->isRunning()) {
263 $groups[
'ongoing'][] = $item;
265 $groups[
'ended'][] = $item;
268 $groups[
'not_dated'][] = $item;
272 foreach ($groups as $key => $group) {
274 if ($key !==
'not_dated') {
275 $group = $this->
sortByDate($group, $key ===
'upcoming');
277 $groups[$this->
lng->txt(
'pd_' . $key)] = $group;
278 unset($groups[$key]);
286 protected function groupItemsByType(): array
288 $object_types_by_container = $this->obj_definition->getGroupedRepositoryObjectTypes(
289 [
'cat',
'crs',
'grp',
'fold']
294 $data = array_merge(...array_values(
$data));
296 foreach ($object_types_by_container as $type_title => $type) {
297 if (!$this->obj_definition->isPlugin($type_title)) {
298 $title = $this->
lng->txt(
'objs_' . $type_title);
301 $title = $pl->txt(
'objs_' . $type_title);
304 foreach (
$data as $item) {
305 if (in_array($item->getType(), $type[
'objs'])) {
306 $grouped_items[
$title][] = $item;
311 foreach ($grouped_items as $key => $group) {
315 return $grouped_items;
321 protected function groupItemsByLocation(): array
326 $data = array_merge(...array_values(
$data));
328 $parent_ref_ids = array_values(array_unique(
331 $this->object_cache->preloadReferenceCache($parent_ref_ids);
333 foreach (
$data as $item) {
334 $parent_ref = $this->tree->getParentId($item->getRefId());
338 $title = $this->object_cache->lookupTitle($this->object_cache->lookupObjId($parent_ref));
340 $grouped_items[
$title][] = $item;
342 $grouped_items = array_map($this->
sortByTitle(...), $grouped_items);
343 return $grouped_items;
348 return $this->tree->getRootId() ===
$refId;
353 $nd = $this->tree->getNodeData($this->tree->getRootId());
365 $sortings = $this->view_settings->getSelectableSortingModes();
366 if (count($sortings) > 1) {
367 foreach ($sortings as $sorting) {
370 $signal = $this->signal_generator->create();
372 $this->manual_sort_modal = $this->
ui->factory()->modal()->roundtrip(
373 $this->
lng->txt(
'dash_manual_sorting_title'),
375 )->withAdditionalOnLoadCode(fn(
$id) =>
"document.getElementById('$id').addEventListener('close', () => {window.location = window.location;});");
377 $this->manual_sort_modal = $this->manual_sort_modal->withAdditionalOnLoadCode(fn(
$id) => (
378 "il.Dashboard.moveModalButtons($id)"
384 $sorting === $this->view_settings->getEffectiveSortingMode()
390 $presentations = $this->view_settings->getSelectablePresentationModes();
394 $this->
ui->renderer()->render($this->ui->factory()->symbol()->glyph()->{
$presentation .
'View'}()),
395 $this->
ctrl->getLinkTarget($this,
'changePDItemPresentation'),
396 $presentation === $this->view_settings->getEffectivePresentationMode()
398 $this->
ctrl->setParameter($this,
'presentation',
null);
403 $this->
ctrl->getLinkTarget($this,
'manage'),
404 $this->lng->txt(
'dash_' . $this->getBlockType() .
'_remove_multiple'),
406 $this->getRemoveModal()
413 $items = $this->getManageFields();
415 $modal = $this->
ui->factory()->modal()->roundtrip(
416 $this->
lng->txt(
'dash_' . $this->getBlockType() .
'_remove_multiple'),
418 $this->ui->factory()->messageBox()->confirmation($this->lng->txt(
'dash_' . $this->getBlockType() .
'_remove_info')),
419 $this->ui->factory()->messageBox()->info($this->lng->txt(
'select_one')),
422 $this->ctrl->getLinkTargetByClass([ilDashboardGUI::class, $this::class],
'confirmedRemove')
423 )->withSubmitLabel($this->
lng->txt(
'dash_' . $this->getBlockType() .
'_remove'));
425 $modal = $modal->withOnLoadCode(
static fn(
$id) =>
"il.Dashboard.confirmModal($id)");
427 $modal = $this->
ui->factory()->modal()->roundtrip(
428 $this->
lng->txt(
'dash_' . $this->getBlockType() .
'_remove_multiple'),
429 $this->ui->factory()->messageBox()->info($this->lng->txt(
'dash_no_items_to_manage'))
439 foreach ($this->getItemGroups() as $key => $item_group) {
441 foreach ($item_group as $item) {
442 $icon = $this->
ui->renderer()->render($this->
ui->factory()->symbol()->icon()->custom(
ilObject::_getIcon($item->getObjId()),
''));
444 if ($this->rbacsystem->checkAccess(
'leave', $item->getRefId())) {
445 if ($item->getType() ===
'crs' || $item->getType() ===
'grp') {
447 if (!$members_obj->checkLastAdmin([$this->user->getId()])) {
451 $options[$item->getRefId()] = $icon . $item->getTitle();
454 $options[$item->getRefId()] = $icon . $item->getTitle();
458 $inputs[] = $this->
ui->factory()->input()->field()->multiSelect((
string) $key,
$options)
459 ->withAdditionalTransformation($this->
refinery->to()->listOf($this->refinery->kindlyTo()->int()));
468 $next_class = $this->
ctrl->getNextClass();
469 $cmd = $this->
ctrl->getCmd(
'getHTML');
471 switch ($next_class) {
472 case strtolower(ilCommonActionDispatcherGUI::class):
475 $this->
ctrl->forwardCommand($gui);
481 case 'confirmedRemove':
482 $form = $this->
ui->factory()->input()->container()->form()->standard(
'', $this->getManageFields())->withRequest($this->
http->request());
483 $this->confirmedRemove(array_merge(...array_filter($form->getData())));
486 if (method_exists($this, $cmd .
'Object')) {
487 return $this->{$cmd .
'Object'}();
496 $request = $this->
http->request();
498 'title' => $this->
factory->table()->column()->text(
'Title')
502 $proc =
function (
$b) use (&$records) {
503 return yield
from array_map(fn($x) =>
$b->buildOrderingRow((
string) $x[
'id'], $x), $records);
506 $uri =
new URI((
string) $request->getUri());
507 parse_str($uri->getQuery(), $query);
508 $uri = $uri->withQuery(http_build_query(array_merge(
510 [
'view' => $this->view_settings->getView()]
512 $table = $this->
factory->table()
513 ->ordering(
new \
ILIAS\Dashboard\TableData($proc), $uri,
'', $columns)
514 ->withRequest($request);
516 $int = $this->
refinery->byTrying([$this->
refinery->kindlyTo()->int(), $this->refinery->always(
null)]);
518 if ($request->getMethod() ===
'POST' && $this->view_settings->getView() === $this->http->wrapper()->query()->retrieve(
'view', $int)) {
519 $data = $table->getData();
521 $this->view_settings->storeActorSortingMode(
'manually');
522 $this->view_settings->storeActorSortingData(array_flip(
$data));
523 $this->
ctrl->redirectByClass(ilDashboardGUI::class);
527 $icon_for = fn(
int $obj_id) => $this->
renderer->render(
531 $records = array_map(fn($x) => [
532 'id' => $x->getRefId(),
533 'title' => $icon_for($x->getObjId()) . $x->getTitle(),
534 ], array_values($this->sortManually($this->getItemGroups())));
542 if (!$this->manual_sort_modal) {
543 return parent::getViewControlsForPanel();
545 $show = $this->manual_sort_modal->getShowSignal();
546 $modal_signals = json_encode([
'manually' => (
string) $show]);
547 $url = json_encode($this->
ctrl->getLinkTarget($this,
'changePDItemSorting'));
548 $signal = $this->signal_generator->create();
549 $code = fn(
$id) =>
"il.Dashboard.showModalOnSort($id, $url, '$signal', $modal_signals)";
550 $compontents = array_map(
551 fn($x) => $x instanceof
Sortation ? $x->
withOnSort($signal)->withAdditionalOnLoadCode($code) : $x,
552 parent::getViewControlsForPanel()
560 $this->initAndShow();
565 $this->view_settings->storeActorSortingMode(
569 return $this->initAndShow();
574 $this->view_settings->storeActorPresentationMode(
577 return $this->initAndShow();
585 switch ($this->view_settings->getEffectiveSortingMode()) {
587 $data = $this->getData();
590 return [
'' =>
$data];
592 return $this->groupItemsByStartDate();
594 return [
'' => $this->sortManually($this->getData())];
596 $groups = $this->groupItemsByType();
597 ksort($groups, SORT_NATURAL);
601 $groups = $this->groupItemsByLocation();
602 ksort($groups, SORT_NATURAL);
609 $this->favourites_manager->add($this->
user->getId(), $this->requested_item_ref_id);
610 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'rep_added_to_favourites'),
true);
611 $this->
ctrl->redirectByClass(ilDashboardGUI::class,
'show');
616 $this->favourites_manager->remove($this->
user->getId(), $this->requested_item_ref_id);
617 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'rep_removed_from_favourites'),
true);
618 $this->
ctrl->redirectByClass(ilDashboardGUI::class,
'show');
635 $class = $this->obj_definition->getClassName($a_type);
637 throw new ilException(sprintf(
'Could not find a class for object type: %s', $a_type));
640 $location = $this->obj_definition->getLocation($a_type);
642 throw new ilException(sprintf(
'Could not find a class location for object type: %s', $a_type));
645 $full_class =
'ilObj' . $class .
'ListGUI';
646 $item_list_gui =
new $full_class();
648 $item_list_gui->setContainerObject($this);
649 $item_list_gui->enableNotes(
false);
650 $item_list_gui->enableComments(
false);
651 $item_list_gui->enableTags(
false);
653 $item_list_gui->enableIcon(
true);
654 $item_list_gui->enableDelete(
false);
655 $item_list_gui->enableCut(
false);
656 $item_list_gui->enableCopy(
false);
657 $item_list_gui->enableLink(
false);
658 $item_list_gui->enableInfoScreen(
true);
660 $item_list_gui->enableCommands(
true,
true);
662 return $item_list_gui;
694 $new_at_botton =
'bot' === ($this->view_settings->getEffectiveSortingOptions()[
'new_items'] ??
'bot');
695 $default = $new_at_botton ? INF : -INF;
696 $manual_sorting = $this->view_settings->getEffectiveSortingData();
698 ($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.
readonly ilLogger $logging
RoundTrip $manual_sort_modal
isRepositoryObject()
Returns whether block has a corresponding repository object.
getCardForData(BlockDTO $data)
changePDItemPresentationObject()
confirmedRemove(array $ids)
getViewControlsForPanel()
readonly ilRbacSystem $rbacsystem
readonly ilFavouritesManager $favourites_manager
getListItemForDataDTO(BlockDTO $data)
changePDItemSortingObject()
addCustomCommandsToActionMenu(ilObjectListGUI $itemListGui, int $ref_id)
preloadData(array $data)
Can be overwritten in subclasses.
sortByDate(array $data, bool $asc=true)
ilPDSelectedItemsBlockViewSettings $view_settings
readonly Factory $refinery
readonly SignalGenerator $signal_generator
readonly ilSetting $settings
readonly mixed $obj_definition
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.