[svn r22008] FS#2867 - The online editor, the mimetex plugin: Reworks, moving automatic detection related options from fckeditor.php to myconfig.php.

skala
Ivan Tcholakov 16 years ago
parent 833edd3468
commit 93bfd73241
  1. 65
      main/inc/lib/fckeditor/fckeditor.php
  2. 23
      main/inc/lib/fckeditor/myconfig.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;
}

@ -105,8 +105,29 @@ $config['LoadPlugin'][] = 'youtube';
$config['LoadPlugin'][] = 'googlemaps';
// mimetex : // Adds a dilog for inserting mathematical formulas. In order this plugin to work prpoperly, preliminary changes
// in your server configuration have to be done. See the installation guide.
// in your server configuration have to be done. The MimeTex executable file has to be installed, see the installation guide.
$config['LoadPlugin'][] = 'mimetex';
// ***** Additional settings that are active only when the 'mimetex' plugin has been loaded. *****
// The following setting determines whether MimeTex executable file has been installed or not. It should be accessible for browsers at
// address http://mysite.com/cgi-bin/mimetex.cgi (Linux) or at address http://mysite.com/cgi-bin/mimetex.exe (Windows).
// How to test manually: Open your browser and enter in the address bar something like http://mysite.com/cgi-bin/mimetex.cgi?hello
// By default, the system tries to detect MimeTex executable automatically.
// In case that detection fails for some reason, but you are sure that the MimeTeX executable has been correctly installed -
// set this option to boolean true value.
$config['MimetexExecutableInstalled'] = 'detect'; // 'detect' (default), true, false
// Sometimes detection fails (due to slow DNS service, security restrictions, ...). For better probability of success,
// the following methods for detection have been defined:
// 'bootstrap_ip' - detection is tried at address like http://127.0.0.1/cgi-bin/mimetex.cgi
// 'localhost' - detection is tried at address like http://localhost/cgi-bin/mimetex.cgi
// 'ip' - detection is tried at ip address, for example http://192.168.0.1/cgi-bin/mimetex.cgi
// 'server_name' - detection is tried at address based on server's name, for example http://mysite.com/cgi-bin/mimetex.cgi
if (IS_WINDOWS_OS) {
$config['MimetexExecutableDetectionMethod'] = 'bootstrap_ip'; // This has better chance on Windows (there is no firewall blocking).
} else {
$config['MimetexExecutableDetectionMethod'] = 'server_name';
}
// Timeout for mimetex executable detection - keep this value as low as possible, especially on Windows servers.
$config['MimetexExecutableDetectionTimeout'] = 0.05;
// wikilink : Adds a dialog for inserting wiki-formatted links.
$config['LoadPlugin'][] = 'wikilink';

Loading…
Cancel
Save