18 * SELECT DISTINCT ?g WHERE {GRAPH ?g {?s ?p ?o}} |
18 * SELECT DISTINCT ?g WHERE {GRAPH ?g {?s ?p ?o}} |
19 */ |
19 */ |
20 class Document extends DocumentResult { |
20 class Document extends DocumentResult { |
21 |
21 |
22 public function __construct($uri, $graph = null) { |
22 public function __construct($uri, $graph = null) { |
23 //print($graph->dump('html')); |
23 // print($graph->dump('html')); |
24 parent::__construct($uri, $graph); |
24 parent::__construct($uri, $graph); |
25 } |
25 } |
26 |
26 |
27 private $publishers = null; |
27 private $publishers = null; |
28 private $mediaArray = null; |
28 private $mediaArray = null; |
29 private $transcript = false; |
29 private $transcript = false; |
30 private $contributors = null; |
30 private $contributors = null; |
31 private $subjects = null; |
31 private $subjects = null; |
|
32 private $geoInfo = false; |
32 |
33 |
33 protected function clearMemoizationCache() { |
34 protected function clearMemoizationCache() { |
34 parent::clearMemoizationCache(); |
35 parent::clearMemoizationCache(); |
35 $this->publishers = null; |
36 $this->publishers = null; |
36 $this->mediaArray = null; |
37 $this->mediaArray = null; |
37 $this->contributors = null; |
38 $this->contributors = null; |
38 $this->subjects = null; |
39 $this->subjects = null; |
39 $this->transcript = false; |
40 $this->transcript = false; |
|
41 $this->geoInfo = false; |
40 } |
42 } |
41 |
43 |
42 |
44 |
43 public function getPublishers() { |
45 public function getPublishers() { |
44 if(is_null($this->publishers)) { |
46 if(is_null($this->publishers)) { |
215 } |
217 } |
216 return $this->subjects; |
218 return $this->subjects; |
217 } |
219 } |
218 |
220 |
219 /** |
221 /** |
|
222 * |
|
223 */ |
|
224 public function getGeoInfo() { |
|
225 if($this->geoInfo === false) { |
|
226 $places = $this->getProvidedCHO()->all('<http://purl.org/dc/terms/spatial>'); |
|
227 $this->geoInfo = null; |
|
228 if($places) { |
|
229 $this->geoInfo = new GeoResource($places[0]->getUri(), $this->graph); |
|
230 } |
|
231 } |
|
232 return $this->geoInfo; |
|
233 } |
|
234 |
|
235 /** |
220 * change subjecs list |
236 * change subjecs list |
221 */ |
237 */ |
222 public function setSubjects($subjects) { |
238 public function setSubjects($subjects) { |
223 $delta = $this->startDelta(); |
239 $delta = $this->startDelta(); |
224 //remove old, |
240 //remove old, |
276 $this->getMediaArray() |
292 $this->getMediaArray() |
277 ) |
293 ) |
278 ); |
294 ); |
279 |
295 |
280 $transcript = is_null($this->getTranscript())?null:$this->getTranscript()->jsonSerialize(); |
296 $transcript = is_null($this->getTranscript())?null:$this->getTranscript()->jsonSerialize(); |
|
297 $geoInfo = is_null($this->getGeoInfo())?null:$this->getGeoInfo()->jsonSerialize(); |
281 |
298 |
282 $publishers = array_map( |
299 $publishers = array_map( |
283 function($v) { return Utils::processLiteralResourceOrString($v); }, |
300 function($v) { return Utils::processLiteralResourceOrString($v); }, |
284 $this->getPublishers() |
301 $this->getPublishers() |
285 ); |
302 ); |
297 $res = array_merge($res, [ |
314 $res = array_merge($res, [ |
298 'publishers' => $publishers, |
315 'publishers' => $publishers, |
299 'contributors' => $contributors, |
316 'contributors' => $contributors, |
300 'subjects' => $subjects, |
317 'subjects' => $subjects, |
301 'transcript' => $transcript, |
318 'transcript' => $transcript, |
302 'mediaArray'=> $mediaArray |
319 'mediaArray'=> $mediaArray, |
|
320 'geoInfo' => $geoInfo |
303 ]); |
321 ]); |
304 |
322 |
305 } |
323 } |
306 return $res; |
324 return $res; |
307 |
325 |