ILIAS  release_7 Revision v7.30-3-g800a261c036
ilGlossaryDefinition Class Reference

Class ilGlossaryDefinition. More...

+ Collaboration diagram for ilGlossaryDefinition:

Public Member Functions

 __construct ($a_id=0)
 Constructor public. More...
 
 read ()
 read data of content object More...
 
 setId ($a_id)
 
 getId ()
 
 getType ()
 
 setTermId ($a_term_id)
 
 getTermId ()
 
 setShortText ($a_text)
 
 getShortText ()
 
 setNr ($a_nr)
 
 getNr ()
 
 assignPageObject (&$a_page_object)
 
getPageObject ()
 
 getTitle ()
 get title of content object More...
 
 setTitle ($a_title)
 set title of content object More...
 
 getDescription ()
 Get description. More...
 
 setDescription ($a_description)
 Set description. More...
 
 setShortTextDirty ($a_val)
 Set short text dirty. More...
 
 getShortTextDirty ()
 Get short text dirty. More...
 
 create ($a_upload=false, $a_omit_page_creation=false)
 Create definition. More...
 
 delete ()
 
 moveUp ()
 
 moveDown ()
 
 update ()
 
 shortenShortText ($text)
 Shorten short text. More...
 
 updateShortText ()
 
 exportXML (&$a_xml_writer, $a_inst)
 export xml More...
 
 exportXMLMetaData (&$a_xml_writer)
 export content objects meta data to xml (see ilias_co.dtd) More...
 
 modifyExportIdentifier ($a_tag, $a_param, $a_value)
 
 exportXMLDefinition (&$a_xml_writer, $a_inst=0)
 export page objects meta data to xml (see ilias_co.dtd) More...
 
 createMetaData ()
 create meta data entry More...
 
 updateMetaData ()
 update meta data entry More...
 
 deleteMetaData ()
 delete meta data entry More...
 
 MDUpdateListener ($a_element)
 Meta data update listener. More...
 

Static Public Member Functions

static getDefinitionList ($a_term_id)
 static More...
 
static _lookupTermId ($a_def_id)
 Looks up term id for a definition id. More...
 
static setShortTextsDirty ($a_glo_id)
 Set short texts dirty. More...
 
static setShortTextsDirtyGlobally ()
 Set short texts dirty. More...
 

Data Fields

 $lng
 
 $tpl
 
 $id
 
 $term_id
 
 $glo_id
 
 $page_object
 
 $short_text
 
 $nr
 
 $short_text_dirty = false
 

Protected Attributes

 $db
 
 $user
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilGlossaryDefinition::__construct (   $a_id = 0)

Constructor public.

Definition at line 38 of file class.ilGlossaryDefinition.php.

References $DIC, $lng, $tpl, read(), and user().

39  {
40  global $DIC;
41 
42  $this->db = $DIC->database();
43  $this->user = $DIC->user();
44  $lng = $DIC->language();
45  $tpl = $DIC["tpl"];
46 
47  $this->lng = $lng;
48  $this->tpl = $tpl;
49 
50  $this->id = $a_id;
51  if ($a_id != 0) {
52  $this->read();
53  }
54  }
user()
Definition: user.php:4
global $DIC
Definition: goto.php:24
read()
read data of content object
+ Here is the call graph for this function:

Member Function Documentation

◆ _lookupTermId()

static ilGlossaryDefinition::_lookupTermId (   $a_def_id)
static

Looks up term id for a definition id.

Parameters
int$a_def_iddefinition id

Definition at line 611 of file class.ilGlossaryDefinition.php.

References $DIC, and $ilDB.

Referenced by ilObjMediaObjectAccess\checkAccessGlossaryTerm(), ilTermUsagesTableGUI\fillRow(), ilMediaPoolPageUsagesTableGUI\fillRow(), ilMediaObjectUsagesTableGUI\fillRow(), ilObjMediaObject\getParentObjectIdForUsage(), ilLMContentSearch\performSearch(), and ilGlossaryDefPageGUI\postOutputProcessing().

