Revision 0e617798
Added by Andreas Kohlbecker over 2 years ago
modules/cdm_dataportal/cdm_api/cdm_api.module | ||
---|---|---|
891 | 891 |
* |
892 | 892 |
* NOTE: Not all CDM Base types are yet supported. |
893 | 893 |
* |
894 |
* @param $cdmBase
|
|
894 |
* @param $cdm_entity
|
|
895 | 895 |
* The CDM entity to construct the annotations pager uri for |
896 | 896 |
*/ |
897 |
function cdm_compose_annotations_uri($cdmBase) { |
|
897 |
function cdm_compose_annotations_uri($cdm_entity) { |
|
898 |
|
|
899 |
$cdm_entity_type = $cdm_entity->class; |
|
900 |
|
|
901 |
if($cdm_entity_type == 'DerivedUnitFacade'){ |
|
902 |
// TODO we may want to implement a derivedUnitFacade/{uuid}/annotations service and use that instead |
|
903 |
$cdm_entity_type = $cdm_entity->fieldUnitEntityReference->type; |
|
904 |
$cdm_entity_uuid = $cdm_entity->fieldUnitEntityReference->uuid; |
|
905 |
} else { |
|
906 |
if (isset($cdm_entity->uuid)) { |
|
907 |
$cdm_entity_uuid = $cdm_entity->uuid; |
|
908 |
} |
|
909 |
} |
|
898 | 910 |
|
899 |
if (!$cdmBase->uuid) { |
|
911 |
if(!$cdm_entity_uuid){ |
|
912 |
// silently give up |
|
900 | 913 |
return; |
901 | 914 |
} |
902 | 915 |
|
903 |
$ws_base_uri = cdm_ws_base_uri($cdmBase->class);
|
|
916 |
$ws_base_uri = cdm_ws_base_uri($cdm_entity_type);
|
|
904 | 917 |
|
905 | 918 |
if($ws_base_uri === null){ |
906 |
trigger_error(check_plain('Unsupported CDM Class - no annotations available for ' . $cdmBase->class), E_USER_ERROR);
|
|
919 |
trigger_error(check_plain('Unsupported CDM Class - no annotations available for ' . $cdm_entity_type), E_USER_ERROR);
|
|
907 | 920 |
} |
908 | 921 |
return cdm_compose_url($ws_base_uri, array( |
909 |
$cdmBase->uuid,
|
|
922 |
$cdm_entity_uuid,
|
|
910 | 923 |
'annotations', |
911 | 924 |
)); |
912 | 925 |
} |
... | ... | |
1777 | 1790 |
* @return array |
1778 | 1791 |
* An array of Annotation objects or an empty array. |
1779 | 1792 |
*/ |
1780 |
function cdm_ws_getAnnotationsFor(&$cdm_entity, $include_types = FALSE) {
|
|
1793 |
function cdm_ws_fetch_annotations(&$cdm_entity, $include_types = FALSE) {
|
|
1781 | 1794 |
|
1782 | 1795 |
if(!isset($cdm_entity->annotations)){ |
1783 | 1796 |
$annotation_url = cdm_compose_annotations_uri($cdm_entity); |
... | ... | |
1816 | 1829 |
if(!$annotations_types_filter) { |
1817 | 1830 |
$annotations_types_filter = unserialize(EXTENSION_TYPES_VISIBLE_DEFAULT); |
1818 | 1831 |
} |
1819 |
return cdm_ws_getAnnotationsFor($cdm_entity, variable_get(ANNOTATION_TYPES_VISIBLE, $annotations_types_filter));
|
|
1832 |
return cdm_ws_fetch_annotations($cdm_entity, variable_get(ANNOTATION_TYPES_VISIBLE, $annotations_types_filter));
|
|
1820 | 1833 |
} |
1821 | 1834 |
|
1822 | 1835 |
/** |
... | ... | |
1830 | 1843 |
*/ |
1831 | 1844 |
function cdm_load_annotations(&$annotatable_entity) { |
1832 | 1845 |
if (isset($annotatable_entity) && !isset($annotatable_entity->annotations)) { |
1833 |
$annotations = cdm_ws_getAnnotationsFor($annotatable_entity);
|
|
1846 |
$annotations = cdm_ws_fetch_annotations($annotatable_entity);
|
|
1834 | 1847 |
if (is_array($annotations)) { |
1835 | 1848 |
$annotatable_entity->annotations = $annotations; |
1836 | 1849 |
} |
... | ... | |
2699 | 2712 |
return $query; |
2700 | 2713 |
} |
2701 | 2714 |
|
2702 |
/** |
|
2703 |
* Implementation of the magic method __clone to allow deep cloning of objects |
|
2704 |
* and arrays. |
|
2705 |
*/ |
|
2706 |
function __clone() { |
|
2707 |
foreach ($this as $name => $value) { |
|
2708 |
if (gettype($value) == 'object' || gettype($value) == 'array') { |
|
2709 |
$this->$name = clone($this->$name); |
|
2710 |
} |
|
2711 |
} |
|
2712 |
} |
|
2713 |
|
|
2714 | 2715 |
/** |
2715 | 2716 |
* Compares the given CDM Term instances by the representationL10n. |
2716 | 2717 |
* |
Also available in: Unified diff
ref #8850 showing fieldunit annotations in registration page