Skip to content

Commit 0437d95

Browse files
Merge remote-tracking branch '32622/bugfix/grid_selected_spacing' into Aug01-comprs
2 parents fe72c40 + 52b154f commit 0437d95

File tree

1 file changed

+53
-49
lines changed
  • app/code/Magento/Backend/view/adminhtml/templates/widget

1 file changed

+53
-49
lines changed

app/code/Magento/Backend/view/adminhtml/templates/widget/grid.phtml

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
* All Rights Reserved.
55
*/
66

7+
use Magento\Backend\Block\Widget\Grid;
8+
use Magento\Framework\Escaper;
9+
use Magento\Framework\View\Helper\SecureHtmlRenderer;
10+
711
?>
812
<?php
913
/**
@@ -16,15 +20,15 @@
1620
* getVarNamePage()
1721
*
1822
*/
19-
/* @var $block \Magento\Backend\Block\Widget\Grid */
20-
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
23+
/** @var Grid $block */
24+
/** @var Escaper $escaper */
25+
/** @var SecureHtmlRenderer $secureRenderer */
2126

22-
$numColumns = $block->getColumns() !== null ? count($block->getColumns()): 0;
27+
$numColumns = $block->getColumns() !== null ? count($block->getColumns()) : 0;
2328
?>
2429
<?php if ($block->getCollection()): ?>
25-
2630
<?php if ($block->canDisplayContainer()): ?>
27-
<div id="<?= $block->escapeHtml($block->getId()) ?>" data-grid-id="<?= $block->escapeHtml($block->getId()) ?>">
31+
<div id="<?= $escaper->escapeHtml($block->getId()) ?>" data-grid-id="<?= $escaper->escapeHtml($block->getId()) ?>">
2832
<?php else: ?>
2933
<?= $block->getLayout()->getMessagesBlock()->getGroupedHtml() ?>
3034
<?php endif; ?>
@@ -45,7 +49,7 @@ $numColumns = $block->getColumns() !== null ? count($block->getColumns()): 0;
4549
<?php endif; ?>
4650
</div>
4751
<?php endif; ?>
48-
<div class="<?php if ($massActionAvailable) { echo '_massaction ';} ?>admin__data-grid-header-row">
52+
<div class="<?= $massActionAvailable ? '_massaction ' : '' ?>admin__data-grid-header-row">
4953
<?php if ($massActionAvailable): ?>
5054
<?= $block->getChildHtml('grid.massaction') ?>
5155
<?php else: ?>
@@ -54,20 +58,19 @@ $numColumns = $block->getColumns() !== null ? count($block->getColumns()): 0;
5458
<?php endif; ?>
5559
<?php $countRecords = $block->getCollection()->getSize(); ?>
5660
<div class="admin__control-support-text">
57-
<span id="<?= $block->escapeHtml($block->getHtmlId()) ?>-total-count"
61+
<span id="<?= $escaper->escapeHtml($block->getHtmlId()) ?>-total-count"
5862
<?= /* @noEscape */ $block->getUiId('total-count') ?>>
5963
<?= /* @noEscape */ $countRecords ?>
6064
</span>
61-
<?= $block->escapeHtml(__('records found')) ?>
62-
<span id="<?= $block->escapeHtml($block->getHtmlId()) ?>_massaction-count"
65+
<?= $escaper->escapeHtml(__('records found')) ?>
66+
<span id="<?= $escaper->escapeHtml($block->getHtmlId()) ?>_massaction-count"
6367
class="mass-select-info _empty"><strong data-role="counter">0</strong>
64-
<span><?= $block->escapeHtml(__('selected')) ?></span>
65-
</span>
68+
<span><?= $escaper->escapeHtml(__('selected')) ?></span></span>
6669
</div>
6770
<?php if ($block->getPagerVisibility()): ?>
6871
<div class="admin__data-grid-pager-wrap">
69-
<select name="<?= $block->escapeHtmlAttr($block->getVarNameLimit()) ?>"
70-
id="<?= $block->escapeHtml($block->getHtmlId()) ?>_page-limit"
72+
<select name="<?= $escaper->escapeHtmlAttr($block->getVarNameLimit()) ?>"
73+
id="<?= $escaper->escapeHtml($block->getHtmlId()) ?>_page-limit"
7174
onchange="<?= /* @noEscape */ $block->getJsObjectName() ?>.loadByElement(this)"
7275
<?= /* @noEscape */ $block->getUiId('per-page') ?>
7376
class="admin__control-select">
@@ -87,63 +90,63 @@ $numColumns = $block->getColumns() !== null ? count($block->getColumns()): 0;
8790
selected="selected"<?php endif; ?>>200
8891
</option>
8992
</select>
90-
<label for="<?= $block->escapeHtml($block->getHtmlId()) ?>_page-limit"
91-
class="admin__control-support-text"><?= $block->escapeHtml(__('per page')) ?></label>
93+
<label for="<?= $escaper->escapeHtml($block->getHtmlId()) ?>_page-limit"
94+
class="admin__control-support-text"><?= $escaper->escapeHtml(__('per page')) ?></label>
9295
<div class="admin__data-grid-pager">
9396
<?php $_curPage = $block->getCollection()->getCurPage() ?>
9497
<?php $_lastPage = $block->getCollection()->getLastPageNumber() ?>
9598

