Revision fbde64c6
Added by Andreas Kohlbecker over 13 years ago
modules/cdm_dataportal/cdm_dataportal.theme.php | ||
---|---|---|
42 | 42 |
', 'inline'); |
43 | 43 |
} |
44 | 44 |
|
45 |
function _add_js_footnotes(){ |
|
46 |
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/footnotes.js'); |
|
47 |
} |
|
48 |
|
|
45 | 49 |
|
46 | 50 |
function _add_js_cluetip(){ |
47 | 51 |
|
... | ... | |
2373 | 2377 |
$block->module = "cdm_dataportal-feature"; |
2374 | 2378 |
|
2375 | 2379 |
//get the text for the feature block |
2376 |
$block->content = theme('cdm_descriptionElements', $node->descriptionElements, $block->delta);
|
|
2380 |
$block->content = theme('cdm_descriptionElements', $node->descriptionElements, $node->feature->uuid);
|
|
2377 | 2381 |
// get media for the feature block |
2378 | 2382 |
$media_list = cdm_dataportal_media_from_descriptionElements($node->descriptionElements); |
2379 | 2383 |
$captionElements = array('title', 'rights'); |
... | ... | |
2449 | 2453 |
return $outArrayOfMedia; |
2450 | 2454 |
} |
2451 | 2455 |
|
2452 |
function theme_cdm_descriptionElements($descriptionElements){ |
|
2456 |
/** |
|
2457 |
* Theme a list of description elements, usually of a specific feature type |
|
2458 |
* @param $descriptionElements |
|
2459 |
* @return unknown_type |
|
2460 |
*/ |
|
2461 |
function theme_cdm_descriptionElements($descriptionElements, $featureUuid){ |
|
2453 | 2462 |
$outArray = array(); |
2454 | 2463 |
$glue = ''; |
2455 | 2464 |
$sortOutArray = false; |
2456 | 2465 |
$enclosingHtml = 'ul'; |
2457 |
$distributionElements=array();
|
|
2466 |
$distributionElements = array();
|
|
2458 | 2467 |
|
2459 | 2468 |
foreach($descriptionElements as $descriptionElement){ |
2460 |
//var_dump($descriptionElement); |
|
2461 |
//var_dump("</br> =============================================================================== </br>"); |
|
2462 |
|
|
2469 |
|
|
2463 | 2470 |
if($descriptionElement->feature->uuid == UUID_DISTRIBUTION){ |
2464 | 2471 |
if($descriptionElement->class == 'Distribution'){ |
2465 |
//$repr = $descriptionElement->area->representation_L10n; |
|
2466 |
$distributionElements[]= $descriptionElement->area->representation_L10n; |
|
2467 |
|
|
2472 |
$distributionElements[]= $descriptionElement; |
|
2468 | 2473 |
} else if($descriptionElement->class == 'TextData'){ |
2469 |
//$repr = $descriptionElement->multilanguageText_L10n->text; |
|
2470 | 2474 |
$asListElement = false; |
2471 |
$repr = "<t/>". theme ('cdm_descriptionElementTextData', $descriptionElement, $asListElement);
|
|
2475 |
$repr = theme ('cdm_descriptionElementTextData', $descriptionElement, $asListElement); |
|
2472 | 2476 |
|
2473 | 2477 |
if( !array_search($repr, $outArray)){ |
2474 | 2478 |
$outArray[] = $repr; |
... | ... | |
2480 | 2484 |
} else if($descriptionElement->class == 'TextData'){ |
2481 | 2485 |
$asListElement = true; |
2482 | 2486 |
$outArray[] = theme('cdm_descriptionElementTextData', $descriptionElement, $asListElement); |
2483 |
} else if($descriptionElement->class == 'media'){ |
|
2484 |
|
|
2485 | 2487 |
} else { |
2486 | 2488 |
$outArray[] = '<li>No method for rendering unknown description class: '.$descriptionElement->classType.'</li>'; |
2487 | 2489 |
} |
2488 | 2490 |
|
2489 | 2491 |
} |
2490 | 2492 |
|
2491 |
$outArray[] = theme(cdm_descriptionElementDistribution, $distributionElements); |
|
2493 |
$outArray[] = theme('cdm_descriptionElementDistribution', $distributionElements); |
|
2494 |
|
|
2495 |
|
|
2492 | 2496 |
// take the feature of the last $descriptionElement |
2493 | 2497 |
$feature = $descriptionElement->feature; |
2494 |
return theme('cdm_descriptionElementArray', $outArray, $feature, $glue, $sortOutArray, $enclosingHtml); |
|
2498 |
$out = theme('cdm_descriptionElementArray', $outArray, $feature, $glue, $sortOutArray, $enclosingHtml); |
|
2499 |
$out .= '<div class="footnote_list">'. FootnoteManager::renderFootnoteList($featureUuid) . '</div>'; |
|
2500 |
return $out; |
|
2495 | 2501 |
} |
2496 | 2502 |
|
2497 | 2503 |
function theme_cdm_descriptionElementDistribution($descriptionElements){ |
2498 | 2504 |
|
2499 |
$descriptions = ''; |
|
2505 |
$out = ''; |
|
2506 |
$separator = ', '; |
|
2500 | 2507 |
|
2501 |
foreach($descriptionElements as $description){ |
|
2502 |
$descriptions .= $description . ", "; |
|
2508 |
foreach($descriptionElements as $descriptionElement){ |
|
2509 |
//$footnoteKey = FootnoteManager::addNewFootnote($descriptionElement->feature->uuid, $descriptionElement->area->representation_L10n); |
|
2510 |
$footnoteKeyList = ''; |
|
2511 |
foreach($descriptionElement->sources as $source){ |
|
2512 |
$footnoteKey = FootnoteManager::addNewFootnote($descriptionElement->feature->uuid, $source, 'cdm_DescriptionElementSource'); |
|
2513 |
$footnoteKeyList .= theme('cdm_footnode_key', $footnoteKey) . ' '; |
|
2514 |
} |
|
2515 |
$out .= $descriptionElement->area->representation_L10n . $footnoteKeyList . $separator; |
|
2503 | 2516 |
} |
2504 |
$descriptions = substr($descriptions, 0, strlen($descriptions)-2); |
|
2517 |
$out = substr($out, 0, strlen($out)-strlen($separator) ); |
|
2518 |
|
|
2505 | 2519 |
$taxonTrees = cdm_ws_get(CDM_WS_TAXONOMY); |
2506 | 2520 |
foreach($taxonTrees as $taxonTree){ |
2507 | 2521 |
if ($taxonTree -> uuid == variable_get('cdm_taxonomictree_uuid', FALSE)){ |
... | ... | |
2510 | 2524 |
} |
2511 | 2525 |
} |
2512 | 2526 |
|
2513 |
if ($reference->title === "World Checklist of Arecaceae"){ |
|
2514 |
$referenceCitation = l('<span class="reference">(World Checklist of Monocotyledons)</span>', path_to_reference($reference->uuid), array("class"=>"reference"), NULL, NULL, FALSE ,TRUE); |
|
2515 |
}else |
|
2516 |
{ |
|
2517 |
$referenceCitation = l('<span class="reference">('.$reference->title.')</span>', path_to_reference($reference->uuid), array("class"=>"reference"), NULL, NULL, FALSE ,TRUE); |
|
2518 |
} |
|
2519 |
if($descriptions && strlen($descriptions) > 0 ){ |
|
2520 |
$sourceRefs .= ' '.$referenceCitation; |
|
2521 |
} |
|
2527 |
// $referenceCitation = l('<span class="reference">('.$reference->title.')</span>', path_to_reference($reference->uuid), array("class"=>"reference"), NULL, NULL, FALSE ,TRUE); |
|
2528 |
// if($descriptions && strlen($descriptions) > 0 ){ |
|
2529 |
// $sourceRefs .= ' '.$referenceCitation; |
|
2530 |
// } |
|
2522 | 2531 |
|
2523 |
if(strlen($sourceRefs) > 0){ |
|
2524 |
$sourceRefs = '<span class="sources">' . $sourceRefs . '</span>'; |
|
2525 |
} |
|
2526 |
return $descriptions. $sourceRefs ; |
|
2532 |
return $out; |
|
2527 | 2533 |
|
2534 |
} |
|
2528 | 2535 |
|
2536 |
function theme_cdm_DescriptionElementSource($descriptionElementSource, $doLink = TRUE){ |
|
2537 |
|
|
2538 |
//ev. delegate to theme_cdm_ReferencedEntityBase |
|
2539 |
$out = ''; |
|
2540 |
if($descriptionElementSource->citation){ |
|
2541 |
$datePublished = $descriptionElementSource->citation->datePublished; |
|
2542 |
if (strlen($datePublished->start) >0){ |
|
2543 |
$year=substr($datePublished->start,0,strpos($datePublished->start,'-')); |
|
2544 |
} |
|
2545 |
$author_team_titlecache = $descriptionElementSource->citation->authorTeam->titleCache; |
|
2546 |
if (strlen($year)>0){ |
|
2547 |
$reference = $author_team_titlecache.' '. $year; |
|
2548 |
}else { |
|
2549 |
$reference = $author_team_titlecache ; |
|
2550 |
} |
|
2551 |
|
|
2552 |
if($doLink){ |
|
2553 |
$out = l('<span class="reference">'.$reference.'</span>' |
|
2554 |
, path_to_reference($descriptionElementSource->citation->uuid) |
|
2555 |
, array("class"=>"reference") |
|
2556 |
, NULL, NULL, FALSE ,TRUE); |
|
2557 |
} else { |
|
2558 |
$out = $reference; |
|
2559 |
} |
|
2560 |
if($descriptionElementSource->citationMicroReference){ |
|
2561 |
$out .= ': '. $descriptionElementSource->citationMicroReference; |
|
2562 |
} |
|
2563 |
} |
|
2564 |
return $out; |
|
2529 | 2565 |
} |
2530 | 2566 |
|
2531 | 2567 |
function theme_cdm_descriptionElementArray($elementArray, $feature, $glue = '', $sortArray = false, $enclosingHtml = 'ul'){ |
... | ... | |
2557 | 2593 |
$res_date; |
2558 | 2594 |
|
2559 | 2595 |
foreach($element->sources as $source){ |
2560 |
$referenceCitation = ''; |
|
2561 |
if($source->citation){ |
|
2562 |
$datePublished = $source->citation->datePublished; |
|
2563 |
if (strlen($datePublished->start) >0){ |
|
2564 |
$year=substr($datePublished->start,0,strpos($datePublished->start,'-')); |
|
2565 |
} |
|
2566 |
/* new implementation */ |
|
2567 |
$author_team_titlecache = $source->citation->authorTeam->titleCache; //$source->citation->authorTeam->titlecache |
|
2568 |
if (strlen($year)>0){ |
|
2569 |
$reference = $author_team_titlecache.' '. $year; |
|
2570 |
}else { |
|
2571 |
$reference = $author_team_titlecache ; |
|
2572 |
} |
|
2573 |
|
|
2574 |
$referenceCitation = l('<span class="reference">'.'(' .$reference.')'.'</span>', path_to_reference($source->citation->uuid), array("class"=>"reference"), NULL, NULL, FALSE ,TRUE); |
|
2575 |
if($source->citationMicroReference){ |
|
2576 |
$referenceCitation .= ': '. $source->citationMicroReference; |
|
2577 |
} |
|
2578 |
if($description && strlen($description) > 0 ){ |
|
2579 |
$sourceRefs .= ' '.$referenceCitation ; |
|
2580 |
} |
|
2596 |
$referenceCitation = theme('cdm_DescriptionElementSource', $source); |
|
2597 |
if($description && strlen($description) > 0 && $referenceCitation ){ |
|
2598 |
$sourceRefs .= ' ('.$referenceCitation.')' ; |
|
2581 | 2599 |
} |
2582 | 2600 |
} |
2583 | 2601 |
if(strlen($sourceRefs) > 0){ |
... | ... | |
2588 | 2606 |
}else{ |
2589 | 2607 |
$res_text = $description . $sourceRefs; |
2590 | 2608 |
} |
2591 |
return $res_text;
|
|
2609 |
return $res_text; |
|
2592 | 2610 |
} |
2593 | 2611 |
|
2594 | 2612 |
function theme_cdm_search_results($pager, $path, $parameters){ |
... | ... | |
2637 | 2655 |
return $out; |
2638 | 2656 |
} |
2639 | 2657 |
|
2658 |
function theme_cdm_footnode_key($footnoteKey){ |
|
2659 |
$out = '<a href="#footnote-'.$footnoteKey.'" class="footnote-key">'.$footnoteKey.'</a>'; |
|
2660 |
return $out; |
|
2661 |
} |
|
2662 |
|
|
2663 |
function theme_cdm_footnode($footnoteKey, $footnodeText){ |
|
2664 |
_add_js_footnotes(); |
|
2665 |
$out = '<span class="footnote footnote-'.$footnoteKey.'"><a name="footnote-'.$footnoteKey.'"></a><span class="footnote-anchor">'.$footnoteKey.'.</span> '.$footnodeText.'</span>'; |
|
2666 |
return $out; |
|
2667 |
} |
|
2668 |
|
|
2669 |
|
|
2640 | 2670 |
|
2641 | 2671 |
function theme_cdm_pager(&$pager, $path, $parameters){ |
2642 | 2672 |
$out = ''; |
Also available in: Unified diff
#1484 & #1483 : implement footnote framework into data portal & display multiple references for distributions as footnotes in portal