![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/app/code/Soon/CsBlock/Model/InputType/Element/ |
<?php /** * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @author Hervé Guétin <[email protected]> <@herveguetin> * @copyright Copyright (c) 2017 Agence Soon (http://www.agence-soon.fr) */ namespace Soon\CsBlock\Model\InputType\Element; use Magento\Framework\Data\Form\Element\AbstractElement; use Magento\Framework\Data\Form\Element\CollectionFactory; use Magento\Framework\Data\Form\Element\Factory; use Magento\Framework\Escaper; use Magento\Framework\UrlInterface; class Media extends AbstractElement { /** * @var UrlInterface */ private $url; public function __construct( Factory $factoryElement, CollectionFactory $factoryCollection, Escaper $escaper, UrlInterface $url, array $data = [] ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); $this->setType('media'); $this->url = $url; } /** * @return string */ public function getElementHtml() { $textInput = sprintf( '<textarea id="%s" name="%s" class="input-text admin__control-text" %s >' . $this->getEscapedValue() . '</textarea>', $this->getHtmlId(), $this->getName(), $this->serialize($this->getHtmlAttributes()) . $this->_getUiId() ); $button = '<button type="button" class="scalable action-add-image plugin" onclick="MediabrowserUtility.openDialog(\'' . $this->getMediaBrowserUrl() . '\', false, false, \'\', {closed: function() {}})" style=""><span><span><span>Insert Image...</span></span></span></button>'; $html = $this->getBeforeElementHtml() . $textInput . $button . $this->getAfterElementHtml(); return $html; } /** * @return string */ private function getMediaBrowserUrl() { return $this->url->getUrl('cms/wysiwyg_images/index', ['target_element_id' => $this->getHtmlId()]); } }