Project

General

Profile

« Previous | Next » 

Revision 0c2b9b9d

Added by Andreas Kohlbecker over 7 years ago

fix #6301 implementing display of sources and annotations for media

View differences:

modules/cdm_dataportal/theme/cdm_dataportal.media.theme
202 202
 * TODO turn into compose method
203 203
 */
204 204
function theme_cdm_media_caption($variables) {
205

  
205 206
  $media = $variables['media'];
206 207
  $elements = $variables['elements'];
207 208
  $media_metadata = read_media_metadata($media);
......
213 214
  $doRights = !$elements || array_search('rights', $elements) !== FALSE;
214 215

  
215 216
  $descriptionPrefix = "";
217
  $footnote_list_key = 'media-' . $media->uuid;
218

  
219
  // handle sources and annotations
220
  cdm_lazyload_array_field('media', 'sources', $media);
221
  cdm_lazyload_array_field('media', 'annotations', $media);
222
  $annotations_and_sources = handle_annotations_and_sources(
223
    $media,
224
    array(
225
      'sources_as_content' => $doTitle ? 0 : 1,
226
      'link_to_name_used_in_source' => 1,
227
      'link_to_reference' => 0,
228
      'add_footnote_keys' => 1
229
    ),
230
     $doTitle ? $media_metadata['title'] : NULL,
231
    $footnote_list_key
232
  );
233

  
234
  $out = '';
216 235

  
217
  $out = '<dl class="media-caption">';
218 236
  // Title.
219 237
  if ($doTitle) {
220
    if ($media_metadata['title']) {
221
      $out .= '<dt class = "title">' . t('Title')  . ':'. '</dt> <dd class = "title">' . $media_metadata['title'] . '</dd>';
222
      $descriptionPrefix = "- ";
223
    }
224
    elseif (!($doDescription && $media_metadata['description'])) {
225
      // Use filename as fallback option if no description will be shown.
226
      $out .= '<dt class = "title">' . t('Title') . '</dt> <dd class = "title">' . $media_metadata['filename'] . '</dd>';
227
      $descriptionPrefix = "- ";
238
    $title_string = $media_metadata['title'] . ' ' . join(', ', $annotations_and_sources['source_references']) . $annotations_and_sources['foot_note_keys'];
239
    $title_string = trim($title_string);
240
    if (empty($title_string) && !($doDescription && $media_metadata['description'])) {
241
      // Use filename as fallback option if no description and no source citations are available.
242
      $title_string = $media_metadata['filename'];
228 243
    }
244
    $out .= '<div class="title">' . $title_string . '</div>';
245
    $descriptionPrefix = "- ";
229 246
  }
247

  
248

  
249
  $out .= '<dl class="media-caption">'; // FIXME rename to media-details
230 250
  // Description.
231 251
  if ($media_metadata['description'] && $doDescription) {
232 252
    $out .= '<dt class = "description">' . t('Description')  . ':'. '</dt> <dd class = "description">' . $descriptionPrefix . $media_metadata['description'] . '</dd>';
......
267 287
  }
268 288
  // TODO add all other metadata elements generically.
269 289
  $out .= '</dl>';
270
  // Return value,
290

  
291
  $out .= theme('cdm_footnotes', array('footnoteListKey' => $footnote_list_key));
292

  
271 293
  return $out;
272 294
}
273 295

  

Also available in: Unified diff