ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilGlossaryTermReferences Class Reference

Glossary term reference. More...

+ Collaboration diagram for ilGlossaryTermReferences:

Public Member Functions

 __construct ($a_glo_id=0)
 __construct More...
 
 setGlossaryId ($a_val)
 Set glossary id. More...
 
 getGlossaryId ()
 Get glossary id. More...
 
 setTerms ($a_val)
 Set terms. More...
 
 getTerms ()
 Get terms. More...
 
 addTerm ($a_term_id)
 Add term. More...
 
 deleteTerm ($a_term_id)
 Delete term. More...
 
 read ()
 Read. More...
 
 update ()
 Update. More...
 
 delete ()
 Delete references (of glossary) More...
 

Static Public Member Functions

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

Protected Attributes

 $glo_id
 
 $terms = array()
 
 $db
 

Detailed Description

Glossary term reference.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilGlossaryTermReferences::__construct (   $a_glo_id = 0)

__construct

Parameters
int$a_glo_idglossary id

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

35 {
36 global $DIC;
37
38 $this->db = $DIC->database();
39
40 $this->setGlossaryId($a_glo_id);
41 if ($a_glo_id > 0) {
42 $this->read();
43 }
44 }
global $DIC
Definition: saml.php:7

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addTerm()

ilGlossaryTermReferences::addTerm (   $a_term_id)

Add term.

Parameters
intterm id

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

92 {
93 if (!in_array($a_term_id, $this->terms)) {
94 $this->terms[] = $a_term_id;
95 }
96 }

Referenced by read().

+ Here is the caller graph for this function:

◆ delete()

ilGlossaryTermReferences::delete ( )

Delete references (of glossary)

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

147 {
148 $this->db->manipulate(
149 "DELETE FROM glo_term_reference WHERE " .
150 " glo_id = " . $this->db->quote($this->getGlossaryId(), "integer")
151 );
152 }

◆ deleteReferencesOfTerm()

static ilGlossaryTermReferences::deleteReferencesOfTerm (   $a_term_id)
static

Delete all references of a term.

Parameters
int$a_term_idterm id

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

160 {
161 global $DIC;
162
163 $db = $DIC->database();
164 $db->manipulate(
165 "DELETE FROM glo_term_reference WHERE " .
166 " term_id = " . $db->quote($a_term_id, "integer")
167 );
168 }

References $db, and $DIC.

Referenced by ilGlossaryTerm\delete().

+ Here is the caller graph for this function:

◆ deleteTerm()

ilGlossaryTermReferences::deleteTerm (   $a_term_id)

Delete term.

Parameters
$a_term_id

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

104 {
105 foreach ($this->terms as $k => $v) {
106 if ($v == $a_term_id) {
107 unset($this->terms[$k]);
108 }
109 }
110 }

◆ getGlossaryId()

ilGlossaryTermReferences::getGlossaryId ( )

Get glossary id.

Returns
int glossary id

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

References $glo_id.

Referenced by update().

+ Here is the caller graph for this function:

◆ getTerms()

ilGlossaryTermReferences::getTerms ( )

Get terms.

Returns
int[] term ids

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

References $terms.

Referenced by update().

+ Here is the caller graph for this function:

◆ hasReferences()

static ilGlossaryTermReferences::hasReferences (   $a_glossary_id)
static

Check if a glossary uses references.

Parameters
int$a_glossary_id
Returns
bool

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

178 {
179 global $DIC;
180
181 $db = $DIC->database();
182 $set = $db->query(
183 "SELECT * FROM glo_term_reference " .
184 " WHERE glo_id = " . $db->quote($a_glossary_id, "integer")
185 );
186 if ($rec = $db->fetchAssoc($set)) {
187 return true;
188 }
189 return false;
190 }

References $db, and $DIC.

Referenced by ilTermListTableGUI\showGlossaryColumn().

+ Here is the caller graph for this function:

◆ isReferenced()

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

Is a term referenced by one or multiple glossaries.

Parameters
int | int[]$a_glo_id
int$a_term_id
Returns
bool

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

199 {
200 global $DIC;
201
202 $db = $DIC->database();
203 if (!is_array($a_glo_id)) {
204 $a_glo_id = array($a_glo_id);
205 }
206 $set = $db->query(
207 $q = "SELECT * FROM glo_term_reference " .
208 " WHERE " . $db->in("glo_id", $a_glo_id, false, "integer") .
209 " AND term_id = " . $db->quote($a_term_id, "integer")
210 );
211 if ($rec = $db->fetchAssoc($set)) {
212 return true;
213 }
214 return false;
215 }

References $db, and $DIC.

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

+ Here is the caller graph for this function:

◆ lookupReferencesOfTerm()

static ilGlossaryTermReferences::lookupReferencesOfTerm (   $a_term_id)
static

Lookup references of a term.

Parameters
int$a_term_idterm id
Returns
int[] glossary ids

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

224 {
225 global $DIC;
226
227 $db = $DIC->database();
228 $set = $db->query(
229 $q = "SELECT DISTINCT glo_id FROM glo_term_reference " .
230 " WHERE term_id = " . $db->quote($a_term_id, "integer")
231 );
232 $glos = array();
233 while ($rec = $db->fetchAssoc($set)) {
234 $glos[] = $rec["glo_id"];
235 }
236 return $glos;
237 }

References $db, and $DIC.

Referenced by ilGlossaryTerm\getUsages().

+ Here is the caller graph for this function:

◆ read()

ilGlossaryTermReferences::read ( )

Read.

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

117 {
118 $set = $this->db->query("SELECT term_id FROM glo_term_reference " .
119 " WHERE glo_id = " . $this->db->quote($this->getGlossaryId(), "integer"));
120 while ($rec = $this->db->fetchAssoc($set)) {
121 $this->addTerm($rec["term_id"]);
122 }
123 }

References addTerm().

Referenced by __construct().

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

◆ setGlossaryId()

ilGlossaryTermReferences::setGlossaryId (   $a_val)

Set glossary id.

Parameters
int$a_valglossary id

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

52 {
53 $this->glo_id = $a_val;
54 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setTerms()

ilGlossaryTermReferences::setTerms (   $a_val)

Set terms.

Parameters
int[]$a_valterm ids

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

72 {
73 $this->terms = $a_val;
74 }

◆ update()

ilGlossaryTermReferences::update ( )

Update.

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

129 {
130 $this->delete();
131 foreach ($this->getTerms() as $t) {
132 $this->db->replace(
133 "glo_term_reference",
134 array(
135 "glo_id" => array("integer", $this->getGlossaryId()),
136 "term_id" => array("integer", $t),
137 ),
138 array()
139 );
140 }
141 }

References $t, getGlossaryId(), and getTerms().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilGlossaryTermReferences::$db
protected

◆ $glo_id

ilGlossaryTermReferences::$glo_id
protected

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

Referenced by getGlossaryId().

◆ $terms

ilGlossaryTermReferences::$terms = array()
protected

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

Referenced by getTerms().


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