Вход Регистрация
Файл: fckeditor/editor/_source/internals/fckconfig.js
Строк: 337
<?php

/*
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
 * Copyright (C) 2003-2008 Frederico Caldeira Knabben
 *
 * == BEGIN LICENSE ==
 *
 * Licensed under the terms of any of the following licenses at your
 * choice:
 *
 *  - GNU General Public License Version 2 or later (the "GPL")
 *    http://www.gnu.org/licenses/gpl.html
 *
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 *    http://www.gnu.org/licenses/lgpl.html
 *
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
 *    http://www.mozilla.org/MPL/MPL-1.1.html
 *
 * == END LICENSE ==
 *
 * Creates and initializes the FCKConfig object.
 */

var FCKConfig FCK.Config = new Object() ;

/*
    For the next major version (probably 3.0) we should move all this stuff to
    another dedicated object and leave FCKConfig as a holder object for settings only).
*/

// Editor Base Path
if ( document.location.protocol == 'file:' )
{
    
FCKConfig.BasePath decodeURIComponentdocument.location.pathname.substr(1) ) ;
    
FCKConfig.BasePath FCKConfig.BasePath.replace( /\/gi'/' ) ;

    
// The way to address local files is different according to the OS.
    // In Windows it is file:// but in MacOs it is file:/// so let's get it automatically
    
var sFullProtocol document.location.href.match( /^(file:/{2,3})/ )[1] ;
    
// #945 Opera does strange things with files loaded from the disk, and it fails in Mac to load xml files
    
if ( FCKBrowserInfo.IsOpera )
        
sFullProtocol += 'localhost/' ;

    
FCKConfig.BasePath sFullProtocol FCKConfig.BasePath.substring0FCKConfig.BasePath.lastIndexOf'/' ) + 1) ;
}
else
    
FCKConfig.BasePath document.location.protocol '//' document.location.host +
        
document.location.pathname.substring0document.location.pathname.lastIndexOf'/' ) + 1) ;

FCKConfig.FullBasePath FCKConfig.BasePath ;

FCKConfig.EditorPath FCKConfig.BasePath.replace( /editor/$/, '' ) ;

// There is a bug in Gecko. If the editor is hidden on startup, an error is
// thrown when trying to get the screen dimensions.
try
{
    
FCKConfig.ScreenWidth    screen.width ;
    
FCKConfig.ScreenHeight    screen.height ;
}
catch (
e)
{
    
FCKConfig.ScreenWidth    800 ;
    
FCKConfig.ScreenHeight    600 ;
}

// Override the actual configuration values with the values passed throw the
// hidden field "<InstanceName>___Config".
FCKConfig.ProcessHiddenField = function()
{
    
this.PageConfig = new Object() ;

    
// Get the hidden field.
    
var oConfigField window.parent.document.getElementByIdFCK.Name '___Config' ) ;

    
// Do nothing if the config field was not defined.
    
if ( ! oConfigField ) return ;

    var 
aCouples oConfigField.value.split('&') ;

    for ( var 
aCouples.length i++ )
    {
        if ( 
aCouples[i].length == )
            continue ;

        var 
aConfig aCouples[i].split'=' ) ;
        var 
sKey decodeURIComponentaConfig[0] ) ;
        var 
sVal decodeURIComponentaConfig[1] ) ;

        if ( 
sKey == 'CustomConfigurationsPath' )    // The Custom Config File path must be loaded immediately.
            
FCKConfigsKey ] = sVal ;

        else if ( 
sVal.toLowerCase() == "true" )    // If it is a boolean TRUE.
            
this.PageConfigsKey ] = true ;

        else if ( 
sVal.toLowerCase() == "false" )    // If it is a boolean FALSE.
            
this.PageConfigsKey ] = false ;

        else if ( 
sVal.length && !isNaNsVal ) )    // If it is a number.
            
this.PageConfigsKey ] = parseIntsVal10 ) ;

        else                                        
// In any other case it is a string.
            
this.PageConfigsKey ] = sVal ;
    }
}

function 
FCKConfig_LoadPageConfig()
{
    var 
oPageConfig FCKConfig.PageConfig ;
    for ( var 
sKey in oPageConfig )
        
FCKConfigsKey ] = oPageConfigsKey ] ;
}

function 
FCKConfig_PreProcess()
{
    var 
oConfig FCKConfig ;

    
// Force debug mode if fckdebug=true in the QueryString (main page).
    
if ( oConfig.AllowQueryStringDebug )
    {
        try
        {
            if ( (/
fckdebug=true/i).testwindow.top.location.search ) )
                
oConfig.Debug true ;
        }
        catch (
e) { /* Ignore it. Much probably we are inside a FRAME where the "top" is in another domain (security error). */ }
    }

    
