From 93bfd7324171cda52a30778115220afe1ba6a0ec Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Sun, 12 Jul 2009 15:09:52 +0200 Subject: [PATCH] [svn r22008] FS#2867 - The online editor, the mimetex plugin: Reworks, moving automatic detection related options from fckeditor.php to myconfig.php. --- main/inc/lib/fckeditor/fckeditor.php | 65 +++++++----- main/inc/lib/fckeditor/myconfig.js | 144 +++++++++++++-------------- main/inc/lib/fckeditor/myconfig.php | 23 ++++- 3 files changed, 133 insertions(+), 99 deletions(-) diff --git a/main/inc/lib/fckeditor/fckeditor.php b/main/inc/lib/fckeditor/fckeditor.php index 6bc3a64d90..ec578a1904 100644 --- a/main/inc/lib/fckeditor/fckeditor.php +++ b/main/inc/lib/fckeditor/fckeditor.php @@ -25,7 +25,8 @@ * instances in PHP pages on server side. */ -// Code to adapt the editor to the Dokeos LMS has been added by the Dokeos team, FEB-2009. +// Code about adaptation of the editor and its plugins has been added by the Dokeos team, February - July 2009. +// For modifying configuration options see myconfig.php and myconfig.js. /** * Check if browser is compatible with FCKeditor. @@ -37,18 +38,6 @@ //require_once api_get_path(LIBRARY_PATH).'/media.lib.php'; // This fails in some pages (Tests). require_once dirname(__FILE__).'/../media.lib.php'; -// Configuration constants. - -// The MimeTeX plugin support, a check whether the server executable file has been installed. -define ( 'CHECK_MIMETEX_PLUGIN_INSTALLED', true ) ; // Change to false in case of unexpected problems. Then installed state will be assumed. -define ( 'CHECK_MIMETEX_PLUGIN_INSTALLED_TIMEOUT', 0.05 ) ; // Response timeout in seconds. Keep this value as low as possible on Windows servers. -define ( 'CHECK_MIMETEX_PLUGIN_INSTALLED_URL_BASE', // This setting is about how to check mimetex executable presense. Possible values: 'ip' and 'domain_name' - IS_WINDOWS_OS - ? 'ip' // http://127.0.0.1/mimetex.exe will be checked for presense, - // this is a preferable setting for Windows Vista, because its firewall does not block this address by default. - : 'domain_name' // http://www.mydokeos.com/mimetex.cgi will be checked for presense. If DNS has problems (if it is slow for example). try using the 'ip' setting. -) ; - function FCKeditor_IsCompatibleBrowser() { if ( isset( $_SERVER ) ) { @@ -408,7 +397,7 @@ class FCKeditor $this->get_repository_configuration(), self::get_media_configuration(), self::get_user_configuration_data(), - self::get_mimetex_plugin_configuration() + $this->get_mimetex_plugin_configuration() ); } @@ -592,19 +581,43 @@ class FCKeditor * @return array */ private function & get_mimetex_plugin_configuration() { - static $config ; - if ( !is_array( $config ) ) { - $server_base = explode( '/', api_get_path( WEB_PATH ) ) ; - $server_base_ip = $server_base[0] . '/' . $server_base[1] . '/127.0.0.1' ; - $server_base = $server_base[0]. '/' . $server_base[1]. '/' . $server_base[2] ; - $url_relative = '/cgi-bin/mimetex' . ( IS_WINDOWS_OS ? '.exe' : '.cgi' ) ; - if ( CHECK_MIMETEX_PLUGIN_INSTALLED ) { - $check_mimetex_url = ( CHECK_MIMETEX_PLUGIN_INSTALLED_URL_BASE == 'ip' ? $server_base_ip : $server_base ) . $url_relative . '?' . rand() ; - $config['IsMimetexInstalled'] = self::url_exists( $check_mimetex_url, CHECK_MIMETEX_PLUGIN_INSTALLED_TIMEOUT ) ; - } else { - $config['IsMimetexInstalled'] = true ; + static $config; + if (!isset($config)) { + $config = array(); + if (is_array($this->Config['LoadPlugin']) && in_array('mimetex', $this->Config['LoadPlugin'])) { + $server_base = api_get_path(WEB_SERVER_ROOT_PATH); + $server_base_parts = explode('/', $server_base); + $url_relative = 'cgi-bin/mimetex' . ( IS_WINDOWS_OS ? '.exe' : '.cgi' ); + if (!isset($this->Config['MimetexExecutableInstalled'])) { + $this->Config['MimetexExecutableDetectionMethod'] = 'detect'; + } + if ($this->Config['MimetexExecutableInstalled'] == 'detect') { + $detection_method = isset($this->Config['MimetexExecutableDetectionMethod']) ? $this->Config['MimetexExecutableDetectionMethod'] : 'bootstrap_ip'; + $detection_timeout = isset($this->Config['MimetexExecutableDetectionTimeout']) ? $this->Config['MimetexExecutableDetectionTimeout'] : 0.05; + switch ($detection_method) { + case 'bootstrap_ip': + $detection_url = $server_base_parts[0] . '//127.0.0.1/'; + break; + case 'localhost': + $detection_url = $server_base_parts[0] . '//localhost/'; + break; + case 'ip': + $detection_url = $server_base_parts[0] . '//' . $_SERVER['SERVER_ADDR'] . '/'; + break; + default: + $detection_url = $server_base_parts[0] . '//' . $_SERVER['SERVER_NAME'] . '/'; + } + $detection_url .= $url_relative . '?' . rand(); + $config['IsMimetexInstalled'] = self::url_exists($detection_url, $detection_timeout); + } else { + $config['IsMimetexInstalled'] = $this->Config['MimetexExecutableInstalled']; + } + $config['MimetexUrl'] = $server_base . $url_relative; } - $config['MimetexUrl'] = $server_base . $url_relative ; + // Cleaning detection related settings, we don't need them anymore. + unset($this->Config['MimetexExecutableInstalled']); + unset($this->Config['MimetexExecutableDetectionMethod']); + unset($this->Config['MimetexExecutableDetectionTimeout']); } return $config; } diff --git a/main/inc/lib/fckeditor/myconfig.js b/main/inc/lib/fckeditor/myconfig.js index 1a2dd7e2b3..68b1ef2ff3 100644 --- a/main/inc/lib/fckeditor/myconfig.js +++ b/main/inc/lib/fckeditor/myconfig.js @@ -1,56 +1,56 @@ -/* - * Dokeos - elearning and course management software - * - * Copyright (c) 2008-2009 Dokeos SPRL - * Copyright (c) 2008-2009 Julio Montoya - * Copyright (c) 2008-2009 Juan Carlos Raña - * Copyright (c) 2008-2009 Ivan Tcholakov - * - * For a full list of contributors, see "credits.txt". - * The full license can be read in "license.txt". - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * See the GNU General Public License for more details. - * - * Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium - * Mail: info@dokeos.com - */ - -/* - * Custom editor configuration settings. - * - * Follow this link for more information: - * http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options - * - * Please, do not modify the file fckconfig.js in order to make upgrades easy. - * Just create your desired settings in this file, myconfig.js. +/* + * Dokeos - elearning and course management software + * + * Copyright (c) 2008-2009 Dokeos SPRL + * Copyright (c) 2008-2009 Julio Montoya + * Copyright (c) 2008-2009 Juan Carlos Raña + * Copyright (c) 2008-2009 Ivan Tcholakov + * + * For a full list of contributors, see "credits.txt". + * The full license can be read in "license.txt". + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * See the GNU General Public License for more details. + * + * Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium + * Mail: info@dokeos.com + */ + +/* + * Custom editor configuration settings. + * + * Follow this link for more information: + * http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options + * + * Please, do not modify the file fckconfig.js in order to make upgrades easy. + * Just create your desired settings in this file, myconfig.js. * Also, configuration options (with higher priority) may be created/modified within the file myconfig.php. - */ - -FCKConfig.DocType = '' ; -FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/silver/' ; - -FCKConfig.ProtectedSource.Add( //gi ) ; // To protect