ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjGlossary.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("classes/class.ilObject.php");
6 require_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
7 
19 class ilObjGlossary extends ilObject
20 {
21 
26  function ilObjGlossary($a_id = 0,$a_call_by_reference = true)
27  {
28  $this->type = "glo";
29  $this->ilObject($a_id,$a_call_by_reference);
30  }
31 
35  function create($a_upload = false)
36  {
37  global $ilDB;
38 
40 
41  // meta data will be created by
42  // import parser
43  if (!$a_upload)
44  {
45  $this->createMetaData();
46  }
47 
48  $ilDB->manipulate("INSERT INTO glossary (id, is_online, virtual, pres_mode, snippet_length) VALUES (".
49  $ilDB->quote($this->getId(), "integer").",".
50  $ilDB->quote("n", "text").",".
51  $ilDB->quote($this->getVirtualMode(), "text").",".
52  $ilDB->quote("table", "text").",".
53  $ilDB->quote(200, "integer").
54  ")");
55  $this->setPresentationMode("table");
56  $this->setSnippetLength(200);
57 
58  }
59 
63  function read()
64  {
65  global $ilDB;
66 
67  parent::read();
68 # echo "Glossary<br>\n";
69 
70  $q = "SELECT * FROM glossary WHERE id = ".
71  $ilDB->quote($this->getId(), "integer");
72  $gl_set = $ilDB->query($q);
73  $gl_rec = $ilDB->fetchAssoc($gl_set);
74  $this->setOnline(ilUtil::yn2tf($gl_rec["is_online"]));
75  $this->setVirtualMode($gl_rec["virtual"]);
76  $this->setPublicExportFile("xml", $gl_rec["public_xml_file"]);
77  $this->setPublicExportFile("html", $gl_rec["public_html_file"]);
78  $this->setActiveGlossaryMenu(ilUtil::yn2tf($gl_rec["glo_menu_active"]));
79  $this->setActiveDownloads(ilUtil::yn2tf($gl_rec["downloads_active"]));
80  $this->setPresentationMode($gl_rec["pres_mode"]);
81  $this->setSnippetLength($gl_rec["snippet_length"]);
82  }
83 
89  function getDescription()
90  {
91  return parent::getDescription();
92  }
93 
97  function setDescription($a_description)
98  {
99  parent::setDescription($a_description);
100  }
101 
102 
106  function setVirtualMode($a_mode)
107  {
108  switch ($a_mode)
109  {
110  case "level":
111  case "subtree":
112  // case "fixed":
113  $this->virtual_mode = $a_mode;
114  $this->virtual = true;
115  break;
116 
117  default:
118  $this->virtual_mode = "none";
119  $this->virtual = false;
120  break;
121  }
122  }
123 
127  function getVirtualMode()
128  {
129  return $this->virtual_mode;
130  }
131 
135  function isVirtual()
136  {
137  return $this->virtual;
138  }
139 
145  function getTitle()
146  {
147  return parent::getTitle();
148  }
149 
153  function setTitle($a_title)
154  {
155  parent::setTitle($a_title);
156 // $this->meta_data->setTitle($a_title);
157  }
158 
164  function setPresentationMode($a_val)
165  {
166  $this->pres_mode = $a_val;
167  }
168 
175  {
176  return $this->pres_mode;
177  }
178 
184  function setSnippetLength($a_val)
185  {
186  $this->snippet_length = $a_val;
187  }
188 
194  function getSnippetLength()
195  {
196  return $this->snippet_length;
197  }
198 
199  function setOnline($a_online)
200  {
201  $this->online = $a_online;
202  }
203 
204  function getOnline()
205  {
206  return $this->online;
207  }
208 
212  function _lookupOnline($a_id)
213  {
214  global $ilDB;
215 
216  $q = "SELECT is_online FROM glossary WHERE id = ".
217  $ilDB->quote($a_id, "integer");
218  $lm_set = $ilDB->query($q);
219  $lm_rec = $ilDB->fetchAssoc($lm_set);
220 
221  return ilUtil::yn2tf($lm_rec["is_online"]);
222  }
223 
230  static protected function lookup($a_id, $a_property)
231  {
232  global $ilDB;
233 
234  $set = $ilDB->query("SELECT $a_property FROM glossary WHERE id = ".
235  $ilDB->quote($a_id, "integer"));
236  $rec = $ilDB->fetchAssoc($set);
237 
238  return $rec[$a_property];
239  }
240 
247  static function lookupSnippetLength($a_id)
248  {
249  return ilObjGlossary::lookup($a_id, "snippet_length");
250  }
251 
252 
253  function setActiveGlossaryMenu($a_act_glo_menu)
254  {
255  $this->glo_menu_active = $a_act_glo_menu;
256  }
257 
259  {
260  return $this->glo_menu_active;
261  }
262 
263  function setActiveDownloads($a_down)
264  {
265  $this->downloads_active = $a_down;
266  }
267 
268  function isActiveDownloads()
269  {
270  return $this->downloads_active;
271  }
272 
276  function update()
277  {
278  global $ilDB;
279 
280  $this->updateMetaData();
281 
282  $ilDB->manipulate("UPDATE glossary SET ".
283  " is_online = ".$ilDB->quote(ilUtil::tf2yn($this->getOnline()), "text").",".
284  " virtual = ".$ilDB->quote($this->getVirtualMode(), "text").",".
285  " public_xml_file = ".$ilDB->quote($this->getPublicExportFile("xml"), "text").",".
286  " public_html_file = ".$ilDB->quote($this->getPublicExportFile("html"), "text").",".
287  " glo_menu_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveGlossaryMenu()), "text").",".
288  " downloads_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveDownloads()), "text").", ".
289  " pres_mode = ".$ilDB->quote($this->getPresentationMode(), "text").", ".
290  " snippet_length = ".$ilDB->quote($this->getSnippetLength(), "integer")." ".
291  " WHERE id = ".$ilDB->quote($this->getId(), "integer"));
292 
293  parent::update();
294  }
295 
296 
300  function getTermList($searchterm = "", $a_letter = "", $a_def = "")
301  {
302  $glo_ids = $this->getAllGlossaryIds();
303 
304  $list = ilGlossaryTerm::getTermList($glo_ids, $searchterm, $a_letter, $a_def);
305  return $list;
306  }
307 
311  function getFirstLetters()
312  {
313  $glo_ids = $this->getAllGlossaryIds();
314  $first_letters = ilGlossaryTerm::getFirstLetters($glo_ids);
315  return $first_letters;
316  }
317 
324  function getAllGlossaryIds()
325  {
326  global $tree;
327 
328  if ($this->isVirtual())
329  {
330  $glo_ids = array();
331 
332 
333  $virtual_mode = $this->getRefId() ? $this->getVirtualMode() : '';
334  switch ($virtual_mode)
335  {
336  case "level":
337  $glo_arr = $tree->getChildsByType($tree->getParentId($this->getRefId()),"glo");
338 
339  foreach ($glo_arr as $glo)
340  {
341  {
342  $glo_ids[] = $glo['obj_id'];
343  }
344  }
345  break;
346 
347  case "subtree":
348  $subtree_nodes = $tree->getSubTree($tree->getNodeData($tree->getParentId($this->getRefId())));
349 
350  foreach ($subtree_nodes as $node)
351  {
352  if ($node['type'] == 'glo')
353  {
354  $glo_ids[] = $node['obj_id'];
355  }
356  }
357  break;
358 
359  // fallback to none virtual mode in case of error
360  default:
361  $glo_ids[] = $this->getId();
362  break;
363  }
364  }
365  else
366  {
367  $glo_ids = $this->getId();
368  }
369 
370  return $glo_ids;
371  }
372 
379  {
380  $glo_data_dir = ilUtil::getDataDir()."/glo_data";
381  ilUtil::makeDir($glo_data_dir);
382  if(!is_writable($glo_data_dir))
383  {
384  $this->ilias->raiseError("Glossary Data Directory (".$glo_data_dir
385  .") not writeable.",$this->ilias->error_obj->FATAL);
386  }
387 
388  // create glossary directory (data_dir/glo_data/glo_<id>)
389  $glo_dir = $glo_data_dir."/glo_".$this->getId();
390  ilUtil::makeDir($glo_dir);
391  if(!@is_dir($glo_dir))
392  {
393  $this->ilias->raiseError("Creation of Glossary Directory failed.",$this->ilias->error_obj->FATAL);
394  }
395  // create Import subdirectory (data_dir/glo_data/glo_<id>/import)
396  $import_dir = $glo_dir."/import";
397  ilUtil::makeDir($import_dir);
398  if(!@is_dir($import_dir))
399  {
400  $this->ilias->raiseError("Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
401  }
402  }
403 
408  {
409  $export_dir = ilUtil::getDataDir()."/glo_data"."/glo_".$this->getId()."/import";
410 
411  return $export_dir;
412  }
413 
417  function createExportDirectory($a_type = "xml")
418  {
419  include_once("./Services/Export/classes/class.ilExport.php");
420  return ilExport::_createExportDirectory($this->getId(), $a_type, $this->getType());
421  }
422 
426  function getExportDirectory($a_type = "xml")
427  {
428  include_once("./Services/Export/classes/class.ilExport.php");
429  return ilExport::_getExportDirectory($this->getId(), $a_type, $this->getType());
430  }
431 
435  function getExportFiles()
436  {
437  include_once("./Services/Export/classes/class.ilExport.php");
438  return ilExport::_getExportFiles($this->getId(), array("xml", "html"), $this->getType());
439  }
440 
447  function setPublicExportFile($a_type, $a_file)
448  {
449  $this->public_export_file[$a_type] = $a_file;
450  }
451 
459  function getPublicExportFile($a_type)
460  {
461  return $this->public_export_file[$a_type];
462  }
463 
467  function exportHTML($a_target_dir, $log)
468  {
469  global $ilias, $tpl;
470 
471  // initialize temporary target directory
472  ilUtil::delDir($a_target_dir);
473  ilUtil::makeDir($a_target_dir);
474 
475  include_once("./Services/COPage/classes/class.ilCOPageHTMLExport.php");
476  $this->co_page_html_export = new ilCOPageHTMLExport($a_target_dir);
477  $this->co_page_html_export->createDirectories();
478 
479  // export system style sheet
480  $location_stylesheet = ilUtil::getStyleSheetLocation("filesystem");
481  $style_name = $ilias->account->prefs["style"].".css";
482  copy($location_stylesheet, $a_target_dir."/".$style_name);
483  $location_stylesheet = ilUtil::getStyleSheetLocation();
484 
485  $cont_stylesheet = "Services/COPage/css/content.css";
486  copy($cont_stylesheet, $a_target_dir."/content.css");
487 
488  // export syntax highlighting style
489  $syn_stylesheet = ilObjStyleSheet::getSyntaxStylePath();
490  copy($syn_stylesheet, $a_target_dir."/syntaxhighlight.css");
491 
492  // get glossary presentation gui class
493  include_once("./Modules/Glossary/classes/class.ilGlossaryPresentationGUI.php");
494  $_GET["cmd"] = "nop";
495  $glo_gui =& new ilGlossaryPresentationGUI();
496  $glo_gui->setOfflineMode(true);
497  $glo_gui->setOfflineDirectory($a_target_dir);
498 
499  // could be implemented in the future if other export
500  // formats are supported (e.g. scorm)
501  //$glo_gui->setExportFormat($a_export_format);
502 
503  // export terms
504  $this->exportHTMLGlossaryTerms($glo_gui, $a_target_dir);
505 
506  // export all media objects
507  foreach ($this->offline_mobs as $mob)
508  {
509  $this->exportHTMLMOB($a_target_dir, $glo_gui, $mob, "_blank");
510  }
511  $_GET["obj_type"] = "MediaObject";
512  $_GET["obj_id"] = $a_mob_id;
513  $_GET["cmd"] = "";
514 
515  // export all file objects
516  foreach ($this->offline_files as $file)
517  {
518  $this->exportHTMLFile($a_target_dir, $file);
519  }
520 
521  // export images
522  $image_dir = $a_target_dir."/images";
523  ilUtil::makeDir($image_dir);
524  ilUtil::makeDir($image_dir."/browser");
525  copy(ilUtil::getImagePath("enlarge.gif", false, "filesystem"),
526  $image_dir."/enlarge.gif");
527  copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
528  $image_dir."/browser/plus.gif");
529  copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
530  $image_dir."/browser/minus.gif");
531  copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
532  $image_dir."/browser/blank.gif");
533  copy(ilUtil::getImagePath("icon_st.gif", false, "filesystem"),
534  $image_dir."/icon_st.gif");
535  copy(ilUtil::getImagePath("icon_pg.gif", false, "filesystem"),
536  $image_dir."/icon_pg.gif");
537  copy(ilUtil::getImagePath("nav_arr_L.gif", false, "filesystem"),
538  $image_dir."/nav_arr_L.gif");
539  copy(ilUtil::getImagePath("nav_arr_R.gif", false, "filesystem"),
540  $image_dir."/nav_arr_R.gif");
541 
542  // template workaround: reset of template
543  $tpl = new ilTemplate("tpl.main.html", true, true);
544  $tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
545  $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
546 
547  // zip everything
548  if (true)
549  {
550  // zip it all
551  $date = time();
552  $zip_file = $this->getExportDirectory("html")."/".$date."__".IL_INST_ID."__".
553  $this->getType()."_".$this->getId().".zip";
554 //echo "zip-".$a_target_dir."-to-".$zip_file;
555  ilUtil::zip($a_target_dir, $zip_file);
556  ilUtil::delDir($a_target_dir);
557  }
558  }
559 
560 
564  function exportHTMLGlossaryTerms(&$a_glo_gui, $a_target_dir)
565  {
566  global $ilUser;
567 
568  // index.html file
569  $a_glo_gui->tpl = new ilTemplate("tpl.main.html", true, true);
570  $style_name = $ilUser->prefs["style"].".css";;
571  $a_glo_gui->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
572  $a_glo_gui->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
573  $a_glo_gui->tpl->setTitle($this->getTitle());
574 
575  $content = $a_glo_gui->listTerms();
576  $file = $a_target_dir."/index.html";
577 
578  // open file
579  if (!($fp = @fopen($file,"w+")))
580  {
581  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
582  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
583  }
584  chmod($file, 0770);
585  fwrite($fp, $content);
586  fclose($fp);
587 
588  $terms = $this->getTermList();
589 
590  $this->offline_mobs = array();
591  $this->offline_files = array();
592 
593  foreach($terms as $term)
594  {
595  $a_glo_gui->tpl = new ilTemplate("tpl.main.html", true, true);
596  //$tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
597 
598  // set style
599  $style_name = $ilUser->prefs["style"].".css";;
600  $a_glo_gui->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
601 
602  $_GET["term_id"] = $term["id"];
603  $_GET["frame"] = "_blank";
604  $content =& $a_glo_gui->listDefinitions();
605  $file = $a_target_dir."/term_".$term["id"].".html";
606 
607  // open file
608  if (!($fp = @fopen($file,"w+")))
609  {
610  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
611  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
612  }
613  chmod($file, 0770);
614  fwrite($fp, $content);
615  fclose($fp);
616 
617  // store linked/embedded media objects of glosssary term
618  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
619  $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
620  foreach($defs as $def)
621  {
622  $def_mobs = ilObjMediaObject::_getMobsOfObject("gdf:pg", $def["id"]);
623  foreach($def_mobs as $def_mob)
624  {
625  $this->offline_mobs[$def_mob] = $def_mob;
626  }
627 
628  // get all files of page
629  include_once("./Modules/File/classes/class.ilObjFile.php");
630  $def_files = ilObjFile::_getFilesOfObject("gdf:pg", $def["id"]);
631  $this->offline_files = array_merge($this->offline_files, $def_files);
632 
633  }
634  }
635  }
636 
640  function exportHTMLMOB($a_target_dir, &$a_glo_gui, $a_mob_id)
641  {
642  global $tpl;
643 
644  $mob_dir = $a_target_dir."/mobs";
645 
646  $source_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob_id;
647  if (@is_dir($source_dir))
648  {
649  ilUtil::makeDir($mob_dir."/mm_".$a_mob_id);
650  ilUtil::rCopy($source_dir, $mob_dir."/mm_".$a_mob_id);
651  }
652 
653  $tpl = new ilTemplate("tpl.main.html", true, true);
654  $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
655  $_GET["obj_type"] = "MediaObject";
656  $_GET["mob_id"] = $a_mob_id;
657  $_GET["cmd"] = "";
658  $content =& $a_glo_gui->media();
659  $file = $a_target_dir."/media_".$a_mob_id.".html";
660 
661  // open file
662  if (!($fp = @fopen($file,"w+")))
663  {
664  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
665  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
666  }
667  chmod($file, 0770);
668  fwrite($fp, $content);
669  fclose($fp);
670 
671  // fullscreen
672  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
673  $mob_obj = new ilObjMediaObject($a_mob_id);
674  if ($mob_obj->hasFullscreenItem())
675  {
676  $tpl = new ilTemplate("tpl.main.html", true, true);
677  $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
678  $_GET["mob_id"] = $a_mob_id;
679  $_GET["cmd"] = "fullscreen";
680  $content = $a_glo_gui->fullscreen();
681  $file = $a_target_dir."/fullscreen_".$a_mob_id.".html";
682 
683  // open file
684  if (!($fp = @fopen($file,"w+")))
685  {
686  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
687  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
688  }
689  chmod($file, 0770);
690  fwrite($fp, $content);
691  fclose($fp);
692  }
693  }
694 
698  function exportHTMLFile($a_target_dir, $a_file_id)
699  {
700  $file_dir = $a_target_dir."/files/file_".$a_file_id;
701  ilUtil::makeDir($file_dir);
702  include_once("./Modules/File/classes/class.ilObjFile.php");
703  $file_obj = new ilObjFile($a_file_id, false);
704  $source_file = $file_obj->getDirectory($file_obj->getVersion())."/".$file_obj->getFileName();
705  if (!is_file($source_file))
706  {
707  $source_file = $file_obj->getDirectory()."/".$file_obj->getFileName();
708  }
709  copy($source_file, $file_dir."/".$file_obj->getFileName());
710  }
711 
712 
719  function exportXML(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
720  {
721  global $ilBench;
722 
723  // export glossary
724  $attrs = array();
725  $attrs["Type"] = "Glossary";
726  $a_xml_writer->xmlStartTag("ContentObject", $attrs);
727 
728  // MetaData
729  $this->exportXMLMetaData($a_xml_writer);
730 
731  // collect media objects
732  $terms = $this->getTermList();
733  $this->mob_ids = array();
734  $this->file_ids = array();
735  foreach ($terms as $term)
736  {
737  include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
738 
739  $defs = ilGlossaryDefinition::getDefinitionList($term[id]);
740 
741  foreach($defs as $def)
742  {
743  $this->page_object =& new ilPageObject("gdf",
744  $def["id"], $this->halt_on_error);
745  $this->page_object->buildDom();
746  $this->page_object->insertInstIntoIDs(IL_INST_ID);
747  $mob_ids = $this->page_object->collectMediaObjects(false);
748  $file_ids = $this->page_object->collectFileItems();
749  foreach($mob_ids as $mob_id)
750  {
751  $this->mob_ids[$mob_id] = $mob_id;
752  }
753  foreach($file_ids as $file_id)
754  {
755  $this->file_ids[$file_id] = $file_id;
756  }
757  }
758  }
759 
760  // export media objects
761  $expLog->write(date("[y-m-d H:i:s] ")."Start Export Media Objects");
762  $ilBench->start("GlossaryExport", "exportMediaObjects");
763  $this->exportXMLMediaObjects($a_xml_writer, $a_inst, $a_target_dir, $expLog);
764  $ilBench->stop("GlossaryExport", "exportMediaObjects");
765  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Media Objects");
766 
767  // FileItems
768  $expLog->write(date("[y-m-d H:i:s] ")."Start Export File Items");
769  $ilBench->start("ContentObjectExport", "exportFileItems");
770  $this->exportFileItems($a_target_dir, $expLog);
771  $ilBench->stop("ContentObjectExport", "exportFileItems");
772  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export File Items");
773 
774  // Glossary
775  $expLog->write(date("[y-m-d H:i:s] ")."Start Export Glossary Items");
776  $ilBench->start("GlossaryExport", "exportGlossaryItems");
777  $this->exportXMLGlossaryItems($a_xml_writer, $a_inst, $expLog);
778  $ilBench->stop("GlossaryExport", "exportGlossaryItems");
779  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Glossary Items");
780 
781  $a_xml_writer->xmlEndTag("ContentObject");
782  }
783 
790  function exportXMLGlossaryItems(&$a_xml_writer, $a_inst, &$expLog)
791  {
792  global $ilBench;
793 
794  $attrs = array();
795  $a_xml_writer->xmlStartTag("Glossary", $attrs);
796 
797  // MetaData
798  $this->exportXMLMetaData($a_xml_writer);
799 
800  $terms = $this->getTermList();
801 
802  // export glossary terms
803  reset($terms);
804  foreach ($terms as $term)
805  {
806  $ilBench->start("GlossaryExport", "exportGlossaryItem");
807  $expLog->write(date("[y-m-d H:i:s] ")."Page Object ".$page["obj_id"]);
808 
809  // export xml to writer object
810  $ilBench->start("GlossaryExport", "exportGlossaryItem_getGlossaryTerm");
811  $glo_term = new ilGlossaryTerm($term["id"]);
812  $ilBench->stop("GlossaryExport", "exportGlossaryItem_getGlossaryTerm");
813  $ilBench->start("GlossaryExport", "exportGlossaryItem_XML");
814  $glo_term->exportXML($a_xml_writer, $a_inst);
815  $ilBench->stop("GlossaryExport", "exportGlossaryItem_XML");
816 
817  // collect all file items
818  /*
819  $ilBench->start("GlossaryExport", "exportGlossaryItem_CollectFileItems");
820  $file_ids = $page_obj->getFileItemIds();
821  foreach($file_ids as $file_id)
822  {
823  $this->file_ids[$file_id] = $file_id;
824  }
825  $ilBench->stop("GlossaryExport", "exportGlossaryItem_CollectFileItems");
826  */
827 
828  unset($glo_term);
829 
830  $ilBench->stop("GlossaryExport", "exportGlossaryItem");
831  }
832 
833  $a_xml_writer->xmlEndTag("Glossary");
834  }
835 
842  function exportXMLMetaData(&$a_xml_writer)
843  {
844  include_once("Services/MetaData/classes/class.ilMD2XML.php");
845  $md2xml = new ilMD2XML($this->getId(), 0, $this->getType());
846  $md2xml->setExportMode(true);
847  $md2xml->startExport();
848  $a_xml_writer->appendXML($md2xml->getXML());
849  }
850 
857  function exportXMLMediaObjects(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
858  {
859  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
860 
861  foreach ($this->mob_ids as $mob_id)
862  {
863  $expLog->write(date("[y-m-d H:i:s] ")."Media Object ".$mob_id);
864  $media_obj = new ilObjMediaObject($mob_id);
865  $media_obj->exportXML($a_xml_writer, $a_inst);
866  $media_obj->exportFiles($a_target_dir);
867  unset($media_obj);
868  }
869  }
870 
875  function exportFileItems($a_target_dir, &$expLog)
876  {
877  include_once("./Modules/File/classes/class.ilObjFile.php");
878 
879  foreach ($this->file_ids as $file_id)
880  {
881  $expLog->write(date("[y-m-d H:i:s] ")."File Item ".$file_id);
882  $file_obj = new ilObjFile($file_id, false);
883  $file_obj->export($a_target_dir);
884  unset($file_obj);
885  }
886  }
887 
888 
889 
893  function modifyExportIdentifier($a_tag, $a_param, $a_value)
894  {
895  if ($a_tag == "Identifier" && $a_param == "Entry")
896  {
897  $a_value = "il_".IL_INST_ID."_glo_".$this->getId();
898  }
899 
900  return $a_value;
901  }
902 
903 
904 
905 
916  function delete()
917  {
918  global $ilDB;
919 
920  // always call parent delete function first!!
921  if (!parent::delete())
922  {
923  return false;
924  }
925 
926  // delete terms
927  if (!$this->isVirtual())
928  {
929  $terms = $this->getTermList();
930  foreach ($terms as $term)
931  {
932  $term_obj =& new ilGlossaryTerm($term["id"]);
933  $term_obj->delete();
934  }
935  }
936 
937  // delete glossary data entry
938  $q = "DELETE FROM glossary WHERE id = ".$ilDB->quote($this->getId());
939  $ilDB->query($q);
940 
941  // delete meta data
942  $this->deleteMetaData();
943 /*
944  $nested = new ilNestedSetXML();
945  $nested->init($this->getId(), $this->getType());
946  $nested->deleteAllDBData();
947 */
948 
949  return true;
950  }
951 
962  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
963  {
964  global $tree;
965 
966  switch ($a_event)
967  {
968  case "link":
969 
970  //var_dump("<pre>",$a_params,"</pre>");
971  //echo "Glossary ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
972  //exit;
973  break;
974 
975  case "cut":
976 
977  //echo "Glossary ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
978  //exit;
979  break;
980 
981  case "copy":
982 
983  //var_dump("<pre>",$a_params,"</pre>");
984  //echo "Glossary ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
985  //exit;
986  break;
987 
988  case "paste":
989 
990  //echo "Glossary ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
991  //exit;
992  break;
993 
994  case "new":
995 
996  //echo "Glossary ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
997  //exit;
998  break;
999  }
1000 
1001  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
1002  if ($a_node_id==$_GET["ref_id"])
1003  {
1004  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
1005  $parent_type = $parent_obj->getType();
1006  if($parent_type == $this->getType())
1007  {
1008  $a_node_id = (int) $tree->getParentId($a_node_id);
1009  }
1010  }
1011 
1012  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
1013  }
1014 
1015 
1019  function getXMLZip()
1020  {
1021  include_once("./Modules/Glossary/classes/class.ilGlossaryExport.php");
1022  $glo_exp = new ilGlossaryExport($this);
1023  return $glo_exp->buildExportFile();
1024  }
1025 
1030  static function getDeletionDependencies($a_obj_id)
1031  {
1032  global $lng;
1033 
1034  $dep = array();
1035  include_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
1037  foreach ($sms as $sm)
1038  {
1039  $lng->loadLanguageModule("content");
1040  $dep[$sm] = $lng->txt("glo_used_in_scorm");
1041  }
1042 //echo "-".$a_obj_id."-";
1043 //var_dump($dep);
1044  return $dep;
1045  }
1046 
1047 } // END class.ilObjGlossary
1048 
1049 ?>