9699
<?php if ($_curPage > 1): ?>
97100
<button class="action-previous" type="button">
98-
<span><?= $block->escapeHtml(__('Previous page')) ?></span>
101+
<span><?= $escaper->escapeHtml(__('Previous page')) ?></span>
99102
</button>
100103
<?= /* @noEscape */ $secureRenderer->renderEventListenerAsTag(
101104
'onclick',
102105
/* @noEscape */ $block->getJsObjectName() . '.setPage(\'' .
103106
/* @noEscape */ ($_curPage - 1) . '\');event.preventDefault();',
104-
'div#' . $block->escapeJs($block->getId()) .
107+
'div#' . $escaper->escapeJs($block->getId()) .
105108
' .admin__data-grid-pager button.action-previous:not(.disabled)'
106109
) ?>
107110
<?php else: ?>
108111
<button type="button" class="action-previous disabled">
109-
<span><?= $block->escapeHtml(__('Previous page')) ?></span>
112+
<span><?= $escaper->escapeHtml(__('Previous page')) ?></span>
110113
</button>
111114
<?php endif; ?>
112115

113116
<input type="text"
114-
id="<?= $block->escapeHtml($block->getHtmlId()) ?>_page-current"
115-
name="<?= $block->escapeHtmlAttr($block->getVarNamePage()) ?>"
116-
value="<?= $block->escapeHtmlAttr($_curPage) ?>"
117+
id="<?= $escaper->escapeHtml($block->getHtmlId()) ?>_page-current"
118+
name="<?= $escaper->escapeHtmlAttr($block->getVarNamePage()) ?>"
119+
value="<?= $escaper->escapeHtmlAttr($_curPage) ?>"
117120
class="admin__control-text"
118121
<?= /* @noEscape */ $block->getUiId('current-page') ?> />
119122

120123
<?= /* @noEscape */ $secureRenderer->renderEventListenerAsTag(
121124
'onkeypress',
122125
/* @noEscape */ $block->getJsObjectName() . '.inputPage(event, \'' .
123126
/* @noEscape */ $_lastPage . '\')',
124-
'#' . $block->escapeHtml($block->getHtmlId()) . '_page-current'
127+
'#' . $escaper->escapeHtml($block->getHtmlId()) . '_page-current'
125128
) ?>
126129

