ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjGlossary.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("classes/class.ilObject.php");
25 require_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
26 
38 class ilObjGlossary extends ilObject
39 {
40 
45  function ilObjGlossary($a_id = 0,$a_call_by_reference = true)
46  {
47  $this->type = "glo";
48  $this->ilObject($a_id,$a_call_by_reference);
49  }
50 
54  function create($a_upload = false)
55  {
56  global $ilDB;
57 
59 
60  // meta data will be created by
61  // import parser
62  if (!$a_upload)
63  {
64  $this->createMetaData();
65  }
66 
67  $q = "INSERT INTO glossary (id, online, virtual) VALUES ".
68  " (".$ilDB->quote($this->getId()).",".$ilDB->quote("n").",".$ilDB->quote($this->getVirtualMode()).")";
69  $ilDB->query($q);
70 
71  }
72 
76  function read()
77  {
78  global $ilDB;
79 
80  parent::read();
81 # echo "Glossary<br>\n";
82 
83  $q = "SELECT * FROM glossary WHERE id = ".$ilDB->quote($this->getId());
84  $gl_set = $this->ilias->db->query($q);
85  $gl_rec = $gl_set->fetchRow(DB_FETCHMODE_ASSOC);
86  $this->setOnline(ilUtil::yn2tf($gl_rec["online"]));
87  $this->setVirtualMode($gl_rec["virtual"]);
88  $this->setPublicExportFile("xml", $gl_rec["public_xml_file"]);
89  $this->setPublicExportFile("html", $gl_rec["public_html_file"]);
90  $this->setActiveGlossaryMenu(ilUtil::yn2tf($gl_rec["glo_menu_active"]));
91  $this->setActiveDownloads(ilUtil::yn2tf($gl_rec["downloads_active"]));
92  }
93 
99  function getDescription()
100  {
101  return parent::getDescription();
102  }
103 
107  function setDescription($a_description)
108  {
109  parent::setDescription($a_description);
110  }
111 
112 
116  function setVirtualMode($a_mode)
117  {
118  switch ($a_mode)
119  {
120  case "level":
121  case "subtree":
122  // case "fixed":
123  $this->virtual_mode = $a_mode;
124  $this->virtual = true;
125  break;
126 
127  default:
128  $this->virtual_mode = "none";
129  $this->virtual = false;
130  break;
131  }
132  }
133 
137  function getVirtualMode()
138  {
139  return $this->virtual_mode;
140  }
141 
145  function isVirtual()
146  {
147  return $this->virtual;
148  }
149 
155  function getTitle()
156  {
157  return parent::getTitle();
158  }
159 
163  function setTitle($a_title)
164  {
165  parent::setTitle($a_title);
166 // $this->meta_data->setTitle($a_title);
167  }
168 
169  function setOnline($a_online)
170  {
171  $this->online = $a_online;
172  }
173 
174  function getOnline()
175  {
176  return $this->online;
177  }
178 
182  function _lookupOnline($a_id)
183  {
184  global $ilDB;
185 
186  $q = "SELECT * FROM glossary WHERE id = ".$ilDB->quote($a_id);
187  $lm_set = $ilDB->query($q);
188  $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
189 
190  return ilUtil::yn2tf($lm_rec["online"]);
191  }
192 
193  function setActiveGlossaryMenu($a_act_glo_menu)
194  {
195  $this->glo_menu_active = $a_act_glo_menu;
196  }
197 
199  {
200  return $this->glo_menu_active;
201  }
202 
203  function setActiveDownloads($a_down)
204  {
205  $this->downloads_active = $a_down;
206  }
207 
208  function isActiveDownloads()
209  {
210  return $this->downloads_active;
211  }
212 
218 /*
219  function assignMetaData(&$a_meta_data)
220  {
221  $this->meta_data =& $a_meta_data;
222  }
223 */
224 
230 /*
231  function &getMetaData()
232  {
233  $this->initMeta();
234  return $this->meta_data;
235  }
236 */
237 
241  function update()
242  {
243  global $ilDB;
244 
245  $this->updateMetaData();
246 
247  $q = "UPDATE glossary SET ".
248  " online = ".$ilDB->quote(ilUtil::tf2yn($this->getOnline())).",".
249  " virtual = ".$ilDB->quote($this->getVirtualMode()).",".
250  " public_xml_file = ".$ilDB->quote($this->getPublicExportFile("xml")).",".
251  " public_html_file = ".$ilDB->quote($this->getPublicExportFile("html")).",".
252  " glo_menu_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveGlossaryMenu())).",".
253  " downloads_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveDownloads()))." ".
254  " WHERE id = ".$ilDB->quote($this->getId());
255 
256  $ilDB->query($q);
257 
258  parent::update();
259  }
260 
261 
265  function getTermList($searchterm="")
266  {
267  if ($this->isVirtual())
268  {
269  global $tree;
270 
271  $glo_ids = array();
272 
273  switch ($this->getVirtualMode())
274  {
275  case "level":
276  $glo_arr = $tree->getChildsByType($tree->getParentId($this->getRefId()),"glo");
277 
278  foreach ($glo_arr as $glo)
279  {
280  {
281  $glo_ids[] = $glo['obj_id'];
282  }
283  }
284  break;
285 
286  case "subtree":
287  $subtree_nodes = $tree->getSubTree($tree->getNodeData($tree->getParentId($this->getRefId())));
288 
289  foreach ($subtree_nodes as $node)
290  {
291  if ($node['type'] == 'glo')
292  {
293  $glo_ids[] = $node['obj_id'];
294  }
295  }
296  break;
297 
298 /* for futere enhancements
299  case "fixed":
300 
301  break;
302 */
303  // fallback to none virtual mode in case of error
304  default:
305  $glo_ids[] = $this->getId();
306  break;
307  }
308  }
309  else
310  {
311  $glo_ids = $this->getId();
312  }
313 
314  $list = ilGlossaryTerm::getTermList($glo_ids,$searchterm);
315  return $list;
316  }
317 
324  {
325  $glo_data_dir = ilUtil::getDataDir()."/glo_data";
326  ilUtil::makeDir($glo_data_dir);
327  if(!is_writable($glo_data_dir))
328  {
329  $this->ilias->raiseError("Glossary Data Directory (".$glo_data_dir
330  .") not writeable.",$this->ilias->error_obj->FATAL);
331  }
332 
333  // create glossary directory (data_dir/glo_data/glo_<id>)
334  $glo_dir = $glo_data_dir."/glo_".$this->getId();
335  ilUtil::makeDir($glo_dir);
336  if(!@is_dir($glo_dir))
337  {
338  $this->ilias->raiseError("Creation of Glossary Directory failed.",$this->ilias->error_obj->FATAL);
339  }
340  // create Import subdirectory (data_dir/glo_data/glo_<id>/import)
341  $import_dir = $glo_dir."/import";
342  ilUtil::makeDir($import_dir);
343  if(!@is_dir($import_dir))
344  {
345  $this->ilias->raiseError("Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
346  }
347  }
348 
353  {
354  $export_dir = ilUtil::getDataDir()."/glo_data"."/glo_".$this->getId()."/import";
355 
356  return $export_dir;
357  }
358 
364  function createExportDirectory($a_type = "xml")
365  {
366  $glo_data_dir = ilUtil::getDataDir()."/glo_data";
367  ilUtil::makeDir($glo_data_dir);
368  if(!is_writable($glo_data_dir))
369  {
370  $this->ilias->raiseError("Glossary Data Directory (".$glo_data_dir
371  .") not writeable.",$this->ilias->error_obj->FATAL);
372  }
373  // create glossary directory (data_dir/glo_data/glo_<id>)
374  $glo_dir = $glo_data_dir."/glo_".$this->getId();
375  ilUtil::makeDir($glo_dir);
376  if(!@is_dir($glo_dir))
377  {
378  $this->ilias->raiseError("Creation of Glossary Directory failed.",$this->ilias->error_obj->FATAL);
379  }
380 
381  // create Export subdirectory (data_dir/glo_data/glo_<id>/Export)
382  switch ($a_type)
383  {
384  // html
385  case "html":
386  $export_dir = $glo_dir."/export_html";
387  break;
388 
389  default: // = xml
390  $export_dir = $glo_dir."/export";
391  break;
392  }
393  ilUtil::makeDir($export_dir);
394 
395  if(!@is_dir($export_dir))
396  {
397  $this->ilias->raiseError("Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
398  }
399  }
400 
404  function getExportDirectory($a_type = "xml")
405  {
406  switch ($a_type)
407  {
408  case "html":
409  $export_dir = ilUtil::getDataDir()."/glo_data"."/glo_".$this->getId()."/export_html";
410  break;
411 
412  default: // = xml
413  $export_dir = ilUtil::getDataDir()."/glo_data"."/glo_".$this->getId()."/export";
414  break;
415  }
416 
417  return $export_dir;
418  }
419 
423  function getExportFiles()
424  {
425  // initialize array
426  $file = array();
427 
428  $types = array("xml", "html");
429 
430  foreach($types as $type)
431  {
432  $dir = $this->getExportDirectory($type);
433 
434  // quit if import dir not available
435  if (!@is_dir($dir) or
436  !is_writeable($dir))
437  {
438  continue;
439  }
440 
441  // open directory
442  $h_dir = dir($dir);
443 
444  // get files and save the in the array
445  while ($entry = $h_dir->read())
446  {
447  if ($entry != "." and
448  $entry != ".." and
449  substr($entry, -4) == ".zip" and
450  ereg("^[0-9]{10}_{2}[0-9]+_{2}(glo_)*[0-9]+\.zip\$", $entry))
451  {
452  $file[$entry.$type] = array("type" => $type, "file" => $entry,
453  "size" => filesize($dir."/".$entry));
454  }
455  }
456 
457  // close import directory
458  $h_dir->close();
459  }
460 
461  // sort files
462  ksort ($file);
463  reset ($file);
464  return $file;
465  }
466 
473  function setPublicExportFile($a_type, $a_file)
474  {
475  $this->public_export_file[$a_type] = $a_file;
476  }
477 
485  function getPublicExportFile($a_type)
486  {
487  return $this->public_export_file[$a_type];
488  }
489 
493  function exportHTML($a_target_dir, $log)
494  {
495  global $ilias, $tpl;
496 
497  // initialize temporary target directory
498  ilUtil::delDir($a_target_dir);
499  ilUtil::makeDir($a_target_dir);
500  $mob_dir = $a_target_dir."/mobs";
501  ilUtil::makeDir($mob_dir);
502  $file_dir = $a_target_dir."/files";
503  ilUtil::makeDir($file_dir);
504  $tex_dir = $a_target_dir."/teximg";
505  ilUtil::makeDir($tex_dir);
506 
507  // export system style sheet
508  $location_stylesheet = ilUtil::getStyleSheetLocation("filesystem");
509  $style_name = $ilias->account->prefs["style"].".css";
510  copy($location_stylesheet, $a_target_dir."/".$style_name);
511  $location_stylesheet = ilUtil::getStyleSheetLocation();
512 
513  $cont_stylesheet = "Services/COPage/css/content.css";
514  copy($cont_stylesheet, $a_target_dir."/content.css");
515 
516  // export syntax highlighting style
517  $syn_stylesheet = ilObjStyleSheet::getSyntaxStylePath();
518  copy($syn_stylesheet, $a_target_dir."/syntaxhighlight.css");
519 
520  // get glossary presentation gui class
521  include_once("./Modules/Glossary/classes/class.ilGlossaryPresentationGUI.php");
522  $_GET["cmd"] = "nop";
523  $glo_gui =& new ilGlossaryPresentationGUI();
524  $glo_gui->setOfflineMode(true);
525  $glo_gui->setOfflineDirectory($a_target_dir);
526 
527  // could be implemented in the future if other export
528  // formats are supported (e.g. scorm)
529  //$glo_gui->setExportFormat($a_export_format);
530 
531  // export terms
532  $this->exportHTMLGlossaryTerms($glo_gui, $a_target_dir);
533 
534  // export all media objects
535  foreach ($this->offline_mobs as $mob)
536  {
537  $this->exportHTMLMOB($a_target_dir, $glo_gui, $mob, "_blank");
538  }
539  $_GET["obj_type"] = "MediaObject";
540  $_GET["obj_id"] = $a_mob_id;
541  $_GET["cmd"] = "";
542 
543  // export all file objects
544  foreach ($this->offline_files as $file)
545  {
546  $this->exportHTMLFile($a_target_dir, $file);
547  }
548 
549  // export images
550  $image_dir = $a_target_dir."/images";
551  ilUtil::makeDir($image_dir);
552  ilUtil::makeDir($image_dir."/browser");
553  copy(ilUtil::getImagePath("enlarge.gif", false, "filesystem"),
554  $image_dir."/enlarge.gif");
555  copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
556  $image_dir."/browser/plus.gif");
557  copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
558  $image_dir."/browser/minus.gif");
559  copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
560  $image_dir."/browser/blank.gif");
561  copy(ilUtil::getImagePath("icon_st.gif", false, "filesystem"),
562  $image_dir."/icon_st.gif");
563  copy(ilUtil::getImagePath("icon_pg.gif", false, "filesystem"),
564  $image_dir."/icon_pg.gif");
565  copy(ilUtil::getImagePath("nav_arr_L.gif", false, "filesystem"),
566  $image_dir."/nav_arr_L.gif");
567  copy(ilUtil::getImagePath("nav_arr_R.gif", false, "filesystem"),
568  $image_dir."/nav_arr_R.gif");
569 
570  // template workaround: reset of template
571  $tpl = new ilTemplate("tpl.main.html", true, true);
572  $tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
573  $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
574 
575  // zip everything
576  if (true)
577  {
578  // zip it all
579  $date = time();
580  $zip_file = $this->getExportDirectory("html")."/".$date."__".IL_INST_ID."__".
581  $this->getType()."_".$this->getId().".zip";
582 //echo "zip-".$a_target_dir."-to-".$zip_file;
583  ilUtil::zip($a_target_dir, $zip_file);
584  ilUtil::delDir($a_target_dir);
585  }
586  }
587 
588 
592  function exportHTMLGlossaryTerms(&$a_glo_gui, $a_target_dir)
593  {
594  global $ilUser;
595 
596  // index.html file
597  $a_glo_gui->tpl = new ilTemplate("tpl.main.html", true, true);
598  $style_name = $ilUser->prefs["style"].".css";;
599  $a_glo_gui->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
600  $a_glo_gui->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
601  $a_glo_gui->tpl->setVariable("HEADER", $this->getTitle());
602 
603  $content = $a_glo_gui->listTerms();
604  $file = $a_target_dir."/index.html";
605 
606  // open file
607  if (!($fp = @fopen($file,"w+")))
608  {
609  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
610  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
611  }
612  chmod($file, 0770);
613  fwrite($fp, $content);
614  fclose($fp);
615 
616  $terms = $this->getTermList();
617 
618  $this->offline_mobs = array();
619  $this->offline_files = array();
620 
621  foreach($terms as $term)
622  {
623  $a_glo_gui->tpl = new ilTemplate("tpl.main.html", true, true);
624  //$tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
625 
626  // set style
627  $style_name = $ilUser->prefs["style"].".css";;
628  $a_glo_gui->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
629 
630  $_GET["term_id"] = $term["id"];
631  $_GET["frame"] = "_blank";
632  $content =& $a_glo_gui->listDefinitions();
633  $file = $a_target_dir."/term_".$term["id"].".html";
634 
635  // open file
636  if (!($fp = @fopen($file,"w+")))
637  {
638  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
639  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
640  }
641  chmod($file, 0770);
642  fwrite($fp, $content);
643  fclose($fp);
644 
645  // store linked/embedded media objects of glosssary term
646  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
647  $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
648  foreach($defs as $def)
649  {
650  $def_mobs = ilObjMediaObject::_getMobsOfObject("gdf:pg", $def["id"]);
651  foreach($def_mobs as $def_mob)
652  {
653  $this->offline_mobs[$def_mob] = $def_mob;
654  }
655 
656  // get all files of page
657  include_once("./Modules/File/classes/class.ilObjFile.php");
658  $def_files = ilObjFile::_getFilesOfObject("gdf:pg", $def["id"]);
659  $this->offline_files = array_merge($this->offline_files, $def_files);
660 
661  }
662  }
663  }
664 
668  function exportHTMLMOB($a_target_dir, &$a_glo_gui, $a_mob_id)
669  {
670  global $tpl;
671 
672  $mob_dir = $a_target_dir."/mobs";
673 
674  $source_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob_id;
675  if (@is_dir($source_dir))
676  {
677  ilUtil::makeDir($mob_dir."/mm_".$a_mob_id);
678  ilUtil::rCopy($source_dir, $mob_dir."/mm_".$a_mob_id);
679  }
680 
681  $tpl = new ilTemplate("tpl.main.html", true, true);
682  $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
683  $_GET["obj_type"] = "MediaObject";
684  $_GET["mob_id"] = $a_mob_id;
685  $_GET["cmd"] = "";
686  $content =& $a_glo_gui->media();
687  $file = $a_target_dir."/media_".$a_mob_id.".html";
688 
689  // open file
690  if (!($fp = @fopen($file,"w+")))
691  {
692  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
693  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
694  }
695  chmod($file, 0770);
696  fwrite($fp, $content);
697  fclose($fp);
698 
699  // fullscreen
700  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
701  $mob_obj = new ilObjMediaObject($a_mob_id);
702  if ($mob_obj->hasFullscreenItem())
703  {
704  $tpl = new ilTemplate("tpl.main.html", true, true);
705  $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
706  $_GET["mob_id"] = $a_mob_id;
707  $_GET["cmd"] = "fullscreen";
708  $content = $a_glo_gui->fullscreen();
709  $file = $a_target_dir."/fullscreen_".$a_mob_id.".html";
710 
711  // open file
712  if (!($fp = @fopen($file,"w+")))
713  {
714  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
715  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
716  }
717  chmod($file, 0770);
718  fwrite($fp, $content);
719  fclose($fp);
720  }
721  }
722 
726  function exportHTMLFile($a_target_dir, $a_file_id)
727  {
728  $file_dir = $a_target_dir."/files/file_".$a_file_id;
729  ilUtil::makeDir($file_dir);
730  include_once("./Modules/File/classes/class.ilObjFile.php");
731  $file_obj = new ilObjFile($a_file_id, false);
732  $source_file = $file_obj->getDirectory($file_obj->getVersion())."/".$file_obj->getFileName();
733  if (!is_file($source_file))
734  {
735  $source_file = $file_obj->getDirectory()."/".$file_obj->getFileName();
736  }
737  copy($source_file, $file_dir."/".$file_obj->getFileName());
738  }
739 
740 
747  function exportXML(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
748  {
749  global $ilBench;
750 
751  // export glossary
752  $attrs = array();
753  $attrs["Type"] = "Glossary";
754  $a_xml_writer->xmlStartTag("ContentObject", $attrs);
755 
756  // MetaData
757  $this->exportXMLMetaData($a_xml_writer);
758 
759  // collect media objects
760  $terms = $this->getTermList();
761  $this->mob_ids = array();
762  $this->file_ids = array();
763  foreach ($terms as $term)
764  {
765  include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
766 
767  $defs = ilGlossaryDefinition::getDefinitionList($term[id]);
768 
769  foreach($defs as $def)
770  {
771  $this->page_object =& new ilPageObject("gdf",
772  $def["id"], $this->halt_on_error);
773  $this->page_object->buildDom();
774  $this->page_object->insertInstIntoIDs(IL_INST_ID);
775  $mob_ids = $this->page_object->collectMediaObjects(false);
776  $file_ids = $this->page_object->collectFileItems();
777  foreach($mob_ids as $mob_id)
778  {
779  $this->mob_ids[$mob_id] = $mob_id;
780  }
781  foreach($file_ids as $file_id)
782  {
783  $this->file_ids[$file_id] = $file_id;
784  }
785  }
786  }
787 
788  // export media objects
789  $expLog->write(date("[y-m-d H:i:s] ")."Start Export Media Objects");
790  $ilBench->start("GlossaryExport", "exportMediaObjects");
791  $this->exportXMLMediaObjects($a_xml_writer, $a_inst, $a_target_dir, $expLog);
792  $ilBench->stop("GlossaryExport", "exportMediaObjects");
793  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Media Objects");
794 
795  // FileItems
796  $expLog->write(date("[y-m-d H:i:s] ")."Start Export File Items");
797  $ilBench->start("ContentObjectExport", "exportFileItems");
798  $this->exportFileItems($a_target_dir, $expLog);
799  $ilBench->stop("ContentObjectExport", "exportFileItems");
800  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export File Items");
801 
802  // Glossary
803  $expLog->write(date("[y-m-d H:i:s] ")."Start Export Glossary Items");
804  $ilBench->start("GlossaryExport", "exportGlossaryItems");
805  $this->exportXMLGlossaryItems($a_xml_writer, $a_inst, $expLog);
806  $ilBench->stop("GlossaryExport", "exportGlossaryItems");
807  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Glossary Items");
808 
809  $a_xml_writer->xmlEndTag("ContentObject");
810  }
811 
818  function exportXMLGlossaryItems(&$a_xml_writer, $a_inst, &$expLog)
819  {
820  global $ilBench;
821 
822  $attrs = array();
823  $a_xml_writer->xmlStartTag("Glossary", $attrs);
824 
825  // MetaData
826  $this->exportXMLMetaData($a_xml_writer);
827 
828  $terms = $this->getTermList();
829 
830  // export glossary terms
831  reset($terms);
832  foreach ($terms as $term)
833  {
834  $ilBench->start("GlossaryExport", "exportGlossaryItem");
835  $expLog->write(date("[y-m-d H:i:s] ")."Page Object ".$page["obj_id"]);
836 
837  // export xml to writer object
838  $ilBench->start("GlossaryExport", "exportGlossaryItem_getGlossaryTerm");
839  $glo_term = new ilGlossaryTerm($term["id"]);
840  $ilBench->stop("GlossaryExport", "exportGlossaryItem_getGlossaryTerm");
841  $ilBench->start("GlossaryExport", "exportGlossaryItem_XML");
842  $glo_term->exportXML($a_xml_writer, $a_inst);
843  $ilBench->stop("GlossaryExport", "exportGlossaryItem_XML");
844 
845  // collect all file items
846  /*
847  $ilBench->start("GlossaryExport", "exportGlossaryItem_CollectFileItems");
848  $file_ids = $page_obj->getFileItemIds();
849  foreach($file_ids as $file_id)
850  {
851  $this->file_ids[$file_id] = $file_id;
852  }
853  $ilBench->stop("GlossaryExport", "exportGlossaryItem_CollectFileItems");
854  */
855 
856  unset($glo_term);
857 
858  $ilBench->stop("GlossaryExport", "exportGlossaryItem");
859  }
860 
861  $a_xml_writer->xmlEndTag("Glossary");
862  }
863 
870  function exportXMLMetaData(&$a_xml_writer)
871  {
872  include_once("Services/MetaData/classes/class.ilMD2XML.php");
873  $md2xml = new ilMD2XML($this->getId(), 0, $this->getType());
874  $md2xml->setExportMode(true);
875  $md2xml->startExport();
876  $a_xml_writer->appendXML($md2xml->getXML());
877  }
878 
885  function exportXMLMediaObjects(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
886  {
887  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
888 
889  foreach ($this->mob_ids as $mob_id)
890  {
891  $expLog->write(date("[y-m-d H:i:s] ")."Media Object ".$mob_id);
892  $media_obj = new ilObjMediaObject($mob_id);
893  $media_obj->exportXML($a_xml_writer, $a_inst);
894  $media_obj->exportFiles($a_target_dir);
895  unset($media_obj);
896  }
897  }
898 
903  function exportFileItems($a_target_dir, &$expLog)
904  {
905  include_once("./Modules/File/classes/class.ilObjFile.php");
906 
907  foreach ($this->file_ids as $file_id)
908  {
909  $expLog->write(date("[y-m-d H:i:s] ")."File Item ".$file_id);
910  $file_obj = new ilObjFile($file_id, false);
911  $file_obj->export($a_target_dir);
912  unset($file_obj);
913  }
914  }
915 
916 
917 
921  function modifyExportIdentifier($a_tag, $a_param, $a_value)
922  {
923  if ($a_tag == "Identifier" && $a_param == "Entry")
924  {
925  $a_value = "il_".IL_INST_ID."_glo_".$this->getId();
926  }
927 
928  return $a_value;
929  }
930 
931 
932 
933 
944  function delete()
945  {
946  global $ilDB;
947 
948  // always call parent delete function first!!
949  if (!parent::delete())
950  {
951  return false;
952  }
953 
954  // delete terms
955  if (!$this->isVirtual())
956  {
957  $terms = $this->getTermList();
958  foreach ($terms as $term)
959  {
960  $term_obj =& new ilGlossaryTerm($term["id"]);
961  $term_obj->delete();
962  }
963  }
964 
965  // delete glossary data entry
966  $q = "DELETE FROM glossary WHERE id = ".$ilDB->quote($this->getId());
967  $ilDB->query($q);
968 
969  // delete meta data
970  $this->deleteMetaData();
971 /*
972  $nested = new ilNestedSetXML();
973  $nested->init($this->getId(), $this->getType());
974  $nested->deleteAllDBData();
975 */
976 
977  return true;
978  }
979 
990  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
991  {
992  global $tree;
993 
994  switch ($a_event)
995  {
996  case "link":
997 
998  //var_dump("<pre>",$a_params,"</pre>");
999  //echo "Glossary ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
1000  //exit;
1001  break;
1002 
1003  case "cut":
1004 
1005  //echo "Glossary ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
1006  //exit;
1007  break;
1008 
1009  case "copy":
1010 
1011  //var_dump("<pre>",$a_params,"</pre>");
1012  //echo "Glossary ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
1013  //exit;
1014  break;
1015 
1016  case "paste":
1017 
1018  //echo "Glossary ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
1019  //exit;
1020  break;
1021 
1022  case "new":
1023 
1024  //echo "Glossary ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
1025  //exit;
1026  break;
1027  }
1028 
1029  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
1030  if ($a_node_id==$_GET["ref_id"])
1031  {
1032  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
1033  $parent_type = $parent_obj->getType();
1034  if($parent_type == $this->getType())
1035  {
1036  $a_node_id = (int) $tree->getParentId($a_node_id);
1037  }
1038  }
1039 
1040  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
1041  }
1042 
1043 
1044  function getXMLZip()
1045  {
1046  include_once("./Modules/Glossary/classes/class.ilGlossaryExport.php");
1047 
1048  $glo_exp = new ilGlossaryExport($this);
1049 
1050  return $glo_exp->buildExportFile();
1051  }
1052 
1053 
1054 } // END class.ilObjGlossary
1055 
1056 ?>