ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAdministrationCommandGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
29 {
31  protected ilSetting $settings;
33  protected ilTree $tree;
35  protected ?ilCtrl $ctrl = null;
36  protected ?ilLanguage $lng = null;
39 
40  public function __construct(ilAdministrationCommandHandling $a_container)
41  {
43  global $DIC;
44 
45  $this->tpl = $DIC->ui()->mainTemplate();
46  $this->settings = $DIC->settings();
47  $this->error = $DIC["ilErr"];
48  $this->tree = $DIC->repositoryTree();
49  $this->obj_definition = $DIC["objDefinition"];
50  $ilCtrl = $DIC->ctrl();
51  $lng = $DIC->language();
52 
53  $this->container = $a_container;
54  $this->ctrl = $ilCtrl;
55  $this->lng = $lng;
56 
57  $this->request = new AdminGUIRequest(
58  $DIC->http(),
59  $DIC->refinery()
60  );
61  }
62 
64  {
65  return $this->container;
66  }
67 
68  public function delete(): void
69  {
70  $tpl = $this->tpl;
73 
74  $this->ctrl->setReturnByClass(get_class($this->getContainer()), '');
75 
76  $to_delete = $this->request->getSelectedIds();
77 
78  if (count($to_delete) === 0) {
79  $ilErr->raiseError($this->lng->txt('no_checkbox'), $ilErr->MESSAGE);
80  }
81 
82  $confirm = new ilConfirmationGUI();
83  $confirm->setFormAction($this->ctrl->getFormActionByClass(get_class($this->getContainer()), 'cancel'));
84  $confirm->setHeaderText('');
85  $confirm->setCancel($this->lng->txt('cancel'), 'cancelDelete');
86  $confirm->setConfirm($this->lng->txt('delete'), 'performDelete');
87 
88  foreach ($to_delete as $delete) {
89  $obj_id = ilObject::_lookupObjId($delete);
90  $type = ilObject::_lookupType($obj_id);
91 
92  $confirm->addItem(
93  'id[]',
94  (string) $delete,
95  call_user_func(array(ilObjectFactory::getClassByType($type),'_lookupTitle'), $obj_id),
96  ilObject::_getIcon($obj_id, 'small', $type)
97  );
98  }
99 
100  $msg = $this->lng->txt("info_delete_sure");
101 
102  if (!$ilSetting->get('enable_trash')) {
103  $msg .= "<br/>" . $this->lng->txt("info_delete_warning_no_trash");
104  }
105  $this->tpl->setOnScreenMessage('question', $msg);
106 
107  $tpl->setContent($confirm->getHTML());
108  }
109 
110  public function performDelete(): void
111  {
112  $this->ctrl->setReturnByClass(get_class($this->getContainer()), '');
113 
114  ilSession::set("saved_post", $this->request->getSelectedIds());
115 
116  $object = new ilObjectGUI(array(), 0, false, false);
117  $object->confirmedDeleteObject();
118  }
119 
120  public function cut(): void
121  {
122  $tree = $this->tree;
123 
124  $this->ctrl->setReturnByClass(get_class($this->getContainer()), '');
125 
126  $ref_id = $tree->getParentId($this->request->getItemRefId());
127 
128  $container = new ilContainerGUI(array(), $ref_id, true, false);
129  $this->ctrl->setParameter($container, 'ref_id', $ref_id);
130  $container->cutObject();
131  }
132 
133  // Show target selection
134  public function showMoveIntoObjectTree(): void
135  {
136  $objDefinition = $this->obj_definition;
137 
138  $this->ctrl->setReturnByClass(get_class($this->getContainer()), '');
139 
140  $obj_id = ilObject::_lookupObjId($this->request->getRefId());
141  $type = ilObject::_lookupType($obj_id);
142 
143  $class_name = "ilObj" . $objDefinition->getClassName($type) . 'GUI';
144 
145  // create instance
146  $container = new $class_name(array(), $this->request->getRefId(), true, false);
147  $container->showMoveIntoObjectTreeObject();
148  }
149 
150  // Target selection
151  public function showLinkIntoMultipleObjectsTree(): void
152  {
153  $objDefinition = $this->obj_definition;
154 
155  $this->ctrl->setReturnByClass(get_class($this->getContainer()), '');
156 
157  $obj_id = ilObject::_lookupObjId($this->request->getRefId());
158  $type = ilObject::_lookupType($obj_id);
159 
160  $class_name = "ilObj" . $objDefinition->getClassName($type) . 'GUI';
161 
162  // create instance
163  $container = new $class_name(array(), $this->request->getRefId(), true, false);
164  $container->showLinkIntoMultipleObjectsTreeObject();
165  }
166 
167  // Start linking object
168  public function link(): void
169  {
170  $tree = $this->tree;
171 
172  $this->ctrl->setReturnByClass(get_class($this->getContainer()), '');
173 
174  $ref_id = $tree->getParentId($this->request->getItemRefId());
175 
176  $container = new ilContainerGUI(array(), $ref_id, true, false);
177  $this->ctrl->setParameter($container, 'ref_id', $ref_id);
178  $container->linkObject();
179  }
180 
181  public function showPasteTree(): void
182  {
183  $tree = $this->tree;
184 
185  $this->ctrl->setReturnByClass(get_class($this->getContainer()), '');
186 
187  $ref_id = $tree->getParentId($this->request->getRefId());
188 
189  $container = new ilContainerGUI(array(), $ref_id, true, false);
190  $container->showPasteTreeObject();
191  }
192 
193  // Paste object
194  public function paste(): void
195  {
196  $objDefinition = $this->obj_definition;
197 
198  $this->ctrl->setReturnByClass(get_class($this->getContainer()), '');
199 
200  $obj_id = ilObject::_lookupObjId($this->request->getItemRefId());
201  $type = ilObject::_lookupType($obj_id);
202 
203  $class_name = "ilObj" . $objDefinition->getClassName($type) . 'GUI';
204 
205  // create instance
206  $container = new $class_name(array(), $this->request->getItemRefId(), true, false);
207  $container->pasteObject();
208  }
209 
210  public function performPasteIntoMultipleObjects(): void
211  {
212  $objDefinition = $this->obj_definition;
213 
214  $this->ctrl->setReturnByClass(get_class($this->getContainer()), '');
215 
216  $obj_id = ilObject::_lookupObjId($this->request->getRefId());
217  $type = ilObject::_lookupType($obj_id);
218 
219  $class_name = "ilObj" . $objDefinition->getClassName($type) . 'GUI';
220 
221  // create instance
222  $container = new $class_name(array(), $this->request->getRefId(), true, false);
223  $container->performPasteIntoMultipleObjectsObject();
224  }
225 }
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
$type
Handles Administration commands (cut, delete paste)
$ilErr
Definition: raiseError.php:17
static _lookupObjId(int $ref_id)
global $DIC
Definition: feed.php:28
parses the objects.xml it handles the xml-description of all ilias objects
$ref_id
Definition: ltiauth.php:67
setContent(string $a_html)
Sets content for standard template.
Class ilObjectGUI Basic methods of all Output classes.
getParentId(int $a_node_id)
get parent id of given node
ilAdministrationCommandHandling $container
static getClassByType(string $obj_type)
Error Handling & global info handling uses PEAR error class.
global $ilSetting
Definition: privfeed.php:17
__construct(Container $dic, ilPlugin $plugin)
Class ilContainerGUI This is a base GUI class for all container objects in ILIAS: root folder...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
static set(string $a_var, $a_val)
Set a value.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...