<?php
if( $a == 'template' ){
	if( isset( $_POST['sOption'] ) ){
		$_POST['allegro_template'] = stripslashes( $_POST['allegro_template'] );
		file_put_contents( $config['dir_templates'] . 'admin/' . LANGUAGE .'_allegro_template.tpl', $_POST['allegro_template'] );
		$oTpl->assign( 'sLink', '?p=' . $p );
		$content.= $oTpl->parse( 'message_done_back.tpl' );
	} else{
		$allegro_template = file_get_contents( $config['dir_templates'] . 'admin/' . LANGUAGE . '_allegro_template.tpl' );
		$oTpl->assign( 'sAllegroTemplate', '<textarea name="allegro_template" id="allegro_template_text">' . htmlspecialchars( $allegro_template ) . '</textarea>' );
		$content.= $oTpl->parse( 'allegro_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'] );
		$oTpl->assign( 'userID', $config['allegro_uid'] );
		$content.= '<textarea cols="80" rows="30" style="width: 100%">' . htmlspecialchars( $oTpl->parse( LANGUAGE . '_allegro_template.tpl' ) ) . '</textarea>';
	} else{
		$content.= 'Nie wybrano produktu!';
	}
}
?>