ILIAS  release_7 Revision v7.30-3-g800a261c036
ilGlossaryTerm Class Reference

Glossary terms. More...

+ Collaboration diagram for ilGlossaryTerm:

Public Member Functions

 __construct ($a_id=0)
 Constructor public. More...
 
 read ()
 read glossary term data More...
 
 setId ($a_id)
 set glossary term id (= glossary item id) More...
 
 getId ()
 get term id (= glossary item id) More...
 
 setGlossary (&$a_glossary)
 set glossary object More...
 
 setGlossaryId ($a_glo_id)
 set glossary id More...
 
 getGlossaryId ()
 get glossary id More...
 
 setTerm ($a_term)
 set term More...
 
 getTerm ()
 get term More...
 
 setLanguage ($a_language)
 set language More...
 
 getLanguage ()
 get language More...
 
 setImportId ($a_import_id)
 set import id More...
 
 getImportId ()
 get import id More...
 
 create ()
 create new glossary term More...
 
 delete ()
 delete glossary term (and all its definition objects) More...
 
 update ()
 update glossary term More...
 
 exportXML (&$a_xml_writer, $a_inst)
 export xml More...
 

Static Public Member Functions

static _getIdForImportId ($a_import_id)
 get current term id for import id (static) More...
 
static _exists ($a_id)
 checks wether a glossary term with specified id exists or not More...
 
static _lookGlossaryID ($term_id)
 get glossary id form term id More...
 
static _lookGlossaryTerm ($term_id)
 get glossary term More...
 
static _lookLanguage ($term_id)
 lookup term language More...
 
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. More...
 
static getFirstLetters ($a_glo_id, $a_tax_node=0)
 Get all terms for given set of glossary ids. More...
 
static getNumberOfUsages ($a_term_id)
 Get number of usages. More...
 
static getUsages ($a_term_id)
 Get number of usages. More...
 
static _copyTerm ($a_term_id, $a_glossary_id)
 Copy a term to a glossary. More...
 
static getTermsOfGlossary ($a_glo_id)
 Get terms of glossary. More...
 

Data Fields

 $lng
 
 $tpl
 
 $id
 
 $glossary
 
 $term
 
 $language
 
 $glo_id
 
 $import_id
 

Protected Attributes

 $db
 

Detailed Description

Glossary terms.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e

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

Constructor & Destructor Documentation

◆ __construct()

ilGlossaryTerm::__construct (   $a_id = 0)

Constructor public.

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

References $DIC, $lng, $tpl, and read().

32  {
33  global $DIC;
34 
35  $this->db = $DIC->database();
36  $lng = $DIC->language();
37  $tpl = $DIC["tpl"];
38 
39  $this->lng = $lng;
40  $this->tpl = $tpl;
41 
42  $this->id = $a_id;
43  $this->type = "term";
44  if ($a_id != 0) {
45  $this->read();
46  }
47  }
global $DIC
Definition: goto.php:24
read()
read glossary term data
+ Here is the call graph for this function:

Member Function Documentation

◆ _copyTerm()

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

Copy a term to a glossary.

Parameters

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

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

Referenced by ilObjGlossary\cloneObject(), ilGlossaryAct\copyTerm(), ilObjGlossaryGUI\pasteTerms(), and ilSCORM2004Page\performAutomaticModifications().

