Revision 65a4de51
Added by Patrick Plitzner about 8 years ago
- Use Link class for every link
- Open all links in new window
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