ILIAS  release_8 Revision v8.24
ilGlossaryTermReferences Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilGlossaryTermReferences:

Public Member Functions

 __construct (int $a_glo_id=0)
 
 setGlossaryId (int $a_val)
 
 getGlossaryId ()
 
 setTerms (array $a_val)
 
 getTerms ()
 
 addTerm (int $a_term_id)
 
 deleteTerm (int $a_term_id)
 
 read ()
 
 update ()
 
 delete ()
 Delete references (of glossary) More...
 

Static Public Member Functions

static deleteReferencesOfTerm (int $a_term_id)
 Delete all references of a term. More...
 
static hasReferences (int $a_glossary_id)
 Check if a glossary uses references. More...
 
static isReferenced (array $a_glo_id, int $a_term_id)
 Is a term referenced by a set of glossaries. More...
 
static lookupReferencesOfTerm (int $a_term_id)
 

Protected Attributes

int $glo_id
 
array $terms = array()
 
ilDBInterface $db
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Glossary term reference

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ilGlossaryTermReferences::__construct ( int  $a_glo_id = 0)

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

31 {
32 global $DIC;
33
34 $this->db = $DIC->database();
35
36 $this->setGlossaryId($a_glo_id);
37 if ($a_glo_id > 0) {
38 $this->read();
39 }
40 }
global $DIC
Definition: feed.php:28

References $DIC, read(), and setGlossaryId().

+ Here is the call graph for this function:

Member Function Documentation

◆ addTerm()

ilGlossaryTermReferences::addTerm ( int  $a_term_id)

Definition at line 68 of file class.ilGlossaryTermReferences.php.

68 : void
69 {
70 if (!in_array($a_term_id, $this->terms)) {
71 $this->terms[] = $a_term_id;
72 }
73 }

Referenced by read().

+ Here is the caller graph for this function:

◆ delete()

ilGlossaryTermReferences::delete ( )

Delete references (of glossary)

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

111 : void
112 {
113 $this->db->manipulate(
114 "DELETE FROM glo_term_reference WHERE " .
115 " glo_id = " . $this->db->quote($this->getGlossaryId(), "integer")
116 );
117 }

◆ deleteReferencesOfTerm()

static ilGlossaryTermReferences::deleteReferencesOfTerm ( int  $a_term_id)
static

Delete all references of a term.

Definition at line 122 of file class.ilGlossaryTermReferences.php.

122 : void
123 {
124 global $DIC;
125
126 $db = $DIC->database();
128 "DELETE FROM glo_term_reference WHERE " .
129 " term_id = " . $db->quote($a_term_id, "integer")
130 );
131 }
quote($value, string $type)
manipulate(string $query)
Run a (write) Query on the database.

References $db, $DIC, ilDBInterface\manipulate(), and ilDBInterface\quote().

Referenced by ilGlossaryTerm\delete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteTerm()

ilGlossaryTermReferences::deleteTerm ( int  $a_term_id)

Definition at line 75 of file class.ilGlossaryTermReferences.php.

75 : void
76 {
77 foreach ($this->terms as $k => $v) {
78 if ($v == $a_term_id) {
79 unset($this->terms[$k]);
80 }
81 }
82 }

◆ getGlossaryId()

ilGlossaryTermReferences::getGlossaryId ( )

Definition at line 47 of file class.ilGlossaryTermReferences.php.

47 : int
48 {
49 return $this->glo_id;
50 }

References $glo_id.

Referenced by update().

+ Here is the caller graph for this function:

◆ getTerms()

ilGlossaryTermReferences::getTerms ( )
Returns
int[] term ids

Definition at line 63 of file class.ilGlossaryTermReferences.php.

63 : array
64 {
65 return $this->terms;
66 }

References $terms.

Referenced by update().

+ Here is the caller graph for this function:

◆ hasReferences()

static ilGlossaryTermReferences::hasReferences ( int  $a_glossary_id)
static

Check if a glossary uses references.

Definition at line 137 of file class.ilGlossaryTermReferences.php.

137 : bool
138 {
139 global $DIC;
140
141 $db = $DIC->database();
142 $set = $db->query(
143 "SELECT * FROM glo_term_reference " .
144 " WHERE glo_id = " . $db->quote($a_glossary_id, "integer")
145 );
146 if ($rec = $db->fetchAssoc($set)) {
147 return true;
148 }
149 return false;
150 }
query(string $query)
Run a (read-only) Query on the database.
fetchAssoc(ilDBStatement $statement)

References $db, $DIC, ilDBInterface\fetchAssoc(), ilDBInterface\query(), and ilDBInterface\quote().

Referenced by ilTermListTableGUI\showGlossaryColumn().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isReferenced()

static ilGlossaryTermReferences::isReferenced ( array  $a_glo_id,
int  $a_term_id 
)
static

Is a term referenced by a set of glossaries.

Parameters
int[]$a_glo_idglossary ids
int$a_term_id
Returns
bool

Definition at line 158 of file class.ilGlossaryTermReferences.php.

161 : bool {
162 global $DIC;
163
164 $db = $DIC->database();
165 $set = $db->query(
166 "SELECT * FROM glo_term_reference " .
167 " WHERE " . $db->in("glo_id", $a_glo_id, false, "integer") .
168 " AND term_id = " . $db->quote($a_term_id, "integer")
169 );
170 if ($db->fetchAssoc($set)) {
171 return true;
172 }
173 return false;
174 }
in(string $field, array $values, bool $negate=false, string $type="")

Referenced by ilObjGlossaryGUI\__construct(), ilObjGlossaryGUI\confirmTermDeletion(), ilObjGlossaryGUI\deleteTerms(), ilTermListTableGUI\fillRow(), and ilGlossaryPresentationGUI\initByRequest().

+ Here is the caller graph for this function:

◆ lookupReferencesOfTerm()

static ilGlossaryTermReferences::lookupReferencesOfTerm ( int  $a_term_id)
static
Parameters
int$a_term_idterm id
Returns
int[] glossary ids

Definition at line 180 of file class.ilGlossaryTermReferences.php.

182 : array {
183 global $DIC;
184
185 $db = $DIC->database();
186 $set = $db->query(
187 $q = "SELECT DISTINCT glo_id FROM glo_term_reference " .
188 " WHERE term_id = " . $db->quote($a_term_id, "integer")
189 );
190 $glos = array();
191 while ($rec = $db->fetchAssoc($set)) {
192 $glos[] = $rec["glo_id"];
193 }
194 return $glos;
195 }

Referenced by ilGlossaryTerm\getUsages().

+ Here is the caller graph for this function:

◆ read()

ilGlossaryTermReferences::read ( )

Definition at line 84 of file class.ilGlossaryTermReferences.php.

84 : void
85 {
86 $set = $this->db->query("SELECT term_id FROM glo_term_reference " .
87 " WHERE glo_id = " . $this->db->quote($this->getGlossaryId(), "integer"));
88 while ($rec = $this->db->fetchAssoc($set)) {
89 $this->addTerm($rec["term_id"]);
90 }
91 }

References addTerm().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setGlossaryId()

ilGlossaryTermReferences::setGlossaryId ( int  $a_val)

Definition at line 42 of file class.ilGlossaryTermReferences.php.

42 : void
43 {
44 $this->glo_id = $a_val;
45 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setTerms()

ilGlossaryTermReferences::setTerms ( array  $a_val)
Parameters
int[]$a_valterm ids

Definition at line 55 of file class.ilGlossaryTermReferences.php.

55 : void
56 {
57 $this->terms = $a_val;
58 }

◆ update()

ilGlossaryTermReferences::update ( )

Definition at line 93 of file class.ilGlossaryTermReferences.php.

93 : void
94 {
95 $this->delete();
96 foreach ($this->getTerms() as $t) {
97 $this->db->replace(
98 "glo_term_reference",
99 array(
100 "glo_id" => array("integer", $this->getGlossaryId()),
101 "term_id" => array("integer", $t),
102 ),
103 array()
104 );
105 }
106 }

References getGlossaryId(), and getTerms().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilGlossaryTermReferences::$db
protected

Definition at line 28 of file class.ilGlossaryTermReferences.php.

Referenced by deleteReferencesOfTerm(), and hasReferences().

◆ $glo_id

int ilGlossaryTermReferences::$glo_id
protected

Definition at line 25 of file class.ilGlossaryTermReferences.php.

Referenced by getGlossaryId().

◆ $terms

array ilGlossaryTermReferences::$terms = array()
protected

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

Referenced by getTerms().


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