1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 12:48:24 +01:00

Fixes #4747 - wysiwyg editor value retention.

This commit is contained in:
Cameron 2022-04-05 09:56:25 -07:00
parent 248a98fffc
commit 45372f285c
3 changed files with 27 additions and 20 deletions

View File

@ -4505,6 +4505,8 @@ class e107
static $availEditors;
$fallbackEditor = 'bbcode';
global $_E107;
if (self::getPref('wysiwyg',false) != true)
{
// wysiwyg disabled by global pref
@ -4512,12 +4514,11 @@ class e107
}
else
{
if(!isset($availEditors))
if(!isset($availEditors) || !empty($_E107['phpunit']))
{
// init list of installed wysiwyg editors
$default = self::isInstalled('tinymce4') ? array('tinymce4'=>'TinyMce4') : array(); // if missing pref fallback.
$availEditors = self::getPref('wysiwyg_list', $default);
// $availEditors = array_keys(e107::getPlug()->getInstalledWysiwygEditors()); // very slow.
}
@ -4531,7 +4532,7 @@ class e107
// check if choosen editor is installed,
// if not, but a different editor is available use that one (e.g. tinymce4 choosen, but only simplemde available available, use simplemde)
// if no wysiwyg editor available, use fallback editor (bbcode)
if(is_bool($editor) || ($editor !== $fallbackEditor && !in_array($editor, $availEditors)))
if(is_bool($editor) || ($editor !== $fallbackEditor && empty($availEditors[$editor])))
{
$names = array_keys($availEditors);
// $editor = count($availEditors) > 0 ? $availEditors[0] : $fallbackEditor;
@ -4539,6 +4540,7 @@ class e107
}
}
// $returnEditor => false:
// false => fallback editor (bbcode)
// true => default wysiwyg editor

View File

@ -239,18 +239,9 @@ class e_jsmanager
}
else // Front-End.
{
if(defset('e_DEBUG_JQUERY') === 2)
{
e107::library('load', 'jquery');
// jQuery Once is used in e107.behaviors.
e107::library('load', 'jquery.once');
}
else
{
e107::library('load', 'jquery3');
}
$jqueryLib = (defset('e_DEBUG_JQUERY') === 2) ? 'jquery' : 'jquery3';
e107::library('load',$jqueryLib);
e107::library('load', 'jquery.once'); // jQuery Once is used in e107.behaviors.
}
// TODO

View File

@ -1808,15 +1808,28 @@ class e107Test extends \Codeception\Test\Unit
public function testWysiwyg()
{
// Simulate editors being installed.
$editors = array (
'tinymce4' => 'TinyMce4',
'simplemde' => 'SimpleMDE',
);
e107::getConfig()->setPref('wysiwyg', true)->save();
$tinyMceInstalled = e107::isInstalled('tinymce4');
e107::getConfig()
->setPref('wysiwyg', true)
->setPref('wysiwyg_list', $editors)
->save();
global $_E107;
$_E107['phpunit'] = true; // make sure pref is re-loaded.
// $tinyMceInstalled = e107::isInstalled('tinymce4');
$tests = array(
//input => expected
'default' => ($tinyMceInstalled) ? 'tinymce4' : 'bbcode',
'default' => 'tinymce4',
'bbcode' => 'bbcode',
'tinymce4' => ($tinyMceInstalled) ? 'tinymce4' : 'bbcode',
'tinymce4' => 'tinymce4',
'simplemde' => 'simplemde',
'nonexist' => 'tinymce4',
);
foreach($tests as $input => $expected)
@ -1835,6 +1848,7 @@ class e107Test extends \Codeception\Test\Unit
$this->assertSame($expected, $result);
e107::getConfig()->setPref('wysiwyg', false)->save(); // wysiwyg is disabled.
}
/*