ILIAS  release_8 Revision v8.24
ilMDGeneral Class Reference
+ Inheritance diagram for ilMDGeneral:
+ Collaboration diagram for ilMDGeneral:

Public Member Functions

 getPossibleSubelements ()
 
 getIdentifierIds ()
 
 getIdentifier (int $a_identifier_id)
 
 addIdentifier ()
 
 getLanguageIds ()
 
 getLanguage (int $a_language_id)
 
 addLanguage ()
 
 getDescriptionIds ()
 
 getDescription (int $a_description_id)
 
 addDescription ()
 
 getKeywordIds ()
 
 getKeyword (int $a_keyword_id)
 
 addKeyword ()
 
 setStructure (string $a_structure)
 
 getStructure ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setTitleLanguage (ilMDLanguageItem $lng_obj)
 
 getTitleLanguage ()
 
 getTitleLanguageCode ()
 
 setCoverage (string $a_coverage)
 
 getCoverage ()
 
 setCoverageLanguage (ilMDLanguageItem $lng_obj)
 
 getCoverageLanguage ()
 
 getCoverageLanguageCode ()
 
 save ()
 
 update ()
 
 delete ()
 
 __getFields ()
 
 read ()
 
 toXML (ilXmlWriter $writer)
 
- Public Member Functions inherited from ilMDBase
 __construct (int $a_rbac_id=0, int $a_obj_id=0, string $a_type='')
 constructor More...
 
 read ()
 
 setRBACId (int $a_id)
 
 getRBACId ()
 
 setObjId (int $a_id)
 
 getObjId ()
 
 setObjType (string $a_type)
 
 getObjType ()
 
 setMetaId (int $a_meta_id, bool $a_read_data=true)
 
 getMetaId ()
 
 setParentType (string $a_parent_type)
 
 getParentType ()
 
 setParentId (int $a_id)
 
 getParentId ()
 
 setExportMode (bool $a_export_mode=true)
 
 getExportMode ()
 
 validate ()
 
 update ()
 
 save ()
 
 delete ()
 
 toXML (ilXmlWriter $writer)
 

Static Public Member Functions

static _getId (int $a_rbac_id, int $a_obj_id)
 

Protected Attributes

ilMDLanguageItem $coverage_language = null
 
- Protected Attributes inherited from ilMDBase
ilLogger $log
 
ilDBInterface $db
 

Private Attributes

string $coverage = ''
 
string $structure = ''
 
string $title = ''
 
ilMDLanguageItem $title_language = null
 

Detailed Description

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

Member Function Documentation

◆ __getFields()

ilMDGeneral::__getFields ( )
Returns
array<string, array<string, mixed>>

Definition at line 302 of file class.ilMDGeneral.php.

302 : array
303 {
304 return array(
305 'rbac_id' => array('integer', $this->getRBACId()),
306 'obj_id' => array('integer', $this->getObjId()),
307 'obj_type' => array('text', $this->getObjType()),
308 'general_structure' => array('text', $this->getStructure()),
309 'title' => array('text', $this->getTitle()),
310 'title_language' => array('text', $this->getTitleLanguageCode()),
311 'coverage' => array('text', $this->getCoverage()),
312 'coverage_language' => array('text', $this->getCoverageLanguageCode())
313 );
314 }

References getCoverage(), getCoverageLanguageCode(), ilMDBase\getObjId(), ilMDBase\getObjType(), ilMDBase\getRBACId(), getStructure(), getTitle(), and getTitleLanguageCode().

Referenced by save(), and update().

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

◆ _getId()

static ilMDGeneral::_getId ( int  $a_rbac_id,
int  $a_obj_id 
)
static

Definition at line 418 of file class.ilMDGeneral.php.

418 : int
419 {
420 global $DIC;
421
422 $ilDB = $DIC->database();
423
424 $query = "SELECT meta_general_id FROM il_meta_general " .
425 "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
426 "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer');
427
428 $res = $ilDB->query($query);
429 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
430 return (int) $row->meta_general_id;
431 }
432 return 0;
433 }
global $DIC
Definition: feed.php:28
$res
Definition: ltiservices.php:69
$query

References $DIC, $ilDB, $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilMD\getGeneral(), and ilMDKeywordExposer\getGeneral().

+ Here is the caller graph for this function:

◆ addDescription()

ilMDGeneral::addDescription ( )

Definition at line 126 of file class.ilMDGeneral.php.

127 {
128 $des = new ilMDDescription($this->getRBACId(), $this->getObjId(), $this->getObjType());
129 $des->setParentId($this->getMetaId());
130 $des->setParentType('meta_general');
131
132 return $des;
133 }

