6 require_once(
"./Modules/LearningModule/classes/class.ilLMObjectGUI.php");
7 require_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
35 $this->tree =& $a_tree;
45 $this->obj =& $a_st_object;
63 $next_class = $this->ctrl->getNextClass($this);
64 $cmd = $this->ctrl->getCmd();
71 include_once
'Services/MetaData/classes/class.ilMDEditorGUI.php';
74 $this->obj->getId(), $this->obj->getType());
75 $md_gui->
addObserver($this->obj,
'MDUpdateListener',
'General');
77 $this->ctrl->forwardCommand($md_gui);
80 case "ilconditionhandlerinterface":
82 include_once
'./Services/AccessControl/classes/class.ilConditionHandlerInterface.php';
86 $this->ctrl->forwardCommand($this->condHI);
87 $ilTabs->setTabActive(
'preconditions');
91 if(
$cmd ==
'listConditions')
95 $ret =& $this->condHI->executeCommand();
97 elseif((
$cmd ==
"create") && (
$_POST[
"new_type"] ==
"pg"))
101 $ret =& $pg_gui->executeCommand();
117 if (
$_GET[
"obj_id"] !=
"")
136 if ($ilUser->getPref(
"lm_js_chapter_editing") !=
"disable")
144 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.structure_edit.html",
"Modules/LearningModule");
147 $this->tpl->setCurrentBlock(
"form");
148 $this->ctrl->setParameter($this,
"backcmd",
"view");
149 $this->tpl->setVariable(
"FORMACTION",
150 $this->ctrl->getFormAction($this));
151 $this->tpl->setVariable(
"HEADER_TEXT", $this->lng->txt(
"cont_pages"));
155 $childs = $this->tree->getChilds($this->obj->getId());
156 foreach ($childs as $child)
158 if($child[
"type"] !=
"pg")
164 include_once(
"./Services/COPage/classes/class.ilPageObject.php");
166 $this->content_object->getType());
169 $this->tpl->setCurrentBlock(
"deactivated");
170 $this->tpl->setVariable(
"TXT_DEACTIVATED",
171 $this->lng->txt(
"cont_page_deactivated"));
172 $this->tpl->parseCurrentBlock();
177 $this->content_object->getType()))
179 $this->tpl->setCurrentBlock(
"deactivated");
180 $this->tpl->setVariable(
"TXT_DEACTIVATED",
181 $this->lng->txt(
"cont_page_deactivated_elements"));
182 $this->tpl->parseCurrentBlock();
186 $this->tpl->setCurrentBlock(
"table_row");
191 $this->tpl->setVariable(
"CHECKBOX_ID", $child[
"obj_id"]);
192 $this->tpl->setVariable(
"CSS_ROW", $css_row);
196 $this->ctrl->setParameterByClass(
"ilLMPageObjectGUI",
"obj_id", $child[
"obj_id"]);
197 $link = $this->ctrl->getLinkTargetByClass(
"ilLMPageObjectGUI",
"edit",
"");
198 $this->tpl->setVariable(
"LINK_TARGET", $link);
201 $this->tpl->setVariable(
"TEXT_CONTENT", $child[
"title"]);
203 $this->tpl->parseCurrentBlock();
207 $this->tpl->setCurrentBlock(
"notfound");
208 $this->tpl->setVariable(
"NUM_COLS", 3);
209 $this->tpl->setVariable(
"TXT_OBJECT_NOT_FOUND", $this->lng->txt(
"obj_not_found"));
210 $this->tpl->parseCurrentBlock();
215 $this->tpl->setVariable(
"NUM_COLS", 3);
217 $acts = array(
"delete" =>
"delete",
"cutPage" =>
"cutPage",
218 "copyPage" =>
"copyPage",
"activatePages" =>
"cont_de_activate");
220 if ($ilUser->clipboardHasObjectsOfType(
"pg"))
222 $acts[
"pastePage"] =
"pastePage";
228 $this->tpl->setVariable(
"NUM_COLS", 3);
230 $subobj = array(
"pg");
233 $this->tpl->setCurrentBlock(
"add_object");
234 $this->tpl->setVariable(
"SELECT_OBJTYPE", $opts);
236 $this->tpl->setVariable(
"BTN_NAME",
"create");
237 $this->tpl->setVariable(
"TXT_ADD", $this->lng->txt(
"insert"));
238 $this->tpl->parseCurrentBlock();
240 $this->tpl->setCurrentBlock(
"form");
241 $this->tpl->parseCurrentBlock();
243 $ilCtrl->setParameter($this,
"obj_id",
$_GET[
"obj_id"]);
244 $this->tpl->setVariable(
"HREF_JS_EDIT",
245 $ilCtrl->getLinkTarget($this,
"activateJSChapterEditing"));
246 $this->tpl->setVariable(
"TXT_JS_EDIT",
247 $lng->txt(
"cont_js_chap_editing"));
261 $ilCtrl->setParameter($this,
"backcmd",
"showHierarchy");
263 include_once(
"./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
266 $form_gui->setTitle($this->obj->getTitle());
268 $form_gui->setTree($this->tree);
269 $form_gui->setCurrentTopNodeId($this->obj->getId());
270 $form_gui->addMultiCommand($lng->txt(
"delete"),
"delete");
271 $form_gui->addMultiCommand($lng->txt(
"cut"),
"cutItems");
272 $form_gui->addMultiCommand($lng->txt(
"copy"),
"copyItems");
273 $form_gui->addMultiCommand($lng->txt(
"cont_de_activate"),
"activatePages");
274 if ($this->content_object->getLayoutPerPage())
276 $form_gui->addMultiCommand($lng->txt(
"cont_set_layout"),
"setPageLayout");
279 $form_gui->addCommand($lng->txt(
"cont_save_all_titles"),
"saveAllTitles");
280 $form_gui->addHelpItem($lng->txt(
"cont_chapters_after_pages"));
281 $up_gui = ($this->content_object->getType() ==
"dbk")
283 :
"ilobjlearningmodulegui";
284 $ilCtrl->setParameterByClass($up_gui,
"active_node", $this->obj->getId());
285 $form_gui->setExplorerUpdater(
"tree",
"tree_div",
286 $ilCtrl->getLinkTargetByClass($up_gui,
"explorer",
"",
true));
287 $ilCtrl->setParameterByClass($up_gui,
"active_node",
"");
289 $ctpl =
new ilTemplate(
"tpl.chap_and_pages.html",
true,
true,
"Modules/LearningModule");
290 $ctpl->setVariable(
"HIERARCHY_FORM", $form_gui->getHTML());
291 $ilCtrl->setParameter($this,
"obj_id",
$_GET[
"obj_id"]);
292 $ctpl->setVariable(
"HREF_NO_JS_EDIT",
293 $ilCtrl->getLinkTarget($this,
"deactivateJSChapterEditing"));
294 $ctpl->setVariable(
"TXT_NO_JS_EDIT",
295 $lng->txt(
"cont_not_js_chap_editing"));
297 $this->tpl->setContent($ctpl->get());
307 $ilUser->writePref(
"lm_js_chapter_editing",
"disable");
308 $ilCtrl->redirect($this,
"view");
318 $ilUser->writePref(
"lm_js_chapter_editing",
"enable");
319 $ilCtrl->redirect($this,
"view");
330 if (!is_array($items))
333 $ilCtrl->redirect($this,
"showHierarchy");
337 foreach($items as $k => $item)
344 foreach($todel as $k)
352 $ilCtrl->redirect($this,
"showHierarchy");
360 $ilCtrl->redirect($this, $a_return);
371 if (!is_array($items))
374 $ilCtrl->redirect($this,
"showHierarchy");
378 foreach($items as $k => $item)
385 foreach($todel as $k)
393 $ilCtrl->redirect($this,
"showHierarchy");
400 $ilCtrl->redirect($this, $a_return);
412 $ilCtrl->redirect($this,
"showHierarchy");
424 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.structure_edit.html",
"Modules/LearningModule");
427 $this->tpl->setCurrentBlock(
"form");
428 $this->ctrl->setParameter($this,
"backcmd",
"subchap");
429 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
430 $this->tpl->setVariable(
"HEADER_TEXT", $this->lng->txt(
"cont_subchapters"));
434 $childs = $this->tree->getChilds($this->obj->getId());
435 foreach ($childs as $child)
437 if($child[
"type"] !=
"st")
441 $this->tpl->setCurrentBlock(
"table_row");
446 $this->tpl->setVariable(
"CHECKBOX_ID", $child[
"obj_id"]);
447 $this->tpl->setVariable(
"CSS_ROW", $css_row);
451 $this->ctrl->setParameterByClass(
"ilStructureObjectGUI",
"obj_id", $child[
"obj_id"]);
452 $link = $this->ctrl->getLinkTargetByClass(
"ilStructureObjectGUI",
"view");
453 $this->tpl->setVariable(
"LINK_TARGET", $link);
456 $this->tpl->setVariable(
"TEXT_CONTENT",
458 $this->content_object->isActiveNumbering()));
460 $this->tpl->parseCurrentBlock();
464 $this->tpl->setCurrentBlock(
"notfound");
465 $this->tpl->setVariable(
"NUM_COLS", 3);
466 $this->tpl->setVariable(
"TXT_OBJECT_NOT_FOUND", $this->lng->txt(
"obj_not_found"));
467 $this->tpl->parseCurrentBlock();
472 $this->tpl->setVariable(
"NUM_COLS", 3);
473 $acts = array(
"delete" =>
"delete",
"cutChapter" =>
"cut",
474 "copyChapter" =>
"copyChapter");
475 if ($ilUser->clipboardHasObjectsOfType(
"st"))
477 $acts[
"pasteChapter"] =
"pasteChapter";
483 $this->tpl->setVariable(
"NUM_COLS", 3);
485 $subobj = array(
"st");
488 $this->tpl->setCurrentBlock(
"add_object");
489 $this->tpl->setVariable(
"SELECT_OBJTYPE", $opts);
491 $this->tpl->setVariable(
"BTN_NAME",
"create");
492 $this->tpl->setVariable(
"TXT_ADD", $this->lng->txt(
"insert"));
493 $this->tpl->parseCurrentBlock();
498 $this->tpl->setCurrentBlock(
"form");
499 $this->tpl->parseCurrentBlock();
501 $ilCtrl->setParameter($this,
"obj_id",
$_GET[
"obj_id"]);
502 $this->tpl->setVariable(
"HREF_JS_EDIT",
503 $ilCtrl->getLinkTarget($this,
"activateJSChapterEditing"));
504 $this->tpl->setVariable(
"TXT_JS_EDIT",
505 $lng->txt(
"cont_js_chap_editing"));
516 $this->tpl->setCurrentBlock(
"begin_link");
517 $this->tpl->setVariable(
"LINK_TARGET", $link);
518 $this->tpl->parseCurrentBlock();
519 $this->tpl->touchBlock(
"end_link");
522 $this->tpl->setCurrentBlock(
"text");
523 $this->tpl->setVariable(
"TEXT_CONTENT", $val);
524 $this->tpl->parseCurrentBlock();
525 $this->tpl->setCurrentBlock(
"table_cell");
526 $this->tpl->parseCurrentBlock();
538 $this->obj->setType(
"st");
541 $this->obj->setLMId($this->content_object->getId());
542 $this->obj->create();
549 if (!empty(
$_GET[
"obj_id"]))
551 $this->ctrl->redirect($this,
"subchap");
567 $tree =
new ilTree($this->content_object->getId());
568 $tree->setTableNames(
'lm_tree',
'lm_data');
569 $tree->setTreeTablePK(
"lm_id");
572 $parent_id = (!empty(
$_GET[
"obj_id"]))
574 :
$tree->getRootId();
576 $childs =&
$tree->getChildsByType($parent_id,
"pg");
577 if (count($childs) != 0)
579 $_GET[
"target"] = $childs[count($childs) - 1][
"obj_id"];
582 if (empty(
$_GET[
"target"]))
600 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
603 if(count(
$_POST[
"id"]) > 1)
605 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
610 $this->ilias->raiseError($this->lng->txt(
"cont_select_item"), $this->ilias->error_obj->MESSAGE);
616 $tree =
new ilTree($this->content_object->getId());
617 $tree->setTableNames(
'lm_tree',
'lm_data');
618 $tree->setTreeTablePK(
"lm_id");
622 foreach (
$_POST[
"id"] as $id)
630 $obj->setLMId($this->content_object->getId());
631 $node_data =
$tree->getNodeData($id);
633 if(
$tree->isInTree($id))
635 $parent_id =
$tree->getParentId($id);
636 $tree->deleteTree($node_data);
639 require_once(
"./Services/History/classes/class.ilHistory.php");
642 $this->content_object->getType().
":pg");
645 $this->content_object->getType().
":st");
658 $this->ctrl->redirect($this,
"view");
676 if (!$ilUser->clipboardHasObjectsOfType(
"pg"))
678 $this->ilias->raiseError($this->lng->txt(
"no_page_in_clipboard"),$this->ilias->error_obj->MESSAGE);
683 $tree =
new ilTree($this->content_object->getId());
684 $tree->setTableNames(
'lm_tree',
'lm_data');
685 $tree->setTreeTablePK(
"lm_id");
695 == $this->content_object->getID())
698 $new_page =& $lm_page->copy();
699 $id = $new_page->getId();
705 $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
707 $copied_nodes = array();
708 $new_page =& $lm_page->copyToOtherContObject($this->content_object, $copied_nodes);
709 $id = $new_page->getId();
718 != $this->content_object->getID())
721 $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
723 $lm_page->setLMId($this->content_object->getID());
725 $page =& $lm_page->getPageObject();
727 $page->setParentId($this->content_object->getID());
732 if(!
$tree->isInTree($id))
740 $target =
$_POST[
"id"][0];
742 $tree->insertNode($id, $this->obj->getId(), $target);
747 include_once(
"./Services/History/classes/class.ilHistory.php");
748 $parent_id =
$tree->getParentId($id);
751 $this->content_object->getType().
":pg");
754 $this->content_object->getType().
":st");
759 $this->ctrl->redirect($this,
"view");
776 $this->ctrl->redirect($this,
"subchap");
791 $this->ctrl->redirect($this,
"subchap");
805 if($id ==
$_POST[
"id"][0])
815 $this->ctrl->redirect($this,
"subchap");
825 include_once(
"./Services/COPage/classes/class.ilPageObject.php");
826 if (is_array(
$_POST[
"id"]))
828 $act_items = array();
830 foreach(
$_POST[
"id"] as $id)
832 $path = $this->tree->getPathId($id);
834 foreach(
$path as $path_id)
836 if ($path_id != $id && in_array($path_id,
$_POST[
"id"]))
848 foreach($act_items as $id)
850 $childs = $this->tree->getChilds($id);
851 foreach($childs as $child)
856 $this->content_object->getType());
858 $this->content_object->getType(), !$act);
864 $this->content_object->getType());
866 $this->content_object->getType(), !$act);
875 $this->ctrl->redirect($this,
"view");
884 include_once(
"./Services/AccessControl/classes/class.ilConditionHandlerInterface.php");
887 $this->condHI->setBackButtons(array());
888 $this->condHI->setAutomaticValidation(
false);
889 $this->condHI->setTargetType(
"st");
890 $this->condHI->setTargetRefId($this->content_object->getRefId());
891 $this->condHI->setTargetId($this->obj->getId());
892 $this->condHI->setTargetTitle($this->obj->getTitle());
901 if (
$_GET[
"obj_id"] != 0)
903 if (
$_GET[
"new_type"] ==
"pg")
905 $this->ctrl->redirect($this,
"view");
909 $this->ctrl->redirect($this,
"subchap");
922 if ($ilUser->getPref(
"lm_js_chapter_editing") ==
"disable")
925 $ilTabs->addTarget(
"cont_pages",
926 $this->ctrl->getLinkTarget($this,
'view'),
927 "view", get_class($this));
930 $ilTabs->addTarget(
"cont_subchapters",
931 $this->ctrl->getLinkTarget($this,
'subchap'),
932 "subchap", get_class($this));
937 $ilTabs->addTarget(
"cont_pages_and_subchapters",
938 $this->ctrl->getLinkTarget($this,
'showHierarchy'),
939 array(
"view",
"showHierarchy"), get_class($this));
943 $ilTabs->addTarget(
"preconditions",
944 $this->ctrl->getLinkTarget($this,
'listConditions'),
945 "listConditions", get_class($this));
948 $ilTabs->addTarget(
"meta_data",
949 $this->ctrl->getLinkTargetByClass(
"ilmdeditorgui",
''),
950 "",
"ilmdeditorgui");
953 $this->tpl->setTitle(
954 $this->lng->txt($this->obj->getType()).
": ".$this->obj->getTitle());
957 $ilTabs->addNonTabbedLink(
"pres_mode", $lng->txt(
"cont_presentation_view"),
958 ILIAS_HTTP_PATH.
"/goto.php?target=st_".$this->obj->getId(),
"_top");
966 function _goto($a_target, $a_target_ref_id =
"")
977 if (in_array($a_target_ref_id, $ref_ids))
979 $ref_ids = array_merge(array($a_target_ref_id), $ref_ids);
986 if ($ilAccess->checkAccess(
"read",
"", $ref_id))
990 $_GET[
"baseClass"] =
"ilLMPresentationGUI";
991 $_GET[
"obj_id"] = $a_target;
993 include_once(
"ilias.php");
998 if ($ilAccess->checkAccess(
"read",
"", ROOT_FOLDER_ID))
1002 include_once(
"./Services/Object/classes/class.ilObjectGUI.php");
1006 $ilErr->raiseError($lng->txt(
"msg_no_perm_read_lm"), $ilErr->FATAL);
1016 include_once(
"./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
1025 $parent_id = $node_id;
1030 $ilCtrl->redirect($this,
"showHierarchy");
1038 $parent_id = $this->tree->getParentId($node_id);
1043 $parent_id = $node_id;
1047 for ($i = 1; $i <= $num; $i++)
1050 $chap->setType(
"st");
1051 $chap->setTitle($lng->txt(
"cont_new_chap"));
1052 $chap->setLMId($this->content_object->getId());
1057 $ilCtrl->redirect($this,
"view");
1077 $ilLog->write(
"Insert Chapter From Clipboard");
1079 include_once(
"./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
1081 if ($ilUser->getPref(
"lm_js_chapter_editing") !=
"disable")
1091 $node_id = $this->obj->getId();
1092 $first_child =
true;
1096 $node_id =
$_POST[
"id"][0];
1097 $first_child =
false;
1105 $parent_id = $node_id;
1110 $ilCtrl->redirect($this,
"showHierarchy");
1118 $parent_id = $this->tree->getParentId($node_id);
1123 $parent_id = $node_id;
1127 $childs = $this->tree->getChildsByType($parent_id,
"pg");
1128 if (count($childs) != 0)
1130 $target = $childs[count($childs) - 1][
"obj_id"];
1136 $chapters = $ilUser->getClipboardObjects(
"st",
true);
1137 $copied_nodes = array();
1139 foreach ($chapters as $chap)
1141 $ilLog->write(
"Call pasteTree, Target LM: ".$this->content_object->getId().
", Chapter ID: ".$chap[
"id"]
1142 .
", Parent ID: ".$parent_id.
", Target: ".$target);
1144 $target, $chap[
"insert_time"], $copied_nodes,
1152 $ilUser->clipboardDeleteObjectsOfType(
"pg");
1153 $ilUser->clipboardDeleteObjectsOfType(
"st");
1157 $this->content_object->checkTree();
1158 $ilCtrl->redirect($this, $a_return);
1176 include_once(
"./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
1183 $parent_id = $this->tree->getParentId($node_id);
1188 $parent_id = $node_id;
1192 for ($i = 1; $i <= $num; $i++)
1195 $page->setType(
"pg");
1196 $page->setTitle($lng->txt(
"cont_new_page"));
1197 $page->setLMId($this->content_object->getId());
1202 $ilCtrl->redirect($this,
"showHierarchy");
1212 include_once(
"./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
1214 if ($ilUser->getPref(
"lm_js_chapter_editing") !=
"disable")
1224 $node_id = $this->obj->getId();
1225 $first_child =
true;
1229 $node_id =
$_POST[
"id"][0];
1230 $first_child =
false;
1236 $parent_id = $this->tree->getParentId($node_id);
1241 $parent_id = $node_id;
1246 $pages = $ilUser->getClipboardObjects(
"pg");
1247 $copied_nodes = array();
1248 foreach ($pages as $pg)
1251 $pg[
"insert_time"], $copied_nodes,
1259 $ilUser->clipboardDeleteObjectsOfType(
"pg");
1260 $ilUser->clipboardDeleteObjectsOfType(
"st");
1264 $ilCtrl->redirect($this,
"view");
1276 $this->content_object->executeDragDrop(
$_POST[
"il_hform_source_id"],
$_POST[
"il_hform_target_id"],
1278 $ilCtrl->redirect($this,
"showHierarchy");
1292 if (!is_array(
$_POST[
"id"]))
1295 $ilCtrl->redirect($this,
"showHierarchy");
1300 $tpl->setContent($this->form->getHTML());
1310 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
1313 if (is_array(
$_POST[
"id"]))
1315 foreach (
$_POST[
"id"] as $id)
1319 $this->form->addItem($hi);
1323 $this->content_object->getLayout());
1325 $this->form->addItem($layout);
1327 $this->form->addCommandButton(
"savePageLayout", $lng->txt(
"save"));
1328 $this->form->addCommandButton(
"showHierarchy", $lng->txt(
"cancel"));
1330 $this->form->setTitle($lng->txt(
"cont_set_layout"));
1331 $this->form->setFormAction($ilCtrl->getFormAction($this));
1342 foreach (
$_POST[
"id"] as $id)
1347 $this->content_object);
1350 $ilCtrl->redirect($this,
"showHierarchy");