From a6701aeb693286a32eb73c6418d409355879f56f Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 23 Aug 2015 15:39:55 +0200 Subject: [PATCH 1/4] New: CkEditor add possibility to choose skin --- htdocs/admin/fckeditor.php | 42 ++++++- htdocs/core/class/doleditor.class.php | 2 +- htdocs/core/lib/doleditor.lib.php | 133 +++++++++++++++++++++ htdocs/core/modules/modFckeditor.class.php | 1 + 4 files changed, 171 insertions(+), 7 deletions(-) create mode 100644 htdocs/core/lib/doleditor.lib.php diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index 7fbe4415b2b..6b608d238f3 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -25,6 +25,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/doleditor.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $langs->load("admin"); @@ -98,13 +99,36 @@ foreach($modules as $const => $desc) if (GETPOST('save','alpha')) { - $res=dolibarr_set_const($db, "FCKEDITOR_TEST", GETPOST('formtestfield'),'chaine',0,'',$conf->entity); + $error = 0; - if ($res > 0) setEventMessage($langs->trans("RecordModifiedSuccessfully")); + $fckeditor_skin = GETPOST('fckeditor_skin', 'alpha'); + if (! empty($fckeditor_skin)) { + if (! dolibarr_set_const($db, 'FCKEDITOR_SKIN', $fckeditor_skin, 'chaine', 0, '', $conf->entity)) { + $error ++; + } + } else { + $error ++; + } + + $fckeditor_test = GETPOST('formtestfield'); + if (! empty($fckeditor_test)) { + if (! dolibarr_set_const($db, 'FCKEDITOR_TEST', $fckeditor_test, 'chaine', 0, '', $conf->entity)) { + $error ++; + } + } else { + $error ++; + } + + if (! $error) + { + setEventMessage($langs->trans("SetupSaved")); + } + else + { + setEventMessage($langs->trans("Error"),'errors'); + } } - - /* * View */ @@ -157,9 +181,15 @@ else print ''."\n"; + print '
'."\n"; + + print '
'."\n"; + + // Skins + show_skin(null,1); print '
'."\n"; - print_fiche_titre($langs->trans("TestSubmitForm"),'(mode='.$mode.')',''); - print ''."\n"; + + print_fiche_titre($langs->trans("TestSubmitForm"),'(mode='.$mode.')',''); print ''; $uselocalbrowser=true; $readonly=($mode=='dolibarr_readonly'?1:0); diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index db303ee7d1b..27fd1b1ee80 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -169,7 +169,7 @@ class DolEditor if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR','1'); //$skin='kama'; - $skin='moono'; // default with cdeditor 4 + $skin = $conf->global->FCKEDITOR_SKIN; // default with ckeditor 4 : moono $htmlencode_force=preg_match('/_encoded$/',$this->toolbarname)?'true':'false'; diff --git a/htdocs/core/lib/doleditor.lib.php b/htdocs/core/lib/doleditor.lib.php new file mode 100644 index 00000000000..63883ffd0f4 --- /dev/null +++ b/htdocs/core/lib/doleditor.lib.php @@ -0,0 +1,133 @@ + + * Copyright (C) 2010-2012 Regis Houssin + * Copyright (C) 2015 Alexandre Spangaro + * + * 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 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + + +/** + * \file htdocs/core/lib/doleditor.lib.php + * \brief Ensemble de fonctions de base pour la gestion des utilisaterus et groupes + */ + +/** + * Show list of ckeditor's themes. + * + * @param User|null $fuser User concerned or null for global theme + * @param int $edit 1 to add edit form + * @return void + */ +function show_skin($fuser,$edit=0) +{ + global $conf,$langs,$db; + global $bc; + + require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; + + $formother = new FormOther($db); + + $dirskins=array('/includes/ckeditor/skins'); + if (! empty($conf->modules_parts['theme'])) // Using this feature slow down application + { + foreach($conf->modules_parts['theme'] as $reldir) + { + $dirskins=array_merge($dirskins,(array) ($reldir.'theme')); + } + } + $dirskins=array_unique($dirskins); + // Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme') + + $selected_theme=''; + $selected_theme=$conf->global->FCKEDITOR_SKIN; + + $colspan=2; + + $thumbsbyrow=6; + print ''; + + $var=false; + + // Title + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + + //$var=!$var; + print ''; + + print '
'.$langs->trans("DefaultSkin").''; + $url='http://ckeditor.com/addons/skins/all'; + print ''; + print $langs->trans('DownloadMoreSkins'); + print ''; + print '
'.$langs->trans("ThemeDir").''; + foreach($dirskins as $dirskin) + { + echo '"'.$dirskin.'" '; + } + print '
'; + + print '
'; + + $i=0; + foreach($dirskins as $dir) + { + //print $dirroot.$dir;exit; + $dirskin=dol_buildpath($dir,0); // This include loop on $conf->file->dol_document_root + $urltheme=dol_buildpath($dir,1); + + if (is_dir($dirskin)) + { + $handle=opendir($dirskin); + if (is_resource($handle)) + { + while (($subdir = readdir($handle))!==false) + { + if (is_dir($dirskin."/".$subdir) && substr($subdir, 0, 1) <> '.' + && substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i',$subdir)) + { + // Disable not stable themes (dir ends with _exp or _dev) + if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i',$subdir)) continue; + if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/_exp$/i',$subdir)) continue; + + print '
'; + if ($subdir == $selected_theme) + { + print ' '.$subdir.''; + } + else + { + print ' '.$subdir; + } + print '
'; + + $i++; + } + } + } + } + } + + print '
'; + + print '
'; +} + diff --git a/htdocs/core/modules/modFckeditor.class.php b/htdocs/core/modules/modFckeditor.class.php index 6a5932cca5a..4edb557e850 100644 --- a/htdocs/core/modules/modFckeditor.class.php +++ b/htdocs/core/modules/modFckeditor.class.php @@ -74,6 +74,7 @@ class modFckeditor extends DolibarrModules $this->const[3] = array("FCKEDITOR_ENABLE_DETAILS","yesno","1","WYSIWIG for products details lines for all entities"); $this->const[4] = array("FCKEDITOR_ENABLE_USERSIGN","yesno","1","WYSIWIG for user signature"); $this->const[5] = array("FCKEDITOR_ENABLE_MAIL","yesno","1","WYSIWIG for products details lines for all entities"); + $this->const[6] = array("FCKEDITOR_SKIN","string","moono","Skin by default for fckeditor"); // Boites $this->boxes = array(); From b1b7966c884ed05a5eb5837b8a161f1c17cfe378 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 10 Sep 2015 06:58:20 +0200 Subject: [PATCH 2/4] ckeditor: define the default skin when constant don't exist. --- htdocs/core/class/doleditor.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 27fd1b1ee80..25265745dd8 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -168,8 +168,11 @@ class DolEditor { if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR','1'); - //$skin='kama'; - $skin = $conf->global->FCKEDITOR_SKIN; // default with ckeditor 4 : moono + if (empty($conf->global->FCKEDITOR_SKIN)) { + $skin = monoo; // default with ckeditor 4 : moono + } else { + $skin = $conf->global->FCKEDITOR_SKIN; + } $htmlencode_force=preg_match('/_encoded$/',$this->toolbarname)?'true':'false'; From 00556062563233c36446210a453bcd1ab9affd2f Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 10 Sep 2015 07:36:17 +0200 Subject: [PATCH 3/4] Invert --- htdocs/core/class/doleditor.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 25265745dd8..84e0433d1d9 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -168,10 +168,10 @@ class DolEditor { if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR','1'); - if (empty($conf->global->FCKEDITOR_SKIN)) { - $skin = monoo; // default with ckeditor 4 : moono + if (! empty($conf->global->FCKEDITOR_SKIN)) { + $skin = $conf->global->FCKEDITOR_SKIN; } else { - $skin = $conf->global->FCKEDITOR_SKIN; + $skin = 'monoo'; // default with ckeditor 4 : moono } $htmlencode_force=preg_match('/_encoded$/',$this->toolbarname)?'true':'false'; From 5b57231c52f17790ca13ed4ed630f126ed068c29 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 15 Sep 2015 06:14:33 +0200 Subject: [PATCH 4/4] Fix : error skin name by default --- htdocs/core/class/doleditor.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 84e0433d1d9..05686e5abb7 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -171,7 +171,7 @@ class DolEditor if (! empty($conf->global->FCKEDITOR_SKIN)) { $skin = $conf->global->FCKEDITOR_SKIN; } else { - $skin = 'monoo'; // default with ckeditor 4 : moono + $skin = 'moono'; // default with ckeditor 4 : moono } $htmlencode_force=preg_match('/_encoded$/',$this->toolbarname)?'true':'false';