574  {
575  $old_term = new ilGlossaryTerm($a_term_id);
576 
577  // copy the term
578  $new_term = new ilGlossaryTerm();
579  $new_term->setTerm($old_term->getTerm());
580  $new_term->setLanguage($old_term->getLanguage());
581  $new_term->setGlossaryId($a_glossary_id);
582  $new_term->create();
583 
584  // copy the definitions
585  $def_list = ilGlossaryDefinition::getDefinitionList($a_term_id);
586  foreach ($def_list as $def) {
587  $old_def = new ilGlossaryDefinition($def["id"]);
588 
589  $new_def = new ilGlossaryDefinition();
590  $new_def->setShortText($old_def->getShortText());
591  $new_def->setNr($old_def->getNr());
592  $new_def->setTermId($new_term->getId());
593  $new_def->create();
594 
595  // copy meta data
596  $md = new ilMD(
597  $old_term->getGlossaryId(),
598  $old_def->getPageObject()->getId(),
599  $old_def->getPageObject()->getParentType()
600  );
601  $new_md = $md->cloneMD(
602  $a_glossary_id,
603  $new_def->getPageObject()->getId(),
604  $old_def->getPageObject()->getParentType()
605  );
606 
607 
608  $new_page = $new_def->getPageObject();
609  $old_def->getPageObject()->copy($new_page->getId(), $new_page->getParentType(), $new_page->getParentId(), true);
610 
611  // page content
612  //$new_def->getPageObject()->setXMLContent($old_def->getPageObject()->copyXmlContent(true));
613  //$new_def->getPageObject()->buildDom();
614  //$new_def->getPageObject()->update();
615  }
616 
617  // adv metadata
618  $old_recs = ilAdvancedMDRecord::_getSelectedRecordsByObject("glo", $old_term->getGlossaryId(), "term");
619  $new_recs = ilAdvancedMDRecord::_getSelectedRecordsByObject("glo", $a_glossary_id, "term");
620  foreach ($old_recs as $old_record_obj) {
621  reset($new_recs);
622  foreach ($new_recs as $new_record_obj) {
623  if ($old_record_obj->getRecordId() == $new_record_obj->getRecordId()) {
624  foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($old_record_obj->getRecordId()) as $def) {
625  // now we need to copy $def->getFieldId() values from old term to new term
626  // how?
627  // clone values
628 
629  $source_primary = array("obj_id" => array("integer", $old_term->getGlossaryId()));
630  $source_primary["sub_type"] = array("text", "term");
631  $source_primary["sub_id"] = array("integer", $old_term->getId());
632  $source_primary["field_id"] = array("integer", $def->getFieldId());
633  $target_primary = array("obj_id" => array("integer", $new_term->getGlossaryId()));
634  $target_primary["sub_type"] = array("text", "term");
635  $target_primary["sub_id"] = array("integer", $new_term->getId());
636 
637  ilADTFactory::getInstance()->initActiveRecordByType();
639  "adv_md_values",
640  array(
641  "obj_id" => "integer",
642  "sub_type" => "text",
643  "sub_id" => "integer",
644  "field_id" => "integer"
645  ),
646  $source_primary,
647  $target_primary,
648  array("disabled" => "integer")
649  );
650  }
651  }
652  }
653  }
654 
655 
656  return $new_term->getId();
657  }
& cloneMD($a_rbac_id, $a_obj_id, $a_obj_type)
Definition: class.ilMD.php:326
static getDefinitionList($a_term_id)
static
Glossary terms.
static getInstance()
Get singleton.
static cloneByPrimary($a_table, array $a_primary_def, array $a_source_primary, array $a_target_primary, array $a_additional=null)
Clone values by (partial) primary key.
static _getSelectedRecordsByObject($a_obj_type, $a_ref_id, $a_sub_type="")
Get selected records by object.
Class ilGlossaryDefinition.
static getInstancesByRecordId($a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _exists()

static ilGlossaryTerm::_exists (   $a_id)
static

checks wether a glossary term with specified id exists or not

Parameters
int$idid
Returns
boolean true, if glossary term exists

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

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

Referenced by ilInternalLink\_exists(), and ilLinksTableGUI\fillRow().

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

◆ _getIdForImportId()

static ilGlossaryTerm::_getIdForImportId (   $a_import_id)
static

get current term id for import id (static)

Parameters
int$a_import_idimport id
Returns
int id

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

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

Referenced by ilInternalLink\_getIdForImportId().

75  {
76  global $DIC;
77 
78  $ilDB = $DIC->database();
79 
80  if ($a_import_id == "") {
81  return 0;
82  }
83 
84  $q = "SELECT * FROM glossary_term WHERE import_id = " .
85  $ilDB->quote($a_import_id, "text") .
86  " ORDER BY create_date DESC";
87  $term_set = $ilDB->query($q);
88  while ($term_rec = $ilDB->fetchAssoc($term_set)) {
89  $glo_id = ilGlossaryTerm::_lookGlossaryID($term_rec["id"]);
90 
91  $ref_ids = ilObject::_getAllReferences($glo_id); // will be 0 if import of lm is in progress (new import)
92  if (count($ref_ids) == 0 || ilObject::_hasUntrashedReference($glo_id)) {
93  return $term_rec["id"];
94  }
95  }
96 
97  return 0;
98  }
static _hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
static _getAllReferences($a_id)
get all reference ids of object
global $DIC
Definition: goto.php:24
static _lookGlossaryID($term_id)
get glossary id form term id
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookGlossaryID()

◆ _lookGlossaryTerm()

static ilGlossaryTerm::_lookGlossaryTerm (   $term_id)
static

get glossary term

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

References $DIC, $ilDB, and $query.

Referenced by SurveyQuestion\addInternalLink(), ilObjGlossaryGUI\copyTerms(), ilLinksTableGUI\fillRow(), ilTermUsagesTableGUI\fillRow(), ilMediaPoolPageUsagesTableGUI\fillRow(), ilMediaObjectUsagesTableGUI\fillRow(), ilObjGlossary\getAdvMDSubItemTitle(), ilSCORM2004Asset\getGlossaryTermIds(), ilObjGlossarySubItemListGUI\getHTML(), ilObjGlossaryGUI\getTemplate(), ilLinkInputGUI\getTranslatedValue(), ilObjGlossaryGUI\referenceTerms(), SurveyQuestion\setMaterial(), and ilLMPresentationGUI\showPrintView().

323  {
324  global $DIC;
325 
326  $ilDB = $DIC->database();
327 
328  $query = "SELECT * FROM glossary_term WHERE id = " .
329  $ilDB->quote($term_id, "integer");
330  $obj_set = $ilDB->query($query);
331  $obj_rec = $ilDB->fetchAssoc($obj_set);
332 
333  return $obj_rec["term"];
334  }
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _lookLanguage()

static ilGlossaryTerm::_lookLanguage (   $term_id)
static

lookup term language

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

References $DIC, $ilDB, and $query.

Referenced by ilGlossaryDefinition\createMetaData().

340  {
341  global $DIC;
342 
343  $ilDB = $DIC->database();
344 
345  $query = "SELECT * FROM glossary_term WHERE id = " .
346  $ilDB->quote($term_id, "integer");
347  $obj_set = $ilDB->query($query);
348  $obj_rec = $ilDB->fetchAssoc($obj_set);
349 
350  return $obj_rec["language"];
351  }
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ Here is the caller graph for this function:

◆ create()

ilGlossaryTerm::create ( )

create new glossary term

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

References $db, $ilDB, getImportId(), language(), and setId().

248  {
249  $ilDB = $this->db;
250 
251  $this->setId($ilDB->nextId("glossary_term"));
252  $ilDB->manipulate("INSERT INTO glossary_term (id, glo_id, term, language, import_id, create_date, last_update)" .
253  " VALUES (" .
254  $ilDB->quote($this->getId(), "integer") . ", " .
255  $ilDB->quote($this->getGlossaryId(), "integer") . ", " .
256  $ilDB->quote($this->term, "text") . ", " .
257  $ilDB->quote($this->language, "text") . "," .
258  $ilDB->quote($this->getImportId(), "text") . "," .
259  $ilDB->now() . ", " .
260  $ilDB->now() . ")");
261  }
getImportId()
get import id
setId($a_id)
set glossary term id (= glossary item id)
global $ilDB
language()
Definition: language.php:2
+ Here is the call graph for this function:

◆ delete()

ilGlossaryTerm::delete ( )

delete glossary term (and all its definition objects)

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

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

268  {
269  $ilDB = $this->db;
270 
272  foreach ($defs as $def) {
273  $def_obj = new ilGlossaryDefinition($def["id"]);
274  $def_obj->delete();
275  }
276 
277  // delete term references
279 
280  // delete glossary_term record
281  $ilDB->manipulate("DELETE FROM glossary_term " .
282  " WHERE id = " . $ilDB->quote($this->getId(), "integer"));
283  }
static getDefinitionList($a_term_id)
static
getId()
get term id (= glossary item id)
Class ilGlossaryDefinition.
static deleteReferencesOfTerm($a_term_id)
Delete all references of a term.
global $ilDB
+ Here is the call graph for this function:

◆ exportXML()

ilGlossaryTerm::exportXML ( $a_xml_writer,
  $a_inst 
)

export xml

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

References ilGlossaryDefinition\getDefinitionList(), getId(), getLanguage(), getTerm(), and IL_INST_ID.

516  {
517  $attrs = array();
518  $attrs["Language"] = $this->getLanguage();
519  $attrs["Id"] = "il_" . IL_INST_ID . "_git_" . $this->getId();
520  $a_xml_writer->xmlStartTag("GlossaryItem", $attrs);
521 
522  $attrs = array();
523  $a_xml_writer->xmlElement("GlossaryTerm", $attrs, $this->getTerm());
524 
526 
527  foreach ($defs as $def) {
528  $definition = new ilGlossaryDefinition($def["id"]);
529  $definition->exportXML($a_xml_writer, $a_inst);
530  }
531 
532  $a_xml_writer->xmlEndTag("GlossaryItem");
533  }
static getDefinitionList($a_term_id)
static
getId()
get term id (= glossary item id)
const IL_INST_ID
Definition: constants.php:38
getLanguage()
get language
Class ilGlossaryDefinition.
+ Here is the call graph for this function:

◆ getFirstLetters()

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

Get all terms for given set of glossary ids.

Parameters
integer/arrayarray of glossary ids for meta glossaries
stringsearchstring
stringfirst letter
Returns
array array of terms

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

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

Referenced by ilObjGlossary\getFirstLetters().

473  {
474  global $DIC;
475 
476  $ilDB = $DIC->database();
477 
478  $terms = array();
479 
480  // meta glossary
481  if (is_array($a_glo_id)) {
482  $where = $ilDB->in("glo_id", $a_glo_id, false, "integer");
483  } else {
484  $where = " glo_id = " . $ilDB->quote($a_glo_id, "integer") . " ";
485 
486  // get all term ids under taxonomy node (if given)
487  if ($a_tax_node > 1) {
488  $tax_ids = ilObjTaxonomy::getUsageOfObject($a_glo_id);
489  if (count($tax_ids) > 0) {
490  $items = ilObjTaxonomy::getSubTreeItems("glo", $a_glo_id, "term", $tax_ids[0], $a_tax_node);
491  $sub_tree_ids = array();
492  foreach ($items as $i) {
493  $sub_tree_ids[] = $i["item_id"];
494  }
495  $in = " AND " . $ilDB->in("id", $sub_tree_ids, false, "integer");
496  }
497  }
498 
499  $where .= $in;
500  }
501 
502  $q = "SELECT DISTINCT " . $ilDB->upper($ilDB->substr("term", 1, 1)) . " let FROM glossary_term WHERE " . $where . " ORDER BY let";
503  $let_set = $ilDB->query($q);
504 
505  $lets = array();
506  while ($let_rec = $ilDB->fetchAssoc($let_set)) {
507  $let[$let_rec["let"]] = $let_rec["let"];
508  }
509  return $let;
510  }
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
global $DIC
Definition: goto.php:24
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
global $ilDB
static getSubTreeItems($a_comp, $a_obj_id, $a_item_type, $a_tax_id, $a_node)
Get all assigned items under a node.
$i
Definition: metadata.php:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getGlossaryId()

ilGlossaryTerm::getGlossaryId ( )

get glossary id

Returns
int glossary id

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

References $glo_id.

179  {
180  return $this->glo_id;
181  }

◆ getId()

ilGlossaryTerm::getId ( )

get term id (= glossary item id)

Returns
int glossary term id

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

References $id.

Referenced by delete(), exportXML(), and update().

146  {
147  return $this->id;
148  }
+ Here is the caller graph for this function:

◆ getImportId()

ilGlossaryTerm::getImportId ( )

get import id

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

References $import_id.

Referenced by create().

239  {
240  return $this->import_id;
241  }
+ Here is the caller graph for this function:

◆ getLanguage()

ilGlossaryTerm::getLanguage ( )

get language

Returns
string two letter language code

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

References $language.

Referenced by exportXML().

221  {
222  return $this->language;
223  }
+ Here is the caller graph for this function:

◆ getNumberOfUsages()

static ilGlossaryTerm::getNumberOfUsages (   $a_term_id)
static

Get number of usages.

Parameters
intterm id
Returns
int number of usages

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

References getUsages().

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

542  {
543  return count(ilGlossaryTerm::getUsages($a_term_id));
544  }
static getUsages($a_term_id)
Get number of usages.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTerm()

ilGlossaryTerm::getTerm ( )

get term

Returns
string term

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

References $term.

Referenced by exportXML().

201  {
202  return $this->term;
203  }
+ Here is the caller graph for this function:

◆ getTermList()

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

Get all terms for given set of glossary ids.

Parameters
integer/arrayarray of glossary ids for meta glossaries
stringsearchstring
stringfirst letter
Returns
array array of terms

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

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

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

370  {
371  global $DIC;
372 
373  if (is_array($a_glo_ref_id)) {
374  $a_glo_id = array_map(function ($id) {
376  }, $a_glo_ref_id);
377  } else {
378  $a_glo_id = ilObject::_lookupObjectId($a_glo_ref_id);
379  }
380  $ilDB = $DIC->database();
381 
382  $join = $in = "";
383 
384  $terms = array();
385 
386  // get all term ids under taxonomy node (if given)
387  if ($a_tax_node > 1) {
388  $tax_ids = ilObjTaxonomy::getUsageOfObject($a_glo_id);
389  if (count($tax_ids) > 0) {
390  $items = ilObjTaxonomy::getSubTreeItems("glo", $a_glo_id, "term", $tax_ids[0], $a_tax_node);
391  $sub_tree_ids = array();
392  foreach ($items as $i) {
393  $sub_tree_ids[] = $i["item_id"];
394  }
395  $in = " AND " . $ilDB->in("gt.id", $sub_tree_ids, false, "integer");
396  }
397  }
398 
399  if ($a_def != "") {
400  // meta glossary?
401  if (is_array($a_glo_id)) {
402  $glo_where = $ilDB->in("page_object.parent_id", $a_glo_id, false, "integer");
403  } else {
404  $glo_where = " page_object.parent_id = " . $ilDB->quote($a_glo_id, "integer");
405  }
406 
407  $join = " JOIN glossary_definition gd ON (gd.term_id = gt.id)" .
408  " JOIN page_object ON (" .
409  $glo_where .
410  " AND page_object.parent_type = " . $ilDB->quote("gdf", "text") .
411  " AND page_object.page_id = gd.id" .
412  " AND " . $ilDB->like("page_object.content", "text", "%" . $a_def . "%") .
413  ")";
414  }
415 
416  $searchterm = (!empty($searchterm))
417  ? " AND " . $ilDB->like("term", "text", "%" . $searchterm . "%") . " "
418  : "";
419 
420  if ($a_first_letter != "") {
421  $searchterm .= " AND " . $ilDB->upper($ilDB->substr("term", 1, 1)) . " = " . $ilDB->upper($ilDB->quote($a_first_letter, "text")) . " ";
422  }
423 
424  // include references
425  $where_glo_id_or = "";
426  if ($a_include_references) {
427  $join .= " LEFT JOIN glo_term_reference tr ON (gt.id = tr.term_id) ";
428  if (is_array($a_glo_id)) {
429  $where_glo_id_or = " OR " . $ilDB->in("tr.glo_id", $a_glo_id, false, "integer");
430  } else {
431  $where_glo_id_or = " OR tr.glo_id = " . $ilDB->quote($a_glo_id, "integer");
432  }
433  }
434 
435  // meta glossary
436  if (is_array($a_glo_id)) {
437  $where = "(" . $ilDB->in("gt.glo_id", $a_glo_id, false, "integer") . $where_glo_id_or . ")";
438  } else {
439  $where = "(gt.glo_id = " . $ilDB->quote($a_glo_id, "integer") . $where_glo_id_or . ")";
440  }
441 
442  $where .= $in;
443 
444 
445  $q = "SELECT DISTINCT(gt.term), gt.id, gt.glo_id, gt.language FROM glossary_term gt " . $join . " WHERE " . $where . $searchterm . " ORDER BY term";
446 
447  //echo $q; exit;
448 
449  $term_set = $ilDB->query($q);
450  $glo_ids = array();
451  while ($term_rec = $ilDB->fetchAssoc($term_set)) {
452  $terms[] = array("term" => $term_rec["term"],
453  "language" => $term_rec["language"], "id" => $term_rec["id"], "glo_id" => $term_rec["glo_id"]);
454  $glo_ids[] = $term_rec["glo_id"];
455  }
456 
457  // add advanced metadata
458  if (($a_add_amet_fields || is_array($a_amet_filter)) && !is_array($a_glo_ref_id)) {
459  $terms = ilAdvancedMDValues::queryForRecords($a_glo_ref_id, "glo", "term", $glo_ids, "term", $terms, "glo_id", "id", $a_amet_filter);
460  }
461  return $terms;
462  }
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
static _lookupObjectId($a_ref_id)
lookup object id
global $DIC
Definition: goto.php:24
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
global $ilDB
static getSubTreeItems($a_comp, $a_obj_id, $a_item_type, $a_tax_id, $a_node)
Get all assigned items under a node.
static queryForRecords($adv_rec_obj_ref_id, $adv_rec_obj_type, $adv_rec_obj_subtype, $a_obj_id, $a_subtype, $a_records, $a_obj_id_key, $a_obj_subid_key, array $a_amet_filter=null)
Query data for given object records.
$i
Definition: metadata.php:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTermsOfGlossary()

static ilGlossaryTerm::getTermsOfGlossary (   $a_glo_id)
static

Get terms of glossary.

Parameters

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

References $DIC, and $ilDB.

Referenced by ilGlossaryDefinition\setShortTextsDirty().

666  {
667  global $DIC;
668 
669  $ilDB = $DIC->database();
670 
671  $set = $ilDB->query(
672  "SELECT id FROM glossary_term WHERE " .
673  " glo_id = " . $ilDB->quote($a_glo_id, "integer")
674  );
675  $ids = array();
676  while ($rec = $ilDB->fetchAssoc($set)) {
677  $ids[] = $rec["id"];
678  }
679  return $ids;
680  }
global $DIC
Definition: goto.php:24
global $ilDB
+ Here is the caller graph for this function:

◆ getUsages()

static ilGlossaryTerm::getUsages (   $a_term_id)
static

Get number of usages.

Parameters
intterm id
Returns
int number of usages

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

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

Referenced by ilTermUsagesTableGUI\getItems(), and getNumberOfUsages().

553  {
554  $usages = (ilInternalLink::_getSourcesOfTarget("git", $a_term_id, 0));
555 
557  $usages["glo:termref:" . $glo_id . ":-"] = array(
558  "type" => "glo:termref",
559  "id" => $glo_id,
560  "lang" => "-"
561  );
562  }
563 
564  return $usages;
565  }
static lookupReferencesOfTerm($a_term_id)
Lookup references of a term.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilGlossaryTerm::read ( )

