45 $this->db = $DIC->database();
46 $this->
user = $DIC->user();
47 $lng = $DIC->language();
59 public function read(): void
63 $q =
"SELECT * FROM glossary_definition WHERE id = " .
64 $ilDB->quote($this->
id,
"integer");
65 $def_set =
$ilDB->query($q);
66 $def_rec =
$ilDB->fetchAssoc($def_set);
68 $this->
setTermId((
int) $def_rec[
"term_id"]);
70 $this->
setNr((
int) $def_rec[
"nr"]);
76 public function setId(
int $a_id): void
93 $this->term_id = $a_term_id;
111 public function setNr(
int $a_nr): void
123 $this->page_object = $a_page_object;
138 $this->title = $a_title;
148 $this->description = $a_description;
153 $this->short_text_dirty = $a_val;
161 bool $a_upload =
false,
162 bool $a_omit_page_creation =
false 168 $this->
setId(
$ilDB->nextId(
"glossary_definition"));
170 $ilAtomQuery =
$ilDB->buildAtomQuery();
171 $ilAtomQuery->addTableLock(
'glossary_definition');
176 $q =
"SELECT max(nr) AS max_nr FROM glossary_definition WHERE term_id = " .
178 $max_set = $ilDB->
query($q);
180 $max = (
int) $max_rec[
"max_nr"];
183 $ilDB->
manipulate(
"INSERT INTO glossary_definition (id, term_id, short_text, nr, short_text_dirty)" .
185 $ilDB->
quote($this->getId(),
"integer") .
"," .
186 $ilDB->
quote($this->getTermId(),
"integer") .
"," .
187 $ilDB->
quote($this->getShortText(),
"text") .
", " .
188 $ilDB->
quote(($max + 1),
"integer") .
", " .
196 $q =
"SELECT nr FROM glossary_definition WHERE id = " .
197 $ilDB->
quote($this->
id,
"integer");
198 $def_set = $ilDB->
query($q);
200 $this->
setNr($def_rec[
"nr"]);
208 if (!$a_omit_page_creation) {
210 $this->page_object->setId($this->
getId());
211 $this->page_object->setParentId($term->getGlossaryId());
212 $this->page_object->create(
false);
216 public function delete():
void 220 $ilAtomQuery =
$ilDB->buildAtomQuery();
221 $ilAtomQuery->addTableLock(
"glossary_definition");
226 $q =
"SELECT * FROM glossary_definition WHERE id = " .
227 $ilDB->
quote($this->
id,
"integer");
228 $def_set = $ilDB->
query($q);
230 $this->
setNr($def_rec[
"nr"]);
233 $ilDB->
manipulate(
"UPDATE glossary_definition SET " .
235 " WHERE term_id = " . $ilDB->
quote($this->getTermId(),
"integer") .
" " .
236 " AND nr > " . $ilDB->
quote($this->getNr(),
"integer"));
239 $ilDB->
manipulate(
"DELETE FROM glossary_definition " .
240 " WHERE id = " . $ilDB->
quote($this->getId(),
"integer"));
245 $this->page_object->delete();
256 $ilAtomQuery =
$ilDB->buildAtomQuery();
257 $ilAtomQuery->addTableLock(
'glossary_definition');
262 $q =
"SELECT * FROM glossary_definition WHERE id = " .
263 $ilDB->
quote($this->
id,
"integer");
264 $def_set = $ilDB->
query($q);
266 $this->
setNr($def_rec[
"nr"]);
268 if ($this->
getNr() < 2) {
273 $ilDB->
manipulate(
"UPDATE glossary_definition SET " .
275 " WHERE term_id = " . $ilDB->
quote($this->getTermId(),
"integer") .
" " .
276 " AND nr = " . $ilDB->
quote(($this->getNr() - 1),
"integer"));
279 $ilDB->
manipulate(
"UPDATE glossary_definition SET " .
281 " WHERE term_id = " . $ilDB->
quote($this->getTermId(),
"integer") .
" " .
282 " AND id = " . $ilDB->
quote($this->getId(),
"integer"));
291 $ilAtomQuery =
$ilDB->buildAtomQuery();
292 $ilAtomQuery->addTableLock(
'glossary_definition');
297 $q =
"SELECT * FROM glossary_definition WHERE id = " .
298 $ilDB->
quote($this->
id,
"integer");
299 $def_set = $ilDB->
query($q);
301 $this->
setNr($def_rec[
"nr"]);
304 $q =
"SELECT max(nr) as max_nr FROM glossary_definition WHERE term_id = " .
306 $max_set = $ilDB->
query($q);
309 if ($this->
getNr() >= $max_rec[
"max_nr"]) {
314 $ilDB->
manipulate(
"UPDATE glossary_definition SET " .
316 " WHERE term_id = " . $ilDB->
quote($this->getTermId(),
"integer") .
" " .
317 " AND nr = " . $ilDB->
quote(($this->getNr() + 1),
"integer"));
320 $ilDB->
manipulate(
"UPDATE glossary_definition SET " .
322 " WHERE term_id = " . $ilDB->
quote($this->getTermId(),
"integer") .
" " .
323 " AND id = " . $ilDB->
quote($this->getId(),
"integer"));
335 $ilDB->manipulate(
"UPDATE glossary_definition SET " .
336 " term_id = " .
$ilDB->quote($this->getTermId(),
"integer") .
", " .
337 " nr = " .
$ilDB->quote($this->getNr(),
"integer") .
", " .
338 " short_text = " .
$ilDB->quote($this->getShortText(),
"text") .
", " .
339 " short_text_dirty = " .
$ilDB->quote($this->getShortTextDirty(),
"integer") .
" " .
340 " WHERE id = " .
$ilDB->quote($this->getId(),
"integer"));
353 if ($snippet_length > 0) {
354 $a_length = $snippet_length;
358 $text = str_replace(
"<br/>",
"<br>", $text);
359 $text = strip_tags($text,
"<br>");
361 if (is_int(strpos(substr($text, $a_length - 16 - 5, 10),
"[tex]"))) {
367 $ltexs = strrpos($short,
"[tex]");
368 $ltexe = strrpos($short,
"[/tex]");
369 if ($ltexs > $ltexe) {
370 $ltexe = strpos($text,
"[/tex]", $ltexs);
383 $this->page_object->buildDom();
384 $text = $this->page_object->getFirstParagraphText();
396 $ilDB = $DIC->database();
399 $q =
"SELECT * FROM glossary_definition WHERE term_id = " .
400 $ilDB->quote($a_term_id,
"integer") .
402 $def_set =
$ilDB->query($q);
403 while ($def_rec =
$ilDB->fetchAssoc($def_set)) {
404 $defs[] = array(
"term_id" => $def_rec[
"term_id"],
405 "page_id" => (
int) ($def_rec[
"page_id"] ?? 0),
"id" => $def_rec[
"id"],
406 "short_text" => strip_tags($def_rec[
"short_text"],
"<br>"),
407 "nr" => $def_rec[
"nr"],
408 "short_text_dirty" => $def_rec[
"short_text_dirty"]);
432 $md2xml->setExportMode(
true);
433 $md2xml->startExport();
434 $a_xml_writer->
appendXML($md2xml->getXML());
442 if ($a_tag ==
"Identifier" && $a_param ==
"Entry") {
456 $this->page_object->buildDom();
457 $this->page_object->insertInstIntoIDs($a_inst);
458 $this->mobs_contained = $this->page_object->collectMediaObjects(
false);
460 $xml = $this->page_object->getXMLFromDom(
false,
false,
false,
"",
true);
461 $xml = str_replace(
"&",
"&", $xml);
464 $this->page_object->freeDom();
472 $md_creator->setTitle($this->
getTitle());
473 $md_creator->setTitleLanguage(
$lang);
475 $md_creator->setDescriptionLanguage(
$lang);
476 $md_creator->setKeywordLanguage(
$lang);
477 $md_creator->setLanguage(
$lang);
478 $md_creator->create();
485 $md_gen = $md->getGeneral();
486 $md_gen->setTitle($this->
getTitle());
489 $md_des_ids = $md_gen->getDescriptionIds();
490 if (count($md_des_ids) > 0) {
491 $md_des = $md_gen->getDescription($md_des_ids[0]);
520 switch ($a_element) {
526 $md_gen = $md->getGeneral();
529 $this->
setTitle($md_gen->getTitle());
531 foreach ($md_gen->getDescriptionIds() as
$id) {
532 $md_des = $md_gen->getDescription($id);
553 $ilDB = $DIC->database();
555 $q =
"SELECT * FROM glossary_definition WHERE id = " .
556 $ilDB->quote($a_def_id,
"integer");
557 $def_set =
$ilDB->query($q);
558 $def_rec =
$ilDB->fetchAssoc($def_set);
560 return $def_rec[
"term_id"];
571 $ilDB = $DIC->database();
575 foreach ($term_ids as $term_id) {
577 "UPDATE glossary_definition SET " .
578 " short_text_dirty = " .
$ilDB->quote(1,
"integer") .
579 " WHERE term_id = " .
$ilDB->quote($term_id,
"integer")
591 $ilDB = $DIC->database();
594 "UPDATE glossary_definition SET " .
595 " short_text_dirty = " .
$ilDB->quote(1,
"integer")
exportXMLMetaData(ilXmlWriter $a_xml_writer)
modifyExportIdentifier(string $a_tag, string $a_param, string $a_value)
static setShortTextsDirty(int $a_glo_id)
Set all short texts of glossary dirty (e.g.
setTitle(string $a_title)
exportXMLDefinition(ilXmlWriter $a_xml_writer, int $a_inst=0)
export page objects meta data to xml
shortenShortText(string $text)
Shorten short text.
fetchAssoc(ilDBStatement $statement)
ilGlossaryDefPage $page_object
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
create(bool $a_upload=false, bool $a_omit_page_creation=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
quote($value, string $type)
appendXML(string $a_str)
append xml string to document
xmlEndTag(string $tag)
Writes an endtag.
setDescription(string $a_description)
static collectFileItems(ilPageObject $a_page, DOMDocument $a_domdoc)
Get all file items that are used within the page.
setShortText(string $a_text)
static setShortTextsDirtyGlobally()
Set short texts dirty (for all glossaries)
setShortTextDirty(bool $a_val)
static getTermsOfGlossary(int $a_glo_id)
query(string $query)
Run a (read-only) Query on the database.
static _lookLanguage(int $term_id)
lookup term language
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getDefinitionList(int $a_term_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
MDUpdateListener(string $a_element)
Meta data update listener.
exportXML(ilXmlWriter $a_xml_writer, int $a_inst)
static _lookupTermId(int $a_def_id)
Looks up term id for a definition id.
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)
setTermId(int $a_term_id)
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
manipulate(string $query)
Run a (write) Query on the database.
assignPageObject(ilGlossaryDefPage $a_page_object)
ilGlobalTemplateInterface $tpl
static _lookGlossaryID(int $term_id)
get glossary id form term id