Revision 4a15731a
Added by Andreas Kohlbecker almost 11 years ago
7.x/modules/cdm_dataportal/cdm_api/cdm_api.module | ||
---|---|---|
1194 | 1194 |
} |
1195 | 1195 |
|
1196 | 1196 |
/** |
1197 |
* Get a list of annotations for a cdm entity. |
|
1197 |
* Returns a filtered a list of annotations for the cdm entity given as parameter $cdmBase. |
|
1198 |
* If the annotations are not yet already loded with the cdm entity the cdm REST service will |
|
1199 |
* be requested for the annotations. |
|
1198 | 1200 |
* |
1199 | 1201 |
* @param string $cdmBase |
1200 | 1202 |
* An annotatable cdm entity. |
... | ... | |
1205 | 1207 |
* @return array |
1206 | 1208 |
* An array of Annotation objects or an empty array. |
1207 | 1209 |
*/ |
1208 |
function cdm_ws_getAnnotationsFor($cdmBase, $includeTypes = FALSE) { |
|
1209 |
$annotationUrl = cdm_compose_annotations_url($cdmBase); |
|
1210 |
if ($annotationUrl) { |
|
1211 |
$annotationPager = cdm_ws_get($annotationUrl, NULL, NULL, NULL, TRUE); |
|
1212 |
if (isset($annotationPager->records) && is_array($annotationPager->records)) { |
|
1213 |
$annotations = array(); |
|
1214 |
foreach ($annotationPager->records as $annotation) { |
|
1215 |
if ($includeTypes) { |
|
1216 |
if ((isset($annotation->annotationType->uuid) && in_array($annotation->annotationType->uuid, $includeTypes, TRUE)) || ($annotation->annotationType === NULL && in_array('NULL_VALUE', $includeTypes, TRUE))) { |
|
1217 |
$annotations[] = $annotation; |
|
1218 |
} |
|
1219 |
} |
|
1220 |
else { |
|
1221 |
$annotations[] = $annotation; |
|
1222 |
} |
|
1210 |
function cdm_ws_getAnnotationsFor(&$cdmBase, $includeTypes = FALSE) { |
|
1211 |
|
|
1212 |
$annotations = array(); |
|
1213 |
|
|
1214 |
if(!isset($cdmBase->annotations)){ |
|
1215 |
$annotationUrl = cdm_compose_annotations_url($cdmBase); |
|
1216 |
if ($annotationUrl) { |
|
1217 |
$annotationPager = cdm_ws_get($annotationUrl, NULL, NULL, NULL, TRUE); |
|
1218 |
if (isset($annotationPager->records) && is_array($annotationPager->records)) { |
|
1219 |
$cdmBase->annotations = $annotationPager->records; |
|
1220 |
} else { |
|
1221 |
$cdmBase->annotations = array(); |
|
1223 | 1222 |
} |
1224 |
return $annotations; |
|
1225 | 1223 |
} |
1226 | 1224 |
} |
1225 |
|
|
1226 |
foreach ($cdmBase->annotations as $annotation) { |
|
1227 |
if ($includeTypes) { |
|
1228 |
if ((isset($annotation->annotationType->uuid) && in_array($annotation->annotationType->uuid, $includeTypes, TRUE)) || ($annotation->annotationType === NULL && in_array('NULL_VALUE', $includeTypes, TRUE))) { |
|
1229 |
$annotations[] = $annotation; |
|
1230 |
} |
|
1231 |
} |
|
1232 |
else { |
|
1233 |
$annotations[] = $annotation; |
|
1234 |
} |
|
1235 |
} |
|
1236 |
return $annotations; |
|
1237 |
|
|
1227 | 1238 |
} |
1228 | 1239 |
|
1229 | 1240 |
/** |
Also available in: Unified diff
loading from REST service annoations only when really needed, this should speed up the portals