Project

General

Profile

« Previous | Next » 

Revision daef68e9

Added by Andreas Kohlbecker over 7 years ago

fix #6260 fixing display of rights on image page

View differences:

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???).

Also available in: Unified diff