public function testEnablePluginsByArrayWithPaths()
 {
     Config::inst()->update('SilverStripe\\Control\\Director', 'alternate_base_url', 'http://mysite.com/subdir');
     $c = new TinyMCEConfig();
     $c->setTheme('modern');
     $c->setOption('language', 'es');
     $c->disablePlugins('table', 'emoticons', 'paste', 'code', 'link', 'importcss');
     $c->enablePlugins(array('plugin1' => 'mypath/plugin1.js', 'plugin2' => '/anotherbase/mypath/plugin2.js', 'plugin3' => 'https://www.google.com/plugin.js', 'plugin4' => null, 'plugin5' => null));
     $attributes = $c->getAttributes();
     $config = Convert::json2array($attributes['data-config']);
     $plugins = $config['external_plugins'];
     $this->assertNotEmpty($plugins);
     // Plugin specified via relative url
     $this->assertContains('plugin1', array_keys($plugins));
     $this->assertEquals('http://mysite.com/subdir/mypath/plugin1.js', $plugins['plugin1']);
     // Plugin specified via root-relative url
     $this->assertContains('plugin2', array_keys($plugins));
     $this->assertEquals('http://mysite.com/anotherbase/mypath/plugin2.js', $plugins['plugin2']);
     // Plugin specified with absolute url
     $this->assertContains('plugin3', array_keys($plugins));
     $this->assertEquals('https://www.google.com/plugin.js', $plugins['plugin3']);
     // Plugin specified with standard location
     $this->assertContains('plugin4', array_keys($plugins));
     $this->assertEquals('http://mysite.com/subdir/' . ADMIN_THIRDPARTY_DIR . '/tinymce/plugins/plugin4/plugin.min.js', $plugins['plugin4']);
     // Check that internal plugins are extractable separately
     $this->assertEquals(['plugin4', 'plugin5'], $c->getInternalPlugins());
     // Test plugins included via gzip compresser
     HTMLEditorField::config()->update('use_gzip', true);
     $this->assertEquals(ADMIN_THIRDPARTY_DIR . '/tinymce/tiny_mce_gzip.php?js=1&plugins=plugin4,plugin5&themes=modern&languages=es&diskcache=true&src=true', $c->getScriptURL());
     // If gzip is disabled only the core plugin is loaded
     HTMLEditorField::config()->remove('use_gzip');
     $this->assertEquals(ADMIN_THIRDPARTY_DIR . '/tinymce/tinymce.min.js', $c->getScriptURL());
 }
 /**
  * Generate gzipped TinyMCE configuration including plugins and languages.
  * This ends up "pre-loading" TinyMCE bundled with the required plugins
  * so that multiple HTTP requests on the client don't need to be made.
  *
  * @return string
  */
 public function getScriptURL()
 {
     // If gzip is disabled just return core script url
     $useGzip = HTMLEditorField::config()->get('use_gzip');
     if (!$useGzip) {
         return ADMIN_THIRDPARTY_DIR . '/tinymce/tinymce.min.js';
     }
     // tinyMCE JS requirement
     require_once ADMIN_THIRDPARTY_PATH . '/tinymce/tiny_mce_gzip.php';
     $tag = TinyMCE_Compressor::renderTag(array('url' => ADMIN_THIRDPARTY_DIR . '/tinymce/tiny_mce_gzip.php', 'plugins' => implode(',', $this->getInternalPlugins()), 'themes' => $this->getTheme(), 'languages' => $this->getOption('language')), true);
     preg_match('/src="([^"]*)"/', $tag, $matches);
     return html_entity_decode($matches[1]);
 }
    public function testReadonlyField()
    {
        $editor = new HTMLEditorField('Content');
        $fileID = $this->idFromFixture('SilverStripe\\Assets\\Image', 'example_image');
        $editor->setValue(sprintf('[image src="assets/HTMLEditorFieldTest_example.jpg" width="10" height="20" id="%d"]', $fileID));
        /** @var HTMLReadonlyField $readonly */
        $readonly = $editor->performReadonlyTransformation();
        /** @var DBHTMLText $readonlyContent */
        $readonlyContent = $readonly->Field();
        $this->assertEquals(<<<EOS
<span class="readonly typography" id="Content">
\t<img src="/assets/HTMLEditorFieldTest/f5c7c2f814/HTMLEditorFieldTest-example__ResizedImageWyIxMCIsIjIwIl0.jpg" alt="HTMLEditorFieldTest example" width="10" height="20">
</span>


EOS
, $readonlyContent->getValue());
        // Test with include input tag
        $readonly = $editor->performReadonlyTransformation()->setIncludeHiddenField(true);
        /** @var DBHTMLText $readonlyContent */
        $readonlyContent = $readonly->Field();
        $this->assertEquals(<<<EOS
<span class="readonly typography" id="Content">
\t<img src="/assets/HTMLEditorFieldTest/f5c7c2f814/HTMLEditorFieldTest-example__ResizedImageWyIxMCIsIjIwIl0.jpg" alt="HTMLEditorFieldTest example" width="10" height="20">
</span>

\t<input type="hidden" name="Content" value="[image src=&quot;/assets/HTMLEditorFieldTest/f5c7c2f814/HTMLEditorFieldTest-example.jpg&quot; width=&quot;10&quot; height=&quot;20&quot; id=&quot;{$fileID}&quot;]" />


EOS
, $readonlyContent->getValue());
    }