(Description for PHP, but perhaps you can adopt it to other adapters/languages)
The default behavior of the filebrowser is that it will search for files in a directory named like their filetype:
file: "File"
image: "Image"
flash: "Flash"
media: "Media"
If you, like me, don't like this behavior, you can change the code so that you can specify whether to use a different folder for each filetype and what folder that should be.
Config options are:
// Set directory per file type
// Leave any setting empty to work in your 'UserFilesPath' for that filetype.
$Config['FileTypeDirectories']['File'] = "myFiles";
$Config['FileTypeDirectories']['Image'] = "";
$Config['FileTypeDirectories']['Flash'] = "exampleDir";
$Config['FileTypeDirectories']['Media'] = "";
So start by adding these below in the config file of your filebrowser ('editor/filemanager/browser/default/connectors/php/config.php').
Then change the 'io.php' ('filemanager/browser/default/connectors/php/io.php') file to let it work with the config settings:
Change the function GetUrlFromPath from:
function GetUrlFromPath( $resourceType, $folderPath )
{
if ( $resourceType == '' )
return RemoveFromEnd( $GLOBALS["UserFilesPath"], '/' ) . $folderPath ;
else
return $GLOBALS["UserFilesPath"] . strtolower( $resourceType ) . $folderPath ;
}
to:
function GetUrlFromPath( $resourceType, $folderPath )
{
global $Config ;
if ( $Config['FileTypeDirectories'][$resourceType] == '' )
return RemoveFromEnd( $GLOBALS["UserFilesPath"], '/' ) . $folderPath ;
else
return $GLOBALS["UserFilesPath"] . $Config['FileTypeDirectories'][$resourceType] . $folderPath ;
}
and change the function ServerMapFolder from:
function ServerMapFolder( $resourceType, $folderPath )
{
// Get the resource type directory.
$sResourceTypePath = $GLOBALS["UserFilesDirectory"] . strtolower( $resourceType ) . '/' ;
// Ensure that the directory exists.
CreateServerFolder( $sResourceTypePath ) ;
// Return the resource type directory combined with the required path.
return $sResourceTypePath . RemoveFromStart( $folderPath, '/' ) ;
}
to:
function ServerMapFolder( $resourceType, $folderPath )
{
global $Config ;
// Get the resource type directory.
$sResourceTypePath = $GLOBALS["UserFilesDirectory"] . $Config['FileTypeDirectories'][$resourceType] . '/' ;
// Ensure that the directory exists.
CreateServerFolder( $sResourceTypePath ) ;
// Return the resource type directory combined with the required path.
return $sResourceTypePath . RemoveFromStart( $folderPath, '/' ) ;
}
That's all!
The default behavior of the filebrowser is that it will search for files in a directory named like their filetype:
file: "File"
image: "Image"
flash: "Flash"
media: "Media"
If you, like me, don't like this behavior, you can change the code so that you can specify whether to use a different folder for each filetype and what folder that should be.
Config options are:
// Set directory per file type
// Leave any setting empty to work in your 'UserFilesPath' for that filetype.
$Config['FileTypeDirectories']['File'] = "myFiles";
$Config['FileTypeDirectories']['Image'] = "";
$Config['FileTypeDirectories']['Flash'] = "exampleDir";
$Config['FileTypeDirectories']['Media'] = "";
So start by adding these below in the config file of your filebrowser ('editor/filemanager/browser/default/connectors/php/config.php').
Then change the 'io.php' ('filemanager/browser/default/connectors/php/io.php') file to let it work with the config settings:
Change the function GetUrlFromPath from:
function GetUrlFromPath( $resourceType, $folderPath )
{
if ( $resourceType == '' )
return RemoveFromEnd( $GLOBALS["UserFilesPath"], '/' ) . $folderPath ;
else
return $GLOBALS["UserFilesPath"] . strtolower( $resourceType ) . $folderPath ;
}
to:
function GetUrlFromPath( $resourceType, $folderPath )
{
global $Config ;
if ( $Config['FileTypeDirectories'][$resourceType] == '' )
return RemoveFromEnd( $GLOBALS["UserFilesPath"], '/' ) . $folderPath ;
else
return $GLOBALS["UserFilesPath"] . $Config['FileTypeDirectories'][$resourceType] . $folderPath ;
}
and change the function ServerMapFolder from:
function ServerMapFolder( $resourceType, $folderPath )
{
// Get the resource type directory.
$sResourceTypePath = $GLOBALS["UserFilesDirectory"] . strtolower( $resourceType ) . '/' ;
// Ensure that the directory exists.
CreateServerFolder( $sResourceTypePath ) ;
// Return the resource type directory combined with the required path.
return $sResourceTypePath . RemoveFromStart( $folderPath, '/' ) ;
}
to:
function ServerMapFolder( $resourceType, $folderPath )
{
global $Config ;
// Get the resource type directory.
$sResourceTypePath = $GLOBALS["UserFilesDirectory"] . $Config['FileTypeDirectories'][$resourceType] . '/' ;
// Ensure that the directory exists.
CreateServerFolder( $sResourceTypePath ) ;
// Return the resource type directory combined with the required path.
return $sResourceTypePath . RemoveFromStart( $folderPath, '/' ) ;
}
That's all!
RE: HOWTO - folder per filetype for filebrowser
RE: HOWTO - folder per filetype for filebrows
function ServerMapFolder( $resourceType, $folderPath )
{
global $Config ;
// Get the resource type directory.
$sResourceTypePath = $GLOBALS["UserFilesDirectory"] . $Config['FileTypeDirectories'][$resourceType] . '/' ;
// Ensure that the directory exists.
$sErrorMsg = CreateServerFolder( $sResourceTypePath ) ;
if ( $sErrorMsg != '' )
{
if ( isset( $GLOBALS['HeaderSent'] ) && $GLOBALS['HeaderSent'] )
{
SendErrorNode( 1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})" ) ;
CreateXmlFooter() ;
exit ;
}
else
{
SendError( 1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})" ) ;
}
}
// Return the resource type directory combined with the required path.
return $sResourceTypePath . RemoveFromStart( $folderPath, '/' ) ;
}