<?php
if( $a == 'template' ){
	if( isset( $_POST['sOption'] ) ){
		$_POST['swistak_template'] = stripslashes( $_POST['swistak_template'] );
		file_put_contents( $config['dir_templates'] . 'admin/' . LANGUAGE . '_swistak_template.tpl', $_POST['swistak_template'] );
		$oTpl->assign( 'sLink', '?p=' . $p );
		$content.= $oTpl->parse( 'message_done_back.tpl' );
	} else{
		$swistak_template = file_get_contents( $config['dir_templates'] . 'admin/' . LANGUAGE . '_swistak_template.tpl' );
		$oTpl->assign( 'sSwistakTemplate', '<textarea name="swistak_template" id="swistak_template_text">' . htmlspecialchars( $swistak_template ) . '</textarea>' );
		$content.= $oTpl->parse( 'swistak_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 . '_swistak_template.tpl' ) ) . '</textarea>';
	} else{
		$content.= 'Nie wybrano produktu!';
	}
}
?>