ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
25 
31  public function __construct(&$a_content_obj)
32  {
33  global $DIC;
34 
35  $tpl = $DIC["tpl"];
36  $lng = $DIC->language();
37  $ilCtrl = $DIC->ctrl();
38 
39  $this->tpl = $tpl;
40  $this->lng = $lng;
41  $this->ctrl = $ilCtrl;
42  $this->content_object = $a_content_obj;
43  }
44 
45 
53  public function setActions($a_actions = "")
54  {
55  if (is_array($a_actions)) {
56  foreach ($a_actions as $name => $lng) {
57  $this->actions[$name] = array("name" => $name, "lng" => $lng);
58  }
59  } else {
60  $this->actions = "";
61  }
62  }
63 
64 
72  public function getTargetFrame($a_cmd, $a_target_frame = "")
73  {
74  if ($this->target_frame[$a_cmd] != "") {
75  return $this->target_frame[$a_cmd];
76  } elseif (!empty($a_target_frame)) {
77  return "target=\"" . $a_target_frame . "\"";
78  } else {
79  return;
80  }
81  }
82 
86  public function create()
87  {
88  $new_type = $_REQUEST["new_type"];
89 
90  $this->ctrl->setParameter($this, "new_type", $new_type);
91  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
92  $form = new ilPropertyFormGUI();
93  $form->setFormAction($this->ctrl->getFormAction($this, "save"));
94  $form->setTitle($this->lng->txt($new_type . "_new"));
95 
96  $title = new ilTextInputGUI($this->lng->txt("title"), "Fobject[title]");
97  //$title->setRequired(true);
98  $form->addItem($title);
99 
100  $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "Fobject[desc]");
101  $form->addItem($desc);
102 
103  $form->addCommandButton("save", $this->lng->txt($new_type . "_add"));
104  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
105 
106  $this->tpl->setContent($form->getHTML());
107  }
108 
109 
113  public function putInTree()
114  {
115  $tree = new ilTree($this->content_object->getId());
116  $tree->setTableNames('lm_tree', 'lm_data');
117  $tree->setTreeTablePK("lm_id");
118 
119  $parent_id = (!empty($_GET["obj_id"]))
120  ? $_GET["obj_id"]
121  : $tree->getRootId();
122 
123  if (!empty($_GET["target"])) {
124  $target = $_GET["target"];
125  } else {
126  // determine last child of current type
127  $childs = $tree->getChildsByType($parent_id, $this->obj->getType());
128  if (count($childs) == 0) {
130  } else {
131  $target = $childs[count($childs) - 1]["obj_id"];
132  }
133  }
134  if (!$tree->isInTree($this->obj->getId())) {
135  $tree->insertNode($this->obj->getId(), $parent_id, $target);
136  }
137  }
138 
139 
143  public function delete()
144  {
145  $this->setTabs();
146 
147  $cont_obj_gui = new ilObjContentObjectGUI(
148  "",
149  $this->content_object->getRefId(),
150  true,
151  false
152  );
153  $cont_obj_gui->delete($this->obj->getId());
154  }
155 
156 
160  public function cancelDelete()
161  {
162  ilSession::clear("saved_post");
163  $this->ctrl->redirect($this, $_GET["backcmd"]);
164  }
165 
166 
170  public function confirmedDelete()
171  {
172  $cont_obj_gui = new ilObjContentObjectGUI(
173  "",
174  $this->content_object->getRefId(),
175  true,
176  false
177  );
178  $cont_obj_gui->confirmedDelete($this->obj->getId());
179  $this->ctrl->redirect($this, $_GET["backcmd"]);
180  }
181 
182 
186  public function add_cell($val, $link = "")
187  {
188  if (!empty($link)) {
189  $this->tpl->setCurrentBlock("begin_link");
190  $this->tpl->setVariable("LINK_TARGET", $link);
191  $this->tpl->parseCurrentBlock();
192  $this->tpl->touchBlock("end_link");
193  }
194 
195  $this->tpl->setCurrentBlock("text");
196  $this->tpl->setVariable("TEXT_CONTENT", $val);
197  $this->tpl->parseCurrentBlock();
198  $this->tpl->setCurrentBlock("table_cell");
199  $this->tpl->parseCurrentBlock();
200  }
201 
202 
208  public function showActions($a_actions)
209  {
210  foreach ($a_actions as $name => $lng) {
211  $d[$name] = array("name" => $name, "lng" => $lng);
212  }
213 
214  $notoperations = array();
215  $operations = array();
216 
217  $operations = $d;
218 
219  if (count($operations) > 0) {
220  foreach ($operations as $val) {
221  $this->tpl->setCurrentBlock("operation_btn");
222  $this->tpl->setVariable("BTN_NAME", $val["name"]);
223  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
224  $this->tpl->parseCurrentBlock();
225  }
226 
227  $this->tpl->setCurrentBlock("operation");
228  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
229  $this->tpl->parseCurrentBlock();
230  }
231  }
232 
236  public function checkTree()
237  {
238  $this->content_object->checkTree();
239  }
240 }
confirmedDelete()
page and structure object deletion
setActions($a_actions="")
build action array
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
checkTree()
check the content object tree
create()
structure / page object creation form
Class ilLMObject.
global $ilCtrl
Definition: ilias.php:18
__construct(&$a_content_obj)
constructor
if(isset($_POST['submit'])) $form
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
const IL_FIRST_NODE
Definition: class.ilTree.php:5
This class represents a text property in a property form.
cancelDelete()
cancel deletion of page/structure objects
static clear($a_var)
Unset a value.
putInTree()
put this object into content object tree
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
showActions($a_actions)
show possible action (form buttons)
confirmedDelete($a_parent_subobj_id=0)
delete page object or structure objects
add_cell($val, $link="")
output a cell in object list
This class represents a text area property in a property form.
Class ilObjContentObjectGUI.
delete($a_parent_subobj_id=0)
confirm deletion screen for page object and structure object deletion
getTargetFrame($a_cmd, $a_target_frame="")
get target frame for command (command is method name without "Object", e.g.
$target
Definition: test.php:19
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296