If I run the editor with the following code:
require_once("FCKeditor/fckeditor.php") ;
$oFCKeditor = new FCKeditor('wpTextbox1') ;
$oFCKeditor->BasePath = "FCKeditor/";
$oFCKeditor->Value = $editText;
// $oFCKeditor->ToolbarSet = 'Wiki' ;
$oFCKeditor->Height = 500 ;
$oFCKeditor->Width = '100%' ;
$oFCKeditor->Config['Username'] = 'ABC' ;
$wgOut->addHTML( $oFCKeditor->CreateHtml() );
How do I get to the Config['Username'] variable inside of the PHP server-side connector?
Or, alternately, how do I pass this value as a parameter to the PHP connector?
I want to attach the username to the uploaded file name.
Here's one of the things that I've tried so far and it doesn't work.
I modified the file commands.php in editor/filemanager/browser/default/connectors/php
Here's the code snippet:
else
{
// echo 'Username = ' . $Config['Username'];
$sFilePath = $sServerDir . $Config['Username'] . "-" . $sFileName ;
move_uploaded_file( $oFile['tmp_name'], $sFilePath ) ;
if ( is_file( $sFilePath ) )
require_once("FCKeditor/fckeditor.php") ;
$oFCKeditor = new FCKeditor('wpTextbox1') ;
$oFCKeditor->BasePath = "FCKeditor/";
$oFCKeditor->Value = $editText;
// $oFCKeditor->ToolbarSet = 'Wiki' ;
$oFCKeditor->Height = 500 ;
$oFCKeditor->Width = '100%' ;
$oFCKeditor->Config['Username'] = 'ABC' ;
$wgOut->addHTML( $oFCKeditor->CreateHtml() );
How do I get to the Config['Username'] variable inside of the PHP server-side connector?
Or, alternately, how do I pass this value as a parameter to the PHP connector?
I want to attach the username to the uploaded file name.
Here's one of the things that I've tried so far and it doesn't work.
I modified the file commands.php in editor/filemanager/browser/default/connectors/php
Here's the code snippet:
else
{
// echo 'Username = ' . $Config['Username'];
$sFilePath = $sServerDir . $Config['Username'] . "-" . $sFileName ;
move_uploaded_file( $oFile['tmp_name'], $sFilePath ) ;
if ( is_file( $sFilePath ) )
RE: Access a dynamic variable in php connecto
Any ideas are greatly appreciated...I really like this editor. Thanks!
RE: Access a dynamic variable in php connecto
session_start();
$_SESSION['user']='ABC';
and in the uploader you get that data back:
session_start();
$name=$_SESSION['user'];
or something like that, I'm not really used to PHP and I've done this without testing, but that's the idea.
RE: Access a dynamic variable in php connecto
In the uploader, I put:
session_name("Username");
session_start();
$sFileName = isset($_SESSION['Username']) ? $_SESSION['Username'] : "EMPTY" . "-" . $sFileName;
For the client side, this is what I used:
session_name("Username");
session_start();
$_SESSION['Username'] = 'ABC' ;
require_once("FCKeditor/fckeditor.php") ;
$oFCKeditor = new FCKeditor('wpTextbox1') ;
I checked the cookies in my browser and there is a cookie set for Username
RE: Access a dynamic variable in php connecto
RE: Access a dynamic variable in php connecto
When I look in the /tmp directory to see where the sessions are saved, the info is there. There's a cookie set in the browser for the session. When I use Firefox, there's two files in the /tmp dir.
-rw------- 1 apache apache 174 Feb 7 16:05 sess_ac7fa5a14be8e80faea89783e48dddd5
-rw------- 1 apache apache 0 Feb 7 16:05 sess_b91d94ad56e3c6ff36b4a8a3171784dc
When I used IE, there was only one. It seems that FF ends up making two sessions. One of them doesn't have any info in it. The funny thing is that even though IE only had one /tmp/sess* file, it didn't work right either.
RE: Access a dynamic variable in php connecto
In my original post, I included the following line.
$oFCKeditor->Config['Username'] = 'ABC' ;
I'm back to using that again. I've tried to access the variable in editor/filemanager/browser/default/frmupload.html by using the following code:
function SetCurrentFolder( resourceType, folderPath )
{
var sUrl = oConnector.ConnectorUrl +'Command=FileUpload' ;
sUrl += '&Type=' + resourceType ;
sUrl += '&CurrentFolder=' + folderPath ;
var oEditor = window.parent.parent.InnerDialogLoaded();
var FCK = oEditor.FCK;
var Username = FCK.Config['Username'];
sUrl += '&Username=' + Username;
document.getElementById('frmUpload').action = sUrl ;
}
I'm attempting to pass the username as a parameter to the php connector on the server. This doesn't work because window.parent.parent.InnerDialogLoaded() is undefined in frmupload.html
I'm just in need of a little javascript wizardry to access the variable that I defined when the editor was instantiated. Any insight is greatly appreciated.
RE: Access a dynamic variable in php connecto
Another solution was pointed out to me, which I used. Here's a quote (with one minor fix I made):
---------------------------------------
You could try passing that information directly to the connector. Forget about the “Config[‘Username’]” thing… go directly in the connector setup:
$oFCKeditor->Config['ImageBrowserURL’] = '/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/php/connector.php%3FUserName%3D' . $UserName ;
The only thing is that, as you can see, the connector value is escaped (the %3F and %3D values). So, you must also change “editor/filemanager/browser/default/browser.html”. Modify the following line:
return oMatch[1] ;
to:
return unescape( oMatch[1] ) ;
-------------------------------------
The only thing that you might need to change is tweak the URL in ImageBrowserURL if /FCKeditor is not at the root of your website.
RE: Access a dynamic variable in php connecto
In connector.php, you can access the UserName variable which was passed w/ this code:
function DoResponse()
{
if ( !isset( $_GET['Command'] ) || !isset( $_GET['Type'] ) || !isset( $_GET['CurrentFolder'] ) )
return ;
// Get the main request informaiton.
$sCommand = $_GET['Command'] ;
$sResourceType = $_GET['Type'] ;
$sCurrentFolder = $_GET['CurrentFolder'] ;
$Username = $_GET['Username'];