4
4
* All Rights Reserved.
5
5
*/
6
6
7
+ use Magento \Backend \Block \Widget \Grid ;
8
+ use Magento \Framework \Escaper ;
9
+ use Magento \Framework \View \Helper \SecureHtmlRenderer ;
10
+
7
11
?>
8
12
<?php
9
13
/**
16
20
* getVarNamePage()
17
21
*
18
22
*/
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 */
21
26
22
- $ numColumns = $ block ->getColumns () !== null ? count ($ block ->getColumns ()): 0 ;
27
+ $ numColumns = $ block ->getColumns () !== null ? count ($ block ->getColumns ()) : 0 ;
23
28
?>
24
29
<?php if ($ block ->getCollection ()): ?>
25
-
26
30
<?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 ()) ?> ">
28
32
<?php else : ?>
29
33
<?= $ block ->getLayout ()->getMessagesBlock ()->getGroupedHtml () ?>
30
34
<?php endif ; ?>
@@ -45,7 +49,7 @@ $numColumns = $block->getColumns() !== null ? count($block->getColumns()): 0;
45
49
<?php endif ; ?>
46
50
</div>
47
51
<?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">
49
53
<?php if ($ massActionAvailable ): ?>
50
54
<?= $ block ->getChildHtml ('grid.massaction ' ) ?>
51
55
<?php else : ?>
@@ -54,20 +58,19 @@ $numColumns = $block->getColumns() !== null ? count($block->getColumns()): 0;
54
58
<?php endif ; ?>
55
59
<?php $ countRecords = $ block ->getCollection ()->getSize (); ?>
56
60
<div class="admin__control-support-text">
57
- <span id="<?= $ block ->escapeHtml ($ block ->getHtmlId ()) ?> -total-count"
61
+ <span id="<?= $ escaper ->escapeHtml ($ block ->getHtmlId ()) ?> -total-count"
58
62
<?= /* @noEscape */ $ block ->getUiId ('total-count ' ) ?> >
59
63
<?= /* @noEscape */ $ countRecords ?>
60
64
</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"
63
67
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>
66
69
</div>
67
70
<?php if ($ block ->getPagerVisibility ()): ?>
68
71
<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"
71
74
onchange="<?= /* @noEscape */ $ block ->getJsObjectName () ?> .loadByElement(this)"
72
75
<?= /* @noEscape */ $ block ->getUiId ('per-page ' ) ?>
73
76
class="admin__control-select">
@@ -87,63 +90,63 @@ $numColumns = $block->getColumns() !== null ? count($block->getColumns()): 0;
87
90
selected="selected"<?php endif ; ?> >200
88
91
</option>
89
92
</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>
92
95
<div class="admin__data-grid-pager">
93
96
<?php $ _curPage = $ block ->getCollection ()->getCurPage () ?>
94
97
<?php $ _lastPage = $ block ->getCollection ()->getLastPageNumber () ?>
95
98
96
99
<?php if ($ _curPage > 1 ): ?>
97
100
<button class="action-previous" type="button">
98
- <span><?= $ block ->escapeHtml (__ ('Previous page ' )) ?> </span>
101
+ <span><?= $ escaper ->escapeHtml (__ ('Previous page ' )) ?> </span>
99
102
</button>
100
103
<?= /* @noEscape */ $ secureRenderer ->renderEventListenerAsTag (
101
104
'onclick ' ,
102
105
/* @noEscape */ $ block ->getJsObjectName () . '.setPage( \'' .
103
106
/* @noEscape */ ($ _curPage - 1 ) . '\');event.preventDefault(); ' ,
104
- 'div# ' . $ block ->escapeJs ($ block ->getId ()) .
107
+ 'div# ' . $ escaper ->escapeJs ($ block ->getId ()) .
105
108
' .admin__data-grid-pager button.action-previous:not(.disabled) '
106
109
) ?>
107
110
<?php else : ?>
108
111
<button type="button" class="action-previous disabled">
109
- <span><?= $ block ->escapeHtml (__ ('Previous page ' )) ?> </span>
112
+ <span><?= $ escaper ->escapeHtml (__ ('Previous page ' )) ?> </span>
110
113
</button>
111
114
<?php endif ; ?>
112
115
113
116
<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 ) ?> "
117
120
class="admin__control-text"
118
121
<?= /* @noEscape */ $ block ->getUiId ('current-page ' ) ?> />
119
122
120
123
<?= /* @noEscape */ $ secureRenderer ->renderEventListenerAsTag (
121
124
'onkeypress ' ,
122
125
/* @noEscape */ $ block ->getJsObjectName () . '.inputPage(event, \'' .
123
126
/* @noEscape */ $ _lastPage . '\') ' ,
124
- '# ' . $ block ->escapeHtml ($ block ->getHtmlId ()) . '_page-current '
127
+ '# ' . $ escaper ->escapeHtml ($ block ->getHtmlId ()) . '_page-current '
125
128
) ?>
126
129
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">
129
132
<?= /* @noEscape */ __ ('of %1 ' , '<span> ' .
130
133
$ block ->getCollection ()->getLastPageNumber () . '</span> ' ) ?>
131
134
</label>
132
135
<?php if ($ _curPage < $ _lastPage ): ?>
133
- <button type="button" title="<?= $ block ->escapeHtmlAttr (__ ('Next page ' )) ?> "
136
+ <button type="button" title="<?= $ escaper ->escapeHtmlAttr (__ ('Next page ' )) ?> "
134
137
class="action-next">
135
- <span><?= $ block ->escapeHtml (__ ('Next page ' )) ?> </span>
138
+ <span><?= $ escaper ->escapeHtml (__ ('Next page ' )) ?> </span>
136
139
</button>
137
140
<?= /* @noEscape */ $ secureRenderer ->renderEventListenerAsTag (
138
141
'onclick ' ,
139
142
/* @noEscape */ $ block ->getJsObjectName () . '.setPage( \'' .
140
143
/* @noEscape */ ($ _curPage + 1 ) . '\');event.preventDefault(); ' ,
141
- 'div# ' . $ block ->escapeJs ($ block ->getId ()) .
144
+ 'div# ' . $ escaper ->escapeJs ($ block ->getId ()) .
142
145
' .admin__data-grid-pager button.action-next:not(.disabled) '
143
146
) ?>
144
147
<?php else : ?>
145
148
<button type="button" class="action-next disabled">
146
- <span><?= $ block ->escapeHtml (__ ('Next page ' )) ?> </span>
149
+ <span><?= $ escaper ->escapeHtml (__ ('Next page ' )) ?> </span>
147
150
</button>
148
151
<?php endif ; ?>
149
152
</div>
@@ -153,14 +156,14 @@ $numColumns = $block->getColumns() !== null ? count($block->getColumns()): 0;
153
156
</div>
154
157
<div class="admin__data-grid-wrap admin__data-grid-wrap-static">
155
158
<?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">
158
161
<!-- Rendering column set -->
159
162
<?= $ block ->getChildHtml ('grid.columnSet ' ) ?>
160
163
</table>
161
164
<?php else : ?>
162
165
163
- <table class="data-grid" id="<?= $ block ->escapeHtml ($ block ->getId ()) ?> _table">
166
+ <table class="data-grid" id="<?= $ escaper ->escapeHtml ($ block ->getId ()) ?> _table">
164
167
<!-- Rendering column set -->
165
168
<?= $ block ->getChildHtml ('grid.columnSet ' ) ?>
166
169
</table>
@@ -191,44 +194,45 @@ $numColumns = $block->getColumns() !== null ? count($block->getColumns()): 0;
191
194
require(deps, function( ' . ($ block ->getDependencyJsObject () ? 'registry ' : '' ) .'){ ' . PHP_EOL ;
192
195
//TODO: getJsObjectName and getRowClickCallback has unexpected behavior. Should be removed
193
196
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 ;
196
199
}
197
200
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 ()) .'\');
203
207
' . 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 ;
206
210
if ($ block ->getRowClickCallback ()) {
207
- $ scriptString .= $ block ->escapeJs ($ block ->getJsObjectName ()) . '.rowClickCallback = ' .
211
+ $ scriptString .= $ escaper ->escapeJs ($ block ->getJsObjectName ()) . '.rowClickCallback = ' .
208
212
/* @noEscape */ $ block ->getRowClickCallback () . '; ' . PHP_EOL ;
209
213
}
210
214
211
215
if ($ block ->getCheckboxCheckCallback ()) {
212
- $ scriptString .= $ block ->escapeJs ($ block ->getJsObjectName ()) . '.checkboxCheckCallback = ' .
216
+ $ scriptString .= $ escaper ->escapeJs ($ block ->getJsObjectName ()) . '.checkboxCheckCallback = ' .
213
217
/* @noEscape */ $ block ->getCheckboxCheckCallback () . '; ' . PHP_EOL ;
214
218
}
215
219
216
220
if ($ block ->getSortableUpdateCallback ()) {
217
- $ scriptString .= $ block ->escapeJs ($ block ->getJsObjectName ()) . '.sortableUpdateCallback = ' .
221
+ $ scriptString .= $ escaper ->escapeJs ($ block ->getJsObjectName ()) . '.sortableUpdateCallback = ' .
218
222
/* @noEscape */ $ block ->getSortableUpdateCallback () . '; ' . PHP_EOL ;
219
223
}
220
224
221
225
if ($ block ->getFilterKeyPressCallback ()) {
222
- $ scriptString .= $ block ->escapeJs ($ block ->getJsObjectName ()) . '.filterKeyPressCallback = ' .
226
+ $ scriptString .= $ escaper ->escapeJs ($ block ->getJsObjectName ()) . '.filterKeyPressCallback = ' .
223
227
/* @noEscape */ $ block ->getFilterKeyPressCallback () . '; ' . PHP_EOL ;
224
228
}
225
229
226
- $ scriptString .= $ block ->escapeJs ($ block ->getJsObjectName ()) . '.bindSortable(); ' . PHP_EOL ;
230
+ $ scriptString .= $ escaper ->escapeJs ($ block ->getJsObjectName ()) . '.bindSortable(); ' . PHP_EOL ;
227
231
228
232
if ($ block ->getRowInitCallback ()) {
229
- $ scriptString .= $ block ->escapeJs ($ block ->getJsObjectName ()) . '.initRowCallback = ' .
233
+ $ scriptString .= $ escaper ->escapeJs ($ block ->getJsObjectName ()) . '.initRowCallback = ' .
230
234
/* @noEscape */ $ block ->getRowInitCallback () . '; ' . PHP_EOL ;
231
- $ scriptString .= $ block ->escapeJs ($ block ->getJsObjectName ()) . '..initGridRows(); ' . PHP_EOL ;
235
+ $ scriptString .= $ escaper ->escapeJs ($ block ->getJsObjectName ()) . '..initGridRows(); ' . PHP_EOL ;
232
236
}
233
237
234
238
if ($ block ->getChildBlock ('grid.massaction ' ) &&
@@ -243,8 +247,8 @@ require(deps, function('. ($block->getDependencyJsObject() ? 'registry' : '') .'
243
247
}
244
248
245
249
$ scriptString .= '}); ' . PHP_EOL ;
246
-
247
- echo /* @noEscape */ $ secureRenderer ->renderTag ('script ' , [], $ scriptString , false );
250
+ /* @noEscape */
251
+ echo $ secureRenderer ->renderTag ('script ' , [], $ scriptString , false );
248
252
?>
249
253
250
254
<?php endif ; ?>
0 commit comments