References ilMDBase\getMetaId(), ilMDBase\getObjId(), ilMDBase\getObjType(), and ilMDBase\getRBACId().

+ Here is the call graph for this function:

◆ addIdentifier()

ilMDGeneral::addIdentifier ( )

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

71 {
72 $ide = new ilMDIdentifier($this->getRBACId(), $this->getObjId(), $this->getObjType());
73 $ide->setParentId($this->getMetaId());
74 $ide->setParentType('meta_general');
75
76 return $ide;
77 }

References ilMDBase\getMetaId(), ilMDBase\getObjId(), ilMDBase\getObjType(), and ilMDBase\getRBACId().

+ Here is the call graph for this function:

◆ addKeyword()

ilMDGeneral::addKeyword ( )

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

155 {
156 $key = new ilMDKeyword($this->getRBACId(), $this->getObjId(), $this->getObjType());
157 $key->setParentId($this->getMetaId());
158 $key->setParentType('meta_general');
159
160 return $key;
161 }
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key, ilMDBase\getMetaId(), ilMDBase\getObjId(), ilMDBase\getObjType(), and ilMDBase\getRBACId().

Referenced by ilMDKeyword\updateKeywords().

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

◆ addLanguage()

ilMDGeneral::addLanguage ( )

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

99 {
100 $lan = new ilMDLanguage($this->getRBACId(), $this->getObjId(), $this->getObjType());
101 $lan->setParentId($this->getMetaId());
102 $lan->setParentType('meta_general');
103
104 return $lan;
105 }

References ilMDBase\getMetaId(), ilMDBase\getObjId(), ilMDBase\getObjType(), and ilMDBase\getRBACId().

+ Here is the call graph for this function:

◆ delete()

ilMDGeneral::delete ( )

Reimplemented from ilMDBase.

Definition at line 260 of file class.ilMDGeneral.php.

