New: CkEditor add possibility to choose skin
This commit is contained in:
parent
15ab9c0ecd
commit
a6701aeb69
@ -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 '</table>'."\n";
|
||||
|
||||
print '<br>'."\n";
|
||||
|
||||
print '<form name="formtest" method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||
|
||||
// Skins
|
||||
show_skin(null,1);
|
||||
print '<br>'."\n";
|
||||
print_fiche_titre($langs->trans("TestSubmitForm"),'(mode='.$mode.')','');
|
||||
print '<form name="formtest" method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||
|
||||
print_fiche_titre($langs->trans("TestSubmitForm"),'(mode='.$mode.')','');
|
||||
print '<input type="hidden" name="mode" value="'.dol_escape_htmltag($mode).'">';
|
||||
$uselocalbrowser=true;
|
||||
$readonly=($mode=='dolibarr_readonly'?1:0);
|
||||
|
||||
@ -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';
|
||||
|
||||
|
||||
133
htdocs/core/lib/doleditor.lib.php
Normal file
133
htdocs/core/lib/doleditor.lib.php
Normal file
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* 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 '<table class="noborder" width="100%">';
|
||||
|
||||
$var=false;
|
||||
|
||||
// Title
|
||||
print '<tr class="liste_titre"><th width="35%">'.$langs->trans("DefaultSkin").'</th>';
|
||||
print '<th align="right">';
|
||||
$url='http://ckeditor.com/addons/skins/all';
|
||||
print '<a href="'.$url.'" target="_blank">';
|
||||
print $langs->trans('DownloadMoreSkins');
|
||||
print '</a>';
|
||||
print '</th></tr>';
|
||||
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.$langs->trans("ThemeDir").'</td>';
|
||||
print '<td>';
|
||||
foreach($dirskins as $dirskin)
|
||||
{
|
||||
echo '"'.$dirskin.'" ';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
//$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td colspan="'.$colspan.'">';
|
||||
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td><div align="center">';
|
||||
|
||||
$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 '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
|
||||
if ($subdir == $selected_theme)
|
||||
{
|
||||
print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" checked name="fckeditor_skin" value="'.$subdir.'"> <b>'.$subdir.'</b>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" name="fckeditor_skin" value="'.$subdir.'"> '.$subdir;
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</div></td></tr></table>';
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user