ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  var $ilias;
19  var $tpl;
20  var $lng;
21  var $obj;
22  var $ctrl;
24  var $actions;
25 
26 
32  function ilLMObjectGUI(&$a_content_obj)
33  {
34  global $ilias, $tpl, $lng, $ilCtrl;
35 
36  $this->ilias =& $ilias;
37  $this->tpl =& $tpl;
38  $this->lng =& $lng;
39  $this->ctrl =& $ilCtrl;
40  $this->content_object =& $a_content_obj;
41  }
42 
43 
51  function setActions($a_actions = "")
52  {
53  if (is_array($a_actions))
54  {
55  foreach ($a_actions as $name => $lng)
56  {
57  $this->actions[$name] = array("name" => $name, "lng" => $lng);
58  }
59  }
60  else
61  {
62  $this->actions = "";
63  }
64  }
65 
66 
74  function getTargetFrame($a_cmd, $a_target_frame = "")
75  {
76  if ($this->target_frame[$a_cmd] != "")
77  {
78  return $this->target_frame[$a_cmd];
79  }
80  elseif (!empty($a_target_frame))
81  {
82  return "target=\"".$a_target_frame."\"";
83  }
84  else
85  {
86  return;
87  }
88  }
89 
93  function create()
94  {
95  $new_type = $_REQUEST["new_type"];
96 
97  $this->ctrl->setParameter($this, "new_type", $new_type);
98  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
99  $form = new ilPropertyFormGUI();
100  $form->setFormAction($this->ctrl->getFormAction($this, "save"));
101  $form->setTitle( $this->lng->txt($new_type."_new"));
102 
103  $title = new ilTextInputGUI($this->lng->txt("title"), "Fobject[title]");
104  $title->setRequired(true);
105  $form->addItem($title);
106 
107  $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "Fobject[desc]");
108  $form->addItem($desc);
109 
110  $form->addCommandButton("save", $this->lng->txt($new_type."_add"));
111  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
112 
113  $this->tpl->setContent($form->getHTML());
114  }
115 
116 
120  function putInTree()
121  {
122  $tree = new ilTree($this->content_object->getId());
123  $tree->setTableNames('lm_tree', 'lm_data');
124  $tree->setTreeTablePK("lm_id");
125 
126  $parent_id = (!empty($_GET["obj_id"]))
127  ? $_GET["obj_id"]
128  : $tree->getRootId();
129 
130  if (!empty($_GET["target"]))
131  {
132  $target = $_GET["target"];
133  }
134  else
135  {
136  // determine last child of current type
137  $childs =& $tree->getChildsByType($parent_id, $this->obj->getType());
138  if (count($childs) == 0)
139  {
140  $target = IL_FIRST_NODE;
141  }
142  else
143  {
144  $target = $childs[count($childs) - 1]["obj_id"];
145  }
146  }
147  if (!$tree->isInTree($this->obj->getId()))
148  {
149  $tree->insertNode($this->obj->getId(), $parent_id, $target);
150  }
151  }
152 
153 
157  function delete()
158  {
159  $this->setTabs();
160 
161  $cont_obj_gui =& new ilObjContentObjectGUI("",$this->content_object->getRefId(),
162  true, false);
163  $cont_obj_gui->delete($this->obj->getId());
164  }
165 
166 
170  function cancelDelete()
171  {
172  ilSession::clear("saved_post");
173  $this->ctrl->redirect($this, $_GET["backcmd"]);
174  }
175 
176 
180  function confirmedDelete()
181  {
182  $cont_obj_gui =& new ilObjContentObjectGUI("",$this->content_object->getRefId(),
183  true, false);
184  $cont_obj_gui->confirmedDelete($this->obj->getId());
185  $this->ctrl->redirect($this, $_GET["backcmd"]);
186  }
187 
188 
192  function add_cell($val, $link = "")
193  {
194  if(!empty($link))
195  {
196  $this->tpl->setCurrentBlock("begin_link");
197  $this->tpl->setVariable("LINK_TARGET", $link);
198  $this->tpl->parseCurrentBlock();
199  $this->tpl->touchBlock("end_link");
200  }
201 
202  $this->tpl->setCurrentBlock("text");
203  $this->tpl->setVariable("TEXT_CONTENT", $val);
204  $this->tpl->parseCurrentBlock();
205  $this->tpl->setCurrentBlock("table_cell");
206  $this->tpl->parseCurrentBlock();
207  }
208 
209 
215  function showActions($a_actions)
216  {
217  foreach ($a_actions as $name => $lng)
218  {
219  $d[$name] = array("name" => $name, "lng" => $lng);
220  }
221 
222  $notoperations = array();
223  $operations = array();
224 
225  $operations = $d;
226 
227  if (count($operations) > 0)
228  {
229  foreach ($operations as $val)
230  {
231  $this->tpl->setCurrentBlock("operation_btn");
232  $this->tpl->setVariable("BTN_NAME", $val["name"]);
233  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
234  $this->tpl->parseCurrentBlock();
235  }
236 
237  $this->tpl->setCurrentBlock("operation");
238  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.png"));
239  $this->tpl->parseCurrentBlock();
240  }
241  }
242 
246  function checkTree()
247  {
248  $this->content_object->checkTree();
249  }
250 }
251 ?>