260 : bool
261 {
262 if (!$this->getMetaId()) {
263 return false;
264 }
265 // Identifier
266 foreach ($this->getIdentifierIds() as $id) {
267 $ide = $this->getIdentifier($id);
268 $ide->delete();
269 }
270
271 // Language
272 foreach ($this->getLanguageIds() as $id) {
273 $lan = $this->getLanguage($id);
274 $lan->delete();
275 }
276
277 // Description
278 foreach ($this->getDescriptionIds() as $id) {
279 $des = $this->getDescription($id);
280 $des->delete();
281 }
282
283 // Keyword
284 foreach ($this->getKeywordIds() as $id) {
285 $key = $this->getKeyword($id);
286 $key->delete();
287 }
288
289 if ($this->getMetaId()) {
290 $query = "DELETE FROM il_meta_general " .
291 "WHERE meta_general_id = " . $this->db->quote($this->getMetaId(), 'integer');
292 $res = $this->db->manipulate($query);
293 return true;
294 }
295
296 return false;
297 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getIdentifier(int $a_identifier_id)
getLanguage(int $a_language_id)
getKeyword(int $a_keyword_id)
getDescription(int $a_description_id)

References $id, ILIAS\LTI\ToolProvider\$key, $query, $res, getDescription(), getDescriptionIds(), getIdentifier(), getIdentifierIds(), getKeyword(), getKeywordIds(), getLanguage(), getLanguageIds(), and ilMDBase\getMetaId().

+ Here is the call graph for this function:

◆ getCoverage()

ilMDGeneral::getCoverage ( )

Definition at line 215 of file class.ilMDGeneral.php.

215 : string
216 {
217 return $this->coverage;
218 }

References $coverage.

Referenced by __getFields(), and toXML().

+ Here is the caller graph for this function:

◆ getCoverageLanguage()

ilMDGeneral::getCoverageLanguage ( )

Definition at line 225 of file class.ilMDGeneral.php.

226 {
227 return is_object($this->coverage_language) ? $this->coverage_language : null;
228 }

◆ getCoverageLanguageCode()

ilMDGeneral::getCoverageLanguageCode ( )

Definition at line 230 of file class.ilMDGeneral.php.

230 : string
231 {
232 return is_object($this->coverage_language) ? $this->coverage_language->getLanguageCode() : '';
233 }

Referenced by __getFields(), and toXML().

+ Here is the caller graph for this function:

◆ getDescription()

ilMDGeneral::getDescription ( int  $a_description_id)

Definition at line 115 of file class.ilMDGeneral.php.

116 {
117 if (!$a_description_id) {
118 return null;
119 }
120 $des = new ilMDDescription();
121 $des->setMetaId($a_description_id);
122
123 return $des;
124 }

Referenced by delete(), and toXML().

+ Here is the caller graph for this function:

◆ getDescriptionIds()

ilMDGeneral::getDescriptionIds ( )
Returns
int[]

Definition at line 110 of file class.ilMDGeneral.php.

110 : array
111 {
112 return ilMDDescription::_getIds($this->getRBACId(), $this->getObjId(), (int) $this->getMetaId(), 'meta_general');
113 }
static _getIds(int $a_rbac_id, int $a_obj_id, int $a_parent_id, string $a_parent_type)

References ilMDDescription\_getIds(), ilMDBase\getMetaId(), ilMDBase\getObjId(), and ilMDBase\getRBACId().

Referenced by delete(), and toXML().

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

◆ getIdentifier()

ilMDGeneral::getIdentifier ( int  $a_identifier_id)

Definition at line 59 of file class.ilMDGeneral.php.

60 {
61 if (!$a_identifier_id) {
62 return null;
63 }
64 $ide = new ilMDIdentifier();
65 $ide->setMetaId($a_identifier_id);
66
67 return $ide;
68 }

Referenced by delete(), and toXML().

+ Here is the caller graph for this function:

◆ getIdentifierIds()

ilMDGeneral::getIdentifierIds ( )
Returns
int[]

Definition at line 54 of file class.ilMDGeneral.php.

54 : array
55 {
56 return ilMDIdentifier::_getIds($this->getRBACId(), $this->getObjId(), (int) $this->getMetaId(), 'meta_general');
57 }
static _getIds(int $a_rbac_id, int $a_obj_id, int $a_parent_id, string $a_parent_type)

References ilMDIdentifier\_getIds(), ilMDBase\getMetaId(), ilMDBase\getObjId(), and ilMDBase\getRBACId().

Referenced by delete(), and toXML().

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

◆ getKeyword()

ilMDGeneral::getKeyword ( int  $a_keyword_id)

Definition at line 143 of file class.ilMDGeneral.php.

143 : ?ilMDKeyword
144 {
145 if (!$a_keyword_id) {
146 return null;
147 }
148 $key = new ilMDKeyword();
149 $key->setMetaId($a_keyword_id);
150
151 return $key;
152 }

References ILIAS\LTI\ToolProvider\$key.

Referenced by delete(), toXML(), and ilMDKeyword\updateKeywords().

+ Here is the caller graph for this function:

◆ getKeywordIds()

ilMDGeneral::getKeywordIds ( )
Returns
int[]

Definition at line 138 of file class.ilMDGeneral.php.

138 : array
139 {
140 return ilMDKeyword::_getIds($this->getRBACId(), $this->getObjId(), (int) $this->getMetaId(), 'meta_general');
141 }
static _getIds(int $a_rbac_id, int $a_obj_id, int $a_parent_id, string $a_parent_type)

References ilMDKeyword\_getIds(), ilMDBase\getMetaId(), ilMDBase\getObjId(), and ilMDBase\getRBACId().

Referenced by delete(), toXML(), and ilMDKeyword\updateKeywords().

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

◆ getLanguage()

ilMDGeneral::getLanguage ( int  $a_language_id)

Definition at line 87 of file class.ilMDGeneral.php.

88 {
89 if (!$a_language_id) {
90 return null;
91 }
92 $lan = new ilMDLanguage();
93 $lan->setMetaId($a_language_id);
94
95 return $lan;
96 }

Referenced by delete(), and toXML().

+ Here is the caller graph for this function:

◆ getLanguageIds()

ilMDGeneral::getLanguageIds ( )
Returns
int[]

Definition at line 82 of file class.ilMDGeneral.php.

82 : array
83 {
84 return ilMDLanguage::_getIds($this->getRBACId(), $this->getObjId(), (int) $this->getMetaId(), 'meta_general');
85 }
static _getIds(int $a_rbac_id, int $a_obj_id, int $a_parent_id, string $a_parent_type)

References ilMDLanguage\_getIds(), ilMDBase\getMetaId(), ilMDBase\getObjId(), and ilMDBase\getRBACId().

Referenced by delete(), and toXML().

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

◆ getPossibleSubelements()

ilMDGeneral::getPossibleSubelements ( )
Returns
array<string, string>

Definition at line 39 of file class.ilMDGeneral.php.

39 : array
40 {
41 $subs['Keyword'] = 'meta_keyword';
42 $subs['Language'] = 'meta_language';
43 $subs['Identifier'] = 'meta_identifier';
44 $subs['Description'] = 'meta_description';
45
46 return $subs;
47 }

◆ getStructure()

ilMDGeneral::getStructure ( )

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

180 : string
181 {
182 return $this->structure;
183 }

References $structure.

Referenced by __getFields(), and toXML().

+ Here is the caller graph for this function:

◆ getTitle()

ilMDGeneral::getTitle ( )

Definition at line 190 of file class.ilMDGeneral.php.

190 : string
191 {
192 return $this->title;
193 }

References $title.

Referenced by __getFields(), and toXML().

+ Here is the caller graph for this function:

◆ getTitleLanguage()

ilMDGeneral::getTitleLanguage ( )

Definition at line 200 of file class.ilMDGeneral.php.

201 {
202 return is_object($this->title_language) ? $this->title_language : null;
203 }

◆ getTitleLanguageCode()

ilMDGeneral::getTitleLanguageCode ( )

Definition at line 205 of file class.ilMDGeneral.php.

205 : string
206 {
207 return is_object($this->title_language) ? $this->title_language->getLanguageCode() : '';
208 }

Referenced by __getFields(), and toXML().

+ Here is the caller graph for this function:

◆ read()

ilMDGeneral::read ( )

Reimplemented from ilMDBase.

Definition at line 316 of file class.ilMDGeneral.php.

316 : bool
317 {
318 if ($this->getMetaId()) {
319 $query = "SELECT * FROM il_meta_general " .
320 "WHERE meta_general_id = " . $this->db->quote($this->getMetaId(), 'integer');
321
322 $res = $this->db->query($query);
323 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
324 $this->setRBACId((int) $row->rbac_id);
325 $this->setObjId((int) $row->obj_id);
326 $this->setObjType((string) $row->obj_type);
327 $this->setStructure((string) $row->general_structure);
328 $this->setTitle((string) $row->title);
329 $this->setTitleLanguage(new ilMDLanguageItem($row->title_language ?? ''));
330 $this->setCoverage((string) $row->coverage);
331 $this->setCoverageLanguage(new ilMDLanguageItem($row->coverage_language ?? ''));
332 }
333 }
334 return true;
335 }
setObjType(string $a_type)
setObjId(int $a_id)
setRBACId(int $a_id)
setTitle(string $a_title)
setCoverageLanguage(ilMDLanguageItem $lng_obj)
setStructure(string $a_structure)
setTitleLanguage(ilMDLanguageItem $lng_obj)
setCoverage(string $a_coverage)

