ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 {
43 $this->read();
44 }
45 }
global $DIC

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 92 of file class.ilGlossaryTermReferences.php.

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

Referenced by read().

+ Here is the caller graph for this function:

◆ delete()

ilGlossaryTermReferences::delete ( )

Delete references (of glossary)

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

152 {
153 $this->db->manipulate("DELETE FROM glo_term_reference WHERE ".
154 " glo_id = ".$this->db->quote($this->getGlossaryId(), "integer")
155 );
156 }

◆ deleteReferencesOfTerm()

static ilGlossaryTermReferences::deleteReferencesOfTerm (   $a_term_id)
static

Delete all references of a term.

Parameters
int$a_term_idterm id

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

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

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 105 of file class.ilGlossaryTermReferences.php.

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

◆ getGlossaryId()

ilGlossaryTermReferences::getGlossaryId ( )

Get glossary id.

Returns
int glossary id

Definition at line 62 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 82 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 180 of file class.ilGlossaryTermReferences.php.

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

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 201 of file class.ilGlossaryTermReferences.php.

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

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 227 of file class.ilGlossaryTermReferences.php.

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

References $db, and $DIC.

Referenced by ilGlossaryTerm\getUsages().

+ Here is the caller graph for this function:

◆ read()

ilGlossaryTermReferences::read ( )

Read.

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

121 {
122 $set = $this->db->query("SELECT term_id FROM glo_term_reference ".
123 " WHERE glo_id = ".$this->db->quote($this->getGlossaryId(), "integer"));
124 while ($rec = $this->db->fetchAssoc($set))
125 {
126 $this->addTerm($rec["term_id"]);
127 }
128 }

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 52 of file class.ilGlossaryTermReferences.php.

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

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 72 of file class.ilGlossaryTermReferences.php.

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

◆ update()

ilGlossaryTermReferences::update ( )

Update.

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

134 {
135 $this->delete();
136 foreach ($this->getTerms() as $t)
137 {
138 $this->db->replace("glo_term_reference",
139 array(
140 "glo_id" => array("integer", $this->getGlossaryId()),
141 "term_id" => array("integer", $t),
142 ),
143 array()
144 );
145 }
146 }

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: