Skip to content

Commit c9cf047

Browse files
author
Oleksandr Gorkun
committed
Merge branch 'MC-29420' of https://github.com/magento-qwerty/magento2ce into MC-33823
� Conflicts: � app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/SubscriptionStatusLabelTest.php � app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/VerticalTest.php � app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/CheckboxTest.php � app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/MultiTest.php � app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/RadioTest.php � app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/SelectTest.php � app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/ImageTest.php � app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/Select/AllowspecificTest.php � app/code/Magento/Config/Test/Unit/Block/System/Config/Form/FieldTest.php � app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php � app/code/Magento/Config/Test/Unit/Block/System/Config/Form/FieldsetTest.php � app/code/Magento/Customer/Block/Form/Register.php � app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Decorator/DebugHintsTest.php � app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/ButtonTest.php � app/code/Magento/OfflineShipping/Test/Unit/Block/Adminhtml/Form/Field/ImportTest.php � app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Field/CountryTest.php � app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Field/Enable/AbstractEnableTest.php � app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Fieldset/GroupTest.php � app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Fieldset/PaymentTest.php � dev/tests/integration/testsuite/Magento/Payment/Block/Transparent/IframeTest.php � lib/internal/Magento/Framework/View/Test/Unit/Helper/JsTest.php
2 parents bf982da + 3be360f commit c9cf047

File tree

408 files changed

+10092
-4340
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

408 files changed

+10092
-4340
lines changed

app/code/Magento/AdminAnalytics/view/adminhtml/templates/notification.phtml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,21 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7+
8+
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
79
?>
810

9-
<script>
11+
<?php
12+
$isAnaliticsVisible = $block->getNotification()->isAnalyticsVisible() ? 1 : 0;
13+
$isReleaseVisible = $block->getNotification()->isReleaseVisible() ? 1 : 0;
14+
$scriptString = <<<script
1015
define('analyticsPopupConfig', function () {
1116
return {
12-
analyticsVisible: <?= $block->getNotification()->isAnalyticsVisible() ? 1 : 0; ?>,
13-
releaseVisible: <?= $block->getNotification()->isReleaseVisible() ? 1 : 0; ?>,
17+
analyticsVisible: {$isAnaliticsVisible},
18+
releaseVisible: {$isReleaseVisible},
1419
}
1520
});
16-
</script>
21+
script
22+
?>
23+
24+
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false); ?>

app/code/Magento/AdminAnalytics/view/adminhtml/templates/tracking.phtml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,28 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
7+
/**
8+
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
9+
*/
610
?>
711

8-
<script src="<?= $block->escapeUrl($block->getTrackingUrl()) ?>" async></script>
9-
<script>
12+
<?= /* @noEscape */ $secureRenderer->renderTag(
13+
'script',
14+
[
15+
'src' => '"' . $block->escapeJs($block->getTrackingUrl()) .'"',
16+
'async' => true,
17+
],
18+
'&nbsp;',
19+
false
20+
) ?>
21+
22+
<?php $scriptString = '
1023
var adminAnalyticsMetadata = {
11-
"version": "<?= $block->escapeJs($block->getMetadata()->getMagentoVersion()) ?>",
12-
"user": "<?= $block->escapeJs($block->getMetadata()->getCurrentUser()) ?>",
13-
"mode": "<?= $block->escapeJs($block->getMetadata()->getMode()) ?>"
24+
"version": "' . $block->escapeJs($block->getMetadata()->getMagentoVersion()) . '",
25+
"user": "' . $block->escapeJs($block->getMetadata()->getCurrentUser()) . '",
26+
"mode": "' . $block->escapeJs($block->getMetadata()->getMode()) . '"
1427
};
15-
</script>
28+
';
29+
?>
30+
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false); ?>

app/code/Magento/AdminNotification/view/adminhtml/templates/notification/window.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
/**
88
* @see \Magento\AdminNotification\Block\Window
9+
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
910
*/
1011
?>
1112
<ul class="message-system-list"
12-
style="display: none;"
1313
data-mage-init='{
1414
"Magento_Ui/js/modal/modal": {
1515
"autoOpen": true,
@@ -25,3 +25,4 @@
2525
</a>
2626
</li>
2727
</ul>
28+
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag('display:none', '.message-system-list'); ?>

app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@
55
*/
66

77
/** @var $block \Magento\AdminNotification\Block\System\Messages\UnreadMessagePopup */
8+
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
89
?>
910

10-
<div style="display:none" id="system_messages_list" data-role="system_messages_list"
11+
<div id="system_messages_list" data-role="system_messages_list"
1112
title="<?= $block->escapeHtmlAttr($block->getPopupTitle()) ?>">
1213
<ul class="message-system-list messages">
13-
<?php foreach ($block->getUnreadMessages() as $message) : ?>
14+
<?php foreach ($block->getUnreadMessages() as $message): ?>
1415
<li class="message message-warning <?= $block->escapeHtmlAttr($block->getItemClass($message)) ?>">
1516
<?= $block->escapeHtml($message->getText()) ?>
1617
</li>
1718
<?php endforeach;?>
1819
</ul>
1920
</div>
21+
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag('display:none', '#system_messages_list'); ?>
2022

2123
<script type="text/x-magento-init">
2224
{
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
/** @var Magento\AuthorizenetAcceptjs\Block\Payment $block */
8+
?>
9+
<script>
10+
//<![CDATA[
11+
require(
12+
[
13+
'Magento_AuthorizenetAcceptjs/js/authorizenet',
14+
'jquery',
15+
'domReady!'
16+
], function(AuthorizenetAcceptjs, $) {
17+
var config = <?= /* @noEscape */ $block->getPaymentConfig() ?>,
18+
form = $('#payment_form_<?= /* @noEscape */ $block->escapeJs($block->escapeHtml($block->getMethodCode())) ?>');
19+
20+
config.active = form.length > 0 && !form.is(':hidden');
21+
new AuthorizenetAcceptjs(config);
22+
});
23+
//]]>
24+
</script>

app/code/Magento/Backend/Block/Template.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
namespace Magento\Backend\Block;
1010

11+
use Magento\Framework\App\ObjectManager;
12+
use Magento\Framework\Json\Helper\Data as JsonHelper;
13+
use Magento\Directory\Helper\Data as DirectoryHelper;
14+
1115
/**
1216
* Standard admin block. Adds admin-specific behavior and event.
1317
* Should be used when you declare a block in admin layout handle.
@@ -60,15 +64,23 @@ class Template extends \Magento\Framework\View\Element\Template
6064
/**
6165
* @param \Magento\Backend\Block\Template\Context $context
6266
* @param array $data
67+
* @param JsonHelper|null $jsonHelper
68+
* @param DirectoryHelper|null $directoryHelper
6369
*/
64-
public function __construct(\Magento\Backend\Block\Template\Context $context, array $data = [])
65-
{
70+
public function __construct(
71+
\Magento\Backend\Block\Template\Context $context,
72+
array $data = [],
73+
?JsonHelper $jsonHelper = null,
74+
?DirectoryHelper $directoryHelper = null
75+
) {
6676
$this->_localeDate = $context->getLocaleDate();
6777
$this->_authorization = $context->getAuthorization();
6878
$this->mathRandom = $context->getMathRandom();
6979
$this->_backendSession = $context->getBackendSession();
7080
$this->formKey = $context->getFormKey();
7181
$this->nameBuilder = $context->getNameBuilder();
82+
$data['jsonHelper'] = $jsonHelper ?? ObjectManager::getInstance()->get(JsonHelper::class);
83+
$data['directoryHelper']= $directoryHelper ?? ObjectManager::getInstance()->get(DirectoryHelper::class);
7284
parent::__construct($context, $data);
7385
}
7486

app/code/Magento/Backend/Block/Widget/Form/Container.php

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
*/
66
namespace Magento\Backend\Block\Widget\Form;
77

8+
use Magento\Backend\Block\Widget\Context;
9+
use Magento\Framework\App\ObjectManager;
10+
use Magento\Framework\View\Helper\SecureHtmlRenderer;
11+
812
/**
913
* Backend form container block
1014
*
@@ -39,7 +43,7 @@ class Container extends \Magento\Backend\Block\Widget\Container
3943
* @var string
4044
*/
4145
protected $_blockGroup = 'Magento_Backend';
42-
46+
4347
/**
4448
* @var string
4549
*/
@@ -55,6 +59,25 @@ class Container extends \Magento\Backend\Block\Widget\Container
5559
*/
5660
protected $_template = 'Magento_Backend::widget/form/container.phtml';
5761

62+
/**
63+
* @var SecureHtmlRenderer
64+
*/
65+
private $secureRenderer;
66+
67+
/**
68+
* @param Context $context
69+
* @param array $data
70+
* @param SecureHtmlRenderer|null $secureRenderer
71+
*/
72+
public function __construct(
73+
Context $context,
74+
array $data = [],
75+
?SecureHtmlRenderer $secureRenderer = null
76+
) {
77+
$this->secureRenderer = $secureRenderer ?? ObjectManager::getInstance()->get(SecureHtmlRenderer::class);
78+
parent::__construct($context, $data);
79+
}
80+
5881
/**
5982
* Initialize form.
6083
*
@@ -205,8 +228,14 @@ public function getFormHtml()
205228
public function getFormInitScripts()
206229
{
207230
if (!empty($this->_formInitScripts) && is_array($this->_formInitScripts)) {
208-
return '<script>' . implode("\n", $this->_formInitScripts) . '</script>';
231+
return $this->secureRenderer->renderTag(
232+
'script',
233+
[],
234+
implode("\n", $this->_formInitScripts),
235+
false
236+
);
209237
}
238+
210239
return '';
211240
}
212241

@@ -218,8 +247,14 @@ public function getFormInitScripts()
218247
public function getFormScripts()
219248
{
220249
if (!empty($this->_formScripts) && is_array($this->_formScripts)) {
221-
return '<script>' . implode("\n", $this->_formScripts) . '</script>';
250+
return $this->secureRenderer->renderTag(
251+
'script',
252+
[],
253+
implode("\n", $this->_formScripts),
254+
false
255+
);
222256
}
257+
223258
return '';
224259
}
225260

app/code/Magento/Backend/Block/Widget/Form/Element/Dependence.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
namespace Magento\Backend\Block\Widget\Form\Element;
88

9+
use Magento\Framework\App\ObjectManager;
10+
use Magento\Framework\View\Helper\SecureHtmlRenderer;
11+
912
/**
1013
* Form element dependencies mapper
1114
* Assumes that one element may depend on other element values.
@@ -52,21 +55,29 @@ class Dependence extends \Magento\Backend\Block\AbstractBlock
5255
*/
5356
protected $_jsonEncoder;
5457

58+
/**
59+
* @var SecureHtmlRenderer
60+
*/
61+
protected $secureRenderer;
62+
5563
/**
5664
* @param \Magento\Backend\Block\Context $context
5765
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
5866
* @param \Magento\Config\Model\Config\Structure\Element\Dependency\FieldFactory $fieldFactory
5967
* @param array $data
68+
* @param SecureHtmlRenderer|null $secureRenderer
6069
*/
6170
public function __construct(
6271
\Magento\Backend\Block\Context $context,
6372
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
6473
\Magento\Config\Model\Config\Structure\Element\Dependency\FieldFactory $fieldFactory,
65-
array $data = []
74+
array $data = [],
75+
?SecureHtmlRenderer $secureRenderer = null
6676
) {
6777
$this->_jsonEncoder = $jsonEncoder;
6878
$this->_fieldFactory = $fieldFactory;
6979
parent::__construct($context, $data);
80+
$this->secureRenderer = $secureRenderer ?? ObjectManager::getInstance()->get(SecureHtmlRenderer::class);
7081
}
7182

7283
/**
@@ -131,11 +142,11 @@ protected function _toHtml()
131142
$params .= ', ' . $this->_jsonEncoder->encode($this->_configOptions);
132143
}
133144

134-
return "<script>
135-
require(['mage/adminhtml/form'], function(){
136-
new FormElementDependenceController({$params});
137-
});
138-
</script>";
145+
$scriptString = 'require([\'mage/adminhtml/form\'], function(){
146+
new FormElementDependenceController(' . $params . ');
147+
});';
148+
149+
return /* @noEscape */ $this->secureRenderer->renderTag('script', [], $scriptString, false);
139150
}
140151

141152
/**

app/code/Magento/Backend/Block/Widget/Form/Element/Gallery.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
namespace Magento\Backend\Block\Widget\Form\Element;
88

9+
use Magento\Framework\App\ObjectManager;
910
use Magento\Framework\Data\Form\Element\AbstractElement;
11+
use Magento\Framework\Json\Helper\Data as JsonHelper;
12+
use Magento\Backend\Block\Template\Context;
1013

1114
/**
1215
* Backend image gallery item renderer
@@ -27,6 +30,18 @@ class Gallery extends \Magento\Backend\Block\Template implements
2730
protected $_template = 'Magento_Backend::widget/form/element/gallery.phtml';
2831

2932
/**
33+
* @param Context $context
34+
* @param array $data
35+
*/
36+
public function __construct(Context $context, array $data = [])
37+
{
38+
$data['jsonHelper'] = ObjectManager::getInstance()->get(JsonHelper::class);
39+
parent::__construct($context, $data);
40+
}
41+
42+
/**
43+
* Renderer.
44+
*
3045
* @param AbstractElement $element
3146
* @return string
3247
*/
@@ -37,6 +52,8 @@ public function render(AbstractElement $element)
3752
}
3853

3954
/**
55+
* Set element.
56+
*
4057
* @param AbstractElement $element
4158
* @return $this
4259
*/
@@ -47,6 +64,8 @@ public function setElement(AbstractElement $element)
4764
}
4865

4966
/**
67+
* Get element.
68+
*
5069
* @return AbstractElement|null
5170
*/
5271
public function getElement()
@@ -55,6 +74,8 @@ public function getElement()
5574
}
5675

5776
/**
77+
* Get value.
78+
*
5879
* @return array
5980
*/
6081
public function getValues()
@@ -63,7 +84,7 @@ public function getValues()
6384
}
6485

6586
/**
66-
* {@inheritdoc}
87+
* @inheritdoc
6788
*/
6889
protected function _prepareLayout()
6990
{
@@ -82,6 +103,8 @@ protected function _prepareLayout()
82103
}
83104

84105
/**
106+
* Return add button.
107+
*
85108
* @return string
86109
*/
87110
public function getAddButtonHtml()
@@ -90,6 +113,8 @@ public function getAddButtonHtml()
90113
}
91114

92115
/**
116+
* Return delete button.
117+
*
93118
* @param string $image
94119
* @return string|string[]
95120
*/

0 commit comments

Comments
 (0)