40 $this->db = $DIC->database();
41 $lng = $DIC->language();
54 public function read(): void
58 $q =
"SELECT * FROM glossary_term WHERE id = " .
59 $ilDB->quote($this->
id,
"integer");
60 $term_set =
$ilDB->query($q);
61 $term_rec =
$ilDB->fetchAssoc($term_set);
63 $this->
setTerm((
string) $term_rec[
"term"]);
64 $this->
setImportId((
string) $term_rec[
"import_id"]);
74 $ilDB = $DIC->database();
76 if ($a_import_id ==
"") {
80 $q =
"SELECT * FROM glossary_term WHERE import_id = " .
81 $ilDB->quote($a_import_id,
"text") .
82 " ORDER BY create_date DESC";
83 $term_set =
$ilDB->query($q);
84 while ($term_rec =
$ilDB->fetchAssoc($term_set)) {
85 $glo_id = self::_lookGlossaryID($term_rec[
"id"]);
89 return (
int) $term_rec[
"id"];
100 public static function _exists(
int $a_id): bool
104 $ilDB = $DIC->database();
106 if (is_int(strpos($a_id,
"_"))) {
110 $q =
"SELECT * FROM glossary_term WHERE id = " .
111 $ilDB->quote($a_id,
"integer");
112 $obj_set =
$ilDB->query($q);
113 if ($obj_rec =
$ilDB->fetchAssoc($obj_set)) {
124 public function setId(
int $a_id): void
137 $this->glossary = $a_glossary;
144 $this->glo_id = $a_glo_id;
154 $this->term = $a_term;
175 $this->import_id = $a_import_id;
188 $ilDB->manipulate(
"INSERT INTO glossary_term (id, glo_id, term, language, import_id, create_date, last_update)" .
190 $ilDB->quote($this->getId(),
"integer") .
", " .
191 $ilDB->quote($this->getGlossaryId(),
"integer") .
", " .
192 $ilDB->quote($this->term,
"text") .
", " .
195 $ilDB->now() .
", " .
202 public function delete():
void 207 foreach ($defs as $def) {
216 $ilDB->manipulate(
"DELETE FROM glossary_term " .
217 " WHERE id = " .
$ilDB->quote($this->getId(),
"integer"));
224 $ilDB->manipulate(
"UPDATE glossary_term SET " .
225 " glo_id = " .
$ilDB->quote($this->getGlossaryId(),
"integer") .
", " .
226 " term = " .
$ilDB->quote($this->getTerm(),
"text") .
", " .
227 " import_id = " .
$ilDB->quote($this->getImportId(),
"text") .
", " .
228 " language = " .
$ilDB->quote($this->getLanguage(),
"text") .
", " .
229 " last_update = " .
$ilDB->now() .
" " .
230 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer"));
240 $ilDB = $DIC->database();
242 $query =
"SELECT * FROM glossary_term WHERE id = " .
243 $ilDB->quote($term_id,
"integer");
245 $obj_rec =
$ilDB->fetchAssoc($obj_set);
247 return (
int) ($obj_rec[
"glo_id"] ?? 0);
257 $ilDB = $DIC->database();
259 $query =
"SELECT * FROM glossary_term WHERE id = " .
260 $ilDB->quote($term_id,
"integer");
262 $obj_rec =
$ilDB->fetchAssoc($obj_set);
264 return $obj_rec[
"term"] ??
"";
274 $ilDB = $DIC->database();
276 $query =
"SELECT * FROM glossary_term WHERE id = " .
277 $ilDB->quote($term_id,
"integer");
279 $obj_rec =
$ilDB->fetchAssoc($obj_set);
281 return $obj_rec[
"language"];
289 string $searchterm =
"",
290 string $a_first_letter =
"",
293 bool $a_add_amet_fields =
false,
294 array $a_amet_filter = null,
295 bool $a_include_references =
false 299 if (count($a_glo_ref_id) > 1) {
300 $a_glo_id = array_map(
static function ($id):
int {
306 $ilDB = $DIC->database();
313 if ($a_tax_node > 1) {
315 if (count($tax_ids) > 0) {
317 $sub_tree_ids = array();
318 foreach ($items as
$i) {
319 $sub_tree_ids[] = $i[
"item_id"];
321 $in =
" AND " .
$ilDB->in(
"gt.id", $sub_tree_ids,
false,
"integer");
327 if (is_array($a_glo_id)) {
328 $glo_where =
$ilDB->in(
"page_object.parent_id", $a_glo_id,
false,
"integer");
330 $glo_where =
" page_object.parent_id = " .
$ilDB->quote($a_glo_id,
"integer");
333 $join =
" JOIN glossary_definition gd ON (gd.term_id = gt.id)" .
334 " JOIN page_object ON (" .
336 " AND page_object.parent_type = " .
$ilDB->quote(
"gdf",
"text") .
337 " AND page_object.page_id = gd.id" .
338 " AND " .
$ilDB->like(
"page_object.content",
"text",
"%" . $a_def .
"%") .
342 $searchterm = (!empty($searchterm))
343 ?
" AND " .
$ilDB->like(
"term",
"text",
"%" . $searchterm .
"%") .
" " 346 if ($a_first_letter !=
"") {
347 $searchterm .=
" AND " .
$ilDB->upper(
$ilDB->substr(
"term", 1, 1)) .
" = " .
$ilDB->upper(
$ilDB->quote($a_first_letter,
"text")) .
" ";
351 $where_glo_id_or =
"";
352 if ($a_include_references) {
353 $join .=
" LEFT JOIN glo_term_reference tr ON (gt.id = tr.term_id) ";
354 if (is_array($a_glo_id)) {
355 $where_glo_id_or =
" OR " .
$ilDB->in(
"tr.glo_id", $a_glo_id,
false,
"integer");
357 $where_glo_id_or =
" OR tr.glo_id = " .
$ilDB->quote($a_glo_id,
"integer");
362 if (is_array($a_glo_id)) {
363 $where =
"(" .
$ilDB->in(
"gt.glo_id", $a_glo_id,
false,
"integer") . $where_glo_id_or .
")";
365 $where =
"(gt.glo_id = " .
$ilDB->quote($a_glo_id,
"integer") . $where_glo_id_or .
")";
371 $q =
"SELECT DISTINCT(gt.term), gt.id, gt.glo_id, gt.language FROM glossary_term gt " . $join .
" WHERE " . $where . $searchterm .
" ORDER BY term";
375 $term_set =
$ilDB->query($q);
377 while ($term_rec =
$ilDB->fetchAssoc($term_set)) {
378 $terms[] = array(
"term" => $term_rec[
"term"],
379 "language" => $term_rec[
"language"],
"id" => $term_rec[
"id"],
"glo_id" => $term_rec[
"glo_id"]);
380 $glo_ids[] = $term_rec[
"glo_id"];
384 if (($a_add_amet_fields || is_array($a_amet_filter)) && count($a_glo_ref_id) == 1) {
396 $ilDB = $DIC->database();
399 if (count($a_glo_id) > 1) {
400 $where =
$ilDB->in(
"glo_id", $a_glo_id,
false,
"integer");
402 $a_glo_id = current($a_glo_id);
403 $where =
" glo_id = " .
$ilDB->quote($a_glo_id,
"integer") .
" ";
406 if ($a_tax_node > 1) {
408 if (count($tax_ids) > 0) {
410 $sub_tree_ids = array();
411 foreach ($items as
$i) {
412 $sub_tree_ids[] = $i[
"item_id"];
414 $in =
" AND " .
$ilDB->in(
"id", $sub_tree_ids,
false,
"integer");
421 $q =
"SELECT DISTINCT " .
$ilDB->upper(
$ilDB->substr(
"term", 1, 1)) .
" let FROM glossary_term WHERE " . $where .
" ORDER BY let";
422 $let_set =
$ilDB->query($q);
425 while ($let_rec =
$ilDB->fetchAssoc($let_set)) {
426 $let[$let_rec[
"let"]] = $let_rec[
"let"];
438 $a_xml_writer->
xmlStartTag(
"GlossaryItem", $attrs);
445 foreach ($defs as $def) {
447 $definition->exportXML($a_xml_writer, $a_inst);
450 $a_xml_writer->
xmlEndTag(
"GlossaryItem");
455 return count(self::getUsages($a_term_id));
463 $usages[
"glo:termref:" . $glo_id .
":-"] = array(
464 "type" =>
"glo:termref",
485 $new_term->setTerm($old_term->getTerm());
486 $new_term->setLanguage($old_term->getLanguage());
487 $new_term->setGlossaryId($a_glossary_id);
492 foreach ($def_list as $def) {
496 $new_def->setShortText($old_def->getShortText());
497 $new_def->setNr($old_def->getNr());
498 $new_def->setTermId($new_term->getId());
503 $old_term->getGlossaryId(),
504 $old_def->getPageObject()->getId(),
505 $old_def->getPageObject()->getParentType()
509 $new_def->getPageObject()->getId(),
510 $old_def->getPageObject()->getParentType()
514 $new_page = $new_def->getPageObject();
515 $old_def->getPageObject()->copy($new_page->getId(), $new_page->getParentType(), $new_page->getParentId(),
true);
526 foreach ($old_recs as $old_record_obj) {
528 foreach ($new_recs as $new_record_obj) {
529 if ($old_record_obj->getRecordId() == $new_record_obj->getRecordId()) {
535 $source_primary = array(
"obj_id" => array(
"integer", $old_term->getGlossaryId()));
536 $source_primary[
"sub_type"] = array(
"text",
"term");
537 $source_primary[
"sub_id"] = array(
"integer", $old_term->getId());
538 $source_primary[
"field_id"] = array(
"integer", $def->getFieldId());
539 $target_primary = array(
"obj_id" => array(
"integer", $new_term->getGlossaryId()));
540 $target_primary[
"sub_type"] = array(
"text",
"term");
541 $target_primary[
"sub_id"] = array(
"integer", $new_term->getId());
547 "obj_id" =>
"integer",
548 "sub_type" =>
"text",
549 "sub_id" =>
"integer",
550 "field_id" =>
"integer" 554 array(
"disabled" =>
"integer")
561 return $new_term->getId();
572 $ilDB = $DIC->database();
575 "SELECT id FROM glossary_term WHERE " .
576 " glo_id = " .
$ilDB->quote($a_glo_id,
"integer")
579 while ($rec =
$ilDB->fetchAssoc($set)) {
580 $ids[] = (
int) $rec[
"id"];
static deleteReferencesOfTerm(int $a_term_id)
Delete all references of a term.
static _getSourcesOfTarget(string $a_target_type, int $a_target_id, int $a_target_inst)
get all sources of a link target
static getUsages(int $a_term_id)
static _extractObjIdOfTarget(string $a_target)
Extract object id out of target.
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _exists(int $a_id)
checks whether a glossary term with specified id exists or not
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getIdForImportId(string $a_import_id)
static _getAllReferences(int $id)
get all reference ids for object ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _hasUntrashedReference(int $obj_id)
checks whether an object has at least one reference that is not in trash
static getUsageOfObject(int $a_obj_id, bool $a_include_titles=false)
static _getSelectedRecordsByObject(string $a_obj_type, int $a_id, string $a_sub_type="", bool $is_ref_id=true)
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 getInstancesByRecordId( $a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.
setGlossary(ilObjGlossary $a_glossary)
static _copyTerm(int $a_term_id, int $a_glossary_id)
Copy a term to a glossary.
xmlEndTag(string $tag)
Writes an endtag.
exportXML(ilXmlWriter $a_xml_writer, int $a_inst)
static lookupReferencesOfTerm(int $a_term_id)
static _lookGlossaryTerm(int $term_id)
get glossary term
static _lookupObjectId(int $ref_id)
static getTermsOfGlossary(int $a_glo_id)
ilGlobalTemplateInterface $tpl
setId(int $a_id)
set glossary term id (= glossary item id)
static _lookLanguage(int $term_id)
lookup term language
static getDefinitionList(int $a_term_id)
setLanguage(string $a_language)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
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)
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)
static getNumberOfUsages(int $a_term_id)
setGlossaryId(int $a_glo_id)
static getFirstLetters(array $a_glo_id, int $a_tax_node=0)
setImportId(string $a_import_id)
cloneMD(int $a_rbac_id, int $a_obj_id, string $a_obj_type)
static _lookGlossaryID(int $term_id)
get glossary id form term id