00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00038 require_once("classes/class.ilObjectGUI.php");
00039 require_once("content/classes/class.ilObjFileBasedLM.php");
00040 require_once("classes/class.ilTableGUI.php");
00041 require_once("classes/class.ilFileSystemGUI.php");
00042
00043 class ilObjFileBasedLMGUI extends ilObjectGUI
00044 {
00045 var $output_prepared;
00046
00052 function ilObjFileBasedLMGUI($a_data,$a_id = 0,$a_call_by_reference = true, $a_prepare_output = true)
00053 {
00054 global $lng, $ilCtrl;
00055
00056 $this->ctrl =& $ilCtrl;
00057 $this->ctrl->saveParameter($this, array("ref_id"));
00058
00059 include_once("classes/class.ilTabsGUI.php");
00060 $this->tabs_gui =& new ilTabsGUI();
00061
00062 $this->type = "htlm";
00063 $lng->loadLanguageModule("content");
00064
00065 parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
00066
00067 $this->output_prepared = $a_prepare_output;
00068
00069 if (defined("ILIAS_MODULE"))
00070 {
00071 $this->setTabTargetScript("fblm_edit.php");
00072 }
00073 }
00074
00078 function executeCommand()
00079 {
00080 $fs_gui =& new ilFileSystemGUI($this->object->getDataDirectory());
00081 $fs_gui->getTabs($this->tabs_gui);
00082 $this->getTemplate();
00083 $this->setLocator();
00084 $this->setTabs();
00085
00086 $next_class = $this->ctrl->getNextClass($this);
00087 $cmd = $this->ctrl->getCmd();
00088
00089 switch($next_class)
00090 {
00091 case "ilfilesystemgui":
00092
00093 $fs_gui->activateLabels(true, $this->lng->txt("cont_purpose"));
00094 if ($this->object->getStartFile() != "")
00095 {
00096 $fs_gui->labelFile($this->object->getStartFile(),
00097 $this->lng->txt("cont_startfile"));
00098 }
00099 $fs_gui->addCommand($this, "setStartFile", $this->lng->txt("cont_set_start_file"));
00100
00101 $ret =& $this->ctrl->forwardCommand($fs_gui);
00102 break;
00103
00104 default:
00105 $cmd = $this->ctrl->getCmd("frameset");
00106 $ret =& $this->$cmd();
00107 break;
00108 }
00109 $this->tpl->show();
00110 }
00111
00112
00118 function properties()
00119 {
00120 global $rbacsystem, $tree, $tpl;
00121
00122
00123 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00124
00125
00126 $this->tpl->setCurrentBlock("btn_cell");
00127 $this->tpl->setVariable("BTN_LINK", "fblm_presentation.php?ref_id=".$this->object->getRefID());
00128 $this->tpl->setVariable("BTN_TARGET"," target=\"ilContObj".$this->object->getID()."\" ");
00129 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
00130 $this->tpl->parseCurrentBlock();
00131
00132
00133 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.fblm_properties.html", true);
00134 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00135 $this->tpl->setVariable("TXT_PROPERTIES", $this->lng->txt("cont_lm_properties"));
00136
00137
00138 $this->tpl->setVariable("TXT_ONLINE", $this->lng->txt("cont_online"));
00139 $this->tpl->setVariable("CBOX_ONLINE", "cobj_online");
00140 $this->tpl->setVariable("VAL_ONLINE", "y");
00141 if ($this->object->getOnline())
00142 {
00143 $this->tpl->setVariable("CHK_ONLINE", "checked");
00144 }
00145
00146
00147 $this->tpl->setVariable("TXT_START_FILE", $this->lng->txt("cont_startfile"));
00148 $this->tpl->setVariable("VAL_START_FILE", $this->object->getStartFile());
00149 $this->tpl->setVariable("TXT_SET_START_FILE", $this->lng->txt("cont_set_start_file"));
00150 $this->tpl->setVariable("LINK_SET_START_FILE",
00151 $this->ctrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"));
00152
00153 $this->tpl->setCurrentBlock("commands");
00154 $this->tpl->setVariable("BTN_NAME", "saveProperties");
00155 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00156 $this->tpl->parseCurrentBlock();
00157
00158 }
00159
00163 function saveProperties()
00164 {
00165 $this->object->setOnline(ilUtil::yn2tf($_POST["cobj_online"]));
00166 $this->object->update();
00167 sendInfo($this->lng->txt("msg_obj_modified"), true);
00168 $this->ctrl->redirect($this, "properties");
00169 }
00170
00171
00176 function saveObject()
00177 {
00178 global $rbacadmin;
00179
00180
00181 $newObj = parent::saveObject();
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192 sendInfo($this->lng->txt("object_added"),true);
00193
00194 ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
00195 }
00196
00202 function editObject()
00203 {
00204 global $rbacsystem, $tree, $tpl;
00205
00206 if (!$rbacsystem->checkAccess("visible,write",$this->object->getRefId()))
00207 {
00208 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00209 }
00210
00211
00212 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00213
00214 if (!defined("ILIAS_MODULE"))
00215 {
00216 $this->tpl->setCurrentBlock("btn_cell");
00217 $this->tpl->setVariable("BTN_LINK","content/fblm_edit.php?ref_id=".$this->object->getRefID());
00218 $this->tpl->setVariable("BTN_TARGET"," target=\"bottom\" ");
00219 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("edit"));
00220 $this->tpl->parseCurrentBlock();
00221 }
00222
00223
00224 }
00225
00229 function edit()
00230 {
00231 $this->prepareOutput();
00232 $this->setFormAction("update", "fblm_edit.php?cmd=post&ref_id=".$_GET["ref_id"].
00233 "&obj_id=".$_GET["obj_id"]);
00234 $this->editObject();
00235 $this->tpl->show();
00236 }
00237
00241 function cancel()
00242 {
00243 $this->setReturnLocation("cancel","fblm_edit.php?cmd=listFiles&ref_id=".$_GET["ref_id"]);
00244 $this->cancelObject();
00245 }
00246
00250 function update()
00251 {
00252 $this->setReturnLocation("update", "fblm_edit.php?cmd=listFiles&ref_id=".$_GET["ref_id"].
00253 "&obj_id=".$_GET["obj_id"]);
00254 $this->updateObject();
00255 }
00256
00257
00258 function setStartFile($a_file)
00259 {
00260 $this->object->setStartFile($a_file);
00261 $this->object->update();
00262 $this->ctrl->redirectByClass("ilfilesystemgui", "listFiles");
00263 }
00264
00268 function perm()
00269 {
00270 $this->setFormAction("permSave", "fblm_edit.php?cmd=permSave&ref_id=".$_GET["ref_id"].
00271 "&obj_id=".$_GET["obj_id"]);
00272 $this->setFormAction("addRole", "fblm_edit.php?ref_id=".$_GET["ref_id"].
00273 "&obj_id=".$_GET["obj_id"]."&cmd=addRole");
00274 $this->permObject();
00275 }
00276
00280 function permSave()
00281 {
00282 $this->setReturnLocation("permSave",
00283 "fblm_edit.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]."&cmd=perm");
00284 $this->permSaveObject();
00285 }
00286
00290 function addRole()
00291 {
00292 $this->setReturnLocation("addRole",
00293 "fblm_edit.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]."&cmd=perm");
00294 $this->addRoleObject();
00295 }
00296
00300 function owner()
00301 {
00302 $this->ownerObject();
00303 }
00304
00309 function chooseMetaSectionObject($a_target = "")
00310 {
00311 if ($a_target == "")
00312 {
00313 $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00314 }
00315
00316 include_once "classes/class.ilMetaDataGUI.php";
00317 $meta_gui =& new ilMetaDataGUI();
00318 $meta_gui->setObject($this->object);
00319 $meta_gui->edit("ADM_CONTENT", "adm_content",
00320 $a_target, $_REQUEST["meta_section"]);
00321 }
00322
00327 function chooseMetaSection()
00328 {
00329
00330 $this->chooseMetaSectionObject($this->ctrl->getLinkTarget($this));
00331 }
00332
00337 function addMetaObject($a_target = "")
00338 {
00339 if ($a_target == "")
00340 {
00341 $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00342 }
00343
00344 include_once "classes/class.ilMetaDataGUI.php";
00345 $meta_gui =& new ilMetaDataGUI();
00346 $meta_gui->setObject($this->object);
00347 $meta_name = $_POST["meta_name"] ? $_POST["meta_name"] : $_GET["meta_name"];
00348 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
00349 if ($meta_index == "")
00350 $meta_index = 0;
00351 $meta_path = $_POST["meta_path"] ? $_POST["meta_path"] : $_GET["meta_path"];
00352 $meta_section = $_POST["meta_section"] ? $_POST["meta_section"] : $_GET["meta_section"];
00353 if ($meta_name != "")
00354 {
00355 $meta_gui->meta_obj->add($meta_name, $meta_path, $meta_index);
00356 }
00357 else
00358 {
00359 sendInfo($this->lng->txt("meta_choose_element"), true);
00360 }
00361 $meta_gui->edit("ADM_CONTENT", "adm_content", $a_target, $meta_section);
00362 }
00363
00368 function addMeta()
00369 {
00370 $this->addMetaObject($this->ctrl->getLinkTarget($this));
00371 }
00372
00373
00378 function deleteMetaObject($a_target = "")
00379 {
00380 if ($a_target == "")
00381 {
00382 $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00383 }
00384
00385 include_once "classes/class.ilMetaDataGUI.php";
00386 $meta_gui =& new ilMetaDataGUI();
00387 $meta_gui->setObject($this->object);
00388 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
00389 $meta_gui->meta_obj->delete($_GET["meta_name"], $_GET["meta_path"], $meta_index);
00390 $meta_gui->edit("ADM_CONTENT", "adm_content", $a_target, $_GET["meta_section"]);
00391 }
00392
00397 function deleteMeta()
00398 {
00399 $this->deleteMetaObject($this->ctrl->getLinkTarget($this));
00400 }
00401
00406 function editMetaObject($a_target = "")
00407 {
00408 if ($a_target == "")
00409 {
00410 $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00411 }
00412
00413 include_once "classes/class.ilMetaDataGUI.php";
00414 $meta_gui =& new ilMetaDataGUI();
00415 $meta_gui->setObject($this->object);
00416 $meta_gui->edit("ADM_CONTENT", "adm_content", $a_target, $_GET["meta_section"]);
00417 }
00418
00423 function editMeta()
00424 {
00425 $this->editMetaObject($this->ctrl->getLinkTarget($this));
00426 }
00427
00432 function saveMetaObject($a_target = "")
00433 {
00434 if ($a_target == "")
00435 {
00436 $a_target = "adm_object.php?cmd=editMeta&ref_id=".$this->object->getRefId();
00437 }
00438
00439 include_once "classes/class.ilMetaDataGUI.php";
00440 $meta_gui =& new ilMetaDataGUI();
00441 $meta_gui->setObject($this->object);
00442 $meta_gui->save($_POST["meta_section"]);
00443 ilUtil::redirect(ilUtil::appendUrlParameterString($a_target,
00444 "meta_section=" . $_POST["meta_section"]));
00445 }
00446
00451 function saveMeta()
00452 {
00453 $this->saveMetaObject($this->ctrl->getLinkTarget($this, "editMeta"));
00454 }
00455
00459 function saveBibItemObject($a_target = "")
00460 {
00461 include_once "content/classes/class.ilBibItemGUI.php";
00462 $bib_gui =& new ilBibItemGUI();
00463 $bib_gui->setObject($this->object);
00464 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
00465 $bibItemIndex *= 1;
00466 if ($bibItemIndex < 0)
00467 {
00468 $bibItemIndex = 0;
00469 }
00470 $bibItemIndex = $bib_gui->save($bibItemIndex);
00471
00472 if ($a_target == "")
00473 {
00474 $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
00475 }
00476
00477 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
00478 }
00479
00483 function saveBibItem()
00484 {
00485
00486 $this->saveBibItemObject($this->ctrl->getLinkTarget($this));
00487 }
00488
00492 function editBibItemObject($a_target = "")
00493 {
00494 include_once "content/classes/class.ilBibItemGUI.php";
00495 $bib_gui =& new ilBibItemGUI();
00496 $bib_gui->setObject($this->object);
00497 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
00498 $bibItemIndex *= 1;
00499 if ($bibItemIndex < 0)
00500 {
00501 $bibItemIndex = 0;
00502 }
00503 if ($a_target == "")
00504 {
00505 $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
00506 }
00507
00508 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
00509 }
00510
00514 function editBibItem()
00515 {
00516
00517 $this->editBibItemObject($this->ctrl->getLinkTarget($this));
00518 }
00519
00523 function deleteBibItemObject($a_target = "")
00524 {
00525 include_once "content/classes/class.ilBibItemGUI.php";
00526 $bib_gui =& new ilBibItemGUI();
00527 $bib_gui->setObject($this->object);
00528 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
00529 $bib_gui->bib_obj->delete($_GET["bibItemName"], $_GET["bibItemPath"], $bibItemIndex);
00530 if (strpos($bibItemIndex, ",") > 0)
00531 {
00532 $bibItemIndex = substr($bibItemIndex, 0, strpos($bibItemIndex, ","));
00533 }
00534 if ($a_target == "")
00535 {
00536 $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
00537 }
00538
00539 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
00540 }
00541
00545 function deleteBibItem()
00546 {
00547
00548 $this->deleteBibItemObject($this->ctrl->getLinkTarget($this));
00549 }
00550
00554 function addBibItemObject($a_target = "")
00555 {
00556 $bibItemName = $_POST["bibItemName"] ? $_POST["bibItemName"] : $_GET["bibItemName"];
00557 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
00558 if ($bibItemName == "BibItem")
00559 {
00560 include_once "content/classes/class.ilBibItem.php";
00561 $bib_item =& new ilBibItem();
00562 $bib_item->setId($this->object->getId());
00563 $bib_item->setType($this->object->getType());
00564 $bib_item->read();
00565 }
00566
00567 include_once "content/classes/class.ilBibItemGUI.php";
00568 $bib_gui =& new ilBibItemGUI();
00569 $bib_gui->setObject($this->object);
00570 if ($bibItemIndex == "")
00571 $bibItemIndex = 0;
00572 $bibItemPath = $_POST["bibItemPath"] ? $_POST["bibItemPath"] : $_GET["bibItemPath"];
00573
00574
00575 if ($bibItemName != "")
00576 {
00577 $bib_gui->bib_obj->add($bibItemName, $bibItemPath, $bibItemIndex);
00578 $data = $bib_gui->bib_obj->getElement("BibItem");
00579 $bibItemIndex = (count($data) - 1);
00580 }
00581 else
00582 {
00583 sendInfo($this->lng->txt("bibitem_choose_element"), true);
00584 }
00585 if ($a_target == "")
00586 {
00587 $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
00588 }
00589
00590 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
00591 }
00592
00596 function addBibItem()
00597 {
00598
00599 $this->addBibItemObject($this->ctrl->getLinkTarget($this));
00600 }
00601
00607 function frameset()
00608 {
00609 $this->tpl = new ilTemplate("tpl.fblm_edit_frameset.html", false, false, "content");
00610 $this->tpl->setVariable("HREF_FILES",$this->ctrl->getLinkTargetByClass(
00611 "ilfilesystemgui", "listFiles"));
00612 $this->tpl->show();
00613 }
00614
00618 function explorer()
00619 {
00620 $this->tpl = new ilTemplate("tpl.main.html", true, true);
00621
00622 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00623
00624 $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
00625
00626 require_once ("content/classes/class.ilFileExplorer.php");
00627 $exp = new ilFileExplorer($this->lm->getDataDirectory());
00628
00629 }
00630
00631
00635 function setLocator($a_tree = "", $a_id = "", $scriptname="adm_object.php")
00636 {
00637 global $ilias_locator, $tree;
00638 if (!defined("ILIAS_MODULE"))
00639 {
00640 parent::setLocator();
00641 }
00642 else
00643 {
00644 $a_tree =& $tree;
00645 $a_id = $_GET["ref_id"];
00646
00647 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00648
00649 $path = $a_tree->getPathFull($a_id);
00650
00651
00652 $modifier = 1;
00653
00654 if (!empty($_GET["obj_id"]))
00655 {
00656 $modifier = 0;
00657 }
00658
00659
00660 $i = 1;
00661
00662 if ($this->object->getType() != "grp" && ($_GET["cmd"] == "delete" || $_GET["cmd"] == "edit"))
00663 {
00664 unset($path[count($path) - 1]);
00665 }
00666
00667 foreach ($path as $key => $row)
00668 {
00669
00670 if ($key < count($path) - $modifier)
00671 {
00672 $this->tpl->touchBlock("locator_separator");
00673 }
00674
00675 $this->tpl->setCurrentBlock("locator_item");
00676 if ($row["child"] != $a_tree->getRootId())
00677 {
00678 $this->tpl->setVariable("ITEM", $row["title"]);
00679 }
00680 else
00681 {
00682 $this->tpl->setVariable("ITEM", $this->lng->txt("repository"));
00683 }
00684 if($row["type"] == "htlm")
00685 {
00686 $this->tpl->setVariable("LINK_ITEM", "fblm_edit.php?ref_id=".$row["child"]);
00687 }
00688 else
00689 {
00690 $this->tpl->setVariable("LINK_ITEM", "../repository.php?cmd=frameset&ref_id=".$row["child"]);
00691 $t_frame = ilFrameTargetInfo::_getFrame("MainContent");
00692 $this->tpl->setVariable("LINK_TARGET", " target=\"$t_frame\" ");
00693 }
00694
00695 $this->tpl->parseCurrentBlock();
00696
00697 $this->tpl->setCurrentBlock("locator");
00698
00699
00700
00701 if ($row["child"] != $a_tree->getRootId())
00702 {
00703 $ilias_locator->navigate($i++,$row["title"],"../repository.php?ref_id=".$row["child"],"bottom");
00704 }
00705 else
00706 {
00707 $ilias_locator->navigate($i++,$this->lng->txt("repository"),"../repository.php?ref_id=".$row["child"],"bottom");
00708 }
00709 }
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724 $this->tpl->setVariable("TXT_LOCATOR",$debug.$this->lng->txt("locator"));
00725 $this->tpl->parseCurrentBlock();
00726 }
00727
00728 }
00729
00733 function getTemplate()
00734 {
00735 global $lng;
00736
00737 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00738
00739 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00740
00741 }
00742
00743 function showLearningModule()
00744 {
00745 $dir = $this->object->getDataDirectory();
00746 if (($this->object->getStartFile() != "") &&
00747 (@is_file($dir."/".$this->object->getStartFile())))
00748 {
00749 ilUtil::redirect("../".$dir."/".$this->object->getStartFile());
00750 }
00751 else if (@is_file($dir."/index.html"))
00752 {
00753 ilUtil::redirect("../".$dir."/index.html");
00754 }
00755 else if (@is_file($dir."/index.htm"))
00756 {
00757 ilUtil::redirect("../".$dir."/index.htm");
00758 }
00759 }
00760
00764 function setTabs()
00765 {
00766 $this->getTabs($this->tabs_gui);
00767 $this->tpl->setVariable("TABS", $this->tabs_gui->getHTML());
00768 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00769 }
00770
00776 function getTabs(&$tabs_gui)
00777 {
00778
00779 $tabs_gui->addTarget("properties",
00780 $this->ctrl->getLinkTarget($this, "properties"), "properties",
00781 get_class($this));
00782
00783
00784 $tabs_gui->addTarget("meta_data",
00785 $this->ctrl->getLinkTarget($this, "editMeta"), "editMeta",
00786 get_class($this));
00787
00788
00789
00790 $tabs_gui->addTarget("bib_data",
00791 $this->ctrl->getLinkTarget($this, "editBibItem"), "editBibItem",
00792 get_class($this));
00793
00794
00795 $tabs_gui->addTarget("perm_settings",
00796 $this->ctrl->getLinkTarget($this, "perm"), "perm",
00797 get_class($this));
00798
00799
00800 $tabs_gui->addTarget("owner",
00801 $this->ctrl->getLinkTarget($this, "owner"), "owner",
00802 get_class($this));
00803 }
00804
00805
00806 }
00807 ?>