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