37    public function __construct($a_id = 0, $a_call_by_reference = 
true)
 
   40        $this->
error = $DIC[
"ilErr"];
 
   41        $this->tpl = 
$DIC[
"tpl"];
 
   43        $this->db = 
$DIC->database();
 
   44        $this->
user = $DIC->user();
 
   52    public function create($a_upload = 
false)
 
   64                'id' => array(
'integer', $this->
getId()),
 
   65                'is_online' => array(
'text', 
'n'),
 
   67                'pres_mode' => array(
'text', 
'table'),
 
   68                'snippet_length' => array(
'integer', 200)
 
   88        #               echo "Glossary<br>\n";
 
   90        $q = 
"SELECT * FROM glossary WHERE id = " .
 
   91            $this->db->quote($this->
getId(), 
"integer");
 
   92        $gl_set = $this->db->query($q);
 
   93        $gl_rec = $this->db->fetchAssoc($gl_set);
 
  107        $set = $this->db->query(
 
  108            "SELECT * FROM glo_glossaries " .
 
  109            " WHERE id = " . $this->db->quote($this->getId(), 
"integer")
 
  112        while ($rec = $this->db->fetchAssoc($set)) {
 
  113            $glos[] = $rec[
"glo_id"];
 
  125        return parent::getDescription();
 
  133        parent::setDescription($a_description);
 
  146                $this->virtual_mode = $a_mode;
 
  147                $this->
virtual = 
true;
 
  151                $this->virtual_mode = 
"none";
 
  152                $this->
virtual = 
false;
 
  162        return $this->virtual_mode;
 
  170        return $this->virtual;
 
  180        return parent::getTitle();
 
  188        parent::setTitle($a_title);
 
  199        $this->pres_mode = $a_val;
 
  209        return $this->pres_mode;
 
  219        $this->snippet_length = $a_val;
 
  229        return ($this->snippet_length > 0)
 
  230            ? $this->snippet_length
 
  236        $this->online = $a_online;
 
  241        return $this->online;
 
  253        $q = 
"SELECT is_online FROM glossary WHERE id = " .
 
  254            $db->quote($a_id, 
"integer");
 
  267    protected static function lookup($a_id, $a_property)
 
  273        $set = 
$db->query(
"SELECT $a_property FROM glossary WHERE id = " .
 
  274            $db->quote($a_id, 
"integer"));
 
  275        $rec = 
$db->fetchAssoc($set);
 
  277        return $rec[$a_property];
 
  294        $this->glo_menu_active = $a_act_glo_menu;
 
  299        return $this->glo_menu_active;
 
  304        $this->downloads_active = $a_down;
 
  309        return $this->downloads_active;
 
  317        return $this->style_id;
 
  325        $this->style_id = $a_style_id;
 
  336        $this->show_tax = $a_val;
 
  346        return $this->show_tax;
 
  356        $this->auto_glossaries = array();
 
  357        if (is_array($a_val)) {
 
  358            foreach ($a_val as $v) {
 
  370        $glo_id = (int) $glo_id;
 
  372            !in_array($glo_id, $this->auto_glossaries)) {
 
  373            $this->auto_glossaries[] = $glo_id;
 
  397            if ($g != $a_glo_id) {
 
  425                'id' => array(
'integer', $this->
getId())
 
  444        $this->db->manipulate(
 
  445            "DELETE FROM glo_glossaries WHERE " .
 
  446            " id = " . $this->db->quote($this->getId(), 
"integer")
 
  452                    'id' => array(
'integer', $this->
getId()),
 
  453                    'glo_id' => array(
'integer', $glo_id)
 
  473            "SELECT * FROM glo_glossaries " .
 
  474            " WHERE id = " . 
$db->quote($a_id, 
"integer")
 
  477        while ($rec = 
$db->fetchAssoc($set)) {
 
  478            $glos[] = $rec[
"glo_id"];
 
  491        $a_include_offline_childs = 
false,
 
  492        $a_add_amet_fields = 
false,
 
  493        array $a_amet_filter = 
null,
 
  494        $a_omit_virtual = 
false,
 
  495        $a_include_references = 
false 
  497        if ($a_omit_virtual) {
 
  510            $a_include_references
 
  522        return $first_letters;
 
  541            switch ($virtual_mode) {
 
  543                    $glo_arr = 
$tree->getChildsByType(
$tree->getParentId($this->getRefId()), 
"glo");
 
  544                    foreach ($glo_arr as $glo) {
 
  546                            if ($ids_are_ref_ids) {
 
  547                                $glo_ids[] = $glo[
'child'];
 
  549                                $glo_ids[] = $glo[
'obj_id'];
 
  556                    $subtree_nodes = 
$tree->getSubTree(
$tree->getNodeData(
$tree->getParentId($this->getRefId())));
 
  558                    foreach ($subtree_nodes as $node) {
 
  559                        if ($node[
'type'] == 
'glo') {
 
  560                            if ($ids_are_ref_ids) {
 
  561                                $glo_ids[] = $node[
'child'];
 
  563                                $glo_ids[] = $node[
'obj_id'];
 
  569            if (!$a_include_offline_childs) {
 
  574            if ($ids_are_ref_ids) {
 
  575                if (!in_array($this->
getRefId(), $glo_ids)) {
 
  579                if (!in_array($this->
getId(), $glo_ids)) {
 
  580                    $glo_ids[] = $this->
getId();
 
  584            if ($ids_are_ref_ids) {
 
  587                $glo_ids = $this->
getId();
 
  605        if (!is_writable($glo_data_dir)) {
 
  606            $ilErr->raiseError(
"Glossary Data Directory (" . $glo_data_dir
 
  607                . 
") not writeable.", 
$ilErr->error_obj->FATAL);
 
  611        $glo_dir = $glo_data_dir . 
"/glo_" . $this->
getId();
 
  613        if (!@is_dir($glo_dir)) {
 
  614            $ilErr->raiseError(
"Creation of Glossary Directory failed.", 
$ilErr->FATAL);
 
  617        $import_dir = $glo_dir . 
"/import";
 
  619        if (!@is_dir($import_dir)) {
 
  620            $ilErr->raiseError(
"Creation of Export Directory failed.", 
$ilErr->FATAL);
 
  666        $this->public_export_file[
$a_type] = $a_file;
 
  678        return $this->public_export_file[
$a_type];
 
  688    public function exportXML(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
 
  692        $attrs[
"Type"] = 
"Glossary";
 
  693        $a_xml_writer->xmlStartTag(
"ContentObject", $attrs);
 
  700        $this->mob_ids = array();
 
  701        $this->file_ids = array();
 
  702        foreach ($terms as $term) {
 
  705            foreach ($defs as $def) {
 
  707                $this->page_object->buildDom();
 
  708                $this->page_object->insertInstIntoIDs(IL_INST_ID);
 
  709                $mob_ids = $this->page_object->collectMediaObjects(
false);
 
  711                foreach ($mob_ids as $mob_id) {
 
  712                    $this->mob_ids[$mob_id] = $mob_id;
 
  714                foreach ($file_ids as $file_id) {
 
  715                    $this->file_ids[$file_id] = $file_id;
 
  721        $expLog->write(date(
"[y-m-d H:i:s] ") . 
"Start Export Media Objects");
 
  723        $expLog->write(date(
"[y-m-d H:i:s] ") . 
"Finished Export Media Objects");
 
  726        $expLog->write(date(
"[y-m-d H:i:s] ") . 
"Start Export File Items");
 
  728        $expLog->write(date(
"[y-m-d H:i:s] ") . 
"Finished Export File Items");
 
  731        $expLog->write(date(
"[y-m-d H:i:s] ") . 
"Start Export Glossary Items");
 
  733        $expLog->write(date(
"[y-m-d H:i:s] ") . 
"Finished Export Glossary Items");
 
  735        $a_xml_writer->xmlEndTag(
"ContentObject");
 
  747        $a_xml_writer->xmlStartTag(
"Glossary", $attrs);
 
  756        foreach ($terms as $term) {
 
  757            $expLog->write(date(
"[y-m-d H:i:s] ") . 
"Page Object " . $page[
"obj_id"]);
 
  761            $glo_term->exportXML($a_xml_writer, $a_inst);
 
  766        $a_xml_writer->xmlEndTag(
"Glossary");
 
  778        $md2xml->setExportMode(
true);
 
  779        $md2xml->startExport();
 
  780        $a_xml_writer->appendXML($md2xml->getXML());
 
  791        foreach ($this->mob_ids as $mob_id) {
 
  792            $expLog->write(date(
"[y-m-d H:i:s] ") . 
"Media Object " . $mob_id);
 
  794            $media_obj->exportXML($a_xml_writer, $a_inst);
 
  795            $media_obj->exportFiles($a_target_dir);
 
  806        foreach ($this->file_ids as $file_id) {
 
  807            $expLog->write(date(
"[y-m-d H:i:s] ") . 
"File Item " . $file_id);
 
  808            $file_obj = 
new ilObjFile($file_id, 
false);
 
  809            $file_obj->export($a_target_dir);
 
  821        if ($a_tag == 
"Identifier" && $a_param == 
"Entry") {
 
  822            $a_value = 
"il_" . IL_INST_ID . 
"_glo_" . $this->
getId();
 
  841    public function delete()
 
  844        if (!parent::delete()) {
 
  851            foreach ($terms as $term) {
 
  862        $q = 
"DELETE FROM glossary WHERE id = " . $this->db->quote($this->
getId());
 
  863        $this->db->query($q);
 
  877        return $glo_exp->buildExportFile();
 
  892        foreach ($sms as $sm) {
 
  893            $lng->loadLanguageModule(
"content");
 
  894            $dep[$sm] = 
$lng->txt(
"glo_used_in_scorm");
 
  909        if (count($tax_ids) > 0) {
 
  923    public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = 
false)
 
  925        $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
 
  931        if (!$cp_options->isRootNode($this->getRefId())) {
 
  947            $new_id = $style_obj->ilClone();
 
  948            $new_obj->setStyleSheetId($new_id);
 
  956            $new_tax = $tax->cloneObject(0, 0, 
true);
 
  957            $map = $tax->getNodeMapping();
 
  969            $new_tax_ass = 
new ilTaxNodeAssignment(
"glo", $new_obj->getId(), 
"term", $new_tax->getId());
 
  973        $term_mappings = array();
 
  976            $term_mappings[$term[
"id"]] = $new_term_id;
 
  980                $assignmts = $tax_ass->getAssignmentsOfItem($term[
"id"]);
 
  981                foreach ($assignmts as 
$a) {
 
  982                    if ($map[
$a[
"node_id"]] > 0) {
 
  983                        $new_tax_ass->addAssignment($map[
$a[
"node_id"]], $new_term_id);
 
  990        if (!empty($term_mappings)) {
 
  991            $cp_options->appendMapping($this->
getRefId() . 
'_glo_terms', (array) $term_mappings);
 
 1006        $glo_ids = $a_glo_ids;
 
 1007        if ($ids_are_ref_ids) {
 
 1008            $glo_ids = array_map(
function (
$id) {
 
 1013        $set = $this->db->query(
 
 1014            "SELECT id FROM glossary " .
 
 1015            " WHERE " . $this->db->in(
"id", $glo_ids, 
false, 
"integer") .
 
 1016            " AND is_online = " . $this->db->quote(
"y", 
"text")
 
 1018        $online_glo_ids = array();
 
 1019        while ($rec = $this->db->fetchAssoc($set)) {
 
 1020            $online_glo_ids[] = $rec[
"id"];
 
 1023        if (!$ids_are_ref_ids) {
 
 1024            return $online_glo_ids;
 
 1027        $online_ref_ids = array_filter($a_glo_ids, 
function (
$ref_id) use ($online_glo_ids) {
 
 1032        return $online_ref_ids;
 
 1041        if ($a_sub_type == 
"term") {
 
 1042            $lng->loadLanguageModule(
"glo");
 
 1061        $found_pages = array();
 
 1062        foreach ($source_terms as $source_term) {
 
 1065            for ($j = 0; $j < count($source_defs); $j++) {
 
 1066                $def = $source_defs[$j];
 
 1069                $c = $pg->getXMLContent();
 
 1070                foreach ($terms as $t) {
 
 1071                    if (is_int(stripos(
$c, $t[
"term"]))) {
 
 1072                        $found_pages[$def[
"id"]][
"terms"][] = $t;
 
 1073                        if (!is_object($found_pages[$def[
"id"]][
"page"])) {
 
 1074                            $found_pages[$def[
"id"]][
"page"] = $pg;
 
 1083        foreach ($found_pages as 
$id => $fp) {
 
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static _getExportFiles($a_obj_id, $a_export_types="", $a_obj_type="")
Get Export Files for a repository object.
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
static _createExportDirectory($a_obj_id, $a_export_type="xml", $a_obj_type="")
Glossary definition page object.
static getDefinitionList($a_term_id)
static
Export class for content objects.
static getTermList( $a_glo_ref_id, $searchterm="", $a_first_letter="", $a_def="", $a_tax_node=0, $a_add_amet_fields=false, array $a_amet_filter=null, $a_include_references=false)
Get all terms for given set of glossary ids.
static _copyTerm($a_term_id, $a_glossary_id)
Copy a term to a glossary.
static _lookGlossaryTerm($term_id)
get glossary term
static getFirstLetters($a_glo_id, $a_tax_node=0)
Get all terms for given set of glossary ids.
getImportDirectory()
get import directory of glossary
setVirtualMode($a_mode)
set glossary type (virtual: fixed/level/subtree, normal:none)
removeOfflineGlossaries($a_glo_ids, $ids_are_ref_ids=false)
Remove offline glossaries from obj id array.
setPublicExportFile($a_type, $a_file)
specify public export file for type
getAutoGlossaries()
Get auto glossaries.
setTitle($a_title)
set title of glossary object
getPublicExportFile($a_type)
get public export file
getExportFiles()
Get export files.
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, $a_include_references=false)
Get term list.
setStyleSheetId($a_style_id)
Set ID of assigned style sheet object.
supportsLongTextQuery()
Is long text search supported.
setActiveDownloads($a_down)
getAllGlossaryIds($a_include_offline_childs=false, $ids_are_ref_ids=false)
Get all glossary ids.
removeAutoGlossary($a_glo_id)
Remove auto glossary.
getSnippetLength()
Get snippet length.
exportFileItems($a_target_dir, &$expLog)
export files of file itmes
static lookupAutoGlossaries($a_id)
Lookup auto glossaries.
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
addAutoGlossary($glo_id)
Add auto glossary.
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)
cloneObject($a_target_id, $a_copy_id=0, $a_omit_tree=false)
Clone glossary.
getXMLZip()
Get zipped xml file for glossary.
getTaxonomyId()
Get taxonomy.
__construct($a_id=0, $a_call_by_reference=true)
Constructor @access public.
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.
createImportDirectory()
creates data directory for import files (data_dir/glo_data/glo_<id>/import, depending on data directo...
autoLinkGlossaryTerms($a_glo_ref_id)
Auto link glossary terms.
getDescription()
get description of glossary object
updateAutoGlossaries()
Update auto glossaries.
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.
exportXMLMetaData(&$a_xml_writer)
export content objects meta data to xml (see ilias_co.dtd)
static _lookupOnline($a_id)
check wether content object is online
getFirstLetters($a_tax_node=0)
Get term list.
getVirtualMode()
get glossary type (normal or virtual)
getTitle()
get title of glossary object
setAutoGlossaries($a_val)
Set auto glossaries.
setPresentationMode($a_val)
Set presentation mode.
setActiveGlossaryMenu($a_act_glo_menu)
setDescription($a_description)
set description of glossary object
static getScormModulesForGlossary($a_glo_id)
Get SCORM modules that assign a certain glossary.
static _lookupStandard($a_id)
Lookup standard flag.
static lookupObjectStyle($a_obj_id)
Lookup object style.
static writeStyleUsage($a_obj_id, $a_style_id)
Write style usage.
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
static saveUsage($a_tax_id, $a_obj_id)
Save Usage.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObject Basic functions for all objects.
getType()
get object type @access public
static _lookupObjectId($a_ref_id)
lookup object id
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 _lookupType($a_id, $a_reference=false)
lookup object type
static collectFileItems($a_page, $a_domdoc)
Get all file items that are used within the page.
static autoLinkGlossariesPage($a_page, $a_terms)
Auto link glossary of whole page.
Taxonomy node <-> item assignment.
static getDataDir()
get data directory (outside webspace)
static tf2yn($a_tf)
convert true/false to "y"/"n"
static yn2tf($a_yn)
convert "y"/"n" to true/false
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples