After much frustration I determined what was necessary to have FCKeditor support an arbitrary assets directory (e.g. /documents/aaa/bbb/ccc rather than UserFiles/Image) and/or to break FCK's assumption that it is installed at your webroot.
-------------------
Modifying FCKeditor to support an arbitrary asset (Image, Flash, File, etc) directory location:
File Manager Connector URL:
FCKConfig.ImageBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Image&Connector=connectors/php/connector.php' ;
Fckconfig.js: In the above URL notice the Type=Image. This works by taking the UserFiles directory (configurable, later) and appending the Image string to it. E.g. if your UserFiles directory is /documents/UserFiles/ then the final directory that FCKeditor will look in is:
/documents/UserFiles/Image
Leave off this URL attribute to start at your asset root (eg. /documents/UserFiles/). Notice that the LinkBrowser URL works this way.
Out of the box FCKeditor makes 2 assumptions:
1) FCKeditor is installed in the web root for your site
2) The assets directory is assumed to be UserFiles (off your webroot, e.g. /UserFiles).
To change these assumptions, you will need to modify:
FCKeditor/editor/filemanager/browser/default/connectors/php/config.php
(appropriately modify whichever connector script you are using).
Change this line, in the PHP file it is around line 23:
$Config['UserFilesPath'] = '/chameleon/UserFiles/' ;
So basically specify the absolute asset root (from your sites webroot) without the Type attribute.
Assuming your structure is /chameleon/UserFiles with Image, File, Flash and Media subdirectories you are now ready to go out of the box.
To support additional Types or to have really arbitrary sub-directories, e.g. /chamelon/UserFiles/Products you will need to modify additional files:
Connectors/php/connector.php: (line 54). Add your resource type (e.g. Products) to the array check which makes sure that your type is an allowed type, e..g:
if ( !in_array( $sResourceType, array('File','Image','Flash','Media','Product', 'Gallery', 'foo') ) )
return ;
Here I added Product, Gallery and foo to the allowed list.
Browser/default/frmresourcetype.html:
Around line 30 add your additional types (entries) to the Javascript array. This array serves as the little menu in the top-left of the image/link browser. Each element in the array is another array, which is composed of two entries, the first one is the actual sub-directory name, e.g Product and the second entry is the text that is inserted into the menu, e.g. My Store Products. An example:
var aTypes = [
['File','File'],
['Image','Image'],
['Flash','Flash'],
['Media','Media'],
['foo', 'My Products']
] ;
-------------------
Modifying FCKeditor to support an arbitrary asset (Image, Flash, File, etc) directory location:
File Manager Connector URL:
FCKConfig.ImageBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Image&Connector=connectors/php/connector.php' ;
Fckconfig.js: In the above URL notice the Type=Image. This works by taking the UserFiles directory (configurable, later) and appending the Image string to it. E.g. if your UserFiles directory is /documents/UserFiles/ then the final directory that FCKeditor will look in is:
/documents/UserFiles/Image
Leave off this URL attribute to start at your asset root (eg. /documents/UserFiles/). Notice that the LinkBrowser URL works this way.
Out of the box FCKeditor makes 2 assumptions:
1) FCKeditor is installed in the web root for your site
2) The assets directory is assumed to be UserFiles (off your webroot, e.g. /UserFiles).
To change these assumptions, you will need to modify:
FCKeditor/editor/filemanager/browser/default/connectors/php/config.php
(appropriately modify whichever connector script you are using).
Change this line, in the PHP file it is around line 23:
$Config['UserFilesPath'] = '/chameleon/UserFiles/' ;
So basically specify the absolute asset root (from your sites webroot) without the Type attribute.
Assuming your structure is /chameleon/UserFiles with Image, File, Flash and Media subdirectories you are now ready to go out of the box.
To support additional Types or to have really arbitrary sub-directories, e.g. /chamelon/UserFiles/Products you will need to modify additional files:
Connectors/php/connector.php: (line 54). Add your resource type (e.g. Products) to the array check which makes sure that your type is an allowed type, e..g:
if ( !in_array( $sResourceType, array('File','Image','Flash','Media','Product', 'Gallery', 'foo') ) )
return ;
Here I added Product, Gallery and foo to the allowed list.
Browser/default/frmresourcetype.html:
Around line 30 add your additional types (entries) to the Javascript array. This array serves as the little menu in the top-left of the image/link browser. Each element in the array is another array, which is composed of two entries, the first one is the actual sub-directory name, e.g Product and the second entry is the text that is inserted into the menu, e.g. My Store Products. An example:
var aTypes = [
['File','File'],
['Image','Image'],
['Flash','Flash'],
['Media','Media'],
['foo', 'My Products']
] ;
RE: Supporting an arbistrary UserFiles direct
Sorry... forgot to post the error msg:
For docs:
Line: 1
Char: 21
Error: Expected ')'
Code: 0
URL: http://.../FCKEditor/editor/filemanager ... elist.html
For images:
Line: 1
Char: 27
Error: Expected ')'
Code: 0
URL: http://.../FCKEditor/editor/filemanager ... elist.html
RE: Supporting an arbitrary UserFiles direct
Sorry I dont have any additional help. Good luck.
RE: Supporting an arbistrary UserFiles direct
fckconfig.js:
FCKConfig.LinkBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=docs&Connector=connectors/asp/connector.asp' ;
FCKConfig.ImageBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=images&Connector=connectors/asp/connector.asp' ;
config.asp
ConfigUserFilesPath = "/"
ConfigAllowedExtensions.Add "docs", ""
ConfigDeniedExtensions.Add "docs", "php|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|com|dll|vbs|js|reg"
ConfigAllowedExtensions.Add "images", "jpg|gif|jpeg|png|bmp"
ConfigDeniedExtensions.Add "images", ""
frmresourcetype.html:
var aTypes = [
['docs','Documents/Files'],
['images','Images']
];
Thanks for your help!
RE: Supporting an arbistrary UserFiles direct
frmresourcetype.html:
var aTypes = [
['docs','Documents/Files'],
['images','Images']
];
you're missing a comman following ['images','Images']
RE: Supporting an arbistrary UserFiles direct
RE: Supporting an arbistrary UserFiles direct
I added the following line to the "GetFoldersAndFilesCallBack " function before the oListManager.AddFile line:
sFileName = replace(sFileName,'\'','%27');
Here is the code for the "replace" function:
function replace(string,text,by) {
// Replaces text with by in string
var strLength = string.length, txtLength = text.length;
if ((strLength == 0) || (txtLength == 0)) return string;
var i = string.indexOf(text);
if ((!i) && (text != string.substring(0,txtLength))) return string;
if (i == -1) return string;
var newstr = string.substring(0,i) + by;
if (i+txtLength < strLength)
newstr += replace(string.substring(i+txtLength,strLength),text,by);
return newstr;
}