forked from extern/egroupware
* ckeditor/aspell: added check for language availability check on extended dict (Lang_Countrycode) first, then fall back to lang -> e.g.: check on en_GB, if not available try using en
This commit is contained in:
parent
f6fe40f2d9
commit
9fad5b84ab
@ -1,6 +1,5 @@
|
||||
--------------- step 1 --------------------------------------
|
||||
removed _samples directory
|
||||
removed _source folder
|
||||
|
||||
--------------- step 2 --------------------------------------
|
||||
-added aspell as plugin, as it is not available by default anymore.
|
||||
@ -9,4 +8,95 @@ removed _source folder
|
||||
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
|
||||
|
@ -24,17 +24,16 @@ $GLOBALS['egw_info'] = array(
|
||||
// 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 @@ $word_win_src = '../wordWindow.js'; // by FredCK
|
||||
$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 @@ function print_checker_results() {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user