127-
<label class="admin__control-support-text" for="<?= $block->escapeHtml($block->getHtmlId())
128-
?>_page-current">
130+
<label class="admin__control-support-text"
131+
for="<?= $escaper->escapeHtml($block->getHtmlId()) ?>_page-current">
129132
<?= /* @noEscape */ __('of %1', '<span>' .
130133
$block->getCollection()->getLastPageNumber() . '</span>') ?>
131134
</label>
132135
<?php if ($_curPage < $_lastPage): ?>
133-
<button type="button" title="<?= $block->escapeHtmlAttr(__('Next page')) ?>"
136+
<button type="button" title="<?= $escaper->escapeHtmlAttr(__('Next page')) ?>"
134137
class="action-next">
135-
<span><?= $block->escapeHtml(__('Next page')) ?></span>
138+
<span><?= $escaper->escapeHtml(__('Next page')) ?></span>
136139
</button>
137140
<?= /* @noEscape */ $secureRenderer->renderEventListenerAsTag(
138141
'onclick',
139142
/* @noEscape */ $block->getJsObjectName() . '.setPage(\'' .
140143
/* @noEscape */ ($_curPage + 1) . '\');event.preventDefault();',
141-
'div#' . $block->escapeJs($block->getId()) .
144+
'div#' . $escaper->escapeJs($block->getId()) .
142145
' .admin__data-grid-pager button.action-next:not(.disabled)'
143146
) ?>
144147
<?php else: ?>
145148
<button type="button" class="action-next disabled">
146-
<span><?= $block->escapeHtml(__('Next page')) ?></span>
149+
<span><?= $escaper->escapeHtml(__('Next page')) ?></span>
147150
</button>
148151
<?php endif; ?>
149152
</div>
@@ -153,14 +156,14 @@ $numColumns = $block->getColumns() !== null ? count($block->getColumns()): 0;
153156
</div>
154157
<div class="admin__data-grid-wrap admin__data-grid-wrap-static">
155158
<?php if ($block->getGridCssClass()): ?>
156-
<table class="<?= $block->escapeHtmlAttr($block->getGridCssClass()) ?> data-grid"
157-
id="<?= $block->escapeHtml($block->getId()) ?>_table">
159+
<table class="<?= $escaper->escapeHtmlAttr($block->getGridCssClass()) ?> data-grid"
160+
id="<?= $escaper->escapeHtml($block->getId()) ?>_table">
158161
<!-- Rendering column set -->
159162
<?= $block->getChildHtml('grid.columnSet') ?>
160163
</table>
161164
<?php else: ?>
162165

