ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLMObjectGUI.php
Go to the documentation of this file.
1<?php
2
20
27{
28 protected int $requested_ref_id;
32 public ilCtrl $ctrl;
34 public array $actions;
35
36 protected \ILIAS\DI\UIServices $ui;
37 protected int $requested_obj_id;
38 protected string $requested_totransl = "";
39 protected string $requested_transl = "";
40 protected string $requested_target;
41 protected string $requested_new_type;
42 protected array $target_frame;
44
49 public function __construct(ilObjLearningModule $a_content_obj)
50 {
51 global $DIC;
52
53 $tpl = $DIC["tpl"];
54 $lng = $DIC->language();
55 $ilCtrl = $DIC->ctrl();
56
57 $this->tpl = $tpl;
58 $this->lng = $lng;
59 $this->ctrl = $ilCtrl;
60 $this->content_object = $a_content_obj;
61 $this->ui = $DIC->ui();
62 $this->request = $DIC
63 ->learningModule()
64 ->internal()
65 ->gui()
66 ->editing()
67 ->request();
69
70 $this->requested_ref_id = $req->getRefId();
71 $this->requested_obj_id = $req->getObjId();
72 $this->requested_transl = $req->getTranslation();
73 $this->requested_totransl = $req->getToTranslation();
74 $this->requested_target = $req->getTarget();
75 $this->requested_new_type = $req->getNewType();
76 }
77
78
82 public function setActions(?array $a_actions = null): void
83 {
84 if (is_array($a_actions)) {
85 foreach ($a_actions as $name => $lng) {
86 $this->actions[$name] = array("name" => $name, "lng" => $lng);
87 }
88 } else {
89 $this->actions = [];
90 }
91 }
92
93
100 public function getTargetFrame(
101 string $a_cmd,
102 string $a_target_frame = ""
103 ): string {
104 if ($this->target_frame[$a_cmd] != "") {
105 return $this->target_frame[$a_cmd];
106 } elseif (!empty($a_target_frame)) {
107 return "target=\"" . $a_target_frame . "\"";
108 } else {
109 return "";
110 }
111 }
112
116 public function create(): void
117 {
118 $form = $this->getCreateForm();
119 $this->tpl->setContent($form->getHTML());
120 }
121
123 {
124 $new_type = $this->requested_new_type;
125 $this->ctrl->setParameter($this, "new_type", $new_type);
126 $form = new ilPropertyFormGUI();
127 $form->setFormAction($this->ctrl->getFormAction($this, "save"));
128 $form->setTitle($this->lng->txt($new_type . "_new"));
129
130 $title = new ilTextInputGUI($this->lng->txt("title"), "title");
131 $form->addItem($title);
132
133 $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
134 $form->addItem($desc);
135
136 $form->addCommandButton("save", $this->lng->txt($new_type . "_add"));
137 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
138
139 return $form;
140 }
141
142
146 public function putInTree(?int $target = 0): void
147 {
148 if ($target == 0) {
149 $target = $this->requested_target;
150 }
151 $tree = new ilTree($this->content_object->getId());
152 $tree->setTableNames('lm_tree', 'lm_data');
153 $tree->setTreeTablePK("lm_id");
154
155 $parent_id = ($this->requested_obj_id > 0)
156 ? $this->requested_obj_id
157 : $tree->getRootId();
158
159 if ($target == "") {
160 // determine last child of current type
161 $childs = $tree->getChildsByType($parent_id, $this->obj->getType());
162 if (count($childs) == 0) {
163 $target = ilTree::POS_FIRST_NODE;
164 } else {
165 $target = $childs[count($childs) - 1]["obj_id"];
166 }
167 }
168 if (!$tree->isInTree($this->obj->getId())) {
169 $tree->insertNode($this->obj->getId(), $parent_id, $target);
170 }
171 }
172
173
177 public function delete(array $ids): void
178 {
179 $this->setTabs();
180
181 $cont_obj_gui = new ilObjLearningModuleGUI(
182 "",
183 $this->content_object->getRefId(),
184 true,
185 false
186 );
187 $cont_obj_gui->delete($ids);
188 }
189
190 public function setTabs(): void
191 {
192 }
193
194
198 public function cancelDelete(): void
199 {
200 ilSession::clear("saved_post");
201 $this->ctrl->redirect($this, $this->request->getBackCmd());
202 }
203
204
208 public function confirmedDelete(): void
209 {
210 $cont_obj_gui = new ilObjLearningModuleGUI(
211 "",
212 $this->content_object->getRefId(),
213 true,
214 false
215 );
216 $cont_obj_gui->confirmedDelete($this->obj->getId());
217 $this->ctrl->redirect($this, $this->request->getBackCmd());
218 }
219
223 public function showActions(array $a_actions): void
224 {
225 $d = [];
226 foreach ($a_actions as $name => $lng) {
227 $d[$name] = array("name" => $name, "lng" => $lng);
228 }
229
230 $operations = $d;
231 if (count($operations) > 0) {
232 foreach ($operations as $val) {
233 $this->tpl->setCurrentBlock("operation_btn");
234 $this->tpl->setVariable("BTN_NAME", $val["name"]);
235 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
236 $this->tpl->parseCurrentBlock();
237 }
238
239 $this->tpl->setCurrentBlock("operation");
240 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("nav/arrow_downright.svg"));
241 $this->tpl->parseCurrentBlock();
242 }
243 }
244
248 public function checkTree(): void
249 {
250 $this->content_object->checkTree();
251 }
252}
Class ilCtrl provides processing control methods.
Base class for ilStructureObjects and ilPageObjects (see ILIAS DTD)
EditingGUIRequest $request
showActions(array $a_actions)
show possible action (form buttons)
cancelDelete()
cancel deletion of page/structure objects
checkTree()
check the content object tree
__construct(ilObjLearningModule $a_content_obj)
constructor
ilGlobalTemplateInterface $tpl
setActions(?array $a_actions=null)
putInTree(?int $target=0)
put this object into content object tree
create()
structure / page object creation form
getTargetFrame(string $a_cmd, string $a_target_frame="")
get target frame for command (command is method name without "Object", e.g.
confirmedDelete()
page and structure object deletion
ilObjLearningModule $content_object
ILIAS DI UIServices $ui
Class ilLMObject.
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property form user interface.
static clear(string $a_var)
This class represents a text area property in a property form.
This class represents a text property in a property form.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
const POS_FIRST_NODE
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
catch(\Exception $e) $req
Definition: xapiproxy.php:91
global $lng
Definition: privfeed.php:31
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26