ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSCORM2004ScoGUI.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 require_once("./Modules/Scorm2004/classes/class.ilSCORM2004NodeGUI.php");
6 require_once("./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
7 require_once("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Objective.php");
8 
22 {
23 
29  var $ctrl = null;
30 
31  function ilSCORM2004ScoGUI($a_slm_obj, $a_node_id = 0)
32  {
33  global $ilCtrl;
34 
35  $ilCtrl->saveParameter($this, "obj_id");
36  $this->ctrl = &$ilCtrl;
37 
38  parent::ilSCORM2004NodeGUI($a_slm_obj, $a_node_id);
39  }
40 
44  function getType()
45  {
46  return "sco";
47  }
48 
52  function &executeCommand()
53  {
54  global $tpl, $ilCtrl, $ilTabs;
55 
56  $tpl->getStandardTemplate();
57 
58  $next_class = $ilCtrl->getNextClass($this);
59  $cmd = $ilCtrl->getCmd();
60 
61  switch($next_class)
62  {
63  // notes
64  case "ilnotegui":
65  switch($_GET["notes_mode"])
66  {
67  default:
68  $ilTabs->setTabActive("sahs_organization");
69  return $this->showOrganization();
70  }
71  break;
72 
73  case 'ilmdeditorgui':
74  $this->setTabs();
75  $this->setLocator();
76  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
77 
78  $md_gui =& new ilMDEditorGUI($this->slm_object->getID(),
79  $this->node_object->getId(), $this->node_object->getType());
80  $md_gui->addObserver($this->node_object,'MDUpdateListener','General');
81  $ilCtrl->forwardCommand($md_gui);
82  break;
83 
84  case 'ilscorm2004pagegui':
85  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php");
86  $page_obj = new ilSCORM2004PageGUI("sahs",$_GET["pg_id"]);
87  //$page_obj->setPresentationTitle($page["title"]);
88  $page_obj->setOutputMode(IL_PAGE_PREVIEW);
89  $ilCtrl->forwardCommand($page_obj);
90  break;
91 
92  default:
93  $cmd = $ilCtrl->getCmd("showOrganization");
94  $ret =& $this->$cmd();
95  break;
96  }
97  }
98 
102  function showProperties()
103  {
104  global $tpl, $lng, $ilTabs, $ilCtrl;
105 
106  $this->setTabs();
107  $this->setLocator();
108  $ilTabs->setTabActive("sahs_desc_objectives");
109 
110  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
111  $form = new ilPropertyFormGUI();
112 
113  // hide objectives page
114  $cb = new ilCheckboxInputGUI($lng->txt("sahs_hide_objectives_page"), "hide_objectives_page");
115  $cb->setInfo($lng->txt("sahs_hide_objectives_page_info"));
116  $form->addItem($cb);
117  $cb->setChecked($this->node_object->getHideObjectivePage());
118 
119  // description
120  $ta = new ilTextAreaInputGUI($lng->txt("description"), "desc");
121  $ta->setRows(4);
122  $ta->setCols(55);
123  $ta->setInfo($lng->txt("sahs_list_info"));
124  $form->setTitle($lng->txt("properties"));
125  $form->addItem($ta);
126  include_once "./Services/MetaData/classes/class.ilMD.php";
127  $meta = new ilMD($this->node_object->getSLMId(), $this->node_object->getId(), $this->node_object->getType());
128  $desc_ids = $meta->getGeneral()->getDescriptionIds();
129  $ta->setValue($meta->getGeneral()->getDescription($desc_ids[0])->getDescription());
130 
131  // objectives
132  $sh = new ilFormSectionHeaderGUI();
133  $sh->setTitle($lng->txt("sahs_learning_objectives"));
134  $form->addItem($sh);
135 
136  $objectives = $this->node_object->getObjectives();
137 
138  foreach ($objectives as $ob)
139  {
140  // map info
141  $mappings = $ob->getMappings();
142  $mapinfo = null;
143  foreach($mappings as $map)
144  {
145  $mapinfo .= $map->getTargetObjectiveID();
146  }
147 
148  if ($mapinfo == null)
149  {
150  $mapinfo = "local";
151  }
152  else
153  {
154  $mapinfo = "global to ".$mapinfo;
155  }
156 
157  // objective
158  $ta = new ilTextAreaInputGUI($mapinfo,
159  "obj_".$ob->getId());
160  $ta->setCols(55);
161  $ta->setRows(4);
162  $ta->setInfo($lng->txt("sahs_list_info"));
163  $form->addItem($ta);
164  $ta->setValue($ob->getObjectiveID());
165  }
166  $form->setFormAction($ilCtrl->getFormAction($this));
167  $form->addCommandButton("updateProperties",
168  $lng->txt("save"));
169  $tpl->setContent($form->getHTML());
170  }
171 
175  function updateProperties()
176  {
177  global $tpl,$lng;
178  $empty = false;
179 
180  foreach ($_POST as $key=>$value) {
181  if(preg_match('/(obj_)(.+)/', $key,$match)){
182  $objective = new ilScorm2004Objective($this->node_object->getId(),$match[2]);
183 // if (!$value)
184 // {
185 // $empty=true;
186 // } else {
187  $objective->setObjectiveID(ilUtil::stripSlashes($value));
188  $objective->updateObjective();
189 // }
190  }
191  }
192 
193  $this->node_object->setHideObjectivePage(ilUtil::stripSlashes($_POST["hide_objectives_page"]));
194  $this->node_object->update();
195 
196  include_once "./Services/MetaData/classes/class.ilMD.php";
197  $meta = new ilMD($this->node_object->getSLMId(), $this->node_object->getId(), $this->node_object->getType());
198  $gen = $meta->getGeneral();
199  $desc_ids = $gen->getDescriptionIds();
200  $des = $gen->getDescription($desc_ids[0]);
201  $des->setDescription(ilUtil::stripSlashes($_POST["desc"]));
202  $des->update();
203  $gen->update();
204 
205  if (!$empty)
206  {
207  ilUtil::sendInfo($lng->txt("saved_successfully"),true);
208  }
209  else
210  {
211  ilUtil::sendFailure($lng->txt("sahs_empty_objectives_are_not_allowed"), true);
212  }
213  $this->showProperties();
214  }
215 
216  function sahs_questions()
217  {
218  global $tpl,$lng, $ilCtrl;
219 
220  $this->setTabs();
221  $this->setLocator();
222 
223  include_once "./Services/Table/classes/class.ilTableGUI.php";
224  include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Page.php";
225  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
226  include_once("./Services/COPage/classes/class.ilPCQuestionGUI.php");
227 
228  // load template for table
229  $tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
230  $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.scormeditor_sco_question.html", "Modules/Scorm2004");
231 
232  $tbl = new ilTableGUI();
233  $tbl->setTitle("Questions for ".$this->node_object->getTitle());
234  $tbl->setHeaderNames(array("Question","Page"));
235  $cols = array("question","page");
236  $tbl->setHeaderVars($cols, $header_params);
237  $tbl->setColumnWidth(array("50%", "50%"));
238  $tbl->disable("sort");
239  $tbl->disable("footer");
240 
241  $tree = new ilTree($this->slm_object->getId());
242  $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
243  $tree->setTreeTablePK("slm_id");
244 
245  foreach($tree->getSubTree($tree->getNodeData($this->node_object->getId()),true,'page') as $page)
246  {
247  // get question ids
248  include_once("./Services/COPage/classes/class.ilPCQuestion.php");
249  $qids = ilPCQuestion::_getQuestionIdsForPage("sahs", $page["obj_id"]);
250  if (count($qids) > 0)
251  {
252  // output questions
253  foreach ($qids as $qid)
254  {
255  $tpl->setCurrentBlock("tbl_content");
256  $tpl->setVariable("TXT_PAGE_TITLE", $page["title"]);
257  $ilCtrl->setParameterByClass("ilscorm2004pagenodegui", "obj_id", $page["obj_id"]);
258  $tpl->setVariable("HREF_EDIT_PAGE", $ilCtrl->getLinkTargetByClass("ilscorm2004pagenodegui", "edit"));
259 
260  $qtitle = assQuestion::_getTitle($qid);
261  $tpl->setVariable("TXT_QUESTION", $qtitle);
262  $ilCtrl->setParameterByClass("ilscorm2004pagenodegui", "obj_id", $page["obj_id"]);
263  //$tpl->setVariable("HREF_EDIT_QUESTION", $ilCtrl->getLinkTargetByClass("ilscorm2004pagenodegui", "edit"));
264 
265  $tpl->setVariable("CSS_ROW", ilUtil::switchColor($i++, "tblrow1", "tblrow2"));
266  $tpl->parseCurrentBlock();
267  }
268  }
269  }
270  $tbl->render();
271  }
272 
273  function getEditTree()
274  {
275 die("deprecated");
276  $slm_tree = new ilTree($this->node_object->getId(),$this->slm_object->getId());
277  $slm_tree->setTreeTablePK("slm_id");
278  $slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
279  return $slm_tree;
280  }
281 
285  function setTabs()
286  {
287  global $ilTabs, $ilCtrl, $tpl, $lng, $ilHelp;
288 
289  $ilHelp->setScreenIdComponent("sahsed");
290 
291  // subelements
292  $ilTabs->addTarget("sahs_organization",
293  $ilCtrl->getLinkTarget($this,'showOrganization'),
294  "showOrganization", get_class($this));
295 
296  // properties (named learning objectives, since here is currently
297  // no other property)
298  $ilTabs->addTarget("sahs_desc_objectives",
299  $ilCtrl->getLinkTarget($this,'showProperties'),
300  "showProperties", get_class($this));
301 
302  // questions
303  $ilTabs->addTarget("sahs_questions",
304  $ilCtrl->getLinkTarget($this,'sahs_questions'),
305  "sahs_questions", get_class($this));
306 
307  // resources
308  $ilTabs->addTarget("cont_files",
309  $ilCtrl->getLinkTarget($this,'sco_resources'),
310  "sco_resources", get_class($this));
311 
312  // metadata
313  $ilTabs->addTarget("meta_data",
314  $ilCtrl->getLinkTargetByClass("ilmdeditorgui",''),
315  "", "ilmdeditorgui");
316 
317  // export
318  $ilTabs->addTarget("export",
319  $ilCtrl->getLinkTarget($this, "showExportList"), "showExportList",
320  get_class($this));
321 
322  // import
323  $ilTabs->addTarget("import",
324  $ilCtrl->getLinkTarget($this, "import"), "import",
325  get_class($this));
326 
327  // preview
328  $ilTabs->addNonTabbedLink("preview",
329  $lng->txt("cont_preview"),
330  $ilCtrl->getLinkTarget($this,'sco_preview'), "_blank");
331 
332  $tpl->setTitleIcon(ilUtil::getImagePath("icon_sco.svg"));
333  $tpl->setTitle(
334  $lng->txt("sahs_unit").": ".$this->node_object->getTitle());
335  }
336 
340  function proceedDragDrop()
341  {
342  global $ilCtrl;
343 
344  //echo "-".$_POST["il_hform_source_id"]."-".$_POST["il_hform_target_id"]."-".$_POST["il_hform_fc"]."-";
345  $this->slm_object->executeDragDrop($_POST["il_hform_source_id"], $_POST["il_hform_target_id"],
346  $_POST["il_hform_fc"], $_POST["il_hform_as_subitem"]);
347  $ilCtrl->redirect($this, "showOrganization");
348  }
349 
353  function sco_preview()
354  {
355  global $tpl, $ilCtrl, $lng;
356 
357  // init main template
358  $tpl = new ilTemplate("tpl.main.html", true, true);
359  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
360  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
361  $tpl->setBodyClass("");
362  $tpl->setCurrentBlock("ContentStyle");
363  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
364  ilObjStyleSheet::getContentStylePath($this->slm_object->getStyleSheetId()));
365  $tpl->parseCurrentBlock();
366 
367  // get javascript
368  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
371  $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/pure.js");
372  $tpl->addJavaScript("./Modules/Scorm2004/scripts/pager.js");
373 
374  $tpl->addOnLoadCode("pager.Init();");
375 
376  $tree = new ilTree($this->slm_object->getId());
377  $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
378  $tree->setTreeTablePK("slm_id");
379  include_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php";
380  include_once "./Services/MetaData/classes/class.ilMD.php";
381 
382  $meta = new ilMD($this->node_object->getSLMId(), $this->node_object->getId(), $this->node_object->getType());
383  $desc_ids = $meta->getGeneral()->getDescriptionIds();
384  $sco_description = $meta->getGeneral()->getDescription($desc_ids[0])->getDescription();
385 
386  // get sco template
387  $sco_tpl = new ilTemplate("tpl.sco.html", true, true, "Modules/Scorm2004");
388 
389  // navigation
390  $lk = ilObjSAHSLearningModule::getAffectiveLocalization($this->node_object->getSLMId());
391  ilSCORM2004Asset::renderNavigation($sco_tpl, "", $lk);
392 
393  // meta page (description and objectives)
394  ilSCORM2004Asset::renderMetaPage($sco_tpl, $this->node_object,
395  $this->node_object->getType());
396 
397  // init export (this initialises glossary template)
399  $terms = $this->node_object->getGlossaryTermIds();
400 
401  // render page
402  foreach($tree->getSubTree($tree->getNodeData($this->node_object->getId()),true,'page') as $page)
403  {
404  $page_obj = new ilSCORM2004PageGUI($this->node_object->getType(),$page["obj_id"],
405  0, $this->slm_object->getId());
406  $page_obj->setPresentationTitle($page["title"]);
407  $page_obj->setOutputMode(IL_PAGE_PREVIEW);
408  $page_obj->setStyleId($this->slm_object->getStyleSheetId());
409  if (count($terms) > 1)
410  {
411  $page_obj->setGlossaryOverviewInfo(
412  ilSCORM2004ScoGUI::getGlossaryOverviewId(), $this->node_object);
413  }
414  $sco_tpl->setCurrentBlock("page_preview");
415  $html = $ilCtrl->getHTML($page_obj);
416  //$sco_tpl->setVariable("PAGE_PRV", $page_obj->showPage("export"));
417  $sco_tpl->setVariable("PAGE_PRV", $html);
418  $sco_tpl->parseCurrentBlock();
419  }
420 
421  $output = $sco_tpl->get();
422 
423  // append glossary entries on the sco level
424  $output.= ilSCORM2004PageGUI::getGlossaryHTML($this->node_object);
425 
426  //insert questions
427  require_once './Modules/Scorm2004/classes/class.ilQuestionExporter.php';
428  $output = preg_replace_callback("/{{{{{(Question;)(il__qst_[0-9]+)}}}}}/",array(get_class($this), 'insertQuestion'),$output);
429 // $output = preg_replace("/&#123;/","",$output);
430 // $output = preg_replace("/&#125;/","",$output);
431  $output = "<script>var ScormApi=null;".ilQuestionExporter::questionsJS()."</script>".$output;
432 
433  $lk = ilObjSAHSLearningModule::getAffectiveLocalization($this->node_object->getSLMId());
434 // include_once("./Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php");
435 // ilSCORM2004PageGUI::addPreparationJavascript($tpl, $lk);
436 
437  $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/question_handling.js");
438  $tpl->addCss("./Modules/Scorm2004/templates/default/question_handling.css");
439 
440  include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
442 
443  //inline JS
444  $output .='<script type="text/javascript" src="./Modules/Scorm2004/scripts/questions/question_handling.js"></script>';
445  $tpl->setVariable("CONTENT", $output);
446  }
447 
448  //callback function for question export
449  private function insertQuestion($matches)
450  {
451  $q_exporter = new ilQuestionExporter(false);
452  return $q_exporter->exportQuestion($matches[2]);
453  }
454 
458  public function selectExport()
459  {
460  switch ($_POST['select_export'])
461  {
462  case "exportScorm12":
463  case "exportScorm2004_3rd":
464  case "exportScorm2004_4th":
465  case "exportPDF":
466  case "exportHTML":
467  $this->ctrl->redirect($this, $_POST['select_export']);
468  break;
469  default:
470  $this->ctrl->redirect($this, 'showExportList');
471  break;
472  }
473  }
474 
475  function showExportList()
476  {
477  global $tpl, $ilCtrl, $lng;
478 
479  $this->setTabs();
480  $this->setLocator();
481 
482 
483  $template = new ilTemplate("tpl.scorm2004_export_buttons.html", true, true, 'Modules/Scorm2004');
484 
485  $buttons = array(
486  "exportScorm2004_3rd" => $lng->txt("scorm_create_export_file_scrom2004"),
487  "exportScorm2004_4th" => $lng->txt("scorm_create_export_file_scrom2004_4th"),
488  "exportScorm12" => $lng->txt("scorm_create_export_file_scrom12"),
489  "exportPDF" => $lng->txt("scorm_create_export_file_pdf"),
490  "exportHTML" => $lng->txt("scorm_create_export_file_html")
491  );
492  foreach ($buttons as $value => $text)
493  {
494  $template->setCurrentBlock('option');
495  $template->setVariable('OPTION_VALUE', $value);
496  $template->setVariable('OPTION_TITLE', ilUtil::prepareFormOutput($text));
497  $template->parseCurrentBlock();
498  }
499  $template->setVariable('EXPORT_TITLE', $lng->txt('export'));
500  $template->setVariable('EXPORT_LABEL', $lng->txt('type'));
501  $template->setVariable('FORMACTION', $ilCtrl->getFormAction($this, 'selectExport'));
502 
503  $export_files = $this->node_object->getExportFiles();
504 
505  include_once "./Modules/Scorm2004/classes/class.ilSCORM2004ExportTableGUI.php";
506  $table_gui = new ilSCORM2004ExportTableGUI($this, 'showExportList');
507  $data = array();
508  foreach ($export_files as $exp_file)
509  {
510  $filetype = $exp_file['type'];
511  // $public_str = ($exp_file["file"] == $this->object->getPublicExportFile($filetype))
512  // ? " <b>(".$this->lng->txt("public").")<b>"
513  // : "";
514  $file_arr = explode("__", $exp_file["file"]);
515  array_push($data, array('file' => $exp_file['file'], 'filetype' => $filetype, 'date' => ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)), 'size' => $exp_file['size'], 'type' => $exp_file['type'].$public_str));
516  }
517  $table_gui->setData($data);
518  $tpl->setVariable('ADM_CONTENT', $template->get() . "\n" . $table_gui->getHTML());
519 
520 
521  }
522 
524  {
525  $export = new ilScorm2004Export($this->node_object,'SCORM 2004 4th');
526  $export->buildExportFile();
527  $this->ctrl->redirect($this, "showExportList");
528  }
529 
530 
532  {
533  $export = new ilScorm2004Export($this->node_object,'SCORM 2004 3rd');
534  $export->buildExportFile();
535  $this->ctrl->redirect($this, "showExportList");
536  }
537 
538  function exportScorm12()
539  {
540  $export = new ilScorm2004Export($this->node_object,'SCORM 1.2');
541  $export->buildExportFile();
542  $this->ctrl->redirect($this, "showExportList");
543  }
544 
545  function exportHTML()
546  {
547  $export = new ilScorm2004Export($this->node_object,'HTML');
548  $export->buildExportFile();
549  $this->ctrl->redirect($this, "showExportList");
550  }
551 
552  function exportISO()
553  {
554  $export = new ilScorm2004Export($this->node_object,'ISO');
555  $export->buildExportFile();
556  $this->ctrl->redirect($this, "showExportList");
557  }
558 
559  function exportPDF()
560  {
561  $export = new ilScorm2004Export($this->node_object,'PDF');
562  $export->buildExportFile();
563  $this->ctrl->redirect($this, "showExportList");
564  }
565 
567  {
568  $file = str_replace("..", "", $_GET['file']);
569  $export = new ilSCORM2004Export($this->node_object);
570  $export_dir = $export->getExportDirectoryForType($_GET['type']);
571  ilUtil::deliverFile($export_dir."/".$file, $file);
572  }
573 
578  {
579  global $lng, $tpl;
580 
581  if(!isset($_POST["file"]))
582  {
583  ilUtil::sendInfo($lng->txt("no_checkbox"),true);
584  $this->ctrl->redirect($this, "showExportList");
585  }
586 
587  ilUtil::sendQuestion($lng->txt("info_delete_sure"));
588  $export_files = $this->node_object->getExportFiles();
589 
590  include_once "./Modules/Scorm2004/classes/class.ilSCORM2004ExportTableGUI.php";
591  $table_gui = new ilSCORM2004ExportTableGUI($this, 'showExportList', true);
592  $data = array();
593  foreach ($export_files as $exp_file)
594  {
595  foreach ($_POST['file'] as $delete_file)
596  {
597  if (strcmp($delete_file, $exp_file['file']) == 0)
598  {
599  // $public_str = ($exp_file["file"] == $this->object->getPublicExportFile($exp_file["type"]))
600  // ? " <b>(".$this->lng->txt("public").")<b>"
601  // : "";
602  $file_arr = explode("__", $exp_file["file"]);
603  array_push($data, array('file' => $exp_file['file'], 'date' => ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)), 'size' => $exp_file['size'], 'type' => $exp_file['type'].$public_str));
604  }
605  }
606  }
607  $table_gui->setData($data);
608  $tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
609  }
610 
615  {
616  ilSession::clear("ilExportFiles");
617  $this->ctrl->redirect($this, "showExportList");
618  }
619 
620 
624  function deleteExportFile()
625  {
626  global $lng;
627  include_once "./Services/Utilities/classes/class.ilUtil.php";
628  $export = new ilSCORM2004Export($this->node_object);
629  foreach($_POST['file'] as $idx => $file)
630  {
631  $export_dir = $export->getExportDirectoryForType($_POST['type'][$idx]);
632  $exp_file = $export_dir."/".$file;
633  if (@is_file($exp_file))
634  {
635  unlink($exp_file);
636  }
637  }
638  ilUtil::sendSuccess($lng->txt('msg_deleted_export_files'), true);
639  $this->ctrl->redirect($this, "showExportList");
640  }
641 
643  {
644  $export_files = array();
645 
646  require_once "./Modules/Scorm2004/classes/class.ilSCORM2004Page.php";
647  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
648  include_once "./Modules/File/classes/class.ilObjFile.php";
649  $tree = new ilTree($this->slm_object->getId());
650  $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
651  $tree->setTreeTablePK("slm_id");
652  foreach($tree->getSubTree($tree->getNodeData($this->node_object->getId()),true,'page') as $page)
653  {
654  $page_obj = new ilSCORM2004Page($page["obj_id"]);
655  $page_obj->buildDom();
656  $mob_ids = $page_obj->collectMediaObjects(false);
657  foreach($mob_ids as $mob_id)
658  {
659  if ($mob_id > 0 && ilObject::_exists($mob_id))
660  {
661  $path = ilObjMediaObject::_lookupStandardItemPath($mob_id,false,false);
662 
663  $media_obj = new ilObjMediaObject($mob_id);
664  $export_files[$i]["date"] = $media_obj->getCreateDate();
665  $export_files[$i]["size"] = @filesize($path); // could be remote, e.g. youtube video
666  $export_files[$i]["file"] = $media_obj->getTitle();
667  $export_files[$i]["type"] = $media_obj->getDescription();
668  $export_files[$i]["path"] = $path;
669  $this->ctrl->setParameter($this, "resource",
670  rawurlencode(ilObjMediaObject::_lookupStandardItemPath($mob_id,false,false)));
671  $export_files[$i]["link"] = $this->ctrl->getLinkTarget($this,"downloadResource");
672  $i++;
673  }
674  }
675  include_once("./Services/COPage/classes/class.ilPCFileList.php");
676  $file_ids =ilPCFileList::collectFileItems($page_obj, $page_obj->getDomDoc());
677  foreach($file_ids as $file_id)
678  {
679  $file_obj = new ilObjFile($file_id, false);
680  $export_files[$i]["date"] = $file_obj->getCreateDate();
681  $export_files[$i]["size"] = $file_obj->getFileSize();
682  $export_files[$i]["file"] = $file_obj->getFileName();
683  $export_files[$i]["type"] = $file_obj->getFileType();
684  $export_files[$i]["file_id"] = $file_id;
685  $this->ctrl->setParameter($this, "file_id",$file_id);
686  $export_files[$i]["link"] = $this->ctrl->getLinkTarget($this,"downloadFile","");
687  $i++;
688  }
689  unset($page_obj);
690  }
691 
692  return $export_files;
693  }
694 
695  function sco_resources()
696  {
697  global $tpl, $lng, $ilCtrl;;
698 
699  $this->setTabs();
700  $this->setLocator();
701  $i = 0;
702 
703  $export_files = $this->getExportResources();
704 
705  // create table
706  require_once("./Services/Table/classes/class.ilTableGUI.php");
707  $tbl = new ilTableGUI();
708 
709  // load files templates
710  $tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
711 
712  // load template for table content data
713  $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.download_file_row.html", "Modules/LearningModule");
714 
715  $num = 0;
716 
717  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
718 
719  $tbl->setTitle($lng->txt("cont_files"));
720 
721  $tbl->setHeaderNames(array($lng->txt("cont_format"),
722  $lng->txt("cont_file"),
723  $lng->txt("size"), $lng->txt("date"),
724  ""));
725 
726  $cols = array("format", "file", "size", "date", "download");
727  $header_params = array("ref_id" => $_GET["ref_id"], "obj_id" => $_GET["obj_id"],
728  "cmd" => "sco_resources", "cmdClass" => strtolower(get_class($this)),
729  "cmdNode" => $_GET["cmdNode"], "baseClass" => $_GET["baseClass"]);
730  $tbl->setHeaderVars($cols, $header_params);
731  $tbl->setColumnWidth(array("10%", "30%", "20%", "20%","20%"));
732  $tbl->disable("sort");
733 
734  $tbl->setOrderColumn($_GET["sort_by"]);
735  $tbl->setOrderDirection($_GET["sort_order"]);
736  $tbl->setLimit($_GET["limit"]);
737  $tbl->setOffset($_GET["offset"]);
738  $tbl->setMaxCount($this->maxcount); // ???
739 
740 
741  $tbl->setMaxCount(count($export_files));
742 
743  // footer
744  $tbl->setFooter("tblfooter",$lng->txt("previous"),$lng->txt("next"));
745  //$tbl->disable("footer");
746 
747  $tbl->setMaxCount(count($export_files));
748  $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
749 
750  $tbl->render();
751  if(count($export_files) > 0)
752  {
753  $i=0;
754  foreach($export_files as $exp_file)
755  {
756  /* remote files (youtube videos) have no size, so we allow them now
757  if (!$exp_file["size"] > 0)
758  {
759  continue;
760  }
761  */
762 
763  $tpl->setCurrentBlock("tbl_content");
764  $tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
765 
766  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
767  $tpl->setVariable("CSS_ROW", $css_row);
768 
769  $tpl->setVariable("TXT_SIZE", $exp_file["size"]);
770  $tpl->setVariable("TXT_FORMAT", $exp_file["type"]);
771 
772  $tpl->setVariable("TXT_DATE", $exp_file["date"]);
773 
774  if($exp_file["size"] > 0)
775  {
776  $tpl->setVariable("TXT_DOWNLOAD", $lng->txt("download"));
777  $ilCtrl->setParameter($this, "resource", rawurlencode($exp_file["path"]));
778  $ilCtrl->setParameter($this, "file_id", rawurlencode($exp_file["file_id"]));
779  $tpl->setVariable("LINK_DOWNLOAD",
780  $ilCtrl->getLinkTarget($this, "downloadResource"));
781  }
782  else
783  {
784  $tpl->setVariable("TXT_DOWNLOAD", $lng->txt("show"));
785  $tpl->setVariable("LINK_TARGET", " target=\"_blank\"");
786  $tpl->setVariable("LINK_DOWNLOAD", $exp_file["path"]);
787  }
788 
789  $tpl->parseCurrentBlock();
790  }
791  } //if is_array
792  /* not found in template?
793  else
794  {
795  $tpl->setCurrentBlock("notfound");
796  $tpl->setVariable("TXT_OBJECT_NOT_FOUND", $lng->txt("obj_not_found"));
797  $tpl->setVariable("NUM_COLS", 4);
798  $tpl->parseCurrentBlock();
799  }
800  */
801  // $tpl->parseCurrentBlock();
802  }
803 
804  function downloadResource()
805  {
806  $export_files = $this->getExportResources();
807 
808  if ($_GET["file_id"] > 0)
809  {
810  $file = new ilObjFile($_GET["file_id"], false);
811  }
812 
813  // check that file really belongs to SCORM module (security)
814  foreach ($export_files as $f)
815  {
816  if (is_object($file))
817  {
818  if ($f["file"] == $file->getFileName())
819  {
820  $file->sendFile();
821  }
822  }
823  else
824  {
825  if ($f["path"] == $_GET["resource"])
826  {
827  if (is_file($f["path"]))
828  {
829  ilUtil::deliverFile($f["path"], $f["file"]);
830  }
831  }
832  }
833  }
834  exit;
835  }
836 
837  function downloadFile()
838  {
839  $file = explode("_", $_GET["file_id"]);
840  require_once("./Modules/File/classes/class.ilObjFile.php");
841  $fileObj =& new ilObjFile($file[count($file) - 1], false);
842  $fileObj->sendFile();
843  exit;
844  }
845 
846  function import()
847  {
848  global $tpl, $lng;
849 
850  $this->setTabs();
851  $this->setLocator();
852 
853  $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.scormeditor_sco_import.html", "Modules/Scorm2004");
854 
855  $tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_lm.svg'));
856  $tpl->setVariable("ALT_IMG", $lng->txt("obj_sahs"));
857 
858  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
859 
860  $tpl->setVariable("BTN_NAME", "importSave");
861 
862  // this leads to _top target which removes the left organization frame
863  //$tpl->setVariable("TARGET", ' target="'.ilFrameTargetInfo::_getFrame("MainContent").'" ');
864 
865  $tpl->setVariable("TXT_UPLOAD", $lng->txt("upload"));
866  $tpl->setVariable("TXT_CANCEL", $lng->txt("cancel"));
867  $tpl->setVariable("TXT_IMPORT_SCO", $lng->txt("import_sco_object"));
868  $tpl->setVariable("TXT_SELECT_FILE", $lng->txt("select_file"));
869  $tpl->setVariable("TXT_VALIDATE_FILE", $lng->txt("cont_validate_file"));
870 
871  // get the value for the maximal uploadable filesize from the php.ini (if available)
872  $umf=get_cfg_var("upload_max_filesize");
873  // get the value for the maximal post data from the php.ini (if available)
874  $pms=get_cfg_var("post_max_size");
875 
876  //convert from short-string representation to "real" bytes
877  $multiplier_a=array("K"=>1024, "M"=>1024*1024, "G"=>1024*1024*1024);
878 
879  $umf_parts=preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
880  $pms_parts=preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
881 
882  if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
883  if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
884 
885  // use the smaller one as limit
886  $max_filesize=min($umf, $pms);
887 
888  if (!$max_filesize) $max_filesize=max($umf, $pms);
889 
890  //format for display in mega-bytes
891  $max_filesize=sprintf("%.1f MB",$max_filesize/1024/1024);
892 
893  // gives out the limit as a little notice
894  $tpl->setVariable("TXT_FILE_INFO", $lng->txt("file_notice")." $max_filesize");
895  }
896 
897  function importSave()
898  {
899  global $_FILES, $rbacsystem;
900  global $ilias, $lng;
901 
902  // check if file was uploaded
903  $source = $_FILES["scormfile"]["tmp_name"];
904  if (($source == 'none') || (!$source))
905  {
906  $ilias->raiseError("No file selected!",$ilias->error_obj->MESSAGE);
907  }
908  // check create permission
909  if (!$rbacsystem->checkAccess("write", $_GET["ref_id"]))
910  {
911  $ilias->raiseError($lng->txt("no_create_permission"), $ilias->error_obj->WARNING);
912  }
913  // get_cfg_var("upload_max_filesize"); // get the may filesize form t he php.ini
914  switch ($__FILES["scormfile"]["error"])
915  {
916  case UPLOAD_ERR_INI_SIZE:
917  $ilias->raiseError($lng->txt("err_max_file_size_exceeds"),$ilias->error_obj->MESSAGE);
918  break;
919 
920  case UPLOAD_ERR_FORM_SIZE:
921  $ilias->raiseError($lng->txt("err_max_file_size_exceeds"),$ilias->error_obj->MESSAGE);
922  break;
923 
924  case UPLOAD_ERR_PARTIAL:
925  $ilias->raiseError($lng->txt("err_partial_file_upload"),$ilias->error_obj->MESSAGE);
926  break;
927 
928  case UPLOAD_ERR_NO_FILE:
929  $ilias->raiseError($lng->txt("err_no_file_uploaded"),$ilias->error_obj->MESSAGE);
930  break;
931  }
932 
933  $file = pathinfo($_FILES["scormfile"]["name"]);
934  $name = substr($file["basename"], 0, strlen($file["basename"]) - strlen($file["extension"]) - 1);
935  $file_path = $this->slm_object->getDataDirectory()."/".$this->node_object->getId()."/".$_FILES["scormfile"]["name"];
936  ilUtil::createDirectory($this->slm_object->getDataDirectory()."/".$this->node_object->getId());
937  ilUtil::moveUploadedFile($_FILES["scormfile"]["tmp_name"], $_FILES["scormfile"]["name"], $file_path);
938  ilUtil::unzip($file_path);
939  ilUtil::renameExecutables($this->slm_object->getDataDirectory()."/".$this->node_object->getId());
940 
941  include_once ("./Modules/Scorm2004/classes/ilSCORM13Package.php");
942  $newPack = new ilSCORM13Package();
943  $newPack->il_importSco($this->slm_object->getId(),$this->node_object->getId(),$this->slm_object->getDataDirectory()."/".$this->node_object->getId());
944 
945  $this->ctrl->redirect($this, "showOrganization");
946  }
947 
951  function cancel()
952  {
953  $this->ctrl->redirect($this, "showOrganization");
954  }
955 
962  static function getGlossaryOverviewId()
963  {
964  return "sco_glo_ov";
965  }
966 
973  static function getGloOverviewOv($a_sco)
974  {
975  global $lng;
976 
977  $tpl = new ilTemplate("tpl.sco_glossary_overview.html", true, true, "Modules/Scorm2004");
978 
979  $terms = $a_sco->getGlossaryTermIds();
980  $lk = ilObjSAHSLearningModule::getAffectiveLocalization($a_sco->getSLMId());
981  foreach ($terms as $k => $t)
982  {
983  $tpl->setCurrentBlock("link");
984  $tpl->setVariable("TXT_LINK", $t);
985  $tpl->setVariable("ID_LINK", "glo_ov_t".$k);
986  $tpl->parseCurrentBlock();
987  }
988 
989  $tpl->setVariable("DIV_ID", ilSCORM2004ScoGUI::getGlossaryOverviewId());
990  $tpl->setVariable("TXT_SCO_GLOSSARY", $lng->txtlng("content", "cont_sco_glossary", $lk));
991  $tpl->setVariable("TXT_CLOSE", $lng->txtlng("common", "close", $lk));
992 
993  if (count($terms) > 1)
994  {
995  return $tpl->get();
996  }
997  else
998  {
999  return "";
1000  }
1001  }
1002 
1003 }
1004 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
static initjQueryUI()
Init jQuery UI (see included_components.txt for included components)
print $file
& executeCommand()
execute command
Scorm 2004 Question Exporter.
const IL_PAGE_PREVIEW
exit
Definition: login.php:54
$_POST['username']
Definition: cron.php:12
static _getQuestionIdsForPage($a_parent_type, $a_page_id, $a_lang="-")
Get all questions of a page.
proceedDragDrop()
Perform drag and drop action.
This class represents a property form user interface.
Class ilSCORM2004NodeGUI.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
This class represents a section header in a property form.
$ctrl
Constructor public.
static getGloOverviewOv($a_sco)
des
$cmd
Definition: sahs_server.php:35
addObserver(&$a_class, $a_method, $a_element)
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static renderMetaPage($a_tpl, $a_sco, $a_asset_type="", $mode="")
Render meta page (description/objectives at beginning)
selectExport()
Select the export type of the SCORM 2004 module.
This class represents a checkbox property in a property form.
setLocator()
Set Locator Items.
Class ilTableGUI.
_getTitle($a_q_id)
Returns the title of a question.
const IL_CAL_UNIX
static getGlossaryOverviewId()
Get sco glossary overlay id.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
cancelDeleteExportFile()
cancel deletion of export files
setInfo($a_info)
Set Information Text.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Class ilSCORM2004Page.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
special template class to simplify handling of ITX/PEAR
static collectFileItems($a_page, $a_domdoc)
Get all file items that are used within the page.
Class ilObjFile.
static formatDate(ilDateTime $date)
Format a date public.
& getGeneral()
Definition: class.ilMD.php:55
Date and time handling
setPresentationTitle($a_title="")
static createDirectory($a_dir, $a_mod=0755)
create directory
Export class for SCORM 2004 object.
Class ilObjMediaObject.
static clear($a_var)
Unset a value.
showOrganization()
Confirm deletion screen (delete page or structure objects)
setTableNames($a_table_tree, $a_table_obj_data, $a_table_obj_reference="")
set table names The primary key of the table containing your object_data must be &#39;obj_id&#39; You may use...
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
setTreeTablePK($a_column_name)
set column containing primary key in tree table public
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
updateProperties()
update Properties
static renderNavigation($a_tpl, $a_spacer_img="", $a_lang="")
Render navigation.
getContentStylePath($a_style_id)
get content style path
getAffectiveLocalization($a_id)
Get affective localization.
Class ilSCORM2004Page GUI class.
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
global $lng
Definition: privfeed.php:40
$path
Definition: index.php:22
This class represents a text area property in a property form.
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows) ...
static _lookupStandardItemPath($a_mob_id, $a_url_encode=false, $a_web=true)
Get path for standard item.
static initjQuery($a_tpl=null)
Init jQuery.
Class ilSCORM2004ScoGUI.
static getGlossaryHTML($a_sco)
Get glossary html (only in export mode)
deleteExportFile()
delete export files
ilSCORM2004ScoGUI($a_slm_obj, $a_node_id=0)
showProperties()
Show learning objectives.
confirmDeleteExportFile()
confirmation screen for export file deletion
static initExport()
Init export.
static initJavascript()
Init javascript.