77
88namespace Magefan \Blog \Block \Adminhtml \Widget \Featured \Grid ;
99
10- use Magento \Framework \App \ObjectManager ;
11- use Magento \Framework \View \Helper \SecureHtmlRenderer ;
12-
1310class Chooser extends \Magento \Widget \Block \Adminhtml \Widget \Chooser
1411{
15- /**
16- * @var SecureHtmlRenderer|null
17- */
18- protected $ secureRenderer ;
19-
20- /**
21- * @param \Magento\Backend\Block\Template\Context $context
22- * @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
23- * @param \Magento\Framework\Data\Form\Element\Factory $elementFactory
24- * @param array $data
25- * @param SecureHtmlRenderer|null $secureRenderer
26- */
27- public function __construct (
28- \Magento \Backend \Block \Template \Context $ context ,
29- \Magento \Framework \Json \EncoderInterface $ jsonEncoder ,
30- \Magento \Framework \Data \Form \Element \Factory $ elementFactory ,
31- array $ data = [], ?SecureHtmlRenderer
32- $ secureRenderer = null
33- ) {
34- $ this ->secureRenderer = $ secureRenderer ?? ObjectManager::getInstance ()->get (SecureHtmlRenderer::class);
35- parent ::__construct ($ context , $ jsonEncoder , $ elementFactory , $ data , $ secureRenderer );
36- }
37-
3812 /**
3913 * @param string $chooserId
4014 * @return string
4115 */
4216 public function onClickJs (string $ chooserId ) : string
4317 {
44- $ buttonHtml = "<button id='addBtn' class='action-primary' ><span>Save </span></button> " ;
18+ $ buttonHtml = "<button id='addBtn' class='action-primary' ><span>Use Selected Posts </span></button> " ;
4519 $ js = '
4620 var waitForElm = function(selector) {
4721 return new Promise(resolve => {
@@ -203,9 +177,7 @@ protected function _toHtml() : string
203177 <div id=" ' .
204178 $ chooserId .
205179 'advice-container" class="hidden"></div> ' .
206- $ this ->secureRenderer ->renderTag (
207- 'script ' ,
208- [],
180+ '<script> ' .
209181 'require(["prototype", "mage/adminhtml/wysiwyg/widget"], function(){
210182 //<![CDATA[
211183 (function() {
@@ -239,8 +211,6 @@ protected function _toHtml() : string
239211 })();
240212 //]]>
241213 });
242- ' ,
243- false
244- );
214+ ' . '</script> ' ;
245215 }
246216}
0 commit comments