mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
Replaced old ckeditor configuration code with own class, fixed felamimail to work with it
This commit is contained in:
parent
30ce2262dd
commit
dd3496be0b
@ -1,268 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* eGroupWare - API ckeditor setup (set up ckeditor with user prefs)
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @author RalfBecker-AT-outdoor-training.de
|
||||
* @author Andreas Stoeckel <as-AT-stylite.de>
|
||||
* @package api
|
||||
* @subpackage tools
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
//Disable framework and cachecontrol
|
||||
$GLOBALS['egw_info'] = array(
|
||||
'flags' => array(
|
||||
'currentapp' => 'home',
|
||||
'noheader' => True,
|
||||
'nonavbar' => True,
|
||||
'noappheader' => True,
|
||||
'noappfooter' => True,
|
||||
'nofooter' => True,
|
||||
'nocachecontrol' => True // allow caching
|
||||
)
|
||||
);
|
||||
|
||||
try {
|
||||
include('../../header.inc.php');
|
||||
}
|
||||
catch (egw_exception_no_permission_app $e) {
|
||||
// ignore exception, if home is not allowed, eg. for sitemgr
|
||||
}
|
||||
|
||||
include('../../header.inc.php');
|
||||
|
||||
header('Content-type: text/javascript; charset='.translation::charset());
|
||||
|
||||
/**
|
||||
* Returns an array which contains both, the current user language and the current
|
||||
* user country setting.
|
||||
*/
|
||||
function get_lang_country()
|
||||
{
|
||||
//use the lang and country information to construct a possible lang info for CKEditor UI and scayt_slang
|
||||
$lang = ($GLOBALS['egw_info']['user']['preferences']['common']['spellchecker_lang'] ?
|
||||
$GLOBALS['egw_info']['user']['preferences']['common']['spellchecker_lang']:
|
||||
$GLOBALS['egw_info']['user']['preferences']['common']['lang']);
|
||||
|
||||
$country = $GLOBALS['egw_info']['user']['preferences']['common']['country'];
|
||||
|
||||
if (!(strpos($lang,'-')===false))
|
||||
list($lang,$country) = explode('-',$lang);
|
||||
|
||||
return array(
|
||||
'lang' => $lang,
|
||||
'country' => $country
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ckeditor basepath
|
||||
*/
|
||||
function get_base_path()
|
||||
{
|
||||
//Get the ckeditor base url
|
||||
return $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/js/ckeditor3/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ckeditor enter mode which defaults to "BR"
|
||||
*/
|
||||
function get_enter_mode()
|
||||
{
|
||||
//Get the input name
|
||||
$enterMode = "CKEDITOR.ENTER_BR";
|
||||
if (isset($GLOBALS['egw_info']['user']['preferences']['common']['rte_enter_mode']))
|
||||
{
|
||||
switch ($GLOBALS['egw_info']['user']['preferences']['common']['rte_enter_mode'])
|
||||
{
|
||||
case 'p':
|
||||
$enterMode = "CKEDITOR.ENTER_P";
|
||||
break;
|
||||
case 'br':
|
||||
$enterMode = "CKEDITOR.ENTER_BR";
|
||||
break;
|
||||
case 'div':
|
||||
$enterMode = "CKEDITOR.ENTER_DIV";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $enterMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the skin the ckeditor should us
|
||||
*/
|
||||
function get_skin()
|
||||
{
|
||||
//Get the skin name
|
||||
$skin = $GLOBALS['egw_info']['user']['preferences']['common']['rte_skin'];
|
||||
|
||||
//Convert old fckeditor skin names to new ones
|
||||
switch ($skin)
|
||||
{
|
||||
case 'silver':
|
||||
$skin = "v2";
|
||||
break;
|
||||
case 'default':
|
||||
$skin = "kama";
|
||||
break;
|
||||
case 'office2003':
|
||||
$skin = "office2003";
|
||||
break;
|
||||
}
|
||||
|
||||
//Check whether the skin actually exists, if not, switch to a default
|
||||
if (!(file_exists($basePath.'skins/'.$skin) || file_exists($skin) || !empty($skin)))
|
||||
$skin = "office2003";
|
||||
|
||||
return $skin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string containing the ckeditor spellchecker settings.
|
||||
*/
|
||||
function get_spellcheck_settings(&$spell)
|
||||
{
|
||||
// Now setting the admin settings
|
||||
$res = '';
|
||||
$spell = false;
|
||||
$lang_country = get_lang_country();
|
||||
if (isset($GLOBALS['egw_info']['server']['enabled_spellcheck']))
|
||||
{
|
||||
$spell = ",'SpellChecker'";
|
||||
if (!empty($GLOBALS['egw_info']['server']['aspell_path']) &&
|
||||
is_executable($GLOBALS['egw_info']['server']['aspell_path']))
|
||||
{
|
||||
$spell = ",'SpellCheck'";
|
||||
$res .= ' config.extraPlugins = "aspell";'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$res .= " config.scaty_autoStartup = true;\n";
|
||||
$res .= " config.scaty_sLang = '".$lang_country['lang'].'_'.strtoupper($lang_country['country'])."';\n";
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string containing the ckeditor toolbar settings
|
||||
*/
|
||||
function get_toolbar($toolbar, $spell)
|
||||
{
|
||||
switch ($toolbar)
|
||||
{
|
||||
case 'simple':
|
||||
return
|
||||
" config.toolbar = [
|
||||
['Bold','Italic','Underline'],
|
||||
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
|
||||
['BulletedList','NumberedList','Outdent','Indent','Undo','Redo'],
|
||||
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print'],
|
||||
['Maximize'".($spell ? $spell : '')."],
|
||||
'/',
|
||||
['Format','Font','FontSize'],
|
||||
['TextColor','BGColor'],
|
||||
['ShowBlocks','-','About']
|
||||
];\n";
|
||||
|
||||
case 'extended':
|
||||
return
|
||||
" config.toolbar = [
|
||||
['Bold','Italic','Underline'],
|
||||
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
|
||||
['BulletedList','NumberedList','Outdent','Indent','Undo','Redo'],
|
||||
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print'],
|
||||
['Link','Unlink','Anchor'],
|
||||
['Find','Replace'],
|
||||
['Maximize'".($spell ? $spell : '').",'Image','Table'],
|
||||
'/',
|
||||
['Format','Font','FontSize'],
|
||||
['TextColor','BGColor'],
|
||||
['ShowBlocks','-','About']
|
||||
];\n";
|
||||
|
||||
case 'advanced':
|
||||
return
|
||||
" config.toolbar = [
|
||||
['Source','DocProps','-','Save','NewPage','Preview','-','Templates'],
|
||||
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print'".($spell ? $spell : '')."],
|
||||
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
|
||||
'/',
|
||||
['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
|
||||
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
|
||||
['BulletedList','NumberedList','-','Outdent','Indent'],
|
||||
['Link','Unlink','Anchor'],
|
||||
['Maximize','Image','SpecialChar','PageBreak'],
|
||||
'/',
|
||||
['Style','Format','Font','FontSize'],
|
||||
['TextColor','BGColor'],
|
||||
['ShowBlocks','-','About']
|
||||
];\n";
|
||||
}
|
||||
}
|
||||
|
||||
//Initialize the user parameters
|
||||
$height = '400px';
|
||||
$width = '100%';
|
||||
$start_path = '';
|
||||
$expanded_toolbar = true;
|
||||
$mode = 'simple';
|
||||
|
||||
//Read some parameters from the $_GET array
|
||||
if (isset($_GET['height']))
|
||||
$height = htmlspecialchars($_GET['height']);
|
||||
if (isset($_GET['width']))
|
||||
$width = htmlspecialchars($_GET['width']);
|
||||
if (isset($_GET['start_path']))
|
||||
$start_path = urlencode($_GET['start_path']);
|
||||
if (isset($_GET['expanded_toolbar']))
|
||||
$expanded_toolbar = $_GET['expanded_toolbar'] == '1';
|
||||
if (isset($_GET['mode']) && in_array($_GET['mode'], array('simple', 'advanced', 'extended')))
|
||||
$mode = $_GET['mode'];
|
||||
|
||||
$lang_country = get_lang_country();
|
||||
$spell = false;
|
||||
|
||||
//Output the configuration
|
||||
echo(
|
||||
'
|
||||
/**
|
||||
* CKEditor user based configuration
|
||||
*/
|
||||
|
||||
window.CKEDITOR_BASEPATH = "'.get_base_path().'";
|
||||
|
||||
CKEDITOR.editorConfig = function(config)
|
||||
{
|
||||
config.resize_enabled = false;
|
||||
|
||||
config.entities = true;
|
||||
config.entities_latin = true;
|
||||
config.entities_processNumerical = true;
|
||||
|
||||
config.editingBlock = true;
|
||||
|
||||
config.filebrowserBrowseUrl = "'.$GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=filemanager.filemanager_select.select&mode=open&method=ckeditor_return'
|
||||
.($start_path != '' ? '&path='.$start_path : '').'";
|
||||
config.filebrowserWindowWidth = "640";
|
||||
config.filebrowserWindowHeight = "580";
|
||||
|
||||
config.language = "'.$lang_country['lang'].'";
|
||||
|
||||
config.expanded_toolbar = '.($expanded_toolbar ? 'true' : 'false').';
|
||||
|
||||
config.height = "'.$height.'";
|
||||
|
||||
config.enterMode = '.get_enter_mode().';
|
||||
config.skin = "'.get_skin().'";
|
||||
'.get_spellcheck_settings($spell).
|
||||
' config.disableNativeSpellchecker = true;
|
||||
'.get_toolbar($mode, $spell).'}'
|
||||
);
|
||||
|
||||
|
272
phpgwapi/inc/class.egw_ckeditor_config.inc.php
Normal file
272
phpgwapi/inc/class.egw_ckeditor_config.inc.php
Normal file
@ -0,0 +1,272 @@
|
||||
<?php
|
||||
/**
|
||||
* eGroupWare - Class which generates JSON encoded configuration for the ckeditor
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @author RalfBecker-AT-outdoor-training.de
|
||||
* @author Andreas Stoeckel <as-AT-stylite.de>
|
||||
* @package api
|
||||
* @subpackage tools
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
class egw_ckeditor_config
|
||||
{
|
||||
private static $lang = null;
|
||||
private static $country = null;
|
||||
private static $enterMode = null;
|
||||
private static $skin = null;
|
||||
|
||||
/**
|
||||
* Read language and country settings for the ckeditor and store them in static
|
||||
* variables
|
||||
*/
|
||||
private static function read_lang_country()
|
||||
{
|
||||
//use the lang and country information to construct a possible lang info for CKEditor UI and scayt_slang
|
||||
self::$lang = ($GLOBALS['egw_info']['user']['preferences']['common']['spellchecker_lang'] ?
|
||||
$GLOBALS['egw_info']['user']['preferences']['common']['spellchecker_lang']:
|
||||
$GLOBALS['egw_info']['user']['preferences']['common']['lang']);
|
||||
|
||||
self::$country = $GLOBALS['egw_info']['user']['preferences']['common']['country'];
|
||||
|
||||
if (!(strpos(self::$lang, '-')===false))
|
||||
list(self::$lang, self::$country) = explode('-', self::$lang);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current user language
|
||||
*/
|
||||
private static function get_lang()
|
||||
{
|
||||
if (self::$lang == null || self::$country == null)
|
||||
self::read_lang_country();
|
||||
|
||||
return self::$lang;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current user country
|
||||
*/
|
||||
private static function get_country()
|
||||
{
|
||||
if (self::$lang == null || self::$country == null)
|
||||
self::read_lang_country();
|
||||
|
||||
return strtoupper(self::$country);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ckeditor basepath
|
||||
*/
|
||||
private static function get_base_path()
|
||||
{
|
||||
//Get the ckeditor base url
|
||||
return $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/js/ckeditor3/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ckeditor enter mode which defaults to "BR"
|
||||
*/
|
||||
private static function get_enter_mode()
|
||||
{
|
||||
if (self::$enterMode == null)
|
||||
{
|
||||
//Get the input name
|
||||
$enterMode = 2;
|
||||
if (isset($GLOBALS['egw_info']['user']['preferences']['common']['rte_enter_mode']))
|
||||
{
|
||||
switch ($GLOBALS['egw_info']['user']['preferences']['common']['rte_enter_mode'])
|
||||
{
|
||||
case 'p':
|
||||
$enterMode = 1;
|
||||
break;
|
||||
case 'br':
|
||||
$enterMode = 2;
|
||||
break;
|
||||
case 'div':
|
||||
$enterMode = 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
self::$enterMode = $enterMode;
|
||||
}
|
||||
|
||||
return self::$enterMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the skin the ckeditor should use
|
||||
*/
|
||||
private static function get_skin()
|
||||
{
|
||||
if (self::$skin == null)
|
||||
{
|
||||
//Get the skin name
|
||||
$skin = $GLOBALS['egw_info']['user']['preferences']['common']['rte_skin'];
|
||||
|
||||
//Convert old fckeditor skin names to new ones
|
||||
switch ($skin)
|
||||
{
|
||||
case 'silver':
|
||||
$skin = "v2";
|
||||
break;
|
||||
case 'default':
|
||||
$skin = "kama";
|
||||
break;
|
||||
case 'office2003':
|
||||
$skin = "office2003";
|
||||
break;
|
||||
}
|
||||
|
||||
//Check whether the skin actually exists, if not, switch to a default
|
||||
if (!(file_exists($basePath.'skins/'.$skin) || file_exists($skin) || !empty($skin)))
|
||||
$skin = "office2003";
|
||||
|
||||
self::$skin = $skin;
|
||||
}
|
||||
|
||||
return self::$skin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL of the filebrowser
|
||||
*/
|
||||
private static function get_filebrowserBrowseUrl($start_path = '')
|
||||
{
|
||||
return $GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=filemanager.filemanager_select.select&mode=open&method=ckeditor_return'
|
||||
.($start_path != '' ? '&path='.$start_path : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all "easy to write" options to the configuration
|
||||
*/
|
||||
private static function add_default_options(&$config, $height, $expanded_toolbar, $start_path)
|
||||
{
|
||||
//Convert the pixel height to an integer value
|
||||
$config['resize_enabled'] = false;
|
||||
$config['height'] = (int)$height;
|
||||
|
||||
$config['entities'] = true;
|
||||
$config['entities_latin'] = true;
|
||||
$config['editingBlock'] = true;
|
||||
$config['disableNativeSpellChecker'] = true;
|
||||
|
||||
$config['expanded_toolbar'] = $expanded_toolbar;
|
||||
|
||||
$config['filebrowserBrowseUrl'] = self::get_filebrowserBrowseUrl($start_path);
|
||||
$config['filebrowserWindowHeight'] = 640;
|
||||
$config['filebrowserWindowWidth'] = 580;
|
||||
|
||||
$config['language'] = self::get_lang();
|
||||
$config['enterMode'] = self::get_enter_mode();
|
||||
$config['skin'] = self::get_skin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the spellchecker configuration to the options and writes the name of
|
||||
* the spellchecker toolbar button to the "spellchecker_button" parameter
|
||||
*/
|
||||
private static function add_spellchecker_options(&$config, &$spellchecker_button)
|
||||
{
|
||||
if (isset($GLOBALS['egw_info']['server']['enabled_spellcheck']))
|
||||
{
|
||||
$spellchecker_button = 'SpellChecker';
|
||||
if (!empty($GLOBALS['egw_info']['server']['aspell_path']) &&
|
||||
is_executable($GLOBALS['egw_info']['server']['aspell_path']))
|
||||
{
|
||||
$spellchecker_button = 'SpellCheck';
|
||||
$config['extraPlugins'] = "aspell";
|
||||
}
|
||||
else
|
||||
{
|
||||
$config['scaty_autoStartup'] = true;
|
||||
$config['scaty_sLang'] = self::get_lang().'_'.self::get_country();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the toolbar configuration to the options which depends on the chosen
|
||||
* mode and the spellchecker_button written by the add_spellchecker_options button
|
||||
*/
|
||||
private static function add_toolbar_options(&$config, $mode, $spellchecker_button)
|
||||
{
|
||||
$config['toolbar'] = array();
|
||||
switch ($mode)
|
||||
{
|
||||
case 'advanced':
|
||||
$config['toolbar'][] = array('Source','DocProps','-','Save','NewPage','Preview','-','Templates');
|
||||
$config['toolbar'][] = array('Cut','Copy','Paste','PasteText','PasteFromWord','-','Print');
|
||||
if ($spellchecker_button)
|
||||
$config['toolbar'][count($config['toolbar'])][] = $spellchecker_button;
|
||||
$config['toolbar'][] = array('Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat');
|
||||
|
||||
$config['toolbar'][] = '/';
|
||||
|
||||
$config['toolbar'][] = array('Bold','Italic','Underline','Strike','-','Subscript','Superscript');
|
||||
$config['toolbar'][] = array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock');
|
||||
$config['toolbar'][] = array('BulletedList','NumberedList','-','Outdent','Indent');
|
||||
$config['toolbar'][] = array('Link','Unlink','Anchor');
|
||||
$config['toolbar'][] = array('Maximize','Image','SpecialChar','PageBreak');
|
||||
|
||||
$config['toolbar'][] = '/';
|
||||
|
||||
$config['toolbar'][] = array('Style','Format','Font','FontSize');
|
||||
$config['toolbar'][] = array('TextColor','BGColor');
|
||||
$config['toolbar'][] = array('ShowBlocks','-','About');
|
||||
break;
|
||||
|
||||
case 'extended': default:
|
||||
$config['toolbar'][] = array('Bold','Italic','Underline');
|
||||
$config['toolbar'][] = array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock');
|
||||
$config['toolbar'][] = array('BulletedList','NumberedList','Outdent','Indent','Undo','Redo');
|
||||
$config['toolbar'][] = array('Cut','Copy','Paste','PasteText','PasteFromWord','-','Print');
|
||||
|
||||
if ($mode == 'extended')
|
||||
{
|
||||
$config['toolbar'][] = array('Link','Unlink','Anchor');
|
||||
$config['toolbar'][] = array('Find', 'Replace');
|
||||
if ($spellchecker_button)
|
||||
$this['toolbar'][] = array('Maximize', $spellchecker_button, 'Image', 'Table');
|
||||
else
|
||||
$this['toolbar'][] = array('Maximize', 'Image', 'Table');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($spellchecker_button)
|
||||
$config['toolbar'][] = array('Maximize', $spellchecker_button);
|
||||
else
|
||||
$config['toolbar'][] = array('Maximize');
|
||||
}
|
||||
|
||||
$config['toolbar'][] = '/';
|
||||
|
||||
$config['toolbar'][] = array('Format','Font','FontSize');
|
||||
$config['toolbar'][] = array('TextColor','BGColor');
|
||||
$config['toolbar'][] = array('ShowBlocks','-','About');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a json encoded string containing the configuration for the ckeditor.
|
||||
* @param string $mode specifies the count of toolbar buttons available to the user. Possible
|
||||
* values are 'simple', 'extended' and 'advanced'. All other values will default to 'simple'
|
||||
* @param integer $height contains the height of the ckeditor in pixels
|
||||
* @param boolean $expanded_toolbar specifies whether the ckeditor should start with an expanded toolbar or not
|
||||
* @param string $start_path specifies
|
||||
*/
|
||||
public static function get_ckeditor_config($mode = 'simple', $height = 400, $expanded_toolbar = true, $start_path = '')
|
||||
{
|
||||
$config = array();
|
||||
$spellchecker_button = null;
|
||||
|
||||
self::add_default_options($config, $height, $expanded_toolbar, $start_path);
|
||||
self::add_spellchecker_options($config, $spellchecker_button);
|
||||
self::add_toolbar_options($config, $mode, $spellchecker_button);
|
||||
|
||||
return json_encode($config);
|
||||
}
|
||||
}
|
@ -582,131 +582,37 @@ class html
|
||||
{
|
||||
return self::textarea($_name,$_content,'style="width: '.$_width.'; height: '.$_height.';"');
|
||||
}
|
||||
|
||||
//include the ckeditor js file
|
||||
egw_framework::validate_file('ckeditor3','ckeditor','phpgwapi');
|
||||
|
||||
// run content through htmlpurifier
|
||||
if ($_purify && !empty($_content)) $_content = self::purify($_content);
|
||||
$oCKeditor = self::initCKEditor($_height, $_mode, $_options);
|
||||
if ($_purify && !empty($_content))
|
||||
$_content = self::purify($_content);
|
||||
|
||||
/* Resize the editor to the actual size delivered by the $_height parameter once it is initialized */
|
||||
$pxheight = (strpos('px', $_height) === false) ? (empty($_height)?400:$_height) : str_replace('px', '', $_height);
|
||||
$events['instanceReady'] = 'function (ev) {
|
||||
// By default the editor start expanded
|
||||
$expanded = isset($_options['toolbarStartupExpanded']) ?
|
||||
$_options['toolbarStartupExpanded'] != 'false' : true;
|
||||
|
||||
//Get the height in pixels from the pixels parameter
|
||||
$pxheight = (strpos('px', $_height) === false) ?
|
||||
(empty($_height) ? 400 : $_height) : str_replace('px', '', $_height);
|
||||
|
||||
return '
|
||||
<textarea name="'.$_name.'">'.htmlspecialchars($_content).'</textarea>
|
||||
<script type="text/javascript">
|
||||
window.CKEDITOR_BASEPATH="'.$GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/js/ckeditor3/";
|
||||
CKEDITOR.replace("'.$_name.'", '.egw_ckeditor_config::get_ckeditor_config($_mode,
|
||||
$pxheight, $expanded, $_start_path).');
|
||||
CKEDITOR.instances["'.$_name.'"].on(
|
||||
"instanceReady",
|
||||
function (ev)
|
||||
{
|
||||
ev.editor.resize("100%", '.str_replace('px', '', $pxheight).');
|
||||
}';
|
||||
|
||||
return $oCKeditor->editor($_name, $_content, null, $events);
|
||||
}
|
||||
|
||||
static function &initCKEditor($_height, $_mode, $_options=array())
|
||||
{
|
||||
include_once(EGW_INCLUDE_ROOT."/phpgwapi/js/ckeditor3/ckeditor_php5.php");
|
||||
// use the lang and country information to construct a possible lang info for CKEditor UI and scayt_slang
|
||||
/* $lang = ($GLOBALS['egw_info']['user']['preferences']['common']['spellchecker_lang'] ? $GLOBALS['egw_info']['user']['preferences']['common']['spellchecker_lang']: $GLOBALS['egw_info']['user']['preferences']['common']['lang']);
|
||||
$country = $GLOBALS['egw_info']['user']['preferences']['common']['country'];
|
||||
if (!(strpos($lang,'-')===false)) list($lang,$country) = explode('-',$lang);*/
|
||||
|
||||
//Get the ckeditor base url
|
||||
$basePath = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/js/ckeditor3/';
|
||||
|
||||
$oCKeditor = new CKeditor($basePath);
|
||||
$oCKeditor->returnOutput = true;
|
||||
|
||||
// By default the editor start expanded
|
||||
$et = '1';
|
||||
if ($_options['toolbar_expanded'] == 'false')
|
||||
$et = '0';
|
||||
|
||||
$oCKeditor->config['customConfig'] = $GLOBALS['egw_info']['server']['webserver_url']."/phpgwapi/inc/ckeditor-setup.php?height=$_height&mode=$_mode&expanded_toolbar=$et";
|
||||
|
||||
/* $oCKeditor->config['customConfig'] = 'ckeditor.egwconfig.js';
|
||||
$oCKeditor->config['language'] = $lang;
|
||||
$oCKeditor->config['resize_enabled'] = false;
|
||||
//switching the encoding as html entities off, as we correctly handle charsets and it messes up the wiki totally
|
||||
$oCKeditor->config['entities'] = true;
|
||||
$oCKeditor->config['entities_latin'] = true;
|
||||
$oCKeditor->config['entities_processNumerical'] = true;
|
||||
|
||||
$oCKeditor->config['editingBlock'] = true;
|
||||
$oCKeditor->config['filebrowserBrowseUrl'] = $GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=filemanager.filemanager_select.select&mode=open&method=ckeditor_return'.urlencode($_start_path);
|
||||
$oCKeditor->config['filebrowserWindowWidth'] = 640;
|
||||
$oCKeditor->config['filebrowserWindowHeight'] = 580;
|
||||
//Only heights with "px" set are supported
|
||||
$pxheight = (strpos('px', $_height) === false) ? (empty($_height)?400:$_height) : str_replace('px', '', $_height);
|
||||
$oCKeditor->config['height'] = $pxheight;
|
||||
|
||||
// By default the editor start expanded
|
||||
if ($_options['toolbar_expanded'] == 'false')
|
||||
$oCKeditor->config['toolbarStartupExpanded'] = false;
|
||||
|
||||
// Now setting the admin settings
|
||||
$spell = '';
|
||||
if (isset($GLOBALS['egw_info']['server']['enabled_spellcheck']))
|
||||
{
|
||||
$spell = '_spellcheck';
|
||||
if (!empty($GLOBALS['egw_info']['server']['aspell_path']) &&
|
||||
is_executable($GLOBALS['egw_info']['server']['aspell_path']))
|
||||
{
|
||||
$spell = '_aspell';
|
||||
$oCKeditor->config['extraPlugins'] = 'aspell';
|
||||
}
|
||||
$oCKeditor->config['scayt_autoStartup']=true;
|
||||
$oCKeditor->config['scayt_sLang']=$lang.'_'.strtoupper($country);
|
||||
}
|
||||
$oCKeditor->config['disableNativeSpellChecker'] = true;
|
||||
|
||||
// Now setting the user preferences
|
||||
if (isset($GLOBALS['egw_info']['user']['preferences']['common']['rte_enter_mode']))
|
||||
{
|
||||
switch ($GLOBALS['egw_info']['user']['preferences']['common']['rte_enter_mode'])
|
||||
{
|
||||
case 'p':
|
||||
$oCKeditor->config['enterMode'] = 1;//'@@CKEDITOR.ENTER_P';
|
||||
break;
|
||||
case 'br':
|
||||
$oCKeditor->config['enterMode'] = 2;//'@@CKEDITOR.ENTER_BR';
|
||||
break;
|
||||
case 'div':
|
||||
$oCKeditor->config['enterMode'] = 3;//'@@CKEDITOR.ENTER_DIV';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$skin = $GLOBALS['egw_info']['user']['preferences']['common']['rte_skin'];
|
||||
|
||||
//Convert old fckeditor skin names to new ones
|
||||
switch ($skin)
|
||||
{
|
||||
case 'silver':
|
||||
$skin = "v2";
|
||||
break;
|
||||
case 'default':
|
||||
$skin = "kama";
|
||||
break;
|
||||
case 'office2003':
|
||||
$skin = "office2003";
|
||||
break;
|
||||
}
|
||||
|
||||
//Check whether the skin actually exists, if not, switch to a default
|
||||
if (!(file_exists($basePath.'skins/'.$skin) || file_exists($skin) || !empty($skin)))
|
||||
$skin = "office2003";
|
||||
|
||||
$oCKeditor->config['skin'] = $skin;
|
||||
|
||||
|
||||
switch($_mode) {
|
||||
case 'simple':
|
||||
$oCKeditor->config['toolbar'] = 'egw_simple'.$spell;
|
||||
$oCKeditor->config['menu_groups'] = '';
|
||||
break;
|
||||
default:
|
||||
case 'extended':
|
||||
$oCKeditor->config['toolbar'] = 'egw_extended'.$spell;
|
||||
break;
|
||||
|
||||
case 'advanced':
|
||||
$oCKeditor->config['toolbar'] = 'egw_advanced'.$spell;
|
||||
break;
|
||||
}*/
|
||||
return $oCKeditor;
|
||||
);
|
||||
</script>
|
||||
';
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user