ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilGlossaryTerm Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilGlossaryTerm:

Public Member Functions

 __construct (int $a_id=0)
 
 read ()
 
 setId (int $a_id)
 set glossary term id (= glossary item id) More...
 
 getId ()
 
 setGlossary (ilObjGlossary $a_glossary)
 
 setGlossaryId (int $a_glo_id)
 
 getGlossaryId ()
 
 setTerm (string $a_term)
 
 getTerm ()
 
 setLanguage (string $a_language)
 
 getLanguage ()
 
 setImportId (string $a_import_id)
 
 getImportId ()
 
 setShortText (string $a_text)
 
 getShortText ()
 
 setShortTextDirty (int $a_val)
 
 getShortTextDirty ()
 
 assignPageObject (ilGlossaryDefPage $a_page_object)
 
 getPageObject ()
 
 create (bool $a_omit_page_creation=false)
 
 delete ()
 delete glossary term More...
 
 update ()
 
 shortenShortText (string $text)
 Shorten short text. More...
 
 updateShortText ()
 
 exportXML (ilXmlWriter $a_xml_writer, int $a_inst)
 

Static Public Member Functions

static _getIdForImportId (string $a_import_id)
 
static _exists (int $a_id)
 checks whether a glossary term with specified id exists or not More...
 
