ILIAS  Release_4_0_x_branch Revision 61816
 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-2009 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  $ilDB->manipulate("INSERT INTO glossary (id, is_online, virtual) VALUES (".
68  $ilDB->quote($this->getId(), "integer").",".
69  $ilDB->quote("n", "text").",".
70  $ilDB->quote($this->getVirtualMode(), "text").")");
71 
72  }
73 
77  function read()
78  {
79  global $ilDB;
80 
81  parent::read();
82 # echo "Glossary<br>\n";
83 
84  $q = "SELECT * FROM glossary WHERE id = ".
85  $ilDB->quote($this->getId(), "integer");
86  $gl_set = $ilDB->query($q);
87  $gl_rec = $ilDB->fetchAssoc($gl_set);
88  $this->setOnline(ilUtil::yn2tf($gl_rec["is_online"]));
89  $this->setVirtualMode($gl_rec["virtual"]);
90  $this->setPublicExportFile("xml", $gl_rec["public_xml_file"]);
91  $this->setPublicExportFile("html", $gl_rec["public_html_file"]);
92  $this->setActiveGlossaryMenu(ilUtil::yn2tf($gl_rec["glo_menu_active"]));
93  $this->setActiveDownloads(ilUtil::yn2tf($gl_rec["downloads_active"]));
94  }
95 
101  function getDescription()
102  {
103  return parent::getDescription();
104  }
105 
109  function setDescription($a_description)
110  {
111  parent::setDescription($a_description);
112  }
113 
114 
118  function setVirtualMode($a_mode)
119  {
120  switch ($a_mode)
121  {
122  case "level":
123  case "subtree":
124  // case "fixed":
125  $this->virtual_mode = $a_mode;
126  $this->virtual = true;
127  break;
128 
129  default:
130  $this->virtual_mode = "none";
131  $this->virtual = false;
132  break;
133  }
134  }
135 
139  function getVirtualMode()
140  {
141  return $this->virtual_mode;
142  }
143 
147  function isVirtual()
148  {
149  return $this->virtual;
150  }
151 
157  function getTitle()
158  {
159  return parent::getTitle();
160  }
161 
165  function setTitle($a_title)
166  {
167  parent::setTitle($a_title);
168 // $this->meta_data->setTitle($a_title);
169  }
170 
171  function setOnline($a_online)
172  {
173  $this->online = $a_online;
174  }
175 
176  function getOnline()
177  {
178  return $this->online;
179  }
180 
184  function _lookupOnline($a_id)
185  {
186  global $ilDB;
187 
188  $q = "SELECT * FROM glossary WHERE id = ".
189  $ilDB->quote($a_id, "integer");
190  $lm_set = $ilDB->query($q);
191  $lm_rec = $ilDB->fetchAssoc($lm_set);
192 
193  return ilUtil::yn2tf($lm_rec["is_online"]);
194  }
195 
196  function setActiveGlossaryMenu($a_act_glo_menu)
197  {
198  $this->glo_menu_active = $a_act_glo_menu;
199  }
200 
202  {
203  return $this->glo_menu_active;
204  }
205 
206  function setActiveDownloads($a_down)
207  {
208  $this->downloads_active = $a_down;
209  }
210 
211  function isActiveDownloads()
212  {
213  return $this->downloads_active;
214  }
215 
219  function update()
220  {
221  global $ilDB;
222 
223  $this->updateMetaData();
224 
225  $ilDB->manipulate("UPDATE glossary SET ".
226  " is_online = ".$ilDB->quote(ilUtil::tf2yn($this->getOnline()), "text").",".
227  " virtual = ".$ilDB->quote($this->getVirtualMode(), "text").",".
228  " public_xml_file = ".$ilDB->quote($this->getPublicExportFile("xml"), "text").",".
229  " public_html_file = ".$ilDB->quote($this->getPublicExportFile("html"), "text").",".
230  " glo_menu_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveGlossaryMenu()), "text").",".
231  " downloads_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveDownloads()), "text")." ".
232  " WHERE id = ".$ilDB->quote($this->getId(), "integer"));
233 
234  parent::update();
235  }
236 
237 
241  function getTermList($searchterm="")
242  {
243  if ($this->isVirtual())
244  {
245  global $tree;
246 
247  $glo_ids = array();
248 
249  switch ($this->getVirtualMode())
250  {
251  case "level":
252  $glo_arr = $tree->getChildsByType($tree->getParentId($this->getRefId()),"glo");
253 
254  foreach ($glo_arr as $glo)
255  {
256  {
257  $glo_ids[] = $glo['obj_id'];
258  }
259  }
260  break;
261 
262  case "subtree":
263  $subtree_nodes = $tree->getSubTree($tree->getNodeData($tree->getParentId($this->getRefId())));
264 
265  foreach ($subtree_nodes as $node)
266  {
267  if ($node['type'] == 'glo')
268  {
269  $glo_ids[] = $node['obj_id'];
270  }
271  }
272  break;
273 
274 /* for futere enhancements
275  case "fixed":
276 
277  break;
278 */
279  // fallback to none virtual mode in case of error
280  default:
281  $glo_ids[] = $this->getId();
282  break;
283  }
284  }
285  else
286  {
287  $glo_ids = $this->getId();
288  }
289 
290  $list = ilGlossaryTerm::getTermList($glo_ids,$searchterm);
291  return $list;
292  }
293 
300  {
301  $glo_data_dir = ilUtil::getDataDir()."/glo_data";
302  ilUtil::makeDir($glo_data_dir);
303  if(!is_writable($glo_data_dir))
304  {
305  $this->ilias->raiseError("Glossary Data Directory (".$glo_data_dir
306  .") not writeable.",$this->ilias->error_obj->FATAL);
307  }
308 
309  // create glossary directory (data_dir/glo_data/glo_<id>)
310  $glo_dir = $glo_data_dir."/glo_".$this->getId();
311  ilUtil::makeDir($glo_dir);
312  if(!@is_dir($glo_dir))
313  {
314  $this->ilias->raiseError("Creation of Glossary Directory failed.",$this->ilias->error_obj->FATAL);
315  }
316  // create Import subdirectory (data_dir/glo_data/glo_<id>/import)
317  $import_dir = $glo_dir."/import";
318  ilUtil::makeDir($import_dir);
319  if(!@is_dir($import_dir))
320  {
321  $this->ilias->raiseError("Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
322  }
323  }
324 
329  {
330  $export_dir = ilUtil::getDataDir()."/glo_data"."/glo_".$this->getId()."/import";
331 
332  return $export_dir;
333  }
334 
338  function createExportDirectory($a_type = "xml")
339  {
340  include_once("./Services/Export/classes/class.ilExport.php");
341  return ilExport::_createExportDirectory($this->getId(), $a_type, $this->getType());
342  }
343 
347  function getExportDirectory($a_type = "xml")
348  {
349  include_once("./Services/Export/classes/class.ilExport.php");
350  return ilExport::_getExportDirectory($this->getId(), $a_type, $this->getType());
351  }
352 
356  function getExportFiles()
357  {
358  include_once("./Services/Export/classes/class.ilExport.php");
359  return ilExport::_getExportFiles($this->getId(), array("xml", "html"), $this->getType());
360  }
361 
368  function setPublicExportFile($a_type, $a_file)
369  {
370  $this->public_export_file[$a_type] = $a_file;
371  }
372 
380  function getPublicExportFile($a_type)
381  {
382  return $this->public_export_file[$a_type];
383  }
384 
388  function exportHTML($a_target_dir, $log)
389  {
390  global $ilias, $tpl;
391 
392  // initialize temporary target directory
393  ilUtil::delDir($a_target_dir);
394  ilUtil::makeDir($a_target_dir);
395  $mob_dir = $a_target_dir."/mobs";
396  ilUtil::makeDir($mob_dir);
397  $file_dir = $a_target_dir."/files";
398  ilUtil::makeDir($file_dir);
399  $tex_dir = $a_target_dir."/teximg";
400  ilUtil::makeDir($tex_dir);
401 
402  // export system style sheet
403  $location_stylesheet = ilUtil::getStyleSheetLocation("filesystem");
404  $style_name = $ilias->account->prefs["style"].".css";
405  copy($location_stylesheet, $a_target_dir."/".$style_name);
406  $location_stylesheet = ilUtil::getStyleSheetLocation();
407 
408  $cont_stylesheet = "Services/COPage/css/content.css";
409  copy($cont_stylesheet, $a_target_dir."/content.css");
410 
411  // export syntax highlighting style
412  $syn_stylesheet = ilObjStyleSheet::getSyntaxStylePath();
413  copy($syn_stylesheet, $a_target_dir."/syntaxhighlight.css");
414 
415  // get glossary presentation gui class
416  include_once("./Modules/Glossary/classes/class.ilGlossaryPresentationGUI.php");
417  $_GET["cmd"] = "nop";
418  $glo_gui =& new ilGlossaryPresentationGUI();
419  $glo_gui->setOfflineMode(true);
420  $glo_gui->setOfflineDirectory($a_target_dir);
421 
422  // could be implemented in the future if other export
423  // formats are supported (e.g. scorm)
424  //$glo_gui->setExportFormat($a_export_format);
425 
426  // export terms
427  $this->exportHTMLGlossaryTerms($glo_gui, $a_target_dir);
428 
429  // export all media objects
430  foreach ($this->offline_mobs as $mob)
431  {
432  $this->exportHTMLMOB($a_target_dir, $glo_gui, $mob, "_blank");
433  }
434  $_GET["obj_type"] = "MediaObject";
435  $_GET["obj_id"] = $a_mob_id;
436  $_GET["cmd"] = "";
437 
438  // export all file objects
439  foreach ($this->offline_files as $file)
440  {
441  $this->exportHTMLFile($a_target_dir, $file);
442  }
443 
444  // export images
445  $image_dir = $a_target_dir."/images";
446  ilUtil::makeDir($image_dir);
447  ilUtil::makeDir($image_dir."/browser");
448  copy(ilUtil::getImagePath("enlarge.gif", false, "filesystem"),
449  $image_dir."/enlarge.gif");
450  copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
451  $image_dir."/browser/plus.gif");
452  copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
453  $image_dir."/browser/minus.gif");
454  copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
455  $image_dir."/browser/blank.gif");
456  copy(ilUtil::getImagePath("icon_st.gif", false, "filesystem"),
457  $image_dir."/icon_st.gif");
458  copy(ilUtil::getImagePath("icon_pg.gif", false, "filesystem"),
459  $image_dir."/icon_pg.gif");
460  copy(ilUtil::getImagePath("nav_arr_L.gif", false, "filesystem"),
461  $image_dir."/nav_arr_L.gif");
462  copy(ilUtil::getImagePath("nav_arr_R.gif", false, "filesystem"),
463  $image_dir."/nav_arr_R.gif");
464 
465  // template workaround: reset of template
466  $tpl = new ilTemplate("tpl.main.html", true, true);
467  $tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
468  $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
469 
470  // zip everything
471  if (true)
472  {
473  // zip it all
474  $date = time();
475  $zip_file = $this->getExportDirectory("html")."/".$date."__".IL_INST_ID."__".
476  $this->getType()."_".$this->getId().".zip";
477 //echo "zip-".$a_target_dir."-to-".$zip_file;
478  ilUtil::zip($a_target_dir, $zip_file);
479  ilUtil::delDir($a_target_dir);
480  }
481  }
482 
483 
487  function exportHTMLGlossaryTerms(&$a_glo_gui, $a_target_dir)
488  {
489  global $ilUser;
490 
491  // index.html file
492  $a_glo_gui->tpl = new ilTemplate("tpl.main.html", true, true);
493  $style_name = $ilUser->prefs["style"].".css";;
494  $a_glo_gui->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
495  $a_glo_gui->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
496  $a_glo_gui->tpl->setVariable("HEADER", $this->getTitle());
497 
498  $content = $a_glo_gui->listTerms();
499  $file = $a_target_dir."/index.html";
500 
501  // open file
502  if (!($fp = @fopen($file,"w+")))
503  {
504  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
505  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
506  }
507  chmod($file, 0770);
508  fwrite($fp, $content);
509  fclose($fp);
510 
511  $terms = $this->getTermList();
512 
513  $this->offline_mobs = array();
514  $this->offline_files = array();
515 
516  foreach($terms as $term)
517  {
518  $a_glo_gui->tpl = new ilTemplate("tpl.main.html", true, true);
519  //$tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
520 
521  // set style
522  $style_name = $ilUser->prefs["style"].".css";;
523  $a_glo_gui->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
524 
525  $_GET["term_id"] = $term["id"];
526  $_GET["frame"] = "_blank";
527  $content =& $a_glo_gui->listDefinitions();
528  $file = $a_target_dir."/term_".$term["id"].".html";
529 
530  // open file
531  if (!($fp = @fopen($file,"w+")))
532  {
533  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
534  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
535  }
536  chmod($file, 0770);
537  fwrite($fp, $content);
538  fclose($fp);
539 
540  // store linked/embedded media objects of glosssary term
541  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
542  $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
543  foreach($defs as $def)
544  {
545  $def_mobs = ilObjMediaObject::_getMobsOfObject("gdf:pg", $def["id"]);
546  foreach($def_mobs as $def_mob)
547  {
548  $this->offline_mobs[$def_mob] = $def_mob;
549  }
550 
551  // get all files of page
552  include_once("./Modules/File/classes/class.ilObjFile.php");
553  $def_files = ilObjFile::_getFilesOfObject("gdf:pg", $def["id"]);
554  $this->offline_files = array_merge($this->offline_files, $def_files);
555 
556  }
557  }
558  }
559 
563  function exportHTMLMOB($a_target_dir, &$a_glo_gui, $a_mob_id)
564  {
565  global $tpl;
566 
567  $mob_dir = $a_target_dir."/mobs";
568 
569  $source_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob_id;
570  if (@is_dir($source_dir))
571  {
572  ilUtil::makeDir($mob_dir."/mm_".$a_mob_id);
573  ilUtil::rCopy($source_dir, $mob_dir."/mm_".$a_mob_id);
574  }
575 
576  $tpl = new ilTemplate("tpl.main.html", true, true);
577  $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
578  $_GET["obj_type"] = "MediaObject";
579  $_GET["mob_id"] = $a_mob_id;
580  $_GET["cmd"] = "";
581  $content =& $a_glo_gui->media();
582  $file = $a_target_dir."/media_".$a_mob_id.".html";
583 
584  // open file
585  if (!($fp = @fopen($file,"w+")))
586  {
587  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
588  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
589  }
590  chmod($file, 0770);
591  fwrite($fp, $content);
592  fclose($fp);
593 
594  // fullscreen
595  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
596  $mob_obj = new ilObjMediaObject($a_mob_id);
597  if ($mob_obj->hasFullscreenItem())
598  {
599  $tpl = new ilTemplate("tpl.main.html", true, true);
600  $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
601  $_GET["mob_id"] = $a_mob_id;
602  $_GET["cmd"] = "fullscreen";
603  $content = $a_glo_gui->fullscreen();
604  $file = $a_target_dir."/fullscreen_".$a_mob_id.".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  }
617 
621  function exportHTMLFile($a_target_dir, $a_file_id)
622  {
623  $file_dir = $a_target_dir."/files/file_".$a_file_id;
624  ilUtil::makeDir($file_dir);
625  include_once("./Modules/File/classes/class.ilObjFile.php");
626  $file_obj = new ilObjFile($a_file_id, false);
627  $source_file = $file_obj->getDirectory($file_obj->getVersion())."/".$file_obj->getFileName();
628  if (!is_file($source_file))
629  {
630  $source_file = $file_obj->getDirectory()."/".$file_obj->getFileName();
631  }
632  copy($source_file, $file_dir."/".$file_obj->getFileName());
633  }
634 
635 
642  function exportXML(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
643  {
644  global $ilBench;
645 
646  // export glossary
647  $attrs = array();
648  $attrs["Type"] = "Glossary";
649  $a_xml_writer->xmlStartTag("ContentObject", $attrs);
650 
651  // MetaData
652  $this->exportXMLMetaData($a_xml_writer);
653 
654  // collect media objects
655  $terms = $this->getTermList();
656  $this->mob_ids = array();
657  $this->file_ids = array();
658  foreach ($terms as $term)
659  {
660  include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
661 
662  $defs = ilGlossaryDefinition::getDefinitionList($term[id]);
663 
664  foreach($defs as $def)
665  {
666  $this->page_object =& new ilPageObject("gdf",
667  $def["id"], $this->halt_on_error);
668  $this->page_object->buildDom();
669  $this->page_object->insertInstIntoIDs(IL_INST_ID);
670  $mob_ids = $this->page_object->collectMediaObjects(false);
671  $file_ids = $this->page_object->collectFileItems();
672  foreach($mob_ids as $mob_id)
673  {
674  $this->mob_ids[$mob_id] = $mob_id;
675  }
676  foreach($file_ids as $file_id)
677  {
678  $this->file_ids[$file_id] = $file_id;
679  }
680  }
681  }
682 
683  // export media objects
684  $expLog->write(date("[y-m-d H:i:s] ")."Start Export Media Objects");
685  $ilBench->start("GlossaryExport", "exportMediaObjects");
686  $this->exportXMLMediaObjects($a_xml_writer, $a_inst, $a_target_dir, $expLog);
687  $ilBench->stop("GlossaryExport", "exportMediaObjects");
688  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Media Objects");
689 
690  // FileItems
691  $expLog->write(date("[y-m-d H:i:s] ")."Start Export File Items");
692  $ilBench->start("ContentObjectExport", "exportFileItems");
693  $this->exportFileItems($a_target_dir, $expLog);
694  $ilBench->stop("ContentObjectExport", "exportFileItems");
695  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export File Items");
696 
697  // Glossary
698  $expLog->write(date("[y-m-d H:i:s] ")."Start Export Glossary Items");
699  $ilBench->start("GlossaryExport", "exportGlossaryItems");
700  $this->exportXMLGlossaryItems($a_xml_writer, $a_inst, $expLog);
701  $ilBench->stop("GlossaryExport", "exportGlossaryItems");
702  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Glossary Items");
703 
704  $a_xml_writer->xmlEndTag("ContentObject");
705  }
706 
713  function exportXMLGlossaryItems(&$a_xml_writer, $a_inst, &$expLog)
714  {
715  global $ilBench;
716 
717  $attrs = array();
718  $a_xml_writer->xmlStartTag("Glossary", $attrs);
719 
720  // MetaData
721  $this->exportXMLMetaData($a_xml_writer);
722 
723  $terms = $this->getTermList();
724 
725  // export glossary terms
726  reset($terms);
727  foreach ($terms as $term)
728  {
729  $ilBench->start("GlossaryExport", "exportGlossaryItem");
730  $expLog->write(date("[y-m-d H:i:s] ")."Page Object ".$page["obj_id"]);
731 
732  // export xml to writer object
733  $ilBench->start("GlossaryExport", "exportGlossaryItem_getGlossaryTerm");
734  $glo_term = new ilGlossaryTerm($term["id"]);
735  $ilBench->stop("GlossaryExport", "exportGlossaryItem_getGlossaryTerm");
736  $ilBench->start("GlossaryExport", "exportGlossaryItem_XML");
737  $glo_term->exportXML($a_xml_writer, $a_inst);
738  $ilBench->stop("GlossaryExport", "exportGlossaryItem_XML");
739 
740  // collect all file items
741  /*
742  $ilBench->start("GlossaryExport", "exportGlossaryItem_CollectFileItems");
743  $file_ids = $page_obj->getFileItemIds();
744  foreach($file_ids as $file_id)
745  {
746  $this->file_ids[$file_id] = $file_id;
747  }
748  $ilBench->stop("GlossaryExport", "exportGlossaryItem_CollectFileItems");
749  */
750 
751  unset($glo_term);
752 
753  $ilBench->stop("GlossaryExport", "exportGlossaryItem");
754  }
755 
756  $a_xml_writer->xmlEndTag("Glossary");
757  }
758 
765  function exportXMLMetaData(&$a_xml_writer)
766  {
767  include_once("Services/MetaData/classes/class.ilMD2XML.php");
768  $md2xml = new ilMD2XML($this->getId(), 0, $this->getType());
769  $md2xml->setExportMode(true);
770  $md2xml->startExport();
771  $a_xml_writer->appendXML($md2xml->getXML());
772  }
773 
780  function exportXMLMediaObjects(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
781  {
782  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
783 
784  foreach ($this->mob_ids as $mob_id)
785  {
786  $expLog->write(date("[y-m-d H:i:s] ")."Media Object ".$mob_id);
787  $media_obj = new ilObjMediaObject($mob_id);
788  $media_obj->exportXML($a_xml_writer, $a_inst);
789  $media_obj->exportFiles($a_target_dir);
790  unset($media_obj);
791  }
792  }
793 
798  function exportFileItems($a_target_dir, &$expLog)
799  {
800  include_once("./Modules/File/classes/class.ilObjFile.php");
801 
802  foreach ($this->file_ids as $file_id)
803  {
804  $expLog->write(date("[y-m-d H:i:s] ")."File Item ".$file_id);
805  $file_obj = new ilObjFile($file_id, false);
806  $file_obj->export($a_target_dir);
807  unset($file_obj);
808  }
809  }
810 
811 
812 
816  function modifyExportIdentifier($a_tag, $a_param, $a_value)
817  {
818  if ($a_tag == "Identifier" && $a_param == "Entry")
819  {
820  $a_value = "il_".IL_INST_ID."_glo_".$this->getId();
821  }
822 
823  return $a_value;
824  }
825 
826 
827 
828 
839  function delete()
840  {
841  global $ilDB;
842 
843  // always call parent delete function first!!
844  if (!parent::delete())
845  {
846  return false;
847  }
848 
849  // delete terms
850  if (!$this->isVirtual())
851  {
852  $terms = $this->getTermList();
853  foreach ($terms as $term)
854  {
855  $term_obj =& new ilGlossaryTerm($term["id"]);
856  $term_obj->delete();
857  }
858  }
859 
860  // delete glossary data entry
861  $q = "DELETE FROM glossary WHERE id = ".$ilDB->quote($this->getId());
862  $ilDB->query($q);
863 
864  // delete meta data
865  $this->deleteMetaData();
866 /*
867  $nested = new ilNestedSetXML();
868  $nested->init($this->getId(), $this->getType());
869  $nested->deleteAllDBData();
870 */
871 
872  return true;
873  }
874 
885  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
886  {
887  global $tree;
888 
889  switch ($a_event)
890  {
891  case "link":
892 
893  //var_dump("<pre>",$a_params,"</pre>");
894  //echo "Glossary ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
895  //exit;
896  break;
897 
898  case "cut":
899 
900  //echo "Glossary ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
901  //exit;
902  break;
903 
904  case "copy":
905 
906  //var_dump("<pre>",$a_params,"</pre>");
907  //echo "Glossary ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
908  //exit;
909  break;
910 
911  case "paste":
912 
913  //echo "Glossary ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
914  //exit;
915  break;
916 
917  case "new":
918 
919  //echo "Glossary ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
920  //exit;
921  break;
922  }
923 
924  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
925  if ($a_node_id==$_GET["ref_id"])
926  {
927  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
928  $parent_type = $parent_obj->getType();
929  if($parent_type == $this->getType())
930  {
931  $a_node_id = (int) $tree->getParentId($a_node_id);
932  }
933  }
934 
935  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
936  }
937 
938 
942  function getXMLZip()
943  {
944  include_once("./Modules/Glossary/classes/class.ilGlossaryExport.php");
945  $glo_exp = new ilGlossaryExport($this);
946  return $glo_exp->buildExportFile();
947  }
948 
949 
950 } // END class.ilObjGlossary
951 
952 ?>