163-
<table class="data-grid" id="<?= $block->escapeHtml($block->getId()) ?>_table">
166+
<table class="data-grid" id="<?= $escaper->escapeHtml($block->getId()) ?>_table">
164167
<!-- Rendering column set -->
165168
<?= $block->getChildHtml('grid.columnSet') ?>
166169
</table>
@@ -191,44 +194,45 @@ $numColumns = $block->getColumns() !== null ? count($block->getColumns()): 0;
191194
require(deps, function('. ($block->getDependencyJsObject() ? 'registry' : '') .'){' . PHP_EOL;
192195
//TODO: getJsObjectName and getRowClickCallback has unexpected behavior. Should be removed
193196
if ($block->getDependencyJsObject()) {
194-
$scriptString .= 'registry.get(\'' . $block->escapeJs($block->getDependencyJsObject()) .
195-
'\', function ('. $block->escapeJs($block->getDependencyJsObject()) . ') {' . PHP_EOL;
197+
$scriptString .= 'registry.get(\'' . $escaper->escapeJs($block->getDependencyJsObject()) .
198+
'\', function ('. $escaper->escapeJs($block->getDependencyJsObject()) . ') {' . PHP_EOL;
196199
}
197200

198-
$scriptString .= $block->escapeJs($block->getJsObjectName()) . ' = new varienGrid(\'' .
199-
$block->escapeJs($block->getId()) . '\', \'' . $block->escapeJs($block->getGridUrl()) . '\', \'' .
200-
$block->escapeJs($block->getVarNamePage()) .'\', \'' .
201-
$block->escapeJs($block->getVarNameSort()) . '\', \'' .
202-
$block->escapeJs($block->getVarNameDir()) . '\', \'' . $block->escapeJs($block->getVarNameFilter()) .'\');
201+
$scriptString .= $escaper->escapeJs($block->getJsObjectName()) . ' = new varienGrid(\'' .
202+
$escaper->escapeJs($block->getId()) . '\', \'' . $escaper->escapeJs($block->getGridUrl()) . '\', \'' .
203+
$escaper->escapeJs($block->getVarNamePage()) .'\', \'' .
204+
$escaper->escapeJs($block->getVarNameSort()) . '\', \'' .
205+
$escaper->escapeJs($block->getVarNameDir()) . '\', \'' .
206+
$escaper->escapeJs($block->getVarNameFilter()) .'\');
203207
' . PHP_EOL;
204-
$scriptString .= $block->escapeJs($block->getJsObjectName()) . '.useAjax = ' .
205-
(/* @noEscape */ $block->escapeJs($block->getUseAjax()) ? 'true' : 'false') . ';' . PHP_EOL;
208+
$scriptString .= $escaper->escapeJs($block->getJsObjectName()) . '.useAjax = ' .
209+
(/* @noEscape */ $escaper->escapeJs($block->getUseAjax()) ? 'true' : 'false') . ';' . PHP_EOL;
206210
if ($block->getRowClickCallback()) {
207-
$scriptString .= $block->escapeJs($block->getJsObjectName()) . '.rowClickCallback = ' .
211+
$scriptString .= $escaper->escapeJs($block->getJsObjectName()) . '.rowClickCallback = ' .
208212
/* @noEscape */ $block->getRowClickCallback() . ';' . PHP_EOL;
209213
}
210214

211215
if ($block->getCheckboxCheckCallback()) {
212-
$scriptString .= $block->escapeJs($block->getJsObjectName()) . '.checkboxCheckCallback = ' .
216+
$scriptString .= $escaper->escapeJs($block->getJsObjectName()) . '.checkboxCheckCallback = ' .
213217
/* @noEscape */ $block->getCheckboxCheckCallback() . ';' . PHP_EOL;
214218
}
215219

216220
if ($block->getSortableUpdateCallback()) {
217-
$scriptString .= $block->escapeJs($block->getJsObjectName()) . '.sortableUpdateCallback = ' .
221+
$scriptString .= $escaper->escapeJs($block->getJsObjectName()) . '.sortableUpdateCallback = ' .
218222
/* @noEscape */ $block->getSortableUpdateCallback() . ';' . PHP_EOL;
219223
}
220224

221225
if ($block->getFilterKeyPressCallback()) {
222-
$scriptString .= $block->escapeJs($block->getJsObjectName()) . '.filterKeyPressCallback = ' .
226+
$scriptString .= $escaper->escapeJs($block->getJsObjectName()) . '.filterKeyPressCallback = ' .
223227
/* @noEscape */ $block->getFilterKeyPressCallback() . ';' . PHP_EOL;
224228
}
225229

226-
$scriptString .= $block->escapeJs($block->getJsObjectName()) . '.bindSortable();' . PHP_EOL;
230+
$scriptString .= $escaper->escapeJs($block->getJsObjectName()) . '.bindSortable();' . PHP_EOL;
227231

228232
if ($block->getRowInitCallback()) {
229-
$scriptString .= $block->escapeJs($block->getJsObjectName()) . '.initRowCallback = ' .
233+
$scriptString .= $escaper->escapeJs($block->getJsObjectName()) . '.initRowCallback = ' .
230234
/* @noEscape */ $block->getRowInitCallback() . ';' . PHP_EOL;
231-
$scriptString .= $block->escapeJs($block->getJsObjectName()) . '..initGridRows();' . PHP_EOL;
235+
$scriptString .= $escaper->escapeJs($block->getJsObjectName()) . '..initGridRows();' . PHP_EOL;
232236
}
233237

234238
if ($block->getChildBlock('grid.massaction') &&
@@ -243,8 +247,8 @@ require(deps, function('. ($block->getDependencyJsObject() ? 'registry' : '') .'
243247
}
244248

245249
$scriptString .= '});' . PHP_EOL;
246-
247-
echo /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false);
250+
/* @noEscape */
251+
echo $secureRenderer->renderTag('script', [], $scriptString, false);
248252
?>
249253

250254
<?php endif; ?>

0 commit comments

Comments
 (0)