2
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
* Copyright (C) 2003-2007 Frederico Caldeira Knabben
7
* Licensed under the terms of any of the following licenses at your
10
* - GNU General Public License Version 2 or later (the "GPL")
11
* http://www.gnu.org/licenses/gpl.html
13
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14
* http://www.gnu.org/licenses/lgpl.html
16
* - Mozilla Public License Version 1.1 or later (the "MPL")
17
* http://www.mozilla.org/MPL/MPL-1.1.html
21
* Creates and initializes the FCKConfig object.
24
var FCKConfig = FCK.Config = new Object() ;
27
For the next major version (probably 3.0) we should move all this stuff to
28
another dedicated object and leave FCKConfig as a holder object for settings only).
32
if ( document.location.protocol == 'file:' )
34
FCKConfig.BasePath = decodeURIComponent( document.location.pathname.substr(1) ) ;
35
FCKConfig.BasePath = FCKConfig.BasePath.replace( /\\/gi, '/' ) ;
36
FCKConfig.BasePath = 'file://' + FCKConfig.BasePath.substring(0,FCKConfig.BasePath.lastIndexOf('/')+1) ;
37
FCKConfig.FullBasePath = FCKConfig.BasePath ;
41
FCKConfig.BasePath = document.location.pathname.substring(0,document.location.pathname.lastIndexOf('/')+1) ;
42
FCKConfig.FullBasePath = document.location.protocol + '//' + document.location.host + FCKConfig.BasePath ;
45
FCKConfig.EditorPath = FCKConfig.BasePath.replace( /editor\/$/, '' ) ;
47
// There is a bug in Gecko. If the editor is hidden on startup, an error is
48
// thrown when trying to get the screen dimentions.
51
FCKConfig.ScreenWidth = screen.width ;
52
FCKConfig.ScreenHeight = screen.height ;
56
FCKConfig.ScreenWidth = 800 ;
57
FCKConfig.ScreenHeight = 600 ;
60
// Override the actual configuration values with the values passed throw the
61
// hidden field "<InstanceName>___Config".
62
FCKConfig.ProcessHiddenField = function()
64
this.PageConfig = new Object() ;
66
// Get the hidden field.
67
var oConfigField = window.parent.document.getElementById( FCK.Name + '___Config' ) ;
69
// Do nothing if the config field was not defined.
70
if ( ! oConfigField ) return ;
72
var aCouples = oConfigField.value.split('&') ;
74
for ( var i = 0 ; i < aCouples.length ; i++ )
76
if ( aCouples[i].length == 0 )
79
var aConfig = aCouples[i].split( '=' ) ;
80
var sKey = decodeURIComponent( aConfig[0] ) ;
81
var sVal = decodeURIComponent( aConfig[1] ) ;
83
if ( sKey == 'CustomConfigurationsPath' ) // The Custom Config File path must be loaded immediately.
84
FCKConfig[ sKey ] = sVal ;
86
else if ( sVal.toLowerCase() == "true" ) // If it is a boolean TRUE.
87
this.PageConfig[ sKey ] = true ;
89
else if ( sVal.toLowerCase() == "false" ) // If it is a boolean FALSE.
90
this.PageConfig[ sKey ] = false ;
92
else if ( sVal.length > 0 && !isNaN( sVal ) ) // If it is a number.
93
this.PageConfig[ sKey ] = parseInt( sVal, 10 ) ;
95
else // In any other case it is a string.
96
this.PageConfig[ sKey ] = sVal ;
100
function FCKConfig_LoadPageConfig()
102
var oPageConfig = FCKConfig.PageConfig ;
103
for ( var sKey in oPageConfig )
104
FCKConfig[ sKey ] = oPageConfig[ sKey ] ;
107
function FCKConfig_PreProcess()
109
var oConfig = FCKConfig ;
111
// Force debug mode if fckdebug=true in the QueryString (main page).
112
if ( oConfig.AllowQueryStringDebug )
116
if ( (/fckdebug=true/i).test( window.top.location.search ) )
117
oConfig.Debug = true ;
119
catch (e) { /* Ignore it. Much probably we are inside a FRAME where the "top" is in another domain (security error). */ }
122
// Certifies that the "PluginsPath" configuration ends with a slash.
123
if ( !oConfig.PluginsPath.EndsWith('/') )
124
oConfig.PluginsPath += '/' ;
126
// EditorAreaCSS accepts an array of paths or a single path (as string).
127
// In the last case, transform it in an array.
128
if ( typeof( oConfig.EditorAreaCSS ) == 'string' )
129
oConfig.EditorAreaCSS = [ oConfig.EditorAreaCSS ] ;
131
var sComboPreviewCSS = oConfig.ToolbarComboPreviewCSS ;
132
if ( !sComboPreviewCSS || sComboPreviewCSS.length == 0 )
133
oConfig.ToolbarComboPreviewCSS = oConfig.EditorAreaCSS ;
134
else if ( typeof( sComboPreviewCSS ) == 'string' )
135
oConfig.ToolbarComboPreviewCSS = [ sComboPreviewCSS ] ;
138
// Define toolbar sets collection.
139
FCKConfig.ToolbarSets = new Object() ;
141
// Defines the plugins collection.
142
FCKConfig.Plugins = new Object() ;
143
FCKConfig.Plugins.Items = new Array() ;
145
FCKConfig.Plugins.Add = function( name, langs, path )
147
FCKConfig.Plugins.Items.AddItem( [name, langs, path] ) ;
150
// FCKConfig.ProtectedSource: object that holds a collection of Regular
151
// Expressions that defined parts of the raw HTML that must remain untouched
152
// like custom tags, scripts, server side code, etc...
153
FCKConfig.ProtectedSource = new Object() ;
155
// Initialize the regex array with the default ones.
156
FCKConfig.ProtectedSource.RegexEntries = [
157
// First of any other protection, we must protect all comments to avoid
158
// loosing them (of course, IE related).
161
// Script tags will also be forced to be protected, otherwise IE will execute them.
162
/<script[\s\S]*?<\/script>/gi,
164
// <noscript> tags (get lost in IE and messed up in FF).
165
/<noscript[\s\S]*?<\/noscript>/gi,
167
// Protect <object> tags. See #359.
168
/<object[\s\S]+?<\/object>/gi
171
FCKConfig.ProtectedSource.Add = function( regexPattern )
173
this.RegexEntries.AddItem( regexPattern ) ;
176
FCKConfig.ProtectedSource.Protect = function( html )
178
function _Replace( protectedSource )
180
var index = FCKTempBin.AddElement( protectedSource ) ;
181
return '<!--{PS..' + index + '}-->' ;
184
for ( var i = 0 ; i < this.RegexEntries.length ; i++ )
186
html = html.replace( this.RegexEntries[i], _Replace ) ;
192
FCKConfig.ProtectedSource.Revert = function( html, clearBin )
194
function _Replace( m, opener, index )
196
var protectedValue = clearBin ? FCKTempBin.RemoveElement( index ) : FCKTempBin.Elements[ index ] ;
197
// There could be protected source inside another one.
198
return FCKConfig.ProtectedSource.Revert( protectedValue, clearBin ) ;
201
return html.replace( /(<|<)!--\{PS..(\d+)\}--(>|>)/g, _Replace ) ;
b'\\ No newline at end of file'