[svn r22264] FS#2867 - The online editor: Corrections in the initialization script.

skala
Ivan Tcholakov 17 years ago
parent 81a713298b
commit 48be88bd44
  1. 36
      main/inc/lib/fckeditor/fckeditor.php

@ -362,50 +362,52 @@ class FCKeditor
} }
/** /**
* This method returns editor's custom configuration settings read from a php-file. * This method returns editor's custom configuration settings read from php-files.
* @return array Custom configuration data. * @return array Custom configuration data.
*/ */
private function & get_custom_configuration() { private function & get_custom_configuration() {
static $config; static $config;
static $toobar_sets = array();
if (!isset($config)) { if (!isset($config)) {
require api_get_path(LIBRARY_PATH).'fckeditor/myconfig.php'; require api_get_path(LIBRARY_PATH).'fckeditor/myconfig.php';
} }
// Seeking the toolbar.
$toolbar_dir = isset($config['ToolbarSets']['Directory']) ? $config['ToolbarSets']['Directory'] : 'default'; $toolbar_dir = isset($config['ToolbarSets']['Directory']) ? $config['ToolbarSets']['Directory'] : 'default';
$config['ToolbarSets']['Normal'] = null; return array_merge($config, $this->get_custom_toolbar_configuration($toolbar_dir));
$config['ToolbarSets']['Maximized'] = null; }
if (!isset($toobar_sets[$this->ToolbarSet])) {
/**
* This method returns editor's toolbar configuration settings read from a php-file.
* @return array Toolbar configuration data.
*/
private function & get_custom_toolbar_configuration($toolbar_dir) {
static $toolbar_config = array('Default' => array());
if (!isset($toolbar_config[$this->ToolbarSet])) {
$toolbar_config[$this->ToolbarSet] = array();
if (preg_match('/[a-zA-Z_]+/', $toolbar_dir) && preg_match('/[a-zA-Z_]+/', $this->ToolbarSet)) { // A security check. if (preg_match('/[a-zA-Z_]+/', $toolbar_dir) && preg_match('/[a-zA-Z_]+/', $this->ToolbarSet)) { // A security check.
// Seeking the toolbar.
@include api_get_path(LIBRARY_PATH).'fckeditor/toolbars/'.$toolbar_dir.'/'.self::camel_case_to_underscore($this->ToolbarSet).'.php'; @include api_get_path(LIBRARY_PATH).'fckeditor/toolbars/'.$toolbar_dir.'/'.self::camel_case_to_underscore($this->ToolbarSet).'.php';
if (!isset($config['ToolbarSets']['Normal'])) { if (!isset($config['ToolbarSets']['Normal'])) {
// No toolbar has been found yet. // No toolbar has been found yet.
if ($toolbar_dir == 'default') { if ($toolbar_dir == 'default') {
// It does not exist in "factory" toolbar definitions, giving up. // It does not exist in default toolbar definitions, giving up.
$this->ToolbarSet = 'Default'; $this->ToolbarSet = 'Default';
} else { } else {
// The custom toolbar does not exist, then trying to load the "factory" one. // The custom toolbar does not exist, then trying to load the default one.
@include api_get_path(LIBRARY_PATH).'fckeditor/toolbars/default/'.self::camel_case_to_underscore($this->ToolbarSet).'.php'; @include api_get_path(LIBRARY_PATH).'fckeditor/toolbars/default/'.self::camel_case_to_underscore($this->ToolbarSet).'.php';
if (!isset($config['ToolbarSets']['Normal'])) { if (!isset($config['ToolbarSets']['Normal'])) {
// It does not exist in "factory" toolbar definitions too, giving up. // It does not exist in default toolbar definitions, giving up.
$this->ToolbarSet = 'Default'; $this->ToolbarSet = 'Default';
} else { } else {
$toobar_sets[$this->ToolbarSet]['Normal'] = $config['ToolbarSets']['Normal']; $toolbar_config[$this->ToolbarSet] = $config;
$toobar_sets[$this->ToolbarSet]['Maximized'] = $config['ToolbarSets']['Maximized'];
} }
} }
} else { } else {
$toobar_sets[$this->ToolbarSet]['Normal'] = $config['ToolbarSets']['Normal']; $toolbar_config[$this->ToolbarSet] = $config;
$toobar_sets[$this->ToolbarSet]['Maximized'] = $config['ToolbarSets']['Maximized'];
} }
} else { } else {
$this->ToolbarSet = 'Default'; $this->ToolbarSet = 'Default';
} }
} else {
$config['ToolbarSets']['Normal'] = $toobar_sets[$this->ToolbarSet]['Normal'];
$config['ToolbarSets']['Maximized'] = $toobar_sets[$this->ToolbarSet]['Maximized'];
} }
return $config; return $toolbar_config[$this->ToolbarSet];
} }
/** /**

Loading…
Cancel
Save