612  {
613  global $DIC;
614 
615  $ilDB = $DIC->database();
616 
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);
621 
622  return $def_rec["term_id"];
623  }
global $DIC
Definition: goto.php:24
global $ilDB
+ Here is the caller graph for this function:

◆ assignPageObject()

ilGlossaryDefinition::assignPageObject ( $a_page_object)

Definition at line 121 of file class.ilGlossaryDefinition.php.

122  {
123  $this->page_object = $a_page_object;
124  }

◆ create()

ilGlossaryDefinition::create (   $a_upload = false,
  $a_omit_page_creation = false 
)

Create definition.

Parameters
booleanupload true/false

Definition at line 193 of file class.ilGlossaryDefinition.php.

References $db, $ilDB, createMetaData(), ilDBInterface\fetchAssoc(), getId(), getShortTextDirty(), getTermId(), ilDBInterface\manipulate(), ilDBInterface\query(), ilDBInterface\quote(), setId(), and setNr().

194  {
195  $ilDB = $this->db;
196 
197  $term = new ilGlossaryTerm($this->getTermId());
198 
199  $this->setId($ilDB->nextId("glossary_definition"));
200 
201  $ilAtomQuery = $ilDB->buildAtomQuery();
202  $ilAtomQuery->addTableLock('glossary_definition');
203 
204  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDB) {
205 
206  // get maximum definition number
207  $q = "SELECT max(nr) AS max_nr FROM glossary_definition WHERE term_id = " .
208  $ilDB->quote($this->getTermId(), "integer");
209  $max_set = $ilDB->query($q);
210  $max_rec = $ilDB->fetchAssoc($max_set);
211  $max = (int) $max_rec["max_nr"];
212 
213  // insert new definition record
214  $ilDB->manipulate("INSERT INTO glossary_definition (id, term_id, short_text, nr, short_text_dirty)" .
215  " VALUES (" .
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") .
221  ")");
222  });
223 
224  $ilAtomQuery->run();
225 
226  // get number
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"]);
232 
233  // meta data will be created by
234  // import parser
235  if (!$a_upload) {
236  $this->createMetaData();
237  }
238 
239  if (!$a_omit_page_creation) {
240  $this->page_object = new ilGlossaryDefPage();
241  $this->page_object->setId($this->getId());
242  $this->page_object->setParentId($term->getGlossaryId());
243  $this->page_object->create();
244  }
245  }
Glossary terms.
quote($value, $type)
Glossary definition page object.
createMetaData()
create meta data entry
global $ilDB
query($query)
Run a (read-only) Query on the database.
fetchAssoc($query_result)
manipulate($query)
Run a (write) Query on the database.
getShortTextDirty()
Get short text dirty.
+ Here is the call graph for this function:

◆ createMetaData()

ilGlossaryDefinition::createMetaData ( )

create meta data entry

Definition at line 515 of file class.ilGlossaryDefinition.php.

References $glo_id, $ilUser, $lang, $user, ilGlossaryTerm\_lookGlossaryID(), ilGlossaryTerm\_lookLanguage(), getDescription(), getId(), getTermId(), getTitle(), and getType().

Referenced by create().

516  {
518 
521  $md_creator = new ilMDCreator($glo_id, $this->getId(), $this->getType());
522  $md_creator->setTitle($this->getTitle());
523  $md_creator->setTitleLanguage($lang);
524  $md_creator->setDescription($this->getDescription());
525  $md_creator->setDescriptionLanguage($lang);
526  $md_creator->setKeywordLanguage($lang);
527  $md_creator->setLanguage($lang);
528  //echo "-".$this->getTitle()."-"; exit;
529  $md_creator->create();
530 
531  return true;
532  }
getTitle()
get title of content object
static _lookLanguage($term_id)
lookup term language
static _lookGlossaryID($term_id)
get glossary id form term id
$lang
Definition: xapiexit.php:8
$ilUser
Definition: imgupload.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilGlossaryDefinition::delete ( )

Definition at line 247 of file class.ilGlossaryDefinition.php.

