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
00037 require_once("classes/class.ilObjectGUI.php");
00038 require_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php");
00039 require_once("./Services/Table/classes/class.ilTableGUI.php");
00040 require_once("classes/class.ilFileSystemGUI.php");
00041
00042 class ilObjFileBasedLMGUI extends ilObjectGUI
00043 {
00044 var $output_prepared;
00045
00051 function ilObjFileBasedLMGUI($a_data,$a_id = 0,$a_call_by_reference = true, $a_prepare_output = true)
00052 {
00053 global $lng, $ilCtrl;
00054
00055 $this->ctrl =& $ilCtrl;
00056 $this->ctrl->saveParameter($this, array("ref_id"));
00057
00058 #include_once("classes/class.ilTabsGUI.php");
00059 #$this->tabs_gui =& new ilTabsGUI();
00060
00061 $this->type = "htlm";
00062 $lng->loadLanguageModule("content");
00063
00064 parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, false);
00065
00066 $this->output_prepared = $a_prepare_output;
00067
00068 }
00069
00073 function &executeCommand()
00074 {
00075 global $ilUser, $ilLocator;
00076
00077 if (strtolower($_GET["baseClass"]) == "iladministrationgui" ||
00078 $this->getCreationMode() == true)
00079 {
00080 $this->prepareOutput();
00081 }
00082 else
00083 {
00084 $this->getTemplate();
00085 $this->setLocator();
00086 $this->setTabs();
00087 }
00088
00089 $next_class = $this->ctrl->getNextClass($this);
00090 $cmd = $this->ctrl->getCmd();
00091
00092 switch($next_class)
00093 {
00094 case 'ilmdeditorgui':
00095
00096 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00097
00098 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00099 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00100
00101 $this->ctrl->forwardCommand($md_gui);
00102 break;
00103
00104 case "ilfilesystemgui":
00105 $fs_gui =& new ilFileSystemGUI($this->object->getDataDirectory());
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 $ret =& $this->ctrl->forwardCommand($fs_gui);
00114 break;
00115
00116 case "ilinfoscreengui":
00117 $ret =& $this->outputInfoScreen();
00118 break;
00119
00120 case "illearningprogressgui":
00121 include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
00122
00123 $new_gui =& new ilLearningProgressGUI(LP_MODE_REPOSITORY,
00124 $this->object->getRefId(),
00125 $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId());
00126 $this->ctrl->forwardCommand($new_gui);
00127 $this->tabs_gui->setTabActive('learning_progress');
00128 break;
00129
00130 case 'ilpermissiongui':
00131 include_once("./classes/class.ilPermissionGUI.php");
00132 $perm_gui =& new ilPermissionGUI($this);
00133 $ret =& $this->ctrl->forwardCommand($perm_gui);
00134 break;
00135
00136 default:
00137 $cmd = $this->ctrl->getCmd("frameset");
00138 if (strtolower($_GET["baseClass"]) == "iladministrationgui" ||
00139 $this->getCreationMode() == true)
00140 {
00141 $cmd.= "Object";
00142 }
00143 $ret =& $this->$cmd();
00144 break;
00145 }
00146
00147 }
00148
00154 function createObject()
00155 {
00156 global $rbacsystem;
00157
00158 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
00159
00160 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
00161 {
00162 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00163 }
00164 else
00165 {
00166
00167 $data = array();
00168 $data["fields"] = array();
00169 $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
00170 $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
00171
00172 $this->getTemplateFile("edit",$new_type);
00173
00174 $this->tpl->setCurrentBlock("img");
00175 $this->tpl->setVariable("TYPE_IMG",
00176 ilUtil::getImagePath("icon_".$new_type.".gif"));
00177 $this->tpl->setVariable("ALT_IMG",
00178 $this->lng->txt("obj_".$new_type));
00179 $this->tpl->parseCurrentBlock();
00180
00181 foreach ($data["fields"] as $key => $val)
00182 {
00183 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
00184 $this->tpl->setVariable(strtoupper($key), $val);
00185
00186 if ($this->prepare_output)
00187 {
00188 $this->tpl->parseCurrentBlock();
00189 }
00190 }
00191
00192 $this->ctrl->setParameter($this, "new_type", $new_type);
00193 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "save"));
00194
00195
00196 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
00197 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00198 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
00199 $this->tpl->setVariable("CMD_SUBMIT", "save");
00200 $this->tpl->setVariable("TARGET", ' target="'.
00201 ilFrameTargetInfo::_getFrame("MainContent").'" ');
00202 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00203 }
00204 }
00205
00206
00212 function properties()
00213 {
00214 global $rbacsystem, $tree, $tpl;
00215
00216
00217 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00218
00219
00220 require_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php");
00221 $startfile = ilObjFileBasedLMAccess::_determineStartUrl($this->object->getId());
00222
00223 if ($startfile != "")
00224 {
00225 $this->tpl->setCurrentBlock("btn_cell");
00226 $this->tpl->setVariable("BTN_LINK",
00227 "ilias.php?baseClass=ilHTLMPresentationGUI&ref_id=".$this->object->getRefID());
00228 $this->tpl->setVariable("BTN_TARGET"," target=\"ilContObj".$this->object->getID()."\" ");
00229 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
00230 $this->tpl->parseCurrentBlock();
00231 }
00232
00233
00234 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.fblm_properties.html",
00235 'Modules/HTMLLearningModule');
00236 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00237 $this->tpl->setVariable("TXT_PROPERTIES", $this->lng->txt("cont_lm_properties"));
00238
00239
00240 $this->tpl->setVariable("TXT_ONLINE", $this->lng->txt("cont_online"));
00241 $this->tpl->setVariable("CBOX_ONLINE", "cobj_online");
00242 $this->tpl->setVariable("VAL_ONLINE", "y");
00243 if ($this->object->getOnline())
00244 {
00245 $this->tpl->setVariable("CHK_ONLINE", "checked");
00246 }
00247
00248
00249 $this->tpl->setVariable("TXT_START_FILE", $this->lng->txt("cont_startfile"));
00250 if ($startfile != "")
00251 {
00252 $this->tpl->setVariable("VAL_START_FILE", basename($startfile));
00253 }
00254 else
00255 {
00256 $this->tpl->setVariable("VAL_START_FILE", $this->lng->txt("no_start_file"));
00257 }
00258 $this->tpl->setVariable("TXT_SET_START_FILE", $this->lng->txt("cont_set_start_file"));
00259 $this->tpl->setVariable("LINK_SET_START_FILE",
00260 $this->ctrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"));
00261
00262 $this->tpl->setCurrentBlock("commands");
00263 $this->tpl->setVariable("BTN_NAME", "saveProperties");
00264 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00265 $this->tpl->parseCurrentBlock();
00266
00267 }
00268
00272 function saveProperties()
00273 {
00274 $this->object->setOnline(ilUtil::yn2tf($_POST["cobj_online"]));
00275 $this->object->update();
00276 ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
00277 $this->ctrl->redirect($this, "properties");
00278 }
00279
00280
00285 function saveObject()
00286 {
00287 global $rbacadmin;
00288
00289
00290 $newObj = parent::saveObject();
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301 ilUtil::sendInfo($this->lng->txt("object_added"),true);
00302 ilUtil::redirect("ilias.php?baseClass=ilHTLMEditorGUI&ref_id=".$newObj->getRefId());
00303
00304
00305 }
00306
00312 function editObject()
00313 {
00314 global $rbacsystem, $tree, $tpl;
00315
00316 if (!$rbacsystem->checkAccess("visible,write",$this->object->getRefId()))
00317 {
00318 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00319 }
00320
00321
00322 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00323
00324 }
00325
00329 function edit()
00330 {
00331 $this->prepareOutput();
00332 $this->editObject();
00333 }
00334
00338 function cancel()
00339 {
00340
00341 $this->cancelObject();
00342 }
00343
00349 function cancelObject($in_rep = false)
00350 {
00351 ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
00352 ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
00353
00354 }
00355
00356
00360 function update()
00361 {
00362
00363
00364 $this->updateObject();
00365 }
00366
00367
00368 function setStartFile($a_file)
00369 {
00370 $this->object->setStartFile($a_file);
00371 $this->object->update();
00372 $this->ctrl->redirectByClass("ilfilesystemgui", "listFiles");
00373 }
00374
00378 function perm()
00379 {
00380 $this->setFormAction("permSave", "fblm_edit.php?cmd=permSave&ref_id=".$_GET["ref_id"].
00381 "&obj_id=".$_GET["obj_id"]);
00382 $this->setFormAction("addRole", "fblm_edit.php?ref_id=".$_GET["ref_id"].
00383 "&obj_id=".$_GET["obj_id"]."&cmd=addRole");
00384 $this->permObject();
00385 }
00386
00390 function saveBibItemObject($a_target = "")
00391 {
00392 include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
00393 $bib_gui =& new ilBibItemGUI();
00394 $bib_gui->setObject($this->object);
00395 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
00396 $bibItemIndex *= 1;
00397 if ($bibItemIndex < 0)
00398 {
00399 $bibItemIndex = 0;
00400 }
00401 $bibItemIndex = $bib_gui->save($bibItemIndex);
00402
00403 if ($a_target == "")
00404 {
00405 $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
00406 }
00407
00408 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
00409 }
00410
00414 function saveBibItem()
00415 {
00416
00417 $this->saveBibItemObject($this->ctrl->getLinkTarget($this));
00418 }
00419
00423 function editBibItemObject($a_target = "")
00424 {
00425 include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
00426 $bib_gui =& new ilBibItemGUI();
00427 $bib_gui->setObject($this->object);
00428 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
00429 $bibItemIndex *= 1;
00430 if ($bibItemIndex < 0)
00431 {
00432 $bibItemIndex = 0;
00433 }
00434 if ($a_target == "")
00435 {
00436 $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
00437 }
00438
00439 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
00440 }
00441
00445 function editBibItem()
00446 {
00447
00448 $this->editBibItemObject($this->ctrl->getLinkTarget($this));
00449 }
00450
00454 function deleteBibItemObject($a_target = "")
00455 {
00456 include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
00457 $bib_gui =& new ilBibItemGUI();
00458 $bib_gui->setObject($this->object);
00459 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
00460 $bib_gui->bib_obj->delete($_GET["bibItemName"], $_GET["bibItemPath"], $bibItemIndex);
00461 if (strpos($bibItemIndex, ",") > 0)
00462 {
00463 $bibItemIndex = substr($bibItemIndex, 0, strpos($bibItemIndex, ","));
00464 }
00465 if ($a_target == "")
00466 {
00467 $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
00468 }
00469
00470 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
00471 }
00472
00476 function deleteBibItem()
00477 {
00478
00479 $this->deleteBibItemObject($this->ctrl->getLinkTarget($this));
00480 }
00481
00485 function addBibItemObject($a_target = "")
00486 {
00487 $bibItemName = $_POST["bibItemName"] ? $_POST["bibItemName"] : $_GET["bibItemName"];
00488 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
00489 if ($bibItemName == "BibItem")
00490 {
00491 include_once "./Modules/LearningModule/classes/class.ilBibItem.php";
00492 $bib_item =& new ilBibItem();
00493 $bib_item->setId($this->object->getId());
00494 $bib_item->setType($this->object->getType());
00495 $bib_item->read();
00496 }
00497
00498 include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
00499 $bib_gui =& new ilBibItemGUI();
00500 $bib_gui->setObject($this->object);
00501 if ($bibItemIndex == "")
00502 $bibItemIndex = 0;
00503 $bibItemPath = $_POST["bibItemPath"] ? $_POST["bibItemPath"] : $_GET["bibItemPath"];
00504
00505
00506 if ($bibItemName != "")
00507 {
00508 $bib_gui->bib_obj->add($bibItemName, $bibItemPath, $bibItemIndex);
00509 $data = $bib_gui->bib_obj->getElement("BibItem");
00510 $bibItemIndex = (count($data) - 1);
00511 }
00512 else
00513 {
00514 ilUtil::sendInfo($this->lng->txt("bibitem_choose_element"), true);
00515 }
00516 if ($a_target == "")
00517 {
00518 $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
00519 }
00520
00521 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
00522 }
00523
00527 function addBibItem()
00528 {
00529
00530 $this->addBibItemObject($this->ctrl->getLinkTarget($this));
00531 }
00532
00538 function frameset()
00539 {
00540 $this->tpl = new ilTemplate("tpl.fblm_edit_frameset.html", false, false,
00541 "Modules/HTMLLearningModule");
00542 $this->tpl->setVariable("HREF_FILES",$this->ctrl->getLinkTargetByClass(
00543 "ilfilesystemgui", "listFiles"));
00544 $this->tpl->show();
00545 exit;
00546 }
00547
00551 function explorer()
00552 {
00553 $this->tpl = new ilTemplate("tpl.main.html", true, true);
00554
00555 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00556
00557 $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
00558
00559 require_once ("./Modules/HTMLLearningModule/classes/class.ilFileExplorer.php");
00560 $exp = new ilFileExplorer($this->lm->getDataDirectory());
00561
00562 }
00563
00567 function getTemplate()
00568 {
00569 global $lng;
00570
00571 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00572
00573 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00574
00575 }
00576
00577 function showLearningModule()
00578 {
00579
00580 include_once "Services/Tracking/classes/class.ilTracking.php";
00581 ilTracking::_trackAccess($this->object->getId(),'htlm');
00582
00583 require_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php");
00584 $startfile = ilObjFileBasedLMAccess::_determineStartUrl($this->object->getId());
00585 if ($startfile != "")
00586 {
00587 ilUtil::redirect($startfile);
00588 }
00589 }
00590
00591
00597 function infoScreen()
00598 {
00599 $this->ctrl->setCmd("showSummary");
00600 $this->ctrl->setCmdClass("ilinfoscreengui");
00601 $this->outputInfoScreen();
00602 }
00603
00607 function showInfoScreen()
00608 {
00609 $this->outputInfoScreen(true);
00610 }
00611
00615 function outputInfoScreen($a_standard_locator = true)
00616 {
00617 global $ilBench, $ilLocator, $ilAccess;
00618
00619
00620 $this->tabs_gui->setTabActive('info_short');
00621
00622 $this->lng->loadLanguageModule("meta");
00623 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
00624
00625 $info = new ilInfoScreenGUI($this);
00626 $info->enablePrivateNotes();
00627 $info->enableLearningProgress();
00628
00629 $info->enableNews();
00630 if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
00631 {
00632 $info->enableNewsEditing();
00633
00634 $news_set = new ilSetting("news");
00635 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
00636 if ($enable_internal_rss)
00637 {
00638 $info->setBlockProperty("news", "settings", true);
00639 }
00640 }
00641
00642
00643 if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
00644 {
00645 $info->addButton($this->lng->txt("view"),
00646 "ilias.php?baseClass=ilHTLMPresentationGUI&ref_id=".$this->object->getRefID(),
00647 ' target="ilContObj'.$this->object->getId().'" ');
00648 }
00649
00650
00651 $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
00652
00653
00654 $this->ctrl->forwardCommand($info);
00655 }
00656
00657
00658
00662 function setTabs()
00663 {
00664 $this->tpl->setCurrentBlock("header_image");
00665 $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_lm_b.gif"));
00666 $this->tpl->parseCurrentBlock();
00667
00668 $this->getTabs($this->tabs_gui);
00669 #$this->tpl->setVariable("TABS", $this->tabs_gui->getHTML());
00670 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00671 }
00672
00678 function getTabs(&$tabs_gui)
00679 {
00680 global $rbacsystem,$ilUser;
00681
00682
00683 if($rbacsystem->checkAccess('write',$this->ref_id))
00684 {
00685
00686 $tabs_gui->addTarget("cont_list_files",
00687 $this->ctrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"), "",
00688 "ilfilesystemgui");
00689
00690
00691 $force_active = (strtolower($_GET["cmdClass"]) == "ilinfoscreengui"
00692 || strtolower($_GET["cmdClass"]) == "ilnotegui")
00693 ? true
00694 : false;
00695 $tabs_gui->addTarget("info_short",
00696 $this->ctrl->getLinkTargetByClass(array("ilobjfilebasedlmgui",
00697 "ilinfoscreengui"),
00698 "showSummary"),
00699 "infoScreen",
00700 "",
00701 "",
00702 $force_active);
00703
00704
00705 $tabs_gui->addTarget("properties",
00706 $this->ctrl->getLinkTarget($this, "properties"), "properties",
00707 get_class($this));
00708
00709 $tabs_gui->addTarget("meta_data",
00710 $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
00711 "", "ilmdeditorgui");
00712
00713
00714 $tabs_gui->addTarget("bib_data",
00715 $this->ctrl->getLinkTarget($this, "editBibItem"),
00716 array("editBibItem", "saveBibItem", "deleteBibItem", "addBibItem"),
00717 get_class($this));
00718 }
00719
00720
00721 include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
00722 if($rbacsystem->checkAccess('write',$this->ref_id) and ilObjUserTracking::_enabledLearningProgress() and $ilUser->getId() != ANONYMOUS_USER_ID)
00723 {
00724 $tabs_gui->addTarget('learning_progress',
00725 $this->ctrl->getLinkTargetByClass(array('ilobjfilebasedlmgui','illearningprogressgui'),''),
00726 '',
00727 array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
00728 }
00729
00730
00731 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00732 {
00733 $tabs_gui->addTarget("perm_settings",
00734 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
00735 }
00736 }
00737
00743 function _goto($a_target)
00744 {
00745 global $rbacsystem, $ilErr, $lng, $ilAccess;
00746
00747 if ($ilAccess->checkAccess("visible", "", $a_target))
00748 {
00749 $_GET["ref_id"] = $a_target;
00750 $_GET["cmd"] = "infoScreen";
00751 include("repository.php");
00752 exit;
00753 }
00754 else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
00755 {
00756 $_GET["cmd"] = "frameset";
00757 $_GET["target"] = "";
00758 $_GET["ref_id"] = ROOT_FOLDER_ID;
00759 ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
00760 ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
00761 include("repository.php");
00762 exit;
00763 }
00764
00765 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
00766 }
00767
00768 function addLocatorItems()
00769 {
00770 global $ilLocator;
00771
00772 if (is_object($this->object))
00773 {
00774 $ilLocator->addItem($this->object->getTitle(),
00775 $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"), "", $_GET["ref_id"]);
00776 }
00777 }
00778 }
00779 ?>