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');
184 $this->view_settings->parse();
185 $this->requested_item_ref_id = (
int) ($this->
http->request()->getQueryParams()[
'item_ref_id'] ?? 0);
188 $this->
ctrl->setParameter($this,
'view', $this->view_settings->getView());
189 if ($this->view_settings->isTilePresentation()) {
199 if ($this->parent === ilDashboardGUI::class) {
200 $this->
ctrl->redirectByClass(ilDashboardGUI::class,
'show');
209 $this->
lng->txt(
'dash_' . $this->view_settings->getViewName($this->view_settings->getView()))
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->obj_definition->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->obj_definition->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 $grouped_items = array_map($this->
sortByTitle(...), $grouped_items);
344 return $grouped_items;
349 return $this->tree->getRootId() ===
$refId;
354 $nd = $this->tree->getNodeData($this->tree->getRootId());
366 $sortings = $this->view_settings->getSelectableSortingModes();
367 if (count($sortings) > 1) {
368 foreach ($sortings as $sorting) {
371 $signal = $this->signal_generator->create();
373 $this->manual_sort_modal = $this->
ui->factory()->modal()->roundtrip(
374 $this->
lng->txt(
'dash_manual_sorting_title'),
376 )->withAdditionalOnLoadCode(fn(
$id) =>
"document.getElementById('$id').addEventListener('close', () => {window.location = window.location;});");
378 $this->manual_sort_modal = $this->manual_sort_modal->withAdditionalOnLoadCode(fn(
$id) => (
379 "il.Dashboard.moveModalButtons($id)"
385 $sorting === $this->view_settings->getEffectiveSortingMode()
391 $presentations = $this->view_settings->getSelectablePresentationModes();
395 $this->
ui->renderer()->render($this->ui->factory()->symbol()->glyph()->{
$presentation .
'View'}()),
396 $this->
ctrl->getLinkTarget($this,
'changePDItemPresentation'),
397 $presentation === $this->view_settings->getEffectivePresentationMode()
399 $this->
ctrl->setParameter($this,
'presentation',
null);
404 $this->
ctrl->getLinkTarget($this,
'manage'),
405 $this->lng->txt(
'dash_' . $this->getBlockType() .
'_remove_multiple'),
407 $this->getRemoveModal()
414 $items = $this->getManageFields();
416 $modal = $this->
ui->factory()->modal()->roundtrip(
417 $this->
lng->txt(
'dash_' . $this->getBlockType() .
'_remove_multiple'),
419 $this->ui->factory()->messageBox()->confirmation($this->lng->txt(
'dash_' . $this->getBlockType() .
'_remove_info')),
420 $this->ui->factory()->messageBox()->info($this->lng->txt(
'select_one')),
423 $this->ctrl->getLinkTargetByClass([ilDashboardGUI::class, $this::class],
'confirmedRemove')
424 )->withSubmitLabel($this->
lng->txt(
'dash_' . $this->getBlockType() .
'_remove'));
426 $modal = $modal->withOnLoadCode(
static fn(
$id) =>
"il.Dashboard.confirmModal($id)");
428 $modal = $this->
ui->factory()->modal()->roundtrip(
429 $this->
lng->txt(
'dash_' . $this->getBlockType() .
'_remove_multiple'),
430 $this->ui->factory()->messageBox()->info($this->lng->txt(
'dash_no_items_to_manage'))
440 foreach ($this->getItemGroups() as $key => $item_group) {
442 foreach ($item_group as $item) {
443 $icon = $this->
ui->renderer()->render($this->
ui->factory()->symbol()->icon()->custom(
ilObject::_getIcon($item->getObjId()),
''));
445 if ($this->rbacsystem->checkAccess(
'leave', $item->getRefId())) {
446 if ($item->getType() ===
'crs' || $item->getType() ===
'grp') {
448 if (!$members_obj->checkLastAdmin([$this->user->getId()])) {
452 $options[$item->getRefId()] = $icon . $item->getTitle();
455 $options[$item->getRefId()] = $icon . $item->getTitle();
459 $inputs[] = $this->
ui->factory()->input()->field()->multiSelect((
string) $key,
$options)
460 ->withAdditionalTransformation($this->
refinery->to()->listOf($this->refinery->kindlyTo()->int()));
469 $next_class = $this->
ctrl->getNextClass();
470 $cmd = $this->
ctrl->getCmd(
'getHTML');
472 switch ($next_class) {
473 case strtolower(ilCommonActionDispatcherGUI::class):
476 $this->
ctrl->forwardCommand($gui);
482 case 'confirmedRemove':
483 $form = $this->
ui->factory()->input()->container()->form()->standard(
'', $this->getManageFields())->withRequest($this->
http->request());
484 $this->confirmedRemove(array_merge(...array_filter($form->getData())));
487 if (method_exists($this, $cmd .
'Object')) {
488 return $this->{$cmd .
'Object'}();
497 $request = $this->
http->request();
499 'title' => $this->
factory->table()->column()->text(
'Title')
503 $proc =
function (
$b) use (&$records) {
504 return yield
from array_map(fn($x) =>
$b->buildOrderingRow((
string) $x[
'id'], $x), $records);
507 $uri =
new URI((
string) $request->getUri());
508 parse_str($uri->getQuery(), $query);
509 $uri = $uri->withQuery(http_build_query(array_merge(
511 [
'view' => $this->view_settings->getView()]
513 $table = $this->
factory->table()
514 ->ordering(
new \
ILIAS\Dashboard\TableData($proc), $uri,
'', $columns)
515 ->withRequest($request);
517 $int = $this->
refinery->byTrying([$this->
refinery->kindlyTo()->int(), $this->refinery->always(
null)]);
519 if ($request->getMethod() ===
'POST' && $this->view_settings->getView() === $this->http->wrapper()->query()->retrieve(
'view', $int)) {
520 $data = $table->getData();
522 $this->view_settings->storeActorSortingMode(
'manually');
523 $this->view_settings->storeActorSortingData(array_flip(
$data));
524 $this->
ctrl->redirectByClass(ilDashboardGUI::class);
528 $icon_for = fn(
int $obj_id) => $this->
renderer->render(
532 $records = array_map(fn($x) => [
533 'id' => $x->getRefId(),
534 'title' => $icon_for($x->getObjId()) . $x->getTitle(),
535 ], array_values($this->sortManually($this->getItemGroups())));
543 if (!$this->manual_sort_modal) {
544 return parent::getViewControlsForPanel();
546 $show = $this->manual_sort_modal->getShowSignal();
547 $modal_signals = json_encode([
'manually' => (
string) $show]);
548 $url = json_encode($this->
ctrl->getLinkTarget($this,
'changePDItemSorting'));
549 $signal = $this->signal_generator->create();
550 $code = fn(
$id) =>
"il.Dashboard.showModalOnSort($id, $url, '$signal', $modal_signals)";
551 $compontents = array_map(
552 fn($x) => $x instanceof
Sortation ? $x->
withOnSort($signal)->withAdditionalOnLoadCode($code) : $x,
553 parent::getViewControlsForPanel()
561 $this->initAndShow();
566 $this->view_settings->storeActorSortingMode(
570 return $this->initAndShow();
575 $this->view_settings->storeActorPresentationMode(
578 return $this->initAndShow();
586 switch ($this->view_settings->getEffectiveSortingMode()) {
588 $data = $this->getData();
591 return [
'' =>
$data];
593 return $this->groupItemsByStartDate();
595 return [
'' => $this->sortManually($this->getData())];
597 $groups = $this->groupItemsByType();
598 ksort($groups, SORT_NATURAL);
602 $groups = $this->groupItemsByLocation();
603 ksort($groups, SORT_NATURAL);
611 $this->favourites_manager->add($this->
user->getId(), $this->requested_item_ref_id);
612 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'added_to_favourites'),
true);
613 $this->
ctrl->redirectByClass(ilDashboardGUI::class,
'show');
618 $this->favourites_manager->remove($this->
user->getId(), $this->requested_item_ref_id);
619 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'removed_from_favourites'),
true);
620 $this->
ctrl->redirectByClass(ilDashboardGUI::class,
'show');
637 $class = $this->obj_definition->getClassName($a_type);
639 throw new ilException(sprintf(
'Could not find a class for object type: %s', $a_type));
642 $location = $this->obj_definition->getLocation($a_type);
644 throw new ilException(sprintf(
'Could not find a class location for object type: %s', $a_type));
647 $full_class =
'ilObj' . $class .
'ListGUI';
648 $item_list_gui =
new $full_class();
650 $item_list_gui->setContainerObject($this);
651 $item_list_gui->enableNotes(
false);
652 $item_list_gui->enableComments(
false);
653 $item_list_gui->enableTags(
false);
655 $item_list_gui->enableIcon(
true);
656 $item_list_gui->enableDelete(
false);
657 $item_list_gui->enableCut(
false);
658 $item_list_gui->enableCopy(
false);
659 $item_list_gui->enableLink(
false);
660 $item_list_gui->enableInfoScreen(
true);
662 $item_list_gui->enableCommands(
true,
true);
664 return $item_list_gui;
696 $new_at_botton =
'bot' === ($this->view_settings->getEffectiveSortingOptions()[
'new_items'] ??
'bot');
697 $default = $new_at_botton ? INF : -INF;
698 $manual_sorting = $this->view_settings->getEffectiveSortingData();
700 ($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.