References $db, $ilDB, deleteMetaData(), ilDBInterface\fetchAssoc(), ilDBInterface\manipulate(), ilDBInterface\query(), ilDBInterface\quote(), and setNr().

248  {
249  $ilDB = $this->db;
250 
251  $ilAtomQuery = $ilDB->buildAtomQuery();
252  $ilAtomQuery->addTableLock("glossary_definition");
253 
254  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDB) {
255 
256  // be sure to get the right number
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"]);
262 
263  // update numbers of other definitions
264  $ilDB->manipulate("UPDATE glossary_definition SET " .
265  " nr = nr - 1 " .
266  " WHERE term_id = " . $ilDB->quote($this->getTermId(), "integer") . " " .
267  " AND nr > " . $ilDB->quote($this->getNr(), "integer"));
268 
269  // delete current definition
270  $ilDB->manipulate("DELETE FROM glossary_definition " .
271  " WHERE id = " . $ilDB->quote($this->getId(), "integer"));
272  });
273  $ilAtomQuery->run();
274 
275  // delete page and meta data
276  $this->page_object->delete();
277 
278  // delete meta data
279  $this->deleteMetaData();
280  }
quote($value, $type)
deleteMetaData()
delete meta data entry
global $ilDB
query($query)
Run a (read-only) Query on the database.
fetchAssoc($query_result)
manipulate($query)
Run a (write) Query on the database.
+ Here is the call graph for this function:

◆ deleteMetaData()

ilGlossaryDefinition::deleteMetaData ( )

delete meta data entry

Definition at line 557 of file class.ilGlossaryDefinition.php.

References $glo_id, ilGlossaryTerm\_lookGlossaryID(), getId(), getTermId(), and getType().

Referenced by delete().

558  {
559  // Delete meta data
561  $md = new ilMD($glo_id, $this->getId(), $this->getType());
562  $md->deleteAll();
563  }
static _lookGlossaryID($term_id)
get glossary id form term id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportXML()

ilGlossaryDefinition::exportXML ( $a_xml_writer,
  $a_inst 
)

export xml

Definition at line 453 of file class.ilGlossaryDefinition.php.

References exportXMLDefinition(), and exportXMLMetaData().

454  {
455  $attrs = array();
456  $a_xml_writer->xmlStartTag("Definition", $attrs);
457 
458  $this->exportXMLMetaData($a_xml_writer);
459  $this->exportXMLDefinition($a_xml_writer, $a_inst);
460 
461  $a_xml_writer->xmlEndTag("Definition");
462  }
exportXMLDefinition(&$a_xml_writer, $a_inst=0)
export page objects meta data to xml (see ilias_co.dtd)
exportXMLMetaData(&$a_xml_writer)
export content objects meta data to xml (see ilias_co.dtd)
+ Here is the call graph for this function:

◆ exportXMLDefinition()

ilGlossaryDefinition::exportXMLDefinition ( $a_xml_writer,
  $a_inst = 0 
)

export page objects meta data to xml (see ilias_co.dtd)

Parameters
object$a_xml_writerilXmlWriter object that receives the xml data

Definition at line 499 of file class.ilGlossaryDefinition.php.

References $xml, and ilPCFileList\collectFileItems().

Referenced by exportXML().

500  {
501  $this->page_object->buildDom();
502  $this->page_object->insertInstIntoIDs($a_inst);
503  $this->mobs_contained = $this->page_object->collectMediaObjects(false);
504  $this->files_contained = ilPCFileList::collectFileItems($this->page_object, $this->page_object->getDomDoc());
505  $xml = $this->page_object->getXMLFromDom(false, false, false, "", true);
506  $xml = str_replace("&", "&", $xml);
507  $a_xml_writer->appendXML($xml);
508 
509  $this->page_object->freeDom();
510  }
static collectFileItems($a_page, $a_domdoc)
Get all file items that are used within the page.
$xml
Definition: metadata.php:332
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportXMLMetaData()

ilGlossaryDefinition::exportXMLMetaData ( $a_xml_writer)

export content objects meta data to xml (see ilias_co.dtd)

