ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Glossary\Term\TermManager Class Reference

Manages terms. More...

+ Collaboration diagram for ILIAS\Glossary\Term\TermManager:

Public Member Functions

 __construct (InternalDomainService $domain_service, TermSessionRepository $session_repo, \ilObjGlossary $glossary, int $user_id)
 
 setSessionLang (string $lang)
 
 getSessionLang ()
 
 copyTermFromOtherGlossary (int $other_glossary_ref_id, int $term_id)
 
 referenceTermsFromOtherGlossary (int $other_glossary_ref_id, array $term_ids)
 Reference terms of another glossary in current glossary. More...
 
 getDataArrayFromInputString (string $input)
 
 createTermDefinitionPairsFromBulkInputString (string $input, string $language)
 
 deleteTerm (int $term_id)
 

Protected Attributes

ilAppEventHandler $event_handler
 
InternalDomainService $domain
 
TermSessionRepository $session_repo
 
ilObjGlossary $glossary
 
int $user_id
 

Detailed Description

Manages terms.

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

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

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Glossary\Term\TermManager::__construct ( InternalDomainService  $domain_service,
TermSessionRepository  $session_repo,
\ilObjGlossary  $glossary,
int  $user_id 
)

Definition at line 37 of file class.TermManager.php.

42 {
43 global $DIC;
44
45 $this->session_repo = $session_repo;
46 $this->glossary = $glossary;
47 $this->user_id = $user_id;
48 $this->domain = $domain_service;
49 $this->event_handler = $DIC->event();
50 }
TermSessionRepository $session_repo
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Glossary\Term\TermManager\$glossary, ILIAS\Glossary\Term\TermManager\$session_repo, and ILIAS\Glossary\Term\TermManager\$user_id.

Member Function Documentation

◆ copyTermFromOtherGlossary()

ILIAS\Glossary\Term\TermManager::copyTermFromOtherGlossary ( int  $other_glossary_ref_id,
int  $term_id 
)

Definition at line 62 of file class.TermManager.php.

65 : void {
66 $access = $this->domain->access();
67
68 if (!$access->checkAccessOfUser(
69 $this->user_id,
70 "write",
71 "",
72 $this->glossary->getRefId()
73 )
74 ) {
75 return;
76 }
77
78 if (!$access->checkAccessOfUser(
79 $this->user_id,
80 "read",
81 "",
82 $other_glossary_ref_id
83 )) {
84 return;
85 }
86
87 if (\ilGlossaryTerm::_lookGlossaryID($term_id) !=
88 \ilObject::_lookupObjectId($other_glossary_ref_id)) {
89 return;
90 }
91
92 \ilGlossaryTerm::_copyTerm($term_id, $this->glossary->getId());
93 }
static _lookGlossaryID(int $term_id)
get glossary id form term id
static _copyTerm(int $a_term_id, int $a_glossary_id)
Copy a term to a glossary.
static _lookupObjectId(int $ref_id)

◆ createTermDefinitionPairsFromBulkInputString()

ILIAS\Glossary\Term\TermManager::createTermDefinitionPairsFromBulkInputString ( string  $input,
string  $language 
)

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

154 : void
155 {
156 foreach ($this->getDataArrayFromInputString($input) as $data) {
157 $term = new \ilGlossaryTerm();
158 $term->setGlossaryId($this->glossary->getId());
159 $term->setTerm($data["term"]);
160 $term->setLanguage($language);
161 $term->setShortText($data["definition"]);
162 $term->create(true);
163
164 $page_object = new \ilGlossaryDefPage();
165 $page_object->setId($term->getId());
166 $page_object->setParentId($this->glossary->getId());
167 $page_object->create(false);
168 $paragraph = new \ilPCParagraph($page_object);
169 $paragraph->create($page_object, "pg");
170 $paragraph->setLanguage($language);
171 $paragraph->setText($data["definition"]);
172 $page_object->update();
173 }
174 }

References $data.

◆ deleteTerm()

ILIAS\Glossary\Term\TermManager::deleteTerm ( int  $term_id)

Definition at line 176 of file class.TermManager.php.

