Revision daef68e9
Added by Andreas Kohlbecker over 7 years ago
modules/cdm_dataportal/includes/media.inc | ||
---|---|---|
28 | 28 |
* the render array of the groups for the HTML description list |
29 | 29 |
*/ |
30 | 30 |
function cdm_rights_as_dl_groups($rights_list) { |
31 |
|
|
32 | 31 |
$copyrights = array(); |
32 |
|
|
33 | 33 |
$licenses = array(); |
34 | 34 |
$access_rights = array(); |
35 | 35 |
$unknown = array(); |
... | ... | |
42 | 42 |
switch ($type_uuid) { |
43 | 43 |
|
44 | 44 |
case UUID_RIGHTS_COPYRIGHT: |
45 |
if (isset($right->agent[0]) ){
|
|
46 |
$agent_names = array();
|
|
47 |
foreach ($right->agent as $agent) {
|
|
48 |
$agent_names[] = $agent->titleCache;
|
|
49 |
}
|
|
50 |
$copyrights[] = implode(', ', $agent_names);
|
|
45 |
$text = '';
|
|
46 |
if (isset($right->text) ){
|
|
47 |
// sanitize potential '(c)' away
|
|
48 |
$text = preg_replace('/^\(c\)/', '', $right->text);
|
|
49 |
} if (isset($right->agent) ){
|
|
50 |
$text .= (strlen($text) > 0 ? ', ' : '') . $right->agent;
|
|
51 | 51 |
} |
52 |
|
|
53 |
$copyrights[] = array('#markup' => '© ' . $text); |
|
52 | 54 |
break; |
53 | 55 |
|
54 | 56 |
case UUID_RIGHTS_LICENCE: |
... | ... | |
67 | 69 |
if (strlen($license_str) > 0 && isset($right->text)) { |
68 | 70 |
$license_str .= ': ' . $right->text; |
69 | 71 |
} |
70 |
$licenses[] = $license_str;
|
|
72 |
$licenses[] = array('#markup' => $license_str);
|
|
71 | 73 |
break; |
72 | 74 |
|
73 | 75 |
case UUID_RIGHTS_ACCESS_RIGHTS: |
74 |
$access_rights[] = $right->text . $right->uuid;
|
|
76 |
$access_rights[] = array('#markup' => $right->text);
|
|
75 | 77 |
break; |
76 | 78 |
|
77 | 79 |
default: |
78 |
$unknown_groups[] = $right->text . $right->uuid; // TODO !
|
|
80 |
$unknown_groups[] = array('#markup' => $right->text);
|
|
79 | 81 |
} |
80 | 82 |
} |
81 | 83 |
|
82 | 84 |
$groups = array(); |
83 | 85 |
if (count($copyrights) > 0) { |
84 |
_description_list_group_add($groups, t('Copyright'), $copyrights); |
|
86 |
_description_list_group_add($groups, t('Copyright') . ':', $copyrights);
|
|
85 | 87 |
} |
86 | 88 |
if (count($licenses) > 0) { |
87 |
_description_list_group_add($groups, t('Licenses'), $licenses); |
|
89 |
_description_list_group_add($groups, t('Licenses') . ':', $licenses);
|
|
88 | 90 |
} |
89 | 91 |
if (count($access_rights) > 0) { |
90 |
_description_list_group_add($groups, t('Access rights'), $access_rights); |
|
92 |
_description_list_group_add($groups, t('Access rights') . ':', $access_rights);
|
|
91 | 93 |
} |
92 | 94 |
if (count($unknown) > 0) { |
93 |
_description_list_group_add($groups, t('Rights (untyped)'), $unknown);
|
|
95 |
_description_list_group_add($groups, t('Rights') . ':', $unknown);
|
|
94 | 96 |
} |
95 | 97 |
|
96 | 98 |
return $groups; |
... | ... | |
178 | 180 |
$metadata_caption['artist'] = $media->artist->titleCache; |
179 | 181 |
} |
180 | 182 |
|
181 |
// Copyright. |
|
182 |
$metadata_caption['rights'] = array( |
|
183 |
'copyright' => array('agentNames' => array()), |
|
184 |
'license' => array( |
|
185 |
'agentNames' => array(), |
|
186 |
'types' => array(), |
|
187 |
'abbreviatedTexts' => array(), |
|
188 |
'uris' => array(), |
|
189 |
), |
|
190 |
); |
|
183 |
// Rights |
|
184 |
$metadata_caption['rights'] = array(); |
|
191 | 185 |
if (!empty($media_metadata->Copyright)) { |
192 |
$metadata_caption['rights']['copyright']['agentNames'][] = $media_metadata->Copyright; |
|
193 |
} |
|
194 |
elseif (isset($media->rights) && is_array($media->rights)) { |
|
195 |
foreach ($media->rights as $right) { |
|
196 |
if(isset($right->term)){ |
|
197 |
switch ($right->type->uuid) { |
|
198 |
case UUID_RIGHTS_LICENCE: |
|
199 |
$metadata_caption['rights']['license']['agentNames'][] = ($right->agent ? '' . $right->agent->firstname . ' ' . $right->agent->lastname : ''); |
|
200 |
$metadata_caption['rights']['license']['types'][] = ($right->representation_L10n ? '' . $right->representation_L10n : ''); |
|
201 |
$metadata_caption['rights']['license']['abbreviatedTexts'][] = ($right->abbreviatedText ? '' . $right->abbreviatedText : ''); |
|
202 |
$metadata_caption['rights']['license']['uris'][] = ($right->uri ? '' . $right->uri : ''); |
|
203 |
break; |
|
204 |
case UUID_RIGHTS_COPYRIGHT: |
|
205 |
$metadata_caption['rights']['copyright']['agentNames'][] = $right->agent->firstname . ' ' . $right->agent->lastname; |
|
206 |
break; |
|
207 |
} |
|
208 |
} |
|
209 |
} |
|
210 |
} |
|
211 |
else { |
|
212 |
$metadata_caption['rights']['agentNames'][] = ''; |
|
186 |
$rightsObj = new stdClass(); |
|
187 |
$rightsObj->type = new stdClass(); |
|
188 |
$rightsObj->type->uuid = UUID_RIGHTS_COPYRIGHT; |
|
189 |
$rightsObj->type->titleCache = 'copyright'; |
|
190 |
$rightsObj->type->representation_L10n = 'copyright'; |
|
191 |
$rightsObj->type->text = $media_metadata->Copyright; |
|
192 |
$metadata_caption['rights'][] = $rightsObj; |
|
193 |
} |
|
194 |
if(isset($media->rights) && is_array($media->rights)) { |
|
195 |
$metadata_caption['rights'] = array_merge($metadata_caption['rights'], $media->rights); |
|
213 | 196 |
} |
214 | 197 |
|
215 | 198 |
// Filling the description (though there is no description in the db???). |
modules/cdm_dataportal/includes/occurrences.inc | ||
---|---|---|
707 | 707 |
NULL, |
708 | 708 |
7 |
709 | 709 |
); |
710 |
break; |
|
710 | 711 |
|
711 | 712 |
case 'rights': |
712 | 713 |
array_merge($groups, cdm_rights_as_dl_groups($value)); |
713 |
break; |
|
714 |
break;
|
|
714 | 715 |
|
715 | 716 |
case 'annotations': |
716 | 717 |
$dd_elements = array(); |
modules/cdm_dataportal/theme/cdm_dataportal.media.theme | ||
---|---|---|
198 | 198 |
* |
199 | 199 |
* @return string |
200 | 200 |
* the themed html output |
201 |
* |
|
202 |
* TODO turn into compose method |
|
201 | 203 |
*/ |
202 | 204 |
function theme_cdm_media_caption($variables) { |
203 | 205 |
$media = $variables['media']; |
... | ... | |
216 | 218 |
// Title. |
217 | 219 |
if ($doTitle) { |
218 | 220 |
if ($media_metadata['title']) { |
219 |
$out .= '<dt class = "title">' . t('Title') . '</dt> <dd class = "title">' . $media_metadata['title'] . '</dd>'; |
|
221 |
$out .= '<dt class = "title">' . t('Title') . ':'. '</dt> <dd class = "title">' . $media_metadata['title'] . '</dd>';
|
|
220 | 222 |
$descriptionPrefix = "- "; |
221 | 223 |
} |
222 | 224 |
elseif (!($doDescription && $media_metadata['description'])) { |
... | ... | |
227 | 229 |
} |
228 | 230 |
// Description. |
229 | 231 |
if ($media_metadata['description'] && $doDescription) { |
230 |
$out .= '<dt class = "description">' . t('Description') . '</dt> <dd class = "description">' . $descriptionPrefix . $media_metadata['description'] . '</dd>'; |
|
232 |
$out .= '<dt class = "description">' . t('Description') . ':'. '</dt> <dd class = "description">' . $descriptionPrefix . $media_metadata['description'] . '</dd>';
|
|
231 | 233 |
} |
232 | 234 |
// Artist. |
233 | 235 |
if ($media_metadata['artist'] && $doArtist) { |
234 |
$out .= '<dt class = "artist">' . t('Artist') . '</dt> <dd class = "astist">' . $media_metadata['artist'] . '</dd>';
|
|
236 |
$out .= '<dt class = "artist">' . t('Artist') . ':' . '</dt> <dd class = "artist">' . $media_metadata['artist'] . '</dd>';
|
|
235 | 237 |
} |
236 | 238 |
// Location. |
237 | 239 |
if ($doLocation) { |
... | ... | |
252 | 254 |
$location .= $media_metadata['location']['country']; |
253 | 255 |
} |
254 | 256 |
if ($location) { |
255 |
$out .= '<dt class = "location">' . t('Location') . '</dt> <dd class = "location">' . $location . '</dd>'; |
|
257 |
$out .= '<dt class = "location">' . t('Location') . ':' . '</dt> <dd class = "location">' . $location . '</dd>';
|
|
256 | 258 |
} |
257 | 259 |
} |
258 | 260 |
// Rights. |
259 | 261 |
if ($doRights) { |
260 |
$rights = ''; |
|
261 |
// TODO use cdm_rights_as_dl_groups() to create dl entries |
|
262 |
|
|
263 |
// Copyrights. |
|
264 |
$cnt = count($media_metadata['rights']['copyright']['agentNames']); |
|
265 |
if ($cnt > 0) { |
|
266 |
$rights .= '<dt class="rights">©</dt> <dd class="rights"> '; |
|
267 |
for ($i = 0; $i < $cnt; $i++) { |
|
268 |
$rights .= $media_metadata['rights']['copyright']['agentNames'][$i]; |
|
269 |
if ($i + 1 < $cnt) { |
|
270 |
$rights .= ' / '; |
|
271 |
} |
|
272 |
} |
|
273 |
$rights .= '</dd>'; |
|
274 |
} |
|
275 |
// License. |
|
276 |
$cnt = count($media_metadata['rights']['license']['agentNames']); |
|
277 |
if ($cnt > 0) { |
|
278 |
$rights .= '<dt class ="license">' . t('License') . '</dt> <dd class = "license">'; |
|
279 |
for ($i = 0; $i < $cnt; $i++) { |
|
280 |
$rights .= $media_metadata['rights']['license']['agentNames'][$i]; |
|
281 |
if ($i + 1 < $cnt) { |
|
282 |
$rights .= ' / '; |
|
283 |
} |
|
284 |
} |
|
285 |
$rights .= '</dd>'; |
|
286 |
} |
|
287 |
if ($rights) { |
|
288 |
$out .= $rights . '</dt>'; |
|
289 |
} |
|
262 |
$rights_render_item = array( |
|
263 |
'#theme' => 'description_list', |
|
264 |
'#groups' => cdm_rights_as_dl_groups($media_metadata['rights']) |
|
265 |
); |
|
266 |
$out .= drupal_render($rights_render_item); |
|
290 | 267 |
} |
291 | 268 |
// TODO add all other metadata elements generically. |
292 | 269 |
$out .= '</dl>'; |
Also available in: Unified diff
fix #6260 fixing display of rights on image page