1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 12:20:44 +02:00

Increase speed of TinyMce footer.

This commit is contained in:
Cameron
2020-12-12 12:40:26 -08:00
parent eaa44b075f
commit c1f5a6f8dc
4 changed files with 29 additions and 9 deletions

View File

@@ -3858,7 +3858,8 @@ class e107
if(!isset($availEditors)) if(!isset($availEditors))
{ {
// init list of installed wysiwyg editors // init list of installed wysiwyg editors
$availEditors = array_keys(e107::getPlug()->getInstalledWysiwygEditors()); $availEditors = self::getPref('wysiwyg_list', array());
// $availEditors = array_keys(e107::getPlug()->getInstalledWysiwygEditors()); // very slow.
} }
if(!is_null($val)) if(!is_null($val))
@@ -3873,7 +3874,8 @@ class e107
// if no wysiwyg editor available, use fallback editor (bbcode) // 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 && !in_array($editor, $availEditors)))
{ {
$editor = count($availEditors) > 0 ? $availEditors[0] : $fallbackEditor; $names = array_keys($availEditors);
$editor = count($availEditors) > 0 ? reset($names) : $fallbackEditor;
} }
} }
// $returnEditor => false: // $returnEditor => false:

View File

@@ -1111,7 +1111,8 @@ class e_plugin
$core->set('bbcode_list', array()) $core->set('bbcode_list', array())
->set('shortcode_legacy_list', array()) ->set('shortcode_legacy_list', array())
->set('shortcode_list', array()) ->set('shortcode_list', array())
->set('lan_global_list', array()); ->set('lan_global_list', array())
->set('wysiwyg_list', array());
$paths = $this->getDetected(); $paths = $this->getDetected();
@@ -1240,6 +1241,8 @@ class e_plugin
} }
} }
$editors = $this->getInstalledWysiwygEditors();
$core->setPref('wysiwyg_list',$editors);
$core->save(false, true, false); $core->save(false, true, false);

View File

@@ -878,13 +878,16 @@ class e107Test extends \Codeception\Test\Unit
$this->assertEquals($expected,$result); $this->assertEquals($expected,$result);
} }
/*
public function testWysiwyg() public function testWysiwyg()
{ {
$res = null; $result = e107::wysiwyg(null, true);
$this->assertTrue($res); $expected = 'bbcode';
}
$this->assertSame($expected, $result);
}
/*
public function testLoadLanFiles() public function testLoadLanFiles()
{ {
$res = null; $res = null;

View File

@@ -30,7 +30,15 @@
} }
} }
public function testGetInstalledWysiwygEditors()
{
$expected = array('tinymce4'=>'TinyMce4');
$result = $this->ep->getInstalledWysiwygEditors();
$this->assertSame($expected,$result);
}
/** /**
* Creates a dummy plugin entry to make sure such plugins are ignored * Creates a dummy plugin entry to make sure such plugins are ignored
*/ */
@@ -99,21 +107,25 @@
$newUrls = array('gallery'=>0, 'news'=>'news', 'rss_menu'=>0); $newUrls = array('gallery'=>0, 'news'=>'news', 'rss_menu'=>0);
e107::getConfig()->setData('e_url_list', $newUrls)->save(false,false,false); e107::getConfig()->setData('e_url_list', $newUrls)->save(false,false,false);
e107::getConfig()->setData('wysiwyg_list', array())->save(false,false,false);
$urlsBefore = e107::pref('core', 'e_url_list'); $urlsBefore = e107::pref('core', 'e_url_list');
$userBefore = e107::pref('core', 'e_user_list'); $userBefore = e107::pref('core', 'e_user_list');
$wysiwygBefore = e107::pref('core', 'wysiwyg_list',array());
// print_r($userBefore); // print_r($wysiwygBefore);
$this->ep->clearCache()->buildAddonPrefLists(); $this->ep->clearCache()->buildAddonPrefLists();
$urlsAfter = e107::pref('core', 'e_url_list'); $urlsAfter = e107::pref('core', 'e_url_list');
$userAfter = e107::pref('core', 'e_user_list'); $userAfter = e107::pref('core', 'e_user_list');
$wysiwygAfter = e107::pref('core', 'wysiwyg_list');
// print_r($userAfter); // print_r($wysiwygAfter);
$this->assertEquals($urlsBefore['gallery'],$urlsAfter['gallery']); $this->assertEquals($urlsBefore['gallery'],$urlsAfter['gallery']);
$this->assertEquals($userBefore['user'],$userAfter['user']); $this->assertEquals($userBefore['user'],$userAfter['user']);
$this->assertNotSame($wysiwygBefore,$wysiwygAfter);
} }