176 : void
177 {
178 global $DIC;
179
180 // todo: move to repo class
181 $db = $DIC->database();
182
183 // delete term references
185
186 // delete glossary_term record
187 $db->manipulate("DELETE FROM glossary_term " .
188 " WHERE id = " . $db->quote($term_id, "integer"));
189
190 try {
191 $page_object = new \ilGlossaryDefPage($term_id);
192 $page_object->delete();
193 } catch (\Exception $e) {
194 }
195
196 // delete flashcard entries
197 $this->event_handler->raise("Modules/Glossary", "deleteTerm", ["term_id" => $term_id]);
198 }
static deleteReferencesOfTerm(int $a_term_id)
Delete all references of a term.

References $DIC, Vendor\Package\$e, and ilGlossaryTermReferences\deleteReferencesOfTerm().

+ Here is the call graph for this function:

◆ getDataArrayFromInputString()

ILIAS\Glossary\Term\TermManager::getDataArrayFromInputString ( string  $input)

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

137 : array
138 {
139 $rows = explode("\n", $input);
140 $data = [];
141 foreach ($rows as $row) {
142 $cells = explode(";", $row);
143 if (count($cells) === 1) {
144 $cells = explode("\t", $row);
145 }
146 $data[] = [
147 "term" => trim($cells[0] ?? ""),
148 "definition" => trim($cells[1] ?? "")
149 ];
150 }
151 return $data;
152 }

References $data.

◆ getSessionLang()

ILIAS\Glossary\Term\TermManager::getSessionLang ( )

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

57 : string
58 {
59 return $this->session_repo->getLang($this->glossary->getRefId());
60 }

◆ referenceTermsFromOtherGlossary()

ILIAS\Glossary\Term\TermManager::referenceTermsFromOtherGlossary ( int  $other_glossary_ref_id,
array  $term_ids 
)

Reference terms of another glossary in current glossary.

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

101 : void {
102 $access = $this->domain->access();
103
104 if (!$access->checkAccessOfUser(
105 $this->user_id,
106 "write",
107 "",
108 $this->glossary->getRefId()
109 )) {
110 return;
111 }
112
113 if (!$access->checkAccessOfUser(
114 $this->user_id,
115 "read",
116 "",
117 $other_glossary_ref_id
118 )) {
119 return;
120 }
121
122 $other_glossary_obj_id = \ilObject::_lookupObjectId($other_glossary_ref_id);
123 $refs = new \ilGlossaryTermReferences($this->glossary->getId());
124 foreach ($term_ids as $term_id) {
125 if (\ilGlossaryTerm::_lookGlossaryID($term_id) != $other_glossary_obj_id) {
126 continue;
127 }
128
129 if ($this->glossary->getId() == $other_glossary_obj_id) {
130 continue;
131 }
132 $refs->addTerm($term_id);
133 }
134 $refs->update();
135 }

◆ setSessionLang()

ILIAS\Glossary\Term\TermManager::setSessionLang ( string  $lang)

Definition at line 52 of file class.TermManager.php.

52 : void
53 {
54 $this->session_repo->setLang($this->glossary->getRefId(), $lang);
55 }
$lang
Definition: xapiexit.php:25

References $lang.

Field Documentation

◆ $domain

InternalDomainService ILIAS\Glossary\Term\TermManager::$domain
protected

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

◆ $event_handler

ilAppEventHandler ILIAS\Glossary\Term\TermManager::$event_handler
protected

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

◆ $glossary

ilObjGlossary ILIAS\Glossary\Term\TermManager::$glossary
protected

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

Referenced by ILIAS\Glossary\Term\TermManager\__construct().

◆ $session_repo

TermSessionRepository ILIAS\Glossary\Term\TermManager::$session_repo
protected

Definition at line 33 of file class.TermManager.php.

Referenced by ILIAS\Glossary\Term\TermManager\__construct().

◆ $user_id

int ILIAS\Glossary\Term\TermManager::$user_id
protected

Definition at line 35 of file class.TermManager.php.

Referenced by ILIAS\Glossary\Term\TermManager\__construct().


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