24 require_once(
"./Modules/LearningModule/classes/class.ilLMObjectGUI.php");
25 require_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
53 $this->tree =& $a_tree;
63 $this->obj =& $a_st_object;
81 $next_class = $this->ctrl->getNextClass($this);
82 $cmd = $this->ctrl->getCmd();
89 include_once
'Services/MetaData/classes/class.ilMDEditorGUI.php';
92 $this->obj->getId(), $this->obj->getType());
93 $md_gui->
addObserver($this->obj,
'MDUpdateListener',
'General');
95 $this->ctrl->forwardCommand($md_gui);
98 case "ilconditionhandlerinterface":
100 include_once
'./classes/class.ilConditionHandlerInterface.php';
104 $this->ctrl->forwardCommand($this->condHI);
105 $ilTabs->setTabActive(
'preconditions');
109 if(
$cmd ==
'listConditions')
113 $ret =& $this->condHI->executeCommand();
115 elseif((
$cmd ==
"create") && ($_POST[
"new_type"] ==
"pg"))
119 $ret =& $pg_gui->executeCommand();
135 if (
$_GET[
"obj_id"] !=
"")
154 if ($ilUser->getPref(
"lm_js_chapter_editing") !=
"disable")
162 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.structure_edit.html",
"Modules/LearningModule");
165 $this->tpl->setCurrentBlock(
"form");
166 $this->ctrl->setParameter($this,
"backcmd",
"view");
167 $this->tpl->setVariable(
"FORMACTION",
168 $this->ctrl->getFormAction($this));
169 $this->tpl->setVariable(
"HEADER_TEXT", $this->lng->txt(
"cont_pages"));
173 $childs = $this->tree->getChilds($this->obj->getId());
174 foreach ($childs as $child)
176 if($child[
"type"] !=
"pg")
184 $this->tpl->setCurrentBlock(
"deactivated");
185 $this->tpl->setVariable(
"TXT_DEACTIVATED",
186 $this->lng->txt(
"cont_page_deactivated"));
187 $this->tpl->parseCurrentBlock();
192 $this->content_object->getType()))
194 $this->tpl->setCurrentBlock(
"deactivated");
195 $this->tpl->setVariable(
"TXT_DEACTIVATED",
196 $this->lng->txt(
"cont_page_deactivated_elements"));
197 $this->tpl->parseCurrentBlock();
201 $this->tpl->setCurrentBlock(
"table_row");
206 $this->tpl->setVariable(
"CHECKBOX_ID", $child[
"obj_id"]);
207 $this->tpl->setVariable(
"CSS_ROW", $css_row);
211 $this->ctrl->setParameterByClass(
"ilLMPageObjectGUI",
"obj_id", $child[
"obj_id"]);
212 $link = $this->ctrl->getLinkTargetByClass(
"ilLMPageObjectGUI",
"edit",
"");
213 $this->tpl->setVariable(
"LINK_TARGET", $link);
216 $this->tpl->setVariable(
"TEXT_CONTENT", $child[
"title"]);
218 $this->tpl->parseCurrentBlock();
222 $this->tpl->setCurrentBlock(
"notfound");
223 $this->tpl->setVariable(
"NUM_COLS", 3);
224 $this->tpl->setVariable(
"TXT_OBJECT_NOT_FOUND", $this->lng->txt(
"obj_not_found"));
225 $this->tpl->parseCurrentBlock();
230 $this->tpl->setVariable(
"NUM_COLS", 3);
232 $acts = array(
"delete" =>
"delete",
"cutPage" =>
"cutPage",
233 "copyPage" =>
"copyPage",
"activatePages" =>
"cont_de_activate");
235 if ($ilUser->clipboardHasObjectsOfType(
"pg"))
237 $acts[
"pastePage"] =
"pastePage";
244 $this->tpl->setVariable(
"NUM_COLS", 3);
246 $subobj = array(
"pg");
249 $this->tpl->setCurrentBlock(
"add_object");
250 $this->tpl->setVariable(
"SELECT_OBJTYPE", $opts);
252 $this->tpl->setVariable(
"BTN_NAME",
"create");
253 $this->tpl->setVariable(
"TXT_ADD", $this->lng->txt(
"insert"));
254 $this->tpl->parseCurrentBlock();
256 $this->tpl->setCurrentBlock(
"form");
257 $this->tpl->parseCurrentBlock();
259 $ilCtrl->setParameter($this,
"obj_id",
$_GET[
"obj_id"]);
260 $this->tpl->setVariable(
"HREF_JS_EDIT",
261 $ilCtrl->getLinkTarget($this,
"activateJSChapterEditing"));
262 $this->tpl->setVariable(
"TXT_JS_EDIT",
263 $lng->txt(
"cont_js_chap_editing"));
277 $ilCtrl->setParameter($this,
"backcmd",
"showHierarchy");
279 include_once(
"./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
282 $form_gui->setTitle($this->obj->getTitle());
284 $form_gui->setTree($this->tree);
285 $form_gui->setCurrentTopNodeId($this->obj->getId());
286 $form_gui->addMultiCommand($lng->txt(
"delete"),
"delete");
287 $form_gui->addMultiCommand($lng->txt(
"cut"),
"cutItems");
288 $form_gui->addMultiCommand($lng->txt(
"copy"),
"copyItems");
289 $form_gui->addMultiCommand($lng->txt(
"cont_de_activate"),
"activatePages");
291 $form_gui->addCommand($lng->txt(
"cont_save_all_titles"),
"saveAllTitles");
292 $form_gui->addHelpItem($lng->txt(
"cont_chapters_after_pages"));
293 $up_gui = ($this->content_object->getType() ==
"dbk")
295 :
"ilobjlearningmodulegui";
296 $ilCtrl->setParameterByClass($up_gui,
"active_node", $this->obj->getId());
297 $form_gui->setExplorerUpdater(
"tree",
"tree_div",
298 $ilCtrl->getLinkTargetByClass($up_gui,
"explorer",
"",
true));
299 $ilCtrl->setParameterByClass($up_gui,
"active_node",
"");
301 $ctpl =
new ilTemplate(
"tpl.chap_and_pages.html",
true,
true,
"Modules/LearningModule");
302 $ctpl->setVariable(
"HIERARCHY_FORM", $form_gui->getHTML());
303 $ilCtrl->setParameter($this,
"obj_id",
$_GET[
"obj_id"]);
304 $ctpl->setVariable(
"HREF_NO_JS_EDIT",
305 $ilCtrl->getLinkTarget($this,
"deactivateJSChapterEditing"));
306 $ctpl->setVariable(
"TXT_NO_JS_EDIT",
307 $lng->txt(
"cont_not_js_chap_editing"));
309 $this->tpl->setContent($ctpl->get());
319 $ilUser->writePref(
"lm_js_chapter_editing",
"disable");
320 $ilCtrl->redirect($this,
"view");
330 $ilUser->writePref(
"lm_js_chapter_editing",
"enable");
331 $ilCtrl->redirect($this,
"view");
342 if (!is_array($items))
345 $ilCtrl->redirect($this,
"showHierarchy");
349 foreach($items as $k => $item)
356 foreach($todel as $k)
364 $ilCtrl->redirect($this,
"showHierarchy");
372 $ilCtrl->redirect($this, $a_return);
383 if (!is_array($items))
386 $ilCtrl->redirect($this,
"showHierarchy");
390 foreach($items as $k => $item)
397 foreach($todel as $k)
405 $ilCtrl->redirect($this,
"showHierarchy");
412 $ilCtrl->redirect($this, $a_return);
424 $ilCtrl->redirect($this,
"showHierarchy");
436 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.structure_edit.html",
"Modules/LearningModule");
439 $this->tpl->setCurrentBlock(
"form");
440 $this->ctrl->setParameter($this,
"backcmd",
"subchap");
441 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
442 $this->tpl->setVariable(
"HEADER_TEXT", $this->lng->txt(
"cont_subchapters"));
446 $childs = $this->tree->getChilds($this->obj->getId());
447 foreach ($childs as $child)
449 if($child[
"type"] !=
"st")
453 $this->tpl->setCurrentBlock(
"table_row");
458 $this->tpl->setVariable(
"CHECKBOX_ID", $child[
"obj_id"]);
459 $this->tpl->setVariable(
"CSS_ROW", $css_row);
463 $this->ctrl->setParameterByClass(
"ilStructureObjectGUI",
"obj_id", $child[
"obj_id"]);
464 $link = $this->ctrl->getLinkTargetByClass(
"ilStructureObjectGUI",
"view");
465 $this->tpl->setVariable(
"LINK_TARGET", $link);
468 $this->tpl->setVariable(
"TEXT_CONTENT",
470 $this->content_object->isActiveNumbering()));
472 $this->tpl->parseCurrentBlock();
476 $this->tpl->setCurrentBlock(
"notfound");
477 $this->tpl->setVariable(
"NUM_COLS", 3);
478 $this->tpl->setVariable(
"TXT_OBJECT_NOT_FOUND", $this->lng->txt(
"obj_not_found"));
479 $this->tpl->parseCurrentBlock();
484 $this->tpl->setVariable(
"NUM_COLS", 3);
485 $acts = array(
"delete" =>
"delete",
"cutChapter" =>
"cut",
486 "copyChapter" =>
"copyChapter");
487 if ($ilUser->clipboardHasObjectsOfType(
"st"))
489 $acts[
"pasteChapter"] =
"pasteChapter";
500 $this->tpl->setVariable(
"NUM_COLS", 3);
502 $subobj = array(
"st");
505 $this->tpl->setCurrentBlock(
"add_object");
506 $this->tpl->setVariable(
"SELECT_OBJTYPE", $opts);
508 $this->tpl->setVariable(
"BTN_NAME",
"create");
509 $this->tpl->setVariable(
"TXT_ADD", $this->lng->txt(
"insert"));
510 $this->tpl->parseCurrentBlock();
515 $this->tpl->setCurrentBlock(
"form");
516 $this->tpl->parseCurrentBlock();
518 $ilCtrl->setParameter($this,
"obj_id",
$_GET[
"obj_id"]);
519 $this->tpl->setVariable(
"HREF_JS_EDIT",
520 $ilCtrl->getLinkTarget($this,
"activateJSChapterEditing"));
521 $this->tpl->setVariable(
"TXT_JS_EDIT",
522 $lng->txt(
"cont_js_chap_editing"));
533 $this->tpl->setCurrentBlock(
"begin_link");
534 $this->tpl->setVariable(
"LINK_TARGET", $link);
535 $this->tpl->parseCurrentBlock();
536 $this->tpl->touchBlock(
"end_link");
539 $this->tpl->setCurrentBlock(
"text");
540 $this->tpl->setVariable(
"TEXT_CONTENT", $val);
541 $this->tpl->parseCurrentBlock();
542 $this->tpl->setCurrentBlock(
"table_cell");
543 $this->tpl->parseCurrentBlock();
555 $this->obj->setType(
"st");
558 $this->obj->setLMId($this->content_object->getId());
559 $this->obj->create();
566 if (!empty(
$_GET[
"obj_id"]))
568 $this->ctrl->redirect($this,
"subchap");
584 $tree =
new ilTree($this->content_object->getId());
585 $tree->setTableNames(
'lm_tree',
'lm_data');
586 $tree->setTreeTablePK(
"lm_id");
589 $parent_id = (!empty(
$_GET[
"obj_id"]))
591 :
$tree->getRootId();
593 $childs =&
$tree->getChildsByType($parent_id,
"pg");
594 if (count($childs) != 0)
596 $_GET[
"target"] = $childs[count($childs) - 1][
"obj_id"];
599 if (empty(
$_GET[
"target"]))
615 if(!isset($_POST[
"id"]))
617 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
620 if(count($_POST[
"id"]) > 1)
622 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
625 if(count($_POST[
"id"]) == 1 && $_POST[
"id"][0] ==
IL_FIRST_NODE)
627 $this->ilias->raiseError($this->lng->txt(
"cont_select_item"), $this->ilias->error_obj->MESSAGE);
633 $tree =
new ilTree($this->content_object->getId());
634 $tree->setTableNames(
'lm_tree',
'lm_data');
635 $tree->setTreeTablePK(
"lm_id");
639 foreach ($_POST[
"id"] as $id)
647 $obj->setLMId($this->content_object->getId());
648 $node_data =
$tree->getNodeData($id);
650 if(
$tree->isInTree($id))
652 $parent_id =
$tree->getParentId($id);
653 $tree->deleteTree($node_data);
656 require_once(
"classes/class.ilHistory.php");
659 $this->content_object->getType().
":pg");
662 $this->content_object->getType().
":st");
675 $this->ctrl->redirect($this,
"view");
686 if(!isset($_POST[
"id"]))
688 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
690 if(count($_POST[
"id"]) > 1)
692 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
695 if(count($_POST[
"id"]) == 1 && $_POST[
"id"][0] ==
IL_FIRST_NODE)
697 $this->ilias->raiseError($this->lng->txt(
"cont_select_item"), $this->ilias->error_obj->MESSAGE);
705 $this->ctrl->redirect($this,
"view");
715 if (!$ilUser->clipboardHasObjectsOfType(
"pg"))
717 $this->ilias->raiseError($this->lng->txt(
"no_page_in_clipboard"),$this->ilias->error_obj->MESSAGE);
722 $tree =
new ilTree($this->content_object->getId());
723 $tree->setTableNames(
'lm_tree',
'lm_data');
724 $tree->setTreeTablePK(
"lm_id");
734 == $this->content_object->getID())
737 $new_page =& $lm_page->copy();
738 $id = $new_page->getId();
744 $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
746 $copied_nodes = array();
747 $new_page =& $lm_page->copyToOtherContObject($this->content_object, $copied_nodes);
748 $id = $new_page->getId();
757 != $this->content_object->getID())
760 $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
762 $lm_page->setLMId($this->content_object->getID());
764 $page =& $lm_page->getPageObject();
766 $page->setParentId($this->content_object->getID());
771 if(!
$tree->isInTree($id))
773 if(!isset($_POST[
"id"]))
779 $target = $_POST[
"id"][0];
781 $tree->insertNode($id, $this->obj->getId(), $target);
786 include_once(
"classes/class.ilHistory.php");
787 $parent_id =
$tree->getParentId($id);
790 $this->content_object->getType().
":pg");
793 $this->content_object->getType().
":st");
798 $this->ctrl->redirect($this,
"view");
815 $this->ctrl->redirect($this,
"subchap");
830 $this->ctrl->redirect($this,
"subchap");
844 if($id == $_POST[
"id"][0])
854 $this->ctrl->redirect($this,
"subchap");
864 if (is_array($_POST[
"id"]))
866 $act_items = array();
868 foreach($_POST[
"id"] as $id)
870 $path = $this->tree->getPathId($id);
872 foreach($path as $path_id)
874 if ($path_id != $id && in_array($path_id, $_POST[
"id"]))
886 foreach($act_items as $id)
888 $childs = $this->tree->getChilds($id);
889 foreach($childs as $child)
909 $this->ctrl->redirect($this,
"view");
918 include_once(
"classes/class.ilConditionHandlerInterface.php");
921 $this->condHI->setBackButtons(array());
922 $this->condHI->setAutomaticValidation(
false);
923 $this->condHI->setTargetType(
"st");
924 $this->condHI->setTargetRefId($this->content_object->getRefId());
925 $this->condHI->setTargetId($this->obj->getId());
926 $this->condHI->setTargetTitle($this->obj->getTitle());
936 if (
$_GET[
"obj_id"] != 0)
938 if (
$_GET[
"new_type"] ==
"pg")
940 $this->ctrl->redirect($this,
"view");
944 $this->ctrl->redirect($this,
"subchap");
955 global $ilTabs, $ilUser;
957 if ($ilUser->getPref(
"lm_js_chapter_editing") ==
"disable")
960 $ilTabs->addTarget(
"cont_pages",
961 $this->ctrl->getLinkTarget($this,
'view'),
962 "view", get_class($this));
965 $ilTabs->addTarget(
"cont_subchapters",
966 $this->ctrl->getLinkTarget($this,
'subchap'),
967 "subchap", get_class($this));
972 $ilTabs->addTarget(
"cont_pages_and_subchapters",
973 $this->ctrl->getLinkTarget($this,
'showHierarchy'),
974 array(
"view",
"showHierarchy"), get_class($this));
978 $ilTabs->addTarget(
"preconditions",
979 $this->ctrl->getLinkTarget($this,
'listConditions'),
980 "listConditions", get_class($this));
983 $ilTabs->addTarget(
"meta_data",
984 $this->ctrl->getLinkTargetByClass(
"ilmdeditorgui",
''),
985 "",
"ilmdeditorgui");
987 $this->tpl->setCurrentBlock(
"header_image");
989 $this->tpl->parseCurrentBlock();
990 $this->tpl->setCurrentBlock(
"content");
992 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
993 $this->tpl->setVariable(
"HEADER",
994 $this->lng->txt($this->obj->getType()).
": ".$this->obj->getTitle());
1002 function _goto($a_target, $a_target_ref_id =
"")
1013 if (in_array($a_target_ref_id, $ref_ids))
1015 $ref_ids = array_merge(array($a_target_ref_id), $ref_ids);
1022 if ($ilAccess->checkAccess(
"read",
"", $ref_id))
1026 $_GET[
"baseClass"] =
"ilLMPresentationGUI";
1027 $_GET[
"obj_id"] = $a_target;
1029 include_once(
"ilias.php");
1034 if ($ilAccess->checkAccess(
"read",
"", ROOT_FOLDER_ID))
1036 $_GET[
"cmd"] =
"frameset";
1037 $_GET[
"target"] =
"";
1038 $_GET[
"ref_id"] = ROOT_FOLDER_ID;
1041 include(
"repository.php");
1045 $ilErr->raiseError($lng->txt(
"msg_no_perm_read_lm"), $ilErr->FATAL);
1055 include_once(
"./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
1064 $parent_id = $node_id;
1069 $ilCtrl->redirect($this,
"showHierarchy");
1077 $parent_id = $this->tree->getParentId($node_id);
1082 $parent_id = $node_id;
1086 for ($i = 1; $i <= $num; $i++)
1089 $chap->setType(
"st");
1090 $chap->setTitle(
"");
1091 $chap->setLMId($this->content_object->getId());
1096 $ilCtrl->redirect($this,
"view");
1116 $ilLog->write(
"Insert Chapter From Clipboard");
1118 include_once(
"./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
1120 if ($ilUser->getPref(
"lm_js_chapter_editing") !=
"disable")
1128 if (!isset($_POST[
"id"]) || $_POST[
"id"][0] == -1)
1130 $node_id = $this->obj->getId();
1131 $first_child =
true;
1135 $node_id = $_POST[
"id"][0];
1136 $first_child =
false;
1144 $parent_id = $node_id;
1149 $ilCtrl->redirect($this,
"showHierarchy");
1157 $parent_id = $this->tree->getParentId($node_id);
1162 $parent_id = $node_id;
1166 $childs = $this->tree->getChildsByType($parent_id,
"pg");
1167 if (count($childs) != 0)
1169 $target = $childs[count($childs) - 1][
"obj_id"];
1175 $chapters = $ilUser->getClipboardObjects(
"st",
true);
1176 $copied_nodes = array();
1178 foreach ($chapters as $chap)
1180 $ilLog->write(
"Call pasteTree, Target LM: ".$this->content_object->getId().
", Chapter ID: ".$chap[
"id"]
1181 .
", Parent ID: ".$parent_id.
", Target: ".$target);
1183 $target, $chap[
"insert_time"], $copied_nodes,
1191 $ilUser->clipboardDeleteObjectsOfType(
"pg");
1192 $ilUser->clipboardDeleteObjectsOfType(
"st");
1196 $this->content_object->checkTree();
1197 $ilCtrl->redirect($this, $a_return);
1215 include_once(
"./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
1222 $parent_id = $this->tree->getParentId($node_id);
1227 $parent_id = $node_id;
1231 for ($i = 1; $i <= $num; $i++)
1234 $page->setType(
"pg");
1235 $page->setTitle(
"");
1236 $page->setLMId($this->content_object->getId());
1241 $ilCtrl->redirect($this,
"showHierarchy");
1251 include_once(
"./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
1253 if ($ilUser->getPref(
"lm_js_chapter_editing") !=
"disable")
1261 if(!isset($_POST[
"id"]) || $_POST[
"id"][0] == -1)
1263 $node_id = $this->obj->getId();
1264 $first_child =
true;
1268 $node_id = $_POST[
"id"][0];
1269 $first_child =
false;
1275 $parent_id = $this->tree->getParentId($node_id);
1280 $parent_id = $node_id;
1285 $pages = $ilUser->getClipboardObjects(
"pg");
1286 $copied_nodes = array();
1287 foreach ($pages as $pg)
1290 $pg[
"insert_time"], $copied_nodes,
1298 $ilUser->clipboardDeleteObjectsOfType(
"pg");
1299 $ilUser->clipboardDeleteObjectsOfType(
"st");
1303 $ilCtrl->redirect($this,
"view");
1315 $this->content_object->executeDragDrop($_POST[
"il_hform_source_id"], $_POST[
"il_hform_target_id"],
1316 $_POST[
"il_hform_fc"], $_POST[
"il_hform_as_subitem"]);
1317 $ilCtrl->redirect($this,
"showHierarchy");