ILIAS  release_8 Revision v8.24
class.ilObjGlossary.php
Go to the documentation of this file.
1<?php
2
23{
24 protected \ILIAS\Style\Content\DomainService $content_style_domain;
26 protected array $file_ids = [];
27 protected array $mob_ids = [];
28 protected bool $show_tax = false;
29 protected int $style_id = 0;
30 protected bool $downloads_active = false;
31 protected bool $glo_menu_active = false;
32 protected bool $online = false;
33 protected int $snippet_length = 0;
34 protected string $pres_mode = "";
35 protected bool $virtual = false;
36 protected string $virtual_mode = "";
38 public array $auto_glossaries = array();
39 protected ilObjUser $user;
40 protected array $public_export_file = [];
41
42
43 public function __construct(
44 int $a_id = 0,
45 bool $a_call_by_reference = true
46 ) {
47 global $DIC;
48 $this->tpl = $DIC["tpl"];
49
50 $this->db = $DIC->database();
51 $this->user = $DIC->user();
52 $this->type = "glo";
53 parent::__construct($a_id, $a_call_by_reference);
54 $this->content_style_domain = $DIC
55 ->contentStyle()
56 ->domain();
57 }
58
59 public function create(bool $a_upload = false): int
60 {
61 $id = parent::create();
62
63 // meta data will be created by
64 // import parser
65 if (!$a_upload) {
66 $this->createMetaData();
67 }
68 $this->db->insert(
69 'glossary',
70 array(
71 'id' => array('integer', $this->getId()),
72 'is_online' => array('text', 'n'),
73 'virtual' => array('text', $this->getVirtualMode()),
74 'pres_mode' => array('text', 'table'),
75 'snippet_length' => array('integer', 200)
76 )
77 );
78
79 $this->setPresentationMode("table");
80 $this->setSnippetLength(200);
81
82 $this->updateAutoGlossaries();
83
84 return $id;
85 }
86
87 public function read(): void
88 {
89 parent::read();
90 # echo "Glossary<br>\n";
91
92 $q = "SELECT * FROM glossary WHERE id = " .
93 $this->db->quote($this->getId(), "integer");
94 $gl_set = $this->db->query($q);
95 $gl_rec = $this->db->fetchAssoc($gl_set);
96 $this->setOnline(ilUtil::yn2tf($gl_rec["is_online"]));
97 $this->setVirtualMode((string) ($gl_rec["virtual"] ?? ""));
98 if (isset($gl_rec["public_xml_file"]) && $gl_rec["public_xml_file"] != "") {
99 $this->setPublicExportFile("xml", $gl_rec["public_xml_file"]);
100 }
101 if (isset($gl_rec["public_html_file"]) && $gl_rec["public_html_file"] != "") {
102 $this->setPublicExportFile("html", $gl_rec["public_html_file"]);
103 }
104 $this->setActiveGlossaryMenu(ilUtil::yn2tf($gl_rec["glo_menu_active"]));
105 $this->setActiveDownloads(ilUtil::yn2tf($gl_rec["downloads_active"]));
106 $this->setPresentationMode((string) $gl_rec["pres_mode"]);
107 $this->setSnippetLength((int) $gl_rec["snippet_length"]);
108 $this->setShowTaxonomy((bool) $gl_rec["show_tax"]);
109
110 // read auto glossaries
111 $set = $this->db->query(
112 "SELECT * FROM glo_glossaries " .
113 " WHERE id = " . $this->db->quote($this->getId(), "integer")
114 );
115 $glos = array();
116 while ($rec = $this->db->fetchAssoc($set)) {
117 $glos[] = $rec["glo_id"];
118 }
119 $this->setAutoGlossaries($glos);
120 }
121
122 public function setVirtualMode(string $a_mode): void
123 {
124 switch ($a_mode) {
125 case "level":
126 case "subtree":
127 // case "fixed":
128 $this->virtual_mode = $a_mode;
129 $this->virtual = true;
130 break;
131
132 default:
133 $this->virtual_mode = "none";
134 $this->virtual = false;
135 break;
136 }
137 }
138
139 public function getVirtualMode(): string
140 {
141 return $this->virtual_mode;
142 }
143
144 public function isVirtual(): bool
145 {
146 return $this->virtual;
147 }
148
149 public function setPresentationMode(string $a_val): void
150 {
151 $this->pres_mode = $a_val;
152 }
153
154 public function getPresentationMode(): string
155 {
156 return $this->pres_mode;
157 }
158
160 public function setSnippetLength(int $a_val): void
161 {
162 $this->snippet_length = $a_val;
163 }
164
165 public function getSnippetLength(): int
166 {
167 return ($this->snippet_length > 0)
168 ? $this->snippet_length
169 : 200;
170 }
171
172 public function setOnline(bool $a_online): void
173 {
174 $this->online = $a_online;
175 }
176
177 public function getOnline(): bool
178 {
179 return $this->online;
180 }
181
182 public static function _lookupOnline(
183 int $a_id
184 ): bool {
185 global $DIC;
186
187 $db = $DIC->database();
188
189 $q = "SELECT is_online FROM glossary WHERE id = " .
190 $db->quote($a_id, "integer");
191 $lm_set = $db->query($q);
192 $lm_rec = $db->fetchAssoc($lm_set);
193
194 return ilUtil::yn2tf($lm_rec["is_online"]);
195 }
196
200 protected static function lookup(
201 int $a_id,
202 string $a_property
203 ): string {
204 global $DIC;
205
206 $db = $DIC->database();
207
208 $set = $db->query("SELECT $a_property FROM glossary WHERE id = " .
209 $db->quote($a_id, "integer"));
210 $rec = $db->fetchAssoc($set);
211
212 return $rec[$a_property];
213 }
214
215 public static function lookupSnippetLength(int $a_id): int
216 {
217 return (int) self::lookup($a_id, "snippet_length");
218 }
219
220
221 public function setActiveGlossaryMenu(bool $a_act_glo_menu): void
222 {
223 $this->glo_menu_active = $a_act_glo_menu;
224 }
225
226 public function isActiveGlossaryMenu(): bool
227 {
228 return $this->glo_menu_active;
229 }
230
231 public function setActiveDownloads(bool $a_down): void
232 {
233 $this->downloads_active = $a_down;
234 }
235
236 public function isActiveDownloads(): bool
237 {
238 return $this->downloads_active;
239 }
240
241 public function setShowTaxonomy(bool $a_val): void
242 {
243 $this->show_tax = $a_val;
244 }
245
246 public function getShowTaxonomy(): bool
247 {
248 return $this->show_tax;
249 }
250
254 public function setAutoGlossaries(
255 array $a_val
256 ): void {
257 $this->auto_glossaries = array();
258 foreach ($a_val as $v) {
259 $this->addAutoGlossary($v);
260 }
261 }
262
263 public function addAutoGlossary(int $glo_id): void
264 {
265 if ($glo_id > 0 && ilObject::_lookupType($glo_id) == "glo" &&
266 !in_array($glo_id, $this->auto_glossaries)) {
267 $this->auto_glossaries[] = $glo_id;
268 }
269 }
270
274 public function getAutoGlossaries(): array
275 {
276 return $this->auto_glossaries;
277 }
278
279 public function removeAutoGlossary(
280 int $a_glo_id
281 ): void {
282 $glo_ids = array();
283 foreach ($this->getAutoGlossaries() as $g) {
284 if ($g != $a_glo_id) {
285 $glo_ids[] = $g;
286 }
287 }
288 $this->setAutoGlossaries($glo_ids);
289 }
290
291 public function update(): bool
292 {
293 $this->updateMetaData();
294
295 $this->db->update(
296 'glossary',
297 array(
298 'is_online' => array('text', ilUtil::tf2yn($this->getOnline())),
299 'virtual' => array('text', $this->getVirtualMode()),
300 'public_xml_file' => array('text', $this->getPublicExportFile("xml")),
301 'public_html_file' => array('text', $this->getPublicExportFile("html")),
302 'glo_menu_active' => array('text', ilUtil::tf2yn($this->isActiveGlossaryMenu())),
303 'downloads_active' => array('text', ilUtil::tf2yn($this->isActiveDownloads())),
304 'pres_mode' => array('text', $this->getPresentationMode()),
305 'show_tax' => array('integer', $this->getShowTaxonomy()),
306 'snippet_length' => array('integer', $this->getSnippetLength())
307 ),
308 array(
309 'id' => array('integer', $this->getId())
310 )
311 );
312
313 $this->updateAutoGlossaries();
314 return parent::update();
315 }
316
317 public function updateAutoGlossaries(): void
318 {
319 // update auto glossaries
320 $this->db->manipulate(
321 "DELETE FROM glo_glossaries WHERE " .
322 " id = " . $this->db->quote($this->getId(), "integer")
323 );
324 foreach ($this->getAutoGlossaries() as $glo_id) {
325 $this->db->insert(
326 'glo_glossaries',
327 array(
328 'id' => array('integer', $this->getId()),
329 'glo_id' => array('integer', $glo_id)
330 )
331 );
332 }
333 }
334
335 public static function lookupAutoGlossaries(
336 int $a_id
337 ): array {
338 global $DIC;
339
340 $db = $DIC->database();
341
342 // read auto glossaries
343 $set = $db->query(
344 "SELECT * FROM glo_glossaries " .
345 " WHERE id = " . $db->quote($a_id, "integer")
346 );
347 $glos = array();
348 while ($rec = $db->fetchAssoc($set)) {
349 $glos[] = (int) $rec["glo_id"];
350 }
351 return $glos;
352 }
353
354 public function getTermList(
355 string $searchterm = "",
356 string $a_letter = "",
357 string $a_def = "",
358 int $a_tax_node = 0,
359 bool $a_include_offline_childs = false,
360 bool $a_add_amet_fields = false,
361 array $a_amet_filter = null,
362 bool $a_omit_virtual = false,
363 bool $a_include_references = false
364 ): array {
365 if ($a_omit_virtual) {
366 $glo_ref_ids[] = $this->getRefId();
367 } else {
368 $glo_ref_ids = $this->getAllGlossaryIds($a_include_offline_childs, true);
369 }
371 $glo_ref_ids,
372 $searchterm,
373 $a_letter,
374 $a_def,
375 $a_tax_node,
376 $a_add_amet_fields,
377 $a_amet_filter,
378 $a_include_references
379 );
380 return $list;
381 }
382
383 public function getFirstLetters(
384 int $a_tax_node = 0
385 ): array {
386 $glo_ids = $this->getAllGlossaryIds();
387 $first_letters = ilGlossaryTerm::getFirstLetters($glo_ids, $a_tax_node);
388 return $first_letters;
389 }
390
395 public function getAllGlossaryIds(
396 bool $a_include_offline_childs = false,
397 bool $ids_are_ref_ids = false
398 ): array {
399 global $DIC;
400
401 $tree = $DIC->repositoryTree();
402
403 if ($this->isVirtual()) {
404 $glo_ids = array();
405
406 $virtual_mode = $this->getRefId() ? $this->getVirtualMode() : '';
407 switch ($virtual_mode) {
408 case "level":
409 $glo_arr = $tree->getChildsByType($tree->getParentId($this->getRefId()), "glo");
410 foreach ($glo_arr as $glo) {
411 {
412 if ($ids_are_ref_ids) {
413 $glo_ids[] = (int) $glo['child'];
414 } else {
415 $glo_ids[] = (int) $glo['obj_id'];
416 }
417 }
418 }
419 break;
420
421 case "subtree":
422 $subtree_nodes = $tree->getSubTree($tree->getNodeData($tree->getParentId($this->getRefId())));
423
424 foreach ($subtree_nodes as $node) {
425 if ($node['type'] == 'glo') {
426 if ($ids_are_ref_ids) {
427 $glo_ids[] = (int) $node['child'];
428 } else {
429 $glo_ids[] = (int) $node['obj_id'];
430 }
431 }
432 }
433 break;
434 }
435 if (!$a_include_offline_childs) {
436 $glo_ids = $this->removeOfflineGlossaries($glo_ids, $ids_are_ref_ids);
437 }
438 // always show entries of current glossary (if no permission is given, user will not come to the presentation screen)
439 // see bug #14477
440 if ($ids_are_ref_ids) {
441 if (!in_array($this->getRefId(), $glo_ids)) {
442 $glo_ids[] = $this->getRefId();
443 }
444 } elseif (!in_array($this->getId(), $glo_ids)) {
445 $glo_ids[] = $this->getId();
446 }
447 } elseif ($ids_are_ref_ids) {
448 $glo_ids = [$this->getRefId()];
449 } else {
450 $glo_ids = [$this->getId()];
451 }
452
453 return $glo_ids;
454 }
455
461 public function createImportDirectory(): void
462 {
463 $glo_data_dir = ilFileUtils::getDataDir() . "/glo_data";
464 ilFileUtils::makeDir($glo_data_dir);
465 if (!is_writable($glo_data_dir)) {
466 throw new ilGlossaryException("Glossary Data Directory (" . $glo_data_dir
467 . ") not writeable.");
468 }
469
470 // create glossary directory (data_dir/glo_data/glo_<id>)
471 $glo_dir = $glo_data_dir . "/glo_" . $this->getId();
472 ilFileUtils::makeDir($glo_dir);
473 if (!is_dir($glo_dir)) {
474 throw new ilGlossaryException("Creation of Glossary Directory failed.");
475 }
476 // create Import subdirectory (data_dir/glo_data/glo_<id>/import)
477 $import_dir = $glo_dir . "/import";
478 ilFileUtils::makeDir($import_dir);
479 if (!is_dir($import_dir)) {
480 throw new ilGlossaryException("Creation of Export Directory failed.");
481 }
482 }
483
484 public function getImportDirectory(): string
485 {
486 $export_dir = ilFileUtils::getDataDir() . "/glo_data" . "/glo_" . $this->getId() . "/import";
487
488 return $export_dir;
489 }
490
491 public function createExportDirectory(string $a_type = "xml"): string
492 {
493 return ilExport::_createExportDirectory($this->getId(), $a_type, $this->getType());
494 }
495
496 public function getExportDirectory(string $a_type = "xml"): string
497 {
498 return ilExport::_getExportDirectory($this->getId(), $a_type, $this->getType());
499 }
500
504 public function getExportFiles(): array
505 {
506 return ilExport::_getExportFiles($this->getId(), array("xml", "html"), $this->getType());
507 }
508
514 public function setPublicExportFile(
515 string $a_type,
516 string $a_file
517 ): void {
518 $this->public_export_file[$a_type] = $a_file;
519 }
520
525 public function getPublicExportFile(string $a_type): string
526 {
527 return $this->public_export_file[$a_type] ?? "";
528 }
529
530 public function exportXML(
531 ilXmlWriter $a_xml_writer,
532 int $a_inst,
533 string $a_target_dir,
534 ilLog $expLog
535 ): void {
536 // export glossary
537 $attrs = array();
538 $attrs["Type"] = "Glossary";
539 $a_xml_writer->xmlStartTag("ContentObject", $attrs);
540
541 // MetaData
542 $this->exportXMLMetaData($a_xml_writer);
543
544 // collect media objects
545 $terms = $this->getTermList();
546 $this->mob_ids = array();
547 $this->file_ids = array();
548 foreach ($terms as $term) {
549 $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
550
551 foreach ($defs as $def) {
552 $this->page_object = new ilGlossaryDefPage($def["id"]);
553 $this->page_object->buildDom();
554 $this->page_object->insertInstIntoIDs(IL_INST_ID);
555 $mob_ids = $this->page_object->collectMediaObjects(false);
556 $file_ids = ilPCFileList::collectFileItems($this->page_object, $this->page_object->getDomDoc());
557 foreach ($mob_ids as $mob_id) {
558 $this->mob_ids[$mob_id] = $mob_id;
559 }
560 foreach ($file_ids as $file_id) {
561 $this->file_ids[$file_id] = $file_id;
562 }
563 }
564 }
565
566 // export media objects
567 $expLog->write(date("[y-m-d H:i:s] ") . "Start Export Media Objects");
568 $this->exportXMLMediaObjects($a_xml_writer, $a_inst, $a_target_dir, $expLog);
569 $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export Media Objects");
570
571 // FileItems
572 $expLog->write(date("[y-m-d H:i:s] ") . "Start Export File Items");
573 $this->exportFileItems($a_target_dir, $expLog);
574 $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export File Items");
575
576 // Glossary
577 $expLog->write(date("[y-m-d H:i:s] ") . "Start Export Glossary Items");
578 $this->exportXMLGlossaryItems($a_xml_writer, $a_inst, $expLog);
579 $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export Glossary Items");
580
581 $a_xml_writer->xmlEndTag("ContentObject");
582 }
583
584 public function exportXMLGlossaryItems(
585 ilXmlWriter $a_xml_writer,
586 int $a_inst,
587 ilLog $expLog
588 ): void {
589 $attrs = array();
590 $a_xml_writer->xmlStartTag("Glossary", $attrs);
591
592 // MetaData
593 $this->exportXMLMetaData($a_xml_writer);
594
595 $terms = $this->getTermList();
596
597 // export glossary terms
598 reset($terms);
599 foreach ($terms as $term) {
600 $expLog->write(date("[y-m-d H:i:s] ") . "Page Object " . $term["obj_id"]);
601
602 // export xml to writer object
603 $glo_term = new ilGlossaryTerm($term["id"]);
604 $glo_term->exportXML($a_xml_writer, $a_inst);
605
606 unset($glo_term);
607 }
608
609 $a_xml_writer->xmlEndTag("Glossary");
610 }
611
612 public function exportXMLMetaData(
613 ilXmlWriter $a_xml_writer
614 ): void {
615 $md2xml = new ilMD2XML($this->getId(), 0, $this->getType());
616 $md2xml->setExportMode(true);
617 $md2xml->startExport();
618 $a_xml_writer->appendXML($md2xml->getXML());
619 }
620
621 public function exportXMLMediaObjects(
622 ilXmlWriter $a_xml_writer,
623 int $a_inst,
624 string $a_target_dir,
625 ilLog $expLog
626 ): void {
627 foreach ($this->mob_ids as $mob_id) {
628 $expLog->write(date("[y-m-d H:i:s] ") . "Media Object " . $mob_id);
629 $media_obj = new ilObjMediaObject($mob_id);
630 $media_obj->exportXML($a_xml_writer, $a_inst);
631 $media_obj->exportFiles($a_target_dir);
632 unset($media_obj);
633 }
634 }
635
636 public function exportFileItems(
637 string $a_target_dir,
638 ilLog $expLog
639 ): void {
640 foreach ($this->file_ids as $file_id) {
641 $expLog->write(date("[y-m-d H:i:s] ") . "File Item " . $file_id);
642 $file_obj = new ilObjFile($file_id, false);
643 $file_obj->export($a_target_dir);
644 unset($file_obj);
645 }
646 }
647
648 public function modifyExportIdentifier(
649 string $a_tag,
650 string $a_param,
651 string $a_value
652 ): string {
653 if ($a_tag == "Identifier" && $a_param == "Entry") {
654 $a_value = "il_" . IL_INST_ID . "_glo_" . $this->getId();
655 }
656 return $a_value;
657 }
658
659 public function delete(): bool
660 {
661 // always call parent delete function first!!
662 if (!parent::delete()) {
663 return false;
664 }
665
666 // delete terms
667 if (!$this->isVirtual()) {
668 $terms = $this->getTermList();
669 foreach ($terms as $term) {
670 $term_obj = new ilGlossaryTerm($term["id"]);
671 $term_obj->delete();
672 }
673 }
674
675 // delete term references
676 $refs = new ilGlossaryTermReferences($this->getId());
677 $refs->delete();
678
679 // delete glossary data entry
680 $q = "DELETE FROM glossary WHERE id = " . $this->db->quote($this->getId());
681 $this->db->query($q);
682
683 // delete meta data
684 $this->deleteMetaData();
685
686 return true;
687 }
688
689 public function getXMLZip(): string
690 {
691 $glo_exp = new ilGlossaryExport($this);
692 return $glo_exp->buildExportFile();
693 }
694
695 public static function getDeletionDependencies(int $obj_id): array
696 {
697 global $DIC;
698
699 $lng = $DIC->language();
700
701 $dep = array();
703 foreach ($sms as $sm) {
704 $lng->loadLanguageModule("content");
705 $dep[$sm] = $lng->txt("glo_used_in_scorm");
706 }
707 return $dep;
708 }
709
710 public function getTaxonomyId(): int
711 {
712 $tax_ids = ilObjTaxonomy::getUsageOfObject($this->getId());
713 if (count($tax_ids) > 0) {
714 // glossaries handle max. one taxonomy
715 return (int) $tax_ids[0];
716 }
717 return 0;
718 }
719
720
721 public function cloneObject(int $target_id, int $copy_id = 0, bool $omit_tree = false): ?ilObject
722 {
723 $new_obj = parent::cloneObject($target_id, $copy_id, $omit_tree);
724 $this->cloneMetaData($new_obj);
725
726 $tax_ass = null;
727 $new_tax_ass = null;
728 $map = [];
729
730 //copy online status if object is not the root copy object
731 $cp_options = ilCopyWizardOptions::_getInstance($copy_id);
732
733 if (!$cp_options->isRootNode($this->getRefId())) {
734 $new_obj->setOnline($this->getOnline());
735 }
736
737 // $new_obj->setTitle($this->getTitle());
738 $new_obj->setDescription($this->getDescription());
739 $new_obj->setVirtualMode($this->getVirtualMode());
740 $new_obj->setPresentationMode($this->getPresentationMode());
741 $new_obj->setSnippetLength($this->getSnippetLength());
742 $new_obj->setAutoGlossaries($this->getAutoGlossaries());
743 $new_obj->update();
744
745 // set/copy stylesheet
746 $this->content_style_domain->styleForRefId($this->getRefId())->cloneTo($new_obj->getId());
747
748 // copy taxonomy
749 if (($tax_id = $this->getTaxonomyId()) > 0) {
750 // clone it
751 $tax = new ilObjTaxonomy($tax_id);
752 $new_tax = $tax->cloneObject(0, 0, true);
753 $map = $tax->getNodeMapping();
754
755 // assign new taxonomy to new glossary
756 ilObjTaxonomy::saveUsage($new_tax->getId(), $new_obj->getId());
757
758 $tax_ass = new ilTaxNodeAssignment("glo", $this->getId(), "term", $tax_id);
759 $new_tax_ass = new ilTaxNodeAssignment("glo", $new_obj->getId(), "term", $new_tax->getId());
760 }
761
762 // copy terms
763 $term_mappings = array();
764 foreach (ilGlossaryTerm::getTermList([$this->getRefId()]) as $term) {
765 $new_term_id = ilGlossaryTerm::_copyTerm($term["id"], $new_obj->getId());
766 $term_mappings[$term["id"]] = $new_term_id;
767
768 // copy tax node assignments
769 if ($tax_id > 0) {
770 $assignmts = $tax_ass->getAssignmentsOfItem($term["id"]);
771 foreach ($assignmts as $a) {
772 if ($map[$a["node_id"]] > 0) {
773 $new_tax_ass->addAssignment($map[$a["node_id"]], $new_term_id);
774 }
775 }
776 }
777 }
778
779 // add mapping of term_ids to copy wizard options
780 if (!empty($term_mappings)) {
781 $cp_options->appendMapping($this->getRefId() . '_glo_terms', $term_mappings);
782 }
783
784
785 return $new_obj;
786 }
787
791 public function removeOfflineGlossaries(
792 array $a_glo_ids,
793 bool $ids_are_ref_ids = false
794 ): array {
795 $glo_ids = $a_glo_ids;
796 if ($ids_are_ref_ids) {
797 $glo_ids = array_map(static function ($id): int {
799 }, $a_glo_ids);
800 }
801
802 $set = $this->db->query(
803 "SELECT id FROM glossary " .
804 " WHERE " . $this->db->in("id", $glo_ids, false, "integer") .
805 " AND is_online = " . $this->db->quote("y", "text")
806 );
807 $online_glo_ids = array();
808 while ($rec = $this->db->fetchAssoc($set)) {
809 $online_glo_ids[] = $rec["id"];
810 }
811
812 if (!$ids_are_ref_ids) {
813 return $online_glo_ids;
814 }
815
816 $online_ref_ids = array_filter($a_glo_ids, static function ($ref_id) use ($online_glo_ids): bool {
817 return in_array(ilObject::_lookupObjectId($ref_id), $online_glo_ids);
818 });
819
820
821 return $online_ref_ids;
822 }
823
824 public static function getAdvMDSubItemTitle(int $a_obj_id, string $a_sub_type, int $a_sub_id): string
825 {
826 global $DIC;
827
828 $lng = $DIC->language();
829
830 if ($a_sub_type == "term") {
831 $lng->loadLanguageModule("glo");
832
833 return $lng->txt("glo_term") . ' "' . ilGlossaryTerm::_lookGlossaryTerm($a_sub_id) . '"';
834 }
835 return "";
836 }
837
841 public function autoLinkGlossaryTerms(
842 int $a_glo_ref_id
843 ): void {
844 // get terms of target glossary
845 $terms = ilGlossaryTerm::getTermList([$a_glo_ref_id]);
846
847 // for each get page: get content
848 $source_terms = ilGlossaryTerm::getTermList([$this->getRefId()]);
849 $found_pages = array();
850 foreach ($source_terms as $source_term) {
851 $source_defs = ilGlossaryDefinition::getDefinitionList($source_term["id"]);
852
853 for ($j = 0, $jMax = count($source_defs); $j < $jMax; $j++) {
854 $def = $source_defs[$j];
855 $pg = new ilGlossaryDefPage($def["id"]);
856
857 $c = $pg->getXMLContent();
858 foreach ($terms as $t) {
859 if (is_int(stripos($c, $t["term"]))) {
860 $found_pages[$def["id"]]["terms"][] = $t;
861 if (!isset($found_pages[$def["id"]]["page"])) {
862 $found_pages[$def["id"]]["page"] = $pg;
863 }
864 }
865 }
866 reset($terms);
867 }
868 }
869
870 // ilPCParagraph autoLinkGlossariesPage with page and terms
871 foreach ($found_pages as $id => $fp) {
872 ilPCParagraph::autoLinkGlossariesPage($fp["page"], $fp["terms"]);
873 }
874 }
875
879 public function supportsLongTextQuery(): bool
880 {
881 return true;
882 }
883}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _getInstance(int $a_copy_id)
static _getExportFiles(int $a_obj_id, $a_export_types="", string $a_obj_type="")
static _createExportDirectory(int $a_obj_id, string $a_export_type="xml", string $a_obj_type="")
static _getExportDirectory(int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
Get export directory for an repository object.
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getDataDir()
get data directory (outside webspace)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getDefinitionList(int $a_term_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getTermList(array $a_glo_ref_id, string $searchterm="", string $a_first_letter="", string $a_def="", int $a_tax_node=0, bool $a_add_amet_fields=false, array $a_amet_filter=null, bool $a_include_references=false)
Get all terms for given set of glossary ids.
static _lookGlossaryTerm(int $term_id)
get glossary term
static getFirstLetters(array $a_glo_id, int $a_tax_node=0)
static _copyTerm(int $a_term_id, int $a_glossary_id)
Copy a term to a glossary.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: class.ilLog.php:31
write(string $a_msg, $a_log_level=null)
logging
setExportMode(bool $a_export_mode=true)
Class ilObjFile.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setSnippetLength(int $a_val)
Set definition snippet length (in overview)
static getAdvMDSubItemTitle(int $a_obj_id, string $a_sub_type, int $a_sub_id)
static lookupAutoGlossaries(int $a_id)
ILIAS Style Content DomainService $content_style_domain
exportXMLMetaData(ilXmlWriter $a_xml_writer)
static lookupSnippetLength(int $a_id)
getExportFiles()
Get export files.
removeAutoGlossary(int $a_glo_id)
ilGlossaryDefPage $page_object
setPublicExportFile(string $a_type, string $a_file)
specify public export file for type
getAllGlossaryIds(bool $a_include_offline_childs=false, bool $ids_are_ref_ids=false)
Get all glossary ids.
supportsLongTextQuery()
Is long text search supported.
setActiveGlossaryMenu(bool $a_act_glo_menu)
setVirtualMode(string $a_mode)
getFirstLetters(int $a_tax_node=0)
setShowTaxonomy(bool $a_val)
ilGlobalTemplateInterface $tpl
exportXMLMediaObjects(ilXmlWriter $a_xml_writer, int $a_inst, string $a_target_dir, ilLog $expLog)
setPresentationMode(string $a_val)
removeOfflineGlossaries(array $a_glo_ids, bool $ids_are_ref_ids=false)
Remove offline glossaries from obj id array.
getPublicExportFile(string $a_type)
get public export file
setActiveDownloads(bool $a_down)
__construct(int $a_id=0, bool $a_call_by_reference=true)
cloneObject(int $target_id, int $copy_id=0, bool $omit_tree=false)
static getDeletionDependencies(int $obj_id)
Get deletion dependencies.
modifyExportIdentifier(string $a_tag, string $a_param, string $a_value)
createExportDirectory(string $a_type="xml")
setAutoGlossaries(array $a_val)
addAutoGlossary(int $glo_id)
exportXML(ilXmlWriter $a_xml_writer, int $a_inst, string $a_target_dir, ilLog $expLog)
static _lookupOnline(int $a_id)
createImportDirectory()
creates data directory for import files (data_dir/glo_data/glo_<id>/import, depending on data directo...
exportFileItems(string $a_target_dir, ilLog $expLog)
create(bool $a_upload=false)
autoLinkGlossaryTerms(int $a_glo_ref_id)
Auto link glossary terms.
exportXMLGlossaryItems(ilXmlWriter $a_xml_writer, int $a_inst, ilLog $expLog)
getTermList(string $searchterm="", string $a_letter="", string $a_def="", int $a_tax_node=0, bool $a_include_offline_childs=false, bool $a_add_amet_fields=false, array $a_amet_filter=null, bool $a_omit_virtual=false, bool $a_include_references=false)
setOnline(bool $a_online)
static lookup(int $a_id, string $a_property)
Lookup glossary property.
getExportDirectory(string $a_type="xml")
static getScormModulesForGlossary(int $a_glo_id)
Get SCORM modules that assign a certain glossary.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getUsageOfObject(int $a_obj_id, bool $a_include_titles=false)
static saveUsage(int $a_tax_id, int $a_obj_id)
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupObjectId(int $ref_id)
static _lookupType(int $id, bool $reference=false)
ilDBInterface $db
static collectFileItems(ilPageObject $a_page, DOMDocument $a_domdoc)
Get all file items that are used within the page.
static autoLinkGlossariesPage(ilPageObject $a_page, array $a_terms)
Auto link glossary of whole page.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static tf2yn(bool $a_tf)
static yn2tf(string $a_yn)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlEndTag(string $tag)
Writes an endtag.
appendXML(string $a_str)
append xml string to document
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
$c
Definition: cli.php:38
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
const IL_INST_ID
Definition: constants.php:40
global $DIC
Definition: feed.php:28
$target_id
Definition: goto.php:52
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
quote($value, string $type)
query(string $query)
Run a (read-only) Query on the database.
fetchAssoc(ilDBStatement $statement)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:67
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
$lng
$lm_set