static setShortTextsDirty (int $a_glo_id)
 Set all short texts of glossary dirty (e.g. More...
 
static setShortTextsDirtyGlobally ()
 Set short texts dirty (for all glossaries) More...
 
static _lookGlossaryID (int $term_id)
 get glossary id form term id More...
 
static _lookGlossaryTerm (int $term_id)
 get glossary term More...
 
static _lookLanguage (int $term_id)
 lookup term language More...
 
static _lookShortText (int $term_id)
 get definition short text More...
 
static _lookShortTextDirty (int $term_id)
 get definition short text dirty More...
 
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. More...
 
static getFirstLetters (array $a_glo_id, int $a_tax_node=0)
 
static getNumberOfUsages (int $a_term_id)
 
static getUsages (int $a_term_id)
 
static _copyTerm (int $a_term_id, int $a_glossary_id)
 Copy a term to a glossary. More...
 
static getTermsOfGlossary (int $a_glo_id)
 

Data Fields

ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
int $id = 0
 
ilObjGlossary $glossary
 
string $term = ""
 
string $language = ""
 
int $glo_id = 0
 
string $import_id = ""
 
string $short_text = ""
 
int $short_text_dirty = 0
 
ilGlossaryDefPage $page_object
 

Protected Attributes

string $type
 
ilDBInterface $db
 
ilAppEventHandler $event_handler
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Glossary terms

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 23 of file class.ilGlossaryTerm.php.

Constructor & Destructor Documentation

◆ __construct()

ilGlossaryTerm::__construct ( int  $a_id = 0)

Definition at line 40 of file class.ilGlossaryTerm.php.

References $DIC, $lng, $tpl, ILIAS\Repository\lng(), and read().

41  {
42  global $DIC;
43 
44  $this->db = $DIC->database();
45  $lng = $DIC->language();
46  $tpl = $DIC["tpl"];
47 
48  $this->lng = $lng;
49  $this->tpl = $tpl;
50 
51  $this->id = $a_id;
52  $this->type = "term";
53  if ($a_id != 0) {
54  $this->read();
55  }
56  $this->event_handler = $DIC->event();
57  }
global $DIC
Definition: feed.php:28
ilGlobalTemplateInterface $tpl
+ Here is the call graph for this function:

Member Function Documentation

◆ _copyTerm()

static ilGlossaryTerm::_copyTerm ( int  $a_term_id,
int  $a_glossary_id 
)
static

Copy a term to a glossary.

Returns
int new term id

Definition at line 639 of file class.ilGlossaryTerm.php.

References ilAdvancedMDRecord\_getSelectedRecordsByObject(), ilADTActiveRecordByType\cloneByPrimary(), ilMD\cloneMD(), ilADTFactory\getInstance(), and ilAdvancedMDFieldDefinition\getInstancesByRecordId().

Referenced by ilObjGlossary\cloneObject(), ILIAS\Glossary\Term\TermManager\copyTermFromOtherGlossary(), and ilObjGlossaryGUI\pasteTerms().

642  : int {
643  $old_term = new ilGlossaryTerm($a_term_id);
644 
645  // copy the term
646  $new_term = new ilGlossaryTerm();
647  $new_term->setTerm($old_term->getTerm());
648  $new_term->setLanguage($old_term->getLanguage());
649  $new_term->setGlossaryId($a_glossary_id);
650  $new_term->setShortText($old_term->getShortText());
651  $new_term->setShortTextDirty($old_term->getShortTextDirty());
652  $new_term->create();
653 
654  // copy meta data
655  $md = new ilMD(
656  $old_term->getGlossaryId(),
657  $old_term->getPageObject()->getId(),
658  $old_term->getPageObject()->getParentType()
659  );
660  $new_md = $md->cloneMD(
661  $a_glossary_id,
662  $new_term->getPageObject()->getId(),
663  $old_term->getPageObject()->getParentType()
664  );
665 
666  $new_page = $new_term->getPageObject();
667  $old_term->getPageObject()->copy($new_page->getId(), $new_page->getParentType(), $new_page->getParentId(), true);
668 
669  // adv metadata
670  $old_recs = ilAdvancedMDRecord::_getSelectedRecordsByObject("glo", $old_term->getGlossaryId(), "term");
671  $new_recs = ilAdvancedMDRecord::_getSelectedRecordsByObject("glo", $a_glossary_id, "term");
672  foreach ($old_recs as $old_record_obj) {
673  reset($new_recs);
674  foreach ($new_recs as $new_record_obj) {
675  if ($old_record_obj->getRecordId() == $new_record_obj->getRecordId()) {
676  foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($old_record_obj->getRecordId()) as $def) {
677  // now we need to copy $def->getFieldId() values from old term to new term
678  // how?
679  // clone values
680 
681  $source_primary = array("obj_id" => array("integer", $old_term->getGlossaryId()));
682  $source_primary["sub_type"] = array("text", "term");
683  $source_primary["sub_id"] = array("integer", $old_term->getId());
684  $source_primary["field_id"] = array("integer", $def->getFieldId());
685  $target_primary = array("obj_id" => array("integer", $new_term->getGlossaryId()));
686  $target_primary["sub_type"] = array("text", "term");
687  $target_primary["sub_id"] = array("integer", $new_term->getId());
688 
689  ilADTFactory::getInstance()->initActiveRecordByType();
691  "adv_md_values",
692  array(
693  "obj_id" => "integer",
694  "sub_type" => "text",
695  "sub_id" => "integer",
696  "field_id" => "integer"
697  ),
698  $source_primary,
699  $target_primary,
700  array("disabled" => "integer")
701  );
702  }
703  }
704  }
705  }
706 
707  return $new_term->getId();
708  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getSelectedRecordsByObject(string $a_obj_type, int $a_id, string $a_sub_type="", bool $is_ref_id=true)
static getInstancesByRecordId( $a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.
static cloneByPrimary(string $a_table, array $a_primary_def, array $a_source_primary, array $a_target_primary, array $a_additional=null)
Clone values by (partial) primary key.
cloneMD(int $a_rbac_id, int $a_obj_id, string $a_obj_type)
Definition: class.ilMD.php:288
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _exists()

static ilGlossaryTerm::_exists ( int  $a_id)
static

checks whether a glossary term with specified id exists or not

Definition at line 109 of file class.ilGlossaryTerm.php.

References $DIC, $ilDB, $q, and ilInternalLink\_extractObjIdOfTarget().

Referenced by ilInternalLink\_exists(), ilCOPageHTMLExport\exportHTMLGlossaryTerms(), ilLinksTableGUI\fillRow(), and ilLMPresentationLinker\getLinkXML().

109  : bool
110  {
111  global $DIC;
112 
113  $ilDB = $DIC->database();
114 
115  if (is_int(strpos($a_id, "_"))) {
117  }
118 
119  $q = "SELECT * FROM glossary_term WHERE id = " .
120  $ilDB->quote($a_id, "integer");
121  $obj_set = $ilDB->query($q);
122  if ($obj_rec = $ilDB->fetchAssoc($obj_set)) {
123  return true;
124  } else {
125  return false;
126  }
127  }
global $DIC
Definition: feed.php:28
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getIdForImportId()

static ilGlossaryTerm::_getIdForImportId ( string  $a_import_id)
static

Definition at line 78 of file class.ilGlossaryTerm.php.

References $DIC, $ilDB, $q, ilObject\_getAllReferences(), and ilObject\_hasUntrashedReference().

Referenced by ilInternalLink\_getIdForImportId().

80  : int {
81  global $DIC;
82 
83  $ilDB = $DIC->database();
84 
85  if ($a_import_id == "") {
86  return 0;
87  }
88 
89  $q = "SELECT * FROM glossary_term WHERE import_id = " .
90  $ilDB->quote($a_import_id, "text") .
91  " ORDER BY create_date DESC";
92  $term_set = $ilDB->query($q);
93  while ($term_rec = $ilDB->fetchAssoc($term_set)) {
94  $glo_id = self::_lookGlossaryID($term_rec["id"]);
95 
96  $ref_ids = ilObject::_getAllReferences($glo_id); // will be 0 if import of lm is in progress (new import)
97  if (count($ref_ids) == 0 || ilObject::_hasUntrashedReference($glo_id)) {
98  return (int) $term_rec["id"];
99  }
100  }
101 
102  return 0;
103  }
static _getAllReferences(int $id)
get all reference ids for object ID
static _hasUntrashedReference(int $obj_id)
checks whether an object has at least one reference that is not in trash
global $DIC
Definition: feed.php:28
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookGlossaryID()

static ilGlossaryTerm::_lookGlossaryID ( int  $term_id)
static

get glossary id form term id

Definition at line 371 of file class.ilGlossaryTerm.php.

References $DIC, and $ilDB.

Referenced by ilTermDefinitionEditorGUI\__construct(), ilGlossaryTermGUI\__construct(), ilObjGlossaryGUI\__construct(), ilObjGlossaryAccess\_checkGoto(), ilGlossaryTermGUI\_goto(), ilObjGlossaryGUI\confirmTermDeletion(), ILIAS\Glossary\Term\TermManager\copyTermFromOtherGlossary(), ilTermUsagesTableGUI\fillRow(), ilMediaPoolPageUsagesTableGUI\fillRow(), ilMediaObjectUsagesTableGUI\fillRow(), ilTermListTableGUI\fillRow(), ilGlossaryTermPermission\getGlossaryIdForTerm(), ilObjMediaObject\getParentObjectIdForUsage(), ilGlossaryPresentationGUI\initByRequest(), ILIAS\Glossary\Term\TermManager\referenceTermsFromOtherGlossary(), and ilGlossaryPresentationGUI\showDefinitionTabs().

371  : int
372  {
373  global $DIC;
374 
375  $ilDB = $DIC->database();
376 
377  $query = "SELECT * FROM glossary_term WHERE id = " .
378  $ilDB->quote($term_id, "integer");
379  $obj_set = $ilDB->query($query);
380  $obj_rec = $ilDB->fetchAssoc($obj_set);
381 
382  return (int) ($obj_rec["glo_id"] ?? 0);
383  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ _lookGlossaryTerm()

static ilGlossaryTerm::_lookGlossaryTerm ( int  $term_id)
static

get glossary term

Definition at line 388 of file class.ilGlossaryTerm.php.

References $DIC, and $ilDB.

Referenced by ilObjGlossaryGUI\copyTerms(), ilLinksTableGUI\fillRow(), ilTermUsagesTableGUI\fillRow(), ilMediaPoolPageUsagesTableGUI\fillRow(), ilMediaObjectUsagesTableGUI\fillRow(), ilObjGlossary\getAdvMDSubItemTitle(), ilObjGlossarySubItemListGUI\getHTML(), ilObjGlossaryGUI\getTemplate(), ilGlossaryFlashcardBoxGUI\getTermText(), ilLinkInputGUI\getTranslatedValue(), ilObjGlossaryGUI\referenceTerms(), and ilLMPresentationGUI\showPrintView().

388  : string
389  {
390  global $DIC;
391 
392  $ilDB = $DIC->database();
393 
394  $query = "SELECT * FROM glossary_term WHERE id = " .
395  $ilDB->quote($term_id, "integer");
396  $obj_set = $ilDB->query($query);
397  $obj_rec = $ilDB->fetchAssoc($obj_set);
398 
399  return $obj_rec["term"] ?? "";
400  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ _lookLanguage()

static ilGlossaryTerm::_lookLanguage ( int  $term_id)
static

lookup term language

Definition at line 405 of file class.ilGlossaryTerm.php.

References $DIC, and $ilDB.

405  : string
406  {
407  global $DIC;
408 
409  $ilDB = $DIC->database();
410 
411  $query = "SELECT * FROM glossary_term WHERE id = " .
412  $ilDB->quote($term_id, "integer");
413  $obj_set = $ilDB->query($query);
414  $obj_rec = $ilDB->fetchAssoc($obj_set);
415 
416  return $obj_rec["language"];
417  }
global $DIC
Definition: feed.php:28

◆ _lookShortText()

static ilGlossaryTerm::_lookShortText ( int  $term_id)
static

get definition short text

Definition at line 422 of file class.ilGlossaryTerm.php.

References $DIC, and $ilDB.

Referenced by ilPresentationListTableGUI\fillRow(), and ilTermListTableGUI\fillRow().

422  : string
423  {
424  global $DIC;
425 
426  $ilDB = $DIC->database();
427 
428  $query = "SELECT * FROM glossary_term WHERE id = " .
429  $ilDB->quote($term_id, "integer");
430  $obj_set = $ilDB->query($query);
431  $obj_rec = $ilDB->fetchAssoc($obj_set);
432 
433  return $obj_rec["short_text"] ?? "";
434  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ _lookShortTextDirty()

static ilGlossaryTerm::_lookShortTextDirty ( int  $term_id)
static

get definition short text dirty

Definition at line 439 of file class.ilGlossaryTerm.php.

References $DIC, and $ilDB.

Referenced by ilPresentationListTableGUI\fillRow(), and ilTermListTableGUI\fillRow().

439  : int
440  {
441  global $DIC;
442 
443  $ilDB = $DIC->database();
444 
445  $query = "SELECT * FROM glossary_term WHERE id = " .
446  $ilDB->quote($term_id, "integer");
447  $obj_set = $ilDB->query($query);
448  $obj_rec = $ilDB->fetchAssoc($obj_set);
449 
450  return (int) ($obj_rec["short_text_dirty"] ?? 0);
451  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ assignPageObject()

ilGlossaryTerm::assignPageObject ( ilGlossaryDefPage  $a_page_object)

Definition at line 212 of file class.ilGlossaryTerm.php.

212  : void
213  {
214  $this->page_object = $a_page_object;
215  }

◆ create()

ilGlossaryTerm::create ( bool  $a_omit_page_creation = false)

Definition at line 222 of file class.ilGlossaryTerm.php.

References $db, $ilDB, getGlossaryId(), getId(), getShortText(), getShortTextDirty(), and setId().

Referenced by ilObjGlossaryGUI\addTerm().

222  : void
223  {
224  $ilDB = $this->db;
225 
226  $this->setId($ilDB->nextId("glossary_term"));
227  $ilDB->manipulate("INSERT INTO glossary_term" .
228  " (id, glo_id, term, language, import_id, create_date, last_update, short_text, short_text_dirty)" .
229  " VALUES (" .
230  $ilDB->quote($this->getId(), "integer") . ", " .
231  $ilDB->quote($this->getGlossaryId(), "integer") . ", " .
232  $ilDB->quote($this->getTerm(), "text") . ", " .
233  $ilDB->quote($this->getLanguage(), "text") . ", " .
234  $ilDB->quote($this->getImportId(), "text") . ", " .
235  $ilDB->now() . ", " .
236  $ilDB->now() . ", " .
237  $ilDB->quote($this->getShortText(), "text") . ", " .
238  $ilDB->quote($this->getShortTextDirty(), "integer") . ")");
239 
240  if (!$a_omit_page_creation) {
241  $this->page_object = new ilGlossaryDefPage();
242  $this->page_object->setId($this->getId());
243  $this->page_object->setParentId($this->getGlossaryId());
244  $this->page_object->create(false);
245  }
246  }
setId(int $a_id)
set glossary term id (= glossary item id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilGlossaryTerm::delete ( )

delete glossary term

Definition at line 251 of file class.ilGlossaryTerm.php.

References $db, $ilDB, ilGlossaryTermReferences\deleteReferencesOfTerm(), and getId().

251  : void
252  {
253  $ilDB = $this->db;
254 
255  // delete term references
257 
258  // delete glossary_term record
259  $ilDB->manipulate("DELETE FROM glossary_term " .
260  " WHERE id = " . $ilDB->quote($this->getId(), "integer"));
261 
262  $this->page_object->delete();
263 
264  // delete flashcard entries
265  $this->event_handler->raise("Modules/Glossary", "deleteTerm", ["term_id" => $this->getId()]);
266  }
static deleteReferencesOfTerm(int $a_term_id)
Delete all references of a term.
+ Here is the call graph for this function:

◆ exportXML()

ilGlossaryTerm::exportXML ( ilXmlWriter  $a_xml_writer,
int  $a_inst 
)

Definition at line 600 of file class.ilGlossaryTerm.php.

References getId(), getLanguage(), getTerm(), IL_INST_ID, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

603  : void {
604  $attrs = array();
605  $attrs["Language"] = $this->getLanguage();
606  $attrs["Id"] = "il_" . IL_INST_ID . "_git_" . $this->getId();
607  $a_xml_writer->xmlStartTag("GlossaryItem", $attrs);
608 
609  $attrs = array();
610  $a_xml_writer->xmlElement("GlossaryTerm", $attrs, $this->getTerm());
611 
612  $a_xml_writer->xmlEndTag("GlossaryItem");
613  }
const IL_INST_ID
Definition: constants.php:40
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:

◆ getFirstLetters()

static ilGlossaryTerm::getFirstLetters ( array  $a_glo_id,
int  $a_tax_node = 0 
)
static

Definition at line 559 of file class.ilGlossaryTerm.php.

References $DIC, $ilDB, $q, ilObjTaxonomy\getSubTreeItems(), and ilObjTaxonomy\getUsageOfObject().

Referenced by ilObjGlossary\getFirstLetters().

562  : array {
563  global $DIC;
564 
565  $ilDB = $DIC->database();
566 
567  // meta glossary
568  if (count($a_glo_id) > 1) {
569  $where = $ilDB->in("glo_id", $a_glo_id, false, "integer");
570  } else {
571  $a_glo_id = current($a_glo_id);
572  $where = " glo_id = " . $ilDB->quote($a_glo_id, "integer") . " ";
573  $in = "";
574  // get all term ids under taxonomy node (if given)
575  if ($a_tax_node > 1) {
576  $tax_ids = ilObjTaxonomy::getUsageOfObject($a_glo_id);
577  if (count($tax_ids) > 0) {
578  $items = ilObjTaxonomy::getSubTreeItems("glo", $a_glo_id, "term", $tax_ids[0], $a_tax_node);
579  $sub_tree_ids = array();
580  foreach ($items as $i) {
581  $sub_tree_ids[] = $i["item_id"];
582  }
583  $in = " AND " . $ilDB->in("id", $sub_tree_ids, false, "integer");
584  }
585  }
586 
587  $where .= $in;
588  }
589 
590  $q = "SELECT DISTINCT " . $ilDB->upper($ilDB->substr("term", 1, 1)) . " let FROM glossary_term WHERE " . $where . " ORDER BY let";
591  $let_set = $ilDB->query($q);
592 
593  $let = array();
594  while ($let_rec = $ilDB->fetchAssoc($let_set)) {
595  $let[$let_rec["let"]] = $let_rec["let"];
596  }
597  return $let;
598  }
static getSubTreeItems(string $a_comp, int $a_obj_id, string $a_item_type, int $a_tax_id, $a_node)
Get all assigned items under a node.
static getUsageOfObject(int $a_obj_id, bool $a_include_titles=false)
global $DIC
Definition: feed.php:28
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getGlossaryId()

ilGlossaryTerm::getGlossaryId ( )

Definition at line 156 of file class.ilGlossaryTerm.php.

References $glo_id.

Referenced by create().

156  : int
157  {
158  return $this->glo_id;
159  }
+ Here is the caller graph for this function:

◆ getId()

ilGlossaryTerm::getId ( )

Definition at line 138 of file class.ilGlossaryTerm.php.

References $id.

Referenced by ilObjGlossaryGUI\addTerm(), create(), delete(), exportXML(), read(), shortenShortText(), and update().

138  : int
139  {
140  return $this->id;
141  }
+ Here is the caller graph for this function:

◆ getImportId()

ilGlossaryTerm::getImportId ( )

Definition at line 187 of file class.ilGlossaryTerm.php.

References $import_id.

187  : string
188  {
189  return $this->import_id;
190  }

◆ getLanguage()

ilGlossaryTerm::getLanguage ( )

Definition at line 177 of file class.ilGlossaryTerm.php.

References $language.

Referenced by exportXML().

177  : string
178  {
179  return $this->language;
180  }
+ Here is the caller graph for this function:

◆ getNumberOfUsages()

static ilGlossaryTerm::getNumberOfUsages ( int  $a_term_id)
static

Definition at line 615 of file class.ilGlossaryTerm.php.

Referenced by ilTermDefinitionEditorGUI\__construct(), ilObjGlossaryGUI\confirmTermDeletion(), ilTermListTableGUI\fillRow(), and ilGlossaryTermGUI\getTabs().

615  : int
616  {
617  return count(self::getUsages($a_term_id));
618  }
+ Here is the caller graph for this function:

◆ getPageObject()

ilGlossaryTerm::getPageObject ( )

Definition at line 217 of file class.ilGlossaryTerm.php.

References $page_object.

218  {
219  return $this->page_object;
220  }
ilGlossaryDefPage $page_object
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getShortText()

ilGlossaryTerm::getShortText ( )

Definition at line 197 of file class.ilGlossaryTerm.php.

References $short_text.

Referenced by create(), and update().

197  : string
198  {
199  return $this->short_text;
200  }
+ Here is the caller graph for this function:

◆ getShortTextDirty()

ilGlossaryTerm::getShortTextDirty ( )

Definition at line 207 of file class.ilGlossaryTerm.php.

References $short_text_dirty.

Referenced by create(), and update().

207  : int
208  {
210  }
+ Here is the caller graph for this function:

◆ getTerm()

ilGlossaryTerm::getTerm ( )

Definition at line 166 of file class.ilGlossaryTerm.php.

References $term.

Referenced by ilObjGlossaryGUI\confirmTermDeletion(), and exportXML().

166  : string
167  {
168  return $this->term;
169  }
+ Here is the caller graph for this function:

◆ getTermList()

static ilGlossaryTerm::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 
)
static

Get all terms for given set of glossary ids.

Definition at line 456 of file class.ilGlossaryTerm.php.

References $DIC, $ilDB, $q, ilObject\_lookupObjectId(), ilObjTaxonomy\getSubTreeItems(), ilObjTaxonomy\getUsageOfObject(), and ilAdvancedMDValues\queryForRecords().

Referenced by ilPCParagraph\autoLinkGlossaries(), ilObjGlossary\autoLinkGlossaryTerms(), ilObjContentObject\autoLinkGlossaryTerms(), ilObjGlossary\cloneObject(), ilObjGlossary\getTermList(), and ilGlossaryExporter\getXmlExportTailDependencies().

465  : array {
466  global $DIC;
467 
468  if (count($a_glo_ref_id) > 1) {
469  $a_glo_id = array_map(static function ($id): int {
471  }, $a_glo_ref_id);
472  } else {
473  $a_glo_id = ilObject::_lookupObjectId(current($a_glo_ref_id));
474  }
475  $ilDB = $DIC->database();
476 
477  $join = $in = "";
478 
479  $terms = array();
480 
481  // get all term ids under taxonomy node (if given)
482  if ($a_tax_node > 1) {
483  $tax_ids = ilObjTaxonomy::getUsageOfObject($a_glo_id);
484  if (count($tax_ids) > 0) {
485  $items = ilObjTaxonomy::getSubTreeItems("glo", $a_glo_id, "term", $tax_ids[0], $a_tax_node);
486  $sub_tree_ids = array();
487  foreach ($items as $i) {
488  $sub_tree_ids[] = $i["item_id"];
489  }
490  $in = " AND " . $ilDB->in("gt.id", $sub_tree_ids, false, "integer");
491  }
492  }
493 
494  if ($a_def != "") {
495  // meta glossary?
496  if (is_array($a_glo_id)) {
497  $glo_where = $ilDB->in("page_object.parent_id", $a_glo_id, false, "integer");
498  } else {
499  $glo_where = " page_object.parent_id = " . $ilDB->quote($a_glo_id, "integer");
500  }
501 
502  $join = " JOIN page_object ON (" .
503  $glo_where .
504  " AND page_object.parent_type = " . $ilDB->quote("term", "text") .
505  " AND page_object.page_id = gt.id" .
506  " AND " . $ilDB->like("page_object.content", "text", "%" . $a_def . "%") .
507  ")";
508  }
509 
510  $searchterm = (!empty($searchterm))
511  ? " AND " . $ilDB->like("term", "text", "%" . $searchterm . "%") . " "
512  : "";
513 
514  if ($a_first_letter != "") {
515  $searchterm .= " AND " . $ilDB->upper($ilDB->substr("term", 1, 1)) . " = " . $ilDB->upper($ilDB->quote($a_first_letter, "text")) . " ";
516  }
517 
518  // include references
519  $where_glo_id_or = "";
520  if ($a_include_references) {
521  $join .= " LEFT JOIN glo_term_reference tr ON (gt.id = tr.term_id) ";
522  if (is_array($a_glo_id)) {
523  $where_glo_id_or = " OR " . $ilDB->in("tr.glo_id", $a_glo_id, false, "integer");
524  } else {
525  $where_glo_id_or = " OR tr.glo_id = " . $ilDB->quote($a_glo_id, "integer");
526  }
527  }
528 
529  // meta glossary
530  if (is_array($a_glo_id)) {
531  $where = "(" . $ilDB->in("gt.glo_id", $a_glo_id, false, "integer") . $where_glo_id_or . ")";
532  } else {
533  $where = "(gt.glo_id = " . $ilDB->quote($a_glo_id, "integer") . $where_glo_id_or . ")";
534  }
535 
536  $where .= $in;
537 
538 
539  $q = "SELECT DISTINCT(gt.term), gt.id, gt.glo_id, gt.language, gt.short_text, gt.short_text_dirty FROM glossary_term gt " .
540  $join . " WHERE " . $where . $searchterm . " ORDER BY gt.term, gt.id";
541 
542  $term_set = $ilDB->query($q);
543  $glo_ids = array();
544  while ($term_rec = $ilDB->fetchAssoc($term_set)) {
545  $terms[] = array("term" => $term_rec["term"],
546  "language" => $term_rec["language"], "id" => $term_rec["id"], "glo_id" => $term_rec["glo_id"],
547  "short_text" => strip_tags((string) $term_rec["short_text"], "<br>"),
548  "short_text_dirty" => $term_rec["short_text_dirty"]);
549  $glo_ids[] = $term_rec["glo_id"];
550  }
551 
552  // add advanced metadata
553  if (($a_add_amet_fields || is_array($a_amet_filter)) && count($a_glo_ref_id) == 1) {
554  $terms = ilAdvancedMDValues::queryForRecords(current($a_glo_ref_id), "glo", "term", $glo_ids, "term", $terms, "glo_id", "id", $a_amet_filter);
555  }
556  return $terms;
557  }
static getSubTreeItems(string $a_comp, int $a_obj_id, string $a_item_type, int $a_tax_id, $a_node)
Get all assigned items under a node.
static getUsageOfObject(int $a_obj_id, bool $a_include_titles=false)
global $DIC
Definition: feed.php:28
static _lookupObjectId(int $ref_id)
static queryForRecords(int $adv_rec_obj_ref_id, string $adv_rec_obj_type, string $adv_rec_obj_subtype, array $a_obj_id, string $a_subtype, array $a_records, string $a_obj_id_key, string $a_obj_subid_key, array $a_amet_filter=null)
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTermsOfGlossary()

static ilGlossaryTerm::getTermsOfGlossary ( int  $a_glo_id)
static
Returns
int[] term ids

Definition at line 713 of file class.ilGlossaryTerm.php.

References $DIC, $ilDB, and ILIAS\Repository\int().

Referenced by ilObjGlossaryGUI\initSettingsForm().

715  : array {
716  global $DIC;
717 
718  $ilDB = $DIC->database();
719 
720  $set = $ilDB->query(
721  "SELECT id FROM glossary_term WHERE " .
722  " glo_id = " . $ilDB->quote($a_glo_id, "integer")
723  );
724  $ids = array();
725  while ($rec = $ilDB->fetchAssoc($set)) {
726  $ids[] = (int) $rec["id"];
727  }
728  return $ids;
729  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUsages()

static ilGlossaryTerm::getUsages ( int  $a_term_id)
static

Definition at line 620 of file class.ilGlossaryTerm.php.

References $glo_id, ilInternalLink\_getSourcesOfTarget(), and ilGlossaryTermReferences\lookupReferencesOfTerm().

Referenced by ilTermUsagesTableGUI\getItems().

620  : array
621  {
622  $usages = (ilInternalLink::_getSourcesOfTarget("git", $a_term_id, 0));
623 
625  $usages["glo:termref:" . $glo_id . ":-"] = array(
626  "type" => "glo:termref",
627  "id" => $glo_id,
628  "lang" => "-"
629  );
630  }
631 
632  return $usages;
633  }
static lookupReferencesOfTerm(int $a_term_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilGlossaryTerm::read ( )

Definition at line 59 of file class.ilGlossaryTerm.php.

References $db, $ilDB, $q, getId(), setGlossaryId(), setImportId(), setLanguage(), setShortText(), setShortTextDirty(), and setTerm().

Referenced by __construct().

59  : void
60  {
61  $ilDB = $this->db;
62 
63  $q = "SELECT * FROM glossary_term WHERE id = " .
64  $ilDB->quote($this->getId(), "integer");
65  $term_set = $ilDB->query($q);
66  $term_rec = $ilDB->fetchAssoc($term_set);
67 
68  $this->setTerm((string) $term_rec["term"]);
69  $this->setImportId((string) $term_rec["import_id"]);
70  $this->setLanguage((string) $term_rec["language"]);
71  $this->setGlossaryId((int) $term_rec["glo_id"]);
72  $this->setShortText((string) $term_rec["short_text"]);
73  $this->setShortTextDirty((int) $term_rec["short_text_dirty"]);
74 
75  $this->page_object = new ilGlossaryDefPage($this->getId());
76  }
setShortTextDirty(int $a_val)
setShortText(string $a_text)
setTerm(string $a_term)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLanguage(string $a_language)
$q
Definition: shib_logout.php:21
setGlossaryId(int $a_glo_id)
setImportId(string $a_import_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setGlossary()

ilGlossaryTerm::setGlossary ( ilObjGlossary  $a_glossary)

Definition at line 143 of file class.ilGlossaryTerm.php.

References ilObject\getId(), and setGlossaryId().

Referenced by ilObjGlossaryGUI\addTerm().

145  : void {
146  $this->glossary = $a_glossary;
147  $this->setGlossaryId($a_glossary->getId());
148  }
setGlossaryId(int $a_glo_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setGlossaryId()

ilGlossaryTerm::setGlossaryId ( int  $a_glo_id)

Definition at line 150 of file class.ilGlossaryTerm.php.

Referenced by read(), and setGlossary().

152  : void {
153  $this->glo_id = $a_glo_id;
154  }
+ Here is the caller graph for this function:

◆ setId()

ilGlossaryTerm::setId ( int  $a_id)

set glossary term id (= glossary item id)

Definition at line 133 of file class.ilGlossaryTerm.php.

Referenced by create().

133  : void
134  {
135  $this->id = $a_id;
136  }
+ Here is the caller graph for this function:

◆ setImportId()

ilGlossaryTerm::setImportId ( string  $a_import_id)

Definition at line 182 of file class.ilGlossaryTerm.php.

Referenced by read().

182  : void
183  {
184  $this->import_id = $a_import_id;
185  }
+ Here is the caller graph for this function:

◆ setLanguage()

ilGlossaryTerm::setLanguage ( string  $a_language)

Definition at line 171 of file class.ilGlossaryTerm.php.

References ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by ilObjGlossaryGUI\addTerm(), and read().

173  : void {
174  $this->language = $a_language;
175  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setShortText()

ilGlossaryTerm::setShortText ( string  $a_text)

Definition at line 192 of file class.ilGlossaryTerm.php.

References shortenShortText().

Referenced by read(), and updateShortText().

192  : void
193  {
194  $this->short_text = $this->shortenShortText($a_text);
195  }
shortenShortText(string $text)
Shorten short text.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setShortTextDirty()

ilGlossaryTerm::setShortTextDirty ( int  $a_val)

Definition at line 202 of file class.ilGlossaryTerm.php.

Referenced by read(), and updateShortText().

202  : void
203  {
204  $this->short_text_dirty = $a_val;
205  }
+ Here is the caller graph for this function:

◆ setShortTextsDirty()

static ilGlossaryTerm::setShortTextsDirty ( int  $a_glo_id)
static

Set all short texts of glossary dirty (e.g.

if length is changed in settings)

Definition at line 336 of file class.ilGlossaryTerm.php.

References $DIC, and $ilDB.

Referenced by ilObjGlossaryGUI\saveProperties().

336  : void
337  {
338  global $DIC;
339 
340  $ilDB = $DIC->database();
341 
342  $term_ids = self::getTermsOfGlossary($a_glo_id);
343 
344  foreach ($term_ids as $term_id) {
345  $ilDB->manipulate(
346  "UPDATE glossary_term SET " .
347  " short_text_dirty = " . $ilDB->quote(1, "integer") .
348  " WHERE id = " . $ilDB->quote($term_id, "integer")
349  );
350  }
351  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ setShortTextsDirtyGlobally()

static ilGlossaryTerm::setShortTextsDirtyGlobally ( )
static

Set short texts dirty (for all glossaries)

Definition at line 356 of file class.ilGlossaryTerm.php.

References $DIC, and $ilDB.

Referenced by ilObjAdvancedEditingGUI\initGeneralPageSettingsForm().

356  : void
357  {
358  global $DIC;
359 
360  $ilDB = $DIC->database();
361 
362  $ilDB->manipulate(
363  "UPDATE glossary_term SET " .
364  " short_text_dirty = " . $ilDB->quote(1, "integer")
365  );
366  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ setTerm()

ilGlossaryTerm::setTerm ( string  $a_term)

Definition at line 161 of file class.ilGlossaryTerm.php.

Referenced by ilObjGlossaryGUI\addTerm(), and read().

161  : void
162  {
163  $this->term = $a_term;
164  }
+ Here is the caller graph for this function:

◆ shortenShortText()

ilGlossaryTerm::shortenShortText ( string  $text)

Shorten short text.

Definition at line 286 of file class.ilGlossaryTerm.php.

References getId(), ilObjGlossary\lookupSnippetLength(), and ilStr\shortenTextExtended().

Referenced by setShortText(), and updateShortText().

286  : string
287  {
288  $a_length = 196;
289 
290  if ($this->getId() > 0) {
291  $glo_id = self::_lookGlossaryID($this->getId());
292  $snippet_length = ilObjGlossary::lookupSnippetLength($glo_id);
293  if ($snippet_length > 0) {
294  $a_length = $snippet_length;
295  }
296  }
297 
298  $text = str_replace("<br/>", "<br>", $text);
299  $text = strip_tags($text, "<br>");
300  $offset = 0;
301  if (is_int(strpos(substr($text, $a_length - 16 - 5, 10), "[tex]"))) {
302  $offset = 5;
303  }
304  $short = ilStr::shortenTextExtended($text, $a_length - 16 + $offset, true);
305 
306  // make short text longer, if tex end tag is missing
307  $ltexs = strrpos($short, "[tex]");
308  $ltexe = strrpos($short, "[/tex]");
309  if ($ltexs > $ltexe) {
310  $ltexe = strpos($text, "[/tex]", $ltexs);
311  if ($ltexe > 0) {
312  $text = ilStr::shortenTextExtended($text, $ltexe + 6, true);
313  }
314  }
315 
316  $short = ilStr::shortenTextExtended($text, $a_length, true);
317 
318  return $short;
319  }
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
static lookupSnippetLength(int $a_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilGlossaryTerm::update ( )

Definition at line 268 of file class.ilGlossaryTerm.php.

References $db, $ilDB, getId(), getShortText(), and getShortTextDirty().

Referenced by updateShortText().

268  : void
269  {
270  $ilDB = $this->db;
271 
272  $ilDB->manipulate("UPDATE glossary_term SET " .
273  " glo_id = " . $ilDB->quote($this->getGlossaryId(), "integer") . ", " .
274  " term = " . $ilDB->quote($this->getTerm(), "text") . ", " .
275  " import_id = " . $ilDB->quote($this->getImportId(), "text") . ", " .
276  " language = " . $ilDB->quote($this->getLanguage(), "text") . ", " .
277  " last_update = " . $ilDB->now() . ", " .
278  " short_text = " . $ilDB->quote($this->getShortText(), "text") . ", " .
279  " short_text_dirty = " . $ilDB->quote($this->getShortTextDirty(), "integer") . " " .
280  " WHERE id = " . $ilDB->quote($this->getId(), "integer"));
281  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateShortText()

ilGlossaryTerm::updateShortText ( )

Definition at line 321 of file class.ilGlossaryTerm.php.

References setShortText(), setShortTextDirty(), shortenShortText(), and update().

321  : void
322  {
323  $this->page_object->buildDom();
324  $text = $this->page_object->getFirstParagraphText();
325  $short = $this->shortenShortText($text);
326 
327  $this->setShortText($short);
328  $this->setShortTextDirty(0);
329  $this->update();
330  }
setShortTextDirty(int $a_val)
setShortText(string $a_text)
shortenShortText(string $text)
Shorten short text.
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilGlossaryTerm::$db
protected

Definition at line 26 of file class.ilGlossaryTerm.php.

Referenced by create(), delete(), read(), and update().

◆ $event_handler

ilAppEventHandler ilGlossaryTerm::$event_handler
protected

Definition at line 38 of file class.ilGlossaryTerm.php.

◆ $glo_id

int ilGlossaryTerm::$glo_id = 0

Definition at line 33 of file class.ilGlossaryTerm.php.

Referenced by getGlossaryId(), and getUsages().

◆ $glossary

ilObjGlossary ilGlossaryTerm::$glossary

Definition at line 30 of file class.ilGlossaryTerm.php.

◆ $id

int ilGlossaryTerm::$id = 0

Definition at line 29 of file class.ilGlossaryTerm.php.

Referenced by getId().

◆ $import_id

string ilGlossaryTerm::$import_id = ""

Definition at line 34 of file class.ilGlossaryTerm.php.

Referenced by getImportId().

◆ $language

string ilGlossaryTerm::$language = ""

Definition at line 32 of file class.ilGlossaryTerm.php.

Referenced by getLanguage().

◆ $lng

ilLanguage ilGlossaryTerm::$lng

Definition at line 27 of file class.ilGlossaryTerm.php.

Referenced by __construct().

◆ $page_object

ilGlossaryDefPage ilGlossaryTerm::$page_object

Definition at line 37 of file class.ilGlossaryTerm.php.

Referenced by getPageObject().

◆ $short_text

string ilGlossaryTerm::$short_text = ""

Definition at line 35 of file class.ilGlossaryTerm.php.

Referenced by getShortText().

◆ $short_text_dirty

int ilGlossaryTerm::$short_text_dirty = 0

Definition at line 36 of file class.ilGlossaryTerm.php.

Referenced by getShortTextDirty().

◆ $term

string ilGlossaryTerm::$term = ""

Definition at line 31 of file class.ilGlossaryTerm.php.

Referenced by getTerm().

◆ $tpl

ilGlobalTemplateInterface ilGlossaryTerm::$tpl

Definition at line 28 of file class.ilGlossaryTerm.php.

Referenced by __construct().

◆ $type

string ilGlossaryTerm::$type
protected

Definition at line 25 of file class.ilGlossaryTerm.php.


The documentation for this class was generated from the following file: