ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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
 
ilAppEventHandler $event_handler
 

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

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

32  {
33  global $DIC;
34 
35  $this->db = $DIC->database();
36  $this->event_handler = $DIC->event();
37 
38  $this->setGlossaryId($a_glo_id);
39  if ($a_glo_id > 0) {
40  $this->read();
41  }
42  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ addTerm()

ilGlossaryTermReferences::addTerm ( int  $a_term_id)

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

Referenced by ilObjGlossaryGUI\pasteTerms(), and read().

70  : void
71  {
72  if (!in_array($a_term_id, $this->terms)) {
73  $this->terms[] = $a_term_id;
74  }
75  }
+ Here is the caller graph for this function:

◆ delete()

ilGlossaryTermReferences::delete ( )

Delete references (of glossary)

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

116  : void
117  {
118  $this->db->manipulate(
119  "DELETE FROM glo_term_reference WHERE " .
120  " glo_id = " . $this->db->quote($this->getGlossaryId(), "integer")
121  );
122  }

◆ deleteReferencesOfTerm()

static ilGlossaryTermReferences::deleteReferencesOfTerm ( int  $a_term_id)
static

Delete all references of a term.

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

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

Referenced by ilGlossaryTerm\delete(), and ILIAS\Glossary\Term\TermManager\deleteTerm().

127  : void
128  {
129  global $DIC;
130 
131  $db = $DIC->database();
132  $db->manipulate(
133  "DELETE FROM glo_term_reference WHERE " .
134  " term_id = " . $db->quote($a_term_id, "integer")
135  );
136  }
quote($value, string $type)
global $DIC
Definition: shib_login.php:22
manipulate(string $query)
Run a (write) Query on the database.
+ 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 77 of file class.ilGlossaryTermReferences.php.

Referenced by ilObjGlossaryGUI\deleteTerms().

77  : void
78  {
79  foreach ($this->terms as $k => $v) {
80  if ($v == $a_term_id) {
81  unset($this->terms[$k]);
82  }
83  }
84 
85  // delete flashcard entries
86  $this->event_handler->raise("components/ILIAS/Glossary", "deleteTerm", ["term_id" => $a_term_id]);
87  }
+ Here is the caller graph for this function:

◆ getGlossaryId()

ilGlossaryTermReferences::getGlossaryId ( )

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

References $glo_id.

Referenced by update().

49  : int
50  {
51  return $this->glo_id;
52  }
+ Here is the caller graph for this function:

◆ getTerms()

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

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

References $terms.

Referenced by update().

65  : array
66  {
67  return $this->terms;
68  }
+ 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 142 of file class.ilGlossaryTermReferences.php.

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

Referenced by ILIAS\components\ILIAS\Glossary\Table\TermListTable\getColumns(), and ILIAS\components\ILIAS\Glossary\Table\TermListTable\getDataRetrieval().

142  : bool
143  {
144  global $DIC;
145 
146  $db = $DIC->database();
147  $set = $db->query(
148  "SELECT * FROM glo_term_reference " .
149  " WHERE glo_id = " . $db->quote($a_glossary_id, "integer")
150  );
151  if ($rec = $db->fetchAssoc($set)) {
152  return true;
153  }
154  return false;
155  }
fetchAssoc(ilDBStatement $statement)
quote($value, string $type)
global $DIC
Definition: shib_login.php:22
query(string $query)
Run a (read-only) Query on the database.
+ 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_id glossary ids
int$a_term_id
Returns
bool

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

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

Referenced by ilObjGlossaryGUI\__construct(), ilObjGlossaryGUI\deleteTerms(), ILIAS\components\ILIAS\Glossary\Table\TermListTable\getDataRetrieval(), ILIAS\components\ILIAS\Glossary\Table\TermListTable\handleTermForModal(), and ilGlossaryPresentationGUI\initByRequest().

166  : bool {
167  global $DIC;
168 
169  $db = $DIC->database();
170  $set = $db->query(
171  "SELECT * FROM glo_term_reference " .
172  " WHERE " . $db->in("glo_id", $a_glo_id, false, "integer") .
173  " AND term_id = " . $db->quote($a_term_id, "integer")
174  );
175  if ($db->fetchAssoc($set)) {
176  return true;
177  }
178  return false;
179  }
fetchAssoc(ilDBStatement $statement)
quote($value, string $type)
global $DIC
Definition: shib_login.php:22
query(string $query)
Run a (read-only) Query on the database.
in(string $field, array $values, bool $negate=false, string $type="")
+ Here is the call graph for this function:
+ 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 185 of file class.ilGlossaryTermReferences.php.

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

Referenced by ilGlossaryTerm\getUsages().

187  : array {
188  global $DIC;
189 
190  $db = $DIC->database();
191  $set = $db->query(
192  $q = "SELECT DISTINCT glo_id FROM glo_term_reference " .
193  " WHERE term_id = " . $db->quote($a_term_id, "integer")
194  );
195  $glos = array();
196  while ($rec = $db->fetchAssoc($set)) {
197  $glos[] = $rec["glo_id"];
198  }
199  return $glos;
200  }
fetchAssoc(ilDBStatement $statement)
quote($value, string $type)
global $DIC
Definition: shib_login.php:22
query(string $query)
Run a (read-only) Query on the database.
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilGlossaryTermReferences::read ( )

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

References addTerm().

Referenced by __construct().

89  : void
90  {
91  $set = $this->db->query("SELECT term_id FROM glo_term_reference " .
92  " WHERE glo_id = " . $this->db->quote($this->getGlossaryId(), "integer"));
93  while ($rec = $this->db->fetchAssoc($set)) {
94  $this->addTerm($rec["term_id"]);
95  }
96  }
+ 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 44 of file class.ilGlossaryTermReferences.php.

Referenced by __construct().

44  : void
45  {
46  $this->glo_id = $a_val;
47  }
+ Here is the caller graph for this function:

◆ setTerms()

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

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

57  : void
58  {
59  $this->terms = $a_val;
60  }

◆ update()

ilGlossaryTermReferences::update ( )

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

References getGlossaryId(), and getTerms().

98  : void
99  {
100  $this->delete();
101  foreach ($this->getTerms() as $t) {
102  $this->db->replace(
103  "glo_term_reference",
104  array(
105  "glo_id" => array("integer", $this->getGlossaryId()),
106  "term_id" => array("integer", $t),
107  ),
108  array()
109  );
110  }
111  }
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilGlossaryTermReferences::$db
protected

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

◆ $event_handler

ilAppEventHandler ilGlossaryTermReferences::$event_handler
protected

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

◆ $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: