Welcome Guest, Not a member yet? Register   Sign In
fckeditor dynamically set $Config['UserFilesPath']
#1

[eluser]coffey[/eluser]
Has anyone got a way to dynamically set fckeditor's file upload path.

It works fine if I set it manually but I need it to work dynamically.

I have tried this:
Code:
$Config['Enabled'] = true ;


// Path to user files relative to the document root.
$this->obj =& get_instance();

//prior to opening this filemanager I have set up in a controller
// $this->session->set_userdata('UserFilesPath', $thispath)

if ($this->obj->session->userdata('UserFilesPath') != '')
{
    $Config['UserFilesPath'] = $this->obj->session->userdata('UserFilesPath') ;
} else {
    $Config['UserFilesPath'] = '/usertemp/' ;
}

I'd be grateful for any help here.
#2

[eluser]coffey[/eluser]
The only solution I could find was to just set a normal $_SESSION['UserFilesPath']. Remember to set $session_start() in the fckeditor config.php file - normal CI files already have the session started.
#3

[eluser]Edemilson Lima[/eluser]
Sorry if I can't help. I have used FCKeditor for some years and I really don't like it. At the beggining it was light and fast, but now it is bloated and very heavy to load. It uses a lot of files to do a simple HTML editor. There are better options like TinyMCE or OpenWYSIWYG. The first have a lot of nice features and the later is very light and fast, but it doesn't have file upload.
#4

[eluser]coffey[/eluser]
Thanks Edemilson Lima.

Yes I have just installed TinyMCE as another option for my users. Much easier. I will also investigate OpenWYSIWYG - I don't know this one. Sound good though.
#5

[eluser]Edemilson Lima[/eluser]
Another interesting editors are:

Damn Small Rich Text Editor - http://www.avidansoft.com/dsrte/dsrte.php
This one have file upload using Ajax, and produces XHTML code with inline styles. Made in jQuery, it is really small and fast.

MarkItUp - http://markitup.jaysalvat.com/home/
If you need a editor to deal with BBcode, Markdown, Textile, Wikitext, etc, this is the right choice. It is not a WYSIWYG editor, but help the user to build rich texts using these formats, like the CI forum does. It comes with the necessary parsers, and is made in jQuery too.

WYMeditor - http://www.wymeditor.org/en/
This editor have the purpose to produce a clean and well formated markup for applications, in XHTML with no inline styles. In this sense, it is in the middle between DSRTE and MarkItUp. If you need a WYSIWYG editor to send clean text to your database, with no invalid markup, this is the right one. Its last version is based in jQuery.
#6

[eluser]Unknown[/eluser]
It can be done in many ways.
1) In fckeditor\editor\filemanager\connectors\phpconfig.php file

a) Go after global $Config ; and $Config['Enabled'] = false ;
i) There, if want a session dependent secure method: only for single site setting: i.e. one FCKeditor for each one project domain or subdomain, not one FCKeditor for multiple project then place this code:

if(!isset($_SESSION)){
session_start();
}

if(isset($_SESSION['SESSION_SERVER_RELATIVEPATH']) && $_SESSION['SESSION_SERVER_RELATIVEPATH']!="") {
$relative_path=$_SESSION['SESSION_SERVER_RELATIVEPATH'];
include_once($_SERVER['DOCUMENT_ROOT'].$relative_path."configurations/configuration.php");
}


N.B.: Here, $_SESSION['SESSION_SERVER_RELATIVEPATH']: relative folder path of the project corresponding to the webroot; should be like "/project/folder/path/" and set this session variable in a common file in your project where the session started. And there should be a configurations/configuration.php as the configuration file in your project. If it's name or path is different you have to place the corresponding path here instead of configurations/configuration.php

ii) If want to use a single FCKeditor component for different projects represented as different sub-folders and with a session dependent secure way (Assuming different session_name for different projects, to differentiate their sessions in a single server). But it will not work if projects represented as sub-domains or different domains, then have to use the session independent way (iii) provided bellow (though it is insecure). Place this code:

if(!isset($_SESSION)){
session_name($_REQUEST['param_project_to_fck']);
session_start();
}

if(isset($_SESSION['SESSION_SERVER_RELATIVEPATH']) && $_SESSION['SESSION_SERVER_RELATIVEPATH']!="") {
$relative_path=$_SESSION['SESSION_SERVER_RELATIVEPATH'];
include_once($_SERVER['DOCUMENT_ROOT'].$relative_path."configurations/configuration.php");
}

