ILIAS  release_8 Revision v8.24
class.ilMMTopItemTableGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5use ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
6
12{
13 use Hasher;
14
16
18
26 {
27 $this->access = $access;
28 $this->setId(self::class);
29 $this->setExternalSorting(true);
30 $this->setExternalSegmentation(true);
31 parent::__construct($a_parent_obj);
32 $this->item_repository = $item_repository;
33 $this->lng = $this->parent_obj->lng;
34 $this->setData($this->resolveData());
35 $this->setFormAction($this->ctrl->getFormAction($this->parent_obj));
36 if ($this->access->hasUserPermissionTo('write')) {
37 $this->addCommandButton(ilMMTopItemGUI::CMD_SAVE_TABLE, $this->lng->txt('button_save'));
38 }
39 $this->initColumns();
40 $this->setRowTemplate('tpl.top_items.html', 'Services/MainMenu');
41 }
42
43 private function initColumns(): void
44 {
45 $this->addColumn($this->lng->txt('topitem_position'), '', '30px');
46 $this->addColumn($this->lng->txt('topitem_title'));
47 $this->addColumn($this->lng->txt('topitem_active'));
48 $this->addColumn($this->lng->txt('topitem_subentries'));
49 $this->addColumn($this->lng->txt('topitem_css_id'));
50 $this->addColumn($this->lng->txt('topitem_type'));
51 $this->addColumn($this->lng->txt('topitem_provider'));
52 $this->addColumn($this->lng->txt('topitem_actions'));
53 }
54
58 protected function fillRow(array $a_set): void
59 {
60 static $position;
61 $position++;
62 global $DIC;
63 $renderer = $DIC->ui()->renderer();
64 $factory = $DIC->ui()->factory();
65
66 $item_facade = $this->item_repository->repository()->getItemFacade($DIC->globalScreen()->identification()->fromSerializedIdentification($a_set['identification']));
67
68 $this->tpl->setVariable('IDENTIFIER', ilMMAbstractItemGUI::IDENTIFIER);
69 $this->tpl->setVariable('ID', $this->hash($item_facade->getId()));
70 $this->tpl->setVariable('NATIVE_ID', $item_facade->getId());
71 $this->tpl->setVariable('TITLE', $item_facade->getDefaultTitle());
72 $this->tpl->setVariable('SUBENTRIES', $item_facade->getAmountOfChildren());
73 $this->tpl->setVariable('TYPE', $item_facade->getTypeForPresentation());
74 $this->tpl->setVariable('CSS_ID', "mm_" . $item_facade->identification()->getInternalIdentifier());
75 $this->tpl->setVariable('POSITION', $position * 10);
76 $this->tpl->setVariable('NATIVE_POSITION', $item_facade->getRawItem()->getPosition());
77 $this->tpl->setVariable('SAVED_POSITION', $item_facade->getFilteredItem()->getPosition());
78 if ($item_facade->isActivated()) {
79 $this->tpl->touchBlock('is_active');
80 }
81 if ($item_facade->isAlwaysAvailable() || !$item_facade->isAvailable()) {
82 $this->tpl->touchBlock('is_active_blocked');
83 }
84 $this->tpl->setVariable('PROVIDER', $item_facade->getProviderNameForPresentation());
85
86 $this->ctrl->setParameterByClass(ilMMTopItemGUI::class, ilMMAbstractItemGUI::IDENTIFIER, $this->hash($a_set['identification']));
87 $this->ctrl->setParameterByClass(ilMMItemTranslationGUI::class, ilMMItemTranslationGUI::IDENTIFIER, $this->hash($a_set['identification']));
88
89 if ($this->access->hasUserPermissionTo('write')) {
90 $items = [];
91 if ($item_facade->isEditable()) {
92 $items[] = $factory->button()->shy($this->lng->txt(ilMMTopItemGUI::CMD_EDIT), $this->ctrl->getLinkTargetByClass(ilMMTopItemGUI::class, ilMMTopItemGUI::CMD_EDIT));
93 $items[] = $factory->button()
94 ->shy($this->lng->txt(ilMMTopItemGUI::CMD_TRANSLATE), $this->ctrl->getLinkTargetByClass(ilMMItemTranslationGUI::class, ilMMItemTranslationGUI::CMD_DEFAULT));
95 }
96
97 $rendered_modal = "";
98 if ($item_facade->isDeletable()) {
99 $ditem = $factory->modal()->interruptiveItem($this->hash($a_set['identification']), $item_facade->getDefaultTitle());
100 $action = $this->ctrl->getFormActionByClass(ilMMSubItemGUI::class, ilMMSubItemGUI::CMD_DELETE);
101 $m = $factory->modal()
102 ->interruptive($this->lng->txt(ilMMTopItemGUI::CMD_DELETE), $this->lng->txt(ilMMTopItemGUI::CMD_CONFIRM_DELETE), $action)
103 ->withAffectedItems([$ditem]);
104
105 $items[] = $shy = $factory->button()->shy($this->lng->txt(ilMMTopItemGUI::CMD_DELETE), "")->withOnClick($m->getShowSignal());
106 // $items[] = $factory->button()->shy($this->lng->txt(ilMMSubItemGUI::CMD_DELETE), $this->ctrl->getLinkTargetByClass(ilMMSubItemGUI::class, ilMMSubItemGUI::CMD_CONFIRM_DELETE));
107 $rendered_modal = $renderer->render([$m]);
108 }
109 if ($item_facade->isInterchangeable()) {
110 $items[] = $factory->button()->shy($this->lng->txt(ilMMTopItemGUI::CMD_MOVE . '_to_item'), $this->ctrl->getLinkTargetByClass(ilMMTopItemGUI::class, ilMMTopItemGUI::CMD_SELECT_PARENT));
111 }
112 $this->tpl->setVariable('ACTIONS', $rendered_modal . $renderer->render([$factory->dropdown()->standard($items)->withLabel($this->lng->txt('sub_actions'))]));
113 }
114 }
115
119 private function resolveData(): array
120 {
121 return $this->item_repository->getTopItems();
122 }
123}
Class ilMMItemRepository.
Class ilMMTopItemGUI @ilCtrl_IsCalledBy ilMMTopItemGUI: ilObjMainMenuGUI @ilCtrl_Calls ilMMTopItemGUI...
Class ilMMTopItemTableGUI.
__construct(ilMMTopItemGUI $a_parent_obj, ilMMItemRepository $item_repository, ilObjMainMenuAccess $access)
ilMMTopItemTableGUI constructor.
fillRow(array $a_set)
@inheritDoc
ilMMItemRepository $item_repository
Class ilObjMainMenuAccess.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setExternalSegmentation(bool $a_val)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setExternalSorting(bool $a_val)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setData(array $a_data)
Set table data.
global $DIC
Definition: feed.php:28
$factory
Definition: metadata.php:75
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc