/** * Wisywyg widget plugin main page * * @return void */ public function execute() { // save extra params for widgets insertion form $skipped = $this->getRequest()->getParam('skip_widgets'); $skipped = $this->_widgetConfig->decodeWidgetsFromQuery($skipped); $this->_coreRegistry->register('skip_widgets', $skipped); $this->_view->loadLayout('empty')->renderLayout(); }
/** * @covers \Magento\Cms\Model\Wysiwyg\Config::getConfig * @param array $data * @param boolean $isAuthorizationAllowed * @param array $expectedResults * * @dataProvider getConfigDataProvider */ public function testGetConfig($data, $isAuthorizationAllowed, $expectedResults) { $wysiwygPluginSettings = ['wysiwygPluginSettings' => 'wysiwyg is here']; $pluginSettings = ['pluginSettings' => 'plugins are here']; $this->backendUrlMock->expects($this->atLeastOnce())->method('getUrl')->withConsecutive(['cms/wysiwyg/directive'], ['cms/wysiwyg_images/index']); $this->assetRepoMock->expects($this->atLeastOnce())->method('getUrl')->withConsecutive(['mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/dialog.css'], ['mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/content.css']); $this->authorizationMock->expects($this->atLeastOnce())->method('isAllowed')->with('Magento_Cms::media_gallery')->willReturn($isAuthorizationAllowed); $this->variableConfigMock->expects($this->any())->method('getWysiwygPluginSettings')->willReturn($wysiwygPluginSettings); $this->widgetConfigMock->expects($this->any())->method('getPluginSettings')->willReturn($pluginSettings); $config = $this->wysiwygConfig->getConfig($data); $this->assertInstanceOf('Magento\\Framework\\Object', $config); $this->assertEquals($expectedResults[0], $config->getData('someData')); $this->assertEquals($expectedResults[1], $config->getData('wysiwygPluginSettings')); $this->assertEquals($expectedResults[2], $config->getData('pluginSettings')); }
/** * Return Wysiwyg config as \Magento\Framework\DataObject * * Config options description: * * enabled: Enabled Visual Editor or not * hidden: Show Visual Editor on page load or not * use_container: Wrap Editor contents into div or not * no_display: Hide Editor container or not (related to use_container) * translator: Helper to translate phrases in lib * files_browser_*: Files Browser (media, images) settings * encode_directives: Encode template directives with JS or not * * @param array|\Magento\Framework\DataObject $data Object constructor params to override default config values * @return \Magento\Framework\DataObject */ public function getConfig($data = []) { $config = new \Magento\Framework\DataObject(); $config->setData(['enabled' => $this->isEnabled(), 'hidden' => $this->isHidden(), 'use_container' => false, 'add_variables' => true, 'add_widgets' => true, 'no_display' => false, 'encode_directives' => true, 'baseStaticUrl' => $this->_assetRepo->getStaticViewFileContext()->getBaseUrl(), 'baseStaticDefaultUrl' => str_replace('index.php/', '', $this->_backendUrl->getBaseUrl()) . $this->filesystem->getUri(DirectoryList::STATIC_VIEW) . '/', 'directives_url' => $this->_backendUrl->getUrl('cms/wysiwyg/directive'), 'popup_css' => $this->_assetRepo->getUrl('mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/dialog.css'), 'content_css' => $this->_assetRepo->getUrl('mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/content.css'), 'width' => '100%', 'height' => '500px', 'plugins' => []]); $config->setData('directives_url_quoted', preg_quote($config->getData('directives_url'))); if ($this->_authorization->isAllowed('Magento_Cms::media_gallery')) { $config->addData(['add_images' => true, 'files_browser_window_url' => $this->_backendUrl->getUrl('cms/wysiwyg_images/index'), 'files_browser_window_width' => $this->_windowSize['width'], 'files_browser_window_height' => $this->_windowSize['height']]); } if (is_array($data)) { $config->addData($data); } if ($config->getData('add_variables')) { $settings = $this->_variableConfig->getWysiwygPluginSettings($config); $config->addData($settings); } if ($config->getData('add_widgets')) { $settings = $this->_widgetConfig->getPluginSettings($config); $config->addData($settings); } return $config; }
/** * Return Wysiwyg config as \Magento\Framework\Object * * Config options description: * * enabled: Enabled Visual Editor or not * hidden: Show Visual Editor on page load or not * use_container: Wrap Editor contents into div or not * no_display: Hide Editor container or not (related to use_container) * translator: Helper to translate phrases in lib * files_browser_*: Files Browser (media, images) settings * encode_directives: Encode template directives with JS or not * * @param array|\Magento\Framework\Object $data Object constructor params to override default config values * @return \Magento\Framework\Object */ public function getConfig($data = array()) { $config = new \Magento\Framework\Object(); $config->setData(array('enabled' => $this->isEnabled(), 'hidden' => $this->isHidden(), 'use_container' => false, 'add_variables' => true, 'add_widgets' => true, 'no_display' => false, 'encode_directives' => true, 'directives_url' => $this->_backendUrl->getUrl('cms/wysiwyg/directive'), 'popup_css' => $this->_assetRepo->getUrl('mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/dialog.css'), 'content_css' => $this->_assetRepo->getUrl('mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/content.css'), 'width' => '100%', 'plugins' => array())); $config->setData('directives_url_quoted', preg_quote($config->getData('directives_url'))); if ($this->_authorization->isAllowed('Magento_Cms::media_gallery')) { $config->addData(array('add_images' => true, 'files_browser_window_url' => $this->_backendUrl->getUrl('cms/wysiwyg_images/index'), 'files_browser_window_width' => $this->_windowSize['width'], 'files_browser_window_height' => $this->_windowSize['height'])); } if (is_array($data)) { $config->addData($data); } if ($config->getData('add_variables')) { $settings = $this->_variableConfig->getWysiwygPluginSettings($config); $config->addData($settings); } if ($config->getData('add_widgets')) { $settings = $this->_widgetConfig->getPluginSettings($config); $config->addData($settings); } return $config; }
/** * @covers \Magento\Cms\Model\Wysiwyg\Config::getConfig * @param array $data * @param boolean $isAuthorizationAllowed * @param array $expectedResults * * @dataProvider getConfigDataProvider */ public function testGetConfig($data, $isAuthorizationAllowed, $expectedResults) { $wysiwygPluginSettings = ['wysiwygPluginSettings' => 'wysiwyg is here']; $pluginSettings = ['pluginSettings' => 'plugins are here']; $this->backendUrlMock->expects($this->atLeastOnce())->method('getUrl')->withConsecutive(['cms/wysiwyg/directive'], ['cms/wysiwyg_images/index']); $this->backendUrlMock->expects($this->once())->method('getBaseUrl')->willReturn('localhost/index.php/'); $this->assetRepoMock->expects($this->atLeastOnce())->method('getUrl')->withConsecutive(['mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/dialog.css'], ['mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/content.css']); $this->filesystemMock->expects($this->once())->method('getUri')->willReturn('pub/static'); /** @var \Magento\Framework\View\Asset\ContextInterface|\PHPUnit_Framework_MockObject_MockObject $contextMock */ $contextMock = $this->getMock(\Magento\Framework\View\Asset\ContextInterface::class); $contextMock->expects($this->once())->method('getBaseUrl')->willReturn('localhost/pub/static/'); $this->assetRepoMock->expects($this->once())->method('getStaticViewFileContext')->willReturn($contextMock); $this->authorizationMock->expects($this->atLeastOnce())->method('isAllowed')->with('Magento_Cms::media_gallery')->willReturn($isAuthorizationAllowed); $this->variableConfigMock->expects($this->any())->method('getWysiwygPluginSettings')->willReturn($wysiwygPluginSettings); $this->widgetConfigMock->expects($this->any())->method('getPluginSettings')->willReturn($pluginSettings); $config = $this->wysiwygConfig->getConfig($data); $this->assertInstanceOf('Magento\\Framework\\DataObject', $config); $this->assertEquals($expectedResults[0], $config->getData('someData')); $this->assertEquals($expectedResults[1], $config->getData('wysiwygPluginSettings')); $this->assertEquals($expectedResults[2], $config->getData('pluginSettings')); $this->assertEquals('localhost/pub/static/', $config->getData('baseStaticUrl')); $this->assertEquals('localhost/pub/static/', $config->getData('baseStaticDefaultUrl')); }
public function testGetWidgetWindowUrl() { $config = new \Magento\Framework\Object(['widget_filters' => ['is_email_compatible' => 1]]); $url = $this->_model->getWidgetWindowUrl($config); $this->assertStringStartsWith('http://localhost/index.php/backend/admin/widget/index/skip_widgets', $url); }