35 $this->db = $DIC->database();
36 $lng = $DIC->language();
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);
61 $this->
setTerm($term_rec[
"term"]);
78 $ilDB = $DIC->database();
80 if ($a_import_id ==
"") {
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)) {
93 return $term_rec[
"id"];
112 $ilDB = $DIC->database();
114 if (is_int(strpos($a_id,
"_"))) {
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)) {
157 $this->glossary = $a_glossary;
169 $this->glo_id = $a_glo_id;
191 $this->term = $a_term;
231 $this->import_id = $a_import_id;
252 $ilDB->manipulate(
"INSERT INTO glossary_term (id, glo_id, term, language, import_id, create_date, last_update)" .
254 $ilDB->quote($this->getId(),
"integer") .
", " .
255 $ilDB->quote($this->getGlossaryId(),
"integer") .
", " .
256 $ilDB->quote($this->term,
"text") .
", " .
259 $ilDB->now() .
", " .
267 public function delete()
272 foreach ($defs as $def) {
281 $ilDB->manipulate(
"DELETE FROM glossary_term " .
282 " WHERE id = " .
$ilDB->quote($this->getId(),
"integer"));
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"));
309 $ilDB = $DIC->database();
311 $query =
"SELECT * FROM glossary_term WHERE id = " .
312 $ilDB->quote($term_id,
"integer");
314 $obj_rec =
$ilDB->fetchAssoc($obj_set);
316 return $obj_rec[
"glo_id"];
326 $ilDB = $DIC->database();
328 $query =
"SELECT * FROM glossary_term WHERE id = " .
329 $ilDB->quote($term_id,
"integer");
331 $obj_rec =
$ilDB->fetchAssoc($obj_set);
333 return $obj_rec[
"term"];
343 $ilDB = $DIC->database();
345 $query =
"SELECT * FROM glossary_term WHERE id = " .
346 $ilDB->quote($term_id,
"integer");
348 $obj_rec =
$ilDB->fetchAssoc($obj_set);
350 return $obj_rec[
"language"];
364 $a_first_letter =
"",
367 $a_add_amet_fields =
false,
368 array $a_amet_filter = null,
369 $a_include_references =
false 373 if (is_array($a_glo_ref_id)) {
374 $a_glo_id = array_map(
function (
$id) {
380 $ilDB = $DIC->database();
387 if ($a_tax_node > 1) {
389 if (count($tax_ids) > 0) {
391 $sub_tree_ids = array();
392 foreach ($items as
$i) {
393 $sub_tree_ids[] = $i[
"item_id"];
395 $in =
" AND " .
$ilDB->in(
"gt.id", $sub_tree_ids,
false,
"integer");
401 if (is_array($a_glo_id)) {
402 $glo_where =
$ilDB->in(
"page_object.parent_id", $a_glo_id,
false,
"integer");
404 $glo_where =
" page_object.parent_id = " .
$ilDB->quote($a_glo_id,
"integer");
407 $join =
" JOIN glossary_definition gd ON (gd.term_id = gt.id)" .
408 " JOIN page_object ON (" .
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 .
"%") .
416 $searchterm = (!empty($searchterm))
417 ?
" AND " .
$ilDB->like(
"term",
"text",
"%" . $searchterm .
"%") .
" " 420 if ($a_first_letter !=
"") {
421 $searchterm .=
" AND " .
$ilDB->upper(
$ilDB->substr(
"term", 1, 1)) .
" = " .
$ilDB->upper(
$ilDB->quote($a_first_letter,
"text")) .
" ";
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");
431 $where_glo_id_or =
" OR tr.glo_id = " .
$ilDB->quote($a_glo_id,
"integer");
436 if (is_array($a_glo_id)) {
437 $where =
"(" .
$ilDB->in(
"gt.glo_id", $a_glo_id,
false,
"integer") . $where_glo_id_or .
")";
439 $where =
"(gt.glo_id = " .
$ilDB->quote($a_glo_id,
"integer") . $where_glo_id_or .
")";
445 $q =
"SELECT DISTINCT(gt.term), gt.id, gt.glo_id, gt.language FROM glossary_term gt " . $join .
" WHERE " . $where . $searchterm .
" ORDER BY term";
449 $term_set =
$ilDB->query($q);
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"];
458 if (($a_add_amet_fields || is_array($a_amet_filter)) && !is_array($a_glo_ref_id)) {
476 $ilDB = $DIC->database();
481 if (is_array($a_glo_id)) {
482 $where =
$ilDB->in(
"glo_id", $a_glo_id,
false,
"integer");
484 $where =
" glo_id = " .
$ilDB->quote($a_glo_id,
"integer") .
" ";
487 if ($a_tax_node > 1) {
489 if (count($tax_ids) > 0) {
491 $sub_tree_ids = array();
492 foreach ($items as
$i) {
493 $sub_tree_ids[] = $i[
"item_id"];
495 $in =
" AND " .
$ilDB->in(
"id", $sub_tree_ids,
false,
"integer");
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);
506 while ($let_rec =
$ilDB->fetchAssoc($let_set)) {
507 $let[$let_rec[
"let"]] = $let_rec[
"let"];
520 $a_xml_writer->xmlStartTag(
"GlossaryItem", $attrs);
523 $a_xml_writer->xmlElement(
"GlossaryTerm", $attrs, $this->
getTerm());
527 foreach ($defs as $def) {
529 $definition->exportXML($a_xml_writer, $a_inst);
532 $a_xml_writer->xmlEndTag(
"GlossaryItem");
557 $usages[
"glo:termref:" .
$glo_id .
":-"] = array(
558 "type" =>
"glo:termref",
573 public static function _copyTerm($a_term_id, $a_glossary_id)
579 $new_term->setTerm($old_term->getTerm());
580 $new_term->setLanguage($old_term->getLanguage());
581 $new_term->setGlossaryId($a_glossary_id);
586 foreach ($def_list as $def) {
590 $new_def->setShortText($old_def->getShortText());
591 $new_def->setNr($old_def->getNr());
592 $new_def->setTermId($new_term->getId());
597 $old_term->getGlossaryId(),
598 $old_def->getPageObject()->getId(),
599 $old_def->getPageObject()->getParentType()
603 $new_def->getPageObject()->getId(),
604 $old_def->getPageObject()->getParentType()
608 $new_page = $new_def->getPageObject();
609 $old_def->getPageObject()->copy($new_page->getId(), $new_page->getParentType(), $new_page->getParentId(),
true);
620 foreach ($old_recs as $old_record_obj) {
622 foreach ($new_recs as $new_record_obj) {
623 if ($old_record_obj->getRecordId() == $new_record_obj->getRecordId()) {
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());
641 "obj_id" =>
"integer",
642 "sub_type" =>
"text",
643 "sub_id" =>
"integer",
644 "field_id" =>
"integer" 648 array(
"disabled" =>
"integer")
656 return $new_term->getId();
669 $ilDB = $DIC->database();
672 "SELECT id FROM glossary_term WHERE " .
673 " glo_id = " .
$ilDB->quote($a_glo_id,
"integer")
676 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 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
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 getInstancesByRecordId($a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.
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.