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")
182 include_once(
"./Services/COPage/classes/class.ilPageObject.php");
184 $this->content_object->getType());
187 $this->tpl->setCurrentBlock(
"deactivated");
188 $this->tpl->setVariable(
"TXT_DEACTIVATED",
189 $this->lng->txt(
"cont_page_deactivated"));
190 $this->tpl->parseCurrentBlock();
195 $this->content_object->getType()))
197 $this->tpl->setCurrentBlock(
"deactivated");
198 $this->tpl->setVariable(
"TXT_DEACTIVATED",
199 $this->lng->txt(
"cont_page_deactivated_elements"));
200 $this->tpl->parseCurrentBlock();
204 $this->tpl->setCurrentBlock(
"table_row");
209 $this->tpl->setVariable(
"CHECKBOX_ID", $child[
"obj_id"]);
210 $this->tpl->setVariable(
"CSS_ROW", $css_row);
214 $this->ctrl->setParameterByClass(
"ilLMPageObjectGUI",
"obj_id", $child[
"obj_id"]);
215 $link = $this->ctrl->getLinkTargetByClass(
"ilLMPageObjectGUI",
"edit",
"");
216 $this->tpl->setVariable(
"LINK_TARGET", $link);
219 $this->tpl->setVariable(
"TEXT_CONTENT", $child[
"title"]);
221 $this->tpl->parseCurrentBlock();
225 $this->tpl->setCurrentBlock(
"notfound");
226 $this->tpl->setVariable(
"NUM_COLS", 3);
227 $this->tpl->setVariable(
"TXT_OBJECT_NOT_FOUND", $this->lng->txt(
"obj_not_found"));
228 $this->tpl->parseCurrentBlock();
233 $this->tpl->setVariable(
"NUM_COLS", 3);
235 $acts = array(
"delete" =>
"delete",
"cutPage" =>
"cutPage",
236 "copyPage" =>
"copyPage",
"activatePages" =>
"cont_de_activate");
238 if ($ilUser->clipboardHasObjectsOfType(
"pg"))
240 $acts[
"pastePage"] =
"pastePage";
246 $this->tpl->setVariable(
"NUM_COLS", 3);
248 $subobj = array(
"pg");
251 $this->tpl->setCurrentBlock(
"add_object");
252 $this->tpl->setVariable(
"SELECT_OBJTYPE", $opts);
254 $this->tpl->setVariable(
"BTN_NAME",
"create");
255 $this->tpl->setVariable(
"TXT_ADD", $this->lng->txt(
"insert"));
256 $this->tpl->parseCurrentBlock();
258 $this->tpl->setCurrentBlock(
"form");
259 $this->tpl->parseCurrentBlock();
261 $ilCtrl->setParameter($this,
"obj_id",
$_GET[
"obj_id"]);
262 $this->tpl->setVariable(
"HREF_JS_EDIT",
263 $ilCtrl->getLinkTarget($this,
"activateJSChapterEditing"));
264 $this->tpl->setVariable(
"TXT_JS_EDIT",
265 $lng->txt(
"cont_js_chap_editing"));
279 $ilCtrl->setParameter($this,
"backcmd",
"showHierarchy");
281 include_once(
"./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
284 $form_gui->setTitle($this->obj->getTitle());
286 $form_gui->setTree($this->tree);
287 $form_gui->setCurrentTopNodeId($this->obj->getId());
288 $form_gui->addMultiCommand($lng->txt(
"delete"),
"delete");
289 $form_gui->addMultiCommand($lng->txt(
"cut"),
"cutItems");
290 $form_gui->addMultiCommand($lng->txt(
"copy"),
"copyItems");
291 $form_gui->addMultiCommand($lng->txt(
"cont_de_activate"),
"activatePages");
293 $form_gui->addCommand($lng->txt(
"cont_save_all_titles"),
"saveAllTitles");
294 $form_gui->addHelpItem($lng->txt(
"cont_chapters_after_pages"));
295 $up_gui = ($this->content_object->getType() ==
"dbk")
297 :
"ilobjlearningmodulegui";
298 $ilCtrl->setParameterByClass($up_gui,
"active_node", $this->obj->getId());
299 $form_gui->setExplorerUpdater(
"tree",
"tree_div",
300 $ilCtrl->getLinkTargetByClass($up_gui,
"explorer",
"",
true));
301 $ilCtrl->setParameterByClass($up_gui,
"active_node",
"");
303 $ctpl =
new ilTemplate(
"tpl.chap_and_pages.html",
true,
true,
"Modules/LearningModule");
304 $ctpl->setVariable(
"HIERARCHY_FORM", $form_gui->getHTML());
305 $ilCtrl->setParameter($this,
"obj_id",
$_GET[
"obj_id"]);
306 $ctpl->setVariable(
"HREF_NO_JS_EDIT",
307 $ilCtrl->getLinkTarget($this,
"deactivateJSChapterEditing"));
308 $ctpl->setVariable(
"TXT_NO_JS_EDIT",
309 $lng->txt(
"cont_not_js_chap_editing"));
311 $this->tpl->setContent($ctpl->get());
321 $ilUser->writePref(
"lm_js_chapter_editing",
"disable");
322 $ilCtrl->redirect($this,
"view");
332 $ilUser->writePref(
"lm_js_chapter_editing",
"enable");
333 $ilCtrl->redirect($this,
"view");
344 if (!is_array($items))
347 $ilCtrl->redirect($this,
"showHierarchy");
351 foreach($items as $k => $item)
358 foreach($todel as $k)
366 $ilCtrl->redirect($this,
"showHierarchy");
374 $ilCtrl->redirect($this, $a_return);
385 if (!is_array($items))
388 $ilCtrl->redirect($this,
"showHierarchy");
392 foreach($items as $k => $item)
399 foreach($todel as $k)
407 $ilCtrl->redirect($this,
"showHierarchy");
414 $ilCtrl->redirect($this, $a_return);
426 $ilCtrl->redirect($this,
"showHierarchy");
438 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.structure_edit.html",
"Modules/LearningModule");
441 $this->tpl->setCurrentBlock(
"form");
442 $this->ctrl->setParameter($this,
"backcmd",
"subchap");
443 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
444 $this->tpl->setVariable(
"HEADER_TEXT", $this->lng->txt(
"cont_subchapters"));
448 $childs = $this->tree->getChilds($this->obj->getId());
449 foreach ($childs as $child)
451 if($child[
"type"] !=
"st")
455 $this->tpl->setCurrentBlock(
"table_row");
460 $this->tpl->setVariable(
"CHECKBOX_ID", $child[
"obj_id"]);
461 $this->tpl->setVariable(
"CSS_ROW", $css_row);
465 $this->ctrl->setParameterByClass(
"ilStructureObjectGUI",
"obj_id", $child[
"obj_id"]);
466 $link = $this->ctrl->getLinkTargetByClass(
"ilStructureObjectGUI",
"view");
467 $this->tpl->setVariable(
"LINK_TARGET", $link);
470 $this->tpl->setVariable(
"TEXT_CONTENT",
472 $this->content_object->isActiveNumbering()));
474 $this->tpl->parseCurrentBlock();
478 $this->tpl->setCurrentBlock(
"notfound");
479 $this->tpl->setVariable(
"NUM_COLS", 3);
480 $this->tpl->setVariable(
"TXT_OBJECT_NOT_FOUND", $this->lng->txt(
"obj_not_found"));
481 $this->tpl->parseCurrentBlock();
486 $this->tpl->setVariable(
"NUM_COLS", 3);
487 $acts = array(
"delete" =>
"delete",
"cutChapter" =>
"cut",
488 "copyChapter" =>
"copyChapter");
489 if ($ilUser->clipboardHasObjectsOfType(
"st"))
491 $acts[
"pasteChapter"] =
"pasteChapter";
497 $this->tpl->setVariable(
"NUM_COLS", 3);
499 $subobj = array(
"st");
502 $this->tpl->setCurrentBlock(
"add_object");
503 $this->tpl->setVariable(
"SELECT_OBJTYPE", $opts);
505 $this->tpl->setVariable(
"BTN_NAME",
"create");
506 $this->tpl->setVariable(
"TXT_ADD", $this->lng->txt(
"insert"));
507 $this->tpl->parseCurrentBlock();
512 $this->tpl->setCurrentBlock(
"form");
513 $this->tpl->parseCurrentBlock();
515 $ilCtrl->setParameter($this,
"obj_id",
$_GET[
"obj_id"]);
516 $this->tpl->setVariable(
"HREF_JS_EDIT",
517 $ilCtrl->getLinkTarget($this,
"activateJSChapterEditing"));
518 $this->tpl->setVariable(
"TXT_JS_EDIT",
519 $lng->txt(
"cont_js_chap_editing"));
530 $this->tpl->setCurrentBlock(
"begin_link");
531 $this->tpl->setVariable(
"LINK_TARGET", $link);
532 $this->tpl->parseCurrentBlock();
533 $this->tpl->touchBlock(
"end_link");
536 $this->tpl->setCurrentBlock(
"text");
537 $this->tpl->setVariable(
"TEXT_CONTENT", $val);
538 $this->tpl->parseCurrentBlock();
539 $this->tpl->setCurrentBlock(
"table_cell");
540 $this->tpl->parseCurrentBlock();
552 $this->obj->setType(
"st");
555 $this->obj->setLMId($this->content_object->getId());
556 $this->obj->create();
563 if (!empty(
$_GET[
"obj_id"]))
565 $this->ctrl->redirect($this,
"subchap");
581 $tree =
new ilTree($this->content_object->getId());
582 $tree->setTableNames(
'lm_tree',
'lm_data');
583 $tree->setTreeTablePK(
"lm_id");
586 $parent_id = (!empty(
$_GET[
"obj_id"]))
588 :
$tree->getRootId();
590 $childs =&
$tree->getChildsByType($parent_id,
"pg");
591 if (count($childs) != 0)
593 $_GET[
"target"] = $childs[count($childs) - 1][
"obj_id"];
596 if (empty(
$_GET[
"target"]))
614 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
617 if(count(
$_POST[
"id"]) > 1)
619 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
624 $this->ilias->raiseError($this->lng->txt(
"cont_select_item"), $this->ilias->error_obj->MESSAGE);
630 $tree =
new ilTree($this->content_object->getId());
631 $tree->setTableNames(
'lm_tree',
'lm_data');
632 $tree->setTreeTablePK(
"lm_id");
636 foreach (
$_POST[
"id"] as $id)
644 $obj->setLMId($this->content_object->getId());
645 $node_data =
$tree->getNodeData($id);
647 if(
$tree->isInTree($id))
649 $parent_id =
$tree->getParentId($id);
650 $tree->deleteTree($node_data);
653 require_once(
"classes/class.ilHistory.php");
656 $this->content_object->getType().
":pg");
659 $this->content_object->getType().
":st");
672 $this->ctrl->redirect($this,
"view");
685 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
687 if(count(
$_POST[
"id"]) > 1)
689 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
694 $this->ilias->raiseError($this->lng->txt(
"cont_select_item"), $this->ilias->error_obj->MESSAGE);
702 $this->ctrl->redirect($this,
"view");
712 if (!$ilUser->clipboardHasObjectsOfType(
"pg"))
714 $this->ilias->raiseError($this->lng->txt(
"no_page_in_clipboard"),$this->ilias->error_obj->MESSAGE);
719 $tree =
new ilTree($this->content_object->getId());
720 $tree->setTableNames(
'lm_tree',
'lm_data');
721 $tree->setTreeTablePK(
"lm_id");
731 == $this->content_object->getID())
734 $new_page =& $lm_page->copy();
735 $id = $new_page->getId();
741 $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
743 $copied_nodes = array();
744 $new_page =& $lm_page->copyToOtherContObject($this->content_object, $copied_nodes);
745 $id = $new_page->getId();
754 != $this->content_object->getID())
757 $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
759 $lm_page->setLMId($this->content_object->getID());
761 $page =& $lm_page->getPageObject();
763 $page->setParentId($this->content_object->getID());
768 if(!
$tree->isInTree($id))
776 $target =
$_POST[
"id"][0];
778 $tree->insertNode($id, $this->obj->getId(), $target);
783 include_once(
"classes/class.ilHistory.php");
784 $parent_id =
$tree->getParentId($id);
787 $this->content_object->getType().
":pg");
790 $this->content_object->getType().
":st");
795 $this->ctrl->redirect($this,
"view");
812 $this->ctrl->redirect($this,
"subchap");
827 $this->ctrl->redirect($this,
"subchap");
841 if($id ==
$_POST[
"id"][0])
851 $this->ctrl->redirect($this,
"subchap");
861 include_once(
"./Services/COPage/classes/class.ilPageObject.php");
862 if (is_array(
$_POST[
"id"]))
864 $act_items = array();
866 foreach(
$_POST[
"id"] as $id)
868 $path = $this->tree->getPathId($id);
870 foreach(
$path as $path_id)
872 if ($path_id != $id && in_array($path_id,
$_POST[
"id"]))
884 foreach($act_items as $id)
886 $childs = $this->tree->getChilds($id);
887 foreach($childs as $child)
892 $this->content_object->getType());
894 $this->content_object->getType(), !$act);
900 $this->content_object->getType());
902 $this->content_object->getType(), !$act);
911 $this->ctrl->redirect($this,
"view");
920 include_once(
"classes/class.ilConditionHandlerInterface.php");
923 $this->condHI->setBackButtons(array());
924 $this->condHI->setAutomaticValidation(
false);
925 $this->condHI->setTargetType(
"st");
926 $this->condHI->setTargetRefId($this->content_object->getRefId());
927 $this->condHI->setTargetId($this->obj->getId());
928 $this->condHI->setTargetTitle($this->obj->getTitle());
937 if (
$_GET[
"obj_id"] != 0)
939 if (
$_GET[
"new_type"] ==
"pg")
941 $this->ctrl->redirect($this,
"view");
945 $this->ctrl->redirect($this,
"subchap");
956 global $ilTabs, $ilUser;
958 if ($ilUser->getPref(
"lm_js_chapter_editing") ==
"disable")
961 $ilTabs->addTarget(
"cont_pages",
962 $this->ctrl->getLinkTarget($this,
'view'),
963 "view", get_class($this));
966 $ilTabs->addTarget(
"cont_subchapters",
967 $this->ctrl->getLinkTarget($this,
'subchap'),
968 "subchap", get_class($this));
973 $ilTabs->addTarget(
"cont_pages_and_subchapters",
974 $this->ctrl->getLinkTarget($this,
'showHierarchy'),
975 array(
"view",
"showHierarchy"), get_class($this));
979 $ilTabs->addTarget(
"preconditions",
980 $this->ctrl->getLinkTarget($this,
'listConditions'),
981 "listConditions", get_class($this));
984 $ilTabs->addTarget(
"meta_data",
985 $this->ctrl->getLinkTargetByClass(
"ilmdeditorgui",
''),
986 "",
"ilmdeditorgui");
988 $this->tpl->setCurrentBlock(
"header_image");
990 $this->tpl->parseCurrentBlock();
991 $this->tpl->setCurrentBlock(
"content");
993 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
994 $this->tpl->setVariable(
"HEADER",
995 $this->lng->txt($this->obj->getType()).
": ".$this->obj->getTitle());
1003 function _goto($a_target, $a_target_ref_id =
"")
1014 if (in_array($a_target_ref_id, $ref_ids))
1016 $ref_ids = array_merge(array($a_target_ref_id), $ref_ids);
1023 if ($ilAccess->checkAccess(
"read",
"", $ref_id))
1027 $_GET[
"baseClass"] =
"ilLMPresentationGUI";
1028 $_GET[
"obj_id"] = $a_target;
1030 include_once(
"ilias.php");
1035 if ($ilAccess->checkAccess(
"read",
"", ROOT_FOLDER_ID))
1037 $_GET[
"cmd"] =
"frameset";
1038 $_GET[
"target"] =
"";
1039 $_GET[
"ref_id"] = ROOT_FOLDER_ID;
1042 include(
"repository.php");
1046 $ilErr->raiseError($lng->txt(
"msg_no_perm_read_lm"), $ilErr->FATAL);
1056 include_once(
"./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
1065 $parent_id = $node_id;
1070 $ilCtrl->redirect($this,
"showHierarchy");
1078 $parent_id = $this->tree->getParentId($node_id);
1083 $parent_id = $node_id;
1087 for ($i = 1; $i <= $num; $i++)
1090 $chap->setType(
"st");
1091 $chap->setTitle($lng->txt(
"cont_new_chap"));
1092 $chap->setLMId($this->content_object->getId());
1097 $ilCtrl->redirect($this,
"view");
1117 $ilLog->write(
"Insert Chapter From Clipboard");
1119 include_once(
"./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
1121 if ($ilUser->getPref(
"lm_js_chapter_editing") !=
"disable")
1131 $node_id = $this->obj->getId();
1132 $first_child =
true;
1136 $node_id =
$_POST[
"id"][0];
1137 $first_child =
false;
1145 $parent_id = $node_id;
1150 $ilCtrl->redirect($this,
"showHierarchy");
1158 $parent_id = $this->tree->getParentId($node_id);
1163 $parent_id = $node_id;
1167 $childs = $this->tree->getChildsByType($parent_id,
"pg");
1168 if (count($childs) != 0)
1170 $target = $childs[count($childs) - 1][
"obj_id"];
1176 $chapters = $ilUser->getClipboardObjects(
"st",
true);
1177 $copied_nodes = array();
1179 foreach ($chapters as $chap)
1181 $ilLog->write(
"Call pasteTree, Target LM: ".$this->content_object->getId().
", Chapter ID: ".$chap[
"id"]
1182 .
", Parent ID: ".$parent_id.
", Target: ".$target);
1184 $target, $chap[
"insert_time"], $copied_nodes,
1192 $ilUser->clipboardDeleteObjectsOfType(
"pg");
1193 $ilUser->clipboardDeleteObjectsOfType(
"st");
1197 $this->content_object->checkTree();
1198 $ilCtrl->redirect($this, $a_return);
1216 include_once(
"./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
1223 $parent_id = $this->tree->getParentId($node_id);
1228 $parent_id = $node_id;
1232 for ($i = 1; $i <= $num; $i++)
1235 $page->setType(
"pg");
1236 $page->setTitle($lng->txt(
"cont_new_page"));
1237 $page->setLMId($this->content_object->getId());
1242 $ilCtrl->redirect($this,
"showHierarchy");
1252 include_once(
"./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
1254 if ($ilUser->getPref(
"lm_js_chapter_editing") !=
"disable")
1264 $node_id = $this->obj->getId();
1265 $first_child =
true;
1269 $node_id =
$_POST[
"id"][0];
1270 $first_child =
false;
1276 $parent_id = $this->tree->getParentId($node_id);
1281 $parent_id = $node_id;
1286 $pages = $ilUser->getClipboardObjects(
"pg");
1287 $copied_nodes = array();
1288 foreach ($pages as $pg)
1291 $pg[
"insert_time"], $copied_nodes,
1299 $ilUser->clipboardDeleteObjectsOfType(
"pg");
1300 $ilUser->clipboardDeleteObjectsOfType(
"st");
1304 $ilCtrl->redirect($this,
"view");
1316 $this->content_object->executeDragDrop(
$_POST[
"il_hform_source_id"],
$_POST[
"il_hform_target_id"],
1318 $ilCtrl->redirect($this,
"showHierarchy");