I installed the FC with the mcpuk filebrowser and the coldfusion connector.
Everything works ok, except: - At first I only could upload image files. I changed the cffile accept attribute so that all files can be uploaded, but now no icons are displayed in the filebrowser.
Has anyone got the filebrowser up and running with the coldfusion connector?
I can reproduce the following problem: 1. Open the mcpuk browser 2. Click Browse and select a file to upload. 3. Click Upload. The upload is successful. 4. Click the text area at the bottom, where the filename is displayed. Or click the Browse button again. 5. That text area expands to cover the Browse and Upload buttons. To use them, you have to close and re-open the editor.
you can easily add a link to your thumbnails, using a new var in config file (in php) like $fckphp_config['urlthumbsprefix']='xxxxxx'; it can be a complete url. Then you just have to change some things in Thumbnails.php
in the config.php I have: $fckphp_config['urlthumbsprefix']="/UserFiles/Thumbs/1";
in the Thumbnail.php I changed this function: function Thumbnail($fckphp_config,$type,$cwd) { $this->fckphp_config=$fckphp_config; $this->type=$type; $this->raw_cwd=$cwd; $this->actual_cwd=str_replace("//","/",($fckphp_config['urlthumbsprefix']."/$type/".$this->raw_cwd)); $this->real_cwd=str_replace("//","/",($this->fckphp_config['basedir']."/".$this->actual_cwd)); $this->filename=str_replace(array("..","/"),"",$_GET['FileName']); }
On the server I created UserFiles/Thumbs/1 and CMOD the dir to 777
However when I upload an image it creates the Thumb in UserFiles/Users/1/images/
but the thumb does not display in the browser window, so I think that the file browser is trying to pull the thumb from the new location: UserFiles/Thumbs/1/
I have struggled it seemed like forever trying to set up the correct paths and kept getting an oNode javascript error. I finally discovered that if you have any auto_append or auto_prepend (probably the culprit) values set on your server using PHP, you'll have major problems getting this to work.
put an .htaccess file in your directory with these lines in it: php_value auto_append_file none php_value auto_prepend_file none
Hope this saves someone the time I spent to figure this out. pj
I am not able to list directories with special characters like "" or "" in their name. It even more, I also cannot list directories containing a directory or file with a special char in their name. Is there any solution for that ?
I manually added this line to the config.php, but still no success
Shouldnt that be a valid imgurl to the thumb? Or am I just stupid? Not a php/js - wiz, so its probaly the latter...But anyways I could use some help/hints to what could be wrong...
Try commenting out line 24 of the connector.php file in the connectors/php folder the line is currently:
error_reporting(E_ALL);
if you change this to
//error_reporting(E_ALL);
and see what happens, for some unknown reasons on some setups PHP seems to be failing to see the FileName GET variable, havent worked out why yet as it works on some platforms.
Now I'm happy again, problem solved! The error_reporting was not the bad guy in this case. It turned out to be a faulty pointer to my magic.mime file in php.ini (embarrasing ? hell yes! ...
When fixed everything runs smooth as silk!
A few hints from others I stumbled across at php.net regarding magic mime though:
"The function mime_content_type only worked for me on Microsoft Windows after I added the directive "mime_magic.debug" to my php.ini with the value of "On". The default value appears to be "Off". Exampe:
[mime_magic] mime_magic.debug = On mime_magic.magicfile = "c:\php\extras\magic.mime" "
and also,error reporting can be an issue: "just a little thing, not sure if it is for everyone or not but for windows, also needed to set error_reporting as strict to work for me, plus the debug thing"
None of these applied to my system, I can go with E_ALL and without mime_magic.debug = On, but it might help someonelse...
Well, hope my sloppiness can result in helping somebody else avoiding this...No thumbs->Check your php.ini!
Thanks again Grant for the support and a great filebrowser! cheers from sweden,
I cannot make the MCPUK File Browser work. I have read carefully the doc, the wikki, the forums, searched the Web and the newsgroups, and I still cannot make the browser work. Whatever I do, it still tries to show she root of my path (F:\).
Here is the structure of my site :
F:\MySite\Site\Admin\ (as http://localhost/mysiteadmin/) index.php \Pictures\UserPictures\ (where I want to upload and browse pictures) \Scripts\ \myFCKconfig.js \FCK\
Can you please tell me how I may configure FCK.
For now, having done everything that is said to be done, I just can see the editor create this :
I have under several days tried to figure out how the authentication works out, but I keep getting the same error; "Error creating folder" when trying to create a folder and "Invalid XML response from connector". This is probably because I don't know how I should implement the values given in the example file :http://www.mcpuk.net/fbxp/downloads/sample05.phps.
I use FCKeditor 2.0 in PHPList. Is there anybody who can help me along the way with this?? I basicly need to figure out where to get hold of the session for current logged in user from PHPList and then send it to the file browser.
Hi, I have on some servers problem with not showing icons for other files than images. I realize that path to icons is wrong. In file iconlookup.php are lines with return like:
where DOCUMENT_ROOT return /var/www/html but my server need /home/something/
So I replace document_root with $fckphp_config['basedir'] from config.php. On the first line in function iconLookup() you have to add line global $fckphp_config;
Then I see other icons (document2.jpg) but it is better than nothing
Hello ! I've a little problem : I don't want to use the directories "File","Media","Image","Flash", I just want to use a single directory. How can I do ?
1. Is it possible to use this file browser/manager as a standalone browser ? And how ..
2. How about the FF (1.0.6) that doesnt reload folder content on upload ? Cant get it to work, have to select a/the folder to get the updated item list.
3. Is there a speciel area where the development on the browser is going on ? Where to get the latest version/info ? It seems to me like it would be at mcpuk.net/fbxp/, but that page looks a bit outdated to me (need a "Last updated on:")
I wish I had an answer to your first question because I'd like to find a way to access the MCPUK file browser with a custom link. As for your second question, I found the answer in this forum post, which I tried and it works:
> I wish I had an answer to your first question because I'd like to find a way to access the MCPUK file browser with a custom link
If you mean "access MCPUK directly" like i understand it, this is the solution i use (no 1to1 copy of my 'code', but the ingredients how it can be done)
Guess we have a class or a function which can create formfields in PHP
Above might be a bit 'PHPish' but this is happen here: ----------------------------------------------------- 1. targetField javascript variable is created and set to a value (value does not matter, main thing is creation of that variable)
2. A javascript function "setUrl" is created, which is, what 'mcpuk' and 'default' codes says, the function that inserts the name of the selected object to a target field.
3. the link to the mcpuk filemanager itself is created, which does 2 main things - Set the type of the browser (== 1'st subdirectory to start) - Set the targetField of the result via "onClick"
4. setUrl (the code above) is also able to set a preview Picture to a <img id="p_$name" ... /> when id is found.
addExplorerLink() can be used more than one time on one page, because Javascripts LIFO behaviour for elements.
OK. enough fo theory.. Here is how above can be used: ----------------------------------------------------- echo 'User Avatar: '; echo createTextInput( 'avatar', $db->getUserAvatar(), array('width'=>160, 'height'=>120) ); echo addExplorerLink( 'avatar' );
Hey guys... i added the mcpuk extensions to the default ASPX connector... & hence created a ASPX connector for mcpuk..
It's not 100% complete yet.. there's some TODO's left in the code.. but the main features are working... basically, i added the extensions to the FileBrowserConnector.cs file in the FCKeditor.NET 2.2 package...
--- start of FileBrowserConnector.cs file ---
/* * FCKeditor - The text editor for internet * Copyright (C) 2003-2005 Frederico Caldeira Knabben * * Licensed under the terms of the GNU Lesser General Public License: * http://www.opensource.org/licenses/lgpl-license.php * * For further information visit: * http://www.fckeditor.net/ * * "Support Open Source software. What about a donation today?" * * File Name: FileBrowserConnector.cs * This is the code behind of the connector.aspx page used by the * File Browser. * * File Authors: * Frederico Caldeira Knabben (fredck@fckeditor.net) * * mpuk extensions by: * Nguyen Ly (nguyen.ly@lyphtec.com) - 16 Nov 2005 * */
using System; using System.Globalization; using System.Xml; using System.Web;
namespace FredCK.FCKeditorV2 { public class FileBrowserConnector : FileWorkerBase { protected override void OnLoad(EventArgs e) { // Get the main request informaiton. string sCommand = Request.QueryString["Command"]; if (sCommand == null) return;
string sResourceType = Request.QueryString["Type"]; if (sResourceType == null) return;
string sCurrentFolder = Request.QueryString["CurrentFolder"]; if (sCurrentFolder == null) return;
// Check the current folder syntax (must begin and start with a slash). if (!sCurrentFolder.EndsWith("/")) sCurrentFolder += "/"; if (!sCurrentFolder.StartsWith("/")) sCurrentFolder = "/" + sCurrentFolder;
// File Upload doesn't have to return XML, so it must be intercepted before anything. if (sCommand == "FileUpload") { this.FileUpload(sResourceType, sCurrentFolder); return; }
// Thumbnail command returns raw image data if (sCommand == "Thumbnail") { // Make sure FileName param is passed over if (sFileName == null || sFileName.Length == 0) return;
// Execute the required command. switch (sCommand) { case "GetFolders": this.GetFolders(oConnectorNode, sResourceType, sCurrentFolder); break; case "GetFoldersAndFiles": this.GetFolders(oConnectorNode, sResourceType, sCurrentFolder); this.GetFiles(oConnectorNode, sResourceType, sCurrentFolder); break; case "CreateFolder": this.CreateFolder(oConnectorNode, sResourceType, sCurrentFolder); break; case "DeleteFile": this.DeleteFile(oConnectorNode, sResourceType, sCurrentFolder, sFileName); break; case "RenameFile": this.RenameFile(oConnectorNode, sResourceType, sCurrentFolder, sFileName); break; case "DeleteFolder": this.DeleteFolder(oConnectorNode, sResourceType, sCurrentFolder); break; case "RenameFolder": this.RenameFolder(oConnectorNode, sResourceType, sCurrentFolder); break; case "GetUploadProgress": this.GetUploadProgress(oConnectorNode, sResourceType, sCurrentFolder); break; }
// Output the resulting XML. Response.Write(oXML.OuterXml);
Response.End(); }
#region Base XML Creation
private XmlNode CreateBaseXml(XmlDocument xml, string command, string resourceType, string currentFolder) { // Create the XML document header. xml.AppendChild(xml.CreateXmlDeclaration("1.0", "utf-8", null));
// Create the main "Connector" node. XmlNode oConnectorNode = XmlUtil.AppendElement(xml, "Connector"); XmlUtil.SetAttribute(oConnectorNode, "command", command); XmlUtil.SetAttribute(oConnectorNode, "resourceType", resourceType);
// Add the current folder node. XmlNode oCurrentNode = XmlUtil.AppendElement(oConnectorNode, "CurrentFolder"); XmlUtil.SetAttribute(oCurrentNode, "path", currentFolder); XmlUtil.SetAttribute(oCurrentNode, "url", GetUrlFromPath(resourceType, currentFolder));
return oConnectorNode; }
#endregion
#region Command Handlers
private void GetFolders(XmlNode connectorNode, string resourceType, string currentFolder) { // Map the virtual path to the local server path. string sServerDir = this.ServerMapFolder(resourceType, currentFolder);
// Create the "Folders" node. XmlNode oFoldersNode = XmlUtil.AppendElement(connectorNode, "Folders");
System.IO.DirectoryInfo oDir = new System.IO.DirectoryInfo(sServerDir); System.IO.DirectoryInfo[] aSubDirs = oDir.GetDirectories();
for (int i = 0; i < aSubDirs.Length; i++) { // Create the "Folders" node. XmlNode oFolderNode = XmlUtil.AppendElement(oFoldersNode, "Folder"); XmlUtil.SetAttribute(oFolderNode, "name", aSubDirs[i].Name); } }
private void GetFiles(XmlNode connectorNode, string resourceType, string currentFolder) { // Map the virtual path to the local server path. string sServerDir = this.ServerMapFolder(resourceType, currentFolder);
// Create the "Files" node. XmlNode oFilesNode = XmlUtil.AppendElement(connectorNode, "Files");
System.IO.DirectoryInfo oDir = new System.IO.DirectoryInfo(sServerDir); System.IO.FileInfo[] aFiles = oDir.GetFiles();
for (int i = 0; i < aFiles.Length; i++) { Decimal iFileSize = Math.Round((Decimal)aFiles[i].Length / 1024); if (iFileSize < 1 && aFiles[i].Length != 0) iFileSize = 1;
if (sNewFolderName == null || sNewFolderName.Length == 0) sErrorNumber = "102"; else { // Map the virtual path to the local server path of the current folder. string sServerDir = this.ServerMapFolder(resourceType, currentFolder);
private void Thumbnail(string resourceType, string currentFolder, string fileName) { string fullFileName = System.IO.Path.Combine(this.ServerMapFolder(resourceType, currentFolder), System.IO.Path.GetFileName(fileName)); System.IO.FileInfo fi = new System.IO.FileInfo(fullFileName); if (!fi.Exists) { // File doesn't exist so we spit out something ?
} else { // Create & return a thumbnail // -- 1. Is the file an image? switch (fi.Extension.TrimStart('.').ToLower()) { case "jpg": case "jpeg": case "gif": case "png": case "bmp": // Create a thumbnail of actual image System.Drawing.Image imgOrig; try { imgOrig = System.Drawing.Image.FromFile(fi.FullName);
// Generate a thumbnail using default size of 96x96 System.Drawing.Image imgThumb = imgOrig.GetThumbnailImage(96, 96, null, IntPtr.Zero);
// Spit out the thumbnail Response.ClearHeaders(); Response.Clear(); Response.ContentType = "image/jpeg"; // Use jpeg always for thumbnails? imgThumb.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); Response.End();
// Clean up imgThumb.Dispose(); imgOrig.Dispose(); } catch (OutOfMemoryException e) { // file does not have a valid image format or GDI+ does not support pixel format of file // TODO: Substitute some error image here throw; }
break; default: // TODO: Return a thumbnail for the file extension break; } } }
// Does file to be renamed exist or new file name already exist? if (!fi.Exists || fiNew.Exists) { errorNumber = "502"; } else { fi.MoveTo(fiNew.FullName); } } catch (Exception) { errorNumber = "502"; } }
// Create the "Progress" node. -- set it to 100% for now XmlNode oPressNode = XmlUtil.AppendElement(oConnectorNode, "Progress"); XmlUtil.SetAttribute(oPressNode, "max", "100"); XmlUtil.SetAttribute(oPressNode, "value", "100");
RE: MCPUK File browser in 2.0FC
RE: MCPUK File browser in 2.0FC
I installed the FC with the mcpuk filebrowser and the coldfusion connector.
Everything works ok, except:
- At first I only could upload image files. I changed the cffile accept attribute so that all files can be uploaded, but now no icons are displayed in the filebrowser.
Has anyone got the filebrowser up and running with the coldfusion connector?
RE: MCPUK File browser in 2.0FC
1. Open the mcpuk browser
2. Click Browse and select a file to upload.
3. Click Upload. The upload is successful.
4. Click the text area at the bottom, where the filename is displayed. Or click the Browse button again.
5. That text area expands to cover the Browse and Upload buttons. To use them, you have to close and re-open the editor.
RE: MCPUK File browser in 2.0FC
Hi,
How about adding a cross-browser XMLHttp object to the file browser? This would make the file browser able to support Opera and other browsers.
IMO I think it would also make it eaiser to port the filebrowser into a stand-alone browser.
http://www.scss.com.au/family/andrew/we ... tprequest/
What do you think?
RE: MCPUK File browser in 2.0FC
Currently I have it looking for images in the user folder
users/12323/images
This is also were it stores the thumbs.. I also have storage space limit set, and I don't want the thumbs to be counted as the users used disk space.
I would like the thumbs to be placed maybe at
users/12323/thumbs.
Thanks,
CHris
RE: MCPUK File browser in 2.0FC
it can be a complete url.
Then you just have to change some things in Thumbnails.php
RE: MCPUK File browser in 2.0FC
$fckphp_config['urlthumbsprefix']="/UserFiles/Thumbs/1";
in the Thumbnail.php I changed this function:
function Thumbnail($fckphp_config,$type,$cwd) {
$this->fckphp_config=$fckphp_config;
$this->type=$type;
$this->raw_cwd=$cwd;
$this->actual_cwd=str_replace("//","/",($fckphp_config['urlthumbsprefix']."/$type/".$this->raw_cwd));
$this->real_cwd=str_replace("//","/",($this->fckphp_config['basedir']."/".$this->actual_cwd));
$this->filename=str_replace(array("..","/"),"",$_GET['FileName']);
}
On the server I created UserFiles/Thumbs/1
and CMOD the dir to 777
However when I upload an image it creates the Thumb in UserFiles/Users/1/images/
but the thumb does not display in the browser window, so I think that the file browser is trying to pull the thumb from the new location:
UserFiles/Thumbs/1/
So How do I tell it were to save the thumbs?
Many Thanks
Chris
RE: MCPUK File browser in 2.0FC
What am i doin wrong, ive been looking everywhere but cant seem the find the error please help me... thanks
RE: MCPUK File browser in 2.0FC
put an .htaccess file in your directory with these lines in it:
php_value auto_append_file none
php_value auto_prepend_file none
Hope this saves someone the time I spent to figure this out. pj
RE: MCPUK File browser in 2.0FC
Hello,

I am not able to list directories with special characters like "" or "" in their name. It even more, I also cannot list directories containing a directory or file with a special char in their name.
Is there any solution for that ?
I manually added this line to the config.php, but still no success
array_push($fckphp_config['DirNameAllowedChars'],chr(196)); //
Thanks so far - Johannes.
RE: MCPUK File browser in 2.0FC
I just changed those lines:
function run() {
header ("Content-Type: application/xml; charset=utf-8");
echo "<?xml version="1.0\" encoding=\"utf-8\" ?>\n";
}
to
function run() {
header ("Content-Type: application/xml; charset=iso8859-1");
echo "<?xml version="1.0\" encoding=\"iso8859-1\" ?>\n";
}
and now any (german) special chars work.
BR, Johannes.
Thumbnail does not show up - problem
Hi all, this is my first post here, just stumbled across this wonderful thing called fckeditor a few days ago...

First: A big THANKS to all involved in this super-software! Especially the filebrowser really made my day.
Now to the problem: Ive set up fcked FC2 on a win-apache system. Everything is working ok, apart from one thing: Thumbnails doesnt show up...
I checked GD support with the testme.php script (suspended I know, but nevertheless..) and have other apps using it , so thats not the problem.
When trying to find out what urls my broken thumbs had in filebrowserwindow I got the following:
src=
"http://localhost/cpg/includes/wysiwyg/f ... traParams="
Shouldnt that be a valid imgurl to the thumb? Or am I just stupid? Not a php/js - wiz, so its probaly the latter...But anyways I could use some help/hints to what could be wrong...
Anybody have a clue?
Thanks for your time,
Henrik
RE: Thumbnail does not show up - problem
Try commenting out line 24 of the connector.php file in the connectors/php folder the line is currently:
error_reporting(E_ALL);
if you change this to
//error_reporting(E_ALL);
and see what happens, for some unknown reasons on some setups PHP seems to be failing to see the FileName GET variable, havent worked out why yet as it works on some platforms.
Let me know how you get on....
Regards,
Grant
RE: Thumbnail does not show up - problem
Thanks Grant, for your very quick reply!
...
Now I'm happy again, problem solved!
The error_reporting was not the bad guy in this case. It turned out to be a faulty pointer to my magic.mime file in php.ini (embarrasing ? hell yes!
When fixed everything runs smooth as silk!
A few hints from others I stumbled across at php.net regarding magic mime though:
"The function mime_content_type only worked for me on Microsoft Windows after I added the directive "mime_magic.debug" to my php.ini with the value of "On". The default value appears to be "Off". Exampe:
[mime_magic]
mime_magic.debug = On
mime_magic.magicfile = "c:\php\extras\magic.mime"
"
and also,error reporting can be an issue:
"just a little thing, not sure if it is for everyone or not
but for windows, also needed to set error_reporting as strict to work for me, plus the debug thing"
None of these applied to my system, I can go with E_ALL and without mime_magic.debug = On, but it might help someonelse...
Well, hope my sloppiness can result in helping somebody else avoiding this...No thumbs->Check your php.ini!
Thanks again Grant for the support and a great filebrowser!
cheers from sweden,
Henrik
RE: Thumbnail does not show up - on LINUX
About line 19 simply change
include "helpers/iconlookup.php";
to be
include "Commands/helpers/iconlookup.php";
Solves the problem!
RE: MCPUK File browser in 2.0FC
Hello,
I cannot make the MCPUK File Browser work. I have read carefully the doc, the wikki, the forums, searched the Web and the newsgroups, and I still cannot make the browser work. Whatever I do, it still tries to show she root of my path (F:\).
Here is the structure of my site :
F:\MySite\Site\Admin\ (as http://localhost/mysiteadmin/)
index.php
\Pictures\UserPictures\ (where I want to upload and browse pictures)
\Scripts\
\myFCKconfig.js
\FCK\
Can you please tell me how I may configure FCK.
For now, having done everything that is said to be done, I just can see the editor create this :
F:\mys\Site\Pictures\UserPictures\
I'm lost...
Thank you for you help.
RE: MCPUK File browser in 2.0FC
Re-post with correct formatting of the structure of the site :
F:\MySite\Site\Admin\ (as http://localhost/mysiteadmin/)
---- index.php
---- \Pictures\UserPictures\ (where I want to upload and browse pictures)
---- \Scripts\
-------- \myFCKconfig.js
-------- \FCK\
RE: MCPUK File browser in 2.0FC
I have under several days tried to figure out how the authentication works out, but I keep getting the same error; "Error creating folder" when trying to create a folder and "Invalid XML response from connector". This is probably because I don't know how I should implement the values given in the example file :http://www.mcpuk.net/fbxp/downloads/sample05.phps.
I use FCKeditor 2.0 in PHPList. Is there anybody who can help me along the way with this?? I basicly need to figure out where to get hold of the session for current logged in user from PHPList and then send it to the file browser.
RE: MCPUK File browser in 2.0FC
Hi,

I have on some servers problem with not showing icons for other files than images. I realize that path to icons is wrong. In file iconlookup.php are lines with return like:
return $_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF'])."/images/".$mimeIcons[$mimePrefix];
where DOCUMENT_ROOT return /var/www/html but my server need /home/something/
So I replace document_root with $fckphp_config['basedir'] from config.php. On the first line in function iconLookup() you have to add line global $fckphp_config;
Then I see other icons (document2.jpg) but it is better than nothing
RE: MCPUK File browser in 2.0FC
I've a little problem :
I don't want to use the directories "File","Media","Image","Flash", I just want to use a single directory.
How can I do ?
mcpuk FB as standalone browser ?
Hi.

Thanks for the good work. Cant say that enough
2 Questions..
1.
Is it possible to use this file browser/manager as a standalone browser ? And how ..
2.
How about the FF (1.0.6) that doesnt reload folder content on upload ? Cant get it to work, have to select a/the folder to get the updated item list.
3.
Is there a speciel area where the development on the browser is going on ? Where to get the latest version/info ? It seems to me like it would be at mcpuk.net/fbxp/, but that page looks a bit outdated to me (need a "Last updated on:")
RE: mcpuk FB as standalone browser ?
I wish I had an answer to your first question because I'd like to find a way to access the MCPUK file browser with a custom link. As for your second question, I found the answer in this forum post, which I tried and it works:
http://sourceforge.net/forum/message.php?msg_id=3186656
RE: mcpuk FB as standalone browser ?
If you mean "access MCPUK directly" like i understand it,
this is the solution i use (no 1to1 copy of my 'code', but the ingredients how it can be done)
Guess we have a class or a function which can create formfields in PHP
... createTextInput( $name, $defaultValue, $params )
Which produces an HTML ouptut like this:
<input type="text" name="$name" id="$name" value="$defaultValue" param_array_as_key="value" />
Important is, that we have a unique identifier (name, id) for this textfield.
Now we need a second function or method:
... addExplorerLink( $name )
(you could add a third param like 'explorer="mcpuk"' to switch() between different 'explorer' types)
//! add a link to open a file browser('explorer'), types can be 'Image', 'File', .. forgot ..
function addExplorerLink( $name, $type="Image" ) {
$html ='';
$html .= '<script language="JavaScript" type="text/javascript">'."\n";
$html .= ' targetField=\''.$name.'\';'."\n";
$html .= ' function SetUrl(val) { '."\n";
$html .= ' if(elem=document.getElementById("p_"+targetField)) elem.src=val;'."\n";
// -- good point to modify/strip/shorten the filepath (js) --
$html .= ' document.getElementById(targetField).value=val;'."\n";
$html .= ' }</script>'."\n";
$html .= '<a class="folderSelect" href="{SPONSOR_THIS}/fckeditor/editor/filemanager/browser/mcpuk/browser.html?Type='.$type.'&Connector=connectors/php/connector.php" onClick="w=window.open( this.href, \'sel\', \'width=730,height=520\'); w.focus(); targetField=\''.$name.'\'; return false;">'."\n";
$html .= ' [select]'."\n";
$html .= '</a>'."\n";
}
Above might be a bit 'PHPish' but this is happen here:
-----------------------------------------------------
1. targetField javascript variable is created and set to a value
(value does not matter, main thing is creation of that variable)
2. A javascript function "setUrl" is created, which is, what 'mcpuk'
and 'default' codes says, the function that inserts the name of
the selected object to a target field.
3. the link to the mcpuk filemanager itself is created, which does 2 main things
- Set the type of the browser (== 1'st subdirectory to start)
- Set the targetField of the result via "onClick"
4. setUrl (the code above) is also able to set a preview Picture to a
<img id="p_$name" ... /> when id is found.
addExplorerLink() can be used more than one time on one page, because Javascripts LIFO behaviour for elements.
OK. enough fo theory.. Here is how above can be used:
-----------------------------------------------------
echo 'User Avatar: ';
echo createTextInput( 'avatar', $db->getUserAvatar(), array('width'=>160, 'height'=>120) );
echo addExplorerLink( 'avatar' );
Happy Halloween,
.kaeferstein
RE: MCPUK File browser in 2.0FC
Hey guys... i added the mcpuk extensions to the default ASPX connector... & hence created a ASPX connector for mcpuk..
It's not 100% complete yet.. there's some TODO's left in the code.. but the main features are working... basically, i added the extensions to the FileBrowserConnector.cs file in the FCKeditor.NET 2.2 package...
--- start of FileBrowserConnector.cs file ---
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
*
* For further information visit:
* http://www.fckeditor.net/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: FileBrowserConnector.cs
* This is the code behind of the connector.aspx page used by the
* File Browser.
*
* File Authors:
* Frederico Caldeira Knabben (fredck@fckeditor.net)
*
* mpuk extensions by:
* Nguyen Ly (nguyen.ly@lyphtec.com) - 16 Nov 2005
*
*/
using System;
using System.Globalization;
using System.Xml;
using System.Web;
namespace FredCK.FCKeditorV2
{
public class FileBrowserConnector : FileWorkerBase
{
protected override void OnLoad(EventArgs e)
{
// Get the main request informaiton.
string sCommand = Request.QueryString["Command"];
if (sCommand == null) return;
string sResourceType = Request.QueryString["Type"];
if (sResourceType == null) return;
string sCurrentFolder = Request.QueryString["CurrentFolder"];
if (sCurrentFolder == null) return;
// Check the current folder syntax (must begin and start with a slash).
if (!sCurrentFolder.EndsWith("/"))
sCurrentFolder += "/";
if (!sCurrentFolder.StartsWith("/"))
sCurrentFolder = "/" + sCurrentFolder;
// File Upload doesn't have to return XML, so it must be intercepted before anything.
if (sCommand == "FileUpload")
{
this.FileUpload(sResourceType, sCurrentFolder);
return;
}
string sFileName = Request.QueryString["FileName"];
// Thumbnail command returns raw image data
if (sCommand == "Thumbnail")
{
// Make sure FileName param is passed over
if (sFileName == null || sFileName.Length == 0) return;
this.Thumbnail(sResourceType, sCurrentFolder, sFileName);
return;
}
// Cleans the response buffer.
Response.ClearHeaders();
Response.Clear();
// Prevent the browser from caching the result.
Response.CacheControl = "no-cache";
// Set the response format.
Response.ContentEncoding = System.Text.UTF8Encoding.UTF8;
Response.ContentType = "text/xml";
XmlDocument oXML = new XmlDocument();
XmlNode oConnectorNode = CreateBaseXml(oXML, sCommand, sResourceType, sCurrentFolder);
// Execute the required command.
switch (sCommand)
{
case "GetFolders":
this.GetFolders(oConnectorNode, sResourceType, sCurrentFolder);
break;
case "GetFoldersAndFiles":
this.GetFolders(oConnectorNode, sResourceType, sCurrentFolder);
this.GetFiles(oConnectorNode, sResourceType, sCurrentFolder);
break;
case "CreateFolder":
this.CreateFolder(oConnectorNode, sResourceType, sCurrentFolder);
break;
case "DeleteFile":
this.DeleteFile(oConnectorNode, sResourceType, sCurrentFolder, sFileName);
break;
case "RenameFile":
this.RenameFile(oConnectorNode, sResourceType, sCurrentFolder, sFileName);
break;
case "DeleteFolder":
this.DeleteFolder(oConnectorNode, sResourceType, sCurrentFolder);
break;
case "RenameFolder":
this.RenameFolder(oConnectorNode, sResourceType, sCurrentFolder);
break;
case "GetUploadProgress":
this.GetUploadProgress(oConnectorNode, sResourceType, sCurrentFolder);
break;
}
// Output the resulting XML.
Response.Write(oXML.OuterXml);
Response.End();
}
#region Base XML Creation
private XmlNode CreateBaseXml(XmlDocument xml, string command, string resourceType, string currentFolder)
{
// Create the XML document header.
xml.AppendChild(xml.CreateXmlDeclaration("1.0", "utf-8", null));
// Create the main "Connector" node.
XmlNode oConnectorNode = XmlUtil.AppendElement(xml, "Connector");
XmlUtil.SetAttribute(oConnectorNode, "command", command);
XmlUtil.SetAttribute(oConnectorNode, "resourceType", resourceType);
// Add the current folder node.
XmlNode oCurrentNode = XmlUtil.AppendElement(oConnectorNode, "CurrentFolder");
XmlUtil.SetAttribute(oCurrentNode, "path", currentFolder);
XmlUtil.SetAttribute(oCurrentNode, "url", GetUrlFromPath(resourceType, currentFolder));
return oConnectorNode;
}
#endregion
#region Command Handlers
private void GetFolders(XmlNode connectorNode, string resourceType, string currentFolder)
{
// Map the virtual path to the local server path.
string sServerDir = this.ServerMapFolder(resourceType, currentFolder);
// Create the "Folders" node.
XmlNode oFoldersNode = XmlUtil.AppendElement(connectorNode, "Folders");
System.IO.DirectoryInfo oDir = new System.IO.DirectoryInfo(sServerDir);
System.IO.DirectoryInfo[] aSubDirs = oDir.GetDirectories();
for (int i = 0; i < aSubDirs.Length; i++)
{
// Create the "Folders" node.
XmlNode oFolderNode = XmlUtil.AppendElement(oFoldersNode, "Folder");
XmlUtil.SetAttribute(oFolderNode, "name", aSubDirs[i].Name);
}
}
private void GetFiles(XmlNode connectorNode, string resourceType, string currentFolder)
{
// Map the virtual path to the local server path.
string sServerDir = this.ServerMapFolder(resourceType, currentFolder);
// Create the "Files" node.
XmlNode oFilesNode = XmlUtil.AppendElement(connectorNode, "Files");
System.IO.DirectoryInfo oDir = new System.IO.DirectoryInfo(sServerDir);
System.IO.FileInfo[] aFiles = oDir.GetFiles();
for (int i = 0; i < aFiles.Length; i++)
{
Decimal iFileSize = Math.Round((Decimal)aFiles[i].Length / 1024);
if (iFileSize < 1 && aFiles[i].Length != 0) iFileSize = 1;
// Create the "File" node.
XmlNode oFileNode = XmlUtil.AppendElement(oFilesNode, "File");
XmlUtil.SetAttribute(oFileNode, "name", aFiles[i].Name);
XmlUtil.SetAttribute(oFileNode, "size", iFileSize.ToString(CultureInfo.InvariantCulture));
}
}
private void CreateFolder(XmlNode connectorNode, string resourceType, string currentFolder)
{
string sErrorNumber = "0";
string sNewFolderName = Request.QueryString["NewFolderName"];
if (sNewFolderName == null || sNewFolderName.Length == 0)
sErrorNumber = "102";
else
{
// Map the virtual path to the local server path of the current folder.
string sServerDir = this.ServerMapFolder(resourceType, currentFolder);
try
{
Util.CreateDirectory(System.IO.Path.Combine(sServerDir, sNewFolderName));
}
catch (ArgumentException)
{
sErrorNumber = "102";
}
catch (System.IO.PathTooLongException)
{
sErrorNumber = "102";
}
catch (System.IO.IOException)
{
sErrorNumber = "101";
}
catch (System.Security.SecurityException)
{
sErrorNumber = "103";
}
catch (Exception)
{
sErrorNumber = "110";
}
}
// Create the "Error" node.
XmlNode oErrorNode = XmlUtil.AppendElement(connectorNode, "Error");
XmlUtil.SetAttribute(oErrorNode, "number", sErrorNumber);
}
private void FileUpload(string resourceType, string currentFolder)
{
HttpPostedFile oFile = Request.Files["NewFile"];
string sErrorNumber = "0";
string sFileName = "";
if (oFile != null)
{
// Map the virtual path to the local server path.
string sServerDir = this.ServerMapFolder(resourceType, currentFolder);
// Get the uploaded file name.
sFileName = System.IO.Path.GetFileName(oFile.FileName);
int iCounter = 0;
while (true)
{
string sFilePath = System.IO.Path.Combine(sServerDir, sFileName);
if (System.IO.File.Exists(sFilePath))
{
iCounter++;
sFileName =
System.IO.Path.GetFileNameWithoutExtension(oFile.FileName) +
"(" + iCounter + ")" +
System.IO.Path.GetExtension(oFile.FileName);
sErrorNumber = "201";
}
else
{
oFile.SaveAs(sFilePath);
break;
}
}
}
else
sErrorNumber = "202";
Response.Clear();
Response.Write("<script type=\"text/javascript\">");
Response.Write("window.parent.frames['frmUpload'].OnUploadCompleted(" + sErrorNumber + ",'" + sFileName.Replace("'", "\\'") + "') ;");
Response.Write("</script>");
Response.End();
}
private void Thumbnail(string resourceType, string currentFolder, string fileName)
{
string fullFileName = System.IO.Path.Combine(this.ServerMapFolder(resourceType, currentFolder), System.IO.Path.GetFileName(fileName));
System.IO.FileInfo fi = new System.IO.FileInfo(fullFileName);
if (!fi.Exists)
{
// File doesn't exist so we spit out something ?
}
else
{
// Create & return a thumbnail
// -- 1. Is the file an image?
switch (fi.Extension.TrimStart('.').ToLower())
{
case "jpg":
case "jpeg":
case "gif":
case "png":
case "bmp":
// Create a thumbnail of actual image
System.Drawing.Image imgOrig;
try
{
imgOrig = System.Drawing.Image.FromFile(fi.FullName);
// Generate a thumbnail using default size of 96x96
System.Drawing.Image imgThumb = imgOrig.GetThumbnailImage(96, 96, null, IntPtr.Zero);
// Spit out the thumbnail
Response.ClearHeaders();
Response.Clear();
Response.ContentType = "image/jpeg"; // Use jpeg always for thumbnails?
imgThumb.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
Response.End();
// Clean up
imgThumb.Dispose();
imgOrig.Dispose();
}
catch (OutOfMemoryException e)
{
// file does not have a valid image format or GDI+ does not support pixel format of file
// TODO: Substitute some error image here
throw;
}
break;
default:
// TODO: Return a thumbnail for the file extension
break;
}
}
}
private void DeleteFile(XmlNode oConnectorNode, string sResourceType, string sCurrentFolder, string sFileName)
{
string errorNumber = "0";
if (sFileName == null || sFileName.Length == 0)
{
errorNumber = "302";
}
else
{
try
{
string fullFileName = System.IO.Path.Combine(this.ServerMapFolder(sResourceType, sCurrentFolder), System.IO.Path.GetFileName(sFileName));
System.IO.FileInfo fi = new System.IO.FileInfo(fullFileName);
if (!fi.Exists)
{
errorNumber = "302";
}
else
{
fi.Delete();
}
}
catch (Exception)
{
errorNumber = "302";
}
}
// Create the "Error" node.
XmlNode oErrorNode = XmlUtil.AppendElement(oConnectorNode, "Error");
XmlUtil.SetAttribute(oErrorNode, "number", errorNumber);
}
private void RenameFile(XmlNode oConnectorNode, string sResourceType, string sCurrentFolder, string sFileName)
{
string errorNumber = "0";
string newName = Request.QueryString["NewName"];
if (sFileName == null || sFileName.Length == 0 || newName == null || newName.Length == 0)
{
errorNumber = "502";
}
else
{
try
{
string fullFileName = System.IO.Path.Combine(this.ServerMapFolder(sResourceType, sCurrentFolder), System.IO.Path.GetFileName(sFileName));
System.IO.FileInfo fi = new System.IO.FileInfo(fullFileName);
string fullNewFileName = System.IO.Path.Combine(this.ServerMapFolder(sResourceType, sCurrentFolder), System.IO.Path.GetFileName(newName));
System.IO.FileInfo fiNew = new System.IO.FileInfo(fullNewFileName);
// Does file to be renamed exist or new file name already exist?
if (!fi.Exists || fiNew.Exists)
{
errorNumber = "502";
}
else
{
fi.MoveTo(fiNew.FullName);
}
}
catch (Exception)
{
errorNumber = "502";
}
}
// Create the "Error" node.
XmlNode oErrorNode = XmlUtil.AppendElement(oConnectorNode, "Error");
XmlUtil.SetAttribute(oErrorNode, "number", errorNumber);
}
private void DeleteFolder(XmlNode oConnectorNode, string sResourceType, string sCurrentFolder)
{
string errorNumber = "0";
string folderName = Request.QueryString["FolderName"];
if (folderName == null || folderName.Length == 0)
{
errorNumber = "402";
}
else
{
try
{
string fullFolderPath = System.IO.Path.Combine(this.ServerMapFolder(sResourceType, sCurrentFolder), System.IO.Path.GetFileName(folderName));
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(fullFolderPath);
if (di.Exists)
{
di.Delete(true);
}
else
{
errorNumber = "402";
}
}
catch (Exception)
{
errorNumber = "402";
}
}
// Create the "Error" node.
XmlNode oErrorNode = XmlUtil.AppendElement(oConnectorNode, "Error");
XmlUtil.SetAttribute(oErrorNode, "number", errorNumber);
}
private void RenameFolder(XmlNode oConnectorNode, string sResourceType, string sCurrentFolder)
{
string errorNumber = "0";
string folderName = Request.QueryString["FolderName"];
string newFolderName = Request.QueryString["NewName"];
if (folderName == null || folderName.Length == 0 || newFolderName == null || newFolderName.Length == 0)
{
errorNumber = "602";
}
else
{
try
{
string fullFolderPath = System.IO.Path.Combine(this.ServerMapFolder(sResourceType, sCurrentFolder), System.IO.Path.GetFileName(folderName));
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(fullFolderPath);
string fullNewFolderPath = System.IO.Path.Combine(this.ServerMapFolder(sResourceType, sCurrentFolder), System.IO.Path.GetFileName(newFolderName));
System.IO.DirectoryInfo diNew = new System.IO.DirectoryInfo(fullNewFolderPath);
if (di.Exists && !diNew.Exists)
{
di.MoveTo(diNew.FullName);
}
else
{
errorNumber = "602";
}
}
catch (Exception)
{
errorNumber = "602";
}
}
// Create the "Error" node.
XmlNode oErrorNode = XmlUtil.AppendElement(oConnectorNode, "Error");
XmlUtil.SetAttribute(oErrorNode, "number", errorNumber);
}
private void GetUploadProgress(XmlNode oConnectorNode, string sResourceType, string sCurrentFolder)
{
// TODO: Implement GetUploadProgess()
string uploadID = Request.QueryString["uploadID"];
// Create the "Progress" node. -- set it to 100% for now
XmlNode oPressNode = XmlUtil.AppendElement(oConnectorNode, "Progress");
XmlUtil.SetAttribute(oPressNode, "max", "100");
XmlUtil.SetAttribute(oPressNode, "value", "100");
// Create the "RefreshURL" node.
string refreshURL = Request.QueryString["refreshURL"];
if (refreshURL != null && refreshURL.Length > 0)
{
XmlNode oRefreshUrlNode = XmlUtil.AppendElement(oConnectorNode, "RefreshURL");
XmlUtil.SetAttribute(oRefreshUrlNode, "url", refreshURL);
}
}
#endregion
#region Directory Mapping
private string ServerMapFolder(string resourceType, string folderPath)
{
// Get the resource type directory.
string sResourceTypePath = System.IO.Path.Combine(this.UserFilesDirectory, resourceType);
// Ensure that the directory exists.
Util.CreateDirectory(sResourceTypePath);
// Return the resource type directory combined with the required path.
return System.IO.Path.Combine(sResourceTypePath, folderPath.TrimStart('/'));
}
private string GetUrlFromPath(string resourceType, string folderPath)
{
if (resourceType == null || resourceType.Length == 0)
return this.UserFilesPath.TrimEnd('/') + folderPath;
else
return this.UserFilesPath + resourceType + folderPath;
}
#endregion
}
}
-- End of file ---
RE: MCPUK File browser in 2.0FC
fckconfig.js:
FCKConfig.ImageBrowser = true ;
FCKConfig.ImageBrowserURL = FCKConfig.BasePath + 'filemanager/browser/mcpuk/browser.html?Type=Image&Connector=connectors/php/connector.php' ;
FCKConfig.ImageBrowserWindowWidth = screen.width * 0.7 ; // 70% ;
FCKConfig.ImageBrowserWindowHeight = screen.height * 0.7 ; // 70% ;
config.php:
Tx in advance!