read glossary term data

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

References $db, $ilDB, setGlossaryId(), setImportId(), setLanguage(), and setTerm().

Referenced by __construct().

53  {
54  $ilDB = $this->db;
55 
56  $q = "SELECT * FROM glossary_term WHERE id = " .
57  $ilDB->quote($this->id, "integer");
58  $term_set = $ilDB->query($q);
59  $term_rec = $ilDB->fetchAssoc($term_set);
60 
61  $this->setTerm($term_rec["term"]);
62  $this->setImportId($term_rec["import_id"]);
63  $this->setLanguage($term_rec["language"]);
64  $this->setGlossaryId($term_rec["glo_id"]);
65  }
setLanguage($a_language)
set language
setGlossaryId($a_glo_id)
set glossary id
setTerm($a_term)
set term
setImportId($a_import_id)
set import id
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setGlossary()

ilGlossaryTerm::setGlossary ( $a_glossary)

set glossary object

Parameters
object$a_glossaryglossary object

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

References setGlossaryId().

156  {
157  $this->glossary = $a_glossary;
158  $this->setGlossaryId($a_glossary->getId());
159  }
setGlossaryId($a_glo_id)
set glossary id
+ Here is the call graph for this function:

◆ setGlossaryId()

ilGlossaryTerm::setGlossaryId (   $a_glo_id)

