blob: a99c77b61a858ec61be465677481e452ee8fc831 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
<?php
namespace SMW\Exporter\ResourceBuilders;
use SMW\DataValueFactory;
use SMW\DIProperty;
use SMWDataItem as DataItem;
use SMWExpData as ExpData;
use SMWExpLiteral as ExpLiteral;
/**
* @private
*
* @license GNU GPL v2+
* @since 2.5
*
* @author mwjames
*/
class PropertyDescriptionValueResourceBuilder extends PropertyValueResourceBuilder {
/**
* @since 2.5
*
* {@inheritDoc}
*/
public function isResourceBuilderFor( DIProperty $property ) {
return $property->getKey() === '_PDESC';
}
/**
* @since 2.5
*
* {@inheritDoc}
*/
public function addResourceValue( ExpData $expData, DIProperty $property, DataItem $dataItem ) {
parent::addResourceValue( $expData, $property, $dataItem );
$dataValue = DataValueFactory::getInstance()->newDataValueByItem(
$dataItem,
$property
);
$list = $dataValue->toArray();
if ( !isset( $list['_TEXT'] ) || !isset( $list['_LCODE'] ) ) {
return;
}
// Ussing `skos:scopeNote` instead of `skos:definition` since we can not
// ensure that the description given by a user is complete.
//
// "skos:scopeNote supplies some, possibly partial, information about the
// intended meaning of a concept ..."
//
// "skos:definition supplies a complete explanation of the intended
// meaning of a concept."
//
// According to https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation
$expData->addPropertyObjectValue(
$this->exporter->getSpecialNsResource( 'skos', 'scopeNote' ),
new ExpLiteral(
(string)$list['_TEXT'],
'http://www.w3.org/2001/XMLSchema#string',
(string)$list['_LCODE'],
$dataItem
)
);
}
}
|