ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 __construct(&$a_content_obj, &$a_tree)
31  {
32  parent::__construct($a_content_obj);
33  $this->tree = $a_tree;
34  }
35 
41  function setStructureObject(&$a_st_object)
42  {
43  $this->obj = $a_st_object;
44  }
45 
46 
50  function getType()
51  {
52  return "st";
53  }
54 
58  function executeCommand()
59  {
60 //echo "<br>:cmd:".$this->ctrl->getCmd().":cmdClass:".$this->ctrl->getCmdClass().":";
61  $next_class = $this->ctrl->getNextClass($this);
62  $cmd = $this->ctrl->getCmd();
63 
64  switch($next_class)
65  {
66  case 'ilobjectmetadatagui':
67 
68  $this->setTabs();
69 
70  include_once 'Services/Object/classes/class.ilObjectMetaDataGUI.php';
71  $md_gui = new ilObjectMetaDataGUI($this->content_object, $this->obj->getType(), $this->obj->getId());
72  $md_gui->addMDObserver($this->obj, 'MDUpdateListener', 'General');
73  $md_gui->addMDObserver($this->obj, 'MDUpdateListener', 'Educational'); // #9510
74  $this->ctrl->forwardCommand($md_gui);
75  break;
76 
77  case "ilconditionhandlergui":
78  global $ilTabs;
79  include_once './Services/AccessControl/classes/class.ilConditionHandlerGUI.php';
80 
81  $this->setTabs();
83  $this->ctrl->forwardCommand($this->condHI);
84  $ilTabs->setTabActive('preconditions');
85  break;
86 
87  default:
88  if($cmd == 'listConditions')
89  {
90  $this->setTabs();
92  $this->condHI->executeCommand();
93  }
94  elseif(($cmd == "create") && ($_POST["new_type"] == "pg"))
95  {
96  $this->setTabs();
97  $pg_gui = new ilLMPageObjectGUI($this->content_object);
98  $pg_gui->executeCommand();
99  }
100  else
101  {
102  $this->$cmd();
103  }
104  break;
105  }
106  }
107 
108 
112  function create()
113  {
114  if ($_GET["obj_id"] != "")
115  {
116  $this->setTabs();
117  }
118  parent::create();
119  }
120 
121  function edit()
122  {
123  $this->view();
124  }
125 
126  /*
127  * display pages of structure object
128  */
129  function view()
130  {
131  global $tree, $ilUser, $ilCtrl, $lng;
132 
133  $this->showHierarchy();
134  }
135 
136 
140  function showHierarchy()
141  {
142  global $lng, $ilCtrl;
143 
144  $this->setTabs();
145 
146  $ilCtrl->setParameter($this, "backcmd", "showHierarchy");
147 
148  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
149  $form_gui = new ilChapterHierarchyFormGUI($this->content_object->getType(), $_GET["transl"]);
150  $form_gui->setFormAction($ilCtrl->getFormAction($this));
151  $form_gui->setTitle($this->obj->getTitle());
152  $form_gui->setIcon(ilUtil::getImagePath("icon_st.svg"));
153  $form_gui->setTree($this->tree);
154  $form_gui->setCurrentTopNodeId($this->obj->getId());
155  $form_gui->addMultiCommand($lng->txt("delete"), "delete");
156  $form_gui->addMultiCommand($lng->txt("cut"), "cutItems");
157  $form_gui->addMultiCommand($lng->txt("copy"), "copyItems");
158  $form_gui->addMultiCommand($lng->txt("cont_de_activate"), "activatePages");
159  if ($this->content_object->getLayoutPerPage())
160  {
161  $form_gui->addMultiCommand($lng->txt("cont_set_layout"), "setPageLayout");
162  }
163  $form_gui->setDragIcon(ilUtil::getImagePath("icon_pg.svg"));
164  $form_gui->addCommand($lng->txt("cont_save_all_titles"), "saveAllTitles");
165  $form_gui->addHelpItem($lng->txt("cont_chapters_after_pages"));
166  $up_gui = "ilobjlearningmodulegui";
167  $ilCtrl->setParameterByClass($up_gui, "active_node", $this->obj->getId());
168  $ilCtrl->setParameterByClass($up_gui, "active_node", "");
169 
170  $ctpl = new ilTemplate("tpl.chap_and_pages.html", true, true, "Modules/LearningModule");
171  $ctpl->setVariable("HIERARCHY_FORM", $form_gui->getHTML());
172  $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
173 
174  include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
175  $ml_head = ilObjContentObjectGUI::getMultiLangHeader($this->content_object->getId(), $this);
176 
177  $this->tpl->setContent($ml_head.$ctpl->get());
178  }
179 
183  function cutItems($a_return = "view")
184  {
185  global $ilCtrl, $lng;
186 
187  $items = ilUtil::stripSlashesArray($_POST["id"]);
188  if (!is_array($items))
189  {
190  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
191  $ilCtrl->redirect($this, "showHierarchy");
192  }
193 
194  $todel = array(); // delete IDs < 0 (needed for non-js editing)
195  foreach($items as $k => $item)
196  {
197  if ($item < 0)
198  {
199  $todel[] = $k;
200  }
201  }
202  foreach($todel as $k)
203  {
204  unset($items[$k]);
205  }
206 
207  if (!ilLMObject::uniqueTypesCheck($items))
208  {
209  ilUtil::sendFailure($lng->txt("cont_choose_pages_or_chapters_only"), true);
210  $ilCtrl->redirect($this, "showHierarchy");
211  }
212 
213  ilLMObject::clipboardCut($this->content_object->getId(), $items);
215  //ilUtil::sendInfo($this->lng->txt("msg_cut_clipboard"), true);
216  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_cut"), true);
217 
218  $ilCtrl->redirect($this, $a_return);
219  }
220 
224  function copyItems($a_return = "view")
225  {
226  global $ilCtrl, $lng;
227 
228  $items = ilUtil::stripSlashesArray($_POST["id"]);
229  if (!is_array($items))
230  {
231  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
232  $ilCtrl->redirect($this, "showHierarchy");
233  }
234 
235  $todel = array(); // delete IDs < 0 (needed for non-js editing)
236  foreach($items as $k => $item)
237  {
238  if ($item < 0)
239  {
240  $todel[] = $k;
241  }
242  }
243  foreach($todel as $k)
244  {
245  unset($items[$k]);
246  }
247 
248  if (!ilLMObject::uniqueTypesCheck($items))
249  {
250  ilUtil::sendFailure($lng->txt("cont_choose_pages_or_chapters_only"), true);
251  $ilCtrl->redirect($this, "showHierarchy");
252  }
253 
254  ilLMObject::clipboardCopy($this->content_object->getId(), $items);
256 
257  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_copied"), true);
258  $ilCtrl->redirect($this, $a_return);
259  }
260 
264  function saveAllTitles()
265  {
266  global $ilCtrl;
267 
268  ilLMObject::saveTitles($this->content_object, ilUtil::stripSlashesArray($_POST["title"]), $_GET["transl"]);
269 
270  $ilCtrl->redirect($this, "showHierarchy");
271  }
272 
273  /*
274  * display subchapters of structure object
275  */
276  function subchap()
277  {
278  global $tree, $ilCtrl, $lng, $ilUser;
279 
280  $this->setTabs();
281 
282  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.structure_edit.html", "Modules/LearningModule");
283  $num = 0;
284 
285  $this->tpl->setCurrentBlock("form");
286  $this->ctrl->setParameter($this, "backcmd", "subchap");
287  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
288  $this->tpl->setVariable("HEADER_TEXT", $this->lng->txt("cont_subchapters"));
289  $this->tpl->setVariable("CHECKBOX_TOP", IL_FIRST_NODE);
290 
291  $cnt = 0;
292  $childs = $this->tree->getChilds($this->obj->getId());
293  foreach ($childs as $child)
294  {
295  if($child["type"] != "st")
296  {
297  continue;
298  }
299  $this->tpl->setCurrentBlock("table_row");
300  // color changing
301  $css_row = ilUtil::switchColor($cnt++,"tblrow1","tblrow2");
302 
303  // checkbox
304  $this->tpl->setVariable("CHECKBOX_ID", $child["obj_id"]);
305  $this->tpl->setVariable("CSS_ROW", $css_row);
306  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_st.svg"));
307 
308  // type
309  $this->ctrl->setParameterByClass("ilStructureObjectGUI", "obj_id", $child["obj_id"]);
310  $link = $this->ctrl->getLinkTargetByClass("ilStructureObjectGUI", "view");
311  $this->tpl->setVariable("LINK_TARGET", $link);
312 
313  // title
314  $this->tpl->setVariable("TEXT_CONTENT",
316  $this->content_object->isActiveNumbering()));
317 
318  $this->tpl->parseCurrentBlock();
319  }
320  if($cnt == 0)
321  {
322  $this->tpl->setCurrentBlock("notfound");
323  $this->tpl->setVariable("NUM_COLS", 3);
324  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
325  $this->tpl->parseCurrentBlock();
326  }
327  //else
328  //{
329  // SHOW VALID ACTIONS
330  $this->tpl->setVariable("NUM_COLS", 3);
331  $acts = array("delete" => "delete", "cutChapter" => "cut",
332  "copyChapter" => "copyChapter");
333  if ($ilUser->clipboardHasObjectsOfType("st"))
334  {
335  $acts["pasteChapter"] = "pasteChapter";
336  }
337  $this->showActions($acts);
338  //}
339 
340  // SHOW POSSIBLE SUB OBJECTS
341  $this->tpl->setVariable("NUM_COLS", 3);
342  //$this->showPossibleSubObjects("st");
343  $subobj = array("st");
344  $opts = ilUtil::formSelect(12,"new_type",$subobj);
345  //$this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
346  $this->tpl->setCurrentBlock("add_object");
347  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
348  //$this->tpl->setVariable("FORMACTION_OBJ_ADD", "adm_object.php?cmd=create&ref_id=".$_GET["ref_id"]);
349  $this->tpl->setVariable("BTN_NAME", "create");
350  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("insert"));
351  $this->tpl->parseCurrentBlock();
352 
353  //$this->tpl->setVariable("NUM_COLS", 2);
354  //$this->showPossibleSubObjects("st");
355 
356  $this->tpl->setCurrentBlock("form");
357  $this->tpl->parseCurrentBlock();
358 
359  $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
360 
361  }
362 
366  function add_cell($val, $link = "")
367  {
368  if(!empty($link))
369  {
370  $this->tpl->setCurrentBlock("begin_link");
371  $this->tpl->setVariable("LINK_TARGET", $link);
372  $this->tpl->parseCurrentBlock();
373  $this->tpl->touchBlock("end_link");
374  }
375 
376  $this->tpl->setCurrentBlock("text");
377  $this->tpl->setVariable("TEXT_CONTENT", $val);
378  $this->tpl->parseCurrentBlock();
379  $this->tpl->setCurrentBlock("table_cell");
380  $this->tpl->parseCurrentBlock();
381  }
382 
383 
387  function save()
388  {
389 
390  $this->obj = new ilStructureObject($this->content_object);
391 
392  $this->obj->setType("st");
393  $this->obj->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
394  $this->obj->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
395  $this->obj->setLMId($this->content_object->getId());
396  $this->obj->create();
397 
398  $this->putInTree();
399 
400  // check the tree
401  $this->checkTree();
402 
403  if (!empty($_GET["obj_id"]))
404  {
405  $this->ctrl->redirect($this, "subchap");
406  }
407 
408  }
409 
413  function putInTree()
414  {
415 //echo "st:putInTree";
416  // chapters should be behind pages in the tree
417  // so if target is first node, the target is substituted with
418  // the last child of type pg
419  if ($_GET["target"] == IL_FIRST_NODE)
420  {
421  $tree = new ilTree($this->content_object->getId());
422  $tree->setTableNames('lm_tree','lm_data');
423  $tree->setTreeTablePK("lm_id");
424 
425  // determine parent node id
426  $parent_id = (!empty($_GET["obj_id"]))
427  ? $_GET["obj_id"]
428  : $tree->getRootId();
429  // determine last child of type pg
430  $childs = $tree->getChildsByType($parent_id, "pg");
431  if (count($childs) != 0)
432  {
433  $_GET["target"] = $childs[count($childs) - 1]["obj_id"];
434  }
435  }
436  if (empty($_GET["target"]))
437  {
438  $_GET["target"] = IL_LAST_NODE;
439  }
440 
441  parent::putInTree();
442  }
443 
447  function cutPage()
448  {
449  $this->cutItems();
450  }
451 
455  function copyPage()
456  {
457  $this->copyItems();
458  }
459 
463  function pastePage()
464  {
465  global $ilUser;
466 
467  if (!$ilUser->clipboardHasObjectsOfType("pg"))
468  {
469  $this->ilias->raiseError($this->lng->txt("no_page_in_clipboard"),$this->ilias->error_obj->MESSAGE);
470  }
471 
472  return $this->insertPageClip();
473  }
474 
475 
479  function cutChapter()
480  {
481  $this->cutItems("subchap");
482  }
483 
487  function copyChapter()
488  {
489  $this->copyItems("subchap");
490  }
491 
495  function pasteChapter()
496  {
497  global $ilUser;
498 
499  return $this->insertChapterClip(false, "subchap");
500  }
501 
505  function activatePages()
506  {
507  global $lng;
508 
509  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
510  if (is_array($_POST["id"]))
511  {
512  $act_items = array();
513  // get all "top" ids, i.e. remove ids, that have a selected parent
514  foreach($_POST["id"] as $id)
515  {
516  $path = $this->tree->getPathId($id);
517  $take = true;
518  foreach($path as $path_id)
519  {
520  if ($path_id != $id && in_array($path_id, $_POST["id"]))
521  {
522  $take = false;
523  }
524  }
525  if ($take)
526  {
527  $act_items[] = $id;
528  }
529  }
530 
531 
532  foreach($act_items as $id)
533  {
534  $childs = $this->tree->getChilds($id);
535  foreach($childs as $child)
536  {
537  if (ilLMObject::_lookupType($child["child"]) == "pg")
538  {
539  $act = ilLMPage::_lookupActive($child["child"],
540  $this->content_object->getType());
541  ilLMPage::_writeActive($child["child"],
542  $this->content_object->getType(), !$act);
543  }
544  }
545  if (ilLMObject::_lookupType($id) == "pg")
546  {
547  $act = ilLMPage::_lookupActive($id,
548  $this->content_object->getType());
550  $this->content_object->getType(), !$act);
551  }
552  }
553  }
554  else
555  {
556  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
557  }
558 
559  $this->ctrl->redirect($this, "view");
560  }
561 
562  //
563  // Condition handling stuff
564  //
565 
567  {
568  include_once("./Services/AccessControl/classes/class.ilConditionHandlerGUI.php");
569 
570  $this->condHI = new ilConditionHandlerGUI($this);
571  $this->condHI->setBackButtons(array());
572  $this->condHI->setAutomaticValidation(false);
573  $this->condHI->setTargetType("st");
574  $this->condHI->setTargetRefId($this->content_object->getRefId());
575  $this->condHI->setTargetId($this->obj->getId());
576  $this->condHI->setTargetTitle($this->obj->getTitle());
577  }
578 
579 
583  function cancel()
584  {
585  if ($_GET["obj_id"] != 0)
586  {
587  if ($_GET["new_type"] == "pg")
588  {
589  $this->ctrl->redirect($this, "view");
590  }
591  else
592  {
593  $this->ctrl->redirect($this, "subchap");
594  }
595  }
596  }
597 
598 
602  function setTabs()
603  {
604  global $ilTabs, $ilUser, $lng;
605 
606  // subelements
607  $ilTabs->addTarget("cont_pages_and_subchapters",
608  $this->ctrl->getLinkTarget($this,'showHierarchy'),
609  array("view", "showHierarchy"), get_class($this));
610 
611  // preconditions
612  $ilTabs->addTarget("preconditions",
613  $this->ctrl->getLinkTarget($this, 'listConditions'),
614  "listConditions", get_class($this));
615 
616  // metadata
617  include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
618  $mdgui = new ilObjectMetaDataGUI($this->content_object, $this->obj->getType(), $this->obj->getId());
619  $mdtab = $mdgui->getTab();
620  if($mdtab)
621  {
622  $ilTabs->addTarget("meta_data",
623  $mdtab,
624  "", "ilmdeditorgui");
625  }
626 
627  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_st.svg"));
628  $this->tpl->setTitle(
629  $this->lng->txt($this->obj->getType()).": ".$this->obj->getTitle());
630 
631  // presentation view
632  $ilTabs->addNonTabbedLink("pres_mode", $lng->txt("cont_presentation_view"),
633  ILIAS_HTTP_PATH."/goto.php?target=st_".$this->obj->getId(), "_top");
634  }
635 
641  public static function _goto($a_target, $a_target_ref_id = "")
642  {
643  global $rbacsystem, $ilErr, $lng, $ilAccess;
644 
645  // determine learning object
646  $lm_id = ilLMObject::_lookupContObjID($a_target);
647 
648  // get all references
649  $ref_ids = ilObject::_getAllReferences($lm_id);
650 
651  // always try passed ref id first
652  if (in_array($a_target_ref_id, $ref_ids))
653  {
654  $ref_ids = array_merge(array($a_target_ref_id), $ref_ids);
655  }
656 
657  // check read permissions
658  foreach ($ref_ids as $ref_id)
659  {
660  // Permission check
661  if ($ilAccess->checkAccess("read", "", $ref_id))
662  {
663  // don't redirect anymore, just set parameters
664  // (goto.php includes "ilias.php")
665  $_GET["baseClass"] = "ilLMPresentationGUI";
666  $_GET["obj_id"] = $a_target;
667  $_GET["ref_id"] = $ref_id;
668  include_once("ilias.php");
669  exit;;
670  }
671  }
672 
673  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
674  {
675  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
676  ilObject::_lookupTitle($lm_id)), true);
677  include_once("./Services/Object/classes/class.ilObjectGUI.php");
679  }
680 
681  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
682  }
683 
687  function insertChapter($a_as_sub = false)
688  {
689  global $ilCtrl, $lng;
690 
691  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
692 
695 
696  if ($a_as_sub) // as subchapter
697  {
698  if (!ilChapterHierarchyFormGUI::getPostFirstChild()) // insert under parent
699  {
700  $parent_id = $node_id;
701  $target = "";
702  }
703  else // we shouldnt end up here
704  {
705  $ilCtrl->redirect($this, "showHierarchy");
706  return;
707  }
708  }
709  else // as chapter
710  {
711  if (!ilChapterHierarchyFormGUI::getPostFirstChild()) // insert after node id
712  {
713  $parent_id = $this->tree->getParentId($node_id);
714  $target = $node_id;
715  }
716  else // insert as first child
717  {
718  $parent_id = $node_id;
720  }
721  }
722  for ($i = 1; $i <= $num; $i++)
723  {
724  $chap = new ilStructureObject($this->content_object);
725  $chap->setType("st");
726  $chap->setTitle($lng->txt("cont_new_chap"));
727  $chap->setLMId($this->content_object->getId());
728  $chap->create();
729  ilLMObject::putInTree($chap, $parent_id, $target);
730  }
731 
732  $ilCtrl->redirect($this, "view");
733  }
734 
738  function insertSubchapter()
739  {
740  global $ilCtrl;
741 
742  $this->insertChapter(true);
743  }
744 
748  function insertChapterClip($a_as_sub = false, $a_return = "view")
749  {
750  global $ilUser, $ilCtrl, $ilLog;
751 
752  $ilLog->write("Insert Chapter From Clipboard");
753 
754  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
755 
758 
759  if ($a_as_sub) // as subchapter
760  {
761  if (!$first_child) // insert under parent
762  {
763  $parent_id = $node_id;
764  $target = "";
765  }
766  else // we shouldnt end up here
767  {
768  $ilCtrl->redirect($this, "showHierarchy");
769  return;
770  }
771  }
772  else // as chapter
773  {
774  if (!$first_child) // insert after node id
775  {
776  $parent_id = $this->tree->getParentId($node_id);
777  $target = $node_id;
778  }
779  else // insert as first child
780  {
781  $parent_id = $node_id;
783 
784  // do not move a chapter in front of a page
785  $childs = $this->tree->getChildsByType($parent_id, "pg");
786  if (count($childs) != 0)
787  {
788  $target = $childs[count($childs) - 1]["obj_id"];
789  }
790  }
791  }
792 
793  // copy and paste
794  $chapters = $ilUser->getClipboardObjects("st", true);
795  $copied_nodes = array();
796 
797  foreach ($chapters as $chap)
798  {
799  $ilLog->write("Call pasteTree, Target LM: ".$this->content_object->getId().", Chapter ID: ".$chap["id"]
800  .", Parent ID: ".$parent_id.", Target: ".$target);
801  $cid = ilLMObject::pasteTree($this->content_object, $chap["id"], $parent_id,
802  $target, $chap["insert_time"], $copied_nodes,
803  (ilEditClipboard::getAction() == "copy"));
804  $target = $cid;
805  }
806  ilLMObject::updateInternalLinks($copied_nodes);
807 
808  if (ilEditClipboard::getAction() == "cut")
809  {
810  $ilUser->clipboardDeleteObjectsOfType("pg");
811  $ilUser->clipboardDeleteObjectsOfType("st");
813  }
814 
815  $this->content_object->checkTree();
816  $ilCtrl->redirect($this, $a_return);
817  }
818 
823  {
824  $this->insertChapterClip(true);
825  }
826 
830  function insertPage()
831  {
832  global $ilCtrl, $lng;
833 
834  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
835 
838 
839  if (!ilChapterHierarchyFormGUI::getPostFirstChild()) // insert after node id
840  {
841  $parent_id = $this->tree->getParentId($node_id);
842  $target = $node_id;
843  }
844  else // insert as first child
845  {
846  $parent_id = $node_id;
848  }
849 
850  for ($i = 1; $i <= $num; $i++)
851  {
852  $page = new ilLMPageObject($this->content_object);
853  $page->setType("pg");
854  $page->setTitle($lng->txt("cont_new_page"));
855  $page->setLMId($this->content_object->getId());
856  $page->create();
857  ilLMObject::putInTree($page, $parent_id, $target);
858  }
859 
860  $ilCtrl->redirect($this, "showHierarchy");
861  }
862 
866  function insertPageClip()
867  {
868  global $ilCtrl, $ilUser;
869 
870  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
871 
874 
875  if (!$first_child) // insert after node id
876  {
877  $parent_id = $this->tree->getParentId($node_id);
878  $target = $node_id;
879  }
880  else // insert as first child
881  {
882  $parent_id = $node_id;
884  }
885 
886  // cut and paste
887  $pages = $ilUser->getClipboardObjects("pg");
888  $copied_nodes = array();
889  foreach ($pages as $pg)
890  {
891  $cid = ilLMObject::pasteTree($this->content_object, $pg["id"], $parent_id, $target,
892  $pg["insert_time"], $copied_nodes,
893  (ilEditClipboard::getAction() == "copy"));
894  $target = $cid;
895  }
896  ilLMObject::updateInternalLinks($copied_nodes);
897 
898  if (ilEditClipboard::getAction() == "cut")
899  {
900  $ilUser->clipboardDeleteObjectsOfType("pg");
901  $ilUser->clipboardDeleteObjectsOfType("st");
903  }
904 
905  $ilCtrl->redirect($this, "view");
906  }
907 
908 
912  function proceedDragDrop()
913  {
914  global $ilCtrl;
915 
916 //echo "-".$_POST["il_hform_source_id"]."-".$_POST["il_hform_target_id"]."-".$_POST["il_hform_fc"]."-";
917  $this->content_object->executeDragDrop($_POST["il_hform_source_id"], $_POST["il_hform_target_id"],
918  $_POST["il_hform_fc"], $_POST["il_hform_as_subitem"]);
919  $ilCtrl->redirect($this, "showHierarchy");
920  }
921 
925 
929  function setPageLayout()
930  {
931  global $tpl, $ilCtrl, $lng;
932 
933  if (!is_array($_POST["id"]))
934  {
935  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
936  $ilCtrl->redirect($this, "showHierarchy");
937  }
938 
939  $this->initSetPageLayoutForm();
940 
941  $tpl->setContent($this->form->getHTML());
942  }
943 
947  public function initSetPageLayoutForm()
948  {
949  global $lng, $ilCtrl;
950 
951  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
952  $this->form = new ilPropertyFormGUI();
953 
954  if (is_array($_POST["id"]))
955  {
956  foreach ($_POST["id"] as $id)
957  {
958  $hi = new ilHiddenInputGUI("id[]");
959  $hi->setValue($id);
960  $this->form->addItem($hi);
961  }
962  }
963  $layout = ilObjContentObjectGUI::getLayoutOption($lng->txt("cont_layout"), "layout",
964  $this->content_object->getLayout());
965 
966  $this->form->addItem($layout);
967 
968  $this->form->addCommandButton("savePageLayout", $lng->txt("save"));
969  $this->form->addCommandButton("showHierarchy", $lng->txt("cancel"));
970 
971  $this->form->setTitle($lng->txt("cont_set_layout"));
972  $this->form->setFormAction($ilCtrl->getFormAction($this));
973 
974  }
975 
979  function savePageLayout()
980  {
981  global $lng, $ilCtrl;
982 
983  foreach ($_POST["id"] as $id)
984  {
985  $id = ilUtil::stripSlashes($id);
987  ilUtil::stripSlashes($_POST["layout"]),
988  $this->content_object);
989  }
990  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
991  $ilCtrl->redirect($this, "showHierarchy");
992  }
993 
1001  {
1002  global $ilCtrl;
1003 
1004  $ilCtrl->setParameter($this, "transl", "");
1005  $ilCtrl->redirect($this, "showHierarchy");
1006  }
1007 
1014  function switchToLanguage()
1015  {
1016  global $ilCtrl;
1017 
1018  $ilCtrl->setParameter($this, "transl", $_GET["totransl"]);
1019  $ilCtrl->redirect($this, "showHierarchy");
1020  }
1021 
1022 }
1023 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
proceedDragDrop()
Perform drag and drop action.
global $ilErr
Definition: raiseError.php:16
static getPostMulti()
Get multi number of _POST input.
saveAllTitles()
Save all titles of chapters/pages.
Class ilObjectMetaDataGUI.
$path
Definition: aliased.php:25
class ilConditionHandlerGUI
editMasterLanguage()
Edit master language.
static updateInternalLinks($a_copied_nodes, $a_parent_type="lm")
Update internal links, after multiple pages have been copied.
static _lookupType($a_obj_id, $a_lm_id=0)
Lookup type.
initSetPageLayoutForm()
Init set page layout form.
static getMultiLangHeader($a_lm_id, $a_gui_class)
Get multi lang header.
static _getPresentationTitle($a_st_id, $a_mode=IL_CHAPTER_TITLE, $a_include_numbers=false, $a_time_scheduled_activation=false, $a_force_content=false, $a_lm_id=0, $a_lang="-")
get presentation title
This class represents a property form user interface.
$_GET["client_id"]
static uniqueTypesCheck($a_items)
Check for unique types (all pages or all chapters)
checkTree()
check the content object tree
static saveTitles($a_lm, $a_titles, $a_lang="-")
Save titles for lm objects.
$cmd
Definition: sahs_server.php:35
static getPostNodeId()
Get node ID of _POST input.
addMDObserver($a_class, $a_method, $a_section)
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
Class ilStructureObjectGUI.
insertPage()
Insert (multiple) pages at node.
static pasteTree($a_target_lm, $a_item_id, $a_parent_id, $a_target, $a_insert_time, &$a_copied_nodes, $a_as_copy=false, $a_source_lm=null)
Paste item (tree) from clipboard to current lm.
static getLayoutOption($a_txt, $a_var, $a_def_option="")
Save help mapping.
setFormAction($a_formaction)
Set FormAction.
static _lookupTitle($a_id)
lookup object title
insertSubchapter()
Insert (multiple) subchapters at node.
static writeLayout($a_obj_id, $a_layout, $a_lm=null)
Write layout setting.
insertChapterClip($a_as_sub=false, $a_return="view")
Insert Chapter from clipboard.
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
static _goto($a_target, $a_target_ref_id="")
redirect script
cancel()
cancel creation of new page or chapter
static _getAllReferences($a_id)
get all reference ids of object
Class ilLMObject.
setPageLayout()
Set layout for multipl pages.
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getPostFirstChild()
Should node be inserted as first child of target node (true) or as successor (false) ...
getType()
this function is called by condition handler gui interface
This class represents a hidden form property in a property form.
insertSubchapterClip()
Insert Chapter from clipboard.
Class ilLMPageObject.
static clipboardCopy($a_cont_obj_id, $a_ids)
Copy a set of chapters/pages into the clipboard.
static _lookupActive($a_id, $a_parent_type, $a_check_scheduled_activation=false, $a_lang="-")
lookup activation status
static _writeActive($a_id, $a_parent_type, $a_active, $a_reset_scheduled_activation=true, $a_lang="-")
write activation status
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static formSelect($selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
This class represents a hierarchical form.
const IL_FIRST_NODE
Definition: class.ilTree.php:5
special template class to simplify handling of ITX/PEAR
static putInTree($a_obj, $a_parent_id="", $a_target_node_id="")
put this object into content object tree
static clipboardCut($a_cont_obj_id, $a_ids)
Copy a set of chapters/pages into the clipboard.
cutItems($a_return="view")
Copy items to clipboard, then cut them from the current tree.
$ilUser
Definition: imgupload.php:18
redirection script todo: (a better solution should control the processing via a xml file) ...
setTableNames($a_table_tree, $a_table_obj_data, $a_table_obj_reference="")
set table names The primary key of the table containing your object_data must be &#39;obj_id&#39; You may use...
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
setStructureObject(&$a_st_object)
set structure object
copyItems($a_return="view")
Copy items to clipboard.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
insertPageClip()
Insert pages from clipboard.
Create styles array
The data for the language used.
switchToLanguage()
Switch to language.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
showActions($a_actions)
show possible action (form buttons)
copyChapter()
copy a single chapter (selection)
static stripSlashesArray($a_arr, $a_strip_html=true, $a_allow="")
Strip slashes from array.
Class ilLMPageObjectGUI.
savePageLayout()
Save page layout.
const IL_LAST_NODE
Definition: class.ilTree.php:4
add_cell($val, $link="")
output a cell in object list
Class ilStructreObject.
$ref_id
Definition: sahs_server.php:39
create()
create new page or chapter in chapter
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows) ...
__construct(&$a_content_obj, &$a_tree)
Constructor public.
activatePages()
activates or deactivates pages
const IL_CHAPTER_TITLE
insertChapter($a_as_sub=false)
Insert (multiple) chapters at node.
static setAction($a_action)
putInTree()
put chapter into tree
showHierarchy()
Show subhiearchy of pages and subchapters.
$_POST["username"]