Skip to content

Commit b7d1892

Browse files
committed
MAGETWO-99286: Eliminate @escapeNotVerified in Magento_Swatches module
1 parent 226ce2f commit b7d1892

File tree

3 files changed

+35
-36
lines changed

3 files changed

+35
-36
lines changed

app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/js.phtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
7+
// phpcs:disable Magento2.Files.LineLength
8+
// phpcs:disable Magento2.Templates.ThisInTemplate
99
?>
1010
<script type="text/x-magento-init">
1111
{
1212
"*": {
1313
"swatchesProductAttributes": {
14-
"hiddenFields": <?= /* @escapeNotVerified */ json_encode($this->helper('Magento\Catalog\Helper\Data')->getAttributeHiddenFields()) ?>
14+
"hiddenFields": <?= /* @noEscape */ json_encode($this->helper(Magento\Catalog\Helper\Data::class)->getAttributeHiddenFields()) ?>
1515
}
1616
}
1717
}

app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/text.phtml

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
7+
// phpcs:disable Magento2.Files.LineLength
88

99
/** @var $block \Magento\Swatches\Block\Adminhtml\Attribute\Edit\Options\Text */
1010

@@ -20,9 +20,8 @@ $stores = $block->getStoresSortedBySortOrder();
2020
<tr id="swatch-text-options-table">
2121
<th class="col-draggable"></th>
2222
<th class="col-default"><span><?= $block->escapeHtml(__('Is Default')) ?></span></th>
23-
<?php foreach ($stores as $_store): ?>
24-
<th class="col-swatch col-swatch-min-width col-<%- data.id %>
25-
<?php if ($_store->getId() == \Magento\Store\Model\Store::DEFAULT_STORE_ID): ?> _required<?php endif; ?>"
23+
<?php foreach ($stores as $_store) : ?>
24+
<th class="col-swatch col-swatch-min-width col-<%- data.id %><?= ($_store->getId() == \Magento\Store\Model\Store::DEFAULT_STORE_ID) ? '_required' : '' ?>"
2625
colspan="2">
2726
<span><?= $block->escapeHtml($_store->getName()) ?></span>
2827
</th>
@@ -41,7 +40,7 @@ $stores = $block->getStoresSortedBySortOrder();
4140
</tr>
4241
<tr>
4342
<th colspan="<?= (int)$colTotal ?>" class="col-actions-add">
44-
<?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()):?>
43+
<?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()) : ?>
4544
<button id="add_new_swatch_text_option_button"
4645
title="<?= $block->escapeHtml(__('Add Swatch')) ?>"
4746
type="button" class="action- scalable add">
@@ -57,44 +56,44 @@ $stores = $block->getStoresSortedBySortOrder();
5756
<script id="swatch-text-row-template" type="text/x-magento-template">
5857
<tr>
5958
<td class="col-draggable">
60-
<?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()): ?>
59+
<?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()) : ?>
6160
<div data-role="draggable-handle"
6261
class="draggable-handle"
63-
title="<?= $block->escapeHtml(__('Sort Option')) ?>"></div>
62+
title="<?= $block->escapeHtmlAttr(__('Sort Option')) ?>"></div>
6463
<?php endif; ?>
6564
<input data-role="order" type="hidden" name="optiontext[order][<%- data.id %>]"
6665
value="<%- data.sort_order %>"
67-
<?php if ($block->getReadOnly() || $block->canManageOptionDefaultOnly()): ?> disabled="disabled"<?php endif; ?>
66+
<?= ($block->getReadOnly() || $block->canManageOptionDefaultOnly()) ? ' disabled="disabled"' : '' ?>
6867
/>
6968
</td>
7069
<td class="col-default">
7170
<input class="input-radio"
7271
type="<%- data.intype %>"
7372
name="defaulttext[]"
74-
value="<%- data.id %>" <%- data.checked %><?php if ($block->getReadOnly()):?>disabled="disabled"<?php endif;?>/>
73+
value="<%- data.id %>" <%- data.checked %><?= ($block->getReadOnly()) ? ' disabled="disabled"' : '' ?>/>
7574
</td>
76-
<?php foreach ($stores as $_store): ?>
75+
<?php foreach ($stores as $_store) : ?>
7776
<?php $storeId = (int)$_store->getId(); ?>
7877
<td class="col-swatch col-swatch-min-width col-<%- data.id %>">
7978
<input class="input-text
8079
swatch-text-field-<?= /* @noEscape */ $storeId ?>
81-
<?php if ($storeId == \Magento\Store\Model\Store::DEFAULT_STORE_ID): ?> required-option required-unique<?php endif; ?>"
80+
<?= ($storeId == \Magento\Store\Model\Store::DEFAULT_STORE_ID) ? ' required-option required-unique' : '' ?>"
8281
name="swatchtext[value][<%- data.id %>][<?= /* @noEscape */ $storeId ?>]"
8382
type="text" value="<%- data.swatch<?= /* @noEscape */ $storeId ?> %>"
84-
placeholder="<?= $block->escapeHtml(__("Swatch")) ?>"/>
83+
placeholder="<?= $block->escapeHtmlAttr(__("Swatch")) ?>"/>
8584
</td>
8685
<td class="col-swatch-min-width swatch-col-<%- data.id %>">
8786
<input name="optiontext[value][<%- data.id %>][<?= /* @noEscape */ $storeId ?>]"
8887
value="<%- data.store<?= /* @noEscape */ $storeId ?> %>"
89-
class="input-text<?php if ($storeId == \Magento\Store\Model\Store::DEFAULT_STORE_ID): ?> required-option<?php endif; ?>"
90-
type="text" <?php if ($block->getReadOnly() || $block->canManageOptionDefaultOnly()):?> disabled="disabled"<?php endif;?>
91-
placeholder="<?= $block->escapeHtml(__("Description")) ?>"/>
88+
class="input-text<?= ($storeId == \Magento\Store\Model\Store::DEFAULT_STORE_ID) ? ' required-option' : '' ?>"
89+
type="text" <?= ($block->getReadOnly() || $block->canManageOptionDefaultOnly()) ? ' disabled="disabled"' : ''?>
90+
placeholder="<?= $block->escapeHtmlAttr(__("Description")) ?>"/>
9291
</td>
9392
<?php endforeach; ?>
9493
<td id="delete_button_swatch_container_<%- data.id %>" class="col-delete">
9594
<input type="hidden" class="delete-flag" name="optiontext[delete][<%- data.id %>]" value="" />
96-
<?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()):?>
97-
<button title="<?= $block->escapeHtml(__('Delete')) ?>" type="button"
95+
<?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()) : ?>
96+
<button title="<?= $block->escapeHtmlAttr(__('Delete')) ?>" type="button"
9897
class="action- scalable delete delete-option">
9998
<span><?= $block->escapeHtml(__('Delete')) ?></span>
10099
</button>
@@ -105,10 +104,10 @@ $stores = $block->getStoresSortedBySortOrder();
105104
<script type="text/x-magento-init">
106105
{
107106
"*": {
108-
"Magento_Swatches/js/text": <?= /* @escapeNotVerified */ $block->getJsonConfig() ?> ,
107+
"Magento_Swatches/js/text": <?= /* @noEscape */ $block->getJsonConfig() ?> ,
109108
"Magento_Catalog/catalog/product/attribute/unique-validate": {
110109
"element": "required-text-swatch-unique",
111-
"message": "<?= $block->escapeHtml(__("The value of Admin must be unique.")) ?>"
110+
"message": "<?= $block->escapeJs($block->escapeHtml(__("The value of Admin must be unique."))) ?>"
112111
}
113112
}
114113
}

