From 48be88bd4426952294d94d77b09769066c495464 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Tue, 21 Jul 2009 00:39:38 +0200 Subject: [PATCH] [svn r22264] FS#2867 - The online editor: Corrections in the initialization script. --- main/inc/lib/fckeditor/fckeditor.php | 36 +++++++++++++++------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/main/inc/lib/fckeditor/fckeditor.php b/main/inc/lib/fckeditor/fckeditor.php index 49123cc8ea..2cce21c01d 100644 --- a/main/inc/lib/fckeditor/fckeditor.php +++ b/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. */ private function & get_custom_configuration() { static $config; - static $toobar_sets = array(); if (!isset($config)) { require api_get_path(LIBRARY_PATH).'fckeditor/myconfig.php'; } - // Seeking the toolbar. $toolbar_dir = isset($config['ToolbarSets']['Directory']) ? $config['ToolbarSets']['Directory'] : 'default'; - $config['ToolbarSets']['Normal'] = null; - $config['ToolbarSets']['Maximized'] = null; - if (!isset($toobar_sets[$this->ToolbarSet])) { + return array_merge($config, $this->get_custom_toolbar_configuration($toolbar_dir)); + } + + /** + * 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. + // Seeking the toolbar. @include api_get_path(LIBRARY_PATH).'fckeditor/toolbars/'.$toolbar_dir.'/'.self::camel_case_to_underscore($this->ToolbarSet).'.php'; if (!isset($config['ToolbarSets']['Normal'])) { // No toolbar has been found yet. 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'; } 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'; 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'; } else { - $toobar_sets[$this->ToolbarSet]['Normal'] = $config['ToolbarSets']['Normal']; - $toobar_sets[$this->ToolbarSet]['Maximized'] = $config['ToolbarSets']['Maximized']; + $toolbar_config[$this->ToolbarSet] = $config; } } } else { - $toobar_sets[$this->ToolbarSet]['Normal'] = $config['ToolbarSets']['Normal']; - $toobar_sets[$this->ToolbarSet]['Maximized'] = $config['ToolbarSets']['Maximized']; + $toolbar_config[$this->ToolbarSet] = $config; } } else { $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]; } /**