ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
5require_once("./Services/Object/classes/class.ilObject.php");
6require_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
7include_once("./Services/AdvancedMetaData/interfaces/interface.ilAdvancedMetaDataSubItems.php");
8
21{
22
27 function ilObjGlossary($a_id = 0,$a_call_by_reference = true)
28 {
29 $this->type = "glo";
30 $this->ilObject($a_id,$a_call_by_reference);
31 }
32
36 function create($a_upload = false)
37 {
38 global $ilDB;
39
40 parent::create();
41
42 // meta data will be created by
43 // import parser
44 if (!$a_upload)
45 {
46 $this->createMetaData();
47 }
48
49 $ilDB->manipulate("INSERT INTO glossary (id, is_online, virtual, pres_mode, snippet_length) VALUES (".
50 $ilDB->quote($this->getId(), "integer").",".
51 $ilDB->quote("n", "text").",".
52 $ilDB->quote($this->getVirtualMode(), "text").",".
53 $ilDB->quote("table", "text").",".
54 $ilDB->quote(200, "integer").
55 ")");
56 $this->setPresentationMode("table");
57 $this->setSnippetLength(200);
58
59 if (((int) $this->getStyleSheetId()) > 0)
60 {
61 include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
63 }
64
65 }
66
70 function read()
71 {
72 global $ilDB;
73
74 parent::read();
75# echo "Glossary<br>\n";
76
77 $q = "SELECT * FROM glossary WHERE id = ".
78 $ilDB->quote($this->getId(), "integer");
79 $gl_set = $ilDB->query($q);
80 $gl_rec = $ilDB->fetchAssoc($gl_set);
81 $this->setOnline(ilUtil::yn2tf($gl_rec["is_online"]));
82 $this->setVirtualMode($gl_rec["virtual"]);
83 $this->setPublicExportFile("xml", $gl_rec["public_xml_file"]);
84 $this->setPublicExportFile("html", $gl_rec["public_html_file"]);
85 $this->setActiveGlossaryMenu(ilUtil::yn2tf($gl_rec["glo_menu_active"]));
86 $this->setActiveDownloads(ilUtil::yn2tf($gl_rec["downloads_active"]));
87 $this->setPresentationMode($gl_rec["pres_mode"]);
88 $this->setSnippetLength($gl_rec["snippet_length"]);
89 $this->setShowTaxonomy($gl_rec["show_tax"]);
90
91 include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
93
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
176 function setPresentationMode($a_val)
177 {
178 $this->pres_mode = $a_val;
179 }
180
187 {
188 return $this->pres_mode;
189 }
190
196 function setSnippetLength($a_val)
197 {
198 $this->snippet_length = $a_val;
199 }
200
207 {
208 return ($this->snippet_length > 0)
209 ? $this->snippet_length
210 : null;
211 }
212
213 function setOnline($a_online)
214 {
215 $this->online = $a_online;
216 }
217
218 function getOnline()
219 {
220 return $this->online;
221 }
222
226 function _lookupOnline($a_id)
227 {
228 global $ilDB;
229
230 $q = "SELECT is_online FROM glossary WHERE id = ".
231 $ilDB->quote($a_id, "integer");
232 $lm_set = $ilDB->query($q);
233 $lm_rec = $ilDB->fetchAssoc($lm_set);
234
235 return ilUtil::yn2tf($lm_rec["is_online"]);
236 }
237
244 static protected function lookup($a_id, $a_property)
245 {
246 global $ilDB;
247
248 $set = $ilDB->query("SELECT $a_property FROM glossary WHERE id = ".
249 $ilDB->quote($a_id, "integer"));
250 $rec = $ilDB->fetchAssoc($set);
251
252 return $rec[$a_property];
253 }
254
261 static function lookupSnippetLength($a_id)
262 {
263 return ilObjGlossary::lookup($a_id, "snippet_length");
264 }
265
266
267 function setActiveGlossaryMenu($a_act_glo_menu)
268 {
269 $this->glo_menu_active = $a_act_glo_menu;
270 }
271
273 {
274 return $this->glo_menu_active;
275 }
276
277 function setActiveDownloads($a_down)
278 {
279 $this->downloads_active = $a_down;
280 }
281
283 {
284 return $this->downloads_active;
285 }
286
291 {
292 return $this->style_id;
293 }
294
298 function setStyleSheetId($a_style_id)
299 {
300 $this->style_id = $a_style_id;
301 }
302
303
309 function setShowTaxonomy($a_val)
310 {
311 $this->show_tax = $a_val;
312 }
313
320 {
321 return $this->show_tax;
322 }
323
327 function update()
328 {
329 global $ilDB;
330
331 $this->updateMetaData();
332
333 $ilDB->manipulate("UPDATE glossary SET ".
334 " is_online = ".$ilDB->quote(ilUtil::tf2yn($this->getOnline()), "text").",".
335 " virtual = ".$ilDB->quote($this->getVirtualMode(), "text").",".
336 " public_xml_file = ".$ilDB->quote($this->getPublicExportFile("xml"), "text").",".
337 " public_html_file = ".$ilDB->quote($this->getPublicExportFile("html"), "text").",".
338 " glo_menu_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveGlossaryMenu()), "text").",".
339 " downloads_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveDownloads()), "text").", ".
340 " pres_mode = ".$ilDB->quote($this->getPresentationMode(), "text").", ".
341 " show_tax = ".$ilDB->quote((int) $this->getShowTaxonomy(), "integer").", ".
342 " snippet_length = ".$ilDB->quote((int)$this->getSnippetLength(), "integer")." ".
343 " WHERE id = ".$ilDB->quote($this->getId(), "integer"));
344
345 include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
347
348 parent::update();
349 }
350
351
355 function getTermList($searchterm = "", $a_letter = "", $a_def = "", $a_tax_node = 0, $a_include_offline_childs = false,
356 $a_add_amet_fields = false, array $a_amet_filter = null, $a_omit_virtual = false)
357 {
358 if ($a_omit_virtual)
359 {
360 $glo_ids[] = $this->getId();
361 }
362 else
363 {
364 $glo_ids = $this->getAllGlossaryIds($a_include_offline_childs);
365 }
366 $list = ilGlossaryTerm::getTermList($glo_ids, $searchterm, $a_letter, $a_def, $a_tax_node,
367 $a_add_amet_fields, $a_amet_filter);
368 return $list;
369 }
370
374 function getFirstLetters($a_tax_node = 0)
375 {
376 $glo_ids = $this->getAllGlossaryIds();
377 $first_letters = ilGlossaryTerm::getFirstLetters($glo_ids, $a_tax_node);
378 return $first_letters;
379 }
380
387 function getAllGlossaryIds($a_include_offline_childs = false)
388 {
389 global $tree;
390
391 if ($this->isVirtual())
392 {
393 $glo_ids = array();
394
395 $virtual_mode = $this->getRefId() ? $this->getVirtualMode() : '';
396 switch ($virtual_mode)
397 {
398 case "level":
399 $glo_arr = $tree->getChildsByType($tree->getParentId($this->getRefId()),"glo");
400 $glo_ids[] = $this->getId();
401 foreach ($glo_arr as $glo)
402 {
403 {
404 $glo_ids[] = $glo['obj_id'];
405 }
406 }
407 if (!$a_include_offline_childs)
408 {
409 $glo_ids = ilObjGlossary::removeOfflineGlossaries($glo_ids);
410 }
411 // always show entries of current glossary (if no permission is given, user will not come to the presentation screen)
412 // see bug #14477
413 if (!in_array($this->getId(), $glo_ids))
414 {
415 $glo_ids[] = $this->getId();
416 }
417 break;
418
419 case "subtree":
420 $subtree_nodes = $tree->getSubTree($tree->getNodeData($tree->getParentId($this->getRefId())));
421
422 foreach ($subtree_nodes as $node)
423 {
424 if ($node['type'] == 'glo')
425 {
426 $glo_ids[] = $node['obj_id'];
427 }
428 }
429 if (!$a_include_offline_childs)
430 {
431 $glo_ids = ilObjGlossary::removeOfflineGlossaries($glo_ids);
432 }
433 // always show entries of current glossary (if no permission is given, user will not come to the presentation screen)
434 // see bug #14477
435 if (!in_array($this->getId(), $glo_ids))
436 {
437 $glo_ids[] = $this->getId();
438 }
439 break;
440
441 // fallback to none virtual mode in case of error
442 default:
443 $glo_ids[] = $this->getId();
444 break;
445 }
446 }
447 else
448 {
449 $glo_ids = $this->getId();
450 }
451
452 return $glo_ids;
453 }
454
461 {
462 $glo_data_dir = ilUtil::getDataDir()."/glo_data";
463 ilUtil::makeDir($glo_data_dir);
464 if(!is_writable($glo_data_dir))
465 {
466 $this->ilias->raiseError("Glossary Data Directory (".$glo_data_dir
467 .") not writeable.",$this->ilias->error_obj->FATAL);
468 }
469
470 // create glossary directory (data_dir/glo_data/glo_<id>)
471 $glo_dir = $glo_data_dir."/glo_".$this->getId();
472 ilUtil::makeDir($glo_dir);
473 if(!@is_dir($glo_dir))
474 {
475 $this->ilias->raiseError("Creation of Glossary Directory failed.",$this->ilias->error_obj->FATAL);
476 }
477 // create Import subdirectory (data_dir/glo_data/glo_<id>/import)
478 $import_dir = $glo_dir."/import";
479 ilUtil::makeDir($import_dir);
480 if(!@is_dir($import_dir))
481 {
482 $this->ilias->raiseError("Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
483 }
484 }
485
490 {
491 $export_dir = ilUtil::getDataDir()."/glo_data"."/glo_".$this->getId()."/import";
492
493 return $export_dir;
494 }
495
499 function createExportDirectory($a_type = "xml")
500 {
501 include_once("./Services/Export/classes/class.ilExport.php");
502 return ilExport::_createExportDirectory($this->getId(), $a_type, $this->getType());
503 }
504
508 function getExportDirectory($a_type = "xml")
509 {
510 include_once("./Services/Export/classes/class.ilExport.php");
511 return ilExport::_getExportDirectory($this->getId(), $a_type, $this->getType());
512 }
513
517 function getExportFiles()
518 {
519 include_once("./Services/Export/classes/class.ilExport.php");
520 return ilExport::_getExportFiles($this->getId(), array("xml", "html"), $this->getType());
521 }
522
529 function setPublicExportFile($a_type, $a_file)
530 {
531 $this->public_export_file[$a_type] = $a_file;
532 }
533
541 function getPublicExportFile($a_type)
542 {
543 return $this->public_export_file[$a_type];
544 }
545
549 function exportHTML($a_target_dir, $log)
550 {
551 global $ilias, $tpl;
552
553 // initialize temporary target directory
554 ilUtil::delDir($a_target_dir);
555 ilUtil::makeDir($a_target_dir);
556
557 include_once("./Services/COPage/classes/class.ilCOPageHTMLExport.php");
558 $this->co_page_html_export = new ilCOPageHTMLExport($a_target_dir);
559 $this->co_page_html_export->createDirectories();
560
561 // export system style sheet
562 $location_stylesheet = ilUtil::getStyleSheetLocation("filesystem");
563 $style_name = $ilias->account->prefs["style"].".css";
564 copy($location_stylesheet, $a_target_dir."/".$style_name);
565 $location_stylesheet = ilUtil::getStyleSheetLocation();
566
567 if ($this->getStyleSheetId() < 1)
568 {
569 $cont_stylesheet = "Services/COPage/css/content.css";
570 copy($cont_stylesheet, $a_target_dir."/content.css");
571 }
572 else
573 {
574 $content_style_img_dir = $a_target_dir."/images";
575 ilUtil::makeDir($content_style_img_dir);
576 $style = new ilObjStyleSheet($this->getStyleSheetId());
577 $style->writeCSSFile($a_target_dir."/content.css", "images");
578 $style->copyImagesToDir($content_style_img_dir);
579 }
580
581 // export syntax highlighting style
582 $syn_stylesheet = ilObjStyleSheet::getSyntaxStylePath();
583 copy($syn_stylesheet, $a_target_dir."/syntaxhighlight.css");
584
585 // get glossary presentation gui class
586 include_once("./Modules/Glossary/classes/class.ilGlossaryPresentationGUI.php");
587 $_GET["cmd"] = "nop";
588 $glo_gui =& new ilGlossaryPresentationGUI();
589 $glo_gui->setOfflineMode(true);
590 $glo_gui->setOfflineDirectory($a_target_dir);
591
592 // could be implemented in the future if other export
593 // formats are supported (e.g. scorm)
594 //$glo_gui->setExportFormat($a_export_format);
595
596 // export terms
597 $this->exportHTMLGlossaryTerms($glo_gui, $a_target_dir);
598
599 // export all media objects
600 foreach ($this->offline_mobs as $mob)
601 {
602 $this->exportHTMLMOB($a_target_dir, $glo_gui, $mob, "_blank");
603 }
604 $_GET["obj_type"] = "MediaObject";
605 $_GET["obj_id"] = $a_mob_id;
606 $_GET["cmd"] = "";
607
608 // export all file objects
609 foreach ($this->offline_files as $file)
610 {
611 $this->exportHTMLFile($a_target_dir, $file);
612 }
613
614 // export images
615 $image_dir = $a_target_dir."/images";
616 ilUtil::makeDir($image_dir);
617 ilUtil::makeDir($image_dir."/browser");
618 copy(ilUtil::getImagePath("enlarge.svg", false, "filesystem"),
619 $image_dir."/enlarge.svg");
620 copy(ilUtil::getImagePath("browser/blank.png", false, "filesystem"),
621 $image_dir."/browser/plus.png");
622 copy(ilUtil::getImagePath("browser/blank.png", false, "filesystem"),
623 $image_dir."/browser/minus.png");
624 copy(ilUtil::getImagePath("browser/blank.png", false, "filesystem"),
625 $image_dir."/browser/blank.png");
626 copy(ilUtil::getImagePath("icon_st.svg", false, "filesystem"),
627 $image_dir."/icon_st.svg");
628 copy(ilUtil::getImagePath("icon_pg.svg", false, "filesystem"),
629 $image_dir."/icon_pg.svg");
630 copy(ilUtil::getImagePath("nav_arr_L.png", false, "filesystem"),
631 $image_dir."/nav_arr_L.png");
632 copy(ilUtil::getImagePath("nav_arr_R.png", false, "filesystem"),
633 $image_dir."/nav_arr_R.png");
634
635 // template workaround: reset of template
636 $tpl = new ilTemplate("tpl.main.html", true, true);
637 $tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
638 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
639
640 // zip everything
641 if (true)
642 {
643 // zip it all
644 $date = time();
645 $zip_file = $this->getExportDirectory("html")."/".$date."__".IL_INST_ID."__".
646 $this->getType()."_".$this->getId().".zip";
647//echo "zip-".$a_target_dir."-to-".$zip_file;
648 ilUtil::zip($a_target_dir, $zip_file);
649 ilUtil::delDir($a_target_dir);
650 }
651 }
652
653
657 function exportHTMLGlossaryTerms(&$a_glo_gui, $a_target_dir)
658 {
659 global $ilUser;
660
661 include_once("./Services/COPage/classes/class.ilCOPageHTMLExport.php");
662 $copage_export = new ilCOPageHTMLExport($a_target_dir);
663 $copage_export->exportSupportScripts();
664
665 // index.html file
666 $a_glo_gui->tpl = new ilTemplate("tpl.main.html", true, true);
667 $style_name = $ilUser->prefs["style"].".css";;
668 $a_glo_gui->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
669 $a_glo_gui->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
670 $a_glo_gui->tpl->setTitle($this->getTitle());
671
672 $content = $a_glo_gui->listTerms();
673 $file = $a_target_dir."/index.html";
674
675 // open file
676 if (!($fp = @fopen($file,"w+")))
677 {
678 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
679 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
680 }
681 chmod($file, 0770);
682 fwrite($fp, $content);
683 fclose($fp);
684
685 $terms = $this->getTermList();
686
687 $this->offline_mobs = array();
688 $this->offline_files = array();
689
690 foreach($terms as $term)
691 {
692 $a_glo_gui->tpl = new ilTemplate("tpl.main.html", true, true);
693 $a_glo_gui->tpl = $copage_export->getPreparedMainTemplate();
694 //$tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
695
696 // set style
697 $style_name = $ilUser->prefs["style"].".css";;
698 $a_glo_gui->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
699
700 $_GET["term_id"] = $term["id"];
701 $_GET["frame"] = "_blank";
702 $content =& $a_glo_gui->listDefinitions($_GET["ref_id"],$term["id"],false);
703 $file = $a_target_dir."/term_".$term["id"].".html";
704
705 // open file
706 if (!($fp = @fopen($file,"w+")))
707 {
708 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
709 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
710 }
711 chmod($file, 0770);
712 fwrite($fp, $content);
713 fclose($fp);
714
715 // store linked/embedded media objects of glosssary term
716 include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
717 $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
718 foreach($defs as $def)
719 {
720 $def_mobs = ilObjMediaObject::_getMobsOfObject("gdf:pg", $def["id"]);
721 foreach($def_mobs as $def_mob)
722 {
723 $this->offline_mobs[$def_mob] = $def_mob;
724 }
725
726 // get all files of page
727 include_once("./Modules/File/classes/class.ilObjFile.php");
728 $def_files = ilObjFile::_getFilesOfObject("gdf:pg", $def["id"]);
729 $this->offline_files = array_merge($this->offline_files, $def_files);
730
731 }
732 }
733 }
734
738 function exportHTMLMOB($a_target_dir, &$a_glo_gui, $a_mob_id)
739 {
740 global $tpl;
741
742 $mob_dir = $a_target_dir."/mobs";
743
744 $source_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob_id;
745 if (@is_dir($source_dir))
746 {
747 ilUtil::makeDir($mob_dir."/mm_".$a_mob_id);
748 ilUtil::rCopy($source_dir, $mob_dir."/mm_".$a_mob_id);
749 }
750
751 $tpl = new ilTemplate("tpl.main.html", true, true);
752 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
753 $_GET["obj_type"] = "MediaObject";
754 $_GET["mob_id"] = $a_mob_id;
755 $_GET["cmd"] = "";
756 $content =& $a_glo_gui->media();
757 $file = $a_target_dir."/media_".$a_mob_id.".html";
758
759 // open file
760 if (!($fp = @fopen($file,"w+")))
761 {
762 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
763 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
764 }
765 chmod($file, 0770);
766 fwrite($fp, $content);
767 fclose($fp);
768
769 // fullscreen
770 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
771 $mob_obj = new ilObjMediaObject($a_mob_id);
772 if ($mob_obj->hasFullscreenItem())
773 {
774 $tpl = new ilTemplate("tpl.main.html", true, true);
775 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
776 $_GET["mob_id"] = $a_mob_id;
777 $_GET["cmd"] = "fullscreen";
778 $content = $a_glo_gui->fullscreen();
779 $file = $a_target_dir."/fullscreen_".$a_mob_id.".html";
780
781 // open file
782 if (!($fp = @fopen($file,"w+")))
783 {
784 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
785 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
786 }
787 chmod($file, 0770);
788 fwrite($fp, $content);
789 fclose($fp);
790 }
791 }
792
796 function exportHTMLFile($a_target_dir, $a_file_id)
797 {
798 $file_dir = $a_target_dir."/files/file_".$a_file_id;
799 ilUtil::makeDir($file_dir);
800 include_once("./Modules/File/classes/class.ilObjFile.php");
801 $file_obj = new ilObjFile($a_file_id, false);
802 $source_file = $file_obj->getDirectory($file_obj->getVersion())."/".$file_obj->getFileName();
803 if (!is_file($source_file))
804 {
805 $source_file = $file_obj->getDirectory()."/".$file_obj->getFileName();
806 }
807 copy($source_file, $file_dir."/".$file_obj->getFileName());
808 }
809
810
817 function exportXML(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
818 {
819 global $ilBench;
820
821 // export glossary
822 $attrs = array();
823 $attrs["Type"] = "Glossary";
824 $a_xml_writer->xmlStartTag("ContentObject", $attrs);
825
826 // MetaData
827 $this->exportXMLMetaData($a_xml_writer);
828
829 // collect media objects
830 $terms = $this->getTermList();
831 $this->mob_ids = array();
832 $this->file_ids = array();
833 foreach ($terms as $term)
834 {
835 include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
836
838
839 foreach($defs as $def)
840 {
841 $this->page_object = new ilGlossaryDefPage($def["id"]);
842 $this->page_object->buildDom();
843 $this->page_object->insertInstIntoIDs(IL_INST_ID);
844 $mob_ids = $this->page_object->collectMediaObjects(false);
845 include_once("./Services/COPage/classes/class.ilPCFileList.php");
846 $file_ids = ilPCFileList::collectFileItems($this->page_object, $this->page_object->getDomDoc());
847 foreach($mob_ids as $mob_id)
848 {
849 $this->mob_ids[$mob_id] = $mob_id;
850 }
851 foreach($file_ids as $file_id)
852 {
853 $this->file_ids[$file_id] = $file_id;
854 }
855 }
856 }
857
858 // export media objects
859 $expLog->write(date("[y-m-d H:i:s] ")."Start Export Media Objects");
860 $ilBench->start("GlossaryExport", "exportMediaObjects");
861 $this->exportXMLMediaObjects($a_xml_writer, $a_inst, $a_target_dir, $expLog);
862 $ilBench->stop("GlossaryExport", "exportMediaObjects");
863 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Media Objects");
864
865 // FileItems
866 $expLog->write(date("[y-m-d H:i:s] ")."Start Export File Items");
867 $ilBench->start("ContentObjectExport", "exportFileItems");
868 $this->exportFileItems($a_target_dir, $expLog);
869 $ilBench->stop("ContentObjectExport", "exportFileItems");
870 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export File Items");
871
872 // Glossary
873 $expLog->write(date("[y-m-d H:i:s] ")."Start Export Glossary Items");
874 $ilBench->start("GlossaryExport", "exportGlossaryItems");
875 $this->exportXMLGlossaryItems($a_xml_writer, $a_inst, $expLog);
876 $ilBench->stop("GlossaryExport", "exportGlossaryItems");
877 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Glossary Items");
878
879 $a_xml_writer->xmlEndTag("ContentObject");
880 }
881
888 function exportXMLGlossaryItems(&$a_xml_writer, $a_inst, &$expLog)
889 {
890 global $ilBench;
891
892 $attrs = array();
893 $a_xml_writer->xmlStartTag("Glossary", $attrs);
894
895 // MetaData
896 $this->exportXMLMetaData($a_xml_writer);
897
898 $terms = $this->getTermList();
899
900 // export glossary terms
901 reset($terms);
902 foreach ($terms as $term)
903 {
904 $ilBench->start("GlossaryExport", "exportGlossaryItem");
905 $expLog->write(date("[y-m-d H:i:s] ")."Page Object ".$page["obj_id"]);
906
907 // export xml to writer object
908 $ilBench->start("GlossaryExport", "exportGlossaryItem_getGlossaryTerm");
909 $glo_term = new ilGlossaryTerm($term["id"]);
910 $ilBench->stop("GlossaryExport", "exportGlossaryItem_getGlossaryTerm");
911 $ilBench->start("GlossaryExport", "exportGlossaryItem_XML");
912 $glo_term->exportXML($a_xml_writer, $a_inst);
913 $ilBench->stop("GlossaryExport", "exportGlossaryItem_XML");
914
915 unset($glo_term);
916
917 $ilBench->stop("GlossaryExport", "exportGlossaryItem");
918 }
919
920 $a_xml_writer->xmlEndTag("Glossary");
921 }
922
929 function exportXMLMetaData(&$a_xml_writer)
930 {
931 include_once("Services/MetaData/classes/class.ilMD2XML.php");
932 $md2xml = new ilMD2XML($this->getId(), 0, $this->getType());
933 $md2xml->setExportMode(true);
934 $md2xml->startExport();
935 $a_xml_writer->appendXML($md2xml->getXML());
936 }
937
944 function exportXMLMediaObjects(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
945 {
946 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
947
948 foreach ($this->mob_ids as $mob_id)
949 {
950 $expLog->write(date("[y-m-d H:i:s] ")."Media Object ".$mob_id);
951 $media_obj = new ilObjMediaObject($mob_id);
952 $media_obj->exportXML($a_xml_writer, $a_inst);
953 $media_obj->exportFiles($a_target_dir);
954 unset($media_obj);
955 }
956 }
957
962 function exportFileItems($a_target_dir, &$expLog)
963 {
964 include_once("./Modules/File/classes/class.ilObjFile.php");
965
966 foreach ($this->file_ids as $file_id)
967 {
968 $expLog->write(date("[y-m-d H:i:s] ")."File Item ".$file_id);
969 $file_obj = new ilObjFile($file_id, false);
970 $file_obj->export($a_target_dir);
971 unset($file_obj);
972 }
973 }
974
975
976
980 function modifyExportIdentifier($a_tag, $a_param, $a_value)
981 {
982 if ($a_tag == "Identifier" && $a_param == "Entry")
983 {
984 $a_value = "il_".IL_INST_ID."_glo_".$this->getId();
985 }
986
987 return $a_value;
988 }
989
990
991
992
1003 function delete()
1004 {
1005 global $ilDB;
1006
1007 // always call parent delete function first!!
1008 if (!parent::delete())
1009 {
1010 return false;
1011 }
1012
1013 // delete terms
1014 if (!$this->isVirtual())
1015 {
1016 $terms = $this->getTermList();
1017 foreach ($terms as $term)
1018 {
1019 $term_obj =& new ilGlossaryTerm($term["id"]);
1020 $term_obj->delete();
1021 }
1022 }
1023
1024 // delete glossary data entry
1025 $q = "DELETE FROM glossary WHERE id = ".$ilDB->quote($this->getId());
1026 $ilDB->query($q);
1027
1028 // delete meta data
1029 $this->deleteMetaData();
1030/*
1031 $nested = new ilNestedSetXML();
1032 $nested->init($this->getId(), $this->getType());
1033 $nested->deleteAllDBData();
1034*/
1035
1036 return true;
1037 }
1038
1049 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
1050 {
1051 global $tree;
1052
1053 switch ($a_event)
1054 {
1055 case "link":
1056
1057 //var_dump("<pre>",$a_params,"</pre>");
1058 //echo "Glossary ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
1059 //exit;
1060 break;
1061
1062 case "cut":
1063
1064 //echo "Glossary ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
1065 //exit;
1066 break;
1067
1068 case "copy":
1069
1070 //var_dump("<pre>",$a_params,"</pre>");
1071 //echo "Glossary ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
1072 //exit;
1073 break;
1074
1075 case "paste":
1076
1077 //echo "Glossary ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
1078 //exit;
1079 break;
1080
1081 case "new":
1082
1083 //echo "Glossary ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
1084 //exit;
1085 break;
1086 }
1087
1088 // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
1089 if ($a_node_id==$_GET["ref_id"])
1090 {
1091 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
1092 $parent_type = $parent_obj->getType();
1093 if($parent_type == $this->getType())
1094 {
1095 $a_node_id = (int) $tree->getParentId($a_node_id);
1096 }
1097 }
1098
1099 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
1100 }
1101
1102
1106 function getXMLZip()
1107 {
1108 include_once("./Modules/Glossary/classes/class.ilGlossaryExport.php");
1109 $glo_exp = new ilGlossaryExport($this);
1110 return $glo_exp->buildExportFile();
1111 }
1112
1117 static function getDeletionDependencies($a_obj_id)
1118 {
1119 global $lng;
1120
1121 $dep = array();
1122 include_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
1124 foreach ($sms as $sm)
1125 {
1126 $lng->loadLanguageModule("content");
1127 $dep[$sm] = $lng->txt("glo_used_in_scorm");
1128 }
1129//echo "-".$a_obj_id."-";
1130//var_dump($dep);
1131 return $dep;
1132 }
1133
1139 function getTaxonomyId()
1140 {
1141 include_once("./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
1142 $tax_ids = ilObjTaxonomy::getUsageOfObject($this->getId());
1143 if (count($tax_ids) > 0)
1144 {
1145 // glossaries handle max. one taxonomy
1146 return $tax_ids[0];
1147 }
1148 return 0;
1149 }
1150
1151
1158 public function cloneObject($a_target_id,$a_copy_id = 0)
1159 {
1160 global $ilDB, $ilUser, $ilias;
1161
1162 $new_obj = parent::cloneObject($a_target_id,$a_copy_id);
1163 $this->cloneMetaData($new_obj);
1164
1165 //copy online status if object is not the root copy object
1166 $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
1167
1168 if(!$cp_options->isRootNode($this->getRefId()))
1169 {
1170 $new_obj->setOnline($this->getOnline());
1171 }
1172
1173// $new_obj->setTitle($this->getTitle());
1174 $new_obj->setDescription($this->getDescription());
1175 $new_obj->setVirtualMode($this->getVirtualMode());
1176 $new_obj->setPresentationMode($this->getPresentationMode());
1177 $new_obj->setSnippetLength($this->getSnippetLength());
1178 $new_obj->update();
1179
1180 // set/copy stylesheet
1181 include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1182 $style_id = $this->getStyleSheetId();
1183 if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id))
1184 {
1185 $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id);
1186 $new_id = $style_obj->ilClone();
1187 $new_obj->setStyleSheetId($new_id);
1188 $new_obj->update();
1189 }
1190
1191 // copy taxonomy
1192 if (($tax_id = $this->getTaxonomyId()) > 0)
1193 {
1194 // clone it
1195 include_once("./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
1196 $tax = new ilObjTaxonomy($tax_id);
1197 $new_tax = $tax->cloneObject(0,0,true);
1198 $map = $tax->getNodeMapping();
1199
1200 // assign new taxonomy to new glossary
1201 ilObjTaxonomy::saveUsage($new_tax->getId(), $new_obj->getId());
1202 }
1203
1204 // assign new tax/new glossary
1205 // handle mapping
1206
1207 // prepare tax node assignments objects
1208 include_once("./Services/Taxonomy/classes/class.ilTaxNodeAssignment.php");
1209 if ($tax_id > 0)
1210 {
1211 $tax_ass = new ilTaxNodeAssignment("glo", $this->getId(), "term", $tax_id);
1212 $new_tax_ass = new ilTaxNodeAssignment("glo", $new_obj->getId(), "term", $new_tax->getId());
1213 }
1214
1215 // copy terms
1216 $term_mappings = array();
1217 foreach (ilGlossaryTerm::getTermList($this->getId()) as $term)
1218 {
1219 $new_term_id = ilGlossaryTerm::_copyTerm($term["id"], $new_obj->getId());
1220 $term_mappings[$term["id"]] = $new_term_id;
1221
1222 // copy tax node assignments
1223 if ($tax_id > 0)
1224 {
1225 $assignmts = $tax_ass->getAssignmentsOfItem($term["id"]);
1226 foreach ($assignmts as $a)
1227 {
1228 if ($map[$a["node_id"]] > 0)
1229 {
1230 $new_tax_ass->addAssignment($map[$a["node_id"]] ,$new_term_id);
1231 }
1232 }
1233 }
1234 }
1235
1236 // add mapping of term_ids to copy wizard options
1237 if (!empty($term_mappings))
1238 {
1239 $cp_options->appendMapping($this->getRefId().'_glo_terms', (array) $term_mappings);
1240 }
1241
1242
1243 return $new_obj;
1244 }
1245
1252 function removeOfflineGlossaries($a_glo_ids)
1253 {
1254 global $ilDB;
1255
1256 $set = $ilDB->query("SELECT id FROM glossary ".
1257 " WHERE ".$ilDB->in("id", $a_glo_ids, false, "integer").
1258 " AND is_online = ".$ilDB->quote("y", "text")
1259 );
1260 $glo_ids = array();
1261 while ($rec = $ilDB->fetchAssoc($set))
1262 {
1263 $glo_ids[] = $rec["id"];
1264 }
1265 return $glo_ids;
1266 }
1267
1268 public static function getAdvMDSubItemTitle($a_obj_id, $a_sub_type, $a_sub_id)
1269 {
1270 global $lng;
1271
1272 if($a_sub_type == "term")
1273 {
1274 $lng->loadLanguageModule("glo");
1275
1276 include_once "Modules/Glossary/classes/class.ilGlossaryTerm.php";
1277 return $lng->txt("glo_term").' "'. ilGlossaryTerm::_lookGlossaryTerm($a_sub_id).'"';
1278 }
1279 }
1280}
1281
1282?>
print $file
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
HTML export class for pages.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
_createExportDirectory($a_obj_id, $a_export_type="xml", $a_obj_type="")
Create export directory.
_getExportFiles($a_obj_id, $a_export_types="", $a_obj_type="")
Get Export Files for a repository object.
Glossary definition page object.
Export class for content objects.
Class ilGlossaryPresentationGUI.
Class ilGlossaryTerm.
_copyTerm($a_term_id, $a_glossary_id)
Copy a term to a glossary.
static _lookGlossaryTerm($term_id)
get glossary term
static getTermList($a_glo_id, $searchterm="", $a_first_letter="", $a_def="", $a_tax_node=0, $a_add_amet_fields=false, array $a_amet_filter=null)
Get all terms for given set of glossary ids.
static getFirstLetters($a_glo_id, $a_tax_node=0)
Get all terms for given set of glossary ids.
Class ilObjFile.
static _getFilesOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
get all files of an object
Class ilObjGlossary.
getImportDirectory()
get import directory of glossary
setVirtualMode($a_mode)
set glossary type (virtual: fixed/level/subtree, normal:none)
exportHTML($a_target_dir, $log)
export html package
setPublicExportFile($a_type, $a_file)
specify public export file for type
setTitle($a_title)
set title of glossary object
getPublicExportFile($a_type)
get public export file
getExportFiles()
Get export files.
setStyleSheetId($a_style_id)
Set ID of assigned style sheet object.
notify($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
notifys an object about an event occured Based on the event happend, each object may decide how it re...
removeOfflineGlossaries($a_glo_ids)
Remove offline glossaries from obj id array.
getSnippetLength()
Get snippet length.
exportFileItems($a_target_dir, &$expLog)
export files of file itmes
_lookupOnline($a_id)
check wether content object is online
exportHTMLMOB($a_target_dir, &$a_glo_gui, $a_mob_id)
export media object to html
exportXML(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
export object to xml (see ilias_co.dtd)
create($a_upload=false)
create glossary object
getShowTaxonomy()
Get show taxonomy.
createExportDirectory($a_type="xml")
Creates export directory.
exportXMLGlossaryItems(&$a_xml_writer, $a_inst, &$expLog)
export page objects to xml (see ilias_co.dtd)
getXMLZip()
Get zipped xml file for glossary.
getTaxonomyId()
Get taxonomy.
update()
Update object.
cloneObject($a_target_id, $a_copy_id=0)
Clone glossary.
read()
read data of content object
setSnippetLength($a_val)
Set snippet length.
getPresentationMode()
Get presentation mode.
getStyleSheetId()
Get ID of assigned style sheet object.
isVirtual()
returns true if glossary type is virtual (any mode)
static getDeletionDependencies($a_obj_id)
Get deletion dependencies.
static getAdvMDSubItemTitle($a_obj_id, $a_sub_type, $a_sub_id)
static lookupSnippetLength($a_id)
Lookup snippet length.
setShowTaxonomy($a_val)
Set show taxonomy.
ilObjGlossary($a_id=0, $a_call_by_reference=true)
Constructor @access public.
exportHTMLGlossaryTerms(&$a_glo_gui, $a_target_dir)
export glossary terms
createImportDirectory()
creates data directory for import files (data_dir/glo_data/glo_<id>/import, depending on data directo...
exportHTMLFile($a_target_dir, $a_file_id)
export file object
getDescription()
get description of glossary object
exportXMLMediaObjects(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
export media objects to xml (see ilias_co.dtd)
getExportDirectory($a_type="xml")
Get export directory of glossary.
modifyExportIdentifier($a_tag, $a_param, $a_value)
static lookup($a_id, $a_property)
Lookup glossary property.
getAllGlossaryIds($a_include_offline_childs=false)
Get all glossary ids.
exportXMLMetaData(&$a_xml_writer)
export content objects meta data to xml (see ilias_co.dtd)
getFirstLetters($a_tax_node=0)
Get term list.
getVirtualMode()
get glossary type (normal or virtual)
getTermList($searchterm="", $a_letter="", $a_def="", $a_tax_node=0, $a_include_offline_childs=false, $a_add_amet_fields=false, array $a_amet_filter=null, $a_omit_virtual=false)
Get term list.
getTitle()
get title of glossary object
setPresentationMode($a_val)
Set presentation mode.
setActiveGlossaryMenu($a_act_glo_menu)
setDescription($a_description)
set description of glossary object
Class ilObjMediaObject.
_getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static getScormModulesForGlossary($a_glo_id)
Get SCORM modules that assign a certain glossary.
Class ilObjStyleSheet.
static lookupObjectStyle($a_obj_id)
Lookup object style.
static writeStyleUsage($a_obj_id, $a_style_id)
Write style usage.
getSyntaxStylePath()
get syntax style path
_lookupStandard($a_id)
Lookup standard flag.
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
static saveUsage($a_tax_id, $a_obj_id)
Save Usage.
Class ilObject Basic functions for all objects.
getType()
get object type @access public
ilObject($a_id=0, $a_reference=true)
Constructor @access public.
deleteMetaData()
delete meta data entry
updateMetaData()
update meta data entry
createMetaData()
create meta data entry
getRefId()
get reference id @access public
cloneMetaData($target_obj)
Copy meta data.
getId()
get object id @access public
static collectFileItems($a_page, $a_domdoc)
Get all file items that are used within the page.
Taxonomy node <-> item assignment.
special template class to simplify handling of ITX/PEAR
static getDataDir()
get data directory (outside webspace)
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static tf2yn($a_tf)
convert true/false to "y"/"n"
static getWebspaceDir($mode="filesystem")
get webspace directory
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static zip($a_dir, $a_file, $compress_content=false)
static yn2tf($a_yn)
convert "y"/"n" to true/false
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
$style
Definition: example_012.php:70
global $ilBench
Definition: ilias.php:18
Interface for repository objects to use adv md with subitems.
redirection script todo: (a better solution should control the processing via a xml file)
global $ilDB
$lm_set
global $ilUser
Definition: imgupload.php:15