4 require_once(
"./Modules/Glossary/classes/class.ilGlossaryDefPage.php");
45 $this->db = $DIC->database();
46 $this->
user = $DIC->user();
47 $lng = $DIC->language();
66 $q =
"SELECT * FROM glossary_definition WHERE id = " .
67 $ilDB->quote($this->
id,
"integer");
68 $def_set =
$ilDB->query($q);
69 $def_rec =
$ilDB->fetchAssoc($def_set);
73 $this->
setNr($def_rec[
"nr"]);
96 $this->term_id = $a_term_id;
126 $this->page_object = $a_page_object;
149 $this->title = $a_title;
169 $this->description = $a_description;
179 $this->short_text_dirty = $a_val;
196 public function create($a_upload =
false, $a_omit_page_creation =
false)
202 $this->
setId(
$ilDB->nextId(
"glossary_definition"));
204 $ilAtomQuery =
$ilDB->buildAtomQuery();
205 $ilAtomQuery->addTableLock(
'glossary_definition');
210 $q =
"SELECT max(nr) AS max_nr FROM glossary_definition WHERE term_id = " .
212 $max_set = $ilDB->
query($q);
214 $max = (int) $max_rec[
"max_nr"];
217 $ilDB->
manipulate(
"INSERT INTO glossary_definition (id, term_id, short_text, nr, short_text_dirty)" .
219 $ilDB->
quote($this->getId(),
"integer") .
"," .
220 $ilDB->
quote($this->getTermId(),
"integer") .
"," .
221 $ilDB->
quote($this->getShortText(),
"text") .
", " .
222 $ilDB->
quote(($max + 1),
"integer") .
", " .
230 $q =
"SELECT nr FROM glossary_definition WHERE id = " .
231 $ilDB->
quote($this->
id,
"integer");
232 $def_set = $ilDB->
query($q);
234 $this->
setNr($def_rec[
"nr"]);
242 if (!$a_omit_page_creation) {
244 $this->page_object->setId($this->
getId());
245 $this->page_object->setParentId($term->getGlossaryId());
246 $this->page_object->create();
250 public function delete()
254 $ilAtomQuery =
$ilDB->buildAtomQuery();
255 $ilAtomQuery->addTableLock(
"glossary_definition");
260 $q =
"SELECT * FROM glossary_definition WHERE id = " .
261 $ilDB->
quote($this->
id,
"integer");
262 $def_set = $ilDB->
query($q);
264 $this->
setNr($def_rec[
"nr"]);
267 $ilDB->
manipulate(
"UPDATE glossary_definition SET " .
269 " WHERE term_id = " . $ilDB->
quote($this->getTermId(),
"integer") .
" " .
270 " AND nr > " . $ilDB->
quote($this->getNr(),
"integer"));
273 $ilDB->
manipulate(
"DELETE FROM glossary_definition " .
274 " WHERE id = " . $ilDB->
quote($this->getId(),
"integer"));
279 $this->page_object->delete();
290 $ilAtomQuery =
$ilDB->buildAtomQuery();
291 $ilAtomQuery->addTableLock(
'glossary_definition');
296 $q =
"SELECT * FROM glossary_definition WHERE id = " .
297 $ilDB->
quote($this->
id,
"integer");
298 $def_set = $ilDB->
query($q);
300 $this->
setNr($def_rec[
"nr"]);
302 if ($this->
getNr() < 2) {
307 $ilDB->
manipulate(
"UPDATE glossary_definition SET " .
309 " WHERE term_id = " . $ilDB->
quote($this->getTermId(),
"integer") .
" " .
310 " AND nr = " . $ilDB->
quote(($this->getNr() - 1),
"integer"));
313 $ilDB->
manipulate(
"UPDATE glossary_definition SET " .
315 " WHERE term_id = " . $ilDB->
quote($this->getTermId(),
"integer") .
" " .
316 " AND id = " . $ilDB->
quote($this->getId(),
"integer"));
325 $ilAtomQuery =
$ilDB->buildAtomQuery();
326 $ilAtomQuery->addTableLock(
'glossary_definition');
331 $q =
"SELECT * FROM glossary_definition WHERE id = " .
332 $ilDB->
quote($this->
id,
"integer");
333 $def_set = $ilDB->
query($q);
335 $this->
setNr($def_rec[
"nr"]);
338 $q =
"SELECT max(nr) as max_nr FROM glossary_definition WHERE term_id = " .
340 $max_set = $ilDB->
query($q);
343 if ($this->
getNr() >= $max_rec[
"max_nr"]) {
348 $ilDB->
manipulate(
"UPDATE glossary_definition SET " .
350 " WHERE term_id = " . $ilDB->
quote($this->getTermId(),
"integer") .
" " .
351 " AND nr = " . $ilDB->
quote(($this->getNr() + 1),
"integer"));
354 $ilDB->
manipulate(
"UPDATE glossary_definition SET " .
356 " WHERE term_id = " . $ilDB->
quote($this->getTermId(),
"integer") .
" " .
357 " AND id = " . $ilDB->
quote($this->getId(),
"integer"));
370 $ilDB->manipulate(
"UPDATE glossary_definition SET " .
371 " term_id = " .
$ilDB->quote($this->getTermId(),
"integer") .
", " .
372 " nr = " .
$ilDB->quote($this->getNr(),
"integer") .
", " .
373 " short_text = " .
$ilDB->quote($this->getShortText(),
"text") .
", " .
374 " short_text_dirty = " .
$ilDB->quote($this->getShortTextDirty(),
"integer") .
" " .
375 " WHERE id = " .
$ilDB->quote($this->getId(),
"integer"));
389 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
390 include_once(
"./Modules/Glossary/classes/class.ilGlossaryTerm.php");
393 if ($snippet_length > 0) {
394 $a_length = $snippet_length;
400 if (is_int(strpos(substr(
$text, $a_length - 16 - 5, 10),
"[tex]"))) {
406 $ltexs = strrpos($short,
"[tex]");
407 $ltexe = strrpos($short,
"[/tex]");
408 if ($ltexs > $ltexe) {
409 $ltexe = strpos(
$text,
"[/tex]", $ltexs);
422 $this->page_object->buildDom();
423 $text = $this->page_object->getFirstParagraphText();
438 $ilDB = $DIC->database();
441 $q =
"SELECT * FROM glossary_definition WHERE term_id = " .
442 $ilDB->quote($a_term_id,
"integer") .
444 $def_set =
$ilDB->query($q);
445 while ($def_rec =
$ilDB->fetchAssoc($def_set)) {
446 $defs[] = array(
"term_id" => $def_rec[
"term_id"],
447 "page_id" => $def_rec[
"page_id"],
"id" => $def_rec[
"id"],
448 "short_text" => strip_tags($def_rec[
"short_text"],
"<br>"),
449 "nr" => $def_rec[
"nr"],
450 "short_text_dirty" => $def_rec[
"short_text_dirty"]);
461 $a_xml_writer->xmlStartTag(
"Definition", $attrs);
466 $a_xml_writer->xmlEndTag(
"Definition");
479 include_once(
"Services/MetaData/classes/class.ilMD2XML.php");
481 $md2xml->setExportMode(
true);
482 $md2xml->startExport();
483 $a_xml_writer->appendXML($md2xml->getXML());
491 if ($a_tag ==
"Identifier" && $a_param ==
"Entry") {
492 $a_value =
"il_" . IL_INST_ID .
"_gdf_" . $this->
getId();
507 $this->page_object->buildDom();
508 $this->page_object->insertInstIntoIDs($a_inst);
509 $this->mobs_contained = $this->page_object->collectMediaObjects(
false);
510 include_once(
"./Services/COPage/classes/class.ilPCFileList.php");
512 $xml = $this->page_object->getXMLFromDom(
false,
false,
false,
"",
true);
513 $xml = str_replace(
"&",
"&", $xml);
514 $a_xml_writer->appendXML($xml);
516 $this->page_object->freeDom();
524 include_once
'Services/MetaData/classes/class.ilMDCreator.php';
531 $md_creator->setTitle($this->
getTitle());
532 $md_creator->setTitleLanguage(
$lang);
534 $md_creator->setDescriptionLanguage(
$lang);
535 $md_creator->setKeywordLanguage(
$lang);
536 $md_creator->setLanguage(
$lang);
538 $md_creator->create();
548 include_once(
"Services/MetaData/classes/class.ilMD.php");
549 include_once(
"Services/MetaData/classes/class.ilMDGeneral.php");
550 include_once(
"Services/MetaData/classes/class.ilMDDescription.php");
554 $md_gen = $md->getGeneral();
555 $md_gen->setTitle($this->
getTitle());
558 $md_des_ids = $md_gen->getDescriptionIds();
559 if (count($md_des_ids) > 0) {
560 $md_des = $md_gen->getDescription($md_des_ids[0]);
573 include_once(
'Services/MetaData/classes/class.ilMD.php');
595 include_once
'Services/MetaData/classes/class.ilMD.php';
597 switch ($a_element) {
603 $md_gen = $md->getGeneral();
606 $this->
setTitle($md_gen->getTitle());
608 foreach ($md_gen->getDescriptionIds() as
$id) {
609 $md_des = $md_gen->getDescription(
$id);
631 $ilDB = $DIC->database();
633 $q =
"SELECT * FROM glossary_definition WHERE id = " .
634 $ilDB->quote($a_def_id,
"integer");
635 $def_set =
$ilDB->query($q);
636 $def_rec =
$ilDB->fetchAssoc($def_set);
638 return $def_rec[
"term_id"];
651 $ilDB = $DIC->database();
653 include_once(
"./Modules/Glossary/classes/class.ilGlossaryTerm.php");
658 "UPDATE glossary_definition SET " .
659 " short_text_dirty = " .
$ilDB->quote(1,
"integer") .
660 " WHERE term_id = " .
$ilDB->quote($term_id,
"integer")
675 $ilDB = $DIC->database();
678 "UPDATE glossary_definition SET " .
679 " short_text_dirty = " .
$ilDB->quote(1,
"integer")
static getDefinitionList($a_term_id)
static
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
assignPageObject(&$a_page_object)
__construct($a_id=0)
Constructor public.
modifyExportIdentifier($a_tag, $a_param, $a_value)
updateMetaData()
update meta data entry
getTitle()
get title of content object
setShortTextDirty($a_val)
Set short text dirty.
static _lookupTermId($a_def_id)
Looks up term id for a definition id.
setDescription($a_description)
Set description.
static setShortTextsDirtyGlobally()
Set short texts dirty.
static collectFileItems($a_page, $a_domdoc)
Get all file items that are used within the page.
deleteMetaData()
delete meta data entry
setTitle($a_title)
set title of content object
exportXMLDefinition(&$a_xml_writer, $a_inst=0)
export page objects meta data to xml (see ilias_co.dtd)
read()
read data of content object
static _lookLanguage($term_id)
lookup term language
Glossary definition page object.
MDUpdateListener($a_element)
Meta data update listener.
static _lookGlossaryID($term_id)
get glossary id form term id
Class ilGlossaryDefinition.
getDescription()
Get description.
createMetaData()
create meta data entry
exportXML(&$a_xml_writer, $a_inst)
export xml
query($query)
Run a (read-only) Query on the database.
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
fetchAssoc($query_result)
static getTermsOfGlossary($a_glo_id)
Get terms of glossary.
exportXMLMetaData(&$a_xml_writer)
export content objects meta data to xml (see ilias_co.dtd)
shortenShortText($text)
Shorten short text.
manipulate($query)
Run a (write) Query on the database.
static setShortTextsDirty($a_glo_id)
Set short texts dirty.
getShortTextDirty()
Get short text dirty.
static lookupSnippetLength($a_id)
Lookup snippet length.
create($a_upload=false, $a_omit_page_creation=false)
Create definition.