1
0
mirror of https://github.com/EGroupware/egroupware.git synced 2024-12-26 16:49:10 +01:00
egroupware_official/phpgwapi/js/ckeditor/egw_integration.txt

111 lines
4.5 KiB
Plaintext
Raw Normal View History

---------------- image Upload dependencies plugins -----------
-filetools - lineutils - uploadimage - widget - pasteforward
- notification - notificationaggregator -fakeobjects
2013-03-14 17:16:49 +01:00
--------------- step 1 --------------------------------------
removed _samples directory
--------------- step 2 --------------------------------------
-added aspell as plugin, as it is not available by default anymore.
phpgwapi/js/ckeditor/plugins/aspell
-as aspell integration was done for CKEditor3; integration into CKEditor 4 needs
- most lang stuff had to be loaded from other sources
- own icon, modified plugin.js, removed aspell.css, modified dialogs/aspell.js
-changed phpgwapi/js/ckeditor3/plugins/aspell/spellerpages/server-scripts/spellchecker.php
to allow only configured aspell, tmp dirs and language settings
-removed other than php spellchecker pages from phpgwapi/js/ckeditor3/plugins/aspell/spellerpages/server-scripts/
-added toolbar options to reflect the use/change of calls of SpellCheck(er) via toolbar button
-added an availability check on dicts (see below)
Index: phpgwapi/js/ckeditor3/plugins/aspell/spellerpages/server-scripts/spellchecker.php
===================================================================
--- phpgwapi/js/ckeditor3/plugins/aspell/spellerpages/server-scripts/spellchecker.php (Revision 37235)
+++ phpgwapi/js/ckeditor3/plugins/aspell/spellerpages/server-scripts/spellchecker.php (Arbeitskopie)
@@ -24,17 +24,16 @@
// will not continue, unless the header get's included and there is a valid eGW session
require('../../../../../../../header.inc.php');
-if (!empty($GLOBALS['egw_info']['user']['preferences']['common']['spellchecker_lang']))
-{
- $lang = $GLOBALS['egw_info']['user']['preferences']['common']['spellchecker_lang'];
-}
-else
-{
- $lang = $GLOBALS['egw_info']['user']['preferences']['common']['lang'];
-}
+$lang = ($GLOBALS['egw_info']['user']['preferences']['common']['spellchecker_lang'] ?
+ $GLOBALS['egw_info']['user']['preferences']['common']['spellchecker_lang']:
+ $GLOBALS['egw_info']['user']['preferences']['common']['lang']);
-$aspell_opts = '-a '.escapeshellarg('--lang='.$lang).' --encoding=utf-8 -H --rem-sgml-check=alt'; // by FredCK
+$country = $GLOBALS['egw_info']['user']['preferences']['common']['country'];
+$lang_ext = $lang.'_'.$country;
+$langs = getDictLangs();
+
+$aspell_opts = '-a '.escapeshellarg('--lang='.(in_array($lang_ext,$langs)?$lang_ext:$lang)).' --encoding=utf-8 -H --rem-sgml-check=alt'; // by FredCK
$tempfiledir = "./";
$spellercss = '../spellerStyle.css'; // by FredCK
@@ -43,6 +42,42 @@
$textinputs = $_POST['textinputs']; # array
$input_separator = "A";
+function getDictLangs()
+{
+ static $langs;
+ if (is_null($langs)) $langs = egw_cache::getCache(egw_cache::TREE,'spellckecher','aspellDictLangs',$callback=null,$callback_params=array(),$expiration=60*60*1);
+ if (isset($langs) && !empty($langs)) return $langs;
+ $langs = array();
+ $aspell_prog = getAspellPath();
+ $cmd = "$aspell_prog dump dicts";
+ if( $aspellret = shell_exec( $cmd )) {
+ $linesout = explode( "\n", $aspellret );
+ $index = 0;
+ $text_input_index = -1;
+ # parse each line of aspell return
+ foreach( $linesout as $key=>$val ) {
+ //error_log('spellerpages'.__LINE__.' : '.trim($val));
+ $langs[] = trim($val);
+ }
+ }
+ egw_cache::setCache(egw_cache::TREE,'spellchecker','aspellDictLangs',$langs,$expiration=60*60*1);
+ return $langs;
+}
+
+function getAspellPath()
+{
+ if (!empty($GLOBALS['egw_info']['server']['aspell_path']) &&
+ is_executable($GLOBALS['egw_info']['server']['aspell_path']))
+ {
+ $aspell_prog = $GLOBALS['egw_info']['server']['aspell_path'];
+ }
+ else // little fallback that might save linux users
+ {
+ $aspell_prog = 'aspell';
+ }
+ return $aspell_prog;
+}
+
# set the JavaScript variable to the submitted text.
# textinputs is an array, each element corresponding to the (url-encoded)
# value of the text control submitted for spell-checking
@@ -101,15 +136,7 @@
global $textinputs;
global $input_separator;
$aspell_err = "";
- if (!empty($GLOBALS['egw_info']['server']['aspell_path']) &&
- is_executable($GLOBALS['egw_info']['server']['aspell_path']))
- {
- $aspell_prog = $GLOBALS['egw_info']['server']['aspell_path'];
- }
- else // little fallback that might save linux users
- {
- $aspell_prog = 'aspell';
- }
+ $aspell_prog = getAspellPath();
# create temp file
// use EGroupware's temp_dir