app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/edit/attribute/steps/attributes_values.phtml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
7+
// phpcs:disable Magento2.Files.LineLength
88

99
/* @var $block \Magento\ConfigurableProduct\Block\Adminhtml\Product\Steps\AttributeValues */
1010
?>
11-
<div data-bind="scope: '<?= /* @escapeNotVerified */ $block->getComponentName() ?>'">
12-
<h2 class="steps-wizard-title"><?= /* @escapeNotVerified */ __('Step 2: Attribute Values') ?></h2>
11+
<div data-bind="scope: '<?= $block->escapeHtmlAttr($block->getComponentName()) ?>'">
12+
<h2 class="steps-wizard-title"><?= $block->escapeHtml(__('Step 2: Attribute Values')) ?></h2>
1313
<div class="steps-wizard-info">
1414
<span><?= $block->escapeHtml(__('Select from the following attribute values for this product. Each unique combination of values creates a unique product SKU.')) ?></span>
1515
</div>
@@ -25,7 +25,7 @@
2525
<div class="attribute-entity-title" data-bind="text: label"></div>
2626
<div class="attribute-options-block">
2727
(<span class="attribute-length" data-bind="text: $data.options().length"></span>
28-
<?= /* @escapeNotVerified */ __('Options') ?>)
28+
<?= $block->escapeHtml(__('Options')) ?>)
2929
</div>
3030
</div>
3131

@@ -34,19 +34,19 @@
3434
class="action-select-all action-tertiary"
3535
data-bind="click: $parent.selectAllAttributes"
3636
title="<?= $block->escapeHtml(__('Select All')) ?>">
37-
<span><?= /* @escapeNotVerified */ __('Select All') ?></span>
37+
<span><?= $block->escapeHtml(__('Select All')) ?></span>
3838
</button>
3939
<button type="button"
4040
class="action-deselect-all action-tertiary"
4141
data-bind="click: $parent.deSelectAllAttributes"
4242
title="<?= $block->escapeHtml(__('Deselect All')) ?>">
43-
<span><?= /* @escapeNotVerified */ __('Deselect All') ?></span>
43+
<span><?=$block->escapeHtml(__('Deselect All')) ?></span>
4444
</button>
4545
<button type="button"
4646
class="action-remove-all action-tertiary"
4747
data-bind="click: $parent.removeAttribute.bind($parent)"
4848
title="<?= $block->escapeHtml(__('Remove Attribute')) ?>">
49-
<span><?= /* @escapeNotVerified */ __('Remove Attribute') ?></span>
49+
<span><?= $block->escapeHtml(__('Remove Attribute')) ?></span>
5050
</button>
5151
</div>
5252
</div>
@@ -74,14 +74,14 @@
7474
title="<?= $block->escapeHtml(__('Save Option')) ?>"
7575
data-action="save"
7676
data-bind="click: $parents[1].saveOption.bind($parent)">
77-
<span><?= /* @escapeNotVerified */ __('Save Option') ?></span>
77+
<span><?= $block->escapeHtml(__('Save Option')) ?></span>
7878
</button>
7979
<button type="button"
8080
class="action-remove"
8181
title="<?= $block->escapeHtml(__('Remove Option')) ?>"
8282
data-action="remove"
8383
data-bind="click: $parents[1].removeOption.bind($parent)">
84-
<span><?= /* @escapeNotVerified */ __('Remove Option') ?></span>
84+
<span><?= $block->escapeHtml(__('Remove Option')) ?></span>
8585
</button>
8686
</div>
8787
</li>
@@ -91,7 +91,7 @@
9191
type="button"
9292
data-action="addOption"
9393
data-bind="click: $parent.createOption, visible: canCreateOption">
94-
<span><?= /* @escapeNotVerified */ __('Create New Value') ?></span>
94+
<span><?= $block->escapeHtml(__('Create New Value')) ?></span>
9595
</button>
9696
</div>
9797
</div>
@@ -101,11 +101,11 @@
101101
"*": {
102102
"Magento_Ui/js/core/app": {
103103
"components": {
104-
"<?= /* @escapeNotVerified */ $block->getComponentName() ?>": {
104+
"<?= $block->escapeJs($block->getComponentName()) ?>": {
105105
"component": "Magento_ConfigurableProduct/js/variations/steps/attributes_values",
106-
"appendTo": "<?= /* @escapeNotVerified */ $block->getParentComponentName() ?>",
107-
"optionsUrl": "<?= /* @escapeNotVerified */ $block->getUrl('catalog/product_attribute/getAttributes') ?>",
108-
"createOptionsUrl": "<?= /* @escapeNotVerified */ $block->getUrl('catalog/product_attribute/createOptions') ?>"
106+
"appendTo": "<?= $block->escapeJs($block->getParentComponentName()) ?>",
107+
"optionsUrl": "<?= $block->escapeJs($block->escapeUrl($block->getUrl('catalog/product_attribute/getAttributes'))) ?>",
108+
"createOptionsUrl": "<?= $block->escapeJs($block->escapeUrl($block->getUrl('catalog/product_attribute/createOptions'))) ?>"
109109
}
110110
}
111111
}

0 commit comments

Comments
 (0)