ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilMMTopItemTableGUI.php
Go to the documentation of this file.
1<?php
2
3use ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
4
10{
11 use Hasher;
12
20 private $access;
21
29 {
30 $this->access = $access;
31 $this->setId(self::class);
32 $this->setExternalSorting(true);
33 $this->setExternalSegmentation(true);
34 parent::__construct($a_parent_obj);
35 $this->item_repository = $item_repository;
36 $this->lng = $this->parent_obj->lng;
37 $this->setData($this->resolveData());
38 $this->setFormAction($this->ctrl->getFormAction($this->parent_obj));
39 if ($this->access->hasUserPermissionTo('write')) {
40 $this->addCommandButton(ilMMTopItemGUI::CMD_SAVE_TABLE, $this->lng->txt('button_save'));
41 }
42 $this->initColumns();
43 $this->setRowTemplate('tpl.top_items.html', 'Services/MainMenu');
44 }
45
46 private function initColumns()
47 {
48 $this->addColumn($this->lng->txt('topitem_position'), '', '30px');
49 $this->addColumn($this->lng->txt('topitem_title'));
50 $this->addColumn($this->lng->txt('topitem_active'));
51 $this->addColumn($this->lng->txt('topitem_subentries'));
52 $this->addColumn($this->lng->txt('topitem_type'));
53 $this->addColumn($this->lng->txt('topitem_provider'));
54 $this->addColumn($this->lng->txt('topitem_actions'));
55 }
56
60 protected function fillRow($a_set)
61 {
62 static $position;
63 $position++;
64 global $DIC;
65 $renderer = $DIC->ui()->renderer();
66 $factory = $DIC->ui()->factory();
67
68 $item_facade = $this->item_repository->repository()->getItemFacade($DIC->globalScreen()->identification()->fromSerializedIdentification($a_set['identification']));
69
70 $this->tpl->setVariable('IDENTIFIER', ilMMTopItemGUI::IDENTIFIER);
71 $this->tpl->setVariable('ID', $this->hash($item_facade->getId()));
72 $this->tpl->setVariable('NATIVE_ID', $item_facade->getId());
73 $this->tpl->setVariable('TITLE', $item_facade->getDefaultTitle());
74 $this->tpl->setVariable('SUBENTRIES', $item_facade->getAmountOfChildren());
75 $this->tpl->setVariable('TYPE', $item_facade->getTypeForPresentation());
76 $this->tpl->setVariable('POSITION', $position * 10);
77 $this->tpl->setVariable('NATIVE_POSITION', $item_facade->getRawItem()->getPosition());
78 $this->tpl->setVariable('SAVED_POSITION', $item_facade->getFilteredItem()->getPosition());
79 if ($item_facade->isActivated()) {
80 $this->tpl->touchBlock('is_active');
81 }
82 if ($item_facade->isAlwaysAvailable() || !$item_facade->isAvailable()) {
83 $this->tpl->touchBlock('is_active_blocked');
84 }
85 $this->tpl->setVariable('PROVIDER', $item_facade->getProviderNameForPresentation());
86
87 $this->ctrl->setParameterByClass(ilMMTopItemGUI::class, ilMMTopItemGUI::IDENTIFIER, $this->hash($a_set['identification']));
88 $this->ctrl->setParameterByClass(ilMMItemTranslationGUI::class, ilMMItemTranslationGUI::IDENTIFIER, $this->hash($a_set['identification']));
89
90 if ($this->access->hasUserPermissionTo('write')) {
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}
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
global $DIC
Definition: goto.php:24
$factory
Definition: metadata.php:58
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc