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, false);
00066
00067 $this->output_prepared = $a_prepare_output;
00068
00069 }
00070
00074 function &executeCommand()
00075 {
00076 if (strtolower($_GET["baseClass"]) == "iladministrationgui" ||
00077 $this->getCreationMode() == true)
00078 {
00079 $this->prepareOutput();
00080 }
00081 else
00082 {
00083 $this->getTemplate();
00084 $this->setLocator();
00085 $this->setTabs();
00086 }
00087
00088 $next_class = $this->ctrl->getNextClass($this);
00089 $cmd = $this->ctrl->getCmd();
00090
00091 switch($next_class)
00092 {
00093 case 'ilmdeditorgui':
00094
00095 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00096
00097 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00098 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00099
00100 $this->ctrl->forwardCommand($md_gui);
00101 break;
00102
00103 case "ilfilesystemgui":
00104 $fs_gui =& new ilFileSystemGUI($this->object->getDataDirectory());
00105
00106 $fs_gui->activateLabels(true, $this->lng->txt("cont_purpose"));
00107 if ($this->object->getStartFile() != "")
00108 {
00109 $fs_gui->labelFile($this->object->getStartFile(),
00110 $this->lng->txt("cont_startfile"));
00111 }
00112 $fs_gui->addCommand($this, "setStartFile", $this->lng->txt("cont_set_start_file"));
00113
00114 $ret =& $this->ctrl->forwardCommand($fs_gui);
00115 break;
00116
00117 case 'ilpermissiongui':
00118 include_once("./classes/class.ilPermissionGUI.php");
00119 $perm_gui =& new ilPermissionGUI($this);
00120 $ret =& $this->ctrl->forwardCommand($perm_gui);
00121 break;
00122
00123 default:
00124 $cmd = $this->ctrl->getCmd("frameset");
00125 if (strtolower($_GET["baseClass"]) == "iladministrationgui" ||
00126 $this->getCreationMode() == true)
00127 {
00128 $cmd.= "Object";
00129 }
00130 $ret =& $this->$cmd();
00131 break;
00132 }
00133
00134 }
00135
00141 function createObject()
00142 {
00143 global $rbacsystem;
00144
00145 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
00146
00147 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
00148 {
00149 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00150 }
00151 else
00152 {
00153
00154 $data = array();
00155 $data["fields"] = array();
00156 $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
00157 $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
00158
00159 $this->getTemplateFile("edit",$new_type);
00160
00161 foreach ($data["fields"] as $key => $val)
00162 {
00163 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
00164 $this->tpl->setVariable(strtoupper($key), $val);
00165
00166 if ($this->prepare_output)
00167 {
00168 $this->tpl->parseCurrentBlock();
00169 }
00170 }
00171
00172 $this->ctrl->setParameter($this, "new_type", $new_type);
00173 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00174
00175
00176 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
00177 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00178 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
00179 $this->tpl->setVariable("CMD_SUBMIT", "save");
00180 $this->tpl->setVariable("TARGET", ' target="'.
00181 ilFrameTargetInfo::_getFrame("MainContent").'" ');
00182 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00183 }
00184 }
00185
00186
00192 function properties()
00193 {
00194 global $rbacsystem, $tree, $tpl;
00195
00196
00197 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00198
00199
00200 $this->tpl->setCurrentBlock("btn_cell");
00201 $this->tpl->setVariable("BTN_LINK", "fblm_presentation.php?ref_id=".$this->object->getRefID());
00202 $this->tpl->setVariable("BTN_TARGET"," target=\"ilContObj".$this->object->getID()."\" ");
00203 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
00204 $this->tpl->parseCurrentBlock();
00205
00206
00207 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.fblm_properties.html", true);
00208 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00209 $this->tpl->setVariable("TXT_PROPERTIES", $this->lng->txt("cont_lm_properties"));
00210
00211
00212 $this->tpl->setVariable("TXT_ONLINE", $this->lng->txt("cont_online"));
00213 $this->tpl->setVariable("CBOX_ONLINE", "cobj_online");
00214 $this->tpl->setVariable("VAL_ONLINE", "y");
00215 if ($this->object->getOnline())
00216 {
00217 $this->tpl->setVariable("CHK_ONLINE", "checked");
00218 }
00219
00220
00221 $this->tpl->setVariable("TXT_START_FILE", $this->lng->txt("cont_startfile"));
00222 $this->tpl->setVariable("VAL_START_FILE", $this->object->getStartFile());
00223 $this->tpl->setVariable("TXT_SET_START_FILE", $this->lng->txt("cont_set_start_file"));
00224 $this->tpl->setVariable("LINK_SET_START_FILE",
00225 $this->ctrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"));
00226
00227 $this->tpl->setCurrentBlock("commands");
00228 $this->tpl->setVariable("BTN_NAME", "saveProperties");
00229 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00230 $this->tpl->parseCurrentBlock();
00231
00232 }
00233
00237 function saveProperties()
00238 {
00239 $this->object->setOnline(ilUtil::yn2tf($_POST["cobj_online"]));
00240 $this->object->update();
00241 sendInfo($this->lng->txt("msg_obj_modified"), true);
00242 $this->ctrl->redirect($this, "properties");
00243 }
00244
00245
00250 function saveObject()
00251 {
00252 global $rbacadmin;
00253
00254
00255 $newObj = parent::saveObject();
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266 sendInfo($this->lng->txt("object_added"),true);
00267 ilUtil::redirect("content/fblm_edit.php?ref_id=".$newObj->getRefId());
00268
00269
00270 }
00271
00277 function editObject()
00278 {
00279 global $rbacsystem, $tree, $tpl;
00280
00281 if (!$rbacsystem->checkAccess("visible,write",$this->object->getRefId()))
00282 {
00283 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00284 }
00285
00286
00287 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00288
00289 if (!defined("ILIAS_MODULE"))
00290 {
00291 $this->tpl->setCurrentBlock("btn_cell");
00292 $this->tpl->setVariable("BTN_LINK","content/fblm_edit.php?ref_id=".$this->object->getRefID());
00293 $this->tpl->setVariable("BTN_TARGET"," target=\"bottom\" ");
00294 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("edit"));
00295 $this->tpl->parseCurrentBlock();
00296 }
00297
00298
00299 }
00300
00304 function edit()
00305 {
00306 $this->prepareOutput();
00307 $this->setFormAction("update", "fblm_edit.php?cmd=post&ref_id=".$_GET["ref_id"].
00308 "&obj_id=".$_GET["obj_id"]);
00309 $this->editObject();
00310
00311 }
00312
00316 function cancel()
00317 {
00318 $this->setReturnLocation("cancel","fblm_edit.php?cmd=listFiles&ref_id=".$_GET["ref_id"]);
00319 $this->cancelObject();
00320 }
00321
00327 function cancelObject($in_rep = false)
00328 {
00329 sendInfo($this->lng->txt("msg_cancel"),true);
00330 ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
00331
00332 }
00333
00334
00338 function update()
00339 {
00340 $this->setReturnLocation("update", "fblm_edit.php?cmd=listFiles&ref_id=".$_GET["ref_id"].
00341 "&obj_id=".$_GET["obj_id"]);
00342 $this->updateObject();
00343 }
00344
00345
00346 function setStartFile($a_file)
00347 {
00348 $this->object->setStartFile($a_file);
00349 $this->object->update();
00350 $this->ctrl->redirectByClass("ilfilesystemgui", "listFiles");
00351 }
00352
00356 function perm()
00357 {
00358 $this->setFormAction("permSave", "fblm_edit.php?cmd=permSave&ref_id=".$_GET["ref_id"].
00359 "&obj_id=".$_GET["obj_id"]);
00360 $this->setFormAction("addRole", "fblm_edit.php?ref_id=".$_GET["ref_id"].
00361 "&obj_id=".$_GET["obj_id"]."&cmd=addRole");
00362 $this->permObject();
00363 }
00364
00368 function info()
00369 {
00370 $this->infoObject();
00371 }
00372
00376 function permSave()
00377 {
00378 $this->setReturnLocation("permSave",
00379 "fblm_edit.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]."&cmd=perm");
00380 $this->permSaveObject();
00381 }
00382
00386 function addRole()
00387 {
00388 $this->setReturnLocation("addRole",
00389 "fblm_edit.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]."&cmd=perm");
00390 $this->addRoleObject();
00391 }
00392
00396 function owner()
00397 {
00398 $this->ownerObject();
00399 }
00400
00404 function saveBibItemObject($a_target = "")
00405 {
00406 include_once "content/classes/class.ilBibItemGUI.php";
00407 $bib_gui =& new ilBibItemGUI();
00408 $bib_gui->setObject($this->object);
00409 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
00410 $bibItemIndex *= 1;
00411 if ($bibItemIndex < 0)
00412 {
00413 $bibItemIndex = 0;
00414 }
00415 $bibItemIndex = $bib_gui->save($bibItemIndex);
00416
00417 if ($a_target == "")
00418 {
00419 $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
00420 }
00421
00422 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
00423 }
00424
00428 function saveBibItem()
00429 {
00430
00431 $this->saveBibItemObject($this->ctrl->getLinkTarget($this));
00432 }
00433
00437 function editBibItemObject($a_target = "")
00438 {
00439 include_once "content/classes/class.ilBibItemGUI.php";
00440 $bib_gui =& new ilBibItemGUI();
00441 $bib_gui->setObject($this->object);
00442 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
00443 $bibItemIndex *= 1;
00444 if ($bibItemIndex < 0)
00445 {
00446 $bibItemIndex = 0;
00447 }
00448 if ($a_target == "")
00449 {
00450 $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
00451 }
00452
00453 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
00454 }
00455
00459 function editBibItem()
00460 {
00461
00462 $this->editBibItemObject($this->ctrl->getLinkTarget($this));
00463 }
00464
00468 function deleteBibItemObject($a_target = "")
00469 {
00470 include_once "content/classes/class.ilBibItemGUI.php";
00471 $bib_gui =& new ilBibItemGUI();
00472 $bib_gui->setObject($this->object);
00473 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
00474 $bib_gui->bib_obj->delete($_GET["bibItemName"], $_GET["bibItemPath"], $bibItemIndex);
00475 if (strpos($bibItemIndex, ",") > 0)
00476 {
00477 $bibItemIndex = substr($bibItemIndex, 0, strpos($bibItemIndex, ","));
00478 }
00479 if ($a_target == "")
00480 {
00481 $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
00482 }
00483
00484 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
00485 }
00486
00490 function deleteBibItem()
00491 {
00492
00493 $this->deleteBibItemObject($this->ctrl->getLinkTarget($this));
00494 }
00495
00499 function addBibItemObject($a_target = "")
00500 {
00501 $bibItemName = $_POST["bibItemName"] ? $_POST["bibItemName"] : $_GET["bibItemName"];
00502 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
00503 if ($bibItemName == "BibItem")
00504 {
00505 include_once "content/classes/class.ilBibItem.php";
00506 $bib_item =& new ilBibItem();
00507 $bib_item->setId($this->object->getId());
00508 $bib_item->setType($this->object->getType());
00509 $bib_item->read();
00510 }
00511
00512 include_once "content/classes/class.ilBibItemGUI.php";
00513 $bib_gui =& new ilBibItemGUI();
00514 $bib_gui->setObject($this->object);
00515 if ($bibItemIndex == "")
00516 $bibItemIndex = 0;
00517 $bibItemPath = $_POST["bibItemPath"] ? $_POST["bibItemPath"] : $_GET["bibItemPath"];
00518
00519
00520 if ($bibItemName != "")
00521 {
00522 $bib_gui->bib_obj->add($bibItemName, $bibItemPath, $bibItemIndex);
00523 $data = $bib_gui->bib_obj->getElement("BibItem");
00524 $bibItemIndex = (count($data) - 1);
00525 }
00526 else
00527 {
00528 sendInfo($this->lng->txt("bibitem_choose_element"), true);
00529 }
00530 if ($a_target == "")
00531 {
00532 $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
00533 }
00534
00535 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
00536 }
00537
00541 function addBibItem()
00542 {
00543
00544 $this->addBibItemObject($this->ctrl->getLinkTarget($this));
00545 }
00546
00552 function frameset()
00553 {
00554 $this->tpl = new ilTemplate("tpl.fblm_edit_frameset.html", false, false, "content");
00555 $this->tpl->setVariable("HREF_FILES",$this->ctrl->getLinkTargetByClass(
00556 "ilfilesystemgui", "listFiles"));
00557 $this->tpl->show();
00558 exit;
00559 }
00560
00564 function explorer()
00565 {
00566 $this->tpl = new ilTemplate("tpl.main.html", true, true);
00567
00568 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00569
00570 $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
00571
00572 require_once ("content/classes/class.ilFileExplorer.php");
00573 $exp = new ilFileExplorer($this->lm->getDataDirectory());
00574
00575 }
00576
00577
00581 function setLocator($a_tree = "", $a_id = "", $scriptname="adm_object.php")
00582 {
00583 global $ilias_locator, $tree;
00584 if (!defined("ILIAS_MODULE"))
00585 {
00586 parent::setLocator();
00587 }
00588 else
00589 {
00590 $a_tree =& $tree;
00591 $a_id = $_GET["ref_id"];
00592
00593 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00594
00595 $path = $a_tree->getPathFull($a_id);
00596
00597
00598 $modifier = 1;
00599
00600 if (!empty($_GET["obj_id"]))
00601 {
00602 $modifier = 0;
00603 }
00604
00605
00606 $i = 1;
00607
00608 if ($this->object->getType() != "grp" && ($_GET["cmd"] == "delete" || $_GET["cmd"] == "edit"))
00609 {
00610 unset($path[count($path) - 1]);
00611 }
00612
00613 foreach ($path as $key => $row)
00614 {
00615
00616 if ($key < count($path) - $modifier)
00617 {
00618 $this->tpl->touchBlock("locator_separator");
00619 }
00620
00621 $this->tpl->setCurrentBlock("locator_item");
00622 if ($row["child"] != $a_tree->getRootId())
00623 {
00624 $this->tpl->setVariable("ITEM", $row["title"]);
00625 }
00626 else
00627 {
00628 $this->tpl->setVariable("ITEM", $this->lng->txt("repository"));
00629 }
00630 if($row["type"] == "htlm")
00631 {
00632 $this->tpl->setVariable("LINK_ITEM", "fblm_edit.php?ref_id=".$row["child"]);
00633 }
00634 else
00635 {
00636 $this->tpl->setVariable("LINK_ITEM", "../repository.php?cmd=frameset&ref_id=".$row["child"]);
00637 $t_frame = ilFrameTargetInfo::_getFrame("MainContent");
00638 $this->tpl->setVariable("LINK_TARGET", " target=\"$t_frame\" ");
00639 }
00640
00641 $this->tpl->parseCurrentBlock();
00642
00643 $this->tpl->setCurrentBlock("locator");
00644
00645
00646
00647 if ($row["child"] != $a_tree->getRootId())
00648 {
00649 $ilias_locator->navigate($i++,$row["title"],"../repository.php?ref_id=".$row["child"],"bottom");
00650 }
00651 else
00652 {
00653 $ilias_locator->navigate($i++,$this->lng->txt("repository"),"../repository.php?ref_id=".$row["child"],"bottom");
00654 }
00655 }
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670 $this->tpl->setVariable("TXT_LOCATOR",$debug.$this->lng->txt("locator"));
00671 $this->tpl->parseCurrentBlock();
00672 }
00673
00674 }
00675
00679 function getTemplate()
00680 {
00681 global $lng;
00682
00683 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00684
00685 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00686
00687 }
00688
00689 function showLearningModule()
00690 {
00691 $dir = $this->object->getDataDirectory();
00692 if (($this->object->getStartFile() != "") &&
00693 (@is_file($dir."/".$this->object->getStartFile())))
00694 {
00695 ilUtil::redirect("../".$dir."/".$this->object->getStartFile());
00696 }
00697 else if (@is_file($dir."/index.html"))
00698 {
00699 ilUtil::redirect("../".$dir."/index.html");
00700 }
00701 else if (@is_file($dir."/index.htm"))
00702 {
00703 ilUtil::redirect("../".$dir."/index.htm");
00704 }
00705 }
00706
00710 function setTabs()
00711 {
00712 $this->tpl->setCurrentBlock("header_image");
00713 $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_lm_b.gif"));
00714 $this->tpl->parseCurrentBlock();
00715
00716 $this->getTabs($this->tabs_gui);
00717 #$this->tpl->setVariable("TABS", $this->tabs_gui->getHTML());
00718 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00719 }
00720
00726 function getTabs(&$tabs_gui)
00727 {
00728 global $rbacsystem;
00729
00730
00731 $tabs_gui->addTarget("cont_list_files",
00732 $this->ctrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"), "",
00733 "ilfilesystemgui");
00734
00735
00736 $tabs_gui->addTarget("properties",
00737 $this->ctrl->getLinkTarget($this, "properties"), "properties",
00738 get_class($this));
00739
00740 $tabs_gui->addTarget("meta_data",
00741 $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
00742 "", "ilmdeditorgui");
00743
00744
00745 $tabs_gui->addTarget("bib_data",
00746 $this->ctrl->getLinkTarget($this, "editBibItem"),
00747 array("editBibItem", "saveBibItem", "deleteBibItem", "addBibItem"),
00748 get_class($this));
00749
00750
00751 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00752 {
00753 $tabs_gui->addTarget("perm_settings",
00754 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
00755 }
00756 }
00757 }
00758 ?>