Revision f79d32d6
Added by Andreas Kohlbecker almost 7 years ago
modules/cdm_dataportal/theme/cdm_dataportal.media.theme | ||
---|---|---|
62 | 62 |
* |
63 | 63 |
* @return string |
64 | 64 |
* The markup |
65 |
* |
|
66 |
* FIXME: move to descriptions.inc |
|
65 | 67 |
*/ |
66 | 68 |
function cdm_description_element_media($descriptionElement, $mimeTypePreference) { |
67 | 69 |
|
... | ... | |
205 | 207 |
|
206 | 208 |
$media = $variables['media']; |
207 | 209 |
$elements = $variables['elements']; |
210 |
$sources_as_content = $variables['sources_as_content']; |
|
208 | 211 |
$media_metadata = read_media_metadata($media); |
209 | 212 |
|
210 | 213 |
$doTitle = !$elements || array_search('title', $elements) !== FALSE; |
... | ... | |
217 | 220 |
$footnote_list_key = 'media-' . $media->uuid; |
218 | 221 |
|
219 | 222 |
// handle sources and annotations |
220 |
cdm_lazyload_array_field('media', 'sources', $media); |
|
221 | 223 |
cdm_lazyload_array_field('media', 'annotations', $media); |
222 | 224 |
$annotations_and_sources = handle_annotations_and_sources( |
223 | 225 |
$media, |
224 | 226 |
array( |
225 |
'sources_as_content' => $doTitle ? 0 : 1,
|
|
227 |
'sources_as_content' => $sources_as_content,
|
|
226 | 228 |
'link_to_name_used_in_source' => 1, |
227 | 229 |
'link_to_reference' => 0, |
228 |
'add_footnote_keys' => 1 |
|
230 |
'add_footnote_keys' => $sources_as_content ? 0 : 1
|
|
229 | 231 |
), |
230 |
$doTitle ? $media_metadata['title'] : NULL,
|
|
231 |
$footnote_list_key |
|
232 |
NULL, |
|
233 |
$footnote_list_key
|
|
232 | 234 |
); |
233 | 235 |
|
234 | 236 |
$out = ''; |
235 | 237 |
|
236 | 238 |
// Title. |
237 | 239 |
if ($doTitle) { |
238 |
$title_string = $media_metadata['title'] . ' ' . join(', ', $annotations_and_sources['source_references']) . $annotations_and_sources['foot_note_keys']; |
|
240 |
$title_string = $media_metadata['title'] |
|
241 |
. $annotations_and_sources['foot_note_keys']; // placing the footnote keys here is not optimal, see #6329 A.1. |
|
239 | 242 |
$title_string = trim($title_string); |
240 | 243 |
if (empty($title_string) && !($doDescription && $media_metadata['description'])) { |
241 | 244 |
// Use filename as fallback option if no description and no source citations are available. |
... | ... | |
245 | 248 |
$descriptionPrefix = "- "; |
246 | 249 |
} |
247 | 250 |
|
251 |
$groups = array(); |
|
248 | 252 |
|
249 |
$out .= '<dl class="media-caption">'; // FIXME rename to media-details
|
|
253 |
$out .= '<dl class="media-caption">'; |
|
250 | 254 |
// Description. |
251 | 255 |
if ($media_metadata['description'] && $doDescription) { |
252 |
$out .= '<dt class = "description">' . t('Description') . ':'. '</dt> <dd class = "description">' . $descriptionPrefix . $media_metadata['description'] . '</dd>';
|
|
256 |
_description_list_group_add($groups, t('Description') . ':', $descriptionPrefix . $media_metadata['description'] );
|
|
253 | 257 |
} |
254 | 258 |
// Artist. |
255 | 259 |
if ($media_metadata['artist'] && $doArtist) { |
256 |
$out .= '<dt class = "artist">' . t('Artist') . ':' . '</dt> <dd class = "artist">' . $media_metadata['artist'] . '</dd>';
|
|
260 |
_description_list_group_add($groups, t('Artist') . ':', $media_metadata['artist'] );
|
|
257 | 261 |
} |
258 | 262 |
// Location. |
259 | 263 |
if ($doLocation) { |
... | ... | |
274 | 278 |
$location .= $media_metadata['location']['country']; |
275 | 279 |
} |
276 | 280 |
if ($location) { |
277 |
$out .= '<dt class = "location">' . t('Location') . ':' . '</dt> <dd class = "location">' . $location . '</dd>';
|
|
281 |
_description_list_group_add($groups, t('Location') . ':', $location );
|
|
278 | 282 |
} |
279 | 283 |
} |
280 | 284 |
// Rights. |
281 | 285 |
if ($doRights) { |
282 |
$rights_render_item = array(
|
|
283 |
'#theme' => 'description_list',
|
|
284 |
'#groups' => cdm_rights_as_dl_groups($media_metadata['rights']) |
|
285 |
);
|
|
286 |
$out .= drupal_render($rights_render_item);
|
|
286 |
$groups = array_merge($groups, cdm_rights_as_dl_groups($media_metadata['rights']));
|
|
287 |
}
|
|
288 |
|
|
289 |
if(!empty($annotations_and_sources['source_references'])){
|
|
290 |
_description_list_group_add($groups, t('Sources') . ':', join(', ', $annotations_and_sources['source_references']) );
|
|
287 | 291 |
} |
292 |
|
|
288 | 293 |
// TODO add all other metadata elements generically. |
289 |
$out .= '</dl>'; |
|
294 |
|
|
295 |
$description_list_item = array( |
|
296 |
'#theme' => 'description_list', |
|
297 |
'#groups' => $groups, |
|
298 |
'#attributes' => array('class' => 'media-caption') |
|
299 |
); |
|
300 |
$out .= drupal_render($description_list_item); |
|
290 | 301 |
|
291 | 302 |
$out .= theme('cdm_footnotes', array('footnoteListKey' => $footnote_list_key)); |
292 | 303 |
|
Also available in: Unified diff
ref #6301 sources as inline elements on media page