ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilMDMetaMetadata Class Reference
+ Inheritance diagram for ilMDMetaMetadata:
+ Collaboration diagram for ilMDMetaMetadata:

Public Member Functions

 getPossibleSubelements ()
 
 getIdentifierIds ()
 
 getIdentifier (int $a_identifier_id)
 
 addIdentifier ()
 
 getContributeIds ()
 
 getContribute (int $a_contribute_id)
 
 addContribute ()
 
 setMetaDataScheme (string $a_val)
 
 getMetaDataScheme ()
 
 setLanguage (ilMDLanguageItem $lng_obj)
 
 getLanguage ()
 
 getLanguageCode ()
 
 save ()
 
 update ()
 
 delete ()
 
 __getFields ()
 
 read ()
 
 toXML (ilXmlWriter $writer)
 
 setMetaId (int $a_meta_id, bool $a_read_data=true)
 Compatibility fix for legacy MD classes for new db tables. More...
 
- 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 Member Functions

 createOrUpdateFirstSchema ()
 Compatibility fix for legacy MD classes for new db tables. More...
 
 deleteAllSchemas ()
 Compatibility fix for legacy MD classes for new db tables. More...
 
 readFirstSchema ()
 Compatibility fix for legacy MD classes for new db tables. More...
 
 getSchemaId ()
 Compatibility fix for legacy MD classes for new db tables. More...
 
 readSchemaId (int $parent_id)
 Compatibility fix for legacy MD classes for new db tables. More...
 

Private Attributes

string $meta_data_scheme = 'LOM v 1.0'
 
ilMDLanguageItem $language = null
 
int $schema_id = 0
 Compatibility fix for legacy MD classes for new db tables. More...
 

Additional Inherited Members

- Protected Attributes inherited from ilMDBase
ilLogger $log
 
ilDBInterface $db
 

Detailed Description

Definition at line 26 of file class.ilMDMetaMetadata.php.

Member Function Documentation

◆ __getFields()

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

Definition at line 188 of file class.ilMDMetaMetadata.php.

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

Referenced by save(), and update().

