42        $this->db = 
$DIC->database();
 
   43        $this->
user = $DIC->user();
 
   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);
 
   70        $this->
setNr($def_rec[
"nr"]);
 
   93        $this->term_id = $a_term_id;
 
  123        $this->page_object = $a_page_object;
 
  146        $this->title = $a_title;
 
  156        return $this->description;
 
  166        $this->description = $a_description;
 
  176        $this->short_text_dirty = $a_val;
 
  193    public function create($a_upload = 
false, $a_omit_page_creation = 
false)
 
  199        $this->
setId(
$ilDB->nextId(
"glossary_definition"));
 
  201        $ilAtomQuery = 
$ilDB->buildAtomQuery();
 
  202        $ilAtomQuery->addTableLock(
'glossary_definition');
 
  207            $q = 
"SELECT max(nr) AS max_nr FROM glossary_definition WHERE term_id = " .
 
  209            $max_set = 
$ilDB->query($q);
 
  210            $max_rec = 
$ilDB->fetchAssoc($max_set);
 
  211            $max = (int) $max_rec[
"max_nr"];
 
  214            $ilDB->manipulate(
"INSERT INTO glossary_definition (id, term_id, short_text, nr, short_text_dirty)" .
 
  216                $ilDB->quote($this->getId(), 
"integer") . 
"," .
 
  217                $ilDB->quote($this->getTermId(), 
"integer") . 
"," .
 
  218                $ilDB->quote($this->getShortText(), 
"text") . 
", " .
 
  219                $ilDB->quote(($max + 1), 
"integer") . 
", " .
 
  220                $ilDB->quote($this->getShortTextDirty(), 
"integer") .
 
  227        $q = 
"SELECT nr FROM glossary_definition WHERE id = " .
 
  228            $ilDB->quote($this->
id, 
"integer");
 
  229        $def_set = 
$ilDB->query($q);
 
  230        $def_rec = 
$ilDB->fetchAssoc($def_set);
 
  231        $this->
setNr($def_rec[
"nr"]);
 
  239        if (!$a_omit_page_creation) {
 
  241            $this->page_object->setId($this->
getId());
 
  242            $this->page_object->setParentId($term->getGlossaryId());
 
  243            $this->page_object->create();
 
  247    public function delete()
 
  251        $ilAtomQuery = 
$ilDB->buildAtomQuery();
 
  252        $ilAtomQuery->addTableLock(
"glossary_definition");
 
  257            $q = 
"SELECT * FROM glossary_definition WHERE id = " .
 
  258                $ilDB->quote($this->
id, 
"integer");
 
  259            $def_set = 
$ilDB->query($q);
 
  260            $def_rec = 
$ilDB->fetchAssoc($def_set);
 
  261            $this->
setNr($def_rec[
"nr"]);
 
  264            $ilDB->manipulate(
"UPDATE glossary_definition SET " .
 
  266                " WHERE term_id = " . 
$ilDB->quote($this->getTermId(), 
"integer") . 
" " .
 
  267                " AND nr > " . 
$ilDB->quote($this->getNr(), 
"integer"));
 
  270            $ilDB->manipulate(
"DELETE FROM glossary_definition " .
 
  271                " WHERE id = " . 
$ilDB->quote($this->getId(), 
"integer"));
 
  276        $this->page_object->delete();
 
  287        $ilAtomQuery = 
$ilDB->buildAtomQuery();
 
  288        $ilAtomQuery->addTableLock(
'glossary_definition');
 
  293            $q = 
"SELECT * FROM glossary_definition WHERE id = " .
 
  294                $ilDB->quote($this->
id, 
"integer");
 
  295            $def_set = 
$ilDB->query($q);
 
  296            $def_rec = 
$ilDB->fetchAssoc($def_set);
 
  297            $this->
setNr($def_rec[
"nr"]);
 
  299            if ($this->
getNr() < 2) {
 
  304            $ilDB->
manipulate(
"UPDATE glossary_definition SET " .
 
  306                " WHERE term_id = " . 
$ilDB->quote($this->getTermId(), 
"integer") . 
" " .
 
  307                " AND nr = " . 
$ilDB->quote(($this->getNr() - 1), 
"integer"));
 
  310            $ilDB->manipulate(
"UPDATE glossary_definition SET " .
 
  312                " WHERE term_id = " . 
$ilDB->quote($this->getTermId(), 
"integer") . 
" " .
 
  313                " AND id = " . 
$ilDB->quote($this->getId(), 
"integer"));
 
  322        $ilAtomQuery = 
$ilDB->buildAtomQuery();
 
  323        $ilAtomQuery->addTableLock(
'glossary_definition');
 
  328            $q = 
"SELECT * FROM glossary_definition WHERE id = " .
 
  329                $ilDB->quote($this->
id, 
"integer");
 
  330            $def_set = 
$ilDB->query($q);
 
  331            $def_rec = 
$ilDB->fetchAssoc($def_set);
 
  332            $this->
setNr($def_rec[
"nr"]);
 
  335            $q = 
"SELECT max(nr) as max_nr FROM glossary_definition WHERE term_id = " .
 
  337            $max_set = 
$ilDB->query($q);
 
  338            $max_rec = 
$ilDB->fetchAssoc($max_set);
 
  340            if ($this->
getNr() >= $max_rec[
"max_nr"]) {
 
  345            $ilDB->manipulate(
"UPDATE glossary_definition SET " .
 
  347                " WHERE term_id = " . 
$ilDB->quote($this->getTermId(), 
"integer") . 
" " .
 
  348                " AND nr = " . 
$ilDB->quote(($this->getNr() + 1), 
"integer"));
 
  351            $ilDB->manipulate(
"UPDATE glossary_definition SET " .
 
  353                " WHERE term_id = " . 
$ilDB->quote($this->getTermId(), 
"integer") . 
" " .
 
  354                " AND id = " . 
$ilDB->quote($this->getId(), 
"integer"));
 
  367        $ilDB->manipulate(
"UPDATE glossary_definition SET " .
 
  368            " term_id = " . 
$ilDB->quote($this->getTermId(), 
"integer") . 
", " .
 
  369            " nr = " . 
$ilDB->quote($this->getNr(), 
"integer") . 
", " .
 
  370            " short_text = " . 
$ilDB->quote($this->getShortText(), 
"text") . 
", " .
 
  371            " short_text_dirty = " . 
$ilDB->quote($this->getShortTextDirty(), 
"integer") . 
" " .
 
  372            " WHERE id = " . 
$ilDB->quote($this->getId(), 
"integer"));
 
  388            if ($snippet_length > 0) {
 
  389                $a_length = $snippet_length;
 
  393        $text = str_replace(
"<br/>", 
"<br>", $text);
 
  394        $text = strip_tags($text, 
"<br>");
 
  395        if (is_int(strpos(substr($text, $a_length - 16 - 5, 10), 
"[tex]"))) {
 
  401        $ltexs = strrpos($short, 
"[tex]");
 
  402        $ltexe = strrpos($short, 
"[/tex]");
 
  403        if ($ltexs > $ltexe) {
 
  404            $ltexe = strpos($text, 
"[/tex]", $ltexs);
 
  417        $this->page_object->buildDom();
 
  418        $text = $this->page_object->getFirstParagraphText();
 
  436        $q = 
"SELECT * FROM glossary_definition WHERE term_id = " .
 
  437            $ilDB->quote($a_term_id, 
"integer") .
 
  439        $def_set = 
$ilDB->query($q);
 
  440        while ($def_rec = 
$ilDB->fetchAssoc($def_set)) {
 
  441            $defs[] = array(
"term_id" => $def_rec[
"term_id"],
 
  442                "page_id" => $def_rec[
"page_id"], 
"id" => $def_rec[
"id"],
 
  443                "short_text" => strip_tags($def_rec[
"short_text"], 
"<br>"),
 
  444                "nr" => $def_rec[
"nr"],
 
  445                "short_text_dirty" => $def_rec[
"short_text_dirty"]);
 
  456        $a_xml_writer->xmlStartTag(
"Definition", $attrs);
 
  461        $a_xml_writer->xmlEndTag(
"Definition");
 
  475        $md2xml->setExportMode(
true);
 
  476        $md2xml->startExport();
 
  477        $a_xml_writer->appendXML($md2xml->getXML());
 
  485        if ($a_tag == 
"Identifier" && $a_param == 
"Entry") {
 
  486            $a_value = 
"il_" . IL_INST_ID . 
"_gdf_" . $this->
getId();
 
  501        $this->page_object->buildDom();
 
  502        $this->page_object->insertInstIntoIDs($a_inst);
 
  503        $this->mobs_contained = $this->page_object->collectMediaObjects(
false);
 
  505        $xml = $this->page_object->getXMLFromDom(
false, 
false, 
false, 
"", 
true);
 
  506        $xml = str_replace(
"&", 
"&", 
$xml);
 
  507        $a_xml_writer->appendXML(
$xml);
 
  509        $this->page_object->freeDom();
 
  522        $md_creator->setTitle($this->
getTitle());
 
  523        $md_creator->setTitleLanguage(
$lang);
 
  525        $md_creator->setDescriptionLanguage(
$lang);
 
  526        $md_creator->setKeywordLanguage(
$lang);
 
  527        $md_creator->setLanguage(
$lang);
 
  529        $md_creator->create();
 
  541        $md_gen = $md->getGeneral();
 
  542        $md_gen->setTitle($this->
getTitle());
 
  545        $md_des_ids = $md_gen->getDescriptionIds();
 
  546        if (count($md_des_ids) > 0) {
 
  547            $md_des = $md_gen->getDescription($md_des_ids[0]);
 
  581        switch ($a_element) {
 
  587                $md_gen = $md->getGeneral();
 
  590                $this->
setTitle($md_gen->getTitle());
 
  592                foreach ($md_gen->getDescriptionIds() as 
$id) {
 
  593                    $md_des = $md_gen->getDescription(
$id);
 
  617        $q = 
"SELECT * FROM glossary_definition WHERE id = " .
 
  618            $ilDB->quote($a_def_id, 
"integer");
 
  619        $def_set = 
$ilDB->query($q);
 
  620        $def_rec = 
$ilDB->fetchAssoc($def_set);
 
  622        return $def_rec[
"term_id"];
 
  641                "UPDATE glossary_definition SET " .
 
  642                " short_text_dirty = " . 
$ilDB->quote(1, 
"integer") .
 
  661            "UPDATE glossary_definition SET " .
 
  662            " short_text_dirty = " . 
$ilDB->quote(1, 
"integer")
 
An exception for terminatinating execution or to throw for unit testing.
Glossary definition page object.
Class ilGlossaryDefinition.
exportXML(&$a_xml_writer, $a_inst)
export xml
createMetaData()
create meta data entry
static _lookupTermId($a_def_id)
Looks up term id for a definition id.
getTitle()
get title of content object
updateMetaData()
update meta data entry
static getDefinitionList($a_term_id)
static
setDescription($a_description)
Set description.
setTitle($a_title)
set title of content object
setShortTextDirty($a_val)
Set short text dirty.
static setShortTextsDirtyGlobally()
Set short texts dirty.
static setShortTextsDirty($a_glo_id)
Set short texts dirty.
__construct($a_id=0)
Constructor @access public.
exportXMLDefinition(&$a_xml_writer, $a_inst=0)
export page objects meta data to xml (see ilias_co.dtd)
assignPageObject(&$a_page_object)
getShortTextDirty()
Get short text dirty.
deleteMetaData()
delete meta data entry
getDescription()
Get description.
modifyExportIdentifier($a_tag, $a_param, $a_value)
read()
read data of content object
create($a_upload=false, $a_omit_page_creation=false)
Create definition.
exportXMLMetaData(&$a_xml_writer)
export content objects meta data to xml (see ilias_co.dtd)
shortenShortText($text)
Shorten short text.
MDUpdateListener($a_element)
Meta data update listener.
static _lookGlossaryID($term_id)
get glossary id form term id
static _lookLanguage($term_id)
lookup term language
static getTermsOfGlossary($a_glo_id)
Get terms of glossary.
static lookupSnippetLength($a_id)
Lookup snippet length.
static collectFileItems($a_page, $a_domdoc)
Get all file items that are used within the page.
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
manipulate($query)
Run a (write) Query on the database.