1 | <?php |
||
2 | |||
3 | class LabelSkosXL extends DataObject |
||
4 | { |
||
5 | |||
6 | public function __construct($model, $resource) |
||
7 | { |
||
8 | parent::__construct($model, $resource); |
||
9 | } |
||
10 | |||
11 | public function getPrefLabel() { |
||
12 | $label = null; |
||
13 | $labels = $this->resource->allResources('skosxl:prefLabel'); |
||
14 | foreach($labels as $labres) { |
||
15 | $label = $labres->getLiteral('skosxl:literalForm'); |
||
16 | if ($label->getLang() == $this->clang) { |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
17 | return $label; |
||
18 | } |
||
19 | } |
||
20 | return $label; |
||
21 | } |
||
22 | |||
23 | public function getProperties() { |
||
24 | $ret = array(); |
||
25 | $props = $this->resource->properties(); |
||
26 | foreach($props as $prop) { |
||
27 | if ($prop !== 'rdf:type' && $prop !== 'skosxl:literalForm') { |
||
28 | // make sure to use the correct gettext keys for DC namespace |
||
29 | $propkey = str_starts_with($prop, 'dc11:') ? |
||
30 | str_replace('dc11:', 'dc:', $prop) : $prop; |
||
31 | $ret[$propkey] = $this->resource->get($prop); |
||
32 | } |
||
33 | } |
||
34 | return $ret; |
||
35 | } |
||
36 | |||
37 | public function getLang() { |
||
38 | return $this->resource->getLiteral('skosxl:literalForm')->getLang(); |
||
39 | } |
||
40 | |||
41 | public function getLiteral() { |
||
42 | return $this->resource->getLiteral('skosxl:literalForm')->getValue(); |
||
43 | } |
||
44 | |||
45 | public function __toString() { |
||
46 | return $this->resource->getLiteral('skosxl:literalForm')->getValue(); |
||
47 | } |
||
48 | } |
||
49 |