188  : array
189  {
190  return array(
191  'rbac_id' => array('integer', $this->getRBACId()),
192  'obj_id' => array('integer', $this->getObjId()),
193  'obj_type' => array('text', $this->getObjType()),
194  //'meta_data_scheme' => array('text', $this->getMetaDataScheme()),
195  'language' => array('text', $this->getLanguageCode())
196  );
197  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getId()

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

Definition at line 258 of file class.ilMDMetaMetadata.php.

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

Referenced by ilMD\getMetaMetadata().

258  : int
259  {
260  global $DIC;
261 
262  $ilDB = $DIC->database();
263 
264  $query = "SELECT meta_meta_data_id FROM il_meta_meta_data " .
265  "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
266  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer');
267 
268  $res = $ilDB->query($query);
269  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
270  return (int) $row->meta_meta_data_id;
271  }
272  return 0;
273  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ addContribute()

ilMDMetaMetadata::addContribute ( )

Definition at line 96 of file class.ilMDMetaMetadata.php.

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

97  {
98  $con = new ilMDContribute($this->getRBACId(), $this->getObjId(), $this->getObjType());
99  $con->setParentId($this->getMetaId());
100  $con->setParentType('meta_meta_data');
101 
102  return $con;
103  }
+ Here is the call graph for this function:

◆ addIdentifier()

ilMDMetaMetadata::addIdentifier ( )

Definition at line 68 of file class.ilMDMetaMetadata.php.

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

69  {
70  $ide = new ilMDIdentifier($this->getRBACId(), $this->getObjId(), $this->getObjType());
71  $ide->setParentId($this->getMetaId());
72  $ide->setParentType('meta_meta_data');
73 
74  return $ide;
75  }
+ Here is the call graph for this function:

◆ createOrUpdateFirstSchema()

ilMDMetaMetadata::createOrUpdateFirstSchema ( )
protected

Compatibility fix for legacy MD classes for new db tables.

Definition at line 279 of file class.ilMDMetaMetadata.php.

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

Referenced by save(), and update().

279  : void
280  {
281  if ($this->getMetaDataScheme() === '') {
282  return;
283  }
284 
285  if (!$this->getSchemaId()) {
286  $this->db->insert(
287  'il_meta_meta_schema',
288  [
289  'meta_meta_schema_id' => ['integer', $next_id = $this->db->nextId('il_meta_meta_schema')],
290  'rbac_id' => ['integer', $this->getRBACId()],
291  'obj_id' => ['integer', $this->getObjId()],
292  'obj_type' => ['text', $this->getObjType()],
293  'parent_type' => ['text', 'meta_general'],
294  'parent_id' => ['integer', $this->getMetaId()],
295  'meta_data_schema' => ['text', 'LOMv1.0'],
296  ]
297  );
298  $this->schema_id = $next_id;
299  }
300  }
getSchemaId()
Compatibility fix for legacy MD classes for new db tables.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilMDMetaMetadata::delete ( )

Definition at line 161 of file class.ilMDMetaMetadata.php.

References $id, $res, deleteAllSchemas(), getContribute(), getContributeIds(), getIdentifier(), getIdentifierIds(), and ilMDBase\getMetaId().

161  : bool
162  {
163  if ($this->getMetaId()) {
164  $query = "DELETE FROM il_meta_meta_data " .
165  "WHERE meta_meta_data_id = " . $this->db->quote($this->getMetaId(), 'integer');
166  $res = $this->db->manipulate($query);
167 
168  $this->deleteAllSchemas();
169 
170  foreach ($this->getIdentifierIds() as $id) {
171  $ide = $this->getIdentifier($id);
172  $ide->delete();
173  }
174 
175  foreach ($this->getContributeIds() as $id) {
176  $con = $this->getContribute($id);
177  $con->delete();
178  }
179  return true;
180  }
181 
182  return false;
183  }
$res
Definition: ltiservices.php:69
getContribute(int $a_contribute_id)
getIdentifier(int $a_identifier_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
deleteAllSchemas()
Compatibility fix for legacy MD classes for new db tables.
+ Here is the call graph for this function:

◆ deleteAllSchemas()

ilMDMetaMetadata::deleteAllSchemas ( )
protected

Compatibility fix for legacy MD classes for new db tables.

Definition at line 305 of file class.ilMDMetaMetadata.php.

References $res, and ilMDBase\getMetaId().

Referenced by delete().

305  : void
306  {
307  $query = "DELETE FROM il_meta_meta_schema WHERE parent_type = 'meta_meta_data'
308  AND parent_id = " . $this->db->quote($this->getMetaId(), 'integer');
309  $res = $this->db->manipulate($query);
310  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContribute()

ilMDMetaMetadata::getContribute ( int  $a_contribute_id)

Definition at line 85 of file class.ilMDMetaMetadata.php.

Referenced by delete(), and toXML().

86  {
87  if (!$a_contribute_id) {
88  return null;
89  }
90  $con = new ilMDContribute();
91  $con->setMetaId($a_contribute_id);
92 
93  return $con;
94  }
+ Here is the caller graph for this function:

◆ getContributeIds()

ilMDMetaMetadata::getContributeIds ( )
Returns
int[]

Definition at line 80 of file class.ilMDMetaMetadata.php.

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

Referenced by delete(), and toXML().

80  : array
81  {
82  return ilMDContribute::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_meta_data');
83  }
static _getIds(int $a_rbac_id, int $a_obj_id, int $a_parent_id, string $a_parent_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIdentifier()

ilMDMetaMetadata::getIdentifier ( int  $a_identifier_id)

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

Referenced by delete(), and toXML().

58  {
59  if (!$a_identifier_id) {
60  return null;
61  }
62  $ide = new ilMDIdentifier();
63  $ide->setMetaId($a_identifier_id);
64 
65  return $ide;
66  }
+ Here is the caller graph for this function:

◆ getIdentifierIds()

ilMDMetaMetadata::getIdentifierIds ( )
Returns
int[]

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

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

Referenced by delete(), and toXML().

52  : array
53  {
54  return ilMDIdentifier::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_meta_data');
55  }
static _getIds(int $a_rbac_id, int $a_obj_id, int $a_parent_id, string $a_parent_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLanguage()

ilMDMetaMetadata::getLanguage ( )

Definition at line 123 of file class.ilMDMetaMetadata.php.

References ILIAS\UI\examples\Symbol\Glyph\Language\language().

124  {
125  return is_object($this->language) ? $this->language : null;
126  }
+ Here is the call graph for this function:

◆ getLanguageCode()

ilMDMetaMetadata::getLanguageCode ( )

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

References ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by __getFields(), and toXML().

128  : string
129  {
130  return is_object($this->language) ? $this->language->getLanguageCode() : '';
131  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMetaDataScheme()

ilMDMetaMetadata::getMetaDataScheme ( )

Definition at line 112 of file class.ilMDMetaMetadata.php.

Referenced by createOrUpdateFirstSchema(), and toXML().

112  : string
113  {
114  // Fixed attribute
115  return 'LOM v 1.0';
116  }
+ Here is the caller graph for this function:

◆ getPossibleSubelements()

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

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

39  : array
40  {
41  $subs['Identifier'] = 'meta_identifier';
42  $subs['Contribute'] = 'meta_contribute';
43 
44  return $subs;
45  }

◆ getSchemaId()

ilMDMetaMetadata::getSchemaId ( )
protected

Compatibility fix for legacy MD classes for new db tables.

Definition at line 329 of file class.ilMDMetaMetadata.php.

References $schema_id.

Referenced by createOrUpdateFirstSchema().

329  : int
330  {
331  return $this->schema_id;
332  }
int $schema_id
Compatibility fix for legacy MD classes for new db tables.
+ Here is the caller graph for this function:

◆ read()

ilMDMetaMetadata::read ( )

Definition at line 199 of file class.ilMDMetaMetadata.php.

References $res, ilDBConstants\FETCHMODE_OBJECT, ilMDBase\getMetaId(), readFirstSchema(), setLanguage(), ilMDBase\setObjId(), ilMDBase\setObjType(), and ilMDBase\setRBACId().

199  : bool
200  {
201  if ($this->getMetaId()) {
202  $query = "SELECT * FROM il_meta_meta_data " .
203  "WHERE meta_meta_data_id = " . $this->db->quote($this->getMetaId(), 'integer');
204 
205  $res = $this->db->query($query);
206  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
207  $this->setRBACId((int) $row->rbac_id);
208  $this->setObjId((int) $row->obj_id);
209  $this->setObjType($row->obj_type);
210  //$this->setMetaDataScheme($row->meta_data_scheme ?? '');
211  $this->setLanguage(new ilMDLanguageItem($row->language ?? ''));
212  }
213 
214  $this->readFirstSchema();
215 
216  return true;
217  }
218  return false;
219  }
$res
Definition: ltiservices.php:69
setLanguage(ilMDLanguageItem $lng_obj)
setRBACId(int $a_id)
setObjId(int $a_id)
readFirstSchema()
Compatibility fix for legacy MD classes for new db tables.
setObjType(string $a_type)
+ Here is the call graph for this function:

◆ readFirstSchema()

ilMDMetaMetadata::readFirstSchema ( )
protected

Compatibility fix for legacy MD classes for new db tables.

Definition at line 315 of file class.ilMDMetaMetadata.php.

References $res, ilMDBase\getMetaId(), and setMetaDataScheme().

Referenced by read().

315  : void
316  {
317  $query = "SELECT * FROM il_meta_meta_schema WHERE meta_meta_schema_id = " .
318  $this->db->quote($this->getMetaId(), 'integer');
319 
320  $res = $this->db->query($query);
321  if ($row = $this->db->fetchAssoc($res)) {
322  $this->setMetaDataScheme((string) $row['meta_data_schema']);
323  }
324  }
$res
Definition: ltiservices.php:69
setMetaDataScheme(string $a_val)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readSchemaId()

ilMDMetaMetadata::readSchemaId ( int  $parent_id)
protected

Compatibility fix for legacy MD classes for new db tables.

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

References $res, and ILIAS\Repository\int().

Referenced by setMetaId().

337  : void
338  {
339  $query = "SELECT meta_meta_schema_id FROM il_meta_meta_schema WHERE parent_type = 'meta_meta_data'
340  AND parent_id = " . $this->db->quote($parent_id, 'integer') .
341  " ORDER BY meta_meta_schema_id";
342 
343  $res = $this->db->query($query);
344  if ($row = $this->db->fetchAssoc($res)) {
345  $this->schema_id = (int) $row['meta_meta_schema_id'];
346  }
347  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilMDMetaMetadata::save ( )

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

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

133  : int
134  {
135  $fields = $this->__getFields();
136  $fields['meta_meta_data_id'] = array('integer', $next_id = $this->db->nextId('il_meta_meta_data'));
137 
138  if ($this->db->insert('il_meta_meta_data', $fields)) {
139  $this->setMetaId($next_id);
140  $this->createOrUpdateFirstSchema();
141  return $this->getMetaId();
142  }
143  return 0;
144  }
setMetaId(int $a_meta_id, bool $a_read_data=true)
Compatibility fix for legacy MD classes for new db tables.
createOrUpdateFirstSchema()
Compatibility fix for legacy MD classes for new db tables.
+ Here is the call graph for this function:

◆ setLanguage()

ilMDMetaMetadata::setLanguage ( ilMDLanguageItem  $lng_obj)

Definition at line 118 of file class.ilMDMetaMetadata.php.

References ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by read().

118  : void
119  {
120  $this->language = $lng_obj;
121  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMetaDataScheme()

ilMDMetaMetadata::setMetaDataScheme ( string  $a_val)

Definition at line 107 of file class.ilMDMetaMetadata.php.

Referenced by readFirstSchema().

107  : void
108  {
109  $this->meta_data_scheme = $a_val;
110  }
+ Here is the caller graph for this function:

◆ setMetaId()

ilMDMetaMetadata::setMetaId ( int  $a_meta_id,
bool  $a_read_data = true 
)

Compatibility fix for legacy MD classes for new db tables.

Definition at line 352 of file class.ilMDMetaMetadata.php.

References readSchemaId().

Referenced by save().

352  : void
353  {
354  $this->readSchemaId($a_meta_id);
355  parent::setMetaId($a_meta_id, $a_read_data);
356  }
readSchemaId(int $parent_id)
Compatibility fix for legacy MD classes for new db tables.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toXML()

ilMDMetaMetadata::toXML ( ilXmlWriter  $writer)

Definition at line 221 of file class.ilMDMetaMetadata.php.

References $id, getContribute(), getContributeIds(), getIdentifier(), getIdentifierIds(), getLanguageCode(), getMetaDataScheme(), ilMDBase\getObjId(), ilMDBase\getRBACId(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

221  : void
222  {
223  $attr = null;
224  if ($this->getMetaDataScheme()) {
225  $attr['MetadataScheme'] = $this->getMetaDataScheme();
226  }
227  if ($this->getLanguageCode()) {
228  $attr['Language'] = $this->getLanguageCode();
229  }
230  $writer->xmlStartTag('Meta-Metadata', $attr);
231 
232  // ELEMENT IDENTIFIER
233  $identifiers = $this->getIdentifierIds();
234  foreach ($identifiers as $id) {
235  $ide = $this->getIdentifier($id);
236  $ide->toXML($writer);
237  }
238  if (!count($identifiers)) {
239  $ide = new ilMDIdentifier($this->getRBACId(), $this->getObjId());
240  $ide->toXML($writer);
241  }
242 
243  // ELEMETN Contribute
244  $contributes = $this->getContributeIds();
245  foreach ($contributes as $id) {
246  $con = $this->getContribute($id);
247  $con->toXML($writer);
248  }
249  if (!count($contributes)) {
250  $con = new ilMDContribute($this->getRBACId(), $this->getObjId());
251  $con->toXML($writer);
252  }
253 
254  $writer->xmlEndTag('Meta-Metadata');
255  }
getContribute(int $a_contribute_id)
xmlEndTag(string $tag)
Writes an endtag.
getIdentifier(int $a_identifier_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
+ Here is the call graph for this function:

◆ update()

ilMDMetaMetadata::update ( )

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

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

146  : bool
147  {
148  if (!$this->getMetaId()) {
149  return false;
150  }
151 
152  $this->createOrUpdateFirstSchema();
153 
154  return (bool) $this->db->update(
155  'il_meta_meta_data',
156  $this->__getFields(),
157  array("meta_meta_data_id" => array('integer', $this->getMetaId()))
158  );
159  }
createOrUpdateFirstSchema()
Compatibility fix for legacy MD classes for new db tables.
+ Here is the call graph for this function:

Field Documentation

◆ $language

ilMDLanguageItem ilMDMetaMetadata::$language = null
private

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

◆ $meta_data_scheme

string ilMDMetaMetadata::$meta_data_scheme = 'LOM v 1.0'
private

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

◆ $schema_id

int ilMDMetaMetadata::$schema_id = 0
private

Compatibility fix for legacy MD classes for new db tables.

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

Referenced by getSchemaId().


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