<?php
/*
 *
 * @copyright (c) 2009 animegame.eu
 * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
 *
 */

// Diese Funktion muss in ein Darstellungspackage hinein und muss noch verlegt werden, Gestaltung in css-Datei
function displayUserLink($userid, $username, $clanpre = NULL, $clansu = NULL){
	if($clanpre === NULL && $clansu === NULL){
		return '<a href="index.php?as=info&user_id='.$userid.'">'.$username.'</a>';
	} else{
		return '<a href="index.php?as=info&user_id='.$userid.'">'.$clanpre.' '.$username.' '.$clansu.'</a>';
	}
}

function displayClanLink($clanid, $clanname){
	 return  '<a href="index.php?as=clan/clan_info&clan_id='.$clanid.'">'.$clanname.'</a>';
}

function displayHistoryBackLink(){
	return '<a href="javascript:history.back()" id="content">zur&uuml;ck</a>';
}

function displayIndexBackLink(){
	return '<a href="index.php">zur&uuml;ck</a>';
}

function displayCharLink($charid, $charname, $img = NULL, $clanpre = NULL, $clansu = NUL){
	if($clanpre !== NULL && $clansu !== NULL){
		$charname = $clanpre.' '.$charname.' '.$clansu;
	}
	if($img === NULL){
		return  '<a href="index.php?as=info&charm=1&char_id='.$charid.'">'.$charname.'</a>';
	} else{
		return  '<a href="index.php?as=info&charm=1&char_id='.$charid.'">'.$charname.'<br><img src="'.$img.'" border="0"  width="75" height="75"></a>';
	}
}

function displayItemLink($tablename, $itemid, $itemname){
	if($itemname != 'Geheim!'){
		return  '<a href="index.php?as=info&charm=2&group='.$tablename.'&item_id='.$itemid.'">'.$itemname.'</a>';
	}
	return $itemname;
}

function displayAuktionsLink($kategorie,$itemnamepart,$itemname,$entriesPerSite,$pageNumber,$maxPrice){
	return '<a href="index.php?as=auktion&kategorie='.$kategorie.'&itemname='.$itemnamepart.'&entries='.$entriesPerSite.'&maxpreis='.$maxPrice.'">Hier Klicken um Auktionen des Items '.$itemname.' anzeigen zu lassen!</a>';
}

// Soll die alte displayPagelinks ersetzen
function displayPagelinksNew($entriesPerPage, $totalEntries, $aktualPage, $url){
	$maxPages = ceil($totalEntries/$entriesPerPage);
	return displayPagelinks($aktualPage, $maxPages, $url);
}

function displayPagelinks($aktualPage, $maxPages, $url){
	// Erstmal die link vorher/nachher
	$vorher = '<td align="left" width="0">vorherige Seite</td>';
	$nachher = '<td align="right" width="0">n&auml;chste Seite</td>';
	$puffer = '';
	$search = array('/###PAGE###/','/###LABEL###/');

	if(0 < $aktualPage){
		$vorher = '<td align="left" width="0">'.preg_replace($search,array($aktualPage-1,'vorherige Seite'),$url).'</td>';
	}
	if($maxPages-1 > $aktualPage){
		$nachher = '<td align="right" width="0">'.preg_replace($search,array($aktualPage+1,'n&auml;chste Seite'),$url).'</td>';
	}

	$normalStep = 1;
	$width=0;
	if($maxPages > 50){
		$normalStep = 10;
		$width = 5;
	} else if($maxPages > 30){
		$normalStep = 5;
		$width = 15;
	}
	$min = $aktualPage-$width+1;
	$max = $aktualPage+$width+1;
	for($i=1;$i<=$maxPages;$i++){
		if($i == 1 || $i%$normalStep == 0 || $i >= $min && $i <= $max){
			$puffer.='<td align="center">'.preg_replace($search,Array($i-1,$i),$url).'</td>';
		}
	}
	return '<table width="100%" cellpadding="0" cellspacing="0"><tr>'.$vorher.$puffer.$nachher.'</tr></table>';
}

function displayMoney($value){
	return number_format($value,0,'','.').' &#165;';
}

function displayCount($value){
	return number_format($value,0,'','.');
}

?>