|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the kaloa/xmp package. |
|
5
|
|
|
* |
|
6
|
|
|
* For full copyright and license information, please view the LICENSE file |
|
7
|
|
|
* that was distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Kaloa\Xmp\Properties; |
|
11
|
|
|
|
|
12
|
|
|
use Kaloa\Xmp\Properties\AbstractProperties; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Extracts the Dublin Core properties from an XMP document referenced by an |
|
16
|
|
|
* XPath instance. |
|
17
|
|
|
* |
|
18
|
|
|
* The descriptions for all getters are taken from |
|
19
|
|
|
* <a href="http://www.exiv2.org/tags-xmp-dc.html">exiv2.org</a>. |
|
20
|
|
|
* |
|
21
|
|
|
* All getter methods return either an array or a string but never one or the |
|
22
|
|
|
* other for the same entity. |
|
23
|
|
|
* |
|
24
|
|
|
* @todo Currently, internal XMP data structures such as XmpSeq oder XmpBag are |
|
25
|
|
|
* represented by PHP arrays. The object model might be extended in later |
|
26
|
|
|
* versions. |
|
27
|
|
|
*/ |
|
28
|
|
|
class DublinCoreProperties extends AbstractProperties |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* See getContributor. |
|
32
|
|
|
* |
|
33
|
|
|
* @var array |
|
34
|
|
|
*/ |
|
35
|
|
|
private $contributor = array(); |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* See getCoverage. |
|
39
|
|
|
* |
|
40
|
|
|
* @var string |
|
41
|
|
|
*/ |
|
42
|
|
|
private $coverage = ''; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* See getCreator. |
|
46
|
|
|
* |
|
47
|
|
|
* @var array |
|
48
|
|
|
*/ |
|
49
|
|
|
private $creator = array(); |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* See getDate. |
|
53
|
|
|
* |
|
54
|
|
|
* @var array |
|
55
|
|
|
*/ |
|
56
|
|
|
private $date = array(); |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* See getDescription. |
|
60
|
|
|
* |
|
61
|
|
|
* @var array |
|
62
|
|
|
*/ |
|
63
|
|
|
private $description = array(); |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* See getFormat. |
|
67
|
|
|
* |
|
68
|
|
|
* @var string |
|
69
|
|
|
*/ |
|
70
|
|
|
private $format = ''; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* See getIdentifier. |
|
74
|
|
|
* |
|
75
|
|
|
* @var string |
|
76
|
|
|
*/ |
|
77
|
|
|
private $identifier = ''; |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* See getLanguage. |
|
81
|
|
|
* |
|
82
|
|
|
* @var array |
|
83
|
|
|
*/ |
|
84
|
|
|
private $language = array(); |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* See getPublisher. |
|
88
|
|
|
* |
|
89
|
|
|
* @var array |
|
90
|
|
|
*/ |
|
91
|
|
|
private $publisher = array(); |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* See getRelation. |
|
95
|
|
|
* |
|
96
|
|
|
* @var array |
|
97
|
|
|
*/ |
|
98
|
|
|
private $relation = array(); |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* See getRights. |
|
102
|
|
|
* |
|
103
|
|
|
* @var array |
|
104
|
|
|
*/ |
|
105
|
|
|
private $rights = array(); |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* See getSource. |
|
109
|
|
|
* |
|
110
|
|
|
* @var string |
|
111
|
|
|
*/ |
|
112
|
|
|
private $source = ''; |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* See getSubject. |
|
116
|
|
|
* |
|
117
|
|
|
* @var array |
|
118
|
|
|
*/ |
|
119
|
|
|
private $subject = array(); |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* See getTitle. |
|
123
|
|
|
* |
|
124
|
|
|
* @var array |
|
125
|
|
|
*/ |
|
126
|
|
|
private $title = array(); |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* See getType. |
|
130
|
|
|
* |
|
131
|
|
|
* @var array |
|
132
|
|
|
*/ |
|
133
|
|
|
private $type = array(); |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* Retrieves all properties from the underlying XMP document. |
|
137
|
|
|
*/ |
|
138
|
1 |
|
final protected function init() |
|
139
|
|
|
{ |
|
140
|
1 |
|
$this->contributor = $this->getArray('contributor'); |
|
141
|
|
|
|
|
142
|
1 |
|
foreach ($this->xPath->query('//dc:coverage') as $node) { |
|
143
|
|
|
$this->coverage = $node->nodeValue; |
|
144
|
1 |
|
} |
|
145
|
|
|
|
|
146
|
1 |
|
$this->creator = $this->getArray('creator'); |
|
147
|
1 |
|
$this->date = $this->getArray('date'); |
|
148
|
1 |
|
$this->description = $this->getArray('description'); |
|
149
|
|
|
|
|
150
|
|
|
// Format |
|
151
|
|
|
|
|
152
|
1 |
|
foreach ($this->xPath->query('//dc:format') as $node) { |
|
153
|
|
|
$this->format = $node->nodeValue; |
|
154
|
1 |
|
} |
|
155
|
|
|
|
|
156
|
|
|
// Identifier |
|
157
|
|
|
|
|
158
|
1 |
|
foreach ($this->xPath->query('//dc:identifier') as $node) { |
|
159
|
|
|
$this->identifier = $node->nodeValue; |
|
160
|
1 |
|
} |
|
161
|
|
|
|
|
162
|
1 |
|
$this->language = $this->getArray('language'); |
|
163
|
1 |
|
$this->publisher = $this->getArray('publisher'); |
|
164
|
1 |
|
$this->relation = $this->getArray('relation'); |
|
165
|
1 |
|
$this->rights = $this->getArray('rights'); |
|
166
|
|
|
|
|
167
|
|
|
// Source |
|
168
|
|
|
|
|
169
|
1 |
|
foreach ($this->xPath->query('//dc:source//rdf:li') as $node) { |
|
170
|
|
|
$this->source = $node->nodeValue; |
|
171
|
1 |
|
} |
|
172
|
|
|
|
|
173
|
|
|
// Subject |
|
174
|
|
|
|
|
175
|
1 |
|
$this->subject = $this->getArray('subject'); |
|
176
|
|
|
|
|
177
|
|
|
// Title |
|
178
|
|
|
|
|
179
|
1 |
|
$this->title = $this->getArray('title'); |
|
180
|
|
|
|
|
181
|
1 |
|
if (count($this->title) === 0) { |
|
182
|
|
|
foreach ($this->xPath->query('//dc:title') as $node) { |
|
183
|
|
|
$this->title[] = $node->nodeValue; |
|
184
|
|
|
} |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
// Free our reference to the XPath instance. |
|
188
|
1 |
|
$this->xPath = null; |
|
189
|
1 |
|
} |
|
190
|
|
|
|
|
191
|
|
|
/** |
|
192
|
|
|
* Returns the values of all occurrences of an entity. |
|
193
|
|
|
* |
|
194
|
|
|
* @param string $entity |
|
195
|
|
|
* @return array |
|
196
|
|
|
*/ |
|
197
|
1 |
|
private function getArray($entity) |
|
198
|
|
|
{ |
|
199
|
1 |
|
$tmp = array(); |
|
200
|
|
|
|
|
201
|
1 |
|
foreach ($this->xPath->query('//dc:' . $entity . '//rdf:li') as $node) { |
|
202
|
1 |
|
$tmp[] = $node->nodeValue; |
|
203
|
1 |
|
} |
|
204
|
|
|
|
|
205
|
1 |
|
return $tmp; |
|
206
|
|
|
} |
|
207
|
|
|
|
|
208
|
|
|
/** |
|
209
|
|
|
* Returns contributors to the resource (other than the authors). |
|
210
|
|
|
* |
|
211
|
|
|
* @return array |
|
212
|
|
|
*/ |
|
213
|
1 |
|
public function getContributor() |
|
214
|
|
|
{ |
|
215
|
1 |
|
return $this->contributor; |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
/** |
|
219
|
|
|
* Returns the spatial or temporal topic of the resource, the spatial |
|
220
|
|
|
* applicability of the resource, or the jurisdiction under which the |
|
221
|
|
|
* resource is relevant. |
|
222
|
|
|
* |
|
223
|
|
|
* @return string |
|
224
|
|
|
*/ |
|
225
|
1 |
|
public function getCoverage() |
|
226
|
|
|
{ |
|
227
|
1 |
|
return $this->coverage; |
|
228
|
|
|
} |
|
229
|
|
|
|
|
230
|
|
|
/** |
|
231
|
|
|
* Returns the authors of the resource (listed in order of precedence, if |
|
232
|
|
|
* significant). |
|
233
|
|
|
* |
|
234
|
|
|
* @return array |
|
235
|
|
|
*/ |
|
236
|
1 |
|
public function getCreator() |
|
237
|
|
|
{ |
|
238
|
1 |
|
return $this->creator; |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
/** |
|
242
|
|
|
* Returns date(s) that something interesting happened to the resource. |
|
243
|
|
|
* |
|
244
|
|
|
* @return array |
|
245
|
|
|
*/ |
|
246
|
1 |
|
public function getDate() |
|
247
|
|
|
{ |
|
248
|
1 |
|
return $this->date; |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
/** |
|
252
|
|
|
* Returns a textual description of the content of the resource. |
|
253
|
|
|
* |
|
254
|
|
|
* Multiple values may be present for different languages. |
|
255
|
|
|
* |
|
256
|
|
|
* @return array |
|
257
|
|
|
*/ |
|
258
|
1 |
|
public function getDescription() |
|
259
|
|
|
{ |
|
260
|
1 |
|
return $this->description; |
|
261
|
|
|
} |
|
262
|
|
|
|
|
263
|
|
|
/** |
|
264
|
|
|
* Returns the file format used when saving the resource. |
|
265
|
|
|
* |
|
266
|
|
|
* Tools and applications should set this property to the save format of the |
|
267
|
|
|
* data. It may include appropriate qualifiers. |
|
268
|
|
|
* |
|
269
|
|
|
* @return string |
|
270
|
|
|
*/ |
|
271
|
1 |
|
public function getFormat() |
|
272
|
|
|
{ |
|
273
|
1 |
|
return $this->format; |
|
274
|
|
|
} |
|
275
|
|
|
|
|
276
|
|
|
/** |
|
277
|
|
|
* Returns the unique identifier of the resource. |
|
278
|
|
|
* |
|
279
|
|
|
* Recommended best practice is to identify the resource by means of a |
|
280
|
|
|
* string conforming to a formal identification system. |
|
281
|
|
|
* |
|
282
|
|
|
* @return string |
|
283
|
|
|
*/ |
|
284
|
1 |
|
public function getIdentifier() |
|
285
|
|
|
{ |
|
286
|
1 |
|
return $this->identifier; |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
/** |
|
290
|
|
|
* Returns an unordered array specifying the languages used in the resource. |
|
291
|
|
|
* |
|
292
|
|
|
* @return array |
|
293
|
|
|
*/ |
|
294
|
1 |
|
public function getLanguage() |
|
295
|
|
|
{ |
|
296
|
1 |
|
return $this->language; |
|
297
|
|
|
} |
|
298
|
|
|
|
|
299
|
|
|
/** |
|
300
|
|
|
* Returns an entity responsible for making the resource available. |
|
301
|
|
|
* |
|
302
|
|
|
* Examples of a Publisher include a person, an organization, or a service. |
|
303
|
|
|
* Typically, the name of a Publisher should be used to indicate the entity. |
|
304
|
|
|
* |
|
305
|
|
|
* @return array |
|
306
|
|
|
*/ |
|
307
|
1 |
|
public function getPublisher() |
|
308
|
|
|
{ |
|
309
|
1 |
|
return $this->publisher; |
|
310
|
|
|
} |
|
311
|
|
|
|
|
312
|
|
|
/** |
|
313
|
|
|
* Returns relationships to other documents. |
|
314
|
|
|
* |
|
315
|
|
|
* Recommended best practice is to identify the related resource by means of |
|
316
|
|
|
* a string conforming to a formal identification system. |
|
317
|
|
|
* |
|
318
|
|
|
* @return array |
|
319
|
|
|
*/ |
|
320
|
1 |
|
public function getRelation() |
|
321
|
|
|
{ |
|
322
|
1 |
|
return $this->relation; |
|
323
|
|
|
} |
|
324
|
|
|
|
|
325
|
|
|
/** |
|
326
|
|
|
* Returns an informal rights statement, selected by language. |
|
327
|
|
|
* |
|
328
|
|
|
* Typically, rights information includes a statement about various property |
|
329
|
|
|
* rights associated with the resource, including intellectual property |
|
330
|
|
|
* rights. |
|
331
|
|
|
* |
|
332
|
|
|
* @return array |
|
333
|
|
|
*/ |
|
334
|
1 |
|
public function getRights() |
|
335
|
|
|
{ |
|
336
|
1 |
|
return $this->rights; |
|
337
|
|
|
} |
|
338
|
|
|
|
|
339
|
|
|
/** |
|
340
|
|
|
* Returns the Unique identifier of the work from which this resource was |
|
341
|
|
|
* derived. |
|
342
|
|
|
* |
|
343
|
|
|
* @return string |
|
344
|
|
|
*/ |
|
345
|
1 |
|
public function getSource() |
|
346
|
|
|
{ |
|
347
|
1 |
|
return $this->source; |
|
348
|
|
|
} |
|
349
|
|
|
|
|
350
|
|
|
/** |
|
351
|
|
|
* Returns an unordered array of descriptive phrases or keywords that |
|
352
|
|
|
* specify the topic of the content of the resource. |
|
353
|
|
|
* |
|
354
|
|
|
* @return array |
|
355
|
|
|
*/ |
|
356
|
1 |
|
public function getSubject() |
|
357
|
|
|
{ |
|
358
|
1 |
|
return $this->subject; |
|
359
|
|
|
} |
|
360
|
|
|
|
|
361
|
|
|
/** |
|
362
|
|
|
* Returns the title of the document, or the name given to the resource. |
|
363
|
|
|
* |
|
364
|
|
|
* Typically, it will be a name by which the resource is formally known. |
|
365
|
|
|
* |
|
366
|
|
|
* @return array |
|
367
|
|
|
*/ |
|
368
|
1 |
|
public function getTitle() |
|
369
|
|
|
{ |
|
370
|
1 |
|
return $this->title; |
|
371
|
|
|
} |
|
372
|
|
|
|
|
373
|
|
|
/** |
|
374
|
|
|
* Returns a document type; for example, novel, poem, or working paper. |
|
375
|
|
|
* |
|
376
|
|
|
* @return array |
|
377
|
|
|
*/ |
|
378
|
1 |
|
public function getType() |
|
379
|
|
|
{ |
|
380
|
1 |
|
return $this->type; |
|
381
|
|
|
} |
|
382
|
|
|
} |
|
383
|
|
|
|