ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 "ilconditionhandlergui":
81  global $ilTabs;
82  include_once './Services/AccessControl/classes/class.ilConditionHandlerGUI.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.svg"));
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.svg"));
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  $ilCtrl->setParameterByClass($up_gui, "active_node", "");
174 
175  $ctpl = new ilTemplate("tpl.chap_and_pages.html", true, true, "Modules/LearningModule");
176  $ctpl->setVariable("HIERARCHY_FORM", $form_gui->getHTML());
177  $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
178 
179  include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
180  $ml_head = ilObjContentObjectGUI::getMultiLangHeader($this->content_object->getId(), $this);
181 
182  $this->tpl->setContent($ml_head.$ctpl->get());
183  }
184 
188  function cutItems($a_return = "view")
189  {
190  global $ilCtrl, $lng;
191 
192  $items = ilUtil::stripSlashesArray($_POST["id"]);
193  if (!is_array($items))
194  {
195  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
196  $ilCtrl->redirect($this, "showHierarchy");
197  }
198 
199  $todel = array(); // delete IDs < 0 (needed for non-js editing)
200  foreach($items as $k => $item)
201  {
202  if ($item < 0)
203  {
204  $todel[] = $k;
205  }
206  }
207  foreach($todel as $k)
208  {
209  unset($items[$k]);
210  }
211 
212  if (!ilLMObject::uniqueTypesCheck($items))
213  {
214  ilUtil::sendFailure($lng->txt("cont_choose_pages_or_chapters_only"), true);
215  $ilCtrl->redirect($this, "showHierarchy");
216  }
217 
218  ilLMObject::clipboardCut($this->content_object->getId(), $items);
220  //ilUtil::sendInfo($this->lng->txt("msg_cut_clipboard"), true);
221  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_cut"), true);
222 
223  $ilCtrl->redirect($this, $a_return);
224  }
225 
229  function copyItems($a_return = "view")
230  {
231  global $ilCtrl, $lng;
232 
233  $items = ilUtil::stripSlashesArray($_POST["id"]);
234  if (!is_array($items))
235  {
236  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
237  $ilCtrl->redirect($this, "showHierarchy");
238  }
239 
240  $todel = array(); // delete IDs < 0 (needed for non-js editing)
241  foreach($items as $k => $item)
242  {
243  if ($item < 0)
244  {
245  $todel[] = $k;
246  }
247  }
248  foreach($todel as $k)
249  {
250  unset($items[$k]);
251  }
252 
253  if (!ilLMObject::uniqueTypesCheck($items))
254  {
255  ilUtil::sendFailure($lng->txt("cont_choose_pages_or_chapters_only"), true);
256  $ilCtrl->redirect($this, "showHierarchy");
257  }
258 
259  ilLMObject::clipboardCopy($this->content_object->getId(), $items);
261 
262  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_copied"), true);
263  $ilCtrl->redirect($this, $a_return);
264  }
265 
269  function saveAllTitles()
270  {
271  global $ilCtrl;
272 
273  ilLMObject::saveTitles($this->content_object, ilUtil::stripSlashesArray($_POST["title"]), $_GET["transl"]);
274 
275  $ilCtrl->redirect($this, "showHierarchy");
276  }
277 
278  /*
279  * display subchapters of structure object
280  */
281  function subchap()
282  {
283  global $tree, $ilCtrl, $lng, $ilUser;
284 
285  $this->setTabs();
286 
287  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.structure_edit.html", "Modules/LearningModule");
288  $num = 0;
289 
290  $this->tpl->setCurrentBlock("form");
291  $this->ctrl->setParameter($this, "backcmd", "subchap");
292  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
293  $this->tpl->setVariable("HEADER_TEXT", $this->lng->txt("cont_subchapters"));
294  $this->tpl->setVariable("CHECKBOX_TOP", IL_FIRST_NODE);
295 
296  $cnt = 0;
297  $childs = $this->tree->getChilds($this->obj->getId());
298  foreach ($childs as $child)
299  {
300  if($child["type"] != "st")
301  {
302  continue;
303  }
304  $this->tpl->setCurrentBlock("table_row");
305  // color changing
306  $css_row = ilUtil::switchColor($cnt++,"tblrow1","tblrow2");
307 
308  // checkbox
309  $this->tpl->setVariable("CHECKBOX_ID", $child["obj_id"]);
310  $this->tpl->setVariable("CSS_ROW", $css_row);
311  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_st.svg"));
312 
313  // type
314  $this->ctrl->setParameterByClass("ilStructureObjectGUI", "obj_id", $child["obj_id"]);
315  $link = $this->ctrl->getLinkTargetByClass("ilStructureObjectGUI", "view");
316  $this->tpl->setVariable("LINK_TARGET", $link);
317 
318  // title
319  $this->tpl->setVariable("TEXT_CONTENT",
321  $this->content_object->isActiveNumbering()));
322 
323  $this->tpl->parseCurrentBlock();
324  }
325  if($cnt == 0)
326  {
327  $this->tpl->setCurrentBlock("notfound");
328  $this->tpl->setVariable("NUM_COLS", 3);
329  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
330  $this->tpl->parseCurrentBlock();
331  }
332  //else
333  //{
334  // SHOW VALID ACTIONS
335  $this->tpl->setVariable("NUM_COLS", 3);
336  $acts = array("delete" => "delete", "cutChapter" => "cut",
337  "copyChapter" => "copyChapter");
338  if ($ilUser->clipboardHasObjectsOfType("st"))
339  {
340  $acts["pasteChapter"] = "pasteChapter";
341  }
342  $this->showActions($acts);
343  //}
344 
345  // SHOW POSSIBLE SUB OBJECTS
346  $this->tpl->setVariable("NUM_COLS", 3);
347  //$this->showPossibleSubObjects("st");
348  $subobj = array("st");
349  $opts = ilUtil::formSelect(12,"new_type",$subobj);
350  //$this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
351  $this->tpl->setCurrentBlock("add_object");
352  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
353  //$this->tpl->setVariable("FORMACTION_OBJ_ADD", "adm_object.php?cmd=create&ref_id=".$_GET["ref_id"]);
354  $this->tpl->setVariable("BTN_NAME", "create");
355  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("insert"));
356  $this->tpl->parseCurrentBlock();
357 
358  //$this->tpl->setVariable("NUM_COLS", 2);
359  //$this->showPossibleSubObjects("st");
360 
361  $this->tpl->setCurrentBlock("form");
362  $this->tpl->parseCurrentBlock();
363 
364  $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
365 
366  }
367 
371  function add_cell($val, $link = "")
372  {
373  if(!empty($link))
374  {
375  $this->tpl->setCurrentBlock("begin_link");
376  $this->tpl->setVariable("LINK_TARGET", $link);
377  $this->tpl->parseCurrentBlock();
378  $this->tpl->touchBlock("end_link");
379  }
380 
381  $this->tpl->setCurrentBlock("text");
382  $this->tpl->setVariable("TEXT_CONTENT", $val);
383  $this->tpl->parseCurrentBlock();
384  $this->tpl->setCurrentBlock("table_cell");
385  $this->tpl->parseCurrentBlock();
386  }
387 
388 
392  function save()
393  {
394 
395  $this->obj =& new ilStructureObject($this->content_object);
396 
397  $this->obj->setType("st");
398  $this->obj->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
399  $this->obj->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
400  $this->obj->setLMId($this->content_object->getId());
401  $this->obj->create();
402 
403  $this->putInTree();
404 
405  // check the tree
406  $this->checkTree();
407 
408  if (!empty($_GET["obj_id"]))
409  {
410  $this->ctrl->redirect($this, "subchap");
411  }
412 
413  }
414 
418  function putInTree()
419  {
420 //echo "st:putInTree";
421  // chapters should be behind pages in the tree
422  // so if target is first node, the target is substituted with
423  // the last child of type pg
424  if ($_GET["target"] == IL_FIRST_NODE)
425  {
426  $tree = new ilTree($this->content_object->getId());
427  $tree->setTableNames('lm_tree','lm_data');
428  $tree->setTreeTablePK("lm_id");
429 
430  // determine parent node id
431  $parent_id = (!empty($_GET["obj_id"]))
432  ? $_GET["obj_id"]
433  : $tree->getRootId();
434  // determine last child of type pg
435  $childs =& $tree->getChildsByType($parent_id, "pg");
436  if (count($childs) != 0)
437  {
438  $_GET["target"] = $childs[count($childs) - 1]["obj_id"];
439  }
440  }
441  if (empty($_GET["target"]))
442  {
443  $_GET["target"] = IL_LAST_NODE;
444  }
445 
446  parent::putInTree();
447  }
448 
452  function cutPage()
453  {
454  $this->cutItems();
455  }
456 
460  function copyPage()
461  {
462  $this->copyItems();
463  }
464 
468  function pastePage()
469  {
470  global $ilUser;
471 
472  if (!$ilUser->clipboardHasObjectsOfType("pg"))
473  {
474  $this->ilias->raiseError($this->lng->txt("no_page_in_clipboard"),$this->ilias->error_obj->MESSAGE);
475  }
476 
477  return $this->insertPageClip();
478  }
479 
480 
484  function cutChapter()
485  {
486  $this->cutItems("subchap");
487  }
488 
492  function copyChapter()
493  {
494  $this->copyItems("subchap");
495  }
496 
500  function pasteChapter()
501  {
502  global $ilUser;
503 
504  return $this->insertChapterClip(false, "subchap");
505  }
506 
510  function activatePages()
511  {
512  global $lng;
513 
514  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
515  if (is_array($_POST["id"]))
516  {
517  $act_items = array();
518  // get all "top" ids, i.e. remove ids, that have a selected parent
519  foreach($_POST["id"] as $id)
520  {
521  $path = $this->tree->getPathId($id);
522  $take = true;
523  foreach($path as $path_id)
524  {
525  if ($path_id != $id && in_array($path_id, $_POST["id"]))
526  {
527  $take = false;
528  }
529  }
530  if ($take)
531  {
532  $act_items[] = $id;
533  }
534  }
535 
536 
537  foreach($act_items as $id)
538  {
539  $childs = $this->tree->getChilds($id);
540  foreach($childs as $child)
541  {
542  if (ilLMObject::_lookupType($child["child"]) == "pg")
543  {
544  $act = ilLMPage::_lookupActive($child["child"],
545  $this->content_object->getType());
546  ilLMPage::_writeActive($child["child"],
547  $this->content_object->getType(), !$act);
548  }
549  }
550  if (ilLMObject::_lookupType($id) == "pg")
551  {
552  $act = ilLMPage::_lookupActive($id,
553  $this->content_object->getType());
555  $this->content_object->getType(), !$act);
556  }
557  }
558  }
559  else
560  {
561  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
562  }
563 
564  $this->ctrl->redirect($this, "view");
565  }
566 
567  //
568  // Condition handling stuff
569  //
570 
572  {
573  include_once("./Services/AccessControl/classes/class.ilConditionHandlerGUI.php");
574 
575  $this->condHI =& new ilConditionHandlerGUI($this);
576  $this->condHI->setBackButtons(array());
577  $this->condHI->setAutomaticValidation(false);
578  $this->condHI->setTargetType("st");
579  $this->condHI->setTargetRefId($this->content_object->getRefId());
580  $this->condHI->setTargetId($this->obj->getId());
581  $this->condHI->setTargetTitle($this->obj->getTitle());
582  }
583 
584 
588  function cancel()
589  {
590  if ($_GET["obj_id"] != 0)
591  {
592  if ($_GET["new_type"] == "pg")
593  {
594  $this->ctrl->redirect($this, "view");
595  }
596  else
597  {
598  $this->ctrl->redirect($this, "subchap");
599  }
600  }
601  }
602 
603 
607  function setTabs()
608  {
609  global $ilTabs, $ilUser, $lng;
610 
611  // subelements
612  $ilTabs->addTarget("cont_pages_and_subchapters",
613  $this->ctrl->getLinkTarget($this,'showHierarchy'),
614  array("view", "showHierarchy"), get_class($this));
615 
616  // preconditions
617  $ilTabs->addTarget("preconditions",
618  $this->ctrl->getLinkTarget($this, 'listConditions'),
619  "listConditions", get_class($this));
620 
621  // metadata
622  $ilTabs->addTarget("meta_data",
623  $this->ctrl->getLinkTargetByClass("ilmdeditorgui",''),
624  "", "ilmdeditorgui");
625 
626  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_st.svg"));
627  $this->tpl->setTitle(
628  $this->lng->txt($this->obj->getType()).": ".$this->obj->getTitle());
629 
630  // presentation view
631  $ilTabs->addNonTabbedLink("pres_mode", $lng->txt("cont_presentation_view"),
632  ILIAS_HTTP_PATH."/goto.php?target=st_".$this->obj->getId(), "_top");
633  }
634 
640  public static function _goto($a_target, $a_target_ref_id = "")
641  {
642  global $rbacsystem, $ilErr, $lng, $ilAccess;
643 
644  // determine learning object
645  $lm_id = ilLMObject::_lookupContObjID($a_target);
646 
647  // get all references
648  $ref_ids = ilObject::_getAllReferences($lm_id);
649 
650  // always try passed ref id first
651  if (in_array($a_target_ref_id, $ref_ids))
652  {
653  $ref_ids = array_merge(array($a_target_ref_id), $ref_ids);
654  }
655 
656  // check read permissions
657  foreach ($ref_ids as $ref_id)
658  {
659  // Permission check
660  if ($ilAccess->checkAccess("read", "", $ref_id))
661  {
662  // don't redirect anymore, just set parameters
663  // (goto.php includes "ilias.php")
664  $_GET["baseClass"] = "ilLMPresentationGUI";
665  $_GET["obj_id"] = $a_target;
666  $_GET["ref_id"] = $ref_id;
667  include_once("ilias.php");
668  exit;;
669  }
670  }
671 
672  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
673  {
674  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
675  ilObject::_lookupTitle($lm_id)), true);
676  include_once("./Services/Object/classes/class.ilObjectGUI.php");
678  }
679 
680  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
681  }
682 
686  function insertChapter($a_as_sub = false)
687  {
688  global $ilCtrl, $lng;
689 
690  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
691 
694 
695  if ($a_as_sub) // as subchapter
696  {
697  if (!ilChapterHierarchyFormGUI::getPostFirstChild()) // insert under parent
698  {
699  $parent_id = $node_id;
700  $target = "";
701  }
702  else // we shouldnt end up here
703  {
704  $ilCtrl->redirect($this, "showHierarchy");
705  return;
706  }
707  }
708  else // as chapter
709  {
710  if (!ilChapterHierarchyFormGUI::getPostFirstChild()) // insert after node id
711  {
712  $parent_id = $this->tree->getParentId($node_id);
713  $target = $node_id;
714  }
715  else // insert as first child
716  {
717  $parent_id = $node_id;
718  $target = IL_FIRST_NODE;
719  }
720  }
721  for ($i = 1; $i <= $num; $i++)
722  {
723  $chap = new ilStructureObject($this->content_object);
724  $chap->setType("st");
725  $chap->setTitle($lng->txt("cont_new_chap"));
726  $chap->setLMId($this->content_object->getId());
727  $chap->create();
728  ilLMObject::putInTree($chap, $parent_id, $target);
729  }
730 
731  $ilCtrl->redirect($this, "view");
732  }
733 
737  function insertSubchapter()
738  {
739  global $ilCtrl;
740 
741  $this->insertChapter(true);
742  }
743 
747  function insertChapterClip($a_as_sub = false, $a_return = "view")
748  {
749  global $ilUser, $ilCtrl, $ilLog;
750 
751  $ilLog->write("Insert Chapter From Clipboard");
752 
753  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
754 
757 
758  if ($a_as_sub) // as subchapter
759  {
760  if (!$first_child) // insert under parent
761  {
762  $parent_id = $node_id;
763  $target = "";
764  }
765  else // we shouldnt end up here
766  {
767  $ilCtrl->redirect($this, "showHierarchy");
768  return;
769  }
770  }
771  else // as chapter
772  {
773  if (!$first_child) // insert after node id
774  {
775  $parent_id = $this->tree->getParentId($node_id);
776  $target = $node_id;
777  }
778  else // insert as first child
779  {
780  $parent_id = $node_id;
781  $target = IL_FIRST_NODE;
782 
783  // do not move a chapter in front of a page
784  $childs = $this->tree->getChildsByType($parent_id, "pg");
785  if (count($childs) != 0)
786  {
787  $target = $childs[count($childs) - 1]["obj_id"];
788  }
789  }
790  }
791 
792  // copy and paste
793  $chapters = $ilUser->getClipboardObjects("st", true);
794  $copied_nodes = array();
795 
796  foreach ($chapters as $chap)
797  {
798  $ilLog->write("Call pasteTree, Target LM: ".$this->content_object->getId().", Chapter ID: ".$chap["id"]
799  .", Parent ID: ".$parent_id.", Target: ".$target);
800  $cid = ilLMObject::pasteTree($this->content_object, $chap["id"], $parent_id,
801  $target, $chap["insert_time"], $copied_nodes,
802  (ilEditClipboard::getAction() == "copy"));
803  $target = $cid;
804  }
805  ilLMObject::updateInternalLinks($copied_nodes);
806 
807  if (ilEditClipboard::getAction() == "cut")
808  {
809  $ilUser->clipboardDeleteObjectsOfType("pg");
810  $ilUser->clipboardDeleteObjectsOfType("st");
812  }
813 
814  $this->content_object->checkTree();
815  $ilCtrl->redirect($this, $a_return);
816  }
817 
822  {
823  $this->insertChapterClip(true);
824  }
825 
829  function insertPage()
830  {
831  global $ilCtrl, $lng;
832 
833  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
834 
837 
838  if (!ilChapterHierarchyFormGUI::getPostFirstChild()) // insert after node id
839  {
840  $parent_id = $this->tree->getParentId($node_id);
841  $target = $node_id;
842  }
843  else // insert as first child
844  {
845  $parent_id = $node_id;
846  $target = IL_FIRST_NODE;
847  }
848 
849  for ($i = 1; $i <= $num; $i++)
850  {
851  $page = new ilLMPageObject($this->content_object);
852  $page->setType("pg");
853  $page->setTitle($lng->txt("cont_new_page"));
854  $page->setLMId($this->content_object->getId());
855  $page->create();
856  ilLMObject::putInTree($page, $parent_id, $target);
857  }
858 
859  $ilCtrl->redirect($this, "showHierarchy");
860  }
861 
865  function insertPageClip()
866  {
867  global $ilCtrl, $ilUser;
868 
869  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
870 
873 
874  if (!$first_child) // insert after node id
875  {
876  $parent_id = $this->tree->getParentId($node_id);
877  $target = $node_id;
878  }
879  else // insert as first child
880  {
881  $parent_id = $node_id;
882  $target = IL_FIRST_NODE;
883  }
884 
885  // cut and paste
886  $pages = $ilUser->getClipboardObjects("pg");
887  $copied_nodes = array();
888  foreach ($pages as $pg)
889  {
890  $cid = ilLMObject::pasteTree($this->content_object, $pg["id"], $parent_id, $target,
891  $pg["insert_time"], $copied_nodes,
892  (ilEditClipboard::getAction() == "copy"));
893  $target = $cid;
894  }
895  ilLMObject::updateInternalLinks($copied_nodes);
896 
897  if (ilEditClipboard::getAction() == "cut")
898  {
899  $ilUser->clipboardDeleteObjectsOfType("pg");
900  $ilUser->clipboardDeleteObjectsOfType("st");
902  }
903 
904  $ilCtrl->redirect($this, "view");
905  }
906 
907 
911  function proceedDragDrop()
912  {
913  global $ilCtrl;
914 
915 //echo "-".$_POST["il_hform_source_id"]."-".$_POST["il_hform_target_id"]."-".$_POST["il_hform_fc"]."-";
916  $this->content_object->executeDragDrop($_POST["il_hform_source_id"], $_POST["il_hform_target_id"],
917  $_POST["il_hform_fc"], $_POST["il_hform_as_subitem"]);
918  $ilCtrl->redirect($this, "showHierarchy");
919  }
920 
924 
928  function setPageLayout()
929  {
930  global $tpl, $ilCtrl, $lng;
931 
932  if (!is_array($_POST["id"]))
933  {
934  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
935  $ilCtrl->redirect($this, "showHierarchy");
936  }
937 
938  $this->initSetPageLayoutForm();
939 
940  $tpl->setContent($this->form->getHTML());
941  }
942 
946  public function initSetPageLayoutForm()
947  {
948  global $lng, $ilCtrl;
949 
950  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
951  $this->form = new ilPropertyFormGUI();
952 
953  if (is_array($_POST["id"]))
954  {
955  foreach ($_POST["id"] as $id)
956  {
957  $hi = new ilHiddenInputGUI("id[]");
958  $hi->setValue($id);
959  $this->form->addItem($hi);
960  }
961  }
962  $layout = ilObjContentObjectGUI::getLayoutOption($lng->txt("cont_layout"), "layout",
963  $this->content_object->getLayout());
964 
965  $this->form->addItem($layout);
966 
967  $this->form->addCommandButton("savePageLayout", $lng->txt("save"));
968  $this->form->addCommandButton("showHierarchy", $lng->txt("cancel"));
969 
970  $this->form->setTitle($lng->txt("cont_set_layout"));
971  $this->form->setFormAction($ilCtrl->getFormAction($this));
972 
973  }
974 
978  function savePageLayout()
979  {
980  global $lng, $ilCtrl;
981 
982  foreach ($_POST["id"] as $id)
983  {
984  $id = ilUtil::stripSlashes($id);
986  ilUtil::stripSlashes($_POST["layout"]),
987  $this->content_object);
988  }
989  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
990  $ilCtrl->redirect($this, "showHierarchy");
991  }
992 
1000  {
1001  global $ilCtrl;
1002 
1003  $ilCtrl->setParameter($this, "transl", "");
1004  $ilCtrl->redirect($this, "showHierarchy");
1005  }
1006 
1013  function switchToLanguage()
1014  {
1015  global $ilCtrl;
1016 
1017  $ilCtrl->setParameter($this, "transl", $_GET["totransl"]);
1018  $ilCtrl->redirect($this, "showHierarchy");
1019  }
1020 
1021 }
1022 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
proceedDragDrop()
Perform drag and drop action.
static getPostMulti()
Get multi number of _POST input.
saveAllTitles()
Save all titles of chapters/pages.
class ilConditionHandlerGUI
editMasterLanguage()
Edit master language.
static updateInternalLinks($a_copied_nodes, $a_parent_type="lm")
Update internal links, after multiple pages have been copied.
exit
Definition: login.php:54
static _lookupType($a_obj_id, $a_lm_id=0)
Lookup type.
$_POST['username']
Definition: cron.php:12
initSetPageLayoutForm()
Init set page layout form.
static _getPresentationTitle($a_st_id, $a_include_numbers=false, $a_time_scheduled_activation=false, $a_lm_id=0, $a_lang="-")
get presentation title
static getMultiLangHeader($a_lm_id, $a_gui_class)
Get multi lang header.
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.
addObserver(&$a_class, $a_method, $a_element)
ilStructureObjectGUI(&$a_content_obj, &$a_tree)
Constructor public.
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.
& executeCommand()
execute command
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
clipboardCut($a_cont_obj_id, $a_ids)
Copy a set of chapters/pages into the clipboard.
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
_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
_lookupContObjID($a_id)
get learning module / digibook id for lm object
cutItems($a_return="view")
Copy items to clipboard, then cut them from the current tree.
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.
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.
global $ilUser
Definition: imgupload.php:15
$ref_id
Definition: sahs_server.php:39
create()
create new page or chapter in chapter
$path
Definition: index.php:22
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows) ...
activatePages()
activates or deactivates pages
insertChapter($a_as_sub=false)
Insert (multiple) chapters at node.
putInTree()
put chapter into tree
showHierarchy()
Show subhiearchy of pages and subchapters.