Parameters
object$a_xml_writerilXmlWriter object that receives the xml data

Definition at line 471 of file class.ilGlossaryDefinition.php.

References $glo_id, ilGlossaryTerm\_lookGlossaryID(), getId(), getTermId(), and getType().

Referenced by exportXML().

472  {
474  $md2xml = new ilMD2XML($glo_id, $this->getId(), $this->getType());
475  $md2xml->setExportMode(true);
476  $md2xml->startExport();
477  $a_xml_writer->appendXML($md2xml->getXML());
478  }
static _lookGlossaryID($term_id)
get glossary id form term id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefinitionList()

static ilGlossaryDefinition::getDefinitionList (   $a_term_id)
static

static

Definition at line 429 of file class.ilGlossaryDefinition.php.

References $DIC, and $ilDB.

Referenced by ilGlossaryTerm\_copyTerm(), ilSoapGLOStructureReader\_parseStructure(), ilObjGlossary\autoLinkGlossaryTerms(), ilCOPageHTMLExport\collectPageElements(), ilGlossaryTerm\delete(), ILIAS\Glossary\Export\GlossaryHtmlExport\exportHTMLGlossaryTerms(), ilSCORM2004Asset\exportHTMLPageObjects(), ilGlossaryTerm\exportXML(), ilObjGlossary\exportXML(), ilTermQuickListTableGUI\fillRow(), ilPresentationListTableGUI\fillRow(), ilTermListTableGUI\fillRow(), ilGlossaryTermGUI\getInternalLinks(), ilGlossaryExporter\getXmlExportTailDependencies(), ilGlossaryTermGUI\listDefinitions(), ilGlossaryPresentationGUI\listDefinitions(), ilGlossaryTermGUI\output(), and ilLMPresentationGUI\showPrintView().

430  {
431  global $DIC;
432 
433  $ilDB = $DIC->database();
434 
435  $defs = array();
436  $q = "SELECT * FROM glossary_definition WHERE term_id = " .
437  $ilDB->quote($a_term_id, "integer") .
438  " ORDER BY nr";
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"]);
446  }
447  return $defs;
448  }
global $DIC
Definition: goto.php:24
global $ilDB
+ Here is the caller graph for this function:

◆ getDescription()

ilGlossaryDefinition::getDescription ( )

Get description.

Returns
string description

Definition at line 154 of file class.ilGlossaryDefinition.php.

Referenced by createMetaData(), and updateMetaData().

155  {
156  return $this->description;
157  }
+ Here is the caller graph for this function:

◆ getId()

ilGlossaryDefinition::getId ( )

Definition at line 81 of file class.ilGlossaryDefinition.php.

References $id.

Referenced by create(), createMetaData(), deleteMetaData(), exportXMLMetaData(), MDUpdateListener(), modifyExportIdentifier(), and updateMetaData().

82  {
83  return $this->id;
84  }
+ Here is the caller graph for this function:

◆ getNr()

ilGlossaryDefinition::getNr ( )

Definition at line 116 of file class.ilGlossaryDefinition.php.

References $nr.

Referenced by moveDown(), and moveUp().

117  {
118  return $this->nr;
119  }
+ Here is the caller graph for this function:

◆ getPageObject()

& ilGlossaryDefinition::getPageObject ( )

Definition at line 126 of file class.ilGlossaryDefinition.php.

References $page_object.

127  {
128  return $this->page_object;
129  }

◆ getShortText()

ilGlossaryDefinition::getShortText ( )

Definition at line 106 of file class.ilGlossaryDefinition.php.

References $short_text.

107  {
108  return $this->short_text;
109  }

◆ getShortTextDirty()

ilGlossaryDefinition::getShortTextDirty ( )

Get short text dirty.

Returns
boolean short text dirty

Definition at line 184 of file class.ilGlossaryDefinition.php.

References $short_text_dirty.

Referenced by create().

+ Here is the caller graph for this function:

◆ getTermId()

ilGlossaryDefinition::getTermId ( )

Definition at line 96 of file class.ilGlossaryDefinition.php.

References $term_id.

