<?php
if( $a == 'template' ){
	if( isset( $_POST['sOption'] ) ){
		$_POST['ebay_template'] = stripslashes( $_POST['ebay_template'] );
		file_put_contents( $config['dir_templates'] . 'admin/' . LANGUAGE . '_ebay_template.tpl', $_POST['ebay_template'] );
		$oTpl->assign( 'sLink', '?p=' . $p );
		$content.= $oTpl->parse( 'message_done_back.tpl' );
	} else{
		$ebay_template = file_get_contents( $config['dir_templates'] . 'admin/' . LANGUAGE . '_ebay_template.tpl' );
		$oTpl->assign( 'sEbayTemplate', '<textarea name="ebay_template" id="ebay_template_text">' . htmlspecialchars( $ebay_template ) . '</textarea>' );
		$content.= $oTpl->parse( 'ebay_config_template.tpl' );
	}
} elseif( ( $a == 'products_form' ) ){
	if( isset( $_GET['iProduct'] ) && is_numeric( $_GET['iProduct'] ) ){
		$aProduct = $oProduct->throwProduct( $_GET['iProduct'] );
		$aFiles = $oFile->aFiles[2][$aProduct['iProduct']];
		foreach( $aFiles as $iType => $aFilesType ) foreach( $aFilesType as $aFile ){
			if( $aFile['iPhoto'] ) $aProduct['aFiles'][] = $aFile;
		}
		if( empty( $aProduct['sDescriptionFull'] ) ) $aProduct['sDescriptionFull'] = $aProduct['sDescriptionShort'];
		$oTpl->assign( 'sTitle', $aProduct['sName'] );
		$oTpl->assign( 'sDescription', $aProduct['sDescriptionFull'] );
		$oTpl->assign( 'aAttributes', $aProduct['aAttributes'] );
		$oTpl->assign( 'aGallery', $aProduct['aFiles'] );
		$content.= '<textarea cols="80" rows="30" style="width: 100%">' . htmlspecialchars( $oTpl->parse( LANGUAGE . '_ebay_template.tpl' ) ) . '</textarea>';
	} else{
		$content.= 'Nie wybrano produktu!';
	}
}
?>