[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. 144
      main/inc/lib/fckeditor/myconfig.js
  3. 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;
}

@ -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 = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' ;
FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/silver/' ;
FCKConfig.ProtectedSource.Add( /<script[\s\S]*?\/script>/gi ) ; // To protect <script> tags.
FCKConfig.AutoDetectLanguage = false ;
FCKConfig.ContextMenu = ['Generic','Link','Anchor','Image','Flash','Select','Textarea','Checkbox','Radio','TextField','HiddenField','ImageButton','Button','BulletedList','NumberedList','Table','Form'] ;
FCKConfig.TemplatesXmlPath = FCKConfig.EditorPath + 'fcktemplates.xml.php' ;
FCKConfig.DisableFFTableHandles = false ;
FCKConfig.SmileyWindowWidth = 450 ;
FCKConfig.SmileyWindowHeight = 250 ;
/*
* Plugins.
*/
*/
FCKConfig.DocType = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' ;
FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/silver/' ;
FCKConfig.ProtectedSource.Add( /<script[\s\S]*?\/script>/gi ) ; // To protect <script> tags.
FCKConfig.AutoDetectLanguage = false ;
FCKConfig.ContextMenu = ['Generic','Link','Anchor','Image','Flash','Select','Textarea','Checkbox','Radio','TextField','HiddenField','ImageButton','Button','BulletedList','NumberedList','Table','Form'] ;
FCKConfig.TemplatesXmlPath = FCKConfig.EditorPath + 'fcktemplates.xml.php' ;
FCKConfig.DisableFFTableHandles = false ;
FCKConfig.SmileyWindowWidth = 450 ;
FCKConfig.SmileyWindowHeight = 250 ;
/*
* Plugins.
*/
// Loading integrated by the Dokeos team plugins. To enable/disable them, see myconfig.php.
FCKConfig.AvailableLanguages = 'en,af,ar,bg,bn,bs,ca,cs,da,de,el,en-au,en-ca,en-uk,eo,es,et,eu,fa,fi,fo,fr-ca,fr,gl,gu,he,hi,hr,hu,is,it,ja,km,ko,lt,lv,mn,ms,nb,nl,no,pl,pt-br,pt,ro,ru,sk,sl,sr-latn,sr,sv,th,tr,uk,vi,zh-cn,zh' ;
FCKConfig.LoadPlugin = eval( '(' + FCKConfig.PageConfig.LoadPlugin + ')' ) ;
@ -75,17 +75,17 @@ for ( var i = 0 ; i < FCKConfig.LoadPlugin.length ; i++ ) {
// If you leave an empty string then the toolbar icon won't be shown.
FCKConfig.GoogleMaps_Key = 'ABQIAAAAlXu5Pw6DFAUgqM2wQn01gxT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSy5hTGQdsosYD3dz6faZHVrO-02A' ;
// This is the old flash plugin. Now the editor has a built-in flash dialog.
// Probably this plugin will be removed at the next release.
//FCKConfig.Plugins.Add('Flash', 'en') ;
// This is the old flash plugin. Now the editor has a built-in flash dialog.
// Probably this plugin will be removed at the next release.
//FCKConfig.Plugins.Add('Flash', 'en') ;
// You may add your own plugins here, i.e. write something as follows:
// FCKConfig.Plugins.Add('my_plugin', 'en') ;
// FCKConfig.Plugins.Add('my_plugin', 'en') ;
/*
* File Manager.
*/
// Window size of the file manager:
// for any type of files;
FCKConfig.LinkBrowserWindowWidth = 782 ;
@ -103,17 +103,17 @@ FCKConfig.MP3BrowserWindowHeight = 490 ;
FCKConfig.VideoBrowserWindowWidth = 782 ;
FCKConfig.VideoBrowserWindowHeight = 490 ;
// for video (flv) files.
FCKConfig.MediaBrowserWindowWidth = 782 ;
FCKConfig.MediaBrowserWindowHeight = 490 ;
FCKConfig.MediaBrowserWindowWidth = 782 ;
FCKConfig.MediaBrowserWindowHeight = 490 ;
//Upload path for the Image manager. Leave it empty.
FCKConfig.IMUploadPath = '' ;
/*
* Quick-upload tabs.
*/
// Lists of allowed and denied name extensions of files to be uploaded.
// for all acceptable types of files;
FCKConfig.LinkUploadAllowedExtensions = '.(7z|aiff|asf|avi|bmp|csv|doc|fla|flv|gif|gz|gzip|jpeg|jpg|mid|mov|mp3|mp4|mpc|mpeg|mpg|ods|odt|pdf|png|ppt|pxd|qt|ram|rar|rm|rmi|rmvb|rtf|sdc|sitd|swf|sxc|sxw|tar|tgz|tif|tiff|txt|vsd|wav|wma|wmv|xls|xml|zip)$' ; // empty for all
@ -134,11 +134,11 @@ FCKConfig.VideoUploadDeniedExtensions = '' ;
FCKConfig.MediaUploadAllowedExtensions = '.(flv|mp4)$' ;
FCKConfig.MediaUploadDeniedExtensions = '' ;
// Note: These lists get combined with the platform's white and black lists.
/*
* Other settings.
*/
// TODO: This setting seems obsolete. To be checked for removal.
FCKConfig.UserStatus = 'teacher' ;
/*
* Other settings.
*/
// TODO: This setting seems obsolete. To be checked for removal.
FCKConfig.UserStatus = 'teacher' ;

@ -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