ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
LOMDictionaryInitiator.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
28 
29 class LOMDictionaryInitiator extends BaseDictionaryInitiator
30 {
31  public const TABLES = [
32  'annotation' => 'il_meta_annotation',
33  'classification' => 'il_meta_classification',
34  'contribute' => 'il_meta_contribute',
35  'description' => 'il_meta_description',
36  'educational' => 'il_meta_educational',
37  'entity' => 'il_meta_entity',
38  'format' => 'il_meta_format',
39  'general' => 'il_meta_general',
40  'identifier' => 'il_meta_identifier',
41  'identifier_' => 'il_meta_identifier_',
42  'keyword' => 'il_meta_keyword',
43  'language' => 'il_meta_language',
44  'lifecycle' => 'il_meta_lifecycle',
45  'location' => 'il_meta_location',
46  'meta_data' => 'il_meta_meta_data',
47  'relation' => 'il_meta_relation',
48  'requirement' => 'il_meta_requirement',
49  'rights' => 'il_meta_rights',
50  'tar' => 'il_meta_tar',
51  'taxon' => 'il_meta_taxon',
52  'taxon_path' => 'il_meta_taxon_path',
53  'technical' => 'il_meta_technical',
54  'coverage' => 'il_meta_coverage',
55  'meta_schema' => 'il_meta_meta_schema',
56  'or_composite' => 'il_meta_or_composite',
57  'lr_type' => 'il_meta_lr_type',
58  'end_usr_role' => 'il_meta_end_usr_role',
59  'context' => 'il_meta_context'
60  ];
61 
62  public const ID_NAME = [
63  'annotation' => 'meta_annotation_id',
64  'classification' => 'meta_classification_id',
65  'contribute' => 'meta_contribute_id',
66  'description' => 'meta_description_id',
67  'educational' => 'meta_educational_id',
68  'entity' => 'meta_entity_id',
69  'format' => 'meta_format_id',
70  'general' => 'meta_general_id',
71  'identifier' => 'meta_identifier_id',
72  'identifier_' => 'meta_identifier__id',
73  'keyword' => 'meta_keyword_id',
74  'language' => 'meta_language_id',
75  'lifecycle' => 'meta_lifecycle_id',
76  'location' => 'meta_location_id',
77  'meta_data' => 'meta_meta_data_id',
78  'relation' => 'meta_relation_id',
79  'requirement' => 'meta_requirement_id',
80  'rights' => 'meta_rights_id',
81  'tar' => 'meta_tar_id',
82  'taxon' => 'meta_taxon_id',
83  'taxon_path' => 'meta_taxon_path_id',
84  'technical' => 'meta_technical_id',
85  'coverage' => 'meta_coverage_id',
86  'meta_schema' => 'meta_meta_schema_id',
87  'or_composite' => 'meta_or_composite_id',
88  'lr_type' => 'meta_lr_type_id',
89  'end_usr_role' => 'meta_end_usr_role_id',
90  'context' => 'meta_context_id'
91  ];
92 
93  protected TagFactory $tag_factory;
94 
95  public function __construct(
96  TagFactory $tag_factory,
100  ) {
101  $this->tag_factory = $tag_factory;
102  parent::__construct($path_factory, $navigator_factory, $structure);
103  }
104 
105  public function get(): DictionaryInterface
106  {
107  $this->initDictionary();
108  return new LOMDictionary($this->path_factory, $this->navigator_factory, ...$this->getTagAssignments());
109  }
110 
111  protected function initDictionary(): void
112  {
113  $structure = $this->getStructure();
114 
124  }
125 
126  protected function setTagsForGeneral(
128  ): void {
129  $this->addTagToElement(
130  $this->tag_factory->containerWithRowInTable('general'),
131  $general = $structure->getRoot()->getSubElement('general')
132  );
133  $this->setTagsForIdentifier(
134  $general,
135  'identifier',
136  'meta_general'
137  );
139  $general->getSubElement('title'),
140  'general',
141  'title',
142  'title_language'
143  );
144  $this->addTagToElement(
145  $this->tag_factory->dataWithRowInTable(
146  'language',
147  'language',
148  'meta_general'
149  ),
150  $general->getSubElement('language')
151  );
152  $this->addTagToElement(
153  $this->tag_factory->containerWithRowInTable(
154  'description',
155  'meta_general'
156  ),
157  $description = $general->getSubElement('description')
158  );
160  $description,
161  'description',
162  'description',
163  'description_language',
164  'meta_general'
165  );
166  $this->addTagToElement(
167  $this->tag_factory->containerWithRowInTable(
168  'keyword',
169  'meta_general'
170  ),
171  $keyword = $general->getSubElement('keyword')
172  );
174  $keyword,
175  'keyword',
176  'keyword',
177  'keyword_language',
178  'meta_general'
179  );
180  $this->addTagToElement(
181  $this->tag_factory->containerWithRowInTable(
182  'coverage',
183  'meta_general'
184  ),
185  $coverage = $general->getSubElement('coverage')
186  );
188  $coverage,
189  'coverage',
190  'coverage',
191  'coverage_language',
192  'meta_general'
193  );
195  $general->getSubElement('structure'),
196  'general',
197  'general_structure'
198  );
200  $general->getSubElement('aggregationLevel'),
201  'general',
202  'general_aggl'
203  );
204  }
205 
206  protected function setTagsForLifecycle(
208  ): void {
209  $this->addTagToElement(
210  $this->tag_factory->containerWithRowInTable('lifecycle'),
211  $life_cycle = $structure->getRoot()->getSubElement('lifeCycle')
212  );
214  $life_cycle->getSubElement('version'),
215  'lifecycle',
216  'meta_version',
217  'version_language'
218  );
220  $life_cycle->getSubElement('status'),
221  'lifecycle',
222  'lifecycle_status'
223  );
224  $this->setTagsForContribute(
225  $life_cycle,
226  'meta_lifecycle'
227  );
228  }
229 
230  protected function setTagsForMetaMetadata(
232  ): void {
233  $this->addTagToElement(
234  $this->tag_factory->containerWithRowInTable('meta_data'),
235  $meta = $structure->getRoot()->getSubElement('metaMetadata')
236  );
237  $this->setTagsForIdentifier(
238  $meta,
239  'identifier',
240  'meta_meta_data'
241  );
242  $this->setTagsForContribute(
243  $meta,
244  'meta_meta_data'
245  );
246  $this->addTagToElement(
247  $this->tag_factory->dataWithRowInTable(
248  'meta_schema',
249  'meta_data_schema',
250  'meta_meta_data'
251  ),
252  $meta->getSubElement('metadataSchema')
253  );
254  $this->addTagToElement(
255  $this->tag_factory->data(
256  'meta_data',
257  'language'
258  ),
259  $meta->getSubElement('language')
260  );
261  }
262 
263  protected function setTagsForTechnical(
265  ): void {
266  $this->addTagToElement(
267  $this->tag_factory->containerWithRowInTable('technical'),
268  $technical = $structure->getRoot()->getSubElement('technical')
269  );
270  $this->addTagToElement(
271  $this->tag_factory->dataWithRowInTable(
272  'format',
273  'format'
274  ),
275  $technical->getSubElement('format')
276  );
277  $this->addTagToElement(
278  $this->tag_factory->data(
279  'technical',
280  't_size'
281  ),
282  $technical->getSubElement('size')
283  );
284  $this->addTagToElement(
285  $this->tag_factory->dataWithRowInTable(
286  'location',
287  'location',
288  'meta_technical'
289  ),
290  $technical->getSubElement('location')
291  );
292  $this->addTagToElement(
293  $this->tag_factory->containerWithRowInTable(
294  'requirement',
295  'meta_technical'
296  ),
297  $requirement = $technical->getSubElement('requirement')
298  );
299  $this->addTagToElement(
300  $this->tag_factory->containerWithRowInTable(
301  'or_composite',
302  'meta_requirement'
303  ),
304  $or = $requirement->getSubElement('orComposite')
305  );
307  $or->getSubElement('type'),
308  'or_composite',
309  'type',
310  'meta_requirement'
311  );
313  $or->getSubElement('name'),
314  'or_composite',
315  'name',
316  'meta_requirement'
317  );
318  $this->addTagToElement(
319  $this->tag_factory->data(
320  'or_composite',
321  'min_version',
322  'meta_requirement'
323  ),
324  $or->getSubElement('minimumVersion')
325  );
326  $this->addTagToElement(
327  $this->tag_factory->data(
328  'or_composite',
329  'max_version',
330  'meta_requirement'
331  ),
332  $or->getSubElement('maximumVersion')
333  );
335  $technical->getSubElement('installationRemarks'),
336  'technical',
337  'ir',
338  'ir_language'
339  );
341  $technical->getSubElement('otherPlatformRequirements'),
342  'technical',
343  'opr',
344  'opr_language'
345  );
346  $duration = $technical->getSubElement('duration');
347  $this->addTagToElement(
348  $this->tag_factory->data(
349  'technical',
350  'duration'
351  ),
352  $duration->getSubElement('duration')
353  );
355  $duration->getSubElement('description'),
356  'technical',
357  'duration_descr',
358  'duration_descr_lang',
359  );
360  }
361 
362  protected function setTagsForEducational(
364  ): void {
365  $this->addTagToElement(
366  $this->tag_factory->containerWithRowInTable('educational'),
367  $educational = $structure->getRoot()->getSubElement('educational')
368  );
370  $educational->getSubElement('interactivityType'),
371  'educational',
372  'interactivity_type'
373  );
374  $this->addTagToElement(
375  $this->tag_factory->containerWithRowInTable(
376  'lr_type',
377  'meta_educational'
378  ),
379  $lr_type = $educational->getSubElement('learningResourceType')
380  );
382  $lr_type,
383  'lr_type',
384  'learning_resource_type',
385  'meta_educational'
386  );
388  $educational->getSubElement('interactivityLevel'),
389  'educational',
390  'interactivity_level'
391  );
393  $educational->getSubElement('semanticDensity'),
394  'educational',
395  'semantic_density'
396  );
397  $this->addTagToElement(
398  $this->tag_factory->containerWithRowInTable(
399  'end_usr_role',
400  'meta_educational'
401  ),
402  $user_role = $educational->getSubElement('intendedEndUserRole')
403  );
405  $user_role,
406  'end_usr_role',
407  'intended_end_user_role',
408  'meta_educational'
409  );
410  $this->addTagToElement(
411  $this->tag_factory->containerWithRowInTable(
412  'context',
413  'meta_educational'
414  ),
415  $context = $educational->getSubElement('context')
416  );
418  $context,
419  'context',
420  'context',
421  'meta_educational'
422  );
423  $this->addTagToElement(
424  $this->tag_factory->containerWithRowInTable(
425  'tar',
426  'meta_educational'
427  ),
428  $age_range = $educational->getSubElement('typicalAgeRange')
429  );
431  $age_range,
432  'tar',
433  'typical_age_range',
434  'tar_language',
435  'meta_educational'
436  );
438  $educational->getSubElement('difficulty'),
439  'educational',
440  'difficulty'
441  );
442  $tlt = $educational->getSubElement('typicalLearningTime');
443  $this->addTagToElement(
444  $this->tag_factory->data(
445  'educational',
446  'typical_learning_time'
447  ),
448  $tlt->getSubElement('duration')
449  );
451  $tlt->getSubElement('description'),
452  'educational',
453  'tlt_descr',
454  'tlt_descr_lang',
455  );
456  $this->addTagToElement(
457  $this->tag_factory->containerWithRowInTable(
458  'description',
459  'meta_educational'
460  ),
461  $description = $educational->getSubElement('description')
462  );
464  $description,
465  'description',
466  'description',
467  'description_language',
468  'meta_educational'
469  );
470  $this->addTagToElement(
471  $this->tag_factory->dataWithRowInTable(
472  'language',
473  'language',
474  'meta_educational'
475  ),
476  $educational->getSubElement('language')
477  );
478  }
479 
480  protected function setTagsForRights(
482  ): void {
483  $this->addTagToElement(
484  $this->tag_factory->containerWithRowInTable('rights'),
485  $rights = $structure->getRoot()->getSubElement('rights')
486  );
488  $rights->getSubElement('cost'),
489  'rights',
490  'costs'
491  );
493  $rights->getSubElement('copyrightAndOtherRestrictions'),
494  'rights',
495  'cpr_and_or'
496  );
498  $rights->getSubElement('description'),
499  'rights',
500  'description',
501  'description_language'
502  );
503  }
504 
505  protected function setTagsForRelation(
507  ): void {
508  $this->addTagToElement(
509  $this->tag_factory->containerWithRowInTable('relation'),
510  $relation = $structure->getRoot()->getSubElement('relation')
511  );
513  $relation->getSubElement('kind'),
514  'relation',
515  'kind'
516  );
517  $resource = $relation->getSubElement('resource');
518  $this->setTagsForIdentifier(
519  $resource,
520  'identifier_',
521  'meta_relation'
522  );
523  $this->addTagToElement(
524  $this->tag_factory->containerWithRowInTable(
525  'description',
526  'meta_relation'
527  ),
528  $description = $resource->getSubElement('description')
529  );
531  $description,
532  'description',
533  'description',
534  'description_language',
535  'meta_relation'
536  );
537  }
538 
539  protected function setTagsForAnnotation(
541  ): void {
542  $this->addTagToElement(
543  $this->tag_factory->containerWithRowInTable('annotation'),
544  $annotation = $structure->getRoot()->getSubElement('annotation')
545  );
546  $this->addTagToElement(
547  $this->tag_factory->data(
548  'annotation',
549  'entity'
550  ),
551  $annotation->getSubElement('entity')
552  );
553  $date = $annotation->getSubElement('date');
554  $this->addTagToElement(
555  $this->tag_factory->data(
556  'annotation',
557  'a_date'
558  ),
559  $date->getSubElement('dateTime')
560  );
562  $date->getSubElement('description'),
563  'annotation',
564  'a_date_descr',
565  'date_descr_lang'
566  );
568  $annotation->getSubElement('description'),
569  'annotation',
570  'description',
571  'description_language'
572  );
573  }
574 
575  protected function setTagsForClassification(
577  ): void {
578  $this->addTagToElement(
579  $this->tag_factory->containerWithRowInTable('classification'),
580  $classification = $structure->getRoot()->getSubElement('classification')
581  );
583  $classification->getSubElement('purpose'),
584  'classification',
585  'purpose'
586  );
587  $this->addTagToElement(
588  $this->tag_factory->containerWithRowInTable(
589  'taxon_path',
590  'meta_classification'
591  ),
592  $taxon_path = $classification->getSubElement('taxonPath')
593  );
595  $taxon_path->getSubElement('source'),
596  'taxon_path',
597  'source',
598  'source_language',
599  'meta_classification'
600  );
601  $this->addTagToElement(
602  $this->tag_factory->containerWithRowInTable(
603  'taxon',
604  'meta_taxon_path'
605  ),
606  $taxon = $taxon_path->getSubElement('taxon')
607  );
608  $this->addTagToElement(
609  $this->tag_factory->data(
610  'taxon',
611  'taxon_id',
612  'meta_taxon_path'
613  ),
614  $taxon->getSubElement('id')
615  );
617  $taxon->getSubElement('entry'),
618  'taxon',
619  'taxon',
620  'taxon_language'
621  );
623  $classification->getSubElement('description'),
624  'classification',
625  'description',
626  'description_language'
627  );
628  $this->addTagToElement(
629  $this->tag_factory->containerWithRowInTable(
630  'keyword',
631  'meta_classification'
632  ),
633  $keyword = $classification->getSubElement('keyword')
634  );
636  $keyword,
637  'keyword',
638  'keyword',
639  'keyword_language',
640  'meta_classification'
641  );
642  }
643 
644  protected function setTagsForIdentifier(
645  StructureElementInterface $element,
646  string $table,
647  string $parent
648  ): void {
649  $this->addTagToElement(
650  $this->tag_factory->containerWithRowInTable(
651  $table,
652  $parent
653  ),
654  $identifier = $element->getSubElement('identifier')
655  );
656  $this->addTagToElement(
657  $this->tag_factory->data(
658  $table,
659  'catalog',
660  $parent
661  ),
662  $identifier->getSubElement('catalog')
663  );
664  $this->addTagToElement(
665  $this->tag_factory->data(
666  $table,
667  'entry',
668  $parent
669  ),
670  $identifier->getSubElement('entry')
671  );
672  }
673 
674  protected function setTagsForContribute(
675  StructureElementInterface $element,
676  string $parent
677  ): void {
678  $this->addTagToElement(
679  $this->tag_factory->containerWithRowInTable(
680  'contribute',
681  $parent
682  ),
683  $contribute = $element->getSubElement('contribute')
684  );
686  $contribute->getSubElement('role'),
687  'contribute',
688  'role',
689  $parent
690  );
691  $this->addTagToElement(
692  $this->tag_factory->dataWithRowInTable(
693  'entity',
694  'entity',
695  'meta_contribute'
696  ),
697  $contribute->getSubElement('entity')
698  );
699  $date = $contribute->getSubElement('date');
700  $this->addTagToElement(
701  $this->tag_factory->data(
702  'contribute',
703  'c_date',
704  $parent
705  ),
706  $date->getSubElement('dateTime')
707  );
709  $date->getSubElement('description'),
710  'contribute',
711  'c_date_descr',
712  'descr_lang',
713  $parent
714  );
715  }
716 
718  StructureElementInterface $lang_string,
719  string $table,
720  string $field_string,
721  string $field_lang,
722  string $parent = ''
723  ): void {
724  $string_tag = $this->tag_factory->data(
725  $table,
726  $field_string,
727  $parent
728  );
729  $lang_tag = $this->tag_factory->data(
730  $table,
731  $field_lang,
732  $parent
733  );
734  $this->addTagToElement(
735  $string_tag,
736  $lang_string->getSubElement('string')
737  );
738  $this->addTagToElement(
739  $lang_tag,
740  $lang_string->getSubElement('language')
741  );
742  }
743 
744  protected function setTagsForVocabSubElements(
746  string $table,
747  string $field_value,
748  string $parent = ''
749  ): void {
750  $value_tag = $this->tag_factory->data(
751  $table,
752  $field_value,
753  $parent
754  );
755  $this->addTagToElement(
756  $value_tag,
757  $vocab->getSubElement('value')
758  );
759  }
760 }
getSubElement(string $name)
Return the first sub-element with the given name, if one exists.
$context
Definition: webdav.php:31
$relation
$technical
setTagsForContribute(StructureElementInterface $element, string $parent)
$duration
__construct(TagFactory $tag_factory, PathFactoryInterface $path_factory, NavigatorFactoryInterface $navigator_factory, StructureSetInterface $structure)
getRoot()
Returns the root element of the metadata set.
$educational
__construct(VocabulariesInterface $vocabularies)
$general
SECTIONS.
$annotation
$vocab
addTagToElement(TagInterface $tag, StructureElementInterface $element)
When indices are added, the tag applies only to copies of the element with those indices (beginning w...
NavigatorFactoryInterface $navigator_factory
only needed to instantiate dictionaries, which is done in inheritors
setTagsForVocabSubElements(StructureElementInterface $vocab, string $table, string $field_value, string $parent='')
$classification
$rights
setTagsForIdentifier(StructureElementInterface $element, string $table, string $parent)
setTagsForLangStringSubElements(StructureElementInterface $lang_string, string $table, string $field_string, string $field_lang, string $parent='')