Revision 65a4de51
Added by Patrick Plitzner over 7 years ago
- Use Link class for every link
- Open all links in new window
modules/cdm_dataportal/includes/occurrences.inc | ||
---|---|---|
98 | 98 |
} |
99 | 99 |
$derivateDataDTO = $preservedSpecimenDTO->derivateDataDTO; |
100 | 100 |
// - specimen scans |
101 |
$specimenScans = create_links($derivateDataDTO->specimenScans);
|
|
101 |
$specimenScans = create_html_links($derivateDataDTO->specimenScans, true);
|
|
102 | 102 |
// - molecular data |
103 | 103 |
$molecularData = ""; |
104 | 104 |
if ($derivateDataDTO->molecularDataList) { |
105 | 105 |
foreach ($derivateDataDTO->molecularDataList as $molecular) { |
106 | 106 |
//provider link |
107 | 107 |
if (isset($molecular->providerLink)) { |
108 |
$molecularData .= create_html_link($molecular->providerLink); |
|
108 |
$molecularData .= create_html_link($molecular->providerLink, true);
|
|
109 | 109 |
} |
110 | 110 |
//contig link |
111 | 111 |
if (isset($molecular->contigFiles[0])) {//FIXME check if empty |
... | ... | |
114 | 114 |
foreach ($molecular->contigFiles as $contigFile) { |
115 | 115 |
if (isset($contigFile->contigLink)){ |
116 | 116 |
if(isset($contigFile->contigLink->uri) and $contigFile->contigLink->uri!=null) { |
117 |
$molecularData .= create_html_link($contigFile->contigLink)." "; |
|
117 |
$molecularData .= create_html_link($contigFile->contigLink, true)." ";
|
|
118 | 118 |
} |
119 | 119 |
//primer links |
120 |
$molecularData .= create_html_links($contigFile->primerLinks); |
|
120 |
$molecularData .= create_html_links($contigFile->primerLinks, true);
|
|
121 | 121 |
} |
122 | 122 |
} |
123 | 123 |
} else { |
... | ... | |
130 | 130 |
} |
131 | 131 |
} |
132 | 132 |
// - detail images |
133 |
$detailImages = create_links($derivateDataDTO->detailImages);
|
|
133 |
$detailImages = create_html_links($derivateDataDTO->detailImages, true);
|
|
134 | 134 |
|
135 | 135 |
if ($types) { |
136 | 136 |
$detail_html .= $isSpecimenPage?"<br>":""; |
modules/cdm_dataportal/includes/pages.inc | ||
---|---|---|
353 | 353 |
return $render_array; |
354 | 354 |
} |
355 | 355 |
|
356 |
function create_html_link($link){ |
|
356 |
function create_html_link($link, $openInExternalWindow=false){
|
|
357 | 357 |
$html = ""; |
358 |
if($link->uri!=""){ |
|
359 |
$html .= '<a href="' . $link->uri . '">' . $link->linkText . "</a>"; |
|
358 |
if($link->uri && $link->uri!=""){ |
|
359 |
$html .= '<a href="' . $link->uri . '"'; |
|
360 |
if($openInExternalWindow){ |
|
361 |
$html .= ' target="_blank"'; |
|
362 |
} |
|
363 |
$html .= '>' . $link->linkText . '</a>'; |
|
360 | 364 |
} |
361 | 365 |
else{ |
362 | 366 |
$html .= $link->linkText; |
... | ... | |
365 | 369 |
} |
366 | 370 |
|
367 | 371 |
/** |
368 |
* Creates HTML links from the given link list concatenated by a white space.
|
|
372 |
* Creates HTML links from the given link list concatenated by default by a comma.
|
|
369 | 373 |
* @param $linkList the list with Link objects having "uri" and "linkText" as members |
370 | 374 |
* @return string the assembled HTML string containing the links |
371 | 375 |
*/ |
372 |
function create_html_links($linkList) |
|
376 |
function create_html_links($linkList, $openInExternalWindow=false, $separator=", ")
|
|
373 | 377 |
{ |
374 | 378 |
$html = ""; |
375 | 379 |
if ($linkList) { |
376 | 380 |
foreach ($linkList as $link) { |
377 |
$html .= create_html_link($link)." ";
|
|
381 |
$html .= create_html_link($link, $openInExternalWindow).$separator;
|
|
378 | 382 |
} |
383 |
$html = rtrim($html, $separator); |
|
379 | 384 |
} |
380 | 385 |
return $html; |
381 | 386 |
} |
382 | 387 |
|
383 |
/** |
|
384 |
* Creates HTML links from the given pair list concatenated by a white space. |
|
385 |
* @param $linkTextPairList the list with pairs which hold the uri as "first" and uriText as "second" |
|
386 |
* @return string the assembled HTML string containing the links |
|
387 |
*/ |
|
388 |
function create_links($linkTextPairList) |
|
389 |
{ |
|
390 |
$html = ""; |
|
391 |
if ($linkTextPairList) { |
|
392 |
foreach ($linkTextPairList as $linkTextPair) { |
|
393 |
if($linkTextPair->first!=""){ |
|
394 |
$html .= '<a href="' . $linkTextPair->first . '">' . $linkTextPair->second . ", </a>"; |
|
395 |
} |
|
396 |
else{ |
|
397 |
$html .= $linkTextPair->second.", "; |
|
398 |
} |
|
399 |
} |
|
400 |
} |
|
401 |
$html = rtrim($html, ", "); |
|
402 |
return $html; |
|
403 |
} |
|
404 | 388 |
/** |
405 | 389 |
* Composes a taxon page which can consist of multiple parts like |
406 | 390 |
* 'General', 'Synonymy', 'Images', 'Keys'. These parts can be displayed |
Also available in: Unified diff