set glossary id

Parameters
int$a_glo_idglossary id

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

Referenced by read(), and setGlossary().

168  {
169  $this->glo_id = $a_glo_id;
170  }
+ Here is the caller graph for this function:

◆ setId()

ilGlossaryTerm::setId (   $a_id)

set glossary term id (= glossary item id)

Parameters
int$a_idglossary term id

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

Referenced by create().

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

◆ setImportId()

ilGlossaryTerm::setImportId (   $a_import_id)

set import id

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

Referenced by read().

230  {
231  $this->import_id = $a_import_id;
232  }
+ Here is the caller graph for this function:

◆ setLanguage()

ilGlossaryTerm::setLanguage (   $a_language)

set language

Parameters
string$a_languagetwo letter language code

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

References language().

Referenced by read().

212  {
213  $this->language = $a_language;
214  }
language()
Definition: language.php:2
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTerm()

ilGlossaryTerm::setTerm (   $a_term)

set term

Parameters
string$a_termterm

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

Referenced by read().

190  {
191  $this->term = $a_term;
192  }
+ Here is the caller graph for this function:

◆ update()

ilGlossaryTerm::update ( )

update glossary term

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

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

290  {
291  $ilDB = $this->db;
292 
293  $ilDB->manipulate("UPDATE glossary_term SET " .
294  " glo_id = " . $ilDB->quote($this->getGlossaryId(), "integer") . ", " .
295  " term = " . $ilDB->quote($this->getTerm(), "text") . ", " .
296  " import_id = " . $ilDB->quote($this->getImportId(), "text") . ", " .
297  " language = " . $ilDB->quote($this->getLanguage(), "text") . ", " .
298  " last_update = " . $ilDB->now() . " " .
299  " WHERE id = " . $ilDB->quote($this->getId(), "integer"));
300  }
getId()
get term id (= glossary item id)
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilGlossaryTerm::$db
protected

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

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

◆ $glo_id

ilGlossaryTerm::$glo_id

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

Referenced by _getIdForImportId(), getGlossaryId(), and getUsages().

◆ $glossary

ilGlossaryTerm::$glossary

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

◆ $id

ilGlossaryTerm::$id

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

Referenced by getId(), and getTermList().

◆ $import_id

ilGlossaryTerm::$import_id

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

Referenced by getImportId().

◆ $language

ilGlossaryTerm::$language

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

Referenced by getLanguage().

◆ $lng

ilGlossaryTerm::$lng

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

Referenced by __construct().

◆ $term

ilGlossaryTerm::$term

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

Referenced by getTerm().

◆ $tpl

ilGlossaryTerm::$tpl

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

Referenced by __construct().


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