﻿__group__	ticket	summary	component	milestone	owner	status	created	version	_changetime	_description	_reporter
New Feature	2622	Automatic dispatching of uploaded files to different folders	General			confirmed	2008-10-29T01:28:05Z	FCKeditor 2.6.3	2008-11-01T10:37:27Z	"I suggest to add an option for automatic dispatching of uploaded files to different folders set in filemanager…config.php file according to the file type. For example, if an image is uploaded as 'FILE', it would be ﻿﻿nevertheless directed to the 'images' folder (if set) and if a new file type such as 'PDF' is created in config.php for file extension 'pdf' with a 'pdf_folder' destination folder, then FileUpload function would send it to this folder.

I patched my version successfully by easily adding just the following two lines of code in filemanager…command.php (and moving down a bit an original one).

Before:
{{{
	if ( isset( $_FILES['NewFile'] ) && !is_null( $_FILES['NewFile']['tmp_name'] ) )
	{
		global $Config ;

		$oFile = $_FILES['NewFile'] ;

		// Map the virtual path to the local server path.
		$sServerDir = ServerMapFolder( $resourceType, $currentFolder, $sCommand ) ;

		// Get the uploaded file name.
		$sFileName = $oFile['name'] ;
		$sFileName = SanitizeFileName( $sFileName ) ;

		$sOriginalFileName = $sFileName ;

		// Get the extension.
		$sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ;
		$sExtension = strtolower( $sExtension ) ;

		if ( isset( $Config['SecureImageUploads'] ) )
		{
			if ( ( $isImageValid = IsImageValid( $oFile['tmp_name'], $sExtension ) ) === false )
			{
				$sErrorNumber = '202' ;
			}
		}
}}}
After:
{{{
	if ( isset( $_FILES['NewFile'] ) && !is_null( $_FILES['NewFile']['tmp_name'] ) )
	{
		global $Config ;

		$oFile = $_FILES['NewFile'] ;

		// Get the uploaded file name.
		$sFileName = $oFile['name'] ;
		$sFileName = SanitizeFileName( $sFileName ) ;

		$sOriginalFileName = $sFileName ;

		// Get the extension.
		$sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ;
		$sExtension = strtolower( $sExtension ) ;

		foreach($Config['ConfigAllowedTypes'] as $type) {	 // #PATCH: automatically dispatch uploaded files
			if($type != 'File' && in_array($sExtension, $Config['AllowedExtensions'][$type])) {
				$resourceType = $type;
			}
		}

		// Map the virtual path to the local server path. #PATCH: moved down
		$sServerDir = ServerMapFolder( $resourceType, $currentFolder, $sCommand ) ; // #HACK: original line moved down

		if ( isset( $Config['SecureImageUploads'] ) )
		{
			if ( ( $isImageValid = IsImageValid( $oFile['tmp_name'], $sExtension ) ) === false )
			{
				$sErrorNumber = '202' ;
			}
		}
}}}
filemanager…config.php sample:
{{{
// Allowed Resource Types.
$Config['ConfigAllowedTypes'] = array('File', 'Image', 'Flash', 'Media', 'PDF') ;
…
$Config['AllowedExtensions']['File']	= array('7z', 'csv', 'doc', 'gz', 'gzip', 'ods', 'odt', 'ppt', 'pxd', 'rar', 'rtf', 'sdc', 'sitd', 'sxc', 'sxw', 'tar', 'tgz', 'txt', 'vsd', 'xls', 'xml', 'zip') ;
$Config['DeniedExtensions']['File']	= array() ;
$Config['FileTypesPath']['File']	= $Config['UserFilesPath'] . 'misc/' ;
…
$Config['AllowedExtensions']['Image']	= array('bmp','gif','jpeg','jpg','png') ;
$Config['DeniedExtensions']['Image']	= array() ;
$Config['FileTypesPath']['Image']	= $Config['UserFilesPath'] . 'images/' ;
…
$Config['AllowedExtensions']['Flash']	= array('swf','fla', 'flv') ;
$Config['DeniedExtensions']['Flash']	= array() ;
$Config['FileTypesPath']['Flash']	= $Config['UserFilesPath'] . 'flash/' ;
…
$Config['AllowedExtensions']['Media']	= array('aiff', 'asf', 'avi', 'mid', 'mov', 'mp3', 'mp4', 'mpc', 'mpeg', 'mpg', 'qt', 'ram', 'rm', 'rmi', 'rmvb', 'tif', 'tiff', 'wav', 'wma', 'wmv') ;
$Config['DeniedExtensions']['Media']	= array() ;
$Config['FileTypesPath']['Media']	= $Config['UserFilesPath'] . 'media/' ;
…
$Config['AllowedExtensions']['PDF']	= array('pdf') ;
$Config['DeniedExtensions']['PDF']	= array() ;
$Config['FileTypesPath']['PDF']		= $Config['UserFilesPath'] . 'pdf/' ;
}}}
"	Ralph
New Feature	2232	Send the current element values as parameters to the FileBrowser (link dialog)	UI : Dialogs			confirmed	2008-05-28T09:16:08Z	FCKeditor 2.6	2008-05-28T09:25:45Z	"In the link dialog, upon a click on ""Browse Server"" the current FCKeditor simply calls a uri defined by the configuration value
{{{
FCKConfig.LinkBrowserURL = ""..."" ;
}}}

Assume we defined a custom link browser. Of course we could use in our custom link browser the javascript command
{{{
opener.GetE(""txtUrl"").value
}}}
to access the current value given in the url textfield of the link dialog. But this is a client side action. Wouldn't it be great to have also a server-side possibility to know the current value?

I propose the following: Add some keys (placeholders) to the LinkBrowserURL which then gets replaced by the current values.
{{{
FCKConfig.LinkBrowserURL = ""custom.php?url=URL&proto=PROTOCOL"" ;
}}}

Implementation: It is easy to implement this feature. In the file ""editor/dialog/fck_link/fck_link.js"" replace
{{{
function BrowseServer()
{
	OpenFileBrowser( FCKConfig.LinkBrowserURL, FCKConfig.LinkBrowserWindowWidth, FCKConfig.LinkBrowserWindowHeight ) ;
}
}}}
by
{{{
function BrowseServer()
{
	var uri = FCKConfig.LinkBrowserURL ;
	uri = uri.replace( /URL/g, encodeURIComponent(GetE(""txtUrl"").value) ) ;
	uri = uri.replace( /PROTOCOL/g, encodeURIComponent(GetE(""cmbLinkProtocol"").value) ) ;

	OpenFileBrowser( uri, FCKConfig.LinkBrowserWindowWidth, FCKConfig.LinkBrowserWindowHeight ) ;
}
}}}

"	Adrian Suter
New Feature	1563	CSS Table Support (Code Attached)	General			confirmed	2007-11-24T20:55:05Z	FCKeditor 2.5	2010-12-28T11:13:34Z	"My site uses css to define some default tables. fckEditor  table dialog can not overwrite the css system, because the css has prioiry over html atributes.
We have recoded the table dialogs to add css rules dynamicly to the page. Files attached with code and screen dumps."	K Rasmussen
