';
foreach($featureNodes as $node){
if(hasFeatureNodeDescriptionElements($node)){
$featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
// HACK to implement images for taxa, should be removed
if($node->feature->uuid != UUID_IMAGE){
$out .= '
' . theme('cdm_descriptionElementArray', $out_array, $element->feature) . '
';
return $common_name_out . $common_name_out_text_data;
//return $common_name_out . theme('cdm_descriptionElementArray', $out_array, $element->feature);
//return " $common_name_out $common_name_out_text_data";
}
/**
* Theme a list of description elements, usually of a specific feature type
* @param $descriptionElements
* @return unknown_type
*/
function theme_cdm_descriptionElements($descriptionElements, $featureUuid, $taxon_uuid){
$outArray = array();
/*
$userDefined = mixed_variable_get(LAYOUT_SETTING_PREFIX . $featureUuid, FEATURE_TREE_LAYOUT_DEFAULTS);
if(variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT'){
$glue = '';
$enclosingTag = 'dl';
$entryEnclosingTag = null;
} else if($userDefined && $userDefined['enabled']){
$glue = $userDefined['glue'];
$enclosingTag = $userDefined['enclosingTag'];
$entryEnclosingTag = $userDefined['entryEnclosingTag'];
} else {
// TODO remove once LAYOUT_SETTING_PREFIX-{uuid} seeting are confired to work for all portals (selenium test still missing!!!)
$glue = '';
$enclosingTag = 'ul';
$entryEnclosingTag = null ;
}
*/
if(variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT'){
$glue = '';
$enclosingTag = 'dl';
} else {
$glue = '';
$enclosingTag = 'ul';
}
$sortOutArray = false;
$distributionElements = array();
RenderHints::pushToRenderStack('cdm_descriptionElements');
if(is_array($descriptionElements)){//avoiding warning box in drupal for flora malesiana
foreach($descriptionElements as $descriptionElement) {
// --- DISTRIBUTION ---- //
if($descriptionElement->feature->uuid == UUID_DISTRIBUTION){
if($descriptionElement->class == 'Distribution'){
$sortKey = $descriptionElement->area->representation_L10n;
$distributionElements[$sortKey]= $descriptionElement;
} else if($descriptionElement->class == 'TextData'){
$asListElement = false;
$repr = theme ('cdm_descriptionElementTextData', $descriptionElement, $asListElement, $descriptionElement->feature->uuid);
if( !array_search($repr, $outArray)){
$outArray[] = $repr;
//TODO HINT: sorting in theme_cdm_descriptionElementArray will not work since this array contains html attributes with uuids !!!!
$sortOutArray = true;
$glue = '
';
$enclosingTag = 'p';
}
}
}
// --- IMAGE_SOURCES --- //
else if($descriptionElement->feature->uuid == UUID_IMAGE_SOURCES){
$image_sources[] = $descriptionElement;
}
// ---- class == TextData ---- //
else if($descriptionElement->class == 'TextData'){
$asListElement = true;
$outArray[] = theme('cdm_descriptionElementTextData', $descriptionElement, $asListElement, $descriptionElement->feature->uuid);
}else if ($descriptionElement->class == 'CommonTaxonName') {
$outArray[] = theme('cdm_descriptionElement_CommonTaxonName', $descriptionElement);
}else {
$outArray[] = '
No method for rendering unknown description class: '.$descriptionElement->classType.'';
}
}
}
//if feature = NAME USAGE sort the list of sources
//this is ONLY for FLORA MALESIANA and FLORE d'AFRIQUE CENTRALE
if($descriptionElement->feature->uuid == UUID_NAME_USAGE){
sort($outArray);
}
if($image_sources){
$outArray[] = theme('cdm_description_element_image_source', $image_sources, true);
}
if(variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT'){
$outArray[] = theme('cdm_description_ordered_distributions', $taxon_uuid, $distributionElements);
}else{
ksort($distributionElements);
$outArray[] = theme('cdm_descriptionElementDistribution', $distributionElements); // TODO , $entryEnclosingTag);
}
// take the feature of the last $descriptionElement
$feature = $descriptionElement->feature;
$out = theme('cdm_descriptionElementArray', $outArray, $feature, $glue, $sortOutArray, $enclosingTag);
RenderHints::popFromRenderStack();
return $out;
}
/**
*
* Enter description here ...
* @param unknown_type $a
* @param unknown_type $b
*/
function compare_image_sources($a, $b){
if($a->multilanguageText_L10n->text == $b->multilanguageText_L10n->text){
return 0;
}
return ($a->multilanguageText_L10n->text < $b->multilanguageText_L10n->text) ? -1 : 1;
}
/**
*
*/
function theme_cdm_description_element_image_source($image_sources, $asListElement) {
$out = '';
$separator = ',';
RenderHints::pushToRenderStack('descriptionElementImageSource');
RenderHints::setFootnoteListKey(UUID_IMAGE_SOURCES);
//sorting the image sources
usort($image_sources, "compare_image_sources");
//generate the footnotes
foreach($image_sources as $image_source){
$footNoteKeys = cdm_annotations_as_footnotekeys($image_source);
foreach($image_source->sources as $source){
if(_is_original_source_type($source)){
$fn_key = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
cdm_add_footnote_to_array($footNoteKeys, $fn_key);// ensure uniqueness of the footnote keys
}
}
//sort and render footnote keys
$footnoteKeyListStr = '';
asort($footNoteKeys);
foreach($footNoteKeys as $footNoteKey){
$footnoteKeyListStr .= theme('cdm_footnote_key', $footNoteKey, ($footnoteKeyListStr ? $separator : ''));
}
//return value!
$out .= '
'.$image_source->multilanguageText_L10n->text . $footnoteKeyListStr . '; ';
}
RenderHints::popFromRenderStack();
return $out;
}
/**
*
* @param unknown_type $descriptionElements
* @param String $enclosingTag
*/
function theme_cdm_descriptionElementDistribution($descriptionElements, $enclosingTag = "span"){
if(!$enclosingTag){
$enclosingTag = "span";
}
$out = '';
$separator = ',';
RenderHints::pushToRenderStack('descriptionElementDistribution');
RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
foreach($descriptionElements as $descriptionElement){
// annotations as footnotes
$footNoteKeys = cdm_annotations_as_footnotekeys($descriptionElement);
// source references as footnotes
foreach($descriptionElement->sources as $source){
if(_is_original_source_type($source)){
$fn_key = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
cdm_add_footnote_to_array($footNoteKeys, $fn_key);// ensure uniqueness of the footnote keys
}
}
// sort and render footnote keys
$footnoteKeyListStr = '';
asort($footNoteKeys);
foreach($footNoteKeys as $footNoteKey){
$footnoteKeyListStr .= theme('cdm_footnote_key', $footNoteKey, ($footnoteKeyListStr ? $separator : ''));
}
$out .= '<'. $enclosingTag .' class="descriptionElement descriptionElement-'.$descriptionElement->uuid.'">'
. $descriptionElement->area->representation_L10n . $footnoteKeyListStr . ' '. $enclosingTag .'>';
}
RenderHints::popFromRenderStack();
return $out;
}
/**
* Function target is to compare two different foootnotes objects.
* The comparation is based on the footnote key. The one which is
* displayed as footnote number.
*
* @param footnote object $a
* @param footnote object $b
*/
function footnotes_key_compare($a, $b){
$res = 0;
if ($a->keyStr < $b->keyStr){
$res = -1;
}elseif ($a->keyStr > $b->keyStr){
$res = 1;
}
return $res;
}
function theme_cdm_description_ordered_distributions($taxon_uuid, $descriptionElements){
//returning null if no description elements
if ($descriptionElements == null){
return '';
}
//initialization some variables
$out = '';
$separator = ',';
RenderHints::pushToRenderStack('descriptionElementDistribution');
RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
//getting all the taxon description for a given taxon
$taxonDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxon_uuid);
foreach ($taxonDescriptions as $description){
$descriptions_uuids[] = $description->uuid;
}
//getting the sortered distributions (omiting level ??)
$request_params = array();
$request_params['omitLevels'] = UUID_NAMEDAREALEVEL_TDWGLEVEL_2;
$ordered_areas = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION_DISTRIBUTION_TREE, join(',',$descriptions_uuids), queryString($request_params));
$ordered_areas = $ordered_areas->rootElement->children;
//printing the distributions
foreach ($ordered_areas as $element_level1){
//level1
if ($element_level1->data){
$out .= '
' . $element_level1->data->area->representation_L10n . ': ';
}
$out .= '
';
//level3
foreach ($element_level1->children as $element_level3){
if ($element_level3->data){
$text_l3 = $element_level3->data->area->representation_L10n;
}
$fnKeysLevel3Str = '';
$fnKeysLevel3 = cdm_annotations_as_footnotekeys($element_level3->data);
foreach($element_level3->data->sources as $source){
if(_is_original_source_type($source)){
$fn_key3 = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
cdm_add_footnote_to_array($fnKeysLevel3, $fn_key3);
}
}
//level4
$l4_regions = array();
foreach ($element_level3->children as $element_level4){
if ($element_level4->data){
$text_l4 = $element_level4->data->area->representation_L10n;
$l4_regions[$element_level3->data->area->representation_L10n] = '';
$fnKeysLevel4Str = '';
$fnKeysLevel4 = cdm_annotations_as_footnotekeys($element_level4->data);
foreach($element_level4->data->sources as $source){
if(_is_original_source_type($source)){
$fn_key4 = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
cdm_add_footnote_to_array($fnKeysLevel4, $fn_key4);
}
}
usort($fnKeysLevel4, "footnotes_key_compare");
$l4_regions[$text_l4] = $fnKeysLevel4;
}
}//level4
//managing level3 and level4 for generating the right output
usort($fnKeysLevel3, "footnotes_key_compare");
foreach ($fnKeysLevel3 as $key3){
foreach ($l4_regions as $key4 => $value4){
cdm_add_footnote_to_array($l4_regions[$key4], $key3);
}
}
if ($element_level3->numberOfChildren == 1 &&
$text_l3 == $element_level3->children[0]->data->area->representation_L10n){
//var_dump($element_level3->children[0]->data->area->representation_L10n);
$fnStr = '';
$region = array_pop($l4_regions);
foreach($region as $key){
$fnStr .= theme('cdm_footnote_key', $key, ($fnStr ? $separator : ''));
}
$out .= "$text_l3 $fnStr; ";
//removing whitespaces when &fnStr is empty
if(substr($out, -3) == ' ; '){
$out = substr($out, 0, -3) . '; ';
}
}else{
$fnKeysLevel3Str = '';
foreach($fnKeysLevel3 as $key){
$fnKeysLevel3Str .= theme('cdm_footnote_key', $key, ($fnKeysLevel3Str ? $separator : ''));
}
$text_l4_aux = '';
foreach ($l4_regions as $key => $value){
$fnKeysLevel4Str = '';
if (is_array($l4_regions[$key])) {
foreach ($l4_regions[$key] as $fnkey){//warning why?
$fnKeysLevel4Str .= theme('cdm_footnote_key', $fnkey, ($fnKeysLevel4Str ? $separator : ''));
}
}
//if ($key != $text_l3 || sizeof($l4_regions > 1)){
if ($key != $text_l3){
$text_l4_aux .= "$key $fnKeysLevel4Str, ";
}
}
$text_l4_aux = substr($text_l4_aux, 0, -2);
if (strlen($text_l4_aux) > 0){
$out .= "$text_l3 $fnKeysLevel3Str ($text_l4_aux); ";
}else{
$out .= "$text_l3 $fnKeysLevel3Str; ";
}
}
}//level3
$out = substr($out, 0, -2);
$out .= '.';
}//level1
RenderHints::popFromRenderStack();
return $out;
}
function theme_cdm_DescriptionElementSource($descriptionElementSource, $doLink = TRUE){
if(isset($descriptionElementSource->citation)){
$out = theme('cdm_reference', $descriptionElementSource->citation, $descriptionElementSource->citationMicroReference, $doLink);
}
return $out;
}
function theme_cdm_IdentifieableSource($source, $doLink = TRUE){
if(isset($source->citation)){
$out = theme('cdm_reference', $source->citation, $source->citationMicroReference, $doLink);
}
return $out;
}
/*
function theme_cdm_descriptionElementDistribution($descriptionElements){
$out = '';
$separator = ',';
RenderHints::pushToRenderStack('descriptionElementDistribution');
RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
foreach($descriptionElements as $descriptionElement){
// annotations as footnotes
$annotationFootnoteKeys = theme('cdm_annotations_as_footnotekeys', $descriptionElement);
// source references as footnotes
$sourcesFootnoteKeyList = '';
foreach($descriptionElement->sources as $source){
if(_is_original_source_type($source)){
$_fkey = FootnoteManager::addNewFootnote(UUID_DISTRIBUTION, theme('cdm_DescriptionElementSource', $source, false));
$sourcesFootnoteKeyList .= theme('cdm_footnote_key', $_fkey, UUID_DISTRIBUTION, ($sourcesFootnoteKeyList ? $separator : ''));
}
}
if($annotationFootnoteKeys && $sourcesFootnoteKeyList){
$annotationFootnoteKeys .= $separator;
}
$out .= $descriptionElement->area->representation_L10n . $annotationFootnoteKeys . $sourcesFootnoteKeyList . ' ';
}
$out = substr($out, 0, strlen($out)-strlen($separator) );
RenderHints::popFromRenderStack();
return $out;
}
*/
/**
* TODO
* Quick-and-dirty solution to show distribution service to exemplar groups
*
* @param unknown_type $featureTo
* @return unknown
*/
function theme_cdm_distribution_map($taxon){
$server = getEDITMapServiceURI();
if(!$server){
//warning message
drupal_set_message('No \'Geoservice Access Point\' has been set so far. '
. 'Please configure the variable \'Geoservice Access Point\' here '
. l('CDM Dataportal Settings', 'admin/settings/cdm_dataportal/geo'), 'warning');
//message to render
return "
No geoservice specified
";
}else{
$fontStyles = array(0 => "plane", 1 => "italic");
// query cdm server for map service uri parameters
$map_data_parameters = cdm_ws_get(CDM_WS_GEOSERVICE_DISTRIBUTIONMAP, $taxon->uuid);
$out .= "";
$query_string = $map_data_parameters->String;
if(!$query_string){
// the $query_string is empty if there are no distribution areas defined
return ;
}
// some cleaning of the URI paramters, TODO is this still needed?
$query_string = str_replace('%3A', ":", $query_string);
// additional query parameters as set in the data portal admin section
$display_width = variable_get('cdm_dataportal_geoservice_display_width', false);
$bounding_box = variable_get('cdm_dataportal_geoservice_bounding_box', false);
$labels_on = variable_get('cdm_dataportal_geoservice_labels_on', 0);
$query_string .= ($display_width ? '&ms=' . $display_width: '').
($bounding_box ? '&bbox=' . $bounding_box : '')
. ($labels_on ? '&label=' . $labels_on : '');
/* ------ choose the display mode, either openlayers or static image ------ */
if(variable_get('cdm_dataportal_map_openlayers', 1)){
$query_string .= '&img=false';
/* =========== display distributions using the openlayers map viewer =========== */
$legend_url_font_size = variable_get('cdm_dataportal_geoservice_legend_font_size', 10);
$legend_url_font_style = variable_get('cdm_dataportal_geoservice_legend_font_style', 1);
$legend_url_font_style = $fontStyles[$legend_url_font_style];
$legend_url_icon_width = variable_get('cdm_dataportal_geoservice_legend_icon_width', 35);
$legend_url_icon_height = variable_get('cdm_dataportal_geoservice_legend_icon_height', 15);
$legendFormatQueryStr = "format=image".urlencode('/')."png&TRANSPARENT=TRUE";
$legendFormatQueryStr .= "&WIDTH=".$legend_url_icon_width."&HEIGHT=".$legend_url_icon_height."&";
//TODO why is the layer=topp:tdwg_level_4 parameter neede at all here??
$legendFormatQueryStr .="layer=topp".urlencode(':')."tdwg_level_4&LEGEND_OPTIONS=forceLabels".urlencode(':')."on;fontStyle".urlencode(':').$legend_url_font_style.";fontSize".urlencode(':').$legend_url_font_size."&SLD=".urlencode($sldLegend);
$out .= get_openlayers_map(
$display_width,
null,
$query_string,
$legendFormatQueryStr,
variable_get('cdm_dataportal_geoservice_map_caption', '')
);
} else {
// simple image
$mapStaticCaption = '&mc_s=Georgia,15,blue&mc=' . variable_get('cdm_dataportal_geoservice_map_caption', '');
$query_string .= '&img=true';
$query_string .= '&legend=1&mlp=3' . $mapStaticCaption . '&recalculate=false';
$map_service_script_name = "areas.php";
// apply Plain Image map settings
if (variable_get('edit_map_server', EDIT_MAPSERVER_V1_URI) == EDIT_MAPSERVER_V11_URI){
/*
* example : title=a:Naturalized++non-invasive
* &ad=cyprusdivs:bdcode:a:5&as=a:ff9900,,0.1,&l=tdwg4
* &ms=500&bbox=32,34,35,36&img=true&legend=1&mlp=3
* &mc_s=Georgia,15,blue&mc=&recalculate=false
*
* http://edit.br.fgov.be/edit_wp5/v1/rest_gen.php?
* l=background_gis:b,cyprusdivs&ad=cyprusdivs%3Abdcode%3Aa%3A8%2C4
* &as=a%3A339966%2C%2C0.1%2C|b:0000ff,,
* &bbox=32%2C34%2C35%2C36&img=true&legend=1&mc=&mc_s=Georgia%2C15%2Cblue
* &mlp=3&ms=500&recalculate=false&title=a%3Aindigenous
*/
$map_service_script_name = "rest_gen.php";
$bgcolor_areaStyleId= "y";
$baselayer_areaStyleId= "z";
$bgcolor_layer='';
$additional_area_styles = array();
// background color:
if(variable_get('map_bg_color', '')){
$bgcolor_layer = "background_gis:".$bgcolor_areaStyleId;
$additional_area_styles[] = $bgcolor_areaStyleId . ":" . variable_get('map_bg_color', '') . ",,";
}
//TODO HACK to replace the default base layer which currently is tdwg4 !!!
if(strpos($query_string, "?l=") !== FALSE){
$layer_param_token = "?l=";
} else {
$layer_param_token = "&l=";
}
if(strpos($query_string, "?as=") !== FALSE){
$areystyle_param_token = "?as=";
} else {
$areystyle_param_token = "&as=";
}
if(variable_get('map_base_layer', '')){
$query_string = str_replace($layer_param_token."tdwg4", "$layer_param_token".variable_get('map_base_layer', ''). ":" . $baselayer_areaStyleId, $query_string);
} else {
$query_string = str_replace($layer_param_token."tdwg4", $layer_param_token."tdwg4:".$baselayer_areaStyleId . ",", $query_string);
}
if($bgcolor_layer){
$query_string = str_replace($layer_param_token, $layer_param_token . $bgcolor_layer . ",", $query_string);
}
if(variable_get('map_base_layer_style', '')){
$additional_area_styles[] = $baselayer_areaStyleId . ":" . variable_get('map_base_layer_style', '');
}
foreach ($additional_area_styles as $as) {
$query_string = str_replace($areystyle_param_token, $areystyle_param_token . $as . "|", $query_string);
}
}
$mapUri = url("$server/$map_service_script_name?$query_string");
$out .= '
';
}
return $out;
}
}
/**
* Returns a list of a specific type of IdentificationKeys, the list can be restricteded by a taxon.
* @param $type The simple name of the cdm class implementing the interface IIdentificationKey,
* valid values are : PolytomousKey, MediaKey, MultiAccessKey
* @param $taxonUuid if given this parameter restrict the listed keys to
* those which have the taxon identified be this uuid in scope.
*/
function _list_IdentificationKeys($type, $taxonUuid = null, $pageSize = null, $pageNumber = null){
if(!$type){
drupal_set_message("Type parameter is missing", "error");
return;
}
$cdm_ws_pasepath = null;
switch($type){
case "PolytomousKey" : $cdm_ws_pasepath = CDM_WS_POLYTOMOUSKEY; break;
case "MediaKey" : $cdm_ws_pasepath = CDM_WS_MEDIAKEY; break;
case "MultiAccessKey" : $cdm_ws_pasepath = CDM_WS_MULTIACCESSKEY; break;
}
if(!$cdm_ws_pasepath){
drupal_set_message("Type parameter is not valid: ".$type, "error");
}
$queryParameters = '';
if(is_numeric($pageSize)){
$queryParameters = "pageSize=".$pageSize;
} else {
$queryParameters = "pageSize=0";
}
if(is_numeric($pageNumber)){
$queryParameters = "pageNumber=".$pageNumber;
} else {
$queryParameters = "pageNumber=0";
}
$queryParameters = null;
if($taxonUuid){
$queryParameters = "findByTaxonomicScope=$taxonUuid";
}
$pager = cdm_ws_get($cdm_ws_pasepath, null, $queryParameters);
if(!$pager || $pager->count == 0){
return array();
}
return $pager->records;
}
function theme_cdm_IdentificationKey($identificationKey, $doLinkToKeyPage = true, $showIdentificationKeyTitle = true){
$parentRenderPath = RenderHints::getRenderPath();
RenderHints::pushToRenderStack("IdentificationKey");
if($showIdentificationKeyTitle){
if($doLinkToKeyPage) {
$out = l($identificationKey->titleCache, path_to_key($identificationKey->class, $identificationKey->uuid));
} else {
$out = $identificationKey->titleCache;
}
}
if(is_array($identificationKey->sources)){
// display sources
$i = 0;
$out .= '
';
foreach($identificationKey->sources as $source){
$out .= ($i++ > 0 ? ', ' : '' ) . theme("cdm_IdentifieableSource", $source);
}
$out .= '
';
}
// display annotations
$out .= theme('cdm_annotations', cdm_ws_getAnnotationsFor($identificationKey), 'div');
RenderHints::popFromRenderStack();
return $out;
}
function theme_cdm_polytomousKey(&$polytomousKey){
$keyStyle = "linkedStyle"; // TODO settings needed
RenderHints::pushToRenderStack("polytomousKey");
// key nodes in linked style
$out = '
';
$out .= theme('cdm_polytomousKey_'.$keyStyle.'_subgraph', $polytomousKey->root);
$out .= '
';
RenderHints::popFromRenderStack();
return $out;
}
function theme_cdm_polytomousKey_linkedStyle_subgraph(&$polytomousKeyNode){
static $statementCountCharacter = '\'';
$out = "";
if(is_array($polytomousKeyNode->children)){
$childCount = 0;
// render edges of the current node
foreach($polytomousKeyNode->children as &$child){
if(!isset($child->statement)){
// skip node with empty statements (see below for explanation: "Special case")
continue;
}
$out .= '
';
$out .= ''. uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber . str_pad("", $childCount++ , $statementCountCharacter)) . " | ";
/*
* Special case:
* Child nodes with empty statements but taxa as leaf are to
* treated as if all those taxa where direct children of the source node.
*/
$islinkToManyTaxa = !isset($child->children[0]->statement) && isset($child->children[0]->taxon->uuid);
$islinkToTaxon = isset($child->taxon->uuid);
$islinkToSubKey = isset($child->subkey->uuid);
$islinkToOtherNode = isset($child->otherNode);
$islinkToNode = $child->nodeNumber && !$islinkToManyTaxa && !$islinkToOtherNode; // either null or 0
$out .= '';
if(isset($polytomousKeyNode->question->label_l10n)){
$out .= $polytomousKeyNode->question->label_l10n . ": ";
}
$out .= $child->statement->label_l10n;
// --- links to nodes taxa and subkeys
$out .= '';
// link to a PolytomousKeyNode
if($islinkToNode){
$out .= ' ' . l($child->nodeNumber, $_REQUEST["q"], null, null, $child->uuid) . ' ';
}
// link to a PolytomousKeyNode
if($islinkToOtherNode){
$out .= ' ' . l($child->otherNode->nodeNumber, $_REQUEST["q"], null, null, $child->otherNode->uuid) . ' ';
}
// link to one or many taxa
if($islinkToTaxon || $islinkToManyTaxa){
if($islinkToManyTaxa){
$taxonChildren = $child->children;
} else {
$taxonChildren = array($child);
}
foreach($taxonChildren as $taxonChild){
// TODO many taxa $child->children->taxon
$out .= ' ';
if(is_object($taxonChild->modifyingText)){
$i = 0;
foreach(get_object_vars($taxonChild->modifyingText) as $language=>$languageString){
$out .= ($i++ > 0 ? ', ' : '') . ''. $languageString->text . ' ';
}
}
$out .= theme("cdm_taxonName", $taxonChild->taxon->name, url(path_to_taxon($taxonChild->taxon->uuid)));
$out .= ' ';
}
// link to a subkey
if($islinkToSubKey){
$out .= ' ' . theme('cdm_IdentificationKey', $child->subkey) . ' ';
}
}
$out .= ' '; // end node link
$out .= ' | '; // end edge
$out .= '
';
}
// recurse into child nodes
foreach($polytomousKeyNode->children as &$child){
$out .= theme('cdm_polytomousKey_linkedStyle_subgraph', $child);
}
}
return $out;
}
/**
* Renders a list of a specific type of IdentificationKeys, the list can be restricteded by a taxon.
* @param $type The simple name of the cdm class implementing the interface IIdentificationKey,
* valid values are : PolytomousKey, MediaKey, MultiAccessKey
* @param $taxonUuid if given this parameter restrict the listed keys to
* those which have the taxon identified be this uuid in scope.
*/
function theme_cdm_list_IdentificationKeys($type, $taxonUuid = null, $pageSize, $pageNumber){
$keyList = _list_IdentificationKeys($type, $taxonUuid);
if(!$keyList || count ($keyList) == 0){
return;
}
RenderHints::pushToRenderStack('list_IdentificationKeys');
$out = '
';
foreach ($keyList as $key){
$out .= '- ';
$out .= theme('cdm_IdentificationKey', $key);
$out .= '
';
}
$out .= '
';
$out .= theme("cdm_annotation_footnotes", RenderHints::getRenderPath());
RenderHints::popFromRenderStack();
return $out;
}
function theme_cdm_block_IdentificationKeys($taxonUuid = null, $pageSize = null){
static $types = array("PolytomousKey"=>"Polytomous", "MediaKey"=>"Media", "MultiAccessKey"=>"Multiaccess");
RenderHints::pushToRenderStack('block_IdentificationKeys');
$out = '';
foreach($types as $type=>$label){
$keylist = theme('cdm_list_IdentificationKeys', $type, $taxonUuid, $pageSize, $pageNumber);
if(!$keylist){
continue;
}
$out .= '
';
$out .= '
'.t($label)."
";
$out .= $keylist;
$out .= '';
}
RenderHints::popFromRenderStack();
return $out;
}