1 |
eeb98da8
|
Andreas Kohlbecker
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Functions for dealing with CDM entities of type SpeciemenOrOccurrences
|
5 |
|
|
*
|
6 |
|
|
* @copyright
|
7 |
|
|
* (C) 2007-2012 EDIT
|
8 |
|
|
* European Distributed Institute of Taxonomy
|
9 |
|
|
* http://www.e-taxonomy.eu
|
10 |
|
|
*
|
11 |
|
|
* The contents of this module are subject to the Mozilla
|
12 |
|
|
* Public License Version 1.1.
|
13 |
|
|
* @see http://www.mozilla.org/MPL/MPL-1.1.html
|
14 |
|
|
*
|
15 |
|
|
* @author
|
16 |
|
|
* - Andreas Kohlbecker <a.kohlbecker@BGBM.org>
|
17 |
|
|
*/
|
18 |
|
|
|
19 |
|
|
/**
|
20 |
|
|
* Returns an array of render array entries for a HTML description list.
|
21 |
|
|
*
|
22 |
|
|
* @see theme_description_list()
|
23 |
|
|
*
|
24 |
|
|
* @param array $rights_list
|
25 |
|
|
* array of CDM Rights entities
|
26 |
|
|
*/
|
27 |
|
|
function cdm_rights_as_dl_groups($rights_list) {
|
28 |
|
|
|
29 |
|
|
$copyrights = array();
|
30 |
|
|
$licenses = array();
|
31 |
|
|
$access_rights = array();
|
32 |
|
|
$unknown = array();
|
33 |
|
|
|
34 |
|
|
foreach ($rights_list as $right) {
|
35 |
|
|
if (!is_object($right)){
|
36 |
|
|
continue;
|
37 |
|
|
}
|
38 |
|
|
$type_uuid = isset($right->type->uuid) ? $right->type->uuid : 'UNKNOWN';
|
39 |
|
|
switch ($type_uuid) {
|
40 |
|
|
|
41 |
|
|
case UUID_RIGHTS_COPYRIGHT:
|
42 |
|
|
if (isset($right->agent[0]) ){
|
43 |
|
|
$agent_names = array();
|
44 |
|
|
foreach ($right->agent as $agent) {
|
45 |
|
|
$agent_names[] = $agent->titleCache;
|
46 |
|
|
}
|
47 |
|
|
$copyrights[] = implode(', ', $agent_names);
|
48 |
|
|
}
|
49 |
|
|
break;
|
50 |
|
|
|
51 |
|
|
case UUID_RIGHTS_LICENCE:
|
52 |
|
|
$license_str = '';
|
53 |
|
|
if (isset($right->abbreviatedText)) {
|
54 |
|
|
$license_str .= $right->abbreviatedText;
|
55 |
|
|
}
|
56 |
|
|
if (isset($right->uri)) {
|
57 |
|
|
if (strlen($license_str) > 0) {
|
58 |
|
|
$license_str = l($license_str, $right->uri);
|
59 |
|
|
} else {
|
60 |
|
|
$license_str = l('link', $right->uri);
|
61 |
|
|
}
|
62 |
|
|
}
|
63 |
|
|
if (strlen($license_str) > 0 && isset($right->text)) {
|
64 |
|
|
$license_str .= ': ' . $right->text;
|
65 |
|
|
}
|
66 |
|
|
$licenses[] = $license_str;
|
67 |
|
|
break;
|
68 |
|
|
|
69 |
|
|
case UUID_RIGHTS_ACCESS_RIGHTS:
|
70 |
|
|
$access_rights[] = $right->text . $right->uuid;
|
71 |
|
|
break;
|
72 |
|
|
|
73 |
|
|
default:
|
74 |
|
|
$unknown_groups[] = $right->text . $right->uuid; //TODO
|
75 |
|
|
}
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
$groups = array();
|
79 |
|
|
if(count($copyrights) > 0) {
|
80 |
|
|
_description_list_group_add($groups, t('Copyright'), $copyrights);
|
81 |
|
|
}
|
82 |
|
|
if(count($licenses) > 0) {
|
83 |
|
|
_description_list_group_add($groups, t('Licenses'), $licenses);
|
84 |
|
|
}
|
85 |
|
|
if(count($access_rights) > 0) {
|
86 |
|
|
_description_list_group_add($groups, t('Access rights'), $access_rights);
|
87 |
|
|
}
|
88 |
|
|
if(count($unknown) > 0) {
|
89 |
|
|
_description_list_group_add($groups, t('Rights (untyped)'), $unknown);
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
return $groups;
|
93 |
|
|
|
94 |
|
|
}
|