Please read N.B. at the end of previous point, i.e. point (i)

iii) If want to use a single FCKeditor component for different projects represented either different sub-folders as well as sub-domains or domains (though it is not fully secure). Place this code:

if(isset($_REQUEST['param_project_to_fck']) && $_REQUEST['param_project_to_fck']!=""){ //base64 encoded relative folder path of the project corresponding to the webroot; should be like "/project/folder/path/" before encoding
$relative_path=base64_decode($_REQUEST['param_project_to_fck']);
include_once($_SERVER['DOCUMENT_ROOT'].$relative_path."configurations/configuration.php");
}

Please read N.B. at the end of point (i)

b)Now after that for any case you selected, please find this code:

// Path to user files relative to the document root.
$Config['UserFilesPath'] = '/userfiles/' ;

and replace the following code:
if(isset($SERVER_RELATIVEPATH) && $SERVER_RELATIVEPATH==$relative_path) { //to make it relatively secure so that hackers can not create any upload folder automatcally in the server, using a direct link and can not upload files there
$Config['Enabled'] = true ;
$file_upload_relative_path=$SERVER_RELATIVEPATH;
}else{
$Config['Enabled'] = false ;
exit();
}
// Path to user files relative to the document root.
//$Config['UserFilesPath'] = '/userfiles/' ;
$Config['UserFilesPath'] = $file_upload_relative_path.'userfiles/' ;

Here $SERVER_RELATIVEPATH is the relative path and it must be set in your project's configuration file included previously.
Mind it, you mast comment out the existing $Config['UserFilesPath'] = '/userfiles/' ; in this file by either replacing or simply commenting out if it exist in other place of the file.

2) If you choose 1) (a) (ii) or (iii) method then open
(a) fckeditor\editor\filemanager\browser\default\browser.html file.

Search for this line: var sConnUrl = GetUrlParam( 'Connector' ) ;

Put these commands after that line:
var param_project_to_fck = GetUrlParam( 'param_project_to_fck' ) ;


Now, Search for this line: sUrl += '&CurrentFolder;=' + encodeURIComponent( this.CurrentFolder ) ;

Put this command after that line:
sUrl += '&param;_project_to_fck=' + param_project_to_fck ;

(b) Now, open ckeditor\\\\editor\\\\filemanager\\\\browser\\\\default\\\\frmupload.html file.

Search for this line (it should be in the SetCurrentFolder() function): sUrl += '&CurrentFolder;=' + encodeURIComponent( folderPath ) ;

Put this command after that line:
sUrl += '&param;_project_to_fck='+window.parent.param_project_to_fck;

3) Now where you want to show the FCKeditor in your project, you have to put those lines first in the corresponding php file/page:

include_once(Absolute/Folder/path/for/FCKeditor/."fckeditor/fckeditor.php") ;
$oFCKeditor = new FCKeditor(Field_name_for_editor_content_area) ;
$oFCKeditor->BasePath = http_full_path_for_FCKeditor_location.'fckeditor/' ;
$oFCKeditor->Height = 400;
$oFCKeditor->Width = 600;
$oFCKeditor->Value =Your_desired_content_to_show_in_editor;
$oFCKeditor->Create() ;

a) Now, if you choose 1) (a) (ii) or (iii) method then place the following code segment before that line: $oFCKeditor->Create() ;

$oFCKeditor->Config["LinkBrowserURL"] = ($oFCKeditor->BasePath)."editor/filemanager/browser/default/browser.html?Connector=../../connectors/php/connector.php&param;_project_to_fck=".base64_encode($SERVER_RELATIVEPATH);
$oFCKeditor->Config["ImageBrowserURL"] = ($oFCKeditor->BasePath)."editor/filemanager/browser/default/browser.html?Type=Image&Connector;=../../connectors/php/connector.php&param;_project_to_fck=".base64_encode($SERVER_RELATIVEPATH);
$oFCKeditor->Config["FlashBrowserURL"] = ($oFCKeditor->BasePath)."editor/filemanager/browser/default/browser.html?Type=Flash&Connector;=../../connectors/php/connector.php&param;_project_to_fck=".base64_encode($SERVER_RELATIVEPATH);

b) if you chose 1) (a) (ii) method, then in the above code code segment, just replace all the texts: base64_encode($SERVER_RELATIVEPATH) with this one: base64_encode(session_name())




Theme © iAndrew 2016 - Forum software by © MyBB