Revision 2264b60d
Added by Andreas Kohlbecker about 13 years ago
modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme | ||
---|---|---|
205 | 205 |
return $out; |
206 | 206 |
} |
207 | 207 |
|
208 |
|
|
208 | 209 |
/** |
209 | 210 |
* TODO: assign a new name to the function? because it is used for the citations |
210 | 211 |
* textdata elements and not for all text data description elements |
... | ... | |
223 | 224 |
|
224 | 225 |
if(is_array($element->sources)){ |
225 | 226 |
foreach($element->sources as $source){ |
226 |
$referenceCitation = theme('cdm_DescriptionElementSource', $source);
|
|
227 |
if($description && strlen($description) > 0 && $referenceCitation ){
|
|
228 |
$sourceRefs .= ' ('.$referenceCitation.')' ;
|
|
229 |
}else if ($referenceCitation){
|
|
230 |
$sourceRefs = $referenceCitation;
|
|
231 |
}
|
|
227 |
$referenceCitation = theme('cdm_DescriptionElementSource', $source);
|
|
228 |
if($description && strlen($description) > 0 && $referenceCitation ){
|
|
229 |
$sourceRefs .= ' ('.$referenceCitation.')' ;
|
|
230 |
}else if ($referenceCitation){
|
|
231 |
$sourceRefs = $referenceCitation;
|
|
232 |
}
|
|
232 | 233 |
|
233 |
if(strlen($sourceRefs) > 0){
|
|
234 |
$sourceRefs = '<span class="sources">' . $sourceRefs . '</span>';
|
|
235 |
}
|
|
234 |
if(strlen($sourceRefs) > 0){
|
|
235 |
$sourceRefs = '<span class="sources">' . $sourceRefs . '</span>';
|
|
236 |
}
|
|
236 | 237 |
|
237 |
if ($source->nameUsedInSource->uuid){ //do a link to name page
|
|
238 |
$name_used_in_source_link_to_show = l($source->nameUsedInSource->titleCache,
|
|
239 |
path_to_name($source->nameUsedInSource->uuid),
|
|
240 |
array(), NULL, NULL, FALSE ,TRUE);
|
|
241 |
}else if (strlen($source->nameUsedInSource->originalNameString) > 0){ //show a text without link
|
|
242 |
$name_used_in_source_link_to_show = $source->nameUsedInSource->originalNameString;
|
|
243 |
}
|
|
238 |
if ($source->nameUsedInSource->uuid){ //do a link to name page
|
|
239 |
$name_used_in_source_link_to_show = l($source->nameUsedInSource->titleCache,
|
|
240 |
path_to_name($source->nameUsedInSource->uuid),
|
|
241 |
array(), NULL, NULL, FALSE ,TRUE);
|
|
242 |
}else if (strlen($source->nameUsedInSource->originalNameString) > 0){ //show a text without link
|
|
243 |
$name_used_in_source_link_to_show = $source->nameUsedInSource->originalNameString;
|
|
244 |
}
|
|
244 | 245 |
|
245 |
if ($asListElement){
|
|
246 |
$out = '<li class="descriptionText">' . $name_used_in_source_link_to_show;
|
|
247 |
//adding ":" if necesary
|
|
248 |
if ($name_used_in_source_link_to_show && ($description || $sourceRefs)){
|
|
249 |
$out .= ': ';
|
|
250 |
}
|
|
251 |
$out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', $element) . '</li>';
|
|
252 |
}else{
|
|
253 |
if ($name_used_in_source_link_to_show){
|
|
254 |
$name_used_in_source_link_to_show = ' (name in source: '. $name_used_in_source_link_to_show . ')';
|
|
255 |
}
|
|
256 |
$out = $description . $sourceRefs . $name_used_in_source_link_to_show;
|
|
257 |
}
|
|
246 |
if ($asListElement){
|
|
247 |
$out = '<li class="descriptionText">' . $name_used_in_source_link_to_show;
|
|
248 |
//adding ":" if necesary
|
|
249 |
if ($name_used_in_source_link_to_show && ($description || $sourceRefs)){
|
|
250 |
$out .= ': ';
|
|
251 |
}
|
|
252 |
$out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', $element) . '</li>';
|
|
253 |
}else{
|
|
254 |
if ($name_used_in_source_link_to_show){
|
|
255 |
$name_used_in_source_link_to_show = ' (name in source: '. $name_used_in_source_link_to_show . ')';
|
|
256 |
}
|
|
257 |
$out = $description . $sourceRefs . $name_used_in_source_link_to_show;
|
|
258 |
}
|
|
258 | 259 |
} |
259 | 260 |
} |
260 | 261 |
//if no sources, print the description |
... | ... | |
268 | 269 |
return $out; |
269 | 270 |
} |
270 | 271 |
|
272 |
|
|
271 | 273 |
function theme_cdm_common_names($elements){ |
272 | 274 |
$text_data_out = ''; |
273 | 275 |
$common_name_out = ''; |
... | ... | |
623 | 625 |
return $out; |
624 | 626 |
} |
625 | 627 |
|
628 |
function theme_cdm_IdentifieableSource($source, $doLink = TRUE){ |
|
629 |
|
|
630 |
if(isset($source->citation)){ |
|
631 |
$out = theme('cdm_reference', $source->citation, $source->citationMicroReference, $doLink); |
|
632 |
} |
|
633 |
return $out; |
|
634 |
} |
|
635 |
|
|
636 |
|
|
637 |
|
|
638 |
|
|
626 | 639 |
|
627 | 640 |
/* |
628 | 641 |
function theme_cdm_descriptionElementDistribution($descriptionElements){ |
... | ... | |
805 | 818 |
return $pager->records; |
806 | 819 |
} |
807 | 820 |
|
821 |
function theme_cdm_IdentificationKey($identificationKey, $doLinkToKeyPage = true){ |
|
822 |
|
|
823 |
$parentRenderPath = RenderHints::getRenderPath(); |
|
824 |
RenderHints::pushToRenderStack("IdentificationKey"); |
|
825 |
|
|
826 |
if($doLinkToKeyPage) { |
|
827 |
$out = l($identificationKey->titleCache, path_to_key($identificationKey->class, $identificationKey->uuid)); |
|
828 |
} else { |
|
829 |
$out = $identificationKey->titleCache; |
|
830 |
} |
|
831 |
if(is_array($identificationKey->sources)){ |
|
832 |
// display sources |
|
833 |
foreach($identificationKey->sources as $source){ |
|
834 |
$out .= theme("cdm_IdentifieableSource", $source); |
|
835 |
} |
|
836 |
// display annotations |
|
837 |
$out .= theme("cdm_annotations_as_footnotekeys", $identificationKey, $parentRenderPath); |
|
838 |
} |
|
839 |
RenderHints::popFromRenderStack(); |
|
840 |
return $out; |
|
841 |
} |
|
842 |
|
|
843 |
function theme_cdm_polytomousKey(&$polytomousKey){ |
|
844 |
|
|
845 |
$keyStyle = "linkedStyle"; // TODO settings needed |
|
846 |
|
|
847 |
RenderHints::pushToRenderStack("polytomousKey"); |
|
848 |
// key nodes in linked style |
|
849 |
$out = '<table class="polytomousKey polytomousKey_'.$keyStyle.'">'; |
|
850 |
$out .= theme('cdm_polytomousKey_'.$keyStyle.'_subgraph', $polytomousKey->root); |
|
851 |
$out .= '</table>'; |
|
852 |
RenderHints::popFromRenderStack(); |
|
853 |
return $out; |
|
854 |
} |
|
855 |
|
|
856 |
function theme_cdm_polytomousKey_linkedStyle_subgraph(&$polytomousKeyNode){ |
|
857 |
|
|
858 |
static $statementCountCharacter = '\''; |
|
859 |
|
|
860 |
$out = ""; |
|
861 |
|
|
862 |
if(is_array($polytomousKeyNode->children)){ |
|
863 |
|
|
864 |
$childCount = 0; |
|
865 |
|
|
866 |
// render edges of the current node |
|
867 |
foreach($polytomousKeyNode->children as &$child){ |
|
868 |
$out .= '<tr class="childCount_' . $childCount . '">'; |
|
869 |
|
|
870 |
$out .= '<td class="nodeNumber">'. uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber . str_pad("", $childCount++ , $statementCountCharacter)) . "</td>"; |
|
871 |
|
|
872 |
$islinkToTaxonOrSubkey = isset($child->taxon->uuid) || isset($child->subkey->uuid); |
|
873 |
|
|
874 |
$out .= '<td class="edge" colspan="'. ( $islinkToTaxonOrSubkey ? '2' : '1' ) .'">'; |
|
875 |
if(isset($polytomousKeyNode->question->label_l10n)){ |
|
876 |
$out .= $polytomousKeyNode->question->label_l10n . ": "; |
|
877 |
} |
|
878 |
$out .= $child->statement->label_l10n; |
|
879 |
|
|
880 |
if(!$islinkToTaxonOrSubkey){ |
|
881 |
$out .= '</td>'; |
|
882 |
// link to a PolytomousKeyNode |
|
883 |
$out .= '<td class="nodeLink">' . l($child->nodeNumber, $_REQUEST["q"], null, null, $child->uuid) . '</td>'; |
|
884 |
} else { |
|
885 |
if(isset($child->taxon->uuid)){ |
|
886 |
// link to a taxon |
|
887 |
$out .= '<div class="nodeLinkToTaxon">' . theme("cdm_taxonName", $child->taxon->name, path_to_taxon($child->taxon->uuid)) . '</div>'; |
|
888 |
} else if(isset($child->subkey->uuid)){ |
|
889 |
// link to a subkey |
|
890 |
$out .= '<div class="nodeLinkToSubkey">' |
|
891 |
. theme('cdm_IdentificationKey', $child->subkey) . '</div>'; |
|
892 |
} |
|
893 |
$out .= '</td>'; |
|
894 |
} |
|
895 |
|
|
896 |
$out .= '</tr>'; |
|
897 |
|
|
898 |
} |
|
899 |
|
|
900 |
// recurse into child nodes |
|
901 |
foreach($polytomousKeyNode->children as &$child){ |
|
902 |
$out .= theme('cdm_polytomousKey_linkedStyle_subgraph', $child); |
|
903 |
} |
|
904 |
|
|
905 |
} |
|
906 |
return $out; |
|
907 |
} |
|
908 |
|
|
808 | 909 |
/** |
809 | 910 |
* Renders a list of a specific type of IdentificationKeys, the list can be restricteded by a taxon. |
810 | 911 |
* @param $type The simple name of the cdm class implementing the interface IIdentificationKey, |
... | ... | |
822 | 923 |
RenderHints::pushToRenderStack('list_IdentificationKeys'); |
823 | 924 |
$out = '<ul>'; |
824 | 925 |
foreach ($keyList as $key){ |
825 |
$out .= '<li>'.l($key->titleCache, path_to_key($type, $key->uuid)).'</li>'; |
|
926 |
$out .= '<li>'; |
|
927 |
$out .= theme('cdm_IdentificationKey', $key); |
|
928 |
$out .= '</li>'; |
|
826 | 929 |
} |
827 | 930 |
$out .= '</ul>'; |
931 |
$out .= theme("cdm_annotation_footnotes", RenderHints::getRenderPath()); |
|
828 | 932 |
RenderHints::popFromRenderStack(); |
829 | 933 |
|
830 | 934 |
return $out; |
Also available in: Unified diff
displaying polytomous keys (fixes #2152)