1
|
|
|
<?php |
2
|
|
|
/* Source: https://github.com/moodle/moodle/blob/MOODLE_310_STABLE/backup/cc/cc_lib/cc_version1.php under GNU/GPL license */ |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Version 1 class of Common Cartridge. |
6
|
|
|
*/ |
7
|
|
|
class CcVersion1 extends CcVersionBase |
8
|
|
|
{ |
9
|
|
|
const WEBCONTENT = 'webcontent'; |
10
|
|
|
const QUESTIONBANK = 'imsqti_xmlv1p2/imscc_xmlv1p0/question-bank'; |
11
|
|
|
const ASSESSMENT = 'imsqti_xmlv1p2/imscc_xmlv1p0/assessment'; |
12
|
|
|
const ASSOCIATEDCONTENT = 'associatedcontent/imscc_xmlv1p0/learning-application-resource'; |
13
|
|
|
const DISCUSSIONTOPIC = 'imsdt_xmlv1p0'; |
14
|
|
|
const WEBLINK = 'imswl_xmlv1p0'; |
15
|
|
|
|
16
|
|
|
public static $checker = [self::WEBCONTENT, |
17
|
|
|
self::ASSESSMENT, |
18
|
|
|
self::ASSOCIATEDCONTENT, |
19
|
|
|
self::DISCUSSIONTOPIC, |
20
|
|
|
self::QUESTIONBANK, |
21
|
|
|
self::WEBLINK, ]; |
22
|
|
|
|
23
|
|
|
public function __construct() |
24
|
|
|
{ |
25
|
|
|
$this->ccnamespaces = ['imscc' => 'http://www.imsglobal.org/xsd/imscc/imscp_v1p1', |
26
|
|
|
'lomimscc' => 'http://ltsc.ieee.org/xsd/imscc/LOM', |
27
|
|
|
'lom' => 'http://ltsc.ieee.org/xsd/LOM', |
28
|
|
|
'voc' => 'http://ltsc.ieee.org/xsd/LOM/vocab', |
29
|
|
|
'xsi' => 'http://www.w3.org/2001/XMLSchema-instance', |
30
|
|
|
]; |
31
|
|
|
|
32
|
|
|
$this->ccnsnames = [ |
33
|
|
|
'imscc' => 'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/imscp_v1p2_localised.xsd', |
34
|
|
|
'lom' => 'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_2/lomLoose_localised.xsd', |
35
|
|
|
'lomimscc' => 'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_1/lomLoose_localised.xsd', |
36
|
|
|
'voc' => 'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_2/vocab/loose.xsd', |
37
|
|
|
]; |
38
|
|
|
|
39
|
|
|
$this->ccversion = '1.0.0'; |
40
|
|
|
$this->camversion = '1.0.0'; |
41
|
|
|
$this->_generator = 'Common Cartridge generator'; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Validate if the type are valid or not. |
46
|
|
|
* |
47
|
|
|
* @param string $type |
48
|
|
|
* |
49
|
|
|
* @return bool |
50
|
|
|
*/ |
51
|
|
|
public function valid($type) |
52
|
|
|
{ |
53
|
|
|
return in_array($type, self::$checker); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Create Education Metadata (How To). |
58
|
|
|
* |
59
|
|
|
* @param object $met |
60
|
|
|
* @param object $xmlnode |
61
|
|
|
* |
62
|
|
|
* @return DOMNode |
63
|
|
|
*/ |
64
|
|
|
public function createMetadataEducational($met, DOMDocument &$doc, $xmlnode) |
65
|
|
|
{ |
66
|
|
|
$nd = $doc->createElementNS($this->ccnamespaces['lom'], 'educational'); |
67
|
|
|
$nd2 = $doc->createElementNS($this->ccnamespaces['lom'], 'intendedEndUserRole'); |
68
|
|
|
$nd3 = $doc->createElementNS($this->ccnamespaces['voc'], 'vocabulary'); |
69
|
|
|
|
70
|
|
|
$xmlnode->appendChild($nd); |
71
|
|
|
$nd->appendChild($nd2); |
72
|
|
|
$nd2->appendChild($nd3); |
73
|
|
|
|
74
|
|
|
foreach ($met->arrayeducational as $name => $value) { |
75
|
|
|
!is_array($value) ? $value = [$value] : null; |
76
|
|
|
foreach ($value as $v) { |
77
|
|
|
$nd4 = $doc->createElementNS($this->ccnamespaces['voc'], $name, $v[0]); |
78
|
|
|
$nd3->appendChild($nd4); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
return $nd; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
protected function onCreate(DOMDocument &$doc, $rootmanifestnode = null, $nmanifestID = null) |
86
|
|
|
{ |
87
|
|
|
$doc->formatOutput = true; |
88
|
|
|
$doc->preserveWhiteSpace = true; |
89
|
|
|
|
90
|
|
|
$this->manifestID = is_null($nmanifestID) ? CcHelpers::uuidgen('M_') : $nmanifestID; |
91
|
|
|
$mUUID = $doc->createAttribute('identifier'); |
92
|
|
|
$mUUID->nodeValue = $this->manifestID; |
93
|
|
|
|
94
|
|
|
if (is_null($rootmanifestnode)) { |
95
|
|
|
if (!empty($this->_generator)) { |
96
|
|
|
$comment = $doc->createComment($this->_generator); |
97
|
|
|
$doc->appendChild($comment); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
$rootel = $doc->createElementNS($this->ccnamespaces['imscc'], 'manifest'); |
101
|
|
|
$rootel->appendChild($mUUID); |
102
|
|
|
$doc->appendChild($rootel); |
103
|
|
|
|
104
|
|
|
// Add all namespaces. |
105
|
|
|
foreach ($this->ccnamespaces as $key => $value) { |
106
|
|
|
$dummy_attr = $key.":dummy"; |
107
|
|
|
$doc->createAttributeNS($value, $dummy_attr); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
// Add location of schemas. |
111
|
|
|
$schemaLocation = ''; |
112
|
|
|
foreach ($this->ccnsnames as $key => $value) { |
113
|
|
|
$vt = empty($schemaLocation) ? '' : ' '; |
114
|
|
|
$schemaLocation .= $vt.$this->ccnamespaces[$key].' '.$value; |
115
|
|
|
} |
116
|
|
|
$aSchemaLoc = $doc->createAttributeNS($this->ccnamespaces['xsi'], 'xsi:schemaLocation'); |
117
|
|
|
$aSchemaLoc->nodeValue = $schemaLocation; |
118
|
|
|
$rootel->appendChild($aSchemaLoc); |
119
|
|
|
} else { |
120
|
|
|
$rootel = $doc->createElementNS($this->ccnamespaces['imscc'], 'imscc:manifest'); |
121
|
|
|
$rootel->appendChild($mUUID); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
$metadata = $doc->createElementNS($this->ccnamespaces['imscc'], 'metadata'); |
125
|
|
|
$schema = $doc->createElementNS($this->ccnamespaces['imscc'], 'schema', 'IMS Common Cartridge'); |
126
|
|
|
$schemaversion = $doc->createElementNS($this->ccnamespaces['imscc'], 'schemaversion', $this->ccversion); |
127
|
|
|
|
128
|
|
|
$metadata->appendChild($schema); |
129
|
|
|
$metadata->appendChild($schemaversion); |
130
|
|
|
$rootel->appendChild($metadata); |
131
|
|
|
|
132
|
|
|
if (!is_null($rootmanifestnode)) { |
133
|
|
|
$rootmanifestnode->appendChild($rootel); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
$organizations = $doc->createElementNS($this->ccnamespaces['imscc'], 'organizations'); |
137
|
|
|
$rootel->appendChild($organizations); |
138
|
|
|
$resources = $doc->createElementNS($this->ccnamespaces['imscc'], 'resources'); |
139
|
|
|
$rootel->appendChild($resources); |
140
|
|
|
|
141
|
|
|
return true; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
protected function updateAttribute(DOMDocument &$doc, $attrname, $attrvalue, DOMElement &$node) |
145
|
|
|
{ |
146
|
|
|
$busenew = (is_object($node) && $node->hasAttribute($attrname)); |
147
|
|
|
$nResult = null; |
148
|
|
|
if (!$busenew && is_null($attrvalue)) { |
149
|
|
|
$node->removeAttribute($attrname); |
150
|
|
|
} else { |
151
|
|
|
$nResult = $busenew ? $node->getAttributeNode($attrname) : $doc->createAttribute($attrname); |
152
|
|
|
$nResult->nodeValue = $attrvalue; |
153
|
|
|
if (!$busenew) { |
154
|
|
|
$node->appendChild($nResult); |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
return $nResult; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
protected function updateAttributeNs(DOMDocument &$doc, $attrname, $attrnamespace, $attrvalue, DOMElement &$node) |
162
|
|
|
{ |
163
|
|
|
$busenew = (is_object($node) && $node->hasAttributeNS($attrnamespace, $attrname)); |
164
|
|
|
$nResult = null; |
165
|
|
|
if (!$busenew && is_null($attrvalue)) { |
166
|
|
|
$node->removeAttributeNS($attrnamespace, $attrname); |
167
|
|
|
} else { |
168
|
|
|
$nResult = $busenew ? $node->getAttributeNodeNS($attrnamespace, $attrname) : |
169
|
|
|
$doc->createAttributeNS($attrnamespace, $attrname); |
170
|
|
|
$nResult->nodeValue = $attrvalue; |
171
|
|
|
if (!$busenew) { |
172
|
|
|
$node->appendChild($nResult); |
173
|
|
|
} |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
return $nResult; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
protected function getChildNode(DOMDocument &$doc, $itemname, DOMElement &$node) |
180
|
|
|
{ |
181
|
|
|
$nlist = $node->getElementsByTagName($itemname); |
182
|
|
|
$item = is_object($nlist) && ($nlist->length > 0) ? $nlist->item(0) : null; |
183
|
|
|
|
184
|
|
|
return $item; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
protected function updateChildItem(DOMDocument &$doc, $itemname, $itemvalue, DOMElement &$node, $attrtostore = null) |
188
|
|
|
{ |
189
|
|
|
$tnode = $this->getChildNode($doc, 'title', $node); |
190
|
|
|
$usenew = is_null($tnode); |
191
|
|
|
$tnode = $usenew ? $doc->createElementNS($this->ccnamespaces['imscc'], $itemname) : $tnode; |
192
|
|
|
if (!is_null($attrtostore)) { |
193
|
|
|
foreach ($attrtostore as $key => $value) { |
194
|
|
|
$this->updateAttribute($doc, $key, $value, $tnode); |
195
|
|
|
} |
196
|
|
|
} |
197
|
|
|
$tnode->nodeValue = $itemvalue; |
198
|
|
|
if ($usenew) { |
199
|
|
|
$node->appendChild($tnode); |
200
|
|
|
} |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
protected function updateItems($items, DOMDocument &$doc, DOMElement &$xmlnode) |
204
|
|
|
{ |
205
|
|
|
foreach ($items as $key => $item) { |
206
|
|
|
$itemnode = $doc->createElementNS($this->ccnamespaces['imscc'], 'item'); |
207
|
|
|
$this->updateAttribute($doc, 'identifier', $key, $itemnode); |
208
|
|
|
$this->updateAttribute($doc, 'identifierref', $item->identifierref, $itemnode); |
209
|
|
|
$this->updateAttribute($doc, 'parameters', $item->parameters, $itemnode); |
210
|
|
|
if (!empty($item->title)) { |
211
|
|
|
$titlenode = $doc->createElementNS($this->ccnamespaces['imscc'], |
212
|
|
|
'title', |
213
|
|
|
$item->title); |
214
|
|
|
$itemnode->appendChild($titlenode); |
215
|
|
|
} |
216
|
|
|
if ($item->hasChildItems()) { |
217
|
|
|
$this->updateItems($item->childitems, $doc, $itemnode); |
218
|
|
|
} |
219
|
|
|
$xmlnode->appendChild($itemnode); |
220
|
|
|
} |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* Create a Resource (How to). |
225
|
|
|
* |
226
|
|
|
* @param CcIResource $res |
227
|
|
|
* @param DOMDocument $doc |
228
|
|
|
* @param object $xmlnode |
229
|
|
|
* |
230
|
|
|
* @return DOMNode |
231
|
|
|
*/ |
232
|
|
|
protected function createResource(CcIResource &$res, DOMDocument &$doc, $xmlnode = null) |
233
|
|
|
{ |
234
|
|
|
$usenew = is_object($xmlnode); |
235
|
|
|
$dnode = $usenew ? $xmlnode : $doc->createElementNS($this->ccnamespaces['imscc'], "resource"); |
236
|
|
|
$this->updateAttribute($doc, 'identifier', $res->identifier, $dnode); |
|
|
|
|
237
|
|
|
$this->updateAttribute($doc, 'type', $res->type, $dnode); |
|
|
|
|
238
|
|
|
!is_null($res->href) ? $this->updateAttribute($doc, 'href', $res->href, $dnode) : null; |
|
|
|
|
239
|
|
|
$this->updateAttribute($doc, 'base', $res->base, $dnode); |
|
|
|
|
240
|
|
|
|
241
|
|
|
foreach ($res->files as $file) { |
|
|
|
|
242
|
|
|
$nd = $doc->createElementNS($this->ccnamespaces['imscc'], 'file'); |
243
|
|
|
$ndatt = $doc->createAttribute('href'); |
244
|
|
|
$ndatt->nodeValue = $file; |
245
|
|
|
$nd->appendChild($ndatt); |
246
|
|
|
$dnode->appendChild($nd); |
247
|
|
|
} |
248
|
|
|
$this->resources[$res->identifier] = $res; |
249
|
|
|
$this->resourcesInd[$res->files[0]] = $res->identifier; |
250
|
|
|
|
251
|
|
|
foreach ($res->dependency as $dependency) { |
|
|
|
|
252
|
|
|
$nd = $doc->createElementNS($this->ccnamespaces['imscc'], 'dependency'); |
253
|
|
|
$ndatt = $doc->createAttribute('identifierref'); |
254
|
|
|
$ndatt->nodeValue = $dependency; |
255
|
|
|
$nd->appendChild($ndatt); |
256
|
|
|
$dnode->appendChild($nd); |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
return $dnode; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* Create an Item Folder (How To). |
264
|
|
|
* |
265
|
|
|
* @param CcIOrganization $org |
266
|
|
|
* @param DOMDocument $doc |
267
|
|
|
* @param DOMElement $xmlnode |
268
|
|
|
*/ |
269
|
|
|
protected function createItemFolder(CcIOrganization &$org, DOMDocument &$doc, DOMElement &$xmlnode = null) |
270
|
|
|
{ |
271
|
|
|
$itemfoldernode = $doc->createElementNS($this->ccnamespaces['imscc'], 'item'); |
272
|
|
|
$this->updateAttribute($doc, 'identifier', "root", $itemfoldernode); |
273
|
|
|
|
274
|
|
|
if ($org->hasItems()) { |
275
|
|
|
$this->updateItems($org->itemlist, $doc, $itemfoldernode); |
|
|
|
|
276
|
|
|
} |
277
|
|
|
if (is_null($this->organizations)) { |
278
|
|
|
$this->organizations = []; |
279
|
|
|
} |
280
|
|
|
$this->organizations[$org->identifier] = $org; |
|
|
|
|
281
|
|
|
|
282
|
|
|
$xmlnode->appendChild($itemfoldernode); |
|
|
|
|
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
/** |
286
|
|
|
* Create an Organization (How To). |
287
|
|
|
* |
288
|
|
|
* @param CcIOrganization $org |
289
|
|
|
* @param DOMDocument $doc |
290
|
|
|
* @param object $xmlnode |
291
|
|
|
* |
292
|
|
|
* @return DOMNode |
293
|
|
|
*/ |
294
|
|
|
protected function createOrganization(CcIOrganization &$org, DOMDocument &$doc, $xmlnode = null) |
295
|
|
|
{ |
296
|
|
|
$usenew = is_object($xmlnode); |
297
|
|
|
$dnode = $usenew ? $xmlnode : $doc->createElementNS($this->ccnamespaces['imscc'], "organization"); |
298
|
|
|
$this->updateAttribute($doc, 'identifier', $org->identifier, $dnode); |
|
|
|
|
299
|
|
|
$this->updateAttribute($doc, 'structure', $org->structure, $dnode); |
|
|
|
|
300
|
|
|
|
301
|
|
|
$this->createItemFolder($org, $doc, $dnode); |
302
|
|
|
|
303
|
|
|
return $dnode; |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
/** |
307
|
|
|
* Create Metadata For Manifest (How To). |
308
|
|
|
* |
309
|
|
|
* @param CcIMetadataManifest $met |
310
|
|
|
* @param DOMDocument $doc |
311
|
|
|
* @param object $xmlnode |
312
|
|
|
* |
313
|
|
|
* @return DOMNode |
314
|
|
|
*/ |
315
|
|
|
protected function createMetadataManifest(CcIMetadataManifest $met, DOMDocument &$doc, $xmlnode = null) |
316
|
|
|
{ |
317
|
|
|
$dnode = $doc->createElementNS($this->ccnamespaces['lomimscc'], "lom"); |
318
|
|
|
if (!empty($xmlnode)) { |
319
|
|
|
$xmlnode->appendChild($dnode); |
320
|
|
|
} |
321
|
|
|
$dnodegeneral = empty($met->arraygeneral) ? null : $this->createMetadataGeneral($met, $doc, $xmlnode); |
|
|
|
|
322
|
|
|
$dnodetechnical = empty($met->arraytech) ? null : $this->createMetadataTechnical($met, $doc, $xmlnode); |
|
|
|
|
323
|
|
|
$dnoderights = empty($met->arrayrights) ? null : $this->createMetadataRights($met, $doc, $xmlnode); |
|
|
|
|
324
|
|
|
$dnodelifecycle = empty($met->arraylifecycle) ? null : $this->createMetadataLifecycle($met, $doc, $xmlnode); |
|
|
|
|
325
|
|
|
|
326
|
|
|
!is_null($dnodegeneral) ? $dnode->appendChild($dnodegeneral) : null; |
327
|
|
|
!is_null($dnodetechnical) ? $dnode->appendChild($dnodetechnical) : null; |
328
|
|
|
!is_null($dnoderights) ? $dnode->appendChild($dnoderights) : null; |
329
|
|
|
!is_null($dnodelifecycle) ? $dnode->appendChild($dnodelifecycle) : null; |
330
|
|
|
|
331
|
|
|
return $dnode; |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* Create Metadata For Resource (How To). |
336
|
|
|
* |
337
|
|
|
* @param CcIMetadataResource $met |
338
|
|
|
* @param DOMDocument $doc |
339
|
|
|
* @param object $xmlnode |
340
|
|
|
* |
341
|
|
|
* @return DOMNode |
342
|
|
|
*/ |
343
|
|
|
protected function createMetadataResource(CcIMetadataResource $met, DOMDocument &$doc, $xmlnode = null) |
344
|
|
|
{ |
345
|
|
|
$dnode = $doc->createElementNS($this->ccnamespaces['lom'], "lom"); |
346
|
|
|
|
347
|
|
|
!empty($xmlnode) ? $xmlnode->appendChild($dnode) : null; |
348
|
|
|
!empty($met->arrayeducational) ? $this->createMetadataEducational($met, $doc, $dnode) : null; |
|
|
|
|
349
|
|
|
|
350
|
|
|
return $dnode; |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
/** |
354
|
|
|
* Create Metadata For File (How To). |
355
|
|
|
* |
356
|
|
|
* @param CcIMetadataFile $met |
357
|
|
|
* @param DOMDocument $doc |
358
|
|
|
* @param object $xmlnode |
359
|
|
|
* |
360
|
|
|
* @return DOMNode |
361
|
|
|
*/ |
362
|
|
|
protected function createMetadataFile(CcIMetadataFile $met, DOMDocument &$doc, $xmlnode = null) |
363
|
|
|
{ |
364
|
|
|
$dnode = $doc->createElementNS($this->ccnamespaces['lom'], "lom"); |
365
|
|
|
|
366
|
|
|
!empty($xmlnode) ? $xmlnode->appendChild($dnode) : null; |
367
|
|
|
!empty($met->arrayeducational) ? $this->createMetadataEducational($met, $doc, $dnode) : null; |
|
|
|
|
368
|
|
|
|
369
|
|
|
return $dnode; |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
/** |
373
|
|
|
* Create General Metadata (How To). |
374
|
|
|
* |
375
|
|
|
* @param object $met |
376
|
|
|
* @param object $xmlnode |
377
|
|
|
* |
378
|
|
|
* @return DOMNode |
379
|
|
|
*/ |
380
|
|
|
protected function createMetadataGeneral($met, DOMDocument &$doc, $xmlnode) |
381
|
|
|
{ |
382
|
|
|
$nd = $doc->createElementNS($this->ccnamespaces['lomimscc'], 'general'); |
383
|
|
|
|
384
|
|
|
foreach ($met->arraygeneral as $name => $value) { |
385
|
|
|
!is_array($value) ? $value = [$value] : null; |
386
|
|
|
foreach ($value as $v) { |
387
|
|
|
if ($name != 'language' && $name != 'catalog' && $name != 'entry') { |
388
|
|
|
$nd2 = $doc->createElementNS($this->ccnamespaces['lomimscc'], $name); |
389
|
|
|
$nd3 = $doc->createElementNS($this->ccnamespaces['lomimscc'], 'string', $v[1]); |
390
|
|
|
$ndatt = $doc->createAttribute('language'); |
391
|
|
|
$ndatt->nodeValue = $v[0]; |
392
|
|
|
$nd3->appendChild($ndatt); |
393
|
|
|
$nd2->appendChild($nd3); |
394
|
|
|
$nd->appendChild($nd2); |
395
|
|
|
} else { |
396
|
|
|
if ($name == 'language') { |
397
|
|
|
$nd2 = $doc->createElementNS($this->ccnamespaces['lomimscc'], $name, $v[0]); |
398
|
|
|
$nd->appendChild($nd2); |
399
|
|
|
} |
400
|
|
|
} |
401
|
|
|
} |
402
|
|
|
} |
403
|
|
|
if (!empty($met->arraygeneral['catalog']) || !empty($met->arraygeneral['entry'])) { |
404
|
|
|
$nd2 = $doc->createElementNS($this->ccnamespaces['lomimscc'], 'identifier'); |
405
|
|
|
$nd->appendChild($nd2); |
406
|
|
|
if (!empty($met->arraygeneral['catalog'])) { |
407
|
|
|
$nd3 = $doc->createElementNS($this->ccnamespaces['lomimscc'], 'catalog', $met->arraygeneral['catalog'][0][0]); |
408
|
|
|
$nd2->appendChild($nd3); |
409
|
|
|
} |
410
|
|
|
if (!empty($met->arraygeneral['entry'])) { |
411
|
|
|
$nd4 = $doc->createElementNS($this->ccnamespaces['lomimscc'], 'entry', $met->arraygeneral['entry'][0][0]); |
412
|
|
|
$nd2->appendChild($nd4); |
413
|
|
|
} |
414
|
|
|
} |
415
|
|
|
|
416
|
|
|
return $nd; |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
/** |
420
|
|
|
* Create Technical Metadata (How To). |
421
|
|
|
* |
422
|
|
|
* @param object $met |
423
|
|
|
* @param object $xmlnode |
424
|
|
|
* |
425
|
|
|
* @return DOMNode |
426
|
|
|
*/ |
427
|
|
|
protected function createMetadataTechnical($met, DOMDocument &$doc, $xmlnode) |
428
|
|
|
{ |
429
|
|
|
$nd = $doc->createElementNS($this->ccnamespaces['lomimscc'], 'technical'); |
430
|
|
|
$xmlnode->appendChild($nd); |
431
|
|
|
|
432
|
|
|
foreach ($met->arraytech as $name => $value) { |
433
|
|
|
!is_array($value) ? $value = [$value] : null; |
434
|
|
|
foreach ($value as $v) { |
435
|
|
|
$nd2 = $doc->createElementNS($this->ccnamespaces['lomimscc'], $name, $v[0]); |
436
|
|
|
$nd->appendChild($nd2); |
437
|
|
|
} |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
return $nd; |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
/** |
444
|
|
|
* Create Rights Metadata (How To). |
445
|
|
|
* |
446
|
|
|
* @param object $met |
447
|
|
|
* @param object $xmlnode |
448
|
|
|
* |
449
|
|
|
* @return DOMNode |
450
|
|
|
*/ |
451
|
|
|
protected function createMetadataRights($met, DOMDocument &$doc, $xmlnode) |
452
|
|
|
{ |
453
|
|
|
$nd = $doc->createElementNS($this->ccnamespaces['lomimscc'], 'rights'); |
454
|
|
|
|
455
|
|
|
foreach ($met->arrayrights as $name => $value) { |
456
|
|
|
!is_array($value) ? $value = [$value] : null; |
457
|
|
|
foreach ($value as $v) { |
458
|
|
|
if ($name == 'description') { |
459
|
|
|
$nd2 = $doc->createElementNS($this->ccnamespaces['lomimscc'], $name); |
460
|
|
|
$nd3 = $doc->createElementNS($this->ccnamespaces['lomimscc'], 'string', $v[1]); |
461
|
|
|
$ndatt = $doc->createAttribute('language'); |
462
|
|
|
$ndatt->nodeValue = $v[0]; |
463
|
|
|
$nd3->appendChild($ndatt); |
464
|
|
|
$nd2->appendChild($nd3); |
465
|
|
|
$nd->appendChild($nd2); |
466
|
|
|
} elseif ($name == 'copyrightAndOtherRestrictions' || $name == 'cost') { |
467
|
|
|
$nd2 = $doc->createElementNS($this->ccnamespaces['lomimscc'], $name); |
468
|
|
|
$nd3 = $doc->createElementNS($this->ccnamespaces['lomimscc'], 'value', $v[0]); |
469
|
|
|
$nd2->appendChild($nd3); |
470
|
|
|
$nd->appendChild($nd2); |
471
|
|
|
} |
472
|
|
|
} |
473
|
|
|
} |
474
|
|
|
|
475
|
|
|
return $nd; |
476
|
|
|
} |
477
|
|
|
|
478
|
|
|
/** |
479
|
|
|
* Create Lifecycle Metadata (How To). |
480
|
|
|
* |
481
|
|
|
* @param object $met |
482
|
|
|
* @param DOMDocument $doc |
483
|
|
|
* @param object $met |
484
|
|
|
* @param object $xmlnode |
485
|
|
|
* |
486
|
|
|
* @return DOMNode |
487
|
|
|
*/ |
488
|
|
|
protected function createMetadataLifecycle($met, DOMDocument &$doc, $xmlnode) |
489
|
|
|
{ |
490
|
|
|
$nd = $doc->createElementNS($this->ccnamespaces['lomimscc'], 'lifeCycle'); |
491
|
|
|
$nd2 = $doc->createElementNS($this->ccnamespaces['lomimscc'], 'contribute'); |
492
|
|
|
|
493
|
|
|
$nd->appendChild($nd2); |
494
|
|
|
$xmlnode->appendChild($nd); |
495
|
|
|
|
496
|
|
|
foreach ($met->arraylifecycle as $name => $value) { |
497
|
|
|
!is_array($value) ? $value = [$value] : null; |
498
|
|
|
foreach ($value as $v) { |
499
|
|
|
if ($name == 'role') { |
500
|
|
|
$nd3 = $doc->createElementNS($this->ccnamespaces['lomimscc'], $name); |
501
|
|
|
$nd2->appendChild($nd3); |
502
|
|
|
$nd4 = $doc->createElementNS($this->ccnamespaces['lomimscc'], 'value', $v[0]); |
503
|
|
|
$nd3->appendChild($nd4); |
504
|
|
|
} else { |
505
|
|
|
if ($name == 'date') { |
506
|
|
|
$nd3 = $doc->createElementNS($this->ccnamespaces['lomimscc'], $name); |
507
|
|
|
$nd2->appendChild($nd3); |
508
|
|
|
$nd4 = $doc->createElementNS($this->ccnamespaces['lomimscc'], 'dateTime', $v[0]); |
509
|
|
|
$nd3->appendChild($nd4); |
510
|
|
|
} else { |
511
|
|
|
$nd3 = $doc->createElementNS($this->ccnamespaces['lomimscc'], $name, $v[0]); |
512
|
|
|
$nd2->appendChild($nd3); |
513
|
|
|
} |
514
|
|
|
} |
515
|
|
|
} |
516
|
|
|
} |
517
|
|
|
|
518
|
|
|
return $nd; |
519
|
|
|
} |
520
|
|
|
} |
521
|
|
|
|