<?php
// Helper for preparation of author names
$names = explode(";", $this->authors);

$nameout = '';
foreach ($names as $name)  {
        $lastName = explode(",", $name);
        $nameout .= '<span style="font-variant: small-caps;">' .trim($lastName[0]) .'</span>, ' .trim($lastName[1]) ;
        $nameout .= "; ";
}

if (strlen($nameout) > 2) $nameout = substr($nameout, 0 , strlen($nameout) - 2);
if (strcmp($this->role, "edt") == 0) {
        $nameout .= " (Hrsg.):";
   } else{
        // $nameout .= ":";
}

// Offene Zusammenhänge : Open Access in der Berufsbildungsforschung /Hubert Ertl [Hrsg.]; Bodo Rödel [Hrsg.]

$seriesout = ''; 
$pos = strrpos($journal,"/"); 

if ($pos !== false)  {
	$vol  = str_replace(" :",".", substr($journal,0, $pos-1));
	$authors = str_replace(["[","]"], ["(",")"],substr($journal, $pos+1)); 
	$au = explode(";",$authors);
	$editorSwitch = false;
	$authors = "";
	foreach ($au as $author)   {
		// Abtrennen Funktionsbezeichnung
		$pos = strpos($author,"(");
		if ($pos !== false) {
			$editorSwitch = true;
			$author = trim(substr($author,0,$pos-1));
		}
		// Name und Vorname drehen
		$a = explode(" ",$author);
		if (count($a) >= 1)  {
			$author = '<span style="font-variant: small-caps;">' .$a[1] .", " .substr($a[0],0,1) .'.</span>';
		}
		$authors .= $author ."; ";
	}
	$authors = substr($authors, 0, strlen($authors) - strlen("; ")); 
	if ($editorSwitch == true)    {
		$authors .= " (Hrsg.): ";
	}
   } else {
	$vol = $journal; 
	$authors = '';
}
?>

<?php if (!empty($this->authors)): ?><?=$nameout?> <?php endif; ?> 
<?php if (!empty($this->title)) : ?><?=$this->escapeHtml($this->title)?><?php if ($this->periodAfterTitle): ?><?php endif; ?><?php endif; ?>

<!--<span style="font-style:italic;"> -->
	In:
        <?= $authors ?> <?= trim(str_replace(array(":", ","), array("&ndash;",""),$vol)) ?>
        <?php if (!empty($this->volume) || !empty($vol)): ?> <?php endif; ?>
<!-- </span> -->
<?php if (!empty($this->issue)): ?>
        (
                <?=$this->escapeHtml($this->issue)?>
        )
<?php endif; ?>
<?php if (!empty($this->volume) || !empty($this->issue)): ?>
<?php endif; ?>
<?php if (!empty($this->pubPlace)) : ?><?=$this->escapeHtml($this->pubPlace)?> <?php endif; ?>
<?php if (!empty($this->volume)): ?><?=$this->escapeHtml(str_replace(array("H.",",") ,array("",""),$this->volume))?>, <?php endif; ?>
<?php if (empty($this->volume)) : ?> <?php if (!empty($this->year)) : ?> <?=$this->escapeHtml($this->year)?> <?php endif; ?> <?php endif; ?> 
<?php if (!empty($this->pageRange)) : ?> <?=$this->escapeHtml(str_replace("Seite","S.",$this->pageRange))?><?endif ; ?>
<?php if (isset($this->doi)): ?>. doi:<?=$this->escapeHtml($this->doi)?><?php endif; ?>

