45 $this->db =
$DIC->database();
46 $this->
user = $DIC->user();
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);
179 $max_rec =
$ilDB->fetchAssoc($max_set);
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") .
", " .
189 $ilDB->quote($this->getShortTextDirty(),
"integer") .
196 $q =
"SELECT nr FROM glossary_definition WHERE id = " .
197 $ilDB->quote($this->
id,
"integer");
198 $def_set =
$ilDB->query($q);
199 $def_rec =
$ilDB->fetchAssoc($def_set);
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);
229 $def_rec =
$ilDB->fetchAssoc($def_set);
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();
248 $this->deleteMetaData();
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);
265 $def_rec =
$ilDB->fetchAssoc($def_set);
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);
300 $def_rec =
$ilDB->fetchAssoc($def_set);
301 $this->setNr($def_rec[
"nr"]);
304 $q =
"SELECT max(nr) as max_nr FROM glossary_definition WHERE term_id = " .
305 $ilDB->quote($this->getTermId(),
"integer");
306 $max_set =
$ilDB->query($q);
307 $max_rec =
$ilDB->fetchAssoc($max_set);
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"));
333 $this->updateMetaData();
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"));
350 if ($this->getTermId() > 0) {
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();
385 $short = $this->shortenShortText($text);
387 $this->setShortText($short);
388 $this->setShortTextDirty(
false);
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"]);
420 $this->exportXMLMetaData($a_xml_writer);
421 $this->exportXMLDefinition($a_xml_writer, $a_inst);
431 $md2xml =
new ilMD2XML($glo_id, $this->
getId(), $this->getType());
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);
474 $md_creator->setDescription($this->getDescription());
475 $md_creator->setDescriptionLanguage(
$lang);
476 $md_creator->setKeywordLanguage(
$lang);
477 $md_creator->setLanguage(
$lang);
478 $md_creator->create();
484 $md =
new ilMD($glo_id, $this->
getId(), $this->getType());
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]);
492 $md_des->setDescription($this->getDescription());
502 $md =
new ilMD($glo_id, $this->
getId(), $this->getType());
520 switch ($a_element) {
525 $md =
new ilMD($glo_id, $this->
getId(), $this->getType());
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);
534 $this->setDescription($md_des->getDescription());
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"];
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")
594 "UPDATE glossary_definition SET " .
595 " short_text_dirty = " .
$ilDB->quote(1,
"integer")
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTermId(int $a_term_id)
assignPageObject(ilGlossaryDefPage $a_page_object)
static setShortTextsDirty(int $a_glo_id)
Set all short texts of glossary dirty (e.g.
exportXMLDefinition(ilXmlWriter $a_xml_writer, int $a_inst=0)
export page objects meta data to xml
static getDefinitionList(int $a_term_id)
ilGlobalTemplateInterface $tpl
setTitle(string $a_title)
static setShortTextsDirtyGlobally()
Set short texts dirty (for all glossaries)
setDescription(string $a_description)
exportXMLMetaData(ilXmlWriter $a_xml_writer)
static _lookupTermId(int $a_def_id)
Looks up term id for a definition id.
modifyExportIdentifier(string $a_tag, string $a_param, string $a_value)
ilGlossaryDefPage $page_object
exportXML(ilXmlWriter $a_xml_writer, int $a_inst)
setShortTextDirty(bool $a_val)
setShortText(string $a_text)
shortenShortText(string $text)
Shorten short text.
MDUpdateListener(string $a_element)
Meta data update listener.
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...
static _lookLanguage(int $term_id)
lookup term language
static getTermsOfGlossary(int $a_glo_id)
static _lookGlossaryID(int $term_id)
get glossary id form term id
static lookupSnippetLength(int $a_id)
static collectFileItems(ilPageObject $a_page, DOMDocument $a_domdoc)
Get all file items that are used within the page.
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlEndTag(string $tag)
Writes an endtag.
appendXML(string $a_str)
append xml string to document
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...