References $query, $res, ilDBConstants\FETCHMODE_OBJECT, ilMDBase\getMetaId(), setCoverage(), setCoverageLanguage(), ilMDBase\setObjId(), ilMDBase\setObjType(), ilMDBase\setRBACId(), setStructure(), setTitle(), and setTitleLanguage().

+ Here is the call graph for this function:

◆ save()

ilMDGeneral::save ( )

Reimplemented from ilMDBase.

Definition at line 235 of file class.ilMDGeneral.php.

235 : int
236 {
237 $fields = $this->__getFields();
238 $fields['meta_general_id'] = array('integer', $next_id = $this->db->nextId('il_meta_general'));
239
240 $this->log->debug("Insert General " . print_r($fields, true));
241 $this->log->logStack(ilLogLevel::DEBUG);
242 //ilUtil::printBacktrace(10);
243
244 if ($this->db->insert('il_meta_general', $fields)) {
245 $this->setMetaId($next_id);
246 return $this->getMetaId();
247 }
248 return 0;
249 }
setMetaId(int $a_meta_id, bool $a_read_data=true)

References __getFields(), ilLogLevel\DEBUG, ilMDBase\getMetaId(), and ilMDBase\setMetaId().

+ Here is the call graph for this function:

◆ setCoverage()

ilMDGeneral::setCoverage ( string  $a_coverage)

Definition at line 210 of file class.ilMDGeneral.php.

