45 bool $a_call_by_reference =
true
48 $this->tpl =
$DIC[
"tpl"];
50 $this->db =
$DIC->database();
51 $this->
user = $DIC->user();
54 $this->content_style_domain =
$DIC
61 $id = parent::create();
71 'id' => array(
'integer', $this->
getId()),
72 'is_online' => array(
'text',
'n'),
74 'pres_mode' => array(
'text',
'table'),
75 'snippet_length' => array(
'integer', 200)
87 public function read(): void
90 # echo "Glossary<br>\n";
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);
98 if (isset($gl_rec[
"public_xml_file"]) && $gl_rec[
"public_xml_file"] !=
"") {
101 if (isset($gl_rec[
"public_html_file"]) && $gl_rec[
"public_html_file"] !=
"") {
111 $set = $this->db->query(
112 "SELECT * FROM glo_glossaries " .
113 " WHERE id = " . $this->db->quote($this->getId(),
"integer")
116 while ($rec = $this->db->fetchAssoc($set)) {
117 $glos[] = $rec[
"glo_id"];
128 $this->virtual_mode = $a_mode;
129 $this->
virtual =
true;
133 $this->virtual_mode =
"none";
134 $this->
virtual =
false;
151 $this->pres_mode = $a_val;
162 $this->snippet_length = $a_val;
167 return ($this->snippet_length > 0)
168 ? $this->snippet_length
174 $this->online = $a_online;
189 $q =
"SELECT is_online FROM glossary WHERE id = " .
206 $db =
$DIC->database();
208 $set = $db->query(
"SELECT $a_property FROM glossary WHERE id = " .
209 $db->quote($a_id,
"integer"));
210 $rec = $db->fetchAssoc($set);
212 return $rec[$a_property];
217 return (
int) self::lookup($a_id,
"snippet_length");
223 $this->glo_menu_active = $a_act_glo_menu;
228 return $this->glo_menu_active;
233 $this->downloads_active = $a_down;
238 return $this->downloads_active;
243 $this->show_tax = $a_val;
248 return $this->show_tax;
257 $this->auto_glossaries = array();
258 foreach ($a_val as $v) {
259 $this->addAutoGlossary($v);
266 !in_array($glo_id, $this->auto_glossaries)) {
267 $this->auto_glossaries[] = $glo_id;
276 return $this->auto_glossaries;
283 foreach ($this->getAutoGlossaries() as $g) {
284 if ($g != $a_glo_id) {
288 $this->setAutoGlossaries($glo_ids);
293 $this->updateMetaData();
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())
309 'id' => array(
'integer', $this->
getId())
313 $this->updateAutoGlossaries();
314 return parent::update();
320 $this->db->manipulate(
321 "DELETE FROM glo_glossaries WHERE " .
322 " id = " . $this->db->quote($this->getId(),
"integer")
324 foreach ($this->getAutoGlossaries() as $glo_id) {
328 'id' => array(
'integer', $this->
getId()),
329 'glo_id' => array(
'integer', $glo_id)
340 $db =
$DIC->database();
344 "SELECT * FROM glo_glossaries " .
345 " WHERE id = " . $db->quote($a_id,
"integer")
348 while ($rec = $db->fetchAssoc($set)) {
349 $glos[] = (
int) $rec[
"glo_id"];
355 string $searchterm =
"",
356 string $a_letter =
"",
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
365 if ($a_omit_virtual) {
366 $glo_ref_ids[] = $this->getRefId();
368 $glo_ref_ids = $this->getAllGlossaryIds($a_include_offline_childs,
true);
378 $a_include_references
386 $glo_ids = $this->getAllGlossaryIds();
388 return $first_letters;
396 bool $a_include_offline_childs =
false,
397 bool $ids_are_ref_ids =
false
401 $tree =
$DIC->repositoryTree();
403 if ($this->isVirtual()) {
406 $virtual_mode = $this->getRefId() ? $this->getVirtualMode() :
'';
407 switch ($virtual_mode) {
409 $glo_arr = $tree->getChildsByType($tree->getParentId($this->getRefId()),
"glo");
410 foreach ($glo_arr as $glo) {
412 if ($ids_are_ref_ids) {
413 $glo_ids[] = (
int) $glo[
'child'];
415 $glo_ids[] = (
int) $glo[
'obj_id'];
422 $subtree_nodes = $tree->getSubTree($tree->getNodeData($tree->getParentId($this->getRefId())));
424 foreach ($subtree_nodes as $node) {
425 if ($node[
'type'] ==
'glo') {
426 if ($ids_are_ref_ids) {
427 $glo_ids[] = (
int) $node[
'child'];
429 $glo_ids[] = (
int) $node[
'obj_id'];
435 if (!$a_include_offline_childs) {
436 $glo_ids = $this->removeOfflineGlossaries($glo_ids, $ids_are_ref_ids);
440 if ($ids_are_ref_ids) {
441 if (!in_array($this->getRefId(), $glo_ids)) {
442 $glo_ids[] = $this->getRefId();
444 } elseif (!in_array($this->
getId(), $glo_ids)) {
445 $glo_ids[] = $this->
getId();
447 } elseif ($ids_are_ref_ids) {
448 $glo_ids = [$this->getRefId()];
450 $glo_ids = [$this->
getId()];
465 if (!is_writable($glo_data_dir)) {
467 .
") not writeable.");
471 $glo_dir = $glo_data_dir .
"/glo_" . $this->
getId();
473 if (!is_dir($glo_dir)) {
477 $import_dir = $glo_dir .
"/import";
479 if (!is_dir($import_dir)) {
518 $this->public_export_file[$a_type] = $a_file;
527 return $this->public_export_file[$a_type] ??
"";
533 string $a_target_dir,
538 $attrs[
"Type"] =
"Glossary";
539 $a_xml_writer->
xmlStartTag(
"ContentObject", $attrs);
542 $this->exportXMLMetaData($a_xml_writer);
545 $terms = $this->getTermList();
546 $this->mob_ids = array();
547 $this->file_ids = array();
548 foreach ($terms as $term) {
551 foreach ($defs as $def) {
553 $this->page_object->buildDom();
554 $this->page_object->insertInstIntoIDs(
IL_INST_ID);
555 $mob_ids = $this->page_object->collectMediaObjects(
false);
557 foreach ($mob_ids as $mob_id) {
558 $this->mob_ids[$mob_id] = $mob_id;
560 foreach ($file_ids as $file_id) {
561 $this->file_ids[$file_id] = $file_id;
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");
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");
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");
581 $a_xml_writer->
xmlEndTag(
"ContentObject");
593 $this->exportXMLMetaData($a_xml_writer);
595 $terms = $this->getTermList();
599 foreach ($terms as $term) {
600 $expLog->
write(date(
"[y-m-d H:i:s] ") .
"Page Object " . $term[
"obj_id"]);
604 $glo_term->exportXML($a_xml_writer, $a_inst);
617 $md2xml->startExport();
618 $a_xml_writer->
appendXML($md2xml->getXML());
624 string $a_target_dir,
627 foreach ($this->mob_ids as $mob_id) {
628 $expLog->
write(date(
"[y-m-d H:i:s] ") .
"Media Object " . $mob_id);
630 $media_obj->exportXML($a_xml_writer, $a_inst);
631 $media_obj->exportFiles($a_target_dir);
637 string $a_target_dir,
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);
653 if ($a_tag ==
"Identifier" && $a_param ==
"Entry") {
659 public function delete():
bool
662 if (!parent::delete()) {
667 if (!$this->isVirtual()) {
668 $terms = $this->getTermList();
669 foreach ($terms as $term) {
680 $q =
"DELETE FROM glossary WHERE id = " . $this->db->quote($this->
getId());
681 $this->db->query($q);
684 $this->deleteMetaData();
692 return $glo_exp->buildExportFile();
703 foreach ($sms as $sm) {
704 $lng->loadLanguageModule(
"content");
705 $dep[$sm] =
$lng->txt(
"glo_used_in_scorm");
713 if (count($tax_ids) > 0) {
715 return (
int) $tax_ids[0];
723 $new_obj = parent::cloneObject(
$target_id, $copy_id, $omit_tree);
724 $this->cloneMetaData($new_obj);
733 if (!$cp_options->isRootNode($this->getRefId())) {
734 $new_obj->setOnline($this->getOnline());
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());
746 $this->content_style_domain->styleForRefId($this->getRefId())->cloneTo($new_obj->getId());
749 if (($tax_id = $this->getTaxonomyId()) > 0) {
752 $new_tax = $tax->cloneObject(0, 0,
true);
753 $map = $tax->getNodeMapping();
759 $new_tax_ass =
new ilTaxNodeAssignment(
"glo", $new_obj->getId(),
"term", $new_tax->getId());
763 $term_mappings = array();
766 $term_mappings[$term[
"id"]] = $new_term_id;
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);
780 if (!empty($term_mappings)) {
781 $cp_options->appendMapping($this->getRefId() .
'_glo_terms', $term_mappings);
793 bool $ids_are_ref_ids =
false
795 $glo_ids = $a_glo_ids;
796 if ($ids_are_ref_ids) {
797 $glo_ids = array_map(
static function (
$id):
int {
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")
807 $online_glo_ids = array();
808 while ($rec = $this->db->fetchAssoc($set)) {
809 $online_glo_ids[] = $rec[
"id"];
812 if (!$ids_are_ref_ids) {
813 return $online_glo_ids;
816 $online_ref_ids = array_filter($a_glo_ids,
static function (
$ref_id) use ($online_glo_ids):
bool {
821 return $online_ref_ids;
830 if ($a_sub_type ==
"term") {
831 $lng->loadLanguageModule(
"glo");
849 $found_pages = array();
850 foreach ($source_terms as $source_term) {
853 for ($j = 0, $jMax = count($source_defs); $j < $jMax; $j++) {
854 $def = $source_defs[$j];
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;
871 foreach ($found_pages as
$id => $fp) {
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
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...
write(string $a_msg, $a_log_level=null)
logging
setExportMode(bool $a_export_mode=true)
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
array $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)
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)
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 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.
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...
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...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples