65 } |
65 } |
66 } |
66 } |
67 return $this->title; |
67 return $this->title; |
68 } |
68 } |
69 |
69 |
|
70 public function getTitleValue() { |
|
71 $title = $this->getTitle(); |
|
72 return is_null($title)?null:$title->getValue(); |
|
73 } |
|
74 |
70 public function getPublishers() { |
75 public function getPublishers() { |
71 if(is_null($this->publishers)) { |
76 if(is_null($this->publishers)) { |
72 try { |
77 try { |
73 $this->publishers = $this->getProvidedCHO()->all('dc11:publisher'); |
78 $this->publishers = $this->getProvidedCHO()->all('dc11:publisher'); |
74 } catch(\Exception $e) { |
79 } catch(\Exception $e) { |
85 } catch(\Exception $e) { |
90 } catch(\Exception $e) { |
86 $this->issued = null; |
91 $this->issued = null; |
87 } |
92 } |
88 } |
93 } |
89 return $this->issued; |
94 return $this->issued; |
|
95 } |
|
96 |
|
97 public function getIssuedValue() { |
|
98 $issued = $this->getIssued(); |
|
99 return is_null($issued)?null:$issued->getValue(); |
90 } |
100 } |
91 |
101 |
92 public function getModified() { |
102 public function getModified() { |
93 if(is_null($this->modified)) { |
103 if(is_null($this->modified)) { |
94 try { |
104 try { |
95 $this->modified = $this->getProvidedCHO()->getLiteral("<http://purl.org/dc/terms/modified>"); |
105 $this->modified = $this->getProvidedCHO()->getLiteral("<http://purl.org/dc/terms/modified>"); |
96 if(is_null($this->modified)) { |
106 if(is_null($this->modified)) { |
97 $this->modified = $this->getIssued(); |
107 $this->modified = $this->getIssued(); |
98 } |
108 } |
99 else { |
|
100 $this->modified = $this->modified->getValue(); |
|
101 } |
|
102 } catch(\Exception $e) { |
109 } catch(\Exception $e) { |
103 $this->modified = null; |
110 $this->modified = null; |
104 } |
111 } |
105 } |
112 } |
106 return $this->modified; |
113 return $this->modified; |
|
114 } |
|
115 |
|
116 public function getModifiedValue() { |
|
117 $modified = $this->getModified(); |
|
118 return is_null($modified)?null:$modified->getValue(); |
107 } |
119 } |
108 |
120 |
109 public function getMediaArray() { |
121 public function getMediaArray() { |
110 |
122 |
111 if(is_null($this->mediaArray)) { |
123 if(is_null($this->mediaArray)) { |
114 |
126 |
115 $master = $this->get('<http://www.europeana.eu/schemas/edm/isShownBy>'); |
127 $master = $this->get('<http://www.europeana.eu/schemas/edm/isShownBy>'); |
116 $masterUrl = is_null($master)?null:$master->getUri(); |
128 $masterUrl = is_null($master)?null:$master->getUri(); |
117 |
129 |
118 foreach($this->graph->allOfType("<http://www.europeana.eu/schemas/edm/WebResources>") as $webResource) { |
130 foreach($this->graph->allOfType("<http://www.europeana.eu/schemas/edm/WebResources>") as $webResource) { |
119 $extent = $webResource->getLiteral("dc:extent"); |
131 $extent = $webResource->getLiteral("<http://purl.org/dc/terms/extent>"); |
120 $extent = is_null($extent)?null:$extent->getValue(); |
132 $extent = is_null($extent)?null:$extent->getValue(); |
121 $extent_ms = Utils::iso8601IntervalToMillis($extent); |
133 $extent_ms = Utils::iso8601IntervalToMillis($extent); |
122 $format = $webResource->getLiteral("dc11:format"); |
134 $format = $webResource->getLiteral("dc11:format"); |
123 |
135 |
124 $this->mediaArray[$webResource->getUri()] = [ |
136 $this->mediaArray[$webResource->getUri()] = [ |
146 public function getOtherTypes() { |
158 public function getOtherTypes() { |
147 $res = array_values(array_filter($this->getTypes(), function($v) { |
159 $res = array_values(array_filter($this->getTypes(), function($v) { |
148 return $v instanceof Resource || $v->getDatatypeUri() !== Config::get('corpusparole.olac_discourse_type')['uri']; |
160 return $v instanceof Resource || $v->getDatatypeUri() !== Config::get('corpusparole.olac_discourse_type')['uri']; |
149 })); |
161 })); |
150 return $res; |
162 return $res; |
|
163 } |
|
164 |
|
165 public function getContributors() { |
|
166 return array_reduce( |
|
167 CocoonUtils::OLAC_ROLES, |
|
168 function($res, $olacRole) { |
|
169 return array_merge( |
|
170 $res, |
|
171 array_map( |
|
172 function($olacValue) use ($olacRole) { |
|
173 return [ |
|
174 'name' => ($olacValue instanceof Literal)?$olacValue->getValue():null, |
|
175 'url' => ($olacValue instanceof Resource)?$olacValue->getUri():null, |
|
176 'role' => $olacRole |
|
177 ]; |
|
178 }, |
|
179 $this->getProvidedCHO()->all("<$olacRole>") |
|
180 ) |
|
181 ); |
|
182 }, |
|
183 [] |
|
184 ); |
151 } |
185 } |
152 |
186 |
153 /** |
187 /** |
154 * change discourse type list |
188 * change discourse type list |
155 */ |
189 */ |
193 ]; |
227 ]; |
194 } else { |
228 } else { |
195 $mediaArray = array_map( |
229 $mediaArray = array_map( |
196 function($m) { |
230 function($m) { |
197 $f = Utils::processLiteralOrString($m['format']); |
231 $f = Utils::processLiteralOrString($m['format']); |
198 return ['url' => $m['url'], 'format' => $f];}, |
232 $res = $m; |
|
233 $res['format'] = $f; |
|
234 return $res;}, |
199 $this->getMediaArray() |
235 $this->getMediaArray() |
200 ); |
236 ); |
201 |
237 |
202 $publishers = array_map( |
238 $publishers = array_map( |
203 function($v) { return Utils::processLiteralOrString($v); }, |
239 function($v) { return Utils::processLiteralOrString($v); }, |
205 ); |
241 ); |
206 |
242 |
207 return [ |
243 return [ |
208 'id' => $this->getId(), |
244 'id' => $this->getId(), |
209 'uri' => $this->getUri(), |
245 'uri' => $this->getUri(), |
210 'title' => $this->getTitle()->getValue(), |
246 'title' => $this->getTitleValue(), |
211 'modified' => $this->getModified(), |
247 'modified' => $this->getModifiedValue(), |
212 'publishers' => $publishers, |
248 'publishers' => $publishers, |
|
249 'contributors' => $this->getContributors(), |
213 'mediaArray'=> $mediaArray |
250 'mediaArray'=> $mediaArray |
214 ]; |
251 ]; |
215 } |
252 } |
216 } |
253 } |
217 |
254 |