Referenced by create(), createMetaData(), deleteMetaData(), exportXMLMetaData(), MDUpdateListener(), moveDown(), shortenShortText(), and updateMetaData().

+ Here is the caller graph for this function:

◆ getTitle()

ilGlossaryDefinition::getTitle ( )

get title of content object

Returns
string title

Definition at line 136 of file class.ilGlossaryDefinition.php.

Referenced by createMetaData(), and updateMetaData().

137  {
138  return $this->title;
139  }
+ Here is the caller graph for this function:

◆ getType()

ilGlossaryDefinition::getType ( )

Definition at line 86 of file class.ilGlossaryDefinition.php.

Referenced by createMetaData(), deleteMetaData(), exportXMLMetaData(), MDUpdateListener(), and updateMetaData().

87  {
88  return "gdf";
89  }
+ Here is the caller graph for this function:

◆ MDUpdateListener()

ilGlossaryDefinition::MDUpdateListener (   $a_element)

Meta data update listener.

Important note: Do never call create() or update() method of ilObject here. It would result in an endless loop: update object -> update meta -> update object -> ... Use static _writeTitle() ... methods instead.

Even if this is not stored to db, it should be stored to the object e.g. for during import parsing

Parameters
string$a_element

Definition at line 579 of file class.ilGlossaryDefinition.php.

References $glo_id, $id, ilGlossaryTerm\_lookGlossaryID(), getId(), getTermId(), getType(), setDescription(), and setTitle().

580  {
581  switch ($a_element) {
582  case 'General':
583 
584  // Update Title and description
586  $md = new ilMD($glo_id, $this->getId(), $this->getType());
587  $md_gen = $md->getGeneral();
588 
589  //ilObject::_writeTitle($this->getId(),$md_gen->getTitle());
590  $this->setTitle($md_gen->getTitle());
591 
592  foreach ($md_gen->getDescriptionIds() as $id) {
593  $md_des = $md_gen->getDescription($id);
594  //ilObject::_writeDescription($this->getId(),$md_des->getDescription());
595  $this->setDescription($md_des->getDescription());
596  break;
597  }
598 
599  break;
600 
601  default:
602  }
603  return true;
604  }
setDescription($a_description)
Set description.
setTitle($a_title)
set title of content object
static _lookGlossaryID($term_id)
get glossary id form term id
+ Here is the call graph for this function:

◆ modifyExportIdentifier()

ilGlossaryDefinition::modifyExportIdentifier (   $a_tag,
  $a_param,
  $a_value 
)

Definition at line 483 of file class.ilGlossaryDefinition.php.

References getId(), and IL_INST_ID.

484  {
485  if ($a_tag == "Identifier" && $a_param == "Entry") {
486  $a_value = "il_" . IL_INST_ID . "_gdf_" . $this->getId();
487  }
488 
489  return $a_value;
490  }
const IL_INST_ID
Definition: constants.php:38
+ Here is the call graph for this function:

◆ moveDown()

ilGlossaryDefinition::moveDown ( )

Definition at line 318 of file class.ilGlossaryDefinition.php.

References $db, $ilDB, ilDBInterface\fetchAssoc(), getNr(), getTermId(), ilDBInterface\manipulate(), ilDBInterface\query(), ilDBInterface\quote(), and setNr().

319  {
320  $ilDB = $this->db;
321 
322  $ilAtomQuery = $ilDB->buildAtomQuery();
323  $ilAtomQuery->addTableLock('glossary_definition');
324 
325  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDB) {
326 
327  // be sure to get the right number
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"]);
333 
334  // get max number
335  $q = "SELECT max(nr) as max_nr FROM glossary_definition WHERE term_id = " .
336  $ilDB->quote($this->getTermId(), "integer");
337  $max_set = $ilDB->query($q);
338  $max_rec = $ilDB->fetchAssoc($max_set);
339 
340  if ($this->getNr() >= $max_rec["max_nr"]) {
341  return;
342  }
343 
344  // update numbers of other definitions
345  $ilDB->manipulate("UPDATE glossary_definition SET " .
346  " nr = nr - 1 " .
347  " WHERE term_id = " . $ilDB->quote($this->getTermId(), "integer") . " " .
348  " AND nr = " . $ilDB->quote(($this->getNr() + 1), "integer"));
349 
350  // delete current definition
351  $ilDB->manipulate("UPDATE glossary_definition SET " .
352  " nr = nr + 1 " .
353  " WHERE term_id = " . $ilDB->quote($this->getTermId(), "integer") . " " .
354  " AND id = " . $ilDB->quote($this->getId(), "integer"));
355  });
356 
357  $ilAtomQuery->run();
358  }
quote($value, $type)
global $ilDB
query($query)
Run a (read-only) Query on the database.
fetchAssoc($query_result)
manipulate($query)
Run a (write) Query on the database.
+ Here is the call graph for this function:

