37 $this->db = $DIC->database();
38 $lng = $DIC->language();
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($term_rec[
"term"]);
80 $ilDB = $DIC->database();
82 if ($a_import_id ==
"") {
86 $q =
"SELECT * FROM glossary_term WHERE import_id = " .
87 $ilDB->quote($a_import_id,
"text") .
88 " ORDER BY create_date DESC";
89 $term_set =
$ilDB->query($q);
90 while ($term_rec =
$ilDB->fetchAssoc($term_set)) {
95 return $term_rec[
"id"];
114 $ilDB = $DIC->database();
116 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
117 if (is_int(strpos($a_id,
"_"))) {
121 $q =
"SELECT * FROM glossary_term WHERE id = " .
122 $ilDB->quote($a_id,
"integer");
123 $obj_set =
$ilDB->query($q);
124 if ($obj_rec =
$ilDB->fetchAssoc($obj_set)) {
160 $this->glossary = $a_glossary;
172 $this->glo_id = $a_glo_id;
194 $this->term = $a_term;
216 $this->language = $a_language;
234 $this->import_id = $a_import_id;
255 $ilDB->manipulate(
"INSERT INTO glossary_term (id, glo_id, term, language, import_id, create_date, last_update)" .
257 $ilDB->quote($this->getId(),
"integer") .
", " .
258 $ilDB->quote($this->getGlossaryId(),
"integer") .
", " .
259 $ilDB->quote($this->term,
"text") .
", " .
260 $ilDB->quote($this->language,
"text") .
"," .
262 $ilDB->now() .
", " .
270 public function delete()
274 require_once(
"./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
276 foreach ($defs as
$def) {
282 include_once(
"./Modules/Glossary/classes/class.ilGlossaryTermReferences.php");
286 $ilDB->manipulate(
"DELETE FROM glossary_term " .
287 " WHERE id = " .
$ilDB->quote($this->getId(),
"integer"));
298 $ilDB->manipulate(
"UPDATE glossary_term SET " .
299 " glo_id = " .
$ilDB->quote($this->getGlossaryId(),
"integer") .
", " .
300 " term = " .
$ilDB->quote($this->getTerm(),
"text") .
", " .
301 " import_id = " .
$ilDB->quote($this->getImportId(),
"text") .
", " .
302 " language = " .
$ilDB->quote($this->getLanguage(),
"text") .
", " .
303 " last_update = " .
$ilDB->now() .
" " .
304 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer"));
314 $ilDB = $DIC->database();
316 $query =
"SELECT * FROM glossary_term WHERE id = " .
317 $ilDB->quote($term_id,
"integer");
319 $obj_rec =
$ilDB->fetchAssoc($obj_set);
321 return $obj_rec[
"glo_id"];
331 $ilDB = $DIC->database();
333 $query =
"SELECT * FROM glossary_term WHERE id = " .
334 $ilDB->quote($term_id,
"integer");
336 $obj_rec =
$ilDB->fetchAssoc($obj_set);
338 return $obj_rec[
"term"];
348 $ilDB = $DIC->database();
350 $query =
"SELECT * FROM glossary_term WHERE id = " .
351 $ilDB->quote($term_id,
"integer");
353 $obj_rec =
$ilDB->fetchAssoc($obj_set);
355 return $obj_rec[
"language"];
369 $a_first_letter =
"",
372 $a_add_amet_fields =
false,
373 array $a_amet_filter = null,
374 $a_include_references =
false 378 if (is_array($a_glo_ref_id)) {
379 $a_glo_id = array_map(
function (
$id) {
385 $ilDB = $DIC->database();
392 if ($a_tax_node > 1) {
393 include_once(
"./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
395 if (count($tax_ids) > 0) {
397 $sub_tree_ids =
array();
398 foreach ($items as
$i) {
399 $sub_tree_ids[] = $i[
"item_id"];
401 $in =
" AND " .
$ilDB->in(
"gt.id", $sub_tree_ids,
false,
"integer");
407 if (is_array($a_glo_id)) {
408 $glo_where =
$ilDB->in(
"page_object.parent_id", $a_glo_id,
false,
"integer");
410 $glo_where =
" page_object.parent_id = " .
$ilDB->quote($a_glo_id,
"integer");
413 $join =
" JOIN glossary_definition gd ON (gd.term_id = gt.id)" .
414 " JOIN page_object ON (" .
416 " AND page_object.parent_type = " .
$ilDB->quote(
"gdf",
"text") .
417 " AND page_object.page_id = gd.id" .
418 " AND " .
$ilDB->like(
"page_object.content",
"text",
"%" . $a_def .
"%") .
422 $searchterm = (!empty($searchterm))
423 ?
" AND " .
$ilDB->like(
"term",
"text",
"%" . $searchterm .
"%") .
" " 426 if ($a_first_letter !=
"") {
427 $searchterm.=
" AND " .
$ilDB->upper(
$ilDB->substr(
"term", 1, 1)) .
" = " .
$ilDB->upper(
$ilDB->quote($a_first_letter,
"text")) .
" ";
431 $where_glo_id_or =
"";
432 if ($a_include_references) {
433 $join.=
" LEFT JOIN glo_term_reference tr ON (gt.id = tr.term_id) ";
434 if (is_array($a_glo_id)) {
435 $where_glo_id_or =
" OR " .
$ilDB->in(
"tr.glo_id", $a_glo_id,
false,
"integer");
437 $where_glo_id_or =
" OR tr.glo_id = " .
$ilDB->quote($a_glo_id,
"integer");
442 if (is_array($a_glo_id)) {
443 $where =
"(" .
$ilDB->in(
"gt.glo_id", $a_glo_id,
false,
"integer") . $where_glo_id_or .
")";
445 $where =
"(gt.glo_id = " .
$ilDB->quote($a_glo_id,
"integer") . $where_glo_id_or .
")";
451 $q =
"SELECT DISTINCT(gt.term), gt.id, gt.glo_id, gt.language FROM glossary_term gt " . $join .
" WHERE " . $where . $searchterm .
" ORDER BY term";
455 $term_set =
$ilDB->query($q);
457 while ($term_rec =
$ilDB->fetchAssoc($term_set)) {
458 $terms[] =
array(
"term" => $term_rec[
"term"],
459 "language" => $term_rec[
"language"],
"id" => $term_rec[
"id"],
"glo_id" => $term_rec[
"glo_id"]);
460 $glo_ids[] = $term_rec[
"glo_id"];
464 if (($a_add_amet_fields || is_array($a_amet_filter)) && !is_array($a_glo_ref_id)) {
465 include_once(
"./Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php");
483 $ilDB = $DIC->database();
488 if (is_array($a_glo_id)) {
489 $where =
$ilDB->in(
"glo_id", $a_glo_id,
false,
"integer");
491 $where =
" glo_id = " .
$ilDB->quote($a_glo_id,
"integer") .
" ";
494 if ($a_tax_node > 1) {
495 include_once(
"./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
497 if (count($tax_ids) > 0) {
499 $sub_tree_ids =
array();
500 foreach ($items as
$i) {
501 $sub_tree_ids[] = $i[
"item_id"];
503 $in =
" AND " .
$ilDB->in(
"id", $sub_tree_ids,
false,
"integer");
510 $q =
"SELECT DISTINCT " .
$ilDB->upper(
$ilDB->substr(
"term", 1, 1)) .
" let FROM glossary_term WHERE " . $where .
" ORDER BY let";
511 $let_set =
$ilDB->query($q);
514 while ($let_rec =
$ilDB->fetchAssoc($let_set)) {
515 $let[$let_rec[
"let"]] = $let_rec[
"let"];
527 $attrs[
"Id"] =
"il_" . IL_INST_ID .
"_git_" . $this->
getId();
528 $a_xml_writer->xmlStartTag(
"GlossaryItem", $attrs);
531 $a_xml_writer->xmlElement(
"GlossaryTerm", $attrs, $this->
getTerm());
535 foreach ($defs as
$def) {
537 $definition->exportXML($a_xml_writer, $a_inst);
540 $a_xml_writer->xmlEndTag(
"GlossaryItem");
562 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
565 include_once(
"./Modules/Glossary/classes/class.ilGlossaryTermReferences.php");
567 $usages[
"glo:termref:" . $glo_id .
":-"] =
array(
568 "type" =>
"glo:termref",
583 public static function _copyTerm($a_term_id, $a_glossary_id)
589 $new_term->setTerm($old_term->getTerm());
590 $new_term->setLanguage($old_term->getLanguage());
591 $new_term->setGlossaryId($a_glossary_id);
595 include_once(
"./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
597 foreach ($def_list as
$def) {
601 $new_def->setShortText($old_def->getShortText());
602 $new_def->setNr($old_def->getNr());
603 $new_def->setTermId($new_term->getId());
607 include_once(
"Services/MetaData/classes/class.ilMD.php");
609 $old_term->getGlossaryId(),
610 $old_def->getPageObject()->getId(),
611 $old_def->getPageObject()->getParentType()
615 $new_def->getPageObject()->getId(),
616 $old_def->getPageObject()->getParentType()
620 $new_page = $new_def->getPageObject();
621 $old_def->getPageObject()->copy($new_page->getId(), $new_page->getParentType(), $new_page->getParentId(),
true);
630 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
631 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
634 foreach ($old_recs as $old_record_obj) {
636 foreach ($new_recs as $new_record_obj) {
637 if ($old_record_obj->getRecordId() == $new_record_obj->getRecordId()) {
643 $source_primary =
array(
"obj_id"=>
array(
"integer", $old_term->getGlossaryId()));
644 $source_primary[
"sub_type"] =
array(
"text",
"term");
645 $source_primary[
"sub_id"] =
array(
"integer", $old_term->getId());
646 $source_primary[
"field_id"] =
array(
"integer", $def->getFieldId());
647 $target_primary =
array(
"obj_id"=>
array(
"integer", $new_term->getGlossaryId()));
648 $target_primary[
"sub_type"] =
array(
"text",
"term");
649 $target_primary[
"sub_id"] =
array(
"integer", $new_term->getId());
655 "obj_id" =>
"integer",
656 "sub_type" =>
"text",
657 "sub_id" =>
"integer",
658 "field_id" =>
"integer" 662 array(
"disabled"=>
"integer")
670 return $new_term->getId();
683 $ilDB = $DIC->database();
686 "SELECT id FROM glossary_term WHERE " .
687 " glo_id = " .
$ilDB->quote($a_glo_id,
"integer")
690 while ($rec =
$ilDB->fetchAssoc($set)) {
& cloneMD($a_rbac_id, $a_obj_id, $a_obj_type)
static getDefinitionList($a_term_id)
static
static _hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
getId()
get term id (= glossary item id)
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
static getNumberOfUsages($a_term_id)
Get number of usages.
setGlossary(&$a_glossary)
set glossary object
static _extractObjIdOfTarget($a_target)
Extract object id out of target.
getImportId()
get import id
create()
create new glossary term
static _getIdForImportId($a_import_id)
get current term id for import id (static)
__construct($a_id=0)
Constructor public.
setLanguage($a_language)
set language
static getInstance()
Get singleton.
getLanguage()
get language
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 _getAllReferences($a_id)
get all reference ids of object
static lookupReferencesOfTerm($a_term_id)
Lookup references of a term.
static _getSelectedRecordsByObject($a_obj_type, $a_ref_id, $a_sub_type="")
Get selected records by object.
static _lookupObjectId($a_ref_id)
lookup object id
static _exists($a_id)
checks wether a glossary term with specified id exists or not
getGlossaryId()
get glossary id
static getInstancesByRecordId($a_record_id, $a_only_searchable=false)
Get definitions by record id.
static getUsages($a_term_id)
Get number of usages.
setGlossaryId($a_glo_id)
set glossary id
static getFirstLetters($a_glo_id, $a_tax_node=0)
Get all terms for given set of glossary ids.
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 _getSourcesOfTarget($a_target_type, $a_target_id, $a_target_inst)
get all sources of a link target
static _lookLanguage($term_id)
lookup term language
Create styles array
The data for the language used.
setImportId($a_import_id)
set import id
setId($a_id)
set glossary term id (= glossary item id)
if(php_sapi_name() !='cli') $in
static _lookGlossaryID($term_id)
get glossary id form term id
Class ilGlossaryDefinition.
update()
update glossary term
static _copyTerm($a_term_id, $a_glossary_id)
Copy a term to a glossary.
static deleteReferencesOfTerm($a_term_id)
Delete all references of a term.
exportXML(&$a_xml_writer, $a_inst)
export xml
static getTermsOfGlossary($a_glo_id)
Get terms of glossary.
static getSubTreeItems($a_comp, $a_obj_id, $a_item_type, $a_tax_id, $a_node)
Get all assigned items under a node.
static _lookGlossaryTerm($term_id)
get glossary term
read()
read glossary term data
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.