// Certifies that the "PluginsPath" configuration ends with a slash.
    
if ( !oConfig.PluginsPath.EndsWith('/') )
        
oConfig.PluginsPath += '/' ;

    
// If no ToolbarComboPreviewCSS, point it to EditorAreaCSS.
    
var sComboPreviewCSS oConfig.ToolbarComboPreviewCSS ;
    if ( !
sComboPreviewCSS || sComboPreviewCSS.length == )
        
oConfig.ToolbarComboPreviewCSS oConfig.EditorAreaCSS ;

    
// Turn the attributes that will be removed in the RemoveFormat from a string to an array
    
oConfig.RemoveAttributesArray = (oConfig.RemoveAttributes || '').split',' );

    if ( !
FCKConfig.SkinEditorCSS || FCKConfig.SkinEditorCSS.length == )
        
FCKConfig.SkinEditorCSS FCKConfig.SkinPath 'fck_editor.css' ;

    if ( !
FCKConfig.SkinDialogCSS || FCKConfig.SkinDialogCSS.length == )
        
FCKConfig.SkinDialogCSS FCKConfig.SkinPath 'fck_dialog.css' ;
}

// Define toolbar sets collection.
FCKConfig.ToolbarSets = new Object() ;

// Defines the plugins collection.
FCKConfig.Plugins = new Object() ;
FCKConfig.Plugins.Items = new Array() ;

FCKConfig.Plugins.Add = function( namelangspath )
{
    
FCKConfig.Plugins.Items.AddItem( [namelangspath] ) ;
}

// FCKConfig.ProtectedSource: object that holds a collection of Regular
// Expressions that defined parts of the raw HTML that must remain untouched
// like custom tags, scripts, server side code, etc...
FCKConfig.ProtectedSource = new Object() ;

// Generates a string used to identify and locate the Protected Tags comments.
FCKConfig.ProtectedSource._CodeTag = (new Date()).valueOf() ;

// Initialize the regex array with the default ones.
FCKConfig.ProtectedSource.RegexEntries = [
    
// First of any other protection, we must protect all comments to avoid
    // loosing them (of course, IE related).
    
/<!--[sS]*?-->/,

    
// Script tags will also be forced to be protected, otherwise IE will execute them.
    
/<script[sS]*?</script>/gi,

    
// <noscript> tags (get lost in IE and messed up in FF).
    
/<noscript[sS]*?</noscript>/gi
] ;

FCKConfig.ProtectedSource.Add = function( regexPattern )
{
    
this.RegexEntries.AddItemregexPattern ) ;
}

FCKConfig.ProtectedSource.Protect = function( html )
{
    var 
codeTag this._CodeTag ;
    function 
_ReplaceprotectedSource )
    {
        var 
index FCKTempBin.AddElementprotectedSource ) ;
        return 
'<!--{' codeTag index '}-->' ;
    }

    for ( var 
this.RegexEntries.length i++ )
    {
        
html html.replacethis.RegexEntries[i], _Replace ) ;
    }

    return 
html ;
}

FCKConfig.ProtectedSource.Revert = function( htmlclearBin )
{
    function 
_Replacemopenerindex )
    {
        var 
protectedValue clearBin FCKTempBin.RemoveElementindex ) : FCKTempBin.Elementsindex ] ;
        
// There could be protected source inside another one.
        
return FCKConfig.ProtectedSource.RevertprotectedValueclearBin ) ;
    }

    var 
regex = new RegExp"(<|&lt;)!--\{" this._CodeTag "(\d+)\}--(>|&gt;)""g" ) ;
    return 
html.replaceregex_Replace ) ;
}

// Returns a string with the attributes that must be appended to the body
FCKConfig.GetBodyAttributes = function()
{
    var 
bodyAttributes '' ;
    
// Add id and class to the body.
    
if ( this.BodyId && this.BodyId.length )
        
bodyAttributes += ' id="' this.BodyId '"' ;
    if ( 
this.BodyClass && this.BodyClass.length )
        
bodyAttributes += ' class="' this.BodyClass '"' ;

    return 
bodyAttributes ;
}

// Sets the body attributes directly on the node
FCKConfig.ApplyBodyAttributes = function( oBody )
{
    
// Add ID and Class to the body
    
if ( this.BodyId && this.BodyId.length )
        
oBody.id FCKConfig.BodyId ;
    if ( 
this.BodyClass && this.BodyClass.length )
        
oBody.className += ' ' FCKConfig.BodyClass ;
}
?>
Онлайн: 0
Реклама