210 : void
211 {
212 $this->coverage = $a_coverage;
213 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setCoverageLanguage()

ilMDGeneral::setCoverageLanguage ( ilMDLanguageItem  $lng_obj)

Definition at line 220 of file class.ilMDGeneral.php.

220 : void
221 {
222 $this->coverage_language = $lng_obj;
223 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setStructure()

ilMDGeneral::setStructure ( string  $a_structure)

Definition at line 164 of file class.ilMDGeneral.php.

164 : bool
165 {
166 switch ($a_structure) {
167 case 'Atomic':
168 case 'Collection':
169 case 'Networked':
170 case 'Hierarchical':
171 case 'Linear':
172 $this->structure = $a_structure;
173 return true;
174
175 default:
176 return false;
177 }
178 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setTitle()

ilMDGeneral::setTitle ( string  $a_title)

Definition at line 185 of file class.ilMDGeneral.php.

185 : void
186 {
187 $this->title = $a_title;
188 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setTitleLanguage()

ilMDGeneral::setTitleLanguage ( ilMDLanguageItem  $lng_obj)

Definition at line 195 of file class.ilMDGeneral.php.

195 : void
196 {
197 $this->title_language = $lng_obj;
198 }

Referenced by read().

+ Here is the caller graph for this function:

◆ toXML()

ilMDGeneral::toXML ( ilXmlWriter  $writer)

Reimplemented from ilMDBase.

Definition at line 337 of file class.ilMDGeneral.php.

337 : void
338 {
339 $writer->xmlStartTag('General', array(
340 'Structure' => $this->getStructure() ?: 'Atomic'
341 ));
342
343 // Identifier
344 $first = true;
345 $identifiers = $this->getIdentifierIds();
346 foreach ($identifiers as $id) {
347 $ide = $this->getIdentifier($id);
348 $ide->setExportMode($this->getExportMode());
349 $ide->toXML($writer);
350 $first = false;
351 }
352 if (!count($identifiers)) {
353 $ide = new ilMDIdentifier(
354 $this->getRBACId(),
355 $this->getObjId(),
356 $this->getObjType()
357 ); // added type, alex, 31 Oct 2007
358 $ide->setExportMode(true);
359 $ide->toXML($writer);
360 }
361
362 // Title
363 $writer->xmlElement(
364 'Title',
365 array(
366 'Language' => $this->getTitleLanguageCode() ?: 'en'
367 ),
368 $this->getTitle()
369 );
370
371 // Language
372 $languages = $this->getLanguageIds();
373 foreach ($languages as $id) {
374 $lan = $this->getLanguage($id);
375 $lan->toXML($writer);
376 }
377
378 // Description
379 $descriptions = $this->getDescriptionIds();
380 foreach ($descriptions as $id) {
381 $des = $this->getDescription($id);
382 $des->toXML($writer);
383 }
384 if (!count($descriptions)) {
385 // Default
386
387 $des = new ilMDDescription($this->getRBACId(), $this->getObjId());
388 $des->toXML($writer);
389 }
390
391 // Keyword
392 $keywords = $this->getKeywordIds();
393 foreach ($keywords as $id) {
394 $key = $this->getKeyword($id);
395 $key->toXML($writer);
396 }
397 if (!count($keywords)) {
398 // Default
399
400 $key = new ilMDKeyword($this->getRBACId(), $this->getObjId());
401 $key->toXML($writer);
402 }
403
404 // Copverage
405 if ($this->getCoverage() !== '') {
406 $writer->xmlElement(
407 'Coverage',
408 array(
409 'Language' => $this->getCoverageLanguageCode() ?: 'en'
410 ),
411 $this->getCoverage()
412 );
413 }
414 $writer->xmlEndTag('General');
415 }
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.

References $id, ILIAS\LTI\ToolProvider\$key, getCoverage(), getCoverageLanguageCode(), getDescription(), getDescriptionIds(), ilMDBase\getExportMode(), getIdentifier(), getIdentifierIds(), getKeyword(), getKeywordIds(), getLanguage(), getLanguageIds(), ilMDBase\getObjId(), ilMDBase\getObjType(), ilMDBase\getRBACId(), getStructure(), getTitle(), getTitleLanguageCode(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

+ Here is the call graph for this function:

◆ update()

ilMDGeneral::update ( )

Reimplemented from ilMDBase.

Definition at line 251 of file class.ilMDGeneral.php.

251 : bool
252 {
253 return $this->getMetaId() && $this->db->update(
254 'il_meta_general',
255 $this->__getFields(),
256 array("meta_general_id" => array('integer', $this->getMetaId()))
257 );
258 }

References __getFields(), and ilMDBase\getMetaId().

+ Here is the call graph for this function:

Field Documentation

◆ $coverage

string ilMDGeneral::$coverage = ''
private

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

Referenced by getCoverage().

◆ $coverage_language

ilMDLanguageItem ilMDGeneral::$coverage_language = null
protected

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

◆ $structure

string ilMDGeneral::$structure = ''
private

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

Referenced by getStructure().

◆ $title

string ilMDGeneral::$title = ''
private

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

Referenced by getTitle().

◆ $title_language

ilMDLanguageItem ilMDGeneral::$title_language = null
private

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


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