◆ moveUp()

ilGlossaryDefinition::moveUp ( )

Definition at line 283 of file class.ilGlossaryDefinition.php.

References $db, $ilDB, ilDBInterface\fetchAssoc(), getNr(), ilDBInterface\manipulate(), ilDBInterface\query(), ilDBInterface\quote(), and setNr().

284  {
285  $ilDB = $this->db;
286 
287  $ilAtomQuery = $ilDB->buildAtomQuery();
288  $ilAtomQuery->addTableLock('glossary_definition');
289 
290  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDB) {
291 
292  // be sure to get the right number
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"]);
298 
299  if ($this->getNr() < 2) {
300  return;
301  }
302 
303  // update numbers of other definitions
304  $ilDB->manipulate("UPDATE glossary_definition SET " .
305  " nr = nr + 1 " .
306  " WHERE term_id = " . $ilDB->quote($this->getTermId(), "integer") . " " .
307  " AND nr = " . $ilDB->quote(($this->getNr() - 1), "integer"));
308 
309  // delete current definition
310  $ilDB->manipulate("UPDATE glossary_definition SET " .
311  " nr = nr - 1 " .
312  " WHERE term_id = " . $ilDB->quote($this->getTermId(), "integer") . " " .
313  " AND id = " . $ilDB->quote($this->getId(), "integer"));
314  });
315  $ilAtomQuery->run();
316  }
quote($value, $type)
global $ilDB
query($query)
Run a (read-only) Query on the database.
fetchAssoc($query_result)
manipulate($query)
Run a (write) Query on the database.
+ Here is the call graph for this function:

◆ read()

ilGlossaryDefinition::read ( )

read data of content object

Definition at line 59 of file class.ilGlossaryDefinition.php.

References $db, $ilDB, setNr(), setShortText(), setShortTextDirty(), and setTermId().

Referenced by __construct().

60  {
61  $ilDB = $this->db;
62 
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);
67 
68  $this->setTermId($def_rec["term_id"]);
69  $this->setShortText($def_rec["short_text"]);
70  $this->setNr($def_rec["nr"]);
71  $this->setShortTextDirty($def_rec["short_text_dirty"]);
72 
73  $this->page_object = new ilGlossaryDefPage($this->id);
74  }
setShortTextDirty($a_val)
Set short text dirty.
Glossary definition page object.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDescription()

ilGlossaryDefinition::setDescription (   $a_description)

Set description.

Parameters
stringdescription

Definition at line 164 of file class.ilGlossaryDefinition.php.

Referenced by MDUpdateListener().

165  {
166  $this->description = $a_description;
167  }
+ Here is the caller graph for this function:

◆ setId()

ilGlossaryDefinition::setId (   $a_id)

Definition at line 76 of file class.ilGlossaryDefinition.php.

Referenced by create().

77  {
78  $this->id = $a_id;
79  }
+ Here is the caller graph for this function:

◆ setNr()

ilGlossaryDefinition::setNr (   $a_nr)

Definition at line 111 of file class.ilGlossaryDefinition.php.

Referenced by create(), delete(), moveDown(), moveUp(), and read().

112  {
113  $this->nr = $a_nr;
114  }
+ Here is the caller graph for this function:

◆ setShortText()

ilGlossaryDefinition::setShortText (   $a_text)

