ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilStructureObjectGUI.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 
6 require_once("./Modules/LearningModule/classes/class.ilLMObjectGUI.php");
7 require_once("./Modules/LearningModule/classes/class.ilLMObject.php");
8 
22 {
23  var $obj; // structure object
24  var $tree;
25 
30  function ilStructureObjectGUI(&$a_content_obj, &$a_tree)
31  {
32  global $ilias, $tpl, $lng;
33 
34  parent::ilLMObjectGUI($a_content_obj);
35  $this->tree =& $a_tree;
36  }
37 
43  function setStructureObject(&$a_st_object)
44  {
45  $this->obj =& $a_st_object;
46  }
47 
48 
52  function getType()
53  {
54  return "st";
55  }
56 
60  function &executeCommand()
61  {
62 //echo "<br>:cmd:".$this->ctrl->getCmd().":cmdClass:".$this->ctrl->getCmdClass().":";
63  $next_class = $this->ctrl->getNextClass($this);
64  $cmd = $this->ctrl->getCmd();
65 
66  switch($next_class)
67  {
68  case 'ilmdeditorgui':
69 
70  $this->setTabs();
71  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
72 
73  $md_gui =& new ilMDEditorGUI($this->content_object->getID(),
74  $this->obj->getId(), $this->obj->getType());
75  $md_gui->addObserver($this->obj,'MDUpdateListener','General');
76 
77  $this->ctrl->forwardCommand($md_gui);
78  break;
79 
80  case "ilconditionhandlerinterface":
81  global $ilTabs;
82  include_once './Services/AccessControl/classes/class.ilConditionHandlerInterface.php';
83 
84  $this->setTabs();
86  $this->ctrl->forwardCommand($this->condHI);
87  $ilTabs->setTabActive('preconditions');
88  break;
89 
90  default:
91  if($cmd == 'listConditions')
92  {
93  $this->setTabs();
95  $ret =& $this->condHI->executeCommand();
96  }
97  elseif(($cmd == "create") && ($_POST["new_type"] == "pg"))
98  {
99  $this->setTabs();
100  $pg_gui =& new ilLMPageObjectGUI($this->content_object);
101  $ret =& $pg_gui->executeCommand();
102  }
103  else
104  {
105  $ret =& $this->$cmd();
106  }
107  break;
108  }
109  }
110 
111 
115  function create()
116  {
117  if ($_GET["obj_id"] != "")
118  {
119  $this->setTabs();
120  }
121  parent::create();
122  }
123 
124  function edit()
125  {
126  $this->view();
127  }
128 
129  /*
130  * display pages of structure object
131  */
132  function view()
133  {
134  global $tree, $ilUser, $ilCtrl, $lng;
135 
136  $this->showHierarchy();
137  }
138 
139 
143  function showHierarchy()
144  {
145  global $lng, $ilCtrl;
146 
147  $this->setTabs();
148 
149  $ilCtrl->setParameter($this, "backcmd", "showHierarchy");
150 
151  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
152  $form_gui = new ilChapterHierarchyFormGUI($this->content_object->getType(), $_GET["transl"]);
153  $form_gui->setFormAction($ilCtrl->getFormAction($this));
154  $form_gui->setTitle($this->obj->getTitle());
155  $form_gui->setIcon(ilUtil::getImagePath("icon_st.png"));
156  $form_gui->setTree($this->tree);
157  $form_gui->setCurrentTopNodeId($this->obj->getId());
158  $form_gui->addMultiCommand($lng->txt("delete"), "delete");
159  $form_gui->addMultiCommand($lng->txt("cut"), "cutItems");
160  $form_gui->addMultiCommand($lng->txt("copy"), "copyItems");
161  $form_gui->addMultiCommand($lng->txt("cont_de_activate"), "activatePages");
162  if ($this->content_object->getLayoutPerPage())
163  {
164  $form_gui->addMultiCommand($lng->txt("cont_set_layout"), "setPageLayout");
165  }
166  $form_gui->setDragIcon(ilUtil::getImagePath("icon_pg_s.png"));
167  $form_gui->addCommand($lng->txt("cont_save_all_titles"), "saveAllTitles");
168  $form_gui->addHelpItem($lng->txt("cont_chapters_after_pages"));
169  $up_gui = ($this->content_object->getType() == "dbk")
170  ? "ilobjdlbookgui"
171  : "ilobjlearningmodulegui";
172  $ilCtrl->setParameterByClass($up_gui, "active_node", $this->obj->getId());
173  $form_gui->setExplorerUpdater("tree", "tree_div",
174  $ilCtrl->getLinkTargetByClass($up_gui, "explorer", "", true));
175  $ilCtrl->setParameterByClass($up_gui, "active_node", "");
176 
177  $ctpl = new ilTemplate("tpl.chap_and_pages.html", true, true, "Modules/LearningModule");
178  $ctpl->setVariable("HIERARCHY_FORM", $form_gui->getHTML());
179  $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
180 
181  include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
182  $ml_head = ilObjContentObjectGUI::getMultiLangHeader($this->content_object->getId(), $this);
183 
184  $this->tpl->setContent($ml_head.$ctpl->get());
185  }
186 
190  function cutItems($a_return = "view")
191  {
192  global $ilCtrl, $lng;
193 
194  $items = ilUtil::stripSlashesArray($_POST["id"]);
195  if (!is_array($items))
196  {
197  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
198  $ilCtrl->redirect($this, "showHierarchy");
199  }
200 
201  $todel = array(); // delete IDs < 0 (needed for non-js editing)
202  foreach($items as $k => $item)
203  {
204  if ($item < 0)
205  {
206  $todel[] = $k;
207  }
208  }
209  foreach($todel as $k)
210  {
211  unset($items[$k]);
212  }
213 
214  if (!ilLMObject::uniqueTypesCheck($items))
215  {
216  ilUtil::sendFailure($lng->txt("cont_choose_pages_or_chapters_only"), true);
217  $ilCtrl->redirect($this, "showHierarchy");
218  }
219 
220  ilLMObject::clipboardCut($this->content_object->getId(), $items);
222  //ilUtil::sendInfo($this->lng->txt("msg_cut_clipboard"), true);
223  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_cut"), true);
224 
225  $ilCtrl->redirect($this, $a_return);
226  }
227 
231  function copyItems($a_return = "view")
232  {
233  global $ilCtrl, $lng;
234 
235  $items = ilUtil::stripSlashesArray($_POST["id"]);
236  if (!is_array($items))
237  {
238  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
239  $ilCtrl->redirect($this, "showHierarchy");
240  }
241 
242  $todel = array(); // delete IDs < 0 (needed for non-js editing)
243  foreach($items as $k => $item)
244  {
245  if ($item < 0)
246  {
247  $todel[] = $k;
248  }
249  }
250  foreach($todel as $k)
251  {
252  unset($items[$k]);
253  }
254 
255  if (!ilLMObject::uniqueTypesCheck($items))
256  {
257  ilUtil::sendFailure($lng->txt("cont_choose_pages_or_chapters_only"), true);
258  $ilCtrl->redirect($this, "showHierarchy");
259  }
260 
261  ilLMObject::clipboardCopy($this->content_object->getId(), $items);
263 
264  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_copied"), true);
265  $ilCtrl->redirect($this, $a_return);
266  }
267 
271  function saveAllTitles()
272  {
273  global $ilCtrl;
274 
275  ilLMObject::saveTitles($this->content_object, ilUtil::stripSlashesArray($_POST["title"]), $_GET["transl"]);
276 
277  $ilCtrl->redirect($this, "showHierarchy");
278  }
279 
280  /*
281  * display subchapters of structure object
282  */
283  function subchap()
284  {
285  global $tree, $ilCtrl, $lng, $ilUser;
286 
287  $this->setTabs();
288 
289  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.structure_edit.html", "Modules/LearningModule");
290  $num = 0;
291 
292  $this->tpl->setCurrentBlock("form");
293  $this->ctrl->setParameter($this, "backcmd", "subchap");
294  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
295  $this->tpl->setVariable("HEADER_TEXT", $this->lng->txt("cont_subchapters"));
296  $this->tpl->setVariable("CHECKBOX_TOP", IL_FIRST_NODE);
297 
298  $cnt = 0;
299  $childs = $this->tree->getChilds($this->obj->getId());
300  foreach ($childs as $child)
301  {
302  if($child["type"] != "st")
303  {
304  continue;
305  }
306  $this->tpl->setCurrentBlock("table_row");
307  // color changing
308  $css_row = ilUtil::switchColor($cnt++,"tblrow1","tblrow2");
309 
310  // checkbox
311  $this->tpl->setVariable("CHECKBOX_ID", $child["obj_id"]);
312  $this->tpl->setVariable("CSS_ROW", $css_row);
313  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_st.png"));
314 
315  // type
316  $this->ctrl->setParameterByClass("ilStructureObjectGUI", "obj_id", $child["obj_id"]);
317  $link = $this->ctrl->getLinkTargetByClass("ilStructureObjectGUI", "view");
318  $this->tpl->setVariable("LINK_TARGET", $link);
319 
320  // title
321  $this->tpl->setVariable("TEXT_CONTENT",
323  $this->content_object->isActiveNumbering()));
324 
325  $this->tpl->parseCurrentBlock();
326  }
327  if($cnt == 0)
328  {
329  $this->tpl->setCurrentBlock("notfound");
330  $this->tpl->setVariable("NUM_COLS", 3);
331  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
332  $this->tpl->parseCurrentBlock();
333  }
334  //else
335  //{
336  // SHOW VALID ACTIONS
337  $this->tpl->setVariable("NUM_COLS", 3);
338  $acts = array("delete" => "delete", "cutChapter" => "cut",
339  "copyChapter" => "copyChapter");
340  if ($ilUser->clipboardHasObjectsOfType("st"))
341  {
342  $acts["pasteChapter"] = "pasteChapter";
343  }
344  $this->showActions($acts);
345  //}
346 
347  // SHOW POSSIBLE SUB OBJECTS
348  $this->tpl->setVariable("NUM_COLS", 3);
349  //$this->showPossibleSubObjects("st");
350  $subobj = array("st");
351  $opts = ilUtil::formSelect(12,"new_type",$subobj);
352  //$this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.png"));
353  $this->tpl->setCurrentBlock("add_object");
354  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
355  //$this->tpl->setVariable("FORMACTION_OBJ_ADD", "adm_object.php?cmd=create&ref_id=".$_GET["ref_id"]);
356  $this->tpl->setVariable("BTN_NAME", "create");
357  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("insert"));
358  $this->tpl->parseCurrentBlock();
359 
360  //$this->tpl->setVariable("NUM_COLS", 2);
361  //$this->showPossibleSubObjects("st");
362 
363  $this->tpl->setCurrentBlock("form");
364  $this->tpl->parseCurrentBlock();
365 
366  $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
367 
368  }
369 
373  function add_cell($val, $link = "")
374  {
375  if(!empty($link))
376  {
377  $this->tpl->setCurrentBlock("begin_link");
378  $this->tpl->setVariable("LINK_TARGET", $link);
379  $this->tpl->parseCurrentBlock();
380  $this->tpl->touchBlock("end_link");
381  }
382 
383  $this->tpl->setCurrentBlock("text");
384  $this->tpl->setVariable("TEXT_CONTENT", $val);
385  $this->tpl->parseCurrentBlock();
386  $this->tpl->setCurrentBlock("table_cell");
387  $this->tpl->parseCurrentBlock();
388  }
389 
390 
394  function save()
395  {
396 
397  $this->obj =& new ilStructureObject($this->content_object);
398 
399  $this->obj->setType("st");
400  $this->obj->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
401  $this->obj->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
402  $this->obj->setLMId($this->content_object->getId());
403  $this->obj->create();
404 
405  $this->putInTree();
406 
407  // check the tree
408  $this->checkTree();
409 
410  if (!empty($_GET["obj_id"]))
411  {
412  $this->ctrl->redirect($this, "subchap");
413  }
414 
415  }
416 
420  function putInTree()
421  {
422 //echo "st:putInTree";
423  // chapters should be behind pages in the tree
424  // so if target is first node, the target is substituted with
425  // the last child of type pg
426  if ($_GET["target"] == IL_FIRST_NODE)
427  {
428  $tree = new ilTree($this->content_object->getId());
429  $tree->setTableNames('lm_tree','lm_data');
430  $tree->setTreeTablePK("lm_id");
431 
432  // determine parent node id
433  $parent_id = (!empty($_GET["obj_id"]))
434  ? $_GET["obj_id"]
435  : $tree->getRootId();
436  // determine last child of type pg
437  $childs =& $tree->getChildsByType($parent_id, "pg");
438  if (count($childs) != 0)
439  {
440  $_GET["target"] = $childs[count($childs) - 1]["obj_id"];
441  }
442  }
443  if (empty($_GET["target"]))
444  {
445  $_GET["target"] = IL_LAST_NODE;
446  }
447 
449  }
450 
454  function cutPage()
455  {
456  $this->cutItems();
457  }
458 
462  function copyPage()
463  {
464  $this->copyItems();
465  }
466 
470  function pastePage()
471  {
472  global $ilUser;
473 
474  if (!$ilUser->clipboardHasObjectsOfType("pg"))
475  {
476  $this->ilias->raiseError($this->lng->txt("no_page_in_clipboard"),$this->ilias->error_obj->MESSAGE);
477  }
478 
479  return $this->insertPageClip();
480  }
481 
482 
486  function cutChapter()
487  {
488  $this->cutItems("subchap");
489  }
490 
494  function copyChapter()
495  {
496  $this->copyItems("subchap");
497  }
498 
502  function pasteChapter()
503  {
504  global $ilUser;
505 
506  return $this->insertChapterClip(false, "subchap");
507  }
508 
512  function activatePages()
513  {
514  global $lng;
515 
516  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
517  if (is_array($_POST["id"]))
518  {
519  $act_items = array();
520  // get all "top" ids, i.e. remove ids, that have a selected parent
521  foreach($_POST["id"] as $id)
522  {
523  $path = $this->tree->getPathId($id);
524  $take = true;
525  foreach($path as $path_id)
526  {
527  if ($path_id != $id && in_array($path_id, $_POST["id"]))
528  {
529  $take = false;
530  }
531  }
532  if ($take)
533  {
534  $act_items[] = $id;
535  }
536  }
537 
538 
539  foreach($act_items as $id)
540  {
541  $childs = $this->tree->getChilds($id);
542  foreach($childs as $child)
543  {
544  if (ilLMObject::_lookupType($child["child"]) == "pg")
545  {
546  $act = ilLMPage::_lookupActive($child["child"],
547  $this->content_object->getType());
548  ilLMPage::_writeActive($child["child"],
549  $this->content_object->getType(), !$act);
550  }
551  }
552  if (ilLMObject::_lookupType($id) == "pg")
553  {
554  $act = ilLMPage::_lookupActive($id,
555  $this->content_object->getType());
557  $this->content_object->getType(), !$act);
558  }
559  }
560  }
561  else
562  {
563  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
564  }
565 
566  $this->ctrl->redirect($this, "view");
567  }
568 
569  //
570  // Condition handling stuff
571  //
572 
574  {
575  include_once("./Services/AccessControl/classes/class.ilConditionHandlerInterface.php");
576 
577  $this->condHI =& new ilConditionHandlerInterface($this);
578  $this->condHI->setBackButtons(array());
579  $this->condHI->setAutomaticValidation(false);
580  $this->condHI->setTargetType("st");
581  $this->condHI->setTargetRefId($this->content_object->getRefId());
582  $this->condHI->setTargetId($this->obj->getId());
583  $this->condHI->setTargetTitle($this->obj->getTitle());
584  }
585 
586 
590  function cancel()
591  {
592  if ($_GET["obj_id"] != 0)
593  {
594  if ($_GET["new_type"] == "pg")
595  {
596  $this->ctrl->redirect($this, "view");
597  }
598  else
599  {
600  $this->ctrl->redirect($this, "subchap");
601  }
602  }
603  }
604 
605 
609  function setTabs()
610  {
611  global $ilTabs, $ilUser, $lng;
612 
613  // subelements
614  $ilTabs->addTarget("cont_pages_and_subchapters",
615  $this->ctrl->getLinkTarget($this,'showHierarchy'),
616  array("view", "showHierarchy"), get_class($this));
617 
618  // preconditions
619  $ilTabs->addTarget("preconditions",
620  $this->ctrl->getLinkTarget($this, 'listConditions'),
621  "listConditions", get_class($this));
622 
623  // metadata
624  $ilTabs->addTarget("meta_data",
625  $this->ctrl->getLinkTargetByClass("ilmdeditorgui",''),
626  "", "ilmdeditorgui");
627 
628  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_st_b.png"));
629  $this->tpl->setTitle(
630  $this->lng->txt($this->obj->getType()).": ".$this->obj->getTitle());
631 
632  // presentation view
633  $ilTabs->addNonTabbedLink("pres_mode", $lng->txt("cont_presentation_view"),
634  ILIAS_HTTP_PATH."/goto.php?target=st_".$this->obj->getId(), "_top");
635  }
636 
642  function _goto($a_target, $a_target_ref_id = "")
643  {
644  global $rbacsystem, $ilErr, $lng, $ilAccess;
645 
646  // determine learning object
647  $lm_id = ilLMObject::_lookupContObjID($a_target);
648 
649  // get all references
650  $ref_ids = ilObject::_getAllReferences($lm_id);
651 
652  // always try passed ref id first
653  if (in_array($a_target_ref_id, $ref_ids))
654  {
655  $ref_ids = array_merge(array($a_target_ref_id), $ref_ids);
656  }
657 
658  // check read permissions
659  foreach ($ref_ids as $ref_id)
660  {
661  // Permission check
662  if ($ilAccess->checkAccess("read", "", $ref_id))
663  {
664  // don't redirect anymore, just set parameters
665  // (goto.php includes "ilias.php")
666  $_GET["baseClass"] = "ilLMPresentationGUI";
667  $_GET["obj_id"] = $a_target;
668  $_GET["ref_id"] = $ref_id;
669  include_once("ilias.php");
670  exit;;
671  }
672  }
673 
674  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
675  {
676  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
677  ilObject::_lookupTitle($lm_id)), true);
678  include_once("./Services/Object/classes/class.ilObjectGUI.php");
680  }
681 
682  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
683  }
684 
688  function insertChapter($a_as_sub = false)
689  {
690  global $ilCtrl, $lng;
691 
692  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
693 
696 
697  if ($a_as_sub) // as subchapter
698  {
699  if (!ilChapterHierarchyFormGUI::getPostFirstChild()) // insert under parent
700  {
701  $parent_id = $node_id;
702  $target = "";
703  }
704  else // we shouldnt end up here
705  {
706  $ilCtrl->redirect($this, "showHierarchy");
707  return;
708  }
709  }
710  else // as chapter
711  {
712  if (!ilChapterHierarchyFormGUI::getPostFirstChild()) // insert after node id
713  {
714  $parent_id = $this->tree->getParentId($node_id);
715  $target = $node_id;
716  }
717  else // insert as first child
718  {
719  $parent_id = $node_id;
720  $target = IL_FIRST_NODE;
721  }
722  }
723  for ($i = 1; $i <= $num; $i++)
724  {
725  $chap = new ilStructureObject($this->content_object);
726  $chap->setType("st");
727  $chap->setTitle($lng->txt("cont_new_chap"));
728  $chap->setLMId($this->content_object->getId());
729  $chap->create();
730  ilLMObject::putInTree($chap, $parent_id, $target);
731  }
732 
733  $ilCtrl->redirect($this, "view");
734  }
735 
739  function insertSubchapter()
740  {
741  global $ilCtrl;
742 
743  $this->insertChapter(true);
744  }
745 
749  function insertChapterClip($a_as_sub = false, $a_return = "view")
750  {
751  global $ilUser, $ilCtrl, $ilLog;
752 
753  $ilLog->write("Insert Chapter From Clipboard");
754 
755  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
756 
759 
760  if ($a_as_sub) // as subchapter
761  {
762  if (!$first_child) // insert under parent
763  {
764  $parent_id = $node_id;
765  $target = "";
766  }
767  else // we shouldnt end up here
768  {
769  $ilCtrl->redirect($this, "showHierarchy");
770  return;
771  }
772  }
773  else // as chapter
774  {
775  if (!$first_child) // insert after node id
776  {
777  $parent_id = $this->tree->getParentId($node_id);
778  $target = $node_id;
779  }
780  else // insert as first child
781  {
782  $parent_id = $node_id;
783  $target = IL_FIRST_NODE;
784 
785  // do not move a chapter in front of a page
786  $childs = $this->tree->getChildsByType($parent_id, "pg");
787  if (count($childs) != 0)
788  {
789  $target = $childs[count($childs) - 1]["obj_id"];
790  }
791  }
792  }
793 
794  // copy and paste
795  $chapters = $ilUser->getClipboardObjects("st", true);
796  $copied_nodes = array();
797 
798  foreach ($chapters as $chap)
799  {
800  $ilLog->write("Call pasteTree, Target LM: ".$this->content_object->getId().", Chapter ID: ".$chap["id"]
801  .", Parent ID: ".$parent_id.", Target: ".$target);
802  $cid = ilLMObject::pasteTree($this->content_object, $chap["id"], $parent_id,
803  $target, $chap["insert_time"], $copied_nodes,
804  (ilEditClipboard::getAction() == "copy"));
805  $target = $cid;
806  }
807  ilLMObject::updateInternalLinks($copied_nodes);
808 
809  if (ilEditClipboard::getAction() == "cut")
810  {
811  $ilUser->clipboardDeleteObjectsOfType("pg");
812  $ilUser->clipboardDeleteObjectsOfType("st");
814  }
815 
816  $this->content_object->checkTree();
817  $ilCtrl->redirect($this, $a_return);
818  }
819 
824  {
825  $this->insertChapterClip(true);
826  }
827 
831  function insertPage()
832  {
833  global $ilCtrl, $lng;
834 
835  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
836 
839 
840  if (!ilChapterHierarchyFormGUI::getPostFirstChild()) // insert after node id
841  {
842  $parent_id = $this->tree->getParentId($node_id);
843  $target = $node_id;
844  }
845  else // insert as first child
846  {
847  $parent_id = $node_id;
848  $target = IL_FIRST_NODE;
849  }
850 
851  for ($i = 1; $i <= $num; $i++)
852  {
853  $page = new ilLMPageObject($this->content_object);
854  $page->setType("pg");
855  $page->setTitle($lng->txt("cont_new_page"));
856  $page->setLMId($this->content_object->getId());
857  $page->create();
858  ilLMObject::putInTree($page, $parent_id, $target);
859  }
860 
861  $ilCtrl->redirect($this, "showHierarchy");
862  }
863 
867  function insertPageClip()
868  {
869  global $ilCtrl, $ilUser;
870 
871  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
872 
875 
876  if (!$first_child) // insert after node id
877  {
878  $parent_id = $this->tree->getParentId($node_id);
879  $target = $node_id;
880  }
881  else // insert as first child
882  {
883  $parent_id = $node_id;
884  $target = IL_FIRST_NODE;
885  }
886 
887  // cut and paste
888  $pages = $ilUser->getClipboardObjects("pg");
889  $copied_nodes = array();
890  foreach ($pages as $pg)
891  {
892  $cid = ilLMObject::pasteTree($this->content_object, $pg["id"], $parent_id, $target,
893  $pg["insert_time"], $copied_nodes,
894  (ilEditClipboard::getAction() == "copy"));
895  $target = $cid;
896  }
897  ilLMObject::updateInternalLinks($copied_nodes);
898 
899  if (ilEditClipboard::getAction() == "cut")
900  {
901  $ilUser->clipboardDeleteObjectsOfType("pg");
902  $ilUser->clipboardDeleteObjectsOfType("st");
904  }
905 
906  $ilCtrl->redirect($this, "view");
907  }
908 
909 
913  function proceedDragDrop()
914  {
915  global $ilCtrl;
916 
917 //echo "-".$_POST["il_hform_source_id"]."-".$_POST["il_hform_target_id"]."-".$_POST["il_hform_fc"]."-";
918  $this->content_object->executeDragDrop($_POST["il_hform_source_id"], $_POST["il_hform_target_id"],
919  $_POST["il_hform_fc"], $_POST["il_hform_as_subitem"]);
920  $ilCtrl->redirect($this, "showHierarchy");
921  }
922 
926 
930  function setPageLayout()
931  {
932  global $tpl, $ilCtrl, $lng;
933 
934  if (!is_array($_POST["id"]))
935  {
936  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
937  $ilCtrl->redirect($this, "showHierarchy");
938  }
939 
940  $this->initSetPageLayoutForm();
941 
942  $tpl->setContent($this->form->getHTML());
943  }
944 
948  public function initSetPageLayoutForm()
949  {
950  global $lng, $ilCtrl;
951 
952  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
953  $this->form = new ilPropertyFormGUI();
954 
955  if (is_array($_POST["id"]))
956  {
957  foreach ($_POST["id"] as $id)
958  {
959  $hi = new ilHiddenInputGUI("id[]");
960  $hi->setValue($id);
961  $this->form->addItem($hi);
962  }
963  }
964  $layout = ilObjContentObjectGUI::getLayoutOption($lng->txt("cont_layout"), "layout",
965  $this->content_object->getLayout());
966 
967  $this->form->addItem($layout);
968 
969  $this->form->addCommandButton("savePageLayout", $lng->txt("save"));
970  $this->form->addCommandButton("showHierarchy", $lng->txt("cancel"));
971 
972  $this->form->setTitle($lng->txt("cont_set_layout"));
973  $this->form->setFormAction($ilCtrl->getFormAction($this));
974 
975  }
976 
980  function savePageLayout()
981  {
982  global $lng, $ilCtrl;
983 
984  foreach ($_POST["id"] as $id)
985  {
986  $id = ilUtil::stripSlashes($id);
988  ilUtil::stripSlashes($_POST["layout"]),
989  $this->content_object);
990  }
991  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
992  $ilCtrl->redirect($this, "showHierarchy");
993  }
994 
1002  {
1003  global $ilCtrl;
1004 
1005  $ilCtrl->setParameter($this, "transl", "");
1006  $ilCtrl->redirect($this, "showHierarchy");
1007  }
1008 
1015  function switchToLanguage()
1016  {
1017  global $ilCtrl;
1018 
1019  $ilCtrl->setParameter($this, "transl", $_GET["totransl"]);
1020  $ilCtrl->redirect($this, "showHierarchy");
1021  }
1022 
1023 }
1024 ?>