ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilMMTopItemTableGUI.php
Go to the documentation of this file.
1<?php
2
3use ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
4
11{
12 use Hasher;
20 private $access;
21
22
31 {
32 $this->access = $access;
33 $this->setId(self::class);
34 $this->setExternalSorting(true);
35 $this->setExternalSegmentation(true);
36 parent::__construct($a_parent_obj);
37 $this->item_repository = $item_repository;
38 $this->lng = $this->parent_obj->lng;
39 $this->setData($this->resolveData());
40 $this->setFormAction($this->ctrl->getFormAction($this->parent_obj));
41 if ($this->access->hasUserPermissionTo('write')) {
42 $this->addCommandButton(ilMMTopItemGUI::CMD_SAVE_TABLE, $this->lng->txt('button_save'));
43 }
44 $this->initColumns();
45 $this->setRowTemplate('tpl.top_items.html', 'Services/MainMenu');
46 }
47
48
49 private function initColumns()
50 {
51 $this->addColumn($this->lng->txt('topitem_position'), '', '30px');
52 $this->addColumn($this->lng->txt('topitem_title'));
53 $this->addColumn($this->lng->txt('topitem_active'));
54 $this->addColumn($this->lng->txt('topitem_subentries'));
55 $this->addColumn($this->lng->txt('topitem_css_id'));
56 $this->addColumn($this->lng->txt('topitem_type'));
57 $this->addColumn($this->lng->txt('topitem_provider'));
58 $this->addColumn($this->lng->txt('topitem_actions'));
59 }
60
61
65 protected function fillRow($a_set)
66 {
67 static $position;
68 $position++;
69 global $DIC;
70 $renderer = $DIC->ui()->renderer();
71 $factory = $DIC->ui()->factory();
72
73 $item_facade = $this->item_repository->repository()->getItemFacade($DIC->globalScreen()->identification()->fromSerializedIdentification($a_set['identification']));
74
75 $this->tpl->setVariable('IDENTIFIER', ilMMTopItemGUI::IDENTIFIER);
76 $this->tpl->setVariable('ID', $item_facade->getId());
77 $this->tpl->setVariable('TITLE', $item_facade->getDefaultTitle());
78 $this->tpl->setVariable('SUBENTRIES', $item_facade->getAmountOfChildren());
79 $this->tpl->setVariable('TYPE', $item_facade->getTypeForPresentation());
80 $this->tpl->setVariable('CSS_ID', "mm_" . $item_facade->identification()->getInternalIdentifier());
81 $this->tpl->setVariable('POSITION', $position * 10);
82 if ($item_facade->isActivated()) {
83 $this->tpl->touchBlock('is_active');
84 }
85 if ($item_facade->isAlwaysAvailable() || !$item_facade->isAvailable()) {
86 $this->tpl->touchBlock('is_active_blocked');
87 }
88 $this->tpl->setVariable('PROVIDER', $item_facade->getProviderNameForPresentation());
89
90 $this->ctrl->setParameterByClass(ilMMTopItemGUI::class, ilMMTopItemGUI::IDENTIFIER, $this->hash($a_set['identification']));
91 $this->ctrl->setParameterByClass(ilMMItemTranslationGUI::class, ilMMItemTranslationGUI::IDENTIFIER, $this->hash($a_set['identification']));
92
93 if ($this->access->hasUserPermissionTo('write')) {
94 if ($item_facade->isEditable()) {
95 $items[] = $factory->button()->shy($this->lng->txt(ilMMTopItemGUI::CMD_EDIT), $this->ctrl->getLinkTargetByClass(ilMMTopItemGUI::class, ilMMTopItemGUI::CMD_EDIT));
96 $items[] = $factory->button()
97 ->shy($this->lng->txt(ilMMTopItemGUI::CMD_TRANSLATE), $this->ctrl->getLinkTargetByClass(ilMMItemTranslationGUI::class, ilMMItemTranslationGUI::CMD_DEFAULT));
98 }
99
100 $rendered_modal = "";
101 if ($item_facade->isDeletable()) {
102 $ditem = $factory->modal()->interruptiveItem($this->hash($a_set['identification']), $item_facade->getDefaultTitle());
103 $action = $this->ctrl->getFormActionByClass(ilMMSubItemGUI::class, ilMMSubItemGUI::CMD_DELETE);
104 $m = $factory->modal()
105 ->interruptive($this->lng->txt(ilMMTopItemGUI::CMD_DELETE), $this->lng->txt(ilMMTopItemGUI::CMD_CONFIRM_DELETE), $action)
106 ->withAffectedItems([$ditem]);
107
108 $items[] = $shy = $factory->button()->shy($this->lng->txt(ilMMTopItemGUI::CMD_DELETE), "")->withOnClick($m->getShowSignal());
109 // $items[] = $factory->button()->shy($this->lng->txt(ilMMSubItemGUI::CMD_DELETE), $this->ctrl->getLinkTargetByClass(ilMMSubItemGUI::class, ilMMSubItemGUI::CMD_CONFIRM_DELETE));
110 $rendered_modal = $renderer->render([$m]);
111 }
112 $this->tpl->setVariable('ACTIONS', $rendered_modal . $renderer->render([$factory->dropdown()->standard($items)->withLabel($this->lng->txt('sub_actions'))]));
113 }
114 }
115
116
120 private function resolveData() : array
121 {
122 return $this->item_repository->getTopItems();
123 }
124}
$factory
Definition: metadata.php:43
An exception for terminatinating execution or to throw for unit testing.
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.
Class ilObjMainMenuAccess.
Class ilTable2GUI.
setExternalSorting($a_val)
Set external sorting.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setExternalSegmentation($a_val)
Set external segmentation.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
$action
hash(StreamInterface $stream, $algo, $rawOutput=false)
Calculate a hash of a Stream.
Definition: functions.php:406
global $DIC
Definition: saml.php:7