Definition at line 101 of file class.ilGlossaryDefinition.php.

References shortenShortText().

Referenced by read(), and updateShortText().

102  {
103  $this->short_text = $this->shortenShortText($a_text);
104  }
shortenShortText($text)
Shorten short text.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setShortTextDirty()

ilGlossaryDefinition::setShortTextDirty (   $a_val)

Set short text dirty.

Parameters
booleanshort text dirty

Definition at line 174 of file class.ilGlossaryDefinition.php.

Referenced by read(), and updateShortText().

175  {
176  $this->short_text_dirty = $a_val;
177  }
+ Here is the caller graph for this function:

◆ setShortTextsDirty()

static ilGlossaryDefinition::setShortTextsDirty (   $a_glo_id)
static

Set short texts dirty.

Parameters

Definition at line 631 of file class.ilGlossaryDefinition.php.

References $DIC, $ilDB, $term_id, and ilGlossaryTerm\getTermsOfGlossary().

Referenced by ilObjGlossaryGUI\saveProperties().

632  {
633  global $DIC;
634 
635  $ilDB = $DIC->database();
636 
637  $term_ids = ilGlossaryTerm::getTermsOfGlossary($a_glo_id);
638 
639  foreach ($term_ids as $term_id) {
640  $ilDB->manipulate(
641  "UPDATE glossary_definition SET " .
642  " short_text_dirty = " . $ilDB->quote(1, "integer") .
643  " WHERE term_id = " . $ilDB->quote($term_id, "integer")
644  );
645  }
646  }
global $DIC
Definition: goto.php:24
global $ilDB
static getTermsOfGlossary($a_glo_id)
Get terms of glossary.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setShortTextsDirtyGlobally()

static ilGlossaryDefinition::setShortTextsDirtyGlobally ( )
static

Set short texts dirty.

Parameters

Definition at line 654 of file class.ilGlossaryDefinition.php.

References $DIC, and $ilDB.

Referenced by ilObjAdvancedEditingGUI\initGeneralPageSettingsForm().

655  {
656  global $DIC;
657 
658  $ilDB = $DIC->database();
659 
660  $ilDB->manipulate(
661  "UPDATE glossary_definition SET " .
662  " short_text_dirty = " . $ilDB->quote(1, "integer")
663  );
664  }
global $DIC
Definition: goto.php:24
global $ilDB
+ Here is the caller graph for this function:

◆ setTermId()

ilGlossaryDefinition::setTermId (   $a_term_id)

Definition at line 91 of file class.ilGlossaryDefinition.php.

Referenced by read().

92  {
93  $this->term_id = $a_term_id;
94  }
+ Here is the caller graph for this function:

◆ setTitle()

ilGlossaryDefinition::setTitle (   $a_title)

set title of content object

Definition at line 144 of file class.ilGlossaryDefinition.php.

Referenced by MDUpdateListener().

145  {
146  $this->title = $a_title;
147  }
+ Here is the caller graph for this function:

◆ shortenShortText()

ilGlossaryDefinition::shortenShortText (   $text)

Shorten short text.

Parameters

Definition at line 381 of file class.ilGlossaryDefinition.php.

References $glo_id, getTermId(), ilObjGlossary\lookupSnippetLength(), and ilUtil\shortenText().

Referenced by setShortText(), and updateShortText().

382  {
383  $a_length = 196;
384 
385  if ($this->getTermId() > 0) {
386  $glo_id = ilGlossaryTerm::_lookGlossaryId($this->getTermId());
387  $snippet_length = ilObjGlossary::lookupSnippetLength($glo_id);
388  if ($snippet_length > 0) {
389  $a_length = $snippet_length;
390  }
391  }
392 
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]"))) {
396  $offset = 5;
397  }
398  $short = ilUtil::shortenText($text, $a_length - 16 + $offset, true);
399 
400  // make short text longer, if tex end tag is missing
401  $ltexs = strrpos($short, "[tex]");
402  $ltexe = strrpos($short, "[/tex]");
403  if ($ltexs > $ltexe) {
404  $ltexe = strpos($text, "[/tex]", $ltexs);
405  if ($ltexe > 0) {
406  $text = ilUtil::shortenText($text, $ltexe + 6, true);
407  }
408  }
409 
410  $short = ilUtil::shortenText($text, $a_length, true);
411 
412  return $short;
413  }
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
static lookupSnippetLength($a_id)
Lookup snippet length.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilGlossaryDefinition::update ( )

