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 |
ca7fa7da
|
Andreas Kohlbecker
|
* array of CDM Rights entities
|
26 |
|
|
*
|
27 |
|
|
* @return array
|
28 |
|
|
* the render array of the groups for the HTML description list
|
29 |
eeb98da8
|
Andreas Kohlbecker
|
*/
|
30 |
|
|
function cdm_rights_as_dl_groups($rights_list) {
|
31 |
|
|
|
32 |
|
|
$copyrights = array();
|
33 |
|
|
$licenses = array();
|
34 |
|
|
$access_rights = array();
|
35 |
|
|
$unknown = array();
|
36 |
|
|
|
37 |
|
|
foreach ($rights_list as $right) {
|
38 |
ca7fa7da
|
Andreas Kohlbecker
|
if (!is_object($right)) {
|
39 |
eeb98da8
|
Andreas Kohlbecker
|
continue;
|
40 |
|
|
}
|
41 |
|
|
$type_uuid = isset($right->type->uuid) ? $right->type->uuid : 'UNKNOWN';
|
42 |
|
|
switch ($type_uuid) {
|
43 |
|
|
|
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);
|
51 |
|
|
}
|
52 |
|
|
break;
|
53 |
|
|
|
54 |
|
|
case UUID_RIGHTS_LICENCE:
|
55 |
|
|
$license_str = '';
|
56 |
|
|
if (isset($right->abbreviatedText)) {
|
57 |
|
|
$license_str .= $right->abbreviatedText;
|
58 |
|
|
}
|
59 |
|
|
if (isset($right->uri)) {
|
60 |
|
|
if (strlen($license_str) > 0) {
|
61 |
|
|
$license_str = l($license_str, $right->uri);
|
62 |
ca7fa7da
|
Andreas Kohlbecker
|
}
|
63 |
|
|
else {
|
64 |
|
|
$license_str = l(t('link'), $right->uri);
|
65 |
eeb98da8
|
Andreas Kohlbecker
|
}
|
66 |
|
|
}
|
67 |
|
|
if (strlen($license_str) > 0 && isset($right->text)) {
|
68 |
|
|
$license_str .= ': ' . $right->text;
|
69 |
|
|
}
|
70 |
|
|
$licenses[] = $license_str;
|
71 |
|
|
break;
|
72 |
|
|
|
73 |
|
|
case UUID_RIGHTS_ACCESS_RIGHTS:
|
74 |
|
|
$access_rights[] = $right->text . $right->uuid;
|
75 |
|
|
break;
|
76 |
|
|
|
77 |
|
|
default:
|
78 |
ca7fa7da
|
Andreas Kohlbecker
|
$unknown_groups[] = $right->text . $right->uuid; // TODO !
|
79 |
eeb98da8
|
Andreas Kohlbecker
|
}
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
$groups = array();
|
83 |
ca7fa7da
|
Andreas Kohlbecker
|
if (count($copyrights) > 0) {
|
84 |
eeb98da8
|
Andreas Kohlbecker
|
_description_list_group_add($groups, t('Copyright'), $copyrights);
|
85 |
|
|
}
|
86 |
ca7fa7da
|
Andreas Kohlbecker
|
if (count($licenses) > 0) {
|
87 |
eeb98da8
|
Andreas Kohlbecker
|
_description_list_group_add($groups, t('Licenses'), $licenses);
|
88 |
|
|
}
|
89 |
ca7fa7da
|
Andreas Kohlbecker
|
if (count($access_rights) > 0) {
|
90 |
eeb98da8
|
Andreas Kohlbecker
|
_description_list_group_add($groups, t('Access rights'), $access_rights);
|
91 |
|
|
}
|
92 |
ca7fa7da
|
Andreas Kohlbecker
|
if (count($unknown) > 0) {
|
93 |
eeb98da8
|
Andreas Kohlbecker
|
_description_list_group_add($groups, t('Rights (untyped)'), $unknown);
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
return $groups;
|
97 |
|
|
|
98 |
ca7fa7da
|
Andreas Kohlbecker
|
}
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
/**
|
102 |
|
|
* Provides the markup for an icon to represent a media which is associated with the given $feature.
|
103 |
|
|
*
|
104 |
|
|
* @param $feature
|
105 |
|
|
* the cdm Feature term
|
106 |
|
|
* @param $media_url
|
107 |
|
|
* Optional, currently unused. May be used in future to display different
|
108 |
|
|
* icons for different media urls, like the fav-icon of the referenced
|
109 |
|
|
* @return string
|
110 |
|
|
* The markup for the icon
|
111 |
|
|
*/
|
112 |
|
|
function media_feature_icon($feature, $media_url = NULL) {
|
113 |
|
|
return font_awesome_icon_markup('fa-book', array('alt' => $feature->representation_L10n));
|
114 |
eeb98da8
|
Andreas Kohlbecker
|
}
|