Revision dba9669c
Added by Andreas Kohlbecker over 3 years ago
modules/cdm_dataportal/includes/occurrences.inc | ||
---|---|---|
1771 | 1771 |
return order_specimens_or_observations_by_date_and_type($fieldUnitDTOs); |
1772 | 1772 |
} |
1773 | 1773 |
|
1774 |
/** |
|
1775 |
* @param $specimen |
|
1776 |
* |
|
1777 |
* @return array |
|
1778 |
*/ |
|
1779 |
function specimen_id_and_collection_for($specimen) { |
|
1780 |
$specimenID = ''; |
|
1781 |
$collection = NULL; |
|
1782 |
if (!($specimen->class == 'FieldUnit')) { |
|
1783 |
if ($specimen->collection) { |
|
1784 |
if ($specimen->collection->code) { |
|
1785 |
$collection = $specimen->collection->code; |
|
1786 |
} |
|
1787 |
elseif ($specimen->collection->name) { |
|
1788 |
$collection = $specimen->collection->name; |
|
1789 |
} |
|
1790 |
} |
|
1791 |
if ($specimen->accessionNumber) { |
|
1792 |
$specimenID = $specimen->accessionNumber; |
|
1793 |
} |
|
1794 |
elseif ($specimen->barcode) { |
|
1795 |
$specimenID = $specimen->barcode; |
|
1796 |
} |
|
1797 |
elseif ($specimen->catalogNumber) { |
|
1798 |
$specimenID = $specimen->catalogNumber; |
|
1799 |
} |
|
1800 |
elseif ($specimen->titleCache) { |
|
1801 |
$specimenID = $specimen->titleCache; |
|
1802 |
} |
|
1803 |
if (!isset($specimenID) and !isset($collection)) { |
|
1804 |
$specimenID = $specimen->uuid; |
|
1805 |
} |
|
1806 |
} |
|
1807 |
else { |
|
1808 |
if ($specimen->titleCache) { |
|
1809 |
$specimenID = $specimen->titleCache; |
|
1810 |
} |
|
1811 |
if (!isset($specimenID) and !isset($collection)) { |
|
1812 |
$specimenID = $specimen->uuid; |
|
1813 |
} |
|
1814 |
} |
|
1815 |
return [$specimenID, $collection]; |
|
1816 |
} |
|
1817 |
|
|
1818 |
/** |
|
1819 |
* Renders a cdm collection entity as html markup. |
|
1820 |
* |
|
1821 |
* institute and super-collections |
|
1822 |
* |
|
1823 |
* @param $collection |
|
1824 |
* The CDM Collection entity |
|
1825 |
* @param bool $do_link |
|
1826 |
* Append a link to the collection page as clickable icon (default = true). |
|
1827 |
* |
|
1828 |
* @return string |
|
1829 |
* The markup for the collection, |
|
1830 |
*/ |
|
1831 |
function render_collection($collection, $do_link = false /* to be made true, see #9250 */ ){ |
|
1832 |
if(!is_object($collection)){ |
|
1833 |
return ''; |
|
1834 |
} |
|
1835 |
$collection_str_list = []; |
|
1836 |
$super_collection = $collection; |
|
1837 |
while($super_collection){ |
|
1838 |
$collection_str = $super_collection->titleCache; |
|
1839 |
if(is_object($super_collection->institute) && $super_collection->institute->titleCache){ |
|
1840 |
$collection_str .= ' at ' . $super_collection->institute->titleCache; |
|
1841 |
} |
|
1842 |
$collection_str_list[] = $collection_str; |
|
1843 |
if(isset($super_collection->superCollection)){ |
|
1844 |
$super_collection = $super_collection->superCollection; |
|
1845 |
} else { |
|
1846 |
$super_collection = null; |
|
1847 |
} |
|
1848 |
} |
|
1849 |
$markup = join(' in ', $collection_str_list); |
|
1850 |
if($markup){ |
|
1851 |
if($do_link){ |
|
1852 |
$markup .= ' ' . cdm_internal_link(path_to_collection($collection->uuid)); |
|
1853 |
} |
|
1854 |
$markup = '<span class="' . html_class_attribute_ref($collection) . '">' . $markup . '</span>'; |
|
1855 |
} |
|
1856 |
return $markup; |
|
1857 |
} |
|
1858 |
|
modules/cdm_dataportal/includes/pages.inc | ||
---|---|---|
1468 | 1468 |
return '<span class="' . $occurrence_dto->class . '">' . $out . '</span>'; |
1469 | 1469 |
} |
1470 | 1470 |
|
1471 |
/** |
|
1472 |
* @param $specimen |
|
1473 |
* |
|
1474 |
* @return array |
|
1475 |
*/ |
|
1476 |
function specimen_id_and_collection_for($specimen) { |
|
1477 |
$specimenID = ''; |
|
1478 |
$collection = NULL; |
|
1479 |
if (!($specimen->class == 'FieldUnit')) { |
|
1480 |
if ($specimen->collection) { |
|
1481 |
if ($specimen->collection->code) { |
|
1482 |
$collection = $specimen->collection->code; |
|
1483 |
} |
|
1484 |
elseif ($specimen->collection->name) { |
|
1485 |
$collection = $specimen->collection->name; |
|
1486 |
} |
|
1487 |
} |
|
1488 |
if ($specimen->accessionNumber) { |
|
1489 |
$specimenID = $specimen->accessionNumber; |
|
1490 |
} |
|
1491 |
elseif ($specimen->barcode) { |
|
1492 |
$specimenID = $specimen->barcode; |
|
1493 |
} |
|
1494 |
elseif ($specimen->catalogNumber) { |
|
1495 |
$specimenID = $specimen->catalogNumber; |
|
1496 |
} |
|
1497 |
elseif ($specimen->titleCache) { |
|
1498 |
$specimenID = $specimen->titleCache; |
|
1499 |
} |
|
1500 |
if (!isset($specimenID) and !isset($collection)) { |
|
1501 |
$specimenID = $specimen->uuid; |
|
1502 |
} |
|
1503 |
} |
|
1504 |
else { |
|
1505 |
if ($specimen->titleCache) { |
|
1506 |
$specimenID = $specimen->titleCache; |
|
1507 |
} |
|
1508 |
if (!isset($specimenID) and !isset($collection)) { |
|
1509 |
$specimenID = $specimen->uuid; |
|
1510 |
} |
|
1511 |
} |
|
1512 |
return [$specimenID, $collection]; |
|
1513 |
} |
|
1514 |
|
|
1515 |
/** |
|
1516 |
* Renders a cdm collection entity as html markup. |
|
1517 |
* |
|
1518 |
* institute and super-collections |
|
1519 |
* |
|
1520 |
* @param $collection |
|
1521 |
* The CDM Collection entity |
|
1522 |
* @param bool $do_link |
|
1523 |
* Append a link to the collection page as clickable icon (default = true). |
|
1524 |
* |
|
1525 |
* @return string |
|
1526 |
* The markup for the collection, |
|
1527 |
*/ |
|
1528 |
function render_collection($collection, $do_link = false /* to be made true, see #9250 */ ){ |
|
1529 |
if(!is_object($collection)){ |
|
1530 |
return ''; |
|
1531 |
} |
|
1532 |
$collection_str_list = []; |
|
1533 |
$super_collection = $collection; |
|
1534 |
while($super_collection){ |
|
1535 |
$collection_str = $super_collection->titleCache; |
|
1536 |
if(is_object($super_collection->institute) && $super_collection->institute->titleCache){ |
|
1537 |
$collection_str .= ' at ' . $super_collection->institute->titleCache; |
|
1538 |
} |
|
1539 |
$collection_str_list[] = $collection_str; |
|
1540 |
if(isset($super_collection->superCollection)){ |
|
1541 |
$super_collection = $super_collection->superCollection; |
|
1542 |
} else { |
|
1543 |
$super_collection = null; |
|
1544 |
} |
|
1545 |
} |
|
1546 |
$markup = join(' in ', $collection_str_list); |
|
1547 |
if($markup){ |
|
1548 |
if($do_link){ |
|
1549 |
$markup .= ' ' . cdm_internal_link(path_to_collection($collection->uuid)); |
|
1550 |
} |
|
1551 |
$markup = '<span class="' . html_class_attribute_ref($collection) . '">' . $markup . '</span>'; |
|
1552 |
} |
|
1553 |
return $markup; |
|
1554 |
} |
|
1555 |
|
Also available in: Unified diff
ref #9249, ref #9250 moving connection and specimen render function to occurrences.inc