ILIAS  eassessment Revision 61809
 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  $mob_dir = $a_target_dir."/mobs";
475  ilUtil::makeDir($mob_dir);
476  $file_dir = $a_target_dir."/files";
477  ilUtil::makeDir($file_dir);
478  $tex_dir = $a_target_dir."/teximg";
479  ilUtil::makeDir($tex_dir);
480 
481  // export system style sheet
482  $location_stylesheet = ilUtil::getStyleSheetLocation("filesystem");
483  $style_name = $ilias->account->prefs["style"].".css";
484  copy($location_stylesheet, $a_target_dir."/".$style_name);
485  $location_stylesheet = ilUtil::getStyleSheetLocation();
486 
487  $cont_stylesheet = "Services/COPage/css/content.css";
488  copy($cont_stylesheet, $a_target_dir."/content.css");
489 
490  // export syntax highlighting style
491  $syn_stylesheet = ilObjStyleSheet::getSyntaxStylePath();
492  copy($syn_stylesheet, $a_target_dir."/syntaxhighlight.css");
493 
494  // get glossary presentation gui class
495  include_once("./Modules/Glossary/classes/class.ilGlossaryPresentationGUI.php");
496  $_GET["cmd"] = "nop";
497  $glo_gui =& new ilGlossaryPresentationGUI();
498  $glo_gui->setOfflineMode(true);
499  $glo_gui->setOfflineDirectory($a_target_dir);
500 
501  // could be implemented in the future if other export
502  // formats are supported (e.g. scorm)
503  //$glo_gui->setExportFormat($a_export_format);
504 
505  // export terms
506  $this->exportHTMLGlossaryTerms($glo_gui, $a_target_dir);
507 
508  // export all media objects
509  foreach ($this->offline_mobs as $mob)
510  {
511  $this->exportHTMLMOB($a_target_dir, $glo_gui, $mob, "_blank");
512  }
513  $_GET["obj_type"] = "MediaObject";
514  $_GET["obj_id"] = $a_mob_id;
515  $_GET["cmd"] = "";
516 
517  // export all file objects
518  foreach ($this->offline_files as $file)
519  {
520  $this->exportHTMLFile($a_target_dir, $file);
521  }
522 
523  // export images
524  $image_dir = $a_target_dir."/images";
525  ilUtil::makeDir($image_dir);
526  ilUtil::makeDir($image_dir."/browser");
527  copy(ilUtil::getImagePath("enlarge.gif", false, "filesystem"),
528  $image_dir."/enlarge.gif");
529  copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
530  $image_dir."/browser/plus.gif");
531  copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
532  $image_dir."/browser/minus.gif");
533  copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
534  $image_dir."/browser/blank.gif");
535  copy(ilUtil::getImagePath("icon_st.gif", false, "filesystem"),
536  $image_dir."/icon_st.gif");
537  copy(ilUtil::getImagePath("icon_pg.gif", false, "filesystem"),
538  $image_dir."/icon_pg.gif");
539  copy(ilUtil::getImagePath("nav_arr_L.gif", false, "filesystem"),
540  $image_dir."/nav_arr_L.gif");
541  copy(ilUtil::getImagePath("nav_arr_R.gif", false, "filesystem"),
542  $image_dir."/nav_arr_R.gif");
543 
544  // template workaround: reset of template
545  $tpl = new ilTemplate("tpl.main.html", true, true);
546  $tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
547  $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
548 
549  // zip everything
550  if (true)
551  {
552  // zip it all
553  $date = time();
554  $zip_file = $this->getExportDirectory("html")."/".$date."__".IL_INST_ID."__".
555  $this->getType()."_".$this->getId().".zip";
556 //echo "zip-".$a_target_dir."-to-".$zip_file;
557  ilUtil::zip($a_target_dir, $zip_file);
558  ilUtil::delDir($a_target_dir);
559  }
560  }
561 
562 
566  function exportHTMLGlossaryTerms(&$a_glo_gui, $a_target_dir)
567  {
568  global $ilUser;
569 
570  // index.html file
571  $a_glo_gui->tpl = new ilTemplate("tpl.main.html", true, true);
572  $style_name = $ilUser->prefs["style"].".css";;
573  $a_glo_gui->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
574  $a_glo_gui->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
575  $a_glo_gui->tpl->setVariable("HEADER", $this->getTitle());
576 
577  $content = $a_glo_gui->listTerms();
578  $file = $a_target_dir."/index.html";
579 
580  // open file
581  if (!($fp = @fopen($file,"w+")))
582  {
583  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
584  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
585  }
586  chmod($file, 0770);
587  fwrite($fp, $content);
588  fclose($fp);
589 
590  $terms = $this->getTermList();
591 
592  $this->offline_mobs = array();
593  $this->offline_files = array();
594 
595  foreach($terms as $term)
596  {
597  $a_glo_gui->tpl = new ilTemplate("tpl.main.html", true, true);
598  //$tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
599 
600  // set style
601  $style_name = $ilUser->prefs["style"].".css";;
602  $a_glo_gui->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
603 
604  $_GET["term_id"] = $term["id"];
605  $_GET["frame"] = "_blank";
606  $content =& $a_glo_gui->listDefinitions();
607  $file = $a_target_dir."/term_".$term["id"].".html";
608 
609  // open file
610  if (!($fp = @fopen($file,"w+")))
611  {
612  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
613  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
614  }
615  chmod($file, 0770);
616  fwrite($fp, $content);
617  fclose($fp);
618 
619  // store linked/embedded media objects of glosssary term
620  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
621  $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
622  foreach($defs as $def)
623  {
624  $def_mobs = ilObjMediaObject::_getMobsOfObject("gdf:pg", $def["id"]);
625  foreach($def_mobs as $def_mob)
626  {
627  $this->offline_mobs[$def_mob] = $def_mob;
628  }
629 
630  // get all files of page
631  include_once("./Modules/File/classes/class.ilObjFile.php");
632  $def_files = ilObjFile::_getFilesOfObject("gdf:pg", $def["id"]);
633  $this->offline_files = array_merge($this->offline_files, $def_files);
634 
635  }
636  }
637  }
638 
642  function exportHTMLMOB($a_target_dir, &$a_glo_gui, $a_mob_id)
643  {
644  global $tpl;
645 
646  $mob_dir = $a_target_dir."/mobs";
647 
648  $source_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob_id;
649  if (@is_dir($source_dir))
650  {
651  ilUtil::makeDir($mob_dir."/mm_".$a_mob_id);
652  ilUtil::rCopy($source_dir, $mob_dir."/mm_".$a_mob_id);
653  }
654 
655  $tpl = new ilTemplate("tpl.main.html", true, true);
656  $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
657  $_GET["obj_type"] = "MediaObject";
658  $_GET["mob_id"] = $a_mob_id;
659  $_GET["cmd"] = "";
660  $content =& $a_glo_gui->media();
661  $file = $a_target_dir."/media_".$a_mob_id.".html";
662 
663  // open file
664  if (!($fp = @fopen($file,"w+")))
665  {
666  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
667  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
668  }
669  chmod($file, 0770);
670  fwrite($fp, $content);
671  fclose($fp);
672 
673  // fullscreen
674  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
675  $mob_obj = new ilObjMediaObject($a_mob_id);
676  if ($mob_obj->hasFullscreenItem())
677  {
678  $tpl = new ilTemplate("tpl.main.html", true, true);
679  $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
680  $_GET["mob_id"] = $a_mob_id;
681  $_GET["cmd"] = "fullscreen";
682  $content = $a_glo_gui->fullscreen();
683  $file = $a_target_dir."/fullscreen_".$a_mob_id.".html";
684 
685  // open file
686  if (!($fp = @fopen($file,"w+")))
687  {
688  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
689  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
690  }
691  chmod($file, 0770);
692  fwrite($fp, $content);
693  fclose($fp);
694  }
695  }
696 
700  function exportHTMLFile($a_target_dir, $a_file_id)
701  {
702  $file_dir = $a_target_dir."/files/file_".$a_file_id;
703  ilUtil::makeDir($file_dir);
704  include_once("./Modules/File/classes/class.ilObjFile.php");
705  $file_obj = new ilObjFile($a_file_id, false);
706  $source_file = $file_obj->getDirectory($file_obj->getVersion())."/".$file_obj->getFileName();
707  if (!is_file($source_file))
708  {
709  $source_file = $file_obj->getDirectory()."/".$file_obj->getFileName();
710  }
711  copy($source_file, $file_dir."/".$file_obj->getFileName());
712  }
713 
714 
721  function exportXML(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
722  {
723  global $ilBench;
724 
725  // export glossary
726  $attrs = array();
727  $attrs["Type"] = "Glossary";
728  $a_xml_writer->xmlStartTag("ContentObject", $attrs);
729 
730  // MetaData
731  $this->exportXMLMetaData($a_xml_writer);
732 
733  // collect media objects
734  $terms = $this->getTermList();
735  $this->mob_ids = array();
736  $this->file_ids = array();
737  foreach ($terms as $term)
738  {
739  include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
740 
741  $defs = ilGlossaryDefinition::getDefinitionList($term[id]);
742 
743  foreach($defs as $def)
744  {
745  $this->page_object =& new ilPageObject("gdf",
746  $def["id"], $this->halt_on_error);
747  $this->page_object->buildDom();
748  $this->page_object->insertInstIntoIDs(IL_INST_ID);
749  $mob_ids = $this->page_object->collectMediaObjects(false);
750  $file_ids = $this->page_object->collectFileItems();
751  foreach($mob_ids as $mob_id)
752  {
753  $this->mob_ids[$mob_id] = $mob_id;
754  }
755  foreach($file_ids as $file_id)
756  {
757  $this->file_ids[$file_id] = $file_id;
758  }
759  }
760  }
761 
762  // export media objects
763  $expLog->write(date("[y-m-d H:i:s] ")."Start Export Media Objects");
764  $ilBench->start("GlossaryExport", "exportMediaObjects");
765  $this->exportXMLMediaObjects($a_xml_writer, $a_inst, $a_target_dir, $expLog);
766  $ilBench->stop("GlossaryExport", "exportMediaObjects");
767  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Media Objects");
768 
769  // FileItems
770  $expLog->write(date("[y-m-d H:i:s] ")."Start Export File Items");
771  $ilBench->start("ContentObjectExport", "exportFileItems");
772  $this->exportFileItems($a_target_dir, $expLog);
773  $ilBench->stop("ContentObjectExport", "exportFileItems");
774  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export File Items");
775 
776  // Glossary
777  $expLog->write(date("[y-m-d H:i:s] ")."Start Export Glossary Items");
778  $ilBench->start("GlossaryExport", "exportGlossaryItems");
779  $this->exportXMLGlossaryItems($a_xml_writer, $a_inst, $expLog);
780  $ilBench->stop("GlossaryExport", "exportGlossaryItems");
781  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Glossary Items");
782 
783  $a_xml_writer->xmlEndTag("ContentObject");
784  }
785 
792  function exportXMLGlossaryItems(&$a_xml_writer, $a_inst, &$expLog)
793  {
794  global $ilBench;
795 
796  $attrs = array();
797  $a_xml_writer->xmlStartTag("Glossary", $attrs);
798 
799  // MetaData
800  $this->exportXMLMetaData($a_xml_writer);
801 
802  $terms = $this->getTermList();
803 
804  // export glossary terms
805  reset($terms);
806  foreach ($terms as $term)
807  {
808  $ilBench->start("GlossaryExport", "exportGlossaryItem");
809  $expLog->write(date("[y-m-d H:i:s] ")."Page Object ".$page["obj_id"]);
810 
811  // export xml to writer object
812  $ilBench->start("GlossaryExport", "exportGlossaryItem_getGlossaryTerm");
813  $glo_term = new ilGlossaryTerm($term["id"]);
814  $ilBench->stop("GlossaryExport", "exportGlossaryItem_getGlossaryTerm");
815  $ilBench->start("GlossaryExport", "exportGlossaryItem_XML");
816  $glo_term->exportXML($a_xml_writer, $a_inst);
817  $ilBench->stop("GlossaryExport", "exportGlossaryItem_XML");
818 
819  // collect all file items
820  /*
821  $ilBench->start("GlossaryExport", "exportGlossaryItem_CollectFileItems");
822  $file_ids = $page_obj->getFileItemIds();
823  foreach($file_ids as $file_id)
824  {
825  $this->file_ids[$file_id] = $file_id;
826  }
827  $ilBench->stop("GlossaryExport", "exportGlossaryItem_CollectFileItems");
828  */
829 
830  unset($glo_term);
831 
832  $ilBench->stop("GlossaryExport", "exportGlossaryItem");
833  }
834 
835  $a_xml_writer->xmlEndTag("Glossary");
836  }
837 
844  function exportXMLMetaData(&$a_xml_writer)
845  {
846  include_once("Services/MetaData/classes/class.ilMD2XML.php");
847  $md2xml = new ilMD2XML($this->getId(), 0, $this->getType());
848  $md2xml->setExportMode(true);
849  $md2xml->startExport();
850  $a_xml_writer->appendXML($md2xml->getXML());
851  }
852 
859  function exportXMLMediaObjects(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
860  {
861  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
862 
863  foreach ($this->mob_ids as $mob_id)
864  {
865  $expLog->write(date("[y-m-d H:i:s] ")."Media Object ".$mob_id);
866  $media_obj = new ilObjMediaObject($mob_id);
867  $media_obj->exportXML($a_xml_writer, $a_inst);
868  $media_obj->exportFiles($a_target_dir);
869  unset($media_obj);
870  }
871  }
872 
877  function exportFileItems($a_target_dir, &$expLog)
878  {
879  include_once("./Modules/File/classes/class.ilObjFile.php");
880 
881  foreach ($this->file_ids as $file_id)
882  {
883  $expLog->write(date("[y-m-d H:i:s] ")."File Item ".$file_id);
884  $file_obj = new ilObjFile($file_id, false);
885  $file_obj->export($a_target_dir);
886  unset($file_obj);
887  }
888  }
889 
890 
891 
895  function modifyExportIdentifier($a_tag, $a_param, $a_value)
896  {
897  if ($a_tag == "Identifier" && $a_param == "Entry")
898  {
899  $a_value = "il_".IL_INST_ID."_glo_".$this->getId();
900  }
901 
902  return $a_value;
903  }
904 
905 
906 
907 
918  function delete()
919  {
920  global $ilDB;
921 
922  // always call parent delete function first!!
923  if (!parent::delete())
924  {
925  return false;
926  }
927 
928  // delete terms
929  if (!$this->isVirtual())
930  {
931  $terms = $this->getTermList();
932  foreach ($terms as $term)
933  {
934  $term_obj =& new ilGlossaryTerm($term["id"]);
935  $term_obj->delete();
936  }
937  }
938 
939  // delete glossary data entry
940  $q = "DELETE FROM glossary WHERE id = ".$ilDB->quote($this->getId());
941  $ilDB->query($q);
942 
943  // delete meta data
944  $this->deleteMetaData();
945 /*
946  $nested = new ilNestedSetXML();
947  $nested->init($this->getId(), $this->getType());
948  $nested->deleteAllDBData();
949 */
950 
951  return true;
952  }
953 
964  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
965  {
966  global $tree;
967 
968  switch ($a_event)
969  {
970  case "link":
971 
972  //var_dump("<pre>",$a_params,"</pre>");
973  //echo "Glossary ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
974  //exit;
975  break;
976 
977  case "cut":
978 
979  //echo "Glossary ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
980  //exit;
981  break;
982 
983  case "copy":
984 
985  //var_dump("<pre>",$a_params,"</pre>");
986  //echo "Glossary ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
987  //exit;
988  break;
989 
990  case "paste":
991 
992  //echo "Glossary ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
993  //exit;
994  break;
995 
996  case "new":
997 
998  //echo "Glossary ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
999  //exit;
1000  break;
1001  }
1002 
1003  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
1004  if ($a_node_id==$_GET["ref_id"])
1005  {
1006  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
1007  $parent_type = $parent_obj->getType();
1008  if($parent_type == $this->getType())
1009  {
1010  $a_node_id = (int) $tree->getParentId($a_node_id);
1011  }
1012  }
1013 
1014  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
1015  }
1016 
1017 
1021  function getXMLZip()
1022  {
1023  include_once("./Modules/Glossary/classes/class.ilGlossaryExport.php");
1024  $glo_exp = new ilGlossaryExport($this);
1025  return $glo_exp->buildExportFile();
1026  }
1027 
1032  static function getDeletionDependencies($a_obj_id)
1033  {
1034  global $lng;
1035 
1036  $dep = array();
1037  include_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
1039  foreach ($sms as $sm)
1040  {
1041  $lng->loadLanguageModule("content");
1042  $dep[$sm] = $lng->txt("glo_used_in_scorm");
1043  }
1044 //echo "-".$a_obj_id."-";
1045 //var_dump($dep);
1046  return $dep;
1047  }
1048 
1049 } // END class.ilObjGlossary
1050 
1051 ?>