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 'ilmdeditorgui':
00092
00093 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00094
00095 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00096 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00097
00098 $this->ctrl->forwardCommand($md_gui);
00099 break;
00100
00101 case "ilfilesystemgui":
00102
00103 $fs_gui->activateLabels(true, $this->lng->txt("cont_purpose"));
00104 if ($this->object->getStartFile() != "")
00105 {
00106 $fs_gui->labelFile($this->object->getStartFile(),
00107 $this->lng->txt("cont_startfile"));
00108 }
00109 $fs_gui->addCommand($this, "setStartFile", $this->lng->txt("cont_set_start_file"));
00110
00111 $ret =& $this->ctrl->forwardCommand($fs_gui);
00112 break;
00113
00114 default:
00115 $cmd = $this->ctrl->getCmd("frameset");
00116 $ret =& $this->$cmd();
00117 break;
00118 }
00119 $this->tpl->show();
00120 }
00121
00122
00128 function properties()
00129 {
00130 global $rbacsystem, $tree, $tpl;
00131
00132
00133 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00134
00135
00136 $this->tpl->setCurrentBlock("btn_cell");
00137 $this->tpl->setVariable("BTN_LINK", "fblm_presentation.php?ref_id=".$this->object->getRefID());
00138 $this->tpl->setVariable("BTN_TARGET"," target=\"ilContObj".$this->object->getID()."\" ");
00139 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
00140 $this->tpl->parseCurrentBlock();
00141
00142
00143 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.fblm_properties.html", true);
00144 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00145 $this->tpl->setVariable("TXT_PROPERTIES", $this->lng->txt("cont_lm_properties"));
00146
00147
00148 $this->tpl->setVariable("TXT_ONLINE", $this->lng->txt("cont_online"));
00149 $this->tpl->setVariable("CBOX_ONLINE", "cobj_online");
00150 $this->tpl->setVariable("VAL_ONLINE", "y");
00151 if ($this->object->getOnline())
00152 {
00153 $this->tpl->setVariable("CHK_ONLINE", "checked");
00154 }
00155
00156
00157 $this->tpl->setVariable("TXT_START_FILE", $this->lng->txt("cont_startfile"));
00158 $this->tpl->setVariable("VAL_START_FILE", $this->object->getStartFile());
00159 $this->tpl->setVariable("TXT_SET_START_FILE", $this->lng->txt("cont_set_start_file"));
00160 $this->tpl->setVariable("LINK_SET_START_FILE",
00161 $this->ctrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"));
00162
00163 $this->tpl->setCurrentBlock("commands");
00164 $this->tpl->setVariable("BTN_NAME", "saveProperties");
00165 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00166 $this->tpl->parseCurrentBlock();
00167
00168 }
00169
00173 function saveProperties()
00174 {
00175 $this->object->setOnline(ilUtil::yn2tf($_POST["cobj_online"]));
00176 $this->object->update();
00177 sendInfo($this->lng->txt("msg_obj_modified"), true);
00178 $this->ctrl->redirect($this, "properties");
00179 }
00180
00181
00186 function saveObject()
00187 {
00188 global $rbacadmin;
00189
00190
00191 $newObj = parent::saveObject();
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202 sendInfo($this->lng->txt("object_added"),true);
00203
00204 ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
00205 }
00206
00212 function editObject()
00213 {
00214 global $rbacsystem, $tree, $tpl;
00215
00216 if (!$rbacsystem->checkAccess("visible,write",$this->object->getRefId()))
00217 {
00218 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00219 }
00220
00221
00222 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00223
00224 if (!defined("ILIAS_MODULE"))
00225 {
00226 $this->tpl->setCurrentBlock("btn_cell");
00227 $this->tpl->setVariable("BTN_LINK","content/fblm_edit.php?ref_id=".$this->object->getRefID());
00228 $this->tpl->setVariable("BTN_TARGET"," target=\"bottom\" ");
00229 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("edit"));
00230 $this->tpl->parseCurrentBlock();
00231 }
00232
00233
00234 }
00235
00239 function edit()
00240 {
00241 $this->prepareOutput();
00242 $this->setFormAction("update", "fblm_edit.php?cmd=post&ref_id=".$_GET["ref_id"].
00243 "&obj_id=".$_GET["obj_id"]);
00244 $this->editObject();
00245 $this->tpl->show();
00246 }
00247
00251 function cancel()
00252 {
00253 $this->setReturnLocation("cancel","fblm_edit.php?cmd=listFiles&ref_id=".$_GET["ref_id"]);
00254 $this->cancelObject();
00255 }
00256
00260 function update()
00261 {
00262 $this->setReturnLocation("update", "fblm_edit.php?cmd=listFiles&ref_id=".$_GET["ref_id"].
00263 "&obj_id=".$_GET["obj_id"]);
00264 $this->updateObject();
00265 }
00266
00267
00268 function setStartFile($a_file)
00269 {
00270 $this->object->setStartFile($a_file);
00271 $this->object->update();
00272 $this->ctrl->redirectByClass("ilfilesystemgui", "listFiles");
00273 }
00274
00278 function perm()
00279 {
00280 $this->setFormAction("permSave", "fblm_edit.php?cmd=permSave&ref_id=".$_GET["ref_id"].
00281 "&obj_id=".$_GET["obj_id"]);
00282 $this->setFormAction("addRole", "fblm_edit.php?ref_id=".$_GET["ref_id"].
00283 "&obj_id=".$_GET["obj_id"]."&cmd=addRole");
00284 $this->permObject();
00285 }
00286
00290 function info()
00291 {
00292 $this->infoObject();
00293 }
00294
00298 function permSave()
00299 {
00300 $this->setReturnLocation("permSave",
00301 "fblm_edit.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]."&cmd=perm");
00302 $this->permSaveObject();
00303 }
00304
00308 function addRole()
00309 {
00310 $this->setReturnLocation("addRole",
00311 "fblm_edit.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]."&cmd=perm");
00312 $this->addRoleObject();
00313 }
00314
00318 function owner()
00319 {
00320 $this->ownerObject();
00321 }
00322
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00347
00348
00349
00350
00351
00352
00353
00354
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00392
00393
00394
00395
00396
00397
00398
00399
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00425
00426
00427
00428
00429
00430
00431
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00455
00456
00457
00458
00459
00460
00461
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00487
00488
00489
00490
00491
00492
00493
00497 function saveBibItemObject($a_target = "")
00498 {
00499 include_once "content/classes/class.ilBibItemGUI.php";
00500 $bib_gui =& new ilBibItemGUI();
00501 $bib_gui->setObject($this->object);
00502 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
00503 $bibItemIndex *= 1;
00504 if ($bibItemIndex < 0)
00505 {
00506 $bibItemIndex = 0;
00507 }
00508 $bibItemIndex = $bib_gui->save($bibItemIndex);
00509
00510 if ($a_target == "")
00511 {
00512 $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
00513 }
00514
00515 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
00516 }
00517
00521 function saveBibItem()
00522 {
00523
00524 $this->saveBibItemObject($this->ctrl->getLinkTarget($this));
00525 }
00526
00530 function editBibItemObject($a_target = "")
00531 {
00532 include_once "content/classes/class.ilBibItemGUI.php";
00533 $bib_gui =& new ilBibItemGUI();
00534 $bib_gui->setObject($this->object);
00535 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
00536 $bibItemIndex *= 1;
00537 if ($bibItemIndex < 0)
00538 {
00539 $bibItemIndex = 0;
00540 }
00541 if ($a_target == "")
00542 {
00543 $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
00544 }
00545
00546 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
00547 }
00548
00552 function editBibItem()
00553 {
00554
00555 $this->editBibItemObject($this->ctrl->getLinkTarget($this));
00556 }
00557
00561 function deleteBibItemObject($a_target = "")
00562 {
00563 include_once "content/classes/class.ilBibItemGUI.php";
00564 $bib_gui =& new ilBibItemGUI();
00565 $bib_gui->setObject($this->object);
00566 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
00567 $bib_gui->bib_obj->delete($_GET["bibItemName"], $_GET["bibItemPath"], $bibItemIndex);
00568 if (strpos($bibItemIndex, ",") > 0)
00569 {
00570 $bibItemIndex = substr($bibItemIndex, 0, strpos($bibItemIndex, ","));
00571 }
00572 if ($a_target == "")
00573 {
00574 $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
00575 }
00576
00577 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
00578 }
00579
00583 function deleteBibItem()
00584 {
00585
00586 $this->deleteBibItemObject($this->ctrl->getLinkTarget($this));
00587 }
00588
00592 function addBibItemObject($a_target = "")
00593 {
00594 $bibItemName = $_POST["bibItemName"] ? $_POST["bibItemName"] : $_GET["bibItemName"];
00595 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
00596 if ($bibItemName == "BibItem")
00597 {
00598 include_once "content/classes/class.ilBibItem.php";
00599 $bib_item =& new ilBibItem();
00600 $bib_item->setId($this->object->getId());
00601 $bib_item->setType($this->object->getType());
00602 $bib_item->read();
00603 }
00604
00605 include_once "content/classes/class.ilBibItemGUI.php";
00606 $bib_gui =& new ilBibItemGUI();
00607 $bib_gui->setObject($this->object);
00608 if ($bibItemIndex == "")
00609 $bibItemIndex = 0;
00610 $bibItemPath = $_POST["bibItemPath"] ? $_POST["bibItemPath"] : $_GET["bibItemPath"];
00611
00612
00613 if ($bibItemName != "")
00614 {
00615 $bib_gui->bib_obj->add($bibItemName, $bibItemPath, $bibItemIndex);
00616 $data = $bib_gui->bib_obj->getElement("BibItem");
00617 $bibItemIndex = (count($data) - 1);
00618 }
00619 else
00620 {
00621 sendInfo($this->lng->txt("bibitem_choose_element"), true);
00622 }
00623 if ($a_target == "")
00624 {
00625 $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
00626 }
00627
00628 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
00629 }
00630
00634 function addBibItem()
00635 {
00636
00637 $this->addBibItemObject($this->ctrl->getLinkTarget($this));
00638 }
00639
00645 function frameset()
00646 {
00647 $this->tpl = new ilTemplate("tpl.fblm_edit_frameset.html", false, false, "content");
00648 $this->tpl->setVariable("HREF_FILES",$this->ctrl->getLinkTargetByClass(
00649 "ilfilesystemgui", "listFiles"));
00650 $this->tpl->show();
00651 }
00652
00656 function explorer()
00657 {
00658 $this->tpl = new ilTemplate("tpl.main.html", true, true);
00659
00660 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00661
00662 $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
00663
00664 require_once ("content/classes/class.ilFileExplorer.php");
00665 $exp = new ilFileExplorer($this->lm->getDataDirectory());
00666
00667 }
00668
00669
00673 function setLocator($a_tree = "", $a_id = "", $scriptname="adm_object.php")
00674 {
00675 global $ilias_locator, $tree;
00676 if (!defined("ILIAS_MODULE"))
00677 {
00678 parent::setLocator();
00679 }
00680 else
00681 {
00682 $a_tree =& $tree;
00683 $a_id = $_GET["ref_id"];
00684
00685 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00686
00687 $path = $a_tree->getPathFull($a_id);
00688
00689
00690 $modifier = 1;
00691
00692 if (!empty($_GET["obj_id"]))
00693 {
00694 $modifier = 0;
00695 }
00696
00697
00698 $i = 1;
00699
00700 if ($this->object->getType() != "grp" && ($_GET["cmd"] == "delete" || $_GET["cmd"] == "edit"))
00701 {
00702 unset($path[count($path) - 1]);
00703 }
00704
00705 foreach ($path as $key => $row)
00706 {
00707
00708 if ($key < count($path) - $modifier)
00709 {
00710 $this->tpl->touchBlock("locator_separator");
00711 }
00712
00713 $this->tpl->setCurrentBlock("locator_item");
00714 if ($row["child"] != $a_tree->getRootId())
00715 {
00716 $this->tpl->setVariable("ITEM", $row["title"]);
00717 }
00718 else
00719 {
00720 $this->tpl->setVariable("ITEM", $this->lng->txt("repository"));
00721 }
00722 if($row["type"] == "htlm")
00723 {
00724 $this->tpl->setVariable("LINK_ITEM", "fblm_edit.php?ref_id=".$row["child"]);
00725 }
00726 else
00727 {
00728 $this->tpl->setVariable("LINK_ITEM", "../repository.php?cmd=frameset&ref_id=".$row["child"]);
00729 $t_frame = ilFrameTargetInfo::_getFrame("MainContent");
00730 $this->tpl->setVariable("LINK_TARGET", " target=\"$t_frame\" ");
00731 }
00732
00733 $this->tpl->parseCurrentBlock();
00734
00735 $this->tpl->setCurrentBlock("locator");
00736
00737
00738
00739 if ($row["child"] != $a_tree->getRootId())
00740 {
00741 $ilias_locator->navigate($i++,$row["title"],"../repository.php?ref_id=".$row["child"],"bottom");
00742 }
00743 else
00744 {
00745 $ilias_locator->navigate($i++,$this->lng->txt("repository"),"../repository.php?ref_id=".$row["child"],"bottom");
00746 }
00747 }
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762 $this->tpl->setVariable("TXT_LOCATOR",$debug.$this->lng->txt("locator"));
00763 $this->tpl->parseCurrentBlock();
00764 }
00765
00766 }
00767
00771 function getTemplate()
00772 {
00773 global $lng;
00774
00775 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00776
00777 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00778
00779 }
00780
00781 function showLearningModule()
00782 {
00783 $dir = $this->object->getDataDirectory();
00784 if (($this->object->getStartFile() != "") &&
00785 (@is_file($dir."/".$this->object->getStartFile())))
00786 {
00787 ilUtil::redirect("../".$dir."/".$this->object->getStartFile());
00788 }
00789 else if (@is_file($dir."/index.html"))
00790 {
00791 ilUtil::redirect("../".$dir."/index.html");
00792 }
00793 else if (@is_file($dir."/index.htm"))
00794 {
00795 ilUtil::redirect("../".$dir."/index.htm");
00796 }
00797 }
00798
00802 function setTabs()
00803 {
00804 $this->getTabs($this->tabs_gui);
00805 $this->tpl->setVariable("TABS", $this->tabs_gui->getHTML());
00806 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00807 }
00808
00814 function getTabs(&$tabs_gui)
00815 {
00816 global $rbacsystem;
00817
00818
00819 $tabs_gui->addTarget("properties",
00820 $this->ctrl->getLinkTarget($this, "properties"), "properties",
00821 get_class($this));
00822
00823
00824
00825
00826
00827
00828
00829
00830 $tabs_gui->addTarget("meta_data",
00831 $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
00832 "meta_data", get_class($this));
00833
00834
00835
00836 $tabs_gui->addTarget("bib_data",
00837 $this->ctrl->getLinkTarget($this, "editBibItem"), "editBibItem",
00838 get_class($this));
00839
00840
00841 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00842 {
00843 $tabs_gui->addTarget("perm_settings",
00844 $this->ctrl->getLinkTarget($this, "perm"), array("perm", "info"),
00845 get_class($this));
00846 }
00847
00848
00849
00850
00851
00852
00853
00854 }
00855
00856
00857 }
00858 ?>