ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilLMObjectGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5
17{
18 public $tpl;
19 public $lng;
20 public $obj;
21 public $ctrl;
23 public $actions;
24
28 protected $ui;
29
30
36 public function __construct(&$a_content_obj)
37 {
38 global $DIC;
39
40 $tpl = $DIC["tpl"];
41 $lng = $DIC->language();
42 $ilCtrl = $DIC->ctrl();
43
44 $this->tpl = $tpl;
45 $this->lng = $lng;
46 $this->ctrl = $ilCtrl;
47 $this->content_object = $a_content_obj;
48 $this->ui = $DIC->ui();
49 }
50
51
59 public function setActions($a_actions = "")
60 {
61 if (is_array($a_actions)) {
62 foreach ($a_actions as $name => $lng) {
63 $this->actions[$name] = array("name" => $name, "lng" => $lng);
64 }
65 } else {
66 $this->actions = "";
67 }
68 }
69
70
78 public function getTargetFrame($a_cmd, $a_target_frame = "")
79 {
80 if ($this->target_frame[$a_cmd] != "") {
81 return $this->target_frame[$a_cmd];
82 } elseif (!empty($a_target_frame)) {
83 return "target=\"" . $a_target_frame . "\"";
84 } else {
85 return;
86 }
87 }
88
92 public function create()
93 {
94 $new_type = $_REQUEST["new_type"];
95
96 $this->ctrl->setParameter($this, "new_type", $new_type);
97 $form = new ilPropertyFormGUI();
98 $form->setFormAction($this->ctrl->getFormAction($this, "save"));
99 $form->setTitle($this->lng->txt($new_type . "_new"));
100
101 $title = new ilTextInputGUI($this->lng->txt("title"), "Fobject[title]");
102 //$title->setRequired(true);
103 $form->addItem($title);
104
105 $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "Fobject[desc]");
106 $form->addItem($desc);
107
108 $form->addCommandButton("save", $this->lng->txt($new_type . "_add"));
109 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
110
111 $this->tpl->setContent($form->getHTML());
112 }
113
114
118 public function putInTree()
119 {
120 $tree = new ilTree($this->content_object->getId());
121 $tree->setTableNames('lm_tree', 'lm_data');
122 $tree->setTreeTablePK("lm_id");
123
124 $parent_id = (!empty($_GET["obj_id"]))
125 ? $_GET["obj_id"]
126 : $tree->getRootId();
127
128 if (!empty($_GET["target"])) {
129 $target = $_GET["target"];
130 } else {
131 // determine last child of current type
132 $childs = $tree->getChildsByType($parent_id, $this->obj->getType());
133 if (count($childs) == 0) {
134 $target = IL_FIRST_NODE;
135 } else {
136 $target = $childs[count($childs) - 1]["obj_id"];
137 }
138 }
139 if (!$tree->isInTree($this->obj->getId())) {
140 $tree->insertNode($this->obj->getId(), $parent_id, $target);
141 }
142 }
143
144
148 public function delete()
149 {
150 $this->setTabs();
151
152 $cont_obj_gui = new ilObjContentObjectGUI(
153 "",
154 $this->content_object->getRefId(),
155 true,
156 false
157 );
158 $cont_obj_gui->delete($this->obj->getId());
159 }
160
161
165 public function cancelDelete()
166 {
167 ilSession::clear("saved_post");
168 $this->ctrl->redirect($this, $_GET["backcmd"]);
169 }
170
171
175 public function confirmedDelete()
176 {
177 $cont_obj_gui = new ilObjContentObjectGUI(
178 "",
179 $this->content_object->getRefId(),
180 true,
181 false
182 );
183 $cont_obj_gui->confirmedDelete($this->obj->getId());
184 $this->ctrl->redirect($this, $_GET["backcmd"]);
185 }
186
187
191 public function add_cell($val, $link = "")
192 {
193 if (!empty($link)) {
194 $this->tpl->setCurrentBlock("begin_link");
195 $this->tpl->setVariable("LINK_TARGET", $link);
196 $this->tpl->parseCurrentBlock();
197 $this->tpl->touchBlock("end_link");
198 }
199
200 $this->tpl->setCurrentBlock("text");
201 $this->tpl->setVariable("TEXT_CONTENT", $val);
202 $this->tpl->parseCurrentBlock();
203 $this->tpl->setCurrentBlock("table_cell");
204 $this->tpl->parseCurrentBlock();
205 }
206
207
213 public function showActions($a_actions)
214 {
215 foreach ($a_actions as $name => $lng) {
216 $d[$name] = array("name" => $name, "lng" => $lng);
217 }
218
219 $notoperations = array();
220 $operations = array();
221
222 $operations = $d;
223
224 if (count($operations) > 0) {
225 foreach ($operations as $val) {
226 $this->tpl->setCurrentBlock("operation_btn");
227 $this->tpl->setVariable("BTN_NAME", $val["name"]);
228 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
229 $this->tpl->parseCurrentBlock();
230 }
231
232 $this->tpl->setCurrentBlock("operation");
233 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
234 $this->tpl->parseCurrentBlock();
235 }
236 }
237
241 public function checkTree()
242 {
243 $this->content_object->checkTree();
244 }
245}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
const IL_FIRST_NODE
Definition: class.ilTree.php:5
Class ilLMObject.
add_cell($val, $link="")
output a cell in object list
putInTree()
put this object into content object tree
cancelDelete()
cancel deletion of page/structure objects
setActions($a_actions="")
build action array
showActions($a_actions)
show possible action (form buttons)
checkTree()
check the content object tree
__construct(&$a_content_obj)
constructor
create()
structure / page object creation form
confirmedDelete()
page and structure object deletion
getTargetFrame($a_cmd, $a_target_frame="")
get target frame for command (command is method name without "Object", e.g.
Class ilObjContentObjectGUI.
This class represents a property form user interface.
static clear($a_var)
Unset a value.
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...
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
global $DIC
Definition: goto.php:24
if($format !==null) $name
Definition: metadata.php:230
ui()
Definition: ui.php:5