Skip to content

Commit 0d68772

Browse files
authored
Merge pull request #6 from adevicef/main
Return complete metadata structures when calling getMetadata
2 parents 6e7cabb + 06bcb78 commit 0d68772

File tree

3 files changed

+668
-308
lines changed

3 files changed

+668
-308
lines changed

docs/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Return a detailed metadata array containing Package, Dublin Core, LOM and LOM-ES
115115
information together with the page tree.
116116

117117
- **Throws:** `Exception` if the XML cannot be parsed
118-
- **Returns:** array - Metadata and content structure
118+
- **Returns:** array - Metadata structure
119119

120120
#### `extract(string $destinationPath): void`
121121

src/ElpParser.php

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -542,73 +542,67 @@ public function getMetadata(): array
542542
$meta = [
543543
[
544544
'schema' => 'Package',
545-
'content' => [
545+
'content' => [
546546
'title' => $data['_title'] ?? '',
547+
'lang' => $data['_lang'] ?? '',
548+
'description' => [
549+
'general_description' => $data['_description'] ?? '',
550+
'objectives' => $data['_objectives'] ?? '',
551+
'preknowledge' => $data['_preknowledge'] ?? ''
552+
],
547553
'author' => $data['_author'] ?? '',
548-
'language' => $data['_lang'] ?? '',
549-
'description' => $data['_description'] ?? '',
550554
'license' => $data['license'] ?? '',
551-
'classification' => '',
555+
'learningResourceType' => $data['_learningResourceType'] ?? '',
556+
'usage' => [
557+
'intendedEndUserRoleType' => $data['_intendedEndUserRoleType'] ?? '',
558+
'intendedEndUserRoleGroup' => $data['_intendedEndUserRoleGroup'] ?? '',
559+
'intendedEndUserRoleTutor' => $data['_intendedEndUserRoleTutor'] ?? '',
560+
'contextPlace' => $data['_contextPlace'] ?? '',
561+
'contextMode' => $data['_contextMode'] ?? '',
562+
],
563+
'project_properties' => [
564+
'backgroundImg' => $data['_backgroundImg'] ?? '',
565+
'backgroundImgTile' => $data['backgroundImgTile'] ?? '',
566+
'footer' => $data['footer'] ?? '',
567+
],
568+
'format' => [
569+
'Doctype' => $data['_docType'] ?? '',
570+
],
571+
'taxonomy' => [
572+
'level_1' => $data['_levelNames'][0] ?? '',
573+
'level_2' => $data['_levelNames'][1] ?? '',
574+
'level_3' => $data['_levelNames'][2] ?? '',
575+
],
576+
'advanced_options' => [
577+
'custom_head' => $data['_extraHeadContent'] ?? ''
578+
]
552579
],
553580
],
554581
];
555582

556583
if (isset($data['dublinCore'])) {
557-
$dc = $data['dublinCore'];
558584
$meta[] = [
559585
'schema' => 'Dublin core',
560-
'content' => [
561-
'title' => $dc['title'] ?? '',
562-
'author' => $dc['creator'] ?? '',
563-
'language' => $dc['language'] ?? '',
564-
'description' => $dc['description'] ?? '',
565-
'license' => [ 'rights' => $dc['rights'] ?? '' ],
566-
'classification' => [ 'source' => $dc['source'] ?? '', 'taxon_path' => [] ],
567-
],
586+
'content' => $data['dublinCore'] ?? [],
568587
];
569588
}
570589

571590
if (isset($data['lom'])) {
572-
$lom = $data['lom'];
573591
$meta[] = [
574592
'schema' => 'LOM v1.0',
575-
'content' => [
576-
'title' => $lom['general']['title']['string'] ?? [],
577-
'author' => $lom['lifeCycle']['contribute']['entity'] ?? [],
578-
'language' => $lom['general']['language'] ?? [],
579-
'description' => $lom['general']['description'] ?? [],
580-
'rights' => $lom['rights'] ?? [],
581-
'classification' => $lom['classification'] ?? [],
582-
],
593+
'content' => $data['lom'] ?? [],
583594
];
584595
}
585596

586597
if (isset($data['lomEs'])) {
587-
$lomEs = $data['lomEs'];
588598
$meta[] = [
589599
'schema' => 'LOM-ES v1.0',
590-
'content' => [
591-
'title' => $lomEs['general']['title']['string'] ?? [],
592-
'author' => $lomEs['lifeCycle']['contribute']['entity']['name'] ?? ($lomEs['lifeCycle']['contribute']['entity'] ?? ''),
593-
'language' => $lomEs['general']['language'] ?? [],
594-
'description' => $lomEs['general']['description'] ?? [],
595-
'rights' => $lomEs['rights'] ?? [],
596-
'classification' => $lomEs['classification'] ?? [],
597-
],
600+
'content' => $data['lomEs'] ?? [],
598601
];
599602
}
600603

601-
$pages = [];
602-
if (isset($data['_nodeIdDict']['0'])) {
603-
$this->collectPages($data['_nodeIdDict']['0'], 0, $pages);
604-
}
605-
606604
return [
607605
'metadata' => $meta,
608-
'content' => [
609-
'file' => basename($this->filePath),
610-
'pages' => $pages,
611-
],
612606
];
613607
}
614608

0 commit comments

Comments
 (0)