24 require_once(
"classes/class.ilObject.php");
25 require_once(
"./Modules/Glossary/classes/class.ilGlossaryTerm.php");
48 $this->
ilObject($a_id,$a_call_by_reference);
67 $q =
"INSERT INTO glossary (id, online, virtual) VALUES ".
68 " (".$ilDB->quote($this->
getId()).
",".$ilDB->quote(
"n").
",".$ilDB->quote($this->
getVirtualMode()).
")";
81 # echo "Glossary<br>\n";
83 $q =
"SELECT * FROM glossary WHERE id = ".$ilDB->quote($this->
getId());
84 $gl_set = $this->ilias->db->query($q);
123 $this->virtual_mode = $a_mode;
124 $this->
virtual =
true;
128 $this->virtual_mode =
"none";
129 $this->
virtual =
false;
139 return $this->virtual_mode;
147 return $this->virtual;
171 $this->online = $a_online;
176 return $this->online;
186 $q =
"SELECT * FROM glossary WHERE id = ".$ilDB->quote($a_id);
187 $lm_set = $ilDB->query($q);
195 $this->glo_menu_active = $a_act_glo_menu;
200 return $this->glo_menu_active;
205 $this->downloads_active = $a_down;
210 return $this->downloads_active;
247 $q =
"UPDATE glossary SET ".
254 " WHERE id = ".$ilDB->quote($this->
getId());
276 $glo_arr = $tree->getChildsByType($tree->getParentId($this->getRefId()),
"glo");
278 foreach ($glo_arr as $glo)
281 $glo_ids[] = $glo[
'obj_id'];
287 $subtree_nodes = $tree->getSubTree($tree->getNodeData($tree->getParentId($this->getRefId())));
289 foreach ($subtree_nodes as $node)
291 if ($node[
'type'] ==
'glo')
293 $glo_ids[] = $node[
'obj_id'];
305 $glo_ids[] = $this->
getId();
311 $glo_ids = $this->
getId();
327 if(!is_writable($glo_data_dir))
329 $this->ilias->raiseError(
"Glossary Data Directory (".$glo_data_dir
330 .
") not writeable.",$this->ilias->error_obj->FATAL);
334 $glo_dir = $glo_data_dir.
"/glo_".$this->
getId();
336 if(!@is_dir($glo_dir))
338 $this->ilias->raiseError(
"Creation of Glossary Directory failed.",$this->ilias->error_obj->FATAL);
341 $import_dir = $glo_dir.
"/import";
343 if(!@is_dir($import_dir))
345 $this->ilias->raiseError(
"Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
368 if(!is_writable($glo_data_dir))
370 $this->ilias->raiseError(
"Glossary Data Directory (".$glo_data_dir
371 .
") not writeable.",$this->ilias->error_obj->FATAL);
374 $glo_dir = $glo_data_dir.
"/glo_".$this->
getId();
376 if(!@is_dir($glo_dir))
378 $this->ilias->raiseError(
"Creation of Glossary Directory failed.",$this->ilias->error_obj->FATAL);
386 $export_dir = $glo_dir.
"/export_html";
390 $export_dir = $glo_dir.
"/export";
395 if(!@is_dir($export_dir))
397 $this->ilias->raiseError(
"Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
428 $types = array(
"xml",
"html");
430 foreach($types as
$type)
435 if (!@is_dir(
$dir) or
445 while ($entry = $h_dir->read())
447 if ($entry !=
"." and
449 substr($entry, -4) ==
".zip" and
450 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(glo_)*[0-9]+\.zip\$", $entry))
452 $file[$entry.$type] = array(
"type" => $type,
"file" => $entry,
453 "size" => filesize(
$dir.
"/".$entry));
475 $this->public_export_file[$a_type] = $a_file;
487 return $this->public_export_file[$a_type];
500 $mob_dir = $a_target_dir.
"/mobs";
502 $file_dir = $a_target_dir.
"/files";
504 $tex_dir = $a_target_dir.
"/teximg";
509 $style_name = $ilias->account->prefs[
"style"].
".css";
510 copy($location_stylesheet, $a_target_dir.
"/".$style_name);
513 $cont_stylesheet =
"Services/COPage/css/content.css";
514 copy($cont_stylesheet, $a_target_dir.
"/content.css");
518 copy($syn_stylesheet, $a_target_dir.
"/syntaxhighlight.css");
521 include_once(
"./Modules/Glossary/classes/class.ilGlossaryPresentationGUI.php");
522 $_GET[
"cmd"] =
"nop";
524 $glo_gui->setOfflineMode(
true);
525 $glo_gui->setOfflineDirectory($a_target_dir);
535 foreach ($this->offline_mobs as $mob)
537 $this->
exportHTMLMOB($a_target_dir, $glo_gui, $mob,
"_blank");
539 $_GET[
"obj_type"] =
"MediaObject";
540 $_GET[
"obj_id"] = $a_mob_id;
544 foreach ($this->offline_files as
$file)
550 $image_dir = $a_target_dir.
"/images";
554 $image_dir.
"/enlarge.gif");
556 $image_dir.
"/browser/plus.gif");
558 $image_dir.
"/browser/minus.gif");
560 $image_dir.
"/browser/blank.gif");
562 $image_dir.
"/icon_st.gif");
564 $image_dir.
"/icon_pg.gif");
566 $image_dir.
"/nav_arr_L.gif");
568 $image_dir.
"/nav_arr_R.gif");
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");
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());
603 $content = $a_glo_gui->listTerms();
604 $file = $a_target_dir.
"/index.html";
607 if (!($fp = @fopen(
$file,
"w+")))
609 die (
"<b>Error</b>: Could not open \"".
$file.
"\" for writing".
610 " in <b>".__FILE__.
"</b> on line <b>".__LINE__.
"</b><br />");
613 fwrite($fp, $content);
618 $this->offline_mobs = array();
619 $this->offline_files = array();
621 foreach($terms as $term)
623 $a_glo_gui->tpl =
new ilTemplate(
"tpl.main.html",
true,
true);
627 $style_name = $ilUser->prefs[
"style"].
".css";;
628 $a_glo_gui->tpl->setVariable(
"LOCATION_STYLESHEET",
"./".$style_name);
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";
636 if (!($fp = @fopen(
$file,
"w+")))
638 die (
"<b>Error</b>: Could not open \"".
$file.
"\" for writing".
639 " in <b>".__FILE__.
"</b> on line <b>".__LINE__.
"</b><br />");
642 fwrite($fp, $content);
646 include_once(
"./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
648 foreach($defs as $def)
651 foreach($def_mobs as $def_mob)
653 $this->offline_mobs[$def_mob] = $def_mob;
657 include_once(
"./Modules/File/classes/class.ilObjFile.php");
659 $this->offline_files = array_merge($this->offline_files, $def_files);
672 $mob_dir = $a_target_dir.
"/mobs";
675 if (@is_dir($source_dir))
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;
686 $content =& $a_glo_gui->media();
687 $file = $a_target_dir.
"/media_".$a_mob_id.
".html";
690 if (!($fp = @fopen(
$file,
"w+")))
692 die (
"<b>Error</b>: Could not open \"".
$file.
"\" for writing".
693 " in <b>".__FILE__.
"</b> on line <b>".__LINE__.
"</b><br />");
696 fwrite($fp, $content);
700 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
702 if ($mob_obj->hasFullscreenItem())
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";
712 if (!($fp = @fopen(
$file,
"w+")))
714 die (
"<b>Error</b>: Could not open \"".
$file.
"\" for writing".
715 " in <b>".__FILE__.
"</b> on line <b>".__LINE__.
"</b><br />");
718 fwrite($fp, $content);
728 $file_dir = $a_target_dir.
"/files/file_".$a_file_id;
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))
735 $source_file = $file_obj->getDirectory().
"/".$file_obj->getFileName();
737 copy($source_file, $file_dir.
"/".$file_obj->getFileName());
747 function exportXML(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
753 $attrs[
"Type"] =
"Glossary";
754 $a_xml_writer->xmlStartTag(
"ContentObject", $attrs);
761 $this->mob_ids = array();
762 $this->file_ids = array();
763 foreach ($terms as $term)
765 include_once
"./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
769 foreach($defs as $def)
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)
779 $this->mob_ids[$mob_id] = $mob_id;
781 foreach($file_ids as $file_id)
783 $this->file_ids[$file_id] = $file_id;
789 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Media Objects");
790 $ilBench->start(
"GlossaryExport",
"exportMediaObjects");
792 $ilBench->stop(
"GlossaryExport",
"exportMediaObjects");
793 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export Media Objects");
796 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export File Items");
797 $ilBench->start(
"ContentObjectExport",
"exportFileItems");
799 $ilBench->stop(
"ContentObjectExport",
"exportFileItems");
800 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export File Items");
803 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Glossary Items");
804 $ilBench->start(
"GlossaryExport",
"exportGlossaryItems");
806 $ilBench->stop(
"GlossaryExport",
"exportGlossaryItems");
807 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export Glossary Items");
809 $a_xml_writer->xmlEndTag(
"ContentObject");
823 $a_xml_writer->xmlStartTag(
"Glossary", $attrs);
832 foreach ($terms as $term)
834 $ilBench->start(
"GlossaryExport",
"exportGlossaryItem");
835 $expLog->write(date(
"[y-m-d H:i:s] ").
"Page Object ".$page[
"obj_id"]);
838 $ilBench->start(
"GlossaryExport",
"exportGlossaryItem_getGlossaryTerm");
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");
858 $ilBench->stop(
"GlossaryExport",
"exportGlossaryItem");
861 $a_xml_writer->xmlEndTag(
"Glossary");
872 include_once(
"Services/MetaData/classes/class.ilMD2XML.php");
874 $md2xml->setExportMode(
true);
875 $md2xml->startExport();
876 $a_xml_writer->appendXML($md2xml->getXML());
887 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
889 foreach ($this->mob_ids as $mob_id)
891 $expLog->write(date(
"[y-m-d H:i:s] ").
"Media Object ".$mob_id);
893 $media_obj->exportXML($a_xml_writer, $a_inst);
894 $media_obj->exportFiles($a_target_dir);
905 include_once(
"./Modules/File/classes/class.ilObjFile.php");
907 foreach ($this->file_ids as $file_id)
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);
923 if ($a_tag ==
"Identifier" && $a_param ==
"Entry")
925 $a_value =
"il_".IL_INST_ID.
"_glo_".$this->
getId();
949 if (!parent::delete())
958 foreach ($terms as $term)
966 $q =
"DELETE FROM glossary WHERE id = ".$ilDB->quote($this->
getId());
990 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
1030 if ($a_node_id==
$_GET[
"ref_id"])
1032 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
1033 $parent_type = $parent_obj->getType();
1034 if($parent_type == $this->
getType())
1036 $a_node_id = (int) $tree->getParentId($a_node_id);
1040 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
1046 include_once(
"./Modules/Glossary/classes/class.ilGlossaryExport.php");
1050 return $glo_exp->buildExportFile();