<?php
//=================================================================
// getNavigationPath
// erzeugt einen pfad zur aktuellen position
// ausgangspunkt --> ... --> aktuelle position -->>
//=================================================================
function getNavigationPath($id, $table, $link, $key, $idtype, $nametype, $result = null, $extra = 0, $nav_op="0", $p="0", $parent_give="Parent_Id", $textra="", $main_link='', $linkname='')
{
$sqlextra = '';
	$LC = $_SESSION['Langcode'];
	$p = $_REQUEST['p']; 
	$l = (isset($_REQUEST['limit']) && !empty($_REQUEST['limit']) && is_numeric($_REQUEST['limit']) && $_REQUEST['limit']>0) ? $_REQUEST['limit'] : 10; 
 
	//=================================================================
	// Daten des aktuellen bereichs
    //=================================================================
	$Lc = $_SESSION['Langcode'];
	$q_item = "SELECT Name_1 as DefName, Name_{$Lc} as Name, $idtype, $nametype, $parent_give FROM " . PREFIX . "_$table WHERE $idtype = '$id'";
	$r_item = $GLOBALS['db']->Query($q_item);
    $item = $r_item->fetchrow(); 
	if(is_object($item) && !$item->$nametype) $item->$nametype = $item->DefName;
	
	$esn  = (is_object($item)) ? $item->$parent_give : '';
	
	if(is_object($item))
	{
		//=================================================================
		// Rekursion abgeschlossen
		//=================================================================
		if ($item->$parent_give == 0)
		{
			$item->$nametype = koobispecialchars($item->$nametype);
			switch($p)
			{
				case 'shop':
					return "<a href='index.php?p={$link}'>" . $textra . "</a>" . $GLOBALS['config_vars']['PageSep'] . "<a title='" . $item->$nametype . "' href='index.php?p={$link}&amp;action=showproducts&amp;{$key}=" . $item->$idtype . "&amp;page=1&amp;limit=$l&amp;t=" . seotitle($item->$nametype) . "'>" . $item->$nametype . "</a>" . $result;
				break;
				
				case 'gallery': 
					$GalInf = $GLOBALS['db']->RowQuery("SELECT Id,Name_{$LC} AS Name FROM " . PREFIX . "_galerie_kategorien WHERE Id = '" . $_REQUEST['categ'] . "'");
					return "<a href='index.php?p={$link}&amp;area=" . AREA . "'>" . $textra . "</a>" . $GLOBALS['config_vars']['PageSep'] . '<a href="index.php?p=gallery&amp;action=showincluded&amp;categ=' . @$GalInf->Id . '&amp;name=' . @seotitle($GalInf->Name) . '&amp;area=' . AREA . '">' . @koobispecialchars($GalInf->Name) . '</a>' . $GLOBALS['config_vars']['PageSep']. "<a title='" . $item->$nametype . "' href='index.php?p={$link}&amp;{$key}=" . $item->$idtype . "&amp;categ=" . @$GalInf->Id . "&amp;name=".seotitle($item->Name)."&amp;area=" . AREA . "'>" . $item->$nametype . "</a>" . $result;
				break;
				
				case 'faq': 
					$GalInf = $GLOBALS['db']->RowQuery("SELECT Id,Name_{$LC} AS Name FROM " . PREFIX . "_faqn WHERE Id = '" . $_REQUEST['faq_id'] . "'");
					return "<a href='index.php?p={$link}&amp;area=" . AREA . "'>" . $GLOBALS['config_vars']['Faq'] . "</a>" . $GLOBALS['config_vars']['PageSep'] . "<a href='index.php?p={$link}&amp;{$key}=" . $item->$idtype . "&amp;area=" . AREA . "&amp;name=".seotitle($item->Name)."'>" . $item->$nametype . "</a>" . $result;
				break;
				
				case '':
				default:
					return "<a href='index.php?p={$link}'>" . $textra . "</a>" . $GLOBALS['config_vars']['PageSep'] . "<a href='index.php?p={$link}&amp;{$key}=" . $item->$idtype . "&amp;name=".seotitle($item->Name)."'>" . $item->$nametype . "</a>" . $result;
				break;
			}
		} 
		
		//=================================================================
		// Daten des Darueberliegenden Bereiches
		//=================================================================
		$item->$nametype = koobispecialchars($item->$nametype);
		if ($extra == 1) $sqlextra = ", $parent_give";
		$q_parent  = "SELECT Name_1 as DefName, Name_{$Lc} as Name, $idtype, $nametype  $sqlextra FROM " . PREFIX . "_$table WHERE $idtype = " . $item->$parent_give;
		$r_parent  = $GLOBALS['db']->Query($q_parent);
		$parent    = $r_parent->fetchRow();
		if(!$parent->$nametype) $parent->$nametype = $parent->DefName;
		
		if($extra == 1) $bextra = "&amp;parent=$parent->Id";
		
		switch($p)
		{
			case 'shop':
				$result = $GLOBALS['config_vars']['PageSep'] . "<a title='" . $item->$nametype . "' href='index.php?p={$link}&amp;action=showproducts&amp;{$key}=" . $item->$idtype . "&amp;page=1&amp;limit=$l&amp;t=" . seotitle($item->$nametype) . "'>" . $item->$nametype . "</a>" . $result;
			break;
			
			case 'gallery':
				$GalInf = $GLOBALS['db']->RowQuery("SELECT Id,Name_{$LC} AS Name FROM " . PREFIX . "_galerie_kategorien WHERE Id = '" . $_REQUEST['categ'] . "'");
				$result = $GLOBALS['config_vars']['PageSep'] . "<a title='" . $item->$nametype . "' href='index.php?p={$link}&amp;{$key}=" . $item->$idtype . "&amp;categ=" . @$GalInf->Id . "&amp;name=".seotitle($item->Name)."&amp;area=" . AREA . "'>" . $item->$nametype . "</a>" . $result;
			break;
			
		
			case '':
			default:
				$result = $GLOBALS['config_vars']['PageSep'] . "<a title='" . $item->$nametype . "' href='index.php?p={$link}&amp;{$key}=" . $item->$idtype . "&amp;name=".seotitle($item->Name)."'>" . $item->$nametype . "</a>" . $result;
			break;
		}
		
	
		return getNavigationPath($item->$parent_give, $table, $link, $key, $idtype, $nametype, $result, $extra, $nav_op, $p, $parent_give, $textra);
	}
}







//=================================================================
// getNavigationptitle
// erzeugt einen seitentitel zur aktuellen position
//=================================================================
//$id, $table, $link, $key, $idtype, $nametype, $result = null, $extra = 0, $nav_op="0", $p="0", $parent_give="Parent_Id")
function getNavigationptitle($id, $table, $link, $key, $idtype, $nametype, $result = null)
{

    $q_item = "SELECT $idtype, $nametype, parent_id FROM " . PREFIX . "_$table WHERE $idtype = $id";
    $r_item = $GLOBALS['db']->Query($q_item);
    $item = $r_item->fetchrow();

    if (@$item->parent_id == 0) return @$item->$nametype . $result;

    $q_parent = "SELECT $idtype, $nametype FROM " . PREFIX . "_$table WHERE $idtype = " . $item->parent_id;
    $r_parent = $GLOBALS['db']->Query($q_parent);
    $parent = $r_parent->fetchRow();

    $result = $GLOBALS['config_vars']['PageSep'] . $item->$nametype . $result;

    return getNavigationptitle($item->parent_id, $table, $link, $key, $idtype, $nametype, $result);
} 

?>