ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilObjFileBasedLMGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 
19 require_once("./Services/Object/classes/class.ilObjectGUI.php");
20 require_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php");
21 require_once("./Services/Table/classes/class.ilTableGUI.php");
22 require_once("./Services/FileSystem/classes/class.ilFileSystemGUI.php");
23 
25 {
27 
33  function ilObjFileBasedLMGUI($a_data,$a_id = 0,$a_call_by_reference = true, $a_prepare_output = true)
34  {
35  global $lng, $ilCtrl;
36 
37  $this->ctrl = $ilCtrl;
38  $this->ctrl->saveParameter($this, array("ref_id"));
39 
40  $this->type = "htlm";
41  $lng->loadLanguageModule("content");
42 
43  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, false);
44  //$this->actions = $this->objDefinition->getActions("mep");
45  $this->output_prepared = $a_prepare_output;
46 
47  }
48 
52  function executeCommand()
53  {
54  global $ilUser, $ilLocator, $ilTabs;
55 
56  $next_class = $this->ctrl->getNextClass($this);
57  $cmd = $this->ctrl->getCmd();
58 
59  if (strtolower($_GET["baseClass"]) == "iladministrationgui" ||
60  $this->getCreationMode() == true)
61  {
62  $this->prepareOutput();
63  }
64  else
65  {
66  if (!in_array($cmd, array("", "framset")) || $next_class != "")
67  {
68  $this->getTemplate();
69  $this->setLocator();
70  $this->setTabs();
71  }
72  }
73 
74 
75  if(!$this->getCreationMode())
76  {
77  if(IS_PAYMENT_ENABLED)
78  {
79  include_once 'Services/Payment/classes/class.ilPaymentObject.php';
80  if(ilPaymentObject::_requiresPurchaseToAccess($_GET['ref_id'], $type = (isset($_GET['purchasetype']) ? $_GET['purchasetype'] : NULL) ))
81  {
82  $this->tpl->getStandardTemplate();
83 
84  include_once 'Services/Payment/classes/class.ilShopPurchaseGUI.php';
85  $pp = new ilShopPurchaseGUI((int)$_GET['ref_id']);
86  $ret = $this->ctrl->forwardCommand($pp);
87  return true;
88  }
89  }
90  }
91 
92  switch($next_class)
93  {
94  case 'ilobjectmetadatagui':
95  $this->checkPermission("write");
96  $ilTabs->activateTab('id_meta_data');
97  include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
98  $md_gui = new ilObjectMetaDataGUI($this->object);
99  $this->ctrl->forwardCommand($md_gui);
100  break;
101 
102  case "ilfilesystemgui":
103  $this->checkPermission("write");
104  $ilTabs->activateTab('id_list_files');
105  $fs_gui = new ilFileSystemGUI($this->object->getDataDirectory());
106  $fs_gui->activateLabels(true, $this->lng->txt("cont_purpose"));
107  $fs_gui->setUseUploadDirectory(true);
108  $fs_gui->setTableId("htlmfs".$this->object->getId());
109  if ($this->object->getStartFile() != "")
110  {
111  $fs_gui->labelFile($this->object->getStartFile(),
112  $this->lng->txt("cont_startfile"));
113  }
114  $fs_gui->addCommand($this, "setStartFile", $this->lng->txt("cont_set_start_file"));
115 
116  $this->ctrl->forwardCommand($fs_gui);
117 
118  // try to set start file automatically
119  require_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php");
120  if (!ilObjFileBasedLMAccess::_determineStartUrl($this->object->getId()))
121  {
122  $do_update = false;
123 
124  $pcommand = $fs_gui->getLastPerformedCommand();
125  if (is_array($pcommand))
126  {
127  $valid = array("index.htm", "index.html", "start.htm", "start.html");
128  if($pcommand["cmd"] == "create_file")
129  {
130  $file = strtolower(basename($pcommand["name"]));
131  if(in_array($file, $valid))
132  {
133  $this->object->setStartFile($pcommand["name"]);
134  $do_update = $pcommand["name"];
135  }
136  }
137  else if($pcommand["cmd"] == "unzip_file")
138  {
139  $zip_file = strtolower(basename($pcommand["name"]));
140  $suffix = strrpos($zip_file, ".");
141  if($suffix)
142  {
143  $zip_file = substr($zip_file, 0, $suffix);
144  }
145  foreach($pcommand["added"] as $file)
146  {
147  $chk_file = null;
148  if(stristr($file, ".htm"))
149  {
150  $chk_file = strtolower(basename($file));
151  $suffix = strrpos($chk_file, ".");
152  if($suffix)
153  {
154  $chk_file = substr($chk_file, 0, $suffix);
155  }
156  }
157  if(in_array(basename($file), $valid) ||
158  ($zip_file && $chk_file && $chk_file == $zip_file))
159  {
160  $this->object->setStartFile($file);
161  $do_update = $file;
162  break;
163  }
164  }
165  }
166  }
167 
168  if($do_update)
169  {
170  ilUtil::sendInfo(sprintf($this->lng->txt("cont_start_file_set_to"), $do_update), true);
171 
172  $this->object->update();
173  $this->ctrl->redirectByClass("ilfilesystemgui", "listFiles");
174  }
175  }
176  break;
177 
178  case "ilinfoscreengui":
179  $ret =& $this->outputInfoScreen();
180  break;
181 
182  case "illearningprogressgui":
183  $ilTabs->activateTab('id_learning_progress');
184  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
186  $this->object->getRefId(),
187  $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId());
188  $this->ctrl->forwardCommand($new_gui);
189  break;
190 
191  case 'ilpermissiongui':
192  $ilTabs->activateTab('id_permissions');
193  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
194  $perm_gui =& new ilPermissionGUI($this);
195  $ret =& $this->ctrl->forwardCommand($perm_gui);
196  break;
197 
198  case 'illicensegui':
199  $ilTabs->activateTab('id_license');
200  include_once("./Services/License/classes/class.ilLicenseGUI.php");
201  $license_gui =& new ilLicenseGUI($this);
202  $ret =& $this->ctrl->forwardCommand($license_gui);
203  break;
204 
205  case "ilexportgui":
206  $ilTabs->activateTab("export");
207  include_once("./Services/Export/classes/class.ilExportGUI.php");
208  $exp_gui = new ilExportGUI($this);
209  $exp_gui->addFormat("xml");
210  $exp_gui->addFormat("html", "", $this, "exportHTML");
211  $ret = $this->ctrl->forwardCommand($exp_gui);
212 // $this->tpl->show();
213  break;
214 
215  case "ilcommonactiondispatchergui":
216  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
218  $this->ctrl->forwardCommand($gui);
219  break;
220 
221  default:
222  $cmd = $this->ctrl->getCmd("frameset");
223  if (strtolower($_GET["baseClass"]) == "iladministrationgui" ||
224  $this->getCreationMode() == true)
225  {
226  $cmd.= "Object";
227  }
228  $ret =& $this->$cmd();
229  break;
230  }
231 
232  $this->addHeaderAction();
233  }
234 
235  protected function initCreationForms($a_new_type)
236  {
237  $forms = array(self::CFORM_NEW => $this->initCreateForm($a_new_type),
238  self::CFORM_IMPORT => $this->initImportForm($a_new_type));
239 
240  return $forms;
241  }
242 
248  final function cancelCreationObject($in_rep = false)
249  {
250  global $ilCtrl;
251 
252  $ilCtrl->redirectByClass("ilrepositorygui", "frameset");
253  }
254 
260  function properties()
261  {
262  global $rbacsystem, $tree, $tpl, $ilTabs;
263 
264  $ilTabs->activateTab("id_settings");
265 
266  $this->initSettingsForm();
267  $this->getSettingsFormValues();
268  $tpl->setContent($this->form->getHTML());
269  }
270 
274  public function initSettingsForm()
275  {
276  global $lng, $ilCtrl, $ilAccess;
277 
278  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
279  $this->form = new ilPropertyFormGUI();
280 
281  // title
282  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
283  $ti->setSize(min(40, ilObject::TITLE_LENGTH));
284  $ti->setMaxLength(ilObject::TITLE_LENGTH);
285  $ti->setRequired(true);
286  $this->form->addItem($ti);
287 
288  // description
289  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
290  $ta->setCols(40);
291  $ta->setRows(2);
292  $this->form->addItem($ta);
293 
294  // online
295  $cb = new ilCheckboxInputGUI($lng->txt("cont_online"), "cobj_online");
296  $cb->setOptionTitle($lng->txt(""));
297  $cb->setValue("y");
298  $this->form->addItem($cb);
299 
300  // startfile
301  require_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php");
302  $startfile = ilObjFileBasedLMAccess::_determineStartUrl($this->object->getId());
303 
304  $ne = new ilNonEditableValueGUI($lng->txt("cont_startfile"), "");
305  if ($startfile != "")
306  {
307  $ne->setValue(basename($startfile));
308  }
309  else
310  {
311  $ne->setValue(basename($this->lng->txt("no_start_file")));
312  }
313  $this->form->addItem($ne);
314 
315  include_once("Services/License/classes/class.ilLicenseAccess.php");
317  {
318  $lic = new ilCheckboxInputGUI($lng->txt("cont_license"), "lic");
319  $lic->setInfo($lng->txt("cont_license_info"));
320  $this->form->addItem($lic);
321 
322  if(!$ilAccess->checkAccess('edit_permission', '', $this->ref_id))
323  {
324  $lic->setDisabled(true);
325  }
326  }
327 
328  $bib = new ilCheckboxInputGUI($lng->txt("cont_biblio"), "bib");
329  $bib->setInfo($lng->txt("cont_biblio_info"));
330  $this->form->addItem($bib);
331 
332  $this->form->addCommandButton("saveProperties", $lng->txt("save"));
333  $this->form->addCommandButton("toFilesystem", $lng->txt("cont_set_start_file"));
334 
335  $this->form->setTitle($lng->txt("cont_lm_properties"));
336  $this->form->setFormAction($ilCtrl->getFormAction($this, "saveProperties"));
337  }
338 
342  public function getSettingsFormValues()
343  {
344  require_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php");
345  $startfile = ilObjFileBasedLMAccess::_determineStartUrl($this->object->getId());
346 
347  $values = array();
348  $values["cobj_online"] = $this->object->getOnline();
349  if ($startfile != "")
350  {
351  $startfile = basename($startfile);
352  }
353  else
354  {
355  $startfile = $this->lng->txt("no_start_file");
356  }
357 
358  $values["cobj_online"] = $this->object->getOnline();
359  $values["startfile"] = $startfile;
360  $values["title"] = $this->object->getTitle();
361  $values["desc"] = $this->object->getDescription();
362  $values["lic"] = $this->object->getShowLicense();
363  $values["bib"] = $this->object->getShowBibliographicalData();
364 
365  $this->form->setValuesByArray($values);
366  }
367 
374  function toFilesystem()
375  {
376  global $ilCtrl;
377 
378  $ilCtrl->redirectByClass("ilfilesystemgui", "listFiles");
379  }
380 
384  public function saveProperties()
385  {
386  global $tpl, $ilAccess, $ilTabs;
387 
388  $this->initSettingsForm("");
389  if ($this->form->checkInput())
390  {
391  $this->object->setTitle($this->form->getInput("title"));
392  $this->object->setDescription($this->form->getInput("desc"));
393  $this->object->setOnline(ilUtil::yn2tf($_POST["cobj_online"]));
394  $this->object->setShowBibliographicalData($this->form->getInput("bib"));
395 
396  $lic = $this->form->getItemByPostVar("lic");
397  if($lic && !$lic->getDisabled())
398  {
399  $this->object->setShowLicense($this->form->getInput("lic"));
400  }
401 
402  $this->object->update();
403  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
404  $this->ctrl->redirect($this, "properties");
405  }
406 
407  $ilTabs->activateTab("id_settings");
408  $this->form->setValuesByPost();
409  $tpl->setContent($this->form->getHtml());
410  }
411 
417  function editObject()
418  {
419  global $rbacsystem, $tree, $tpl;
420 
421  if (!$rbacsystem->checkAccess("visible,write",$this->object->getRefId()))
422  {
423  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
424  }
425 
426  }
427 
431  function edit()
432  {
433  $this->prepareOutput();
434  $this->editObject();
435  }
436 
440  function cancel()
441  {
442  //$this->setReturnLocation("cancel","fblm_edit.php?cmd=listFiles&ref_id=".$_GET["ref_id"]);
443  $this->cancelObject();
444  }
445 
450  function afterSave($newObj)
451  {
452  if(!$newObj->getStartFile())
453  {
454  // try to set start file automatically
455  $files = array();
456  include_once "Services/Utilities/classes/class.ilFileUtils.php";
457  ilFileUtils::recursive_dirscan($newObj->getDataDirectory(), $files);
458  if(is_array($files["file"]))
459  {
460  $zip_file = null;
461  if(stristr($newObj->getTitle(), ".zip"))
462  {
463  $zip_file = strtolower($newObj->getTitle());
464  $suffix = strrpos($zip_file, ".");
465  if($suffix)
466  {
467  $zip_file = substr($zip_file, 0, $suffix);
468  }
469  }
470  $valid = array("index.htm", "index.html", "start.htm", "start.html");
471  foreach($files["file"] as $idx => $file)
472  {
473  $chk_file = null;
474  if(stristr($file, ".htm"))
475  {
476  $chk_file = strtolower($file);
477  $suffix = strrpos($chk_file, ".");
478  if($suffix)
479  {
480  $chk_file = substr($chk_file, 0, $suffix);
481  }
482  }
483  if(in_array($file, $valid) ||
484  ($chk_file && $zip_file && $chk_file == $zip_file))
485  {
486  $newObj->setStartFile(str_replace($newObj->getDataDirectory()."/", "", $files["path"][$idx]).$file);
487  $newObj->update();
488  break;
489  }
490  }
491  }
492  }
493 
494  // always send a message
495  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
496  ilUtil::redirect("ilias.php?baseClass=ilHTLMEditorGUI&ref_id=".$newObj->getRefId());
497  }
498 
499 
503  function update()
504  {
505  //$this->setReturnLocation("update", "fblm_edit.php?cmd=listFiles&ref_id=".$_GET["ref_id"].
506  // "&obj_id=".$_GET["obj_id"]);
507  $this->updateObject();
508  }
509 
510 
511  function setStartFile($a_file)
512  {
513  $this->object->setStartFile($a_file);
514  $this->object->update();
515  $this->ctrl->redirectByClass("ilfilesystemgui", "listFiles");
516  }
517 
521  function perm()
522  {
523  $this->setFormAction("permSave", "fblm_edit.php?cmd=permSave&ref_id=".$_GET["ref_id"].
524  "&obj_id=".$_GET["obj_id"]);
525  $this->setFormAction("addRole", "fblm_edit.php?ref_id=".$_GET["ref_id"].
526  "&obj_id=".$_GET["obj_id"]."&cmd=addRole");
527  $this->permObject();
528  }
529 
533  function saveBibItemObject($a_target = "")
534  {
535  global $ilTabs;
536 
537  $ilTabs->activateTab("id_bib_data");
538 
539  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
540  $bib_gui =& new ilBibItemGUI();
541  $bib_gui->setObject($this->object);
542  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
543  $bibItemIndex *= 1;
544  if ($bibItemIndex < 0)
545  {
546  $bibItemIndex = 0;
547  }
548  $bibItemIndex = $bib_gui->save($bibItemIndex);
549 
550  if ($a_target == "")
551  {
552  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
553  }
554 
555  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
556  }
557 
561  function saveBibItem()
562  {
563  // questionable workaround to make this old stuff work
564  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
565 
566  //$this->setTabs();
567  $this->saveBibItemObject($this->ctrl->getLinkTarget($this));
568  }
569 
573  function editBibItemObject($a_target = "")
574  {
575  global $ilTabs;
576 
577  $ilTabs->activateTab("id_bib_data");
578 
579  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
580  $bib_gui =& new ilBibItemGUI();
581  $bib_gui->setObject($this->object);
582  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
583  $bibItemIndex *= 1;
584  if ($bibItemIndex < 0)
585  {
586  $bibItemIndex = 0;
587  }
588  if ($a_target == "")
589  {
590  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
591  }
592 
593  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
594  }
595 
599  function editBibItem()
600  {
601  // questionable workaround to make this old stuff work
602  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
603 
604  //$this->setTabs();
605  $this->editBibItemObject($this->ctrl->getLinkTarget($this));
606  }
607 
611  function deleteBibItemObject($a_target = "")
612  {
613  global $ilTabs;
614 
615  $ilTabs->activateTab("id_bib_data");
616 
617  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
618  $bib_gui =& new ilBibItemGUI();
619  $bib_gui->setObject($this->object);
620  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
621  $bib_gui->bib_obj->delete($_GET["bibItemName"], $_GET["bibItemPath"], $bibItemIndex);
622  if (strpos($bibItemIndex, ",") > 0)
623  {
624  $bibItemIndex = substr($bibItemIndex, 0, strpos($bibItemIndex, ","));
625  }
626  if ($a_target == "")
627  {
628  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
629  }
630 
631  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, max(0, $bibItemIndex - 1));
632  }
633 
637  function deleteBibItem()
638  {
639  // questionable workaround to make this old stuff work
640  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
641 
642  //$this->setTabs();
643  $this->deleteBibItemObject($this->ctrl->getLinkTarget($this));
644  }
645 
649  function addBibItemObject($a_target = "")
650  {
651  global $ilTabs;
652 
653  $ilTabs->activateTab("id_bib_data");
654 
655  $bibItemName = $_POST["bibItemName"] ? $_POST["bibItemName"] : $_GET["bibItemName"];
656  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
657  if ($bibItemName == "BibItem")
658  {
659  include_once "./Modules/LearningModule/classes/class.ilBibItem.php";
660  $bib_item =& new ilBibItem();
661  $bib_item->setId($this->object->getId());
662  $bib_item->setType($this->object->getType());
663  $bib_item->read();
664  }
665 
666  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
667  $bib_gui =& new ilBibItemGUI();
668  $bib_gui->setObject($this->object);
669  if ($bibItemIndex == "")
670  $bibItemIndex = 0;
671  $bibItemPath = $_POST["bibItemPath"] ? $_POST["bibItemPath"] : $_GET["bibItemPath"];
672 
673  //if ($bibItemName != "" && $bibItemName != "BibItem")
674  if ($bibItemName != "")
675  {
676  $bib_gui->bib_obj->add($bibItemName, $bibItemPath, $bibItemIndex);
677  $data = $bib_gui->bib_obj->getElement("BibItem");
678  $bibItemIndex = (count($data) - 1);
679  }
680  else
681  {
682  ilUtil::sendInfo($this->lng->txt("bibitem_choose_element"), true);
683  }
684  if ($a_target == "")
685  {
686  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
687  }
688 
689  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
690  }
691 
695  function addBibItem()
696  {
697  // questionable workaround to make this old stuff work
698  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
699 
700  //$this->setTabs();
701  $this->addBibItemObject($this->ctrl->getLinkTarget($this));
702  }
703 
707  function frameset()
708  {
709  global $ilCtrl;
710 
711  $ilCtrl->setCmdClass("ilfilesystemgui");
712  $ilCtrl->setCmd("listFiles");
713  return $this->executeCommand();
714  }
715 
719  function getTemplate()
720  {
721  global $lng;
722 
723  $this->tpl->getStandardTemplate();
724  }
725 
727  {
728  global $ilUser;
729 
730  // Note license usage
731  include_once "Services/License/classes/class.ilLicense.php";
732  ilLicense::_noteAccess($this->object->getId(), $this->object->getType(),
733  $this->object->getRefId());
734 
735  // #9483
736  if ($ilUser->getId() != ANONYMOUS_USER_ID)
737  {
738  include_once "Services/Tracking/classes/class.ilLearningProgress.php";
739  ilLearningProgress::_tracProgress($ilUser->getId(), $this->object->getId(),
740  $this->object->getRefId(), "htlm");
741  }
742 
743  require_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php");
744  require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
745 
746  $startfile = ilObjFileBasedLMAccess::_determineStartUrl($this->object->getId());
748  if ($startfile != "")
749  {
750  ilUtil::redirect($startfile);
751  }
752  }
753 
754  // InfoScreen methods
760  function infoScreen()
761  {
762  $this->ctrl->setCmd("showSummary");
763  $this->ctrl->setCmdClass("ilinfoscreengui");
764  $this->outputInfoScreen();
765  }
766 
770  function showInfoScreen()
771  {
772  $this->outputInfoScreen(true);
773  }
774 
778  function outputInfoScreen($a_standard_locator = true)
779  {
780  global $ilToolbar, $ilAccess, $ilTabs;
781 
782  $ilTabs->activateTab('id_info');
783 
784  $this->lng->loadLanguageModule("meta");
785  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
786 
787  $info = new ilInfoScreenGUI($this);
788  $info->enablePrivateNotes();
789  $info->enableLearningProgress();
790 
791  $info->enableNews();
792  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
793  {
794  $info->enableNewsEditing();
795 
796  $news_set = new ilSetting("news");
797  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
798  if ($enable_internal_rss)
799  {
800  $info->setBlockProperty("news", "settings", true);
801  }
802  }
803 
804  // add read / back button
805  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
806  {
807  // #15127
808  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
809  $button = ilLinkButton::getInstance();
810  $button->setCaption("view");
811  $button->setPrimary(true);
812  $button->setUrl("ilias.php?baseClass=ilHTLMPresentationGUI&ref_id=".$this->object->getRefID());
813  $button->setTarget("ilContObj".$this->object->getId());
814  $ilToolbar->addButtonInstance($button);
815  }
816 
817  // show standard meta data section
818  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
819 
820  // forward the command
821  $this->ctrl->forwardCommand($info);
822  }
823 
824 
825 
829  function setTabs()
830  {
831  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm.svg"));
832 
833  $this->getTabs();
834  $this->tpl->setTitle($this->object->getTitle());
835  }
836 
840  function getTabs()
841  {
842  global $ilUser, $ilAccess, $ilTabs, $lng, $ilHelp;
843 
844  $ilHelp->setScreenIdComponent("htlm");
845 
846  if($ilAccess->checkAccess('write', '', $this->ref_id))
847  {
848  $ilTabs->addTab("id_list_files",
849  $lng->txt("cont_list_files"),
850  $this->ctrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"));
851  }
852 
853  if($ilAccess->checkAccess('visible', '', $this->ref_id))
854  {
855  $ilTabs->addTab("id_info",
856  $lng->txt("info_short"),
857  $this->ctrl->getLinkTargetByClass(array("ilobjfilebasedlmgui", "ilinfoscreengui"), "showSummary"));
858  }
859 
860  if($ilAccess->checkAccess('write', '', $this->ref_id))
861  {
862  $ilTabs->addTab("id_settings",
863  $lng->txt("settings"),
864  $this->ctrl->getLinkTarget($this, "properties"));
865  }
866 
867  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
868  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()))
869  {
870  $ilTabs->addTab("id_learning_progress",
871  $lng->txt("learning_progress"),
872  $this->ctrl->getLinkTargetByClass(array('ilobjfilebasedlmgui','illearningprogressgui'), ''));
873  }
874 
875  include_once("Services/License/classes/class.ilLicenseAccess.php");
876  if ($ilAccess->checkAccess('edit_permission', '', $this->ref_id) &&
878  $this->object->getShowLicense())
879  {
880  $ilTabs->addTab("id_license",
881  $lng->txt("license"),
882  $this->ctrl->getLinkTargetByClass('illicensegui', ''));
883  }
884 
885  if($ilAccess->checkAccess('write', '', $this->ref_id))
886  {
887  include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
888  $mdgui = new ilObjectMetaDataGUI($this->object);
889  $mdtab = $mdgui->getTab();
890  if($mdtab)
891  {
892  $ilTabs->addTab("id_meta_data",
893  $lng->txt("meta_data"),
894  $mdtab);
895  }
896 
897  if($this->object->getShowBibliographicalData())
898  {
899  $ilTabs->addTab("id_bib_data",
900  $lng->txt("bib_data"),
901  $this->ctrl->getLinkTarget($this, "editBibItem"));
902  }
903  }
904 
905 
906  // export
907  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
908  {
909  $ilTabs->addTab("export",
910  $lng->txt("export"),
911  $this->ctrl->getLinkTargetByClass("ilexportgui", ""));
912  }
913 
914  if ($ilAccess->checkAccess('edit_permission', '', $this->object->getRefId()))
915  {
916  $ilTabs->addTab("id_permissions",
917  $lng->txt("perm_settings"),
918  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"));
919  }
920 
921  require_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php");
922  $startfile = ilObjFileBasedLMAccess::_determineStartUrl($this->object->getId());
923 
924  if ($startfile != "")
925  {
926  $ilTabs->addNonTabbedLink("presentation_view",
927  $this->lng->txt("glo_presentation_view"),
928  "ilias.php?baseClass=ilHTLMPresentationGUI&ref_id=".$this->object->getRefID(),
929  "_blank"
930  );
931  }
932 
933  }
934 
940  public static function _goto($a_target)
941  {
942  global $rbacsystem, $ilErr, $lng, $ilAccess;
943 
944  if ($ilAccess->checkAccess("read", "", $a_target) ||
945  $ilAccess->checkAccess("visible", "", $a_target))
946  {
947  ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreen");
948  }
949  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
950  {
951  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
954  }
955 
956  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
957  }
958 
959  function addLocatorItems()
960  {
961  global $ilLocator;
962 
963  if (is_object($this->object))
964  {
965  $ilLocator->addItem($this->object->getTitle(),
966  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"), "", $_GET["ref_id"]);
967  }
968  }
969 
970 
977  function importFileObject($parent_id = null)
978  {
979  try
980  {
981  return parent::importFileObject();
982  }
984  {
985  // since there is no manifest xml we assume that this is an HTML export file
986  $this->createFromDirectory($e->getTmpDir());
987  }
988  }
989 
996  function createFromDirectory($a_dir)
997  {
998  global $ilErr;
999 
1000  if (!$this->checkPermissionBool("create", "", "htlm") || $a_dir == "")
1001  {
1002  $ilErr->raiseError($this->lng->txt("no_create_permission"));
1003  }
1004 
1005  // create instance
1006  $newObj = new ilObjFileBasedLM();
1007  $filename = ilUtil::stripSlashes($_FILES["importfile"]["name"]);
1008  $newObj->setTitle($filename);
1009  $newObj->setDescription("");
1010  $newObj->create();
1011  $newObj->populateByDirectoy($a_dir, $filename);
1012  $this->putObjectInTree($newObj);
1013 
1014  $this->afterSave($newObj);
1015  }
1016 
1017 
1018 
1019 
1023 
1024 
1028  function exportHTML()
1029  {
1030  $inst_id = IL_INST_ID;
1031 
1032  include_once("./Services/Export/classes/class.ilExport.php");
1033 
1034  ilExport::_createExportDirectory($this->object->getId(), "html",
1035  $this->object->getType());
1036  $export_dir = ilExport::_getExportDirectory($this->object->getId(), "html",
1037  $this->object->getType());
1038 
1039  $subdir = $this->object->getType()."_".$this->object->getId();
1040  $filename = $this->subdir.".zip";
1041 
1042  $target_dir = $export_dir."/".$subdir;
1043 
1044  ilUtil::delDir($target_dir);
1045  ilUtil::makeDir($target_dir);
1046 
1047  $source_dir = $this->object->getDataDirectory();
1048 
1049  ilUtil::rCopy($source_dir, $target_dir);
1050 
1051  // zip it all
1052  $date = time();
1053  $zip_file = $export_dir."/".$date."__".IL_INST_ID."__".
1054  $this->object->getType()."_".$this->object->getId().".zip";
1055  ilUtil::zip($target_dir, $zip_file);
1056 
1057  ilUtil::delDir($target_dir);
1058  }
1059 
1060 }
1061 ?>
importFileObject($parent_id=null)
Import file.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
afterSave($newObj)
save object public
outputInfoScreen($a_standard_locator=true)
info screen
ILIAS Setting Class.
Class ilObjectMetaDataGUI.
print $file
getTemplate()
output main header (title and locator)
Class ilInfoScreenGUI.
$_POST['username']
Definition: cron.php:12
exportHTML()
create html package
activateLabels($a_act, $a_label_header)
activate file labels
This class represents a property form user interface.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
const TITLE_LENGTH
max length of object title
$_GET["client_id"]
static signFolderOfStartFile($start_file_path, ilWACCookieInterface $ilWACCookieInterface=null)
Class ilBibItem.
cancelCreationObject($in_rep=false)
cancel action and go back to previous page public
_determineStartUrl($a_id)
check wether learning module is online
addBibItem()
add bib item (module call)
static _isEnabled()
Check, if licencing is enabled This check is called from the ilAccessHandler class.
$valid
edit()
edit properties of object (module form)
File Based Learning Module (HTML) object.
Class ilShopPurchaseGUI.
$cmd
Definition: sahs_server.php:35
static _requiresPurchaseToAccess($a_ref_id, $a_purchasetype='')
this function should be used by all buyable repository objects !!
_createExportDirectory($a_obj_id, $a_export_type="xml", $a_obj_type="")
Create export directory.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
getSettingsFormValues()
Get current values for settings from.
setFormAction($a_cmd, $a_formaction)
set specific form action for command
static _tracProgress($a_user_id, $a_obj_id, $a_ref_id, $a_obj_type='')
This class represents a checkbox property in a property form.
cancelObject($in_rep=false)
cancel action and go back to previous page public
static _lookupTitle($a_id)
lookup object title
editObject()
edit properties of object (admin form)
saveProperties()
Save properties form.
executeCommand()
execute command
initSettingsForm()
Init settings form.
static _goto($a_target)
redirect script
deleteBibItemObject($a_target="")
delete bib item (admin call)
showInfoScreen()
info screen call from inside learning module
infoScreen()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
global $ilCtrl
Definition: ilias.php:18
const IL_RTOKEN_NAME
saveBibItem()
save bib item (module call)
setInfo($a_info)
Set Information Text.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Export User Interface Class.
static checkAccess($a_ref_id, $a_allow_only_read=true)
check access to learning progress
initImportForm($a_new_type)
Init object import form.
$info
Definition: example_052.php:80
ilObjFileBasedLMGUI($a_data, $a_id=0, $a_call_by_reference=true, $a_prepare_output=true)
Constructor.
static _gotoRepositoryNode($a_ref_id, $a_cmd="frameset")
Goto repository root.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId($a_id)
setSize($a_size)
Set Size.
This class represents a text property in a property form.
Class ilBibItemGUI.
redirection script todo: (a better solution should control the processing via a xml file) ...
frameset()
Frameset -> Output list of files.
initCreateForm($a_new_type)
Init object creation form.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
manifest.xml file not found-exception for import
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
prepareOutput()
prepare output
deleteBibItem()
delete bib item (module call)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$filename
Definition: buildRTE.php:89
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
editBibItemObject($a_target="")
edit bib items (admin call)
addBibItemObject($a_target="")
add bib item (admin call)
createFromDirectory($a_dir)
Create new object from a html zip file.
saveBibItemObject($a_target="")
save bib item (admin call)
This class represents a non editable value in a property form.
global $ilUser
Definition: imgupload.php:15
recursive_dirscan($dir, &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
This class represents a text area property in a property form.
properties()
edit properties of object (admin form)
getCreationMode()
get creation mode
User Interface class for file based learning modules (HTML)
updateObject()
updates object entry in object_data
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
putObjectInTree(ilObject $a_obj, $a_parent_node_id=null)
Add object to tree at given position.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
getTabs()
adds tabs to tab gui object
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
_noteAccess($a_obj_id, $a_type, $a_ref_id)
Note the access of the current usr to an object.
File System Explorer GUI class.
static yn2tf($a_yn)
convert "y"/"n" to true/false
setOptionTitle($a_optiontitle)
Set Option Title (optional).
static redirect($a_script)
http redirect to other script
addHeaderAction()
Add header action menu.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
Class ilObjUserTrackingGUI.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
editBibItem()
edit bib items (module call)
setLocator()
set Locator