Definition at line 361 of file class.ilGlossaryDefinition.php.

References $db, $ilDB, and updateMetaData().

Referenced by updateShortText().

362  {
363  $ilDB = $this->db;
364 
365  $this->updateMetaData();
366 
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"));
373  }
updateMetaData()
update meta data entry
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateMetaData()

ilGlossaryDefinition::updateMetaData ( )

update meta data entry

Definition at line 537 of file class.ilGlossaryDefinition.php.

References $glo_id, ilGlossaryTerm\_lookGlossaryID(), getDescription(), getId(), getTermId(), getTitle(), and getType().

Referenced by update().

538  {
540  $md = new ilMD($glo_id, $this->getId(), $this->getType());
541  $md_gen = $md->getGeneral();
542  $md_gen->setTitle($this->getTitle());
543 
544  // sets first description (maybe not appropriate)
545  $md_des_ids = $md_gen->getDescriptionIds();
546  if (count($md_des_ids) > 0) {
547  $md_des = $md_gen->getDescription($md_des_ids[0]);
548  $md_des->setDescription($this->getDescription());
549  $md_des->update();
550  }
551  $md_gen->update();
552  }
getTitle()
get title of content object
static _lookGlossaryID($term_id)
get glossary id form term id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateShortText()

ilGlossaryDefinition::updateShortText ( )

Definition at line 415 of file class.ilGlossaryDefinition.php.

References setShortText(), setShortTextDirty(), shortenShortText(), and update().

416  {
417  $this->page_object->buildDom();
418  $text = $this->page_object->getFirstParagraphText();
419  $short = $this->shortenShortText($text);
420 
421  $this->setShortText($short);
422  $this->setShortTextDirty(false);
423  $this->update();
424  }
setShortTextDirty($a_val)
Set short text dirty.
shortenShortText($text)
Shorten short text.
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilGlossaryDefinition::$db
protected

Definition at line 16 of file class.ilGlossaryDefinition.php.

Referenced by create(), delete(), moveDown(), moveUp(), read(), and update().

◆ $glo_id

ilGlossaryDefinition::$glo_id

◆ $id

ilGlossaryDefinition::$id

Definition at line 26 of file class.ilGlossaryDefinition.php.

Referenced by getId(), and MDUpdateListener().

◆ $lng

ilGlossaryDefinition::$lng

Definition at line 23 of file class.ilGlossaryDefinition.php.

Referenced by __construct().

◆ $nr

ilGlossaryDefinition::$nr

Definition at line 31 of file class.ilGlossaryDefinition.php.

Referenced by getNr().

◆ $page_object

ilGlossaryDefinition::$page_object

Definition at line 29 of file class.ilGlossaryDefinition.php.

Referenced by getPageObject().

◆ $short_text

ilGlossaryDefinition::$short_text

Definition at line 30 of file class.ilGlossaryDefinition.php.

Referenced by getShortText().

◆ $short_text_dirty

ilGlossaryDefinition::$short_text_dirty = false

Definition at line 32 of file class.ilGlossaryDefinition.php.

Referenced by getShortTextDirty().

◆ $term_id

ilGlossaryDefinition::$term_id

Definition at line 27 of file class.ilGlossaryDefinition.php.

Referenced by getTermId(), and setShortTextsDirty().

◆ $tpl

ilGlossaryDefinition::$tpl

Definition at line 24 of file class.ilGlossaryDefinition.php.

Referenced by __construct().

◆ $user

ilGlossaryDefinition::$user
protected

Definition at line 21 of file class.ilGlossaryDefinition.php.

Referenced by createMetaData().


The documentation for this class was generated from the following file: