Revision 4a462641
Added by Andreas Kohlbecker about 4 years ago
modules/cdm_dataportal/cdm_api/cdm_api.module | ||
---|---|---|
310 | 310 |
} |
311 | 311 |
|
312 | 312 |
/** |
313 |
* NOTE: The cdm-library provides a very similar server side function. See |
|
314 |
* eu.etaxonomy.cdm.model.media.MediaUtils.filterAndOrderMediaRepresentations() |
|
313 | 315 |
* |
314 | 316 |
* @param object $media |
315 | 317 |
* @param array $mimeTypes |
modules/cdm_dataportal/cdm_api/webservice_uris.php | ||
---|---|---|
68 | 68 |
define('CDM_WS_TAXON_SEARCH', 'taxon/search'); |
69 | 69 |
define('CDM_WS_PORTAL_TAXON_FINDBY_DESCRIPTIONELEMENT_FULLTEXT', 'portal/taxon/findByDescriptionElementFullText'); |
70 | 70 |
|
71 |
define('CDM_WS_IIIF_TAXON_MANIFEST', 'iiif/taxon/$0/manifest'); |
|
71 | 72 |
|
72 | 73 |
|
73 | 74 |
define('CDM_WS_TAXONNODE', 'taxonNode/$0'); |
modules/cdm_dataportal/cdm_dataportal.module | ||
---|---|---|
355 | 355 |
); |
356 | 356 |
} |
357 | 357 |
|
358 |
function _add_js_universalviewer($jquery_selector){ |
|
358 |
function _add_js_universalviewer($jquery_selector, $manifest_uri){
|
|
359 | 359 |
|
360 | 360 |
$universalviewer_path = drupal_get_path('module', 'cdm_dataportal') . '/js/universalviewer'; |
361 | 361 |
|
... | ... | |
379 | 379 |
'preprocess' => FALSE |
380 | 380 |
) |
381 | 381 |
); |
382 |
|
|
383 | 382 |
drupal_add_js(' |
384 | 383 |
console.log(\'jQuery inline: \' + jQuery.fn.jquery); |
385 | 384 |
jQuery(window).on(\'uvLoaded\', function() { |
386 | 385 |
jQuery( "' . $jquery_selector . '" ).jqUniversalviewer( |
387 | 386 |
{ |
388 | 387 |
universalviewer_path: \'' . $universalviewer_path . '\', |
389 |
manifestUri: \'http://edit.test/iiif-test/manifest2.json\'
|
|
388 |
manifestUri: \'' . $manifest_uri . '\'
|
|
390 | 389 |
} |
391 | 390 |
); |
392 | 391 |
});', |
... | ... | |
1334 | 1333 |
* The media lists are cached in a static variable. |
1335 | 1334 |
* |
1336 | 1335 |
* @param Taxon $taxon |
1337 |
* A CDM Taxon entitiy
|
|
1336 |
* A CDM Taxon entity |
|
1338 | 1337 |
* |
1339 | 1338 |
* @return array |
1340 | 1339 |
* An array of CDM Media entities |
1341 | 1340 |
* |
1342 | 1341 |
*/ |
1343 |
function _load_media_for_taxon($taxon) { |
|
1342 |
function _load_media_for_taxon($taxon) {
|
|
1344 | 1343 |
|
1345 | 1344 |
static $media = NULL; |
1346 | 1345 |
|
... | ... | |
1349 | 1348 |
} |
1350 | 1349 |
if (!isset($media[$taxon->uuid])) { |
1351 | 1350 |
|
1352 |
// --- GET Images --- // |
|
1353 |
$mediaQueryParameters = array( |
|
1354 |
"type" => "ImageFile", |
|
1355 |
); |
|
1356 |
|
|
1357 |
$relationship_choice = variable_get(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS, unserialize(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT)); |
|
1358 |
$mediaQueryParameters['relationships'] = implode(',', get_selection($relationship_choice['direct'])); |
|
1359 |
$mediaQueryParameters['relationshipsInvers'] = implode(',', get_selection($relationship_choice['invers'])); |
|
1360 | 1351 |
|
1361 |
$taxon_media_filter_choice = variable_get(CDM_TAXON_MEDIA_FILTER, unserialize(CDM_TAXON_MEDIA_FILTER_DEFAULT)); |
|
1362 |
$mediaQueryParameters['includeTaxonDescriptions'] = (boolean) $taxon_media_filter_choice['includeTaxonDescriptions'] != 0; |
|
1363 |
$mediaQueryParameters['includeOccurrences'] = (boolean) $taxon_media_filter_choice['includeOccurrences'] != 0; |
|
1364 |
$mediaQueryParameters['includeTaxonNameDescriptions'] = (boolean) $taxon_media_filter_choice['includeTaxonNameDescriptions'] != 0; |
|
1352 |
$mediaQueryParameters = taxon_media_query_parameters(); |
|
1365 | 1353 |
|
1366 | 1354 |
$ws_endpoint = NULL; |
1367 |
if ( variable_get('cdm_images_include_children', 0) == 0) { |
|
1368 |
$ws_endpoint = CDM_WS_PORTAL_TAXON_MEDIA; |
|
1369 |
} else { |
|
1355 |
if ( $mediaQueryParameters['includeTaxonomicChildren']) { |
|
1370 | 1356 |
$ws_endpoint = CDM_WS_PORTAL_TAXON_SUBTREE_MEDIA; |
1357 |
} else { |
|
1358 |
$ws_endpoint = CDM_WS_PORTAL_TAXON_MEDIA; |
|
1371 | 1359 |
} |
1360 |
// this parameter is not yet used by the CDM_WS_PORTAL_TAXON_*MEDIA |
|
1361 |
// services |
|
1362 |
unset($mediaQueryParameters['includeTaxonomicChildren']); |
|
1372 | 1363 |
|
1373 | 1364 |
$media[$taxon->uuid] = cdm_ws_get($ws_endpoint, |
1374 | 1365 |
array( |
modules/cdm_dataportal/includes/media.inc | ||
---|---|---|
851 | 851 |
*/ |
852 | 852 |
function taxon_media_gallery_universalviewer($taxon, $media) { |
853 | 853 |
|
854 |
_add_js_universalviewer('#uv'); |
|
854 |
$media_query_parameters = taxon_media_query_parameters(); |
|
855 |
unset($media_query_parameters['includeTaxonomicChildren']); |
|
856 |
$manifest_uri = cdm_compose_url( |
|
857 |
CDM_WS_IIIF_TAXON_MANIFEST, |
|
858 |
array($taxon->uuid), |
|
859 |
queryString($media_query_parameters) |
|
860 |
); |
|
861 |
_add_js_universalviewer('#uv', $manifest_uri); |
|
855 | 862 |
$out = '<div id="uv" class="uv" style="width: 680px; height: 680px;"></div>'; |
856 | 863 |
return $out; |
857 | 864 |
} |
858 | 865 |
|
866 |
/** |
|
867 |
* Prepares from the settings an array of query parameters for the taxon media webservices: |
|
868 |
* |
|
869 |
* - CDM_WS_PORTAL_TAXON_SUBTREE_MEDIA |
|
870 |
* - CDM_WS_PORTAL_TAXON_MEDIA |
|
871 |
* - CDM_WS_IIIF_TAXON_MANIFEST |
|
872 |
* |
|
873 |
* @return array |
|
874 |
*/ |
|
875 |
function taxon_media_query_parameters() { |
|
876 |
$mediaQueryParameters = [ |
|
877 |
"type" => "ImageFile", |
|
878 |
]; |
|
879 |
$relationship_choice = variable_get(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS, unserialize(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT)); |
|
880 |
$mediaQueryParameters['relationships'] = implode(',', get_selection($relationship_choice['direct'])); |
|
881 |
$mediaQueryParameters['relationshipsInvers'] = implode(',', get_selection($relationship_choice['invers'])); |
|
882 |
|
|
883 |
$taxon_media_filter_choice = variable_get(CDM_TAXON_MEDIA_FILTER, unserialize(CDM_TAXON_MEDIA_FILTER_DEFAULT)); |
|
884 |
$mediaQueryParameters['includeTaxonDescriptions'] = (boolean) $taxon_media_filter_choice['includeTaxonDescriptions'] != 0; |
|
885 |
$mediaQueryParameters['includeOccurrences'] = (boolean) $taxon_media_filter_choice['includeOccurrences'] != 0; |
|
886 |
$mediaQueryParameters['includeTaxonNameDescriptions'] = (boolean) $taxon_media_filter_choice['includeTaxonNameDescriptions'] != 0; |
|
887 |
$mediaQueryParameters['includeTaxonomicChildren'] = variable_get('cdm_images_include_children', 0) != 0; |
|
888 |
return $mediaQueryParameters; |
|
889 |
} |
|
890 |
|
|
891 |
|
Also available in: Unified diff
ref #5083 using iif taxon manifest service in dataportal