We've made changes throughout FCK to use our own Image directory and relative paths throughout. the only problem i'm running into now is that when I drag an image, FCK is replacing the relative path with an absolute path.
Could someone point me to the function that is doing this replacement, and the file containing it? i've dug through fckeditorcode_ie 1and 2 with no luck finding the occurence of this.
thanks!
Could someone point me to the function that is doing this replacement, and the file containing it? i've dug through fckeditorcode_ie 1and 2 with no luck finding the occurence of this.
thanks!

RE: Relative URL replacement
RE: Relative URL replacement
RE: Relative URL replacement
In filemanager\browser\mcpuk\connectors\php\config.php
go to this line (line 42 for me):
$fckphp_config['urlprefix']=$fckphp_config['prot'].$_SERVER['SERVER_NAME'];
and replace it with:
$fckphp_config['urlprefix']="";
For normal use, I believe you only need to look at config.php and edit there.. probably you're having an absolute path defined in $config['userfilespath'] ??
Hope this helps!
RE: Relative URL replacement
RE: Relative URL replacement
http://www.MyWebsite.com/Editors/FCKedi ... eFile.aspx
RE: Relative URL replacement (SOLVED)
//============================================
//============================================
function etiFixUrl(StrRef)
{
//alert('StartVal=' + StrRef);
//variables uses to manipulate the URL
var URL_Host = window.location.protocol + '//' + window.location.hostname + '/'; //for absolute refs
var URL_Dir = window.location.protocol + '//' + window.location.hostname + window.location.pathname; //for realtive refs
URL_Dir = URL_Dir.substr(0,URL_Dir.lastIndexOf("/")+1); //Remove filename from URL to get directory, dont include last "/" to insure proper relative urls
var URL = window.location.toString(); //for bookmarks
if (StrRef.substr(0,URL_Host.length)==URL_Host)
{
//The domain is in the ref
if(StrRef.substr(0,URL_Dir.length)==URL_Dir)
{
//The url less the page name and querystring
if(StrRef.substr(0,URL.length)==URL)
{
//The url - including the querystring is in StrRef - remove
StrRef = StrRef.substr(URL.length);
}
else
{
//only the url less the page name and querystring is in StrRef - remove
StrRef = StrRef.substr(URL_Dir.length);
}
}
else //only the domain is in is in StrRef - remove
{
StrRef = '/'+ StrRef.substr(URL_Host.length);
}
}
//alert('EndVal=' + StrRef);
//prevent 'about:blank from being inserted on anchor tags (href must be blank to render in the editor)
if (StrRef == 'about:blank')
return '';
else
return StrRef;
}
function etiCleanAbsolutePaths(editorDocument)
{
var anchorlen = editorDocument.all.tags('A').length;
var imagelen = editorDocument.all.tags('IMG').length;
//remove base from links where needed
for (i = 0;i <= anchorlen -1 ;i++)
{
objanchor = editorDocument.all.tags('A').item(i);
objanchor.href = etiFixUrl(objanchor.href);
}
//remove base from Images where needed
for (i = 0;i <= imagelen -1 ;i++)
{
objIMG = editorDocument.all.tags('IMG').item(i);
objIMG.src = etiFixUrl(objIMG.src);
}
}
//============================================
//============================================
Then, I updated the following to include a call to my cleanup function:
//============================================
//============================================
function Doc_OnSelectionChange()
{
etiCleanAbsolutePaths(FCK.EditorDocument);
FCK.Events.FireEvent( "OnSelectionChange" ) ;
}
//============================================
//============================================
I also added similar calls in the functions "GetHTML" and "GetXHTML" which can be found in the file "_source/internals/fck_1.js" I know that for those of you that use the editor for creating email newsletters, this may/may not be useful since you need to have the absolute path. I am handling this on the server side to append the approporiate root path to links and images for that specific case. Hope this helps! Please feel free to submit any bugs as well....Thanks!
RE: Relative URL replacement (SOLVED)
Wouldn't it be enough to call at the GetXHTML function (checking that the browser is IE)?
Also, although the code is needed only for IE I think that it's better to use always the standard methods, so instead of .all.tags('A') I would use .getElementsByTagName('A') as it has been supported since IE 5.0 and all the browsers support that function, so if you copy this code someday there will be no need to adapt it as it is already standard compliant.
RE: Relative URL replacement (more...)
=======================================
function etiFixUrl(StrRef)
{
//variables uses to manipulate the URL
var URL_Host = window.location.protocol + '//' + window.location.hostname + '/'; //for absolute refs
var URL_Dir = window.location.protocol + '//' + window.location.hostname + window.location.pathname; //for realtive refs
URL_Dir = URL_Dir.substr(0,URL_Dir.lastIndexOf("/")+1); //Remove filename from URL to get directory, dont include last "/" to insure proper relative urls
var URL = window.location.toString(); //for bookmarks
var URLedit_Host = window.parent.location.protocol + '//' + window.parent.location.hostname + '/'; //for absolute refs
var URLedit_Dir = window.parent.location.protocol + '//' + window.parent.location.hostname + window.parent.location.pathname; //for realtive refs
URLedit_Dir = URLedit_Dir.substr(0,URLedit_Dir.lastIndexOf("/")+1); //Remove filename from URL to get directory, dont include last "/" to insure proper relative urls
var URLedit = window.parent.location.toString(); //for bookmarks
//var s = 'Initial Value: ' + StrRef + '\n\nURL_Host: ' + URL_Host + '\n\nURL_Dir: ' + URL_Dir + '\n\nURL: ' + URL + '\n\nURLedit_Host: ' + URLedit_Host + '\n\nURLedit_Dir: ' + URLedit_Dir + '\n\nURLedit: ' + URLedit;
//The domain is in the ref... so we need to do some replacements
//if (StrRef.indexOf(URL_Host)==0 || StrRef.indexOf(URL_Host)==0)substr(0,URL_Host.length)==URL_Host || StrRef.substr(0,URLedit_Host.length)==URLedit_Host)
//{
//-------------------------------------------------------
//check standard view's window.location versions
//The url - including the querystring is in StrRef - remove
if(StrRef.indexOf(URL)==0) //substr(0,URL.length)==URL)
StrRef = StrRef.substr(URL.length);
//only the url less the page name and querystring is in StrRef - remove
if(StrRef.indexOf(URL_Dir)==0) //substr(0,URL_Dir.length)==URL_Dir)
StrRef = StrRef.substr(URL_Dir.length);
//-------------------------------------------------------
//check source view's window.parent.location versions
//The url - including the querystring is in StrRef - remove
if(StrRef.indexOf(URLedit)==0) //substr(0,URLedit.length)==URLedit)
StrRef = StrRef.substr(URLedit.length);
//only the url less the page name and querystring is in StrRef - remove
if(StrRef.indexOf(URLedit_Dir)==0) //substr(0,URLedit_Dir.length)==URLedit_Dir)
StrRef = StrRef.substr(URLedit_Dir.length);
//-------------------------------------------------------
//remove the domain name if that is all that is present
if(StrRef.indexOf(URL_Host)==0) //substr(0,URL_Host.length)==URL_Host)
StrRef = '/'+ StrRef.substr(URL_Host.length);
if(StrRef.indexOf(URLedit_Host)==0) //substr(0,URLedit_Host.length)==URLedit_Host)
StrRef = '/'+ StrRef.substr(URLv_Host.length);
//}
//replace any %20's with an actual space (the browser will resolve this just fine)
StrRef = etiReplace(StrRef, "%20", " ");
//alert(s + '\n\n===================\n\nEndVal=' + StrRef);
//prevent 'about:blank from being inserted on anchor tags (href must be blank to render in the editor)
if (StrRef == 'about:blank')
return '';
else
return StrRef;
}
function etiCleanAbsolutePaths(editorDocument)
{
var anchorlen = editorDocument.getElementsByTagName('A').length;
var imagelen = editorDocument.getElementsByTagName('IMG').length;
//remove base from links where needed
for (i = 0;i <= anchorlen -1 ;i++)
{
objanchor = editorDocument.getElementsByTagName('A').item(i);
objanchor.href = etiFixUrl(objanchor.href);
}
//remove base from Images where needed
for (i = 0;i <= imagelen -1 ;i++)
{
objIMG = editorDocument.getElementsByTagName('IMG').item(i);
objIMG.src = etiFixUrl(objIMG.src);
}
}
function etiReplace(inputString, fromString, toString) {
// Goes through the inputString and replaces every occurrence of fromString with toString
var temp = inputString;
if (fromString == "") {
return inputString;
}
if (toString.indexOf(fromString) == -1) {
while (temp.indexOf(fromString) != -1) {
var toTheLeft = temp.substring(0, temp.indexOf(fromString));
var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
temp = toTheLeft + toString + toTheRight;
}
} else {
var midStrings = new Array("~", "`", "_", "^", "#");
var midStringLen = 1;
var midString = "";
// Find a string that doesn't exist in the inputString to be used as an "inbetween" string
while (midString == "") {
for (var i=0; i < midStrings.length; i++) {
var tempMidString = "";
for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
if (fromString.indexOf(tempMidString) == -1) {
midString = tempMidString;
i = midStrings.length + 1;
}
}
}
// Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
while (temp.indexOf(fromString) != -1) {
var toTheLeft = temp.substring(0, temp.indexOf(fromString));
var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
temp = toTheLeft + midString + toTheRight;
}
// Next, replace the "inbetween" string with the "toString"
while (temp.indexOf(midString) != -1) {
var toTheLeft = temp.substring(0, temp.indexOf(midString));
var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
temp = toTheLeft + toString + toTheRight;
}
}
return temp;
}