<?
  $openUrl = $this->openUrl($this->driver, 'record');
  $openUrlActive = $openUrl->isActive();
  // Account for replace_other_urls setting
  $urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
  $title = $this->driver->getMainTitle() ;
  $id   =  $this->driver->getUniqueID(); 
//  $data = $this->driver->getRawData();
/*  if (isset($data['rightsuri']))  {
	$license =  $data['rightsuri'];
  	$parts = explode("/", $license[0]);
  	$rightsImage = '';
 	if (isset($parts) && count($parts) > 1)   {
        	  $rightsImage = "/vufind/themes/bibb/images/".$parts[4].".png";
  	}
   }
*/
//  if ($title) $title = trim(strstr($title,":", true));

 
?>
<? if (!empty($urls) || $openUrlActive): ?>

  <? foreach ($urls as $current): ?>
    <? if (strncmp($current['url'],"https://bibb-dspace.bibb.de/handle", strlen("https://bibb-dspace.bibb.de/handle")) == 0) : ?>
        <? continue; ?>
    <?endif ; ?>
    <? if (strncmp($current['url'],"https://bibb-dspace.bibb.de/jspui/handle", strlen("https://bibb-dspace.bibb.de/jspui/handle")) == 0) : ?>
        <? continue; ?>
    <?endif ; ?>

    <? if (strncmp($current['url'],"https://bibb-dspace.bibb.de/rest/bitstreams", strlen("https://bibb-dspace.bibb.de/rest/bitstreams")) == 0) : ?>
	<? $current['desc'] = "Volltext"; ?> 
    <?endif ; ?>


    <? //Looking for "(" and ")" and separation of the link and the label MUST be located here!! ?>
    <? if (($start = strrpos($current['url'], "(")) !== false) : ?>
        <? $current['desc'] = substr($current['url'],$start+1, strrpos($current['url'],")") - $start -1) ; ?>
        <? $current['url']  = trim(substr($current['url'],0, $start)); ?>
    <? endif; ?>

    <? if (($start = strrpos($current['url'], "[")) !== false) : ?>
        <? $current['desc'] = substr($current['url'],$start+1, strrpos($current['url'],"]") - $start -1) ; ?>
        <? $current['url']  = trim(substr($current['url'],0, $start)); ?>
    <? endif; ?>

    <? if (strncmp($current['url'],"www.bibb.de", strlen("www.bibb.de")) == 0) : ?>
	<? $current['url'] = "https://" .$current['url']; ?>
    <? endif; ?>

   <? if (strncmp(strtolower($current['url']),"http://dx.doi.org/", strlen("http://dx.doi.org/")) == 0) : ?>
        <? $current['url'] = "https://doi.org/" .urlencode(trim(substr($current['url'], strlen("http://dx.doi.org/")))) ; ?>
        <? $current['desc'] = "DOI"; ?>
    <? endif; ?>

   <? if (strncmp(strtolower($current['url']),"doi:", strlen("doi:")) == 0) : ?>
        <? $current['url'] = "https://doi.org/" .urlencode(trim(substr($current['url'], strlen("doi:")))) ; ?>
        <? $current['desc'] = "DOI"; ?>
    <? endif; ?>

   <? if (strncmp($current['url'],"http://dispatch.opac.d-nb.de/", strlen("http://dispatch.opac.d-nb.de/")) == 0) : ?>
        <? $current['url'] = "https://zdb-katalog.de/list.xhtml?t=" .urlencode("\"" .$title ."\"")  ."&key=tit" ; ?>
        <? $current['desc'] = "\"" .$title ."\" in der ZDB"; ?>
    <? endif; ?>

    <? if (strncmp($current['url'],"urn:nbn:de:", strlen("urn:nbn:de:")) == 0) : ?>
	<? $current['url'] = "http://nbn-resolving.org/" .urlencode($current['url']) ; ?>
	<? $current['desc'] = "URN"; ?> 
    <? endif; ?>

    <a href="<?=$this->escapeHtmlAttr(trim($this->proxyUrl($current['url'])))?>"><?=$this->escapeHtml($current['desc'])?></a> &nbsp; &nbsp;

    <? if (strlen($rightsImage))  : ?>
                <img src="<?= $rightsImage ?>" alt="License" style="zoom: 0.18" name="<? echo $this->escapeHtmlAttr($this->driver->getUniqueID())?>"
 onmouseover="this.style.zoom='0.22'" onmouseout="this.style.zoom='0.18'" />
	  <? $rightsImage = ''; ?>
    <? endif; ?>
    <br />
    &nbsp;&nbsp; 
    <a class="feedbackLink" style="color: #14416b; font-size: 13px;" data-lightbox href="<?=$this->url('feedback-home') ."?function=feedback&comments=Titel: " .urlencode($title) ." (ID: " .$id ."): Link ist nicht korrekt!" ?>"> <i class="fa fa-chain-broken" aria-hidden="true"></i> <?=$this->transEsc('Report broken link')?></a>
    <br />
  <? endforeach; ?>
  <? if ($openUrlActive): ?>
    <?=$openUrl->renderTemplate()?><br/>
  <? endif; ?>
<? endif; ?>
