Skip to content

Commit bc08919

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-99528' into borg-2.2
2 parents 365e6ac + 4498205 commit bc08919

File tree

17 files changed

+170
-182
lines changed

17 files changed

+170
-182
lines changed

app/code/Magento/CatalogSearch/Model/ResourceModel/Search/Collection.php

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

7-
// @codingStandardsIgnoreFile
8-
97
namespace Magento\CatalogSearch\Model\ResourceModel\Search;
108

9+
use Magento\Search\Model\SearchCollectionInterface;
10+
1111
/**
1212
* Search collection
1313
*
1414
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1515
* @api
1616
* @since 100.0.2
1717
*/
18-
class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection implements \Magento\Search\Model\SearchCollectionInterface
18+
class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection implements SearchCollectionInterface
1919
{
2020
/**
2121
* Attribute collection
@@ -123,7 +123,8 @@ public function addSearchFilter($query)
123123
$this->_searchQuery = $query;
124124
$this->addFieldToFilter(
125125
$this->getEntity()->getLinkField(),
126-
['in' => new \Zend_Db_Expr($this->_getSearchEntityIdsSql($query))]);
126+
['in' => new \Zend_Db_Expr($this->_getSearchEntityIdsSql($query))]
127+
);
127128
return $this;
128129
}
129130

app/code/Magento/CatalogSearch/view/frontend/templates/advanced/form.phtml

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

7-
// @codingStandardsIgnoreFile
8-
7+
// phpcs:disable Magento2.Templates.ThisInTemplate
98
?>
109
<?php
1110
/**
@@ -14,108 +13,119 @@
1413
* @var $block \Magento\CatalogSearch\Block\Advanced\Form
1514
*/
1615
?>
17-
<?php $maxQueryLength = $this->helper('Magento\CatalogSearch\Helper\Data')->getMaxQueryLength();?>
18-
<form class="form search advanced" action="<?= /* @escapeNotVerified */ $block->getSearchPostUrl() ?>" method="get" id="form-validate">
16+
<?php $maxQueryLength = (int)$this->helper(\Magento\CatalogSearch\Helper\Data::class)->getMaxQueryLength();?>
17+
<form class="form search advanced" action="<?= $block->escapeUrl($block->getSearchPostUrl()) ?>" method="get" id="form-validate">
1918
<fieldset class="fieldset">
20-
<legend class="legend"><span><?= /* @escapeNotVerified */ __('Search Settings') ?></span></legend><br />
21-
<?php foreach ($block->getSearchableAttributes() as $_attribute): ?>
19+
<legend class="legend"><span><?= $block->escapeHtml(__('Search Settings')) ?></span></legend><br />
20+
<?php foreach ($block->getSearchableAttributes() as $_attribute) : ?>
2221
<?php $_code = $_attribute->getAttributeCode() ?>
23-
<div class="field <?= /* @escapeNotVerified */ $_code ?>">
24-
<label class="label" for="<?= /* @escapeNotVerified */ $_code ?>">
22+
<div class="field <?= $block->escapeHtmlAttr($_code) ?>">
23+
<label class="label" for="<?= $block->escapeHtmlAttr($_code) ?>">
2524
<span><?= $block->escapeHtml(__($block->getAttributeLabel($_attribute))) ?></span>
2625
</label>
2726
<div class="control">
28-
<?php switch ($block->getAttributeInputType($_attribute)):
29-
case 'number': ?>
27+
<?php switch ($block->getAttributeInputType($_attribute)) :
28+
case 'number':
29+
?>
3030
<div class="range fields group group-2">
3131
<div class="field no-label">
3232
<div class="control">
3333
<input type="text"
34-
name="<?= /* @escapeNotVerified */ $_code ?>[from]"
34+
name="<?= $block->escapeHtmlAttr($_code) ?>[from]"
3535
value="<?= $block->escapeHtml($block->getAttributeValue($_attribute, 'from')) ?>"
36-
id="<?= /* @escapeNotVerified */ $_code ?>"
36+
id="<?= $block->escapeHtmlAttr($_code) ?>"
3737
title="<?= $block->escapeHtml($block->getAttributeLabel($_attribute)) ?>"
3838
class="input-text"
39-
maxlength="<?= /* @escapeNotVerified */ $maxQueryLength ?>"
40-
data-validate="{number:true, 'less-than-equals-to':'#<?= /* @escapeNotVerified */ $_code ?>_to'}" />
39+
maxlength="<?= /* @noEscape */ $maxQueryLength ?>"
40+
data-validate="{number:true, 'less-than-equals-to':'#<?= $block->escapeHtmlAttr($_code) ?>_to'}" />
4141
</div>
4242
</div>
4343
<div class="field no-label">
4444
<div class="control">
4545
<input type="text"
46-
name="<?= /* @escapeNotVerified */ $_code ?>[to]"
46+
name="<?= $block->escapeHtmlAttr($_code) ?>[to]"
4747
value="<?= $block->escapeHtml($block->getAttributeValue($_attribute, 'to')) ?>"
48-
id="<?= /* @escapeNotVerified */ $_code ?>_to"
48+
id="<?= $block->escapeHtmlAttr($_code) ?>_to"
4949
title="<?= $block->escapeHtml($block->getAttributeLabel($_attribute)) ?>"
5050
class="input-text"
51-
maxlength="<?= /* @escapeNotVerified */ $maxQueryLength ?>"
52-
data-validate="{number:true, 'greater-than-equals-to':'#<?= /* @escapeNotVerified */ $_code ?>'}" />
51+
maxlength="<?= /* @noEscape */ $maxQueryLength ?>"
52+
data-validate="{number:true, 'greater-than-equals-to':'#<?= $block->escapeHtmlAttr($_code) ?>'}" />
5353
</div>
5454
</div>
5555
</div>
56-
<?php break;
57-
case 'price': ?>
56+
<?php
57+
break;
58+
case 'price':
59+
?>
5860
<div class="range price fields group group-2">
5961
<div class="field no-label">
6062
<div class="control">
61-
<input name="<?= /* @escapeNotVerified */ $_code ?>[from]"
63+
<input name="<?= $block->escapeHtmlAttr($_code) ?>[from]"
6264
value="<?= $block->escapeHtml($block->getAttributeValue($_attribute, 'from')) ?>"
63-
id="<?= /* @escapeNotVerified */ $_code ?>"
65+
id="<?= $block->escapeHtmlAttr($_code) ?>"
6466
title="<?= $block->escapeHtml($block->getAttributeLabel($_attribute)) ?>"
6567
class="input-text"
6668
type="text"
67-
maxlength="<?= /* @escapeNotVerified */ $maxQueryLength ?>"
68-
data-validate="{number:true, 'less-than-equals-to':'#<?= /* @escapeNotVerified */ $_code ?>_to'}" />
69+
maxlength="<?= /* @noEscape */ $maxQueryLength ?>"
70+
data-validate="{number:true, 'less-than-equals-to':'#<?= $block->escapeHtmlAttr($_code) ?>_to'}" />
6971
</div>
7072
</div>
7173
<div class="field with-addon no-label">
7274
<div class="control">
7375
<div class="addon">
74-
<input name="<?= /* @escapeNotVerified */ $_code ?>[to]"
76+
<input name="<?= $block->escapeHtmlAttr($_code) ?>[to]"
7577
value="<?= $block->escapeHtml($block->getAttributeValue($_attribute, 'to')) ?>"
76-
id="<?= /* @escapeNotVerified */ $_code ?>_to"
78+
id="<?= $block->escapeHtmlAttr($_code) ?>_to"
7779
title="<?= $block->escapeHtml($block->getAttributeLabel($_attribute)) ?>"
7880
class="input-text"
7981
type="text"
80-
maxlength="<?= /* @escapeNotVerified */ $maxQueryLength ?>"
81-
data-validate="{number:true, 'greater-than-equals-to':'#<?= /* @escapeNotVerified */ $_code ?>'}" />
82+
maxlength="<?= /* @noEscape */ $maxQueryLength ?>"
83+
data-validate="{number:true, 'greater-than-equals-to':'#<?= $block->escapeHtmlAttr($_code) ?>'}" />
8284
<label class="addafter"
83-
for="<?= /* @escapeNotVerified */ $_code ?>_to">
84-
<?= /* @escapeNotVerified */ $block->getCurrency($_attribute) ?>
85+
for="<?= $block->escapeHtmlAttr($_code) ?>_to">
86+
<?= $block->escapeHtml($block->getCurrency($_attribute)) ?>
8587
</label>
8688
</div>
8789
</div>
8890
</div>
8991
</div>
90-
<?php break;
91-
case 'select': ?>
92-
<?= /* @escapeNotVerified */ $block->getAttributeSelectElement($_attribute) ?>
93-
<?php break;
94-
case 'yesno': ?>
95-
<?= /* @escapeNotVerified */ $block->getAttributeYesNoElement($_attribute) ?>
96-
<?php break;
97-
case 'date': ?>
92+
<?php
93+
break;
94+
case 'select':
95+
?>
96+
<?= /* @noEscape */ $block->getAttributeSelectElement($_attribute) ?>
97+
<?php
98+
break;
99+
case 'yesno':
100+
?>
101+
<?= /* @noEscape */ $block->getAttributeYesNoElement($_attribute) ?>
102+
<?php
103+
break;
104+
case 'date':
105+
?>
98106
<div class="range dates fields group group-2">
99107
<div class="field date no-label">
100108
<div class="control">
101-
<?= /* @escapeNotVerified */ $block->getDateInput($_attribute, 'from') ?>
109+
<?= /* @noEscape */ $block->getDateInput($_attribute, 'from') ?>
102110
</div>
103111
</div>
104112
<div class="field date no-label">
105113
<div class="control">
106-
<?= /* @escapeNotVerified */ $block->getDateInput($_attribute, 'to') ?>
114+
<?= /* @noEscape */ $block->getDateInput($_attribute, 'to') ?>
107115
</div>
108116
</div>
109117
</div>
110-
<?php break;
111-
default: ?>
118+
<?php
119+
break;
120+
default:
121+
?>
112122
<input type="text"
113-
name="<?= /* @escapeNotVerified */ $_code ?>"
114-
id="<?= /* @escapeNotVerified */ $_code ?>"
123+
name="<?= $block->escapeHtmlAttr($_code) ?>"
124+
id="<?= $block->escapeHtmlAttr($_code) ?>"
115125
value="<?= $block->escapeHtml($block->getAttributeValue($_attribute)) ?>"
116126
title="<?= $block->escapeHtml($block->getAttributeLabel($_attribute)) ?>"
117-
class="input-text <?= /* @escapeNotVerified */ $block->getAttributeValidationClass($_attribute) ?>"
118-
maxlength="<?= /* @escapeNotVerified */ $maxQueryLength ?>" />
127+
class="input-text <?= $block->escapeHtmlAttr($block->getAttributeValidationClass($_attribute)) ?>"
128+
maxlength="<?= /* @noEscape */ $maxQueryLength ?>" />
119129
<?php endswitch; ?>
120130
</div>
121131
</div>
@@ -126,7 +136,7 @@
126136
<button type="submit"
127137
class="action search primary"
128138
title="<?= $block->escapeHtml(__('Search')) ?>">
129-
<span><?= /* @escapeNotVerified */ __('Search') ?></span>
139+
<span><?= $block->escapeHtml(__('Search')) ?></span>
130140
</button>
131141
</div>
132142
</div>
@@ -147,8 +157,8 @@ require([
147157
}
148158
},
149159
messages: {
150-
'price[to]': {'greater-than-equals-to': '<?= /* @escapeNotVerified */ __('Please enter a valid price range.') ?>'},
151-
'price[from]': {'less-than-equals-to': '<?= /* @escapeNotVerified */ __('Please enter a valid price range.') ?>'}
160+
'price[to]': {'greater-than-equals-to': '<?= $block->escapeJs(__('Please enter a valid price range.')) ?>'},
161+
'price[from]': {'less-than-equals-to': '<?= $block->escapeJs(__('Please enter a valid price range.')) ?>'}
152162
}
153163
});
154164
});

app/code/Magento/CatalogSearch/view/frontend/templates/advanced/link.phtml

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

7-
// @codingStandardsIgnoreFile
7+
// phpcs:disable Magento2.Templates.ThisInTemplate
88

99
/** @var \Magento\CatalogSearch\Helper\Data $helper */
10-
$helper = $this->helper('Magento\CatalogSearch\Helper\Data');
10+
$helper = $this->helper(\Magento\CatalogSearch\Helper\Data::class);
1111
?>
1212
<div class="nested">
13-
<a class="action advanced" href="<?= /* @escapeNotVerified */ $helper->getAdvancedSearchUrl() ?>" data-action="advanced-search">
14-
<?= /* @escapeNotVerified */ __('Advanced Search') ?>
13+
<a class="action advanced" href="<?= $block->escapeUrl($helper->getAdvancedSearchUrl()) ?>" data-action="advanced-search">
14+
<?= $block->escapeHtml(__('Advanced Search')) ?>
1515
</a>
1616
</div>

app/code/Magento/CatalogSearch/view/frontend/templates/advanced/result.phtml

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,49 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
7-
// @codingStandardsIgnoreFile
8-
96
?>
107
<?php
118
/**
129
* @var $block \Magento\CatalogSearch\Block\Advanced\Result
1310
*/
1411
?>
15-
<?php if ($results = $block->getResultCount()): ?>
12+
<?php if ($results = $block->getResultCount()) : ?>
1613
<div class="search found">
1714
<?php if ($results == 1) : ?>
18-
<?= /* @escapeNotVerified */ __('<strong>%1 item</strong> were found using the following search criteria', $results) ?>
19-
<?php else: ?>
20-
<?= /* @escapeNotVerified */ __('<strong>%1 items</strong> were found using the following search criteria', $results) ?>
15+
<?= /* @noEscape */ __('<strong>%1 item</strong> were found using the following search criteria', $results) ?>
16+
<?php else : ?>
17+
<?= /* @noEscape */ __('<strong>%1 items</strong> were found using the following search criteria', $results) ?>
2118
<?php endif; ?>
2219
</div>
23-
<?php else: ?>
20+
<?php else : ?>
2421
<div role="alert" class="message error">
2522
<div>
26-
<?= /* @escapeNotVerified */ __('We can\'t find any items matching these search criteria.') ?> <a href="<?= /* @escapeNotVerified */ $block->getFormUrl() ?>"><?= /* @escapeNotVerified */ __('Modify your search.') ?></a>
23+
<?= $block->escapeHtml(__('We can\'t find any items matching these search criteria.')) ?> <a href="<?= $block->escapeUrl($block->getFormUrl()) ?>"><?= $block->escapeHtml(__('Modify your search.')) ?></a>
2724
</div>
2825
</div>
2926
<?php endif; ?>
3027

3128
<?php $searchCriterias = $block->getSearchCriterias(); ?>
3229
<div class="search summary">
33-
<?php foreach (['left', 'right'] as $side): ?>
34-
<?php if (@$searchCriterias[$side]): ?>
30+
<?php foreach (['left', 'right'] as $side) : ?>
31+
<?php if (!empty($searchCriterias[$side])) : ?>
3532
<ul class="items">
36-
<?php foreach ($searchCriterias[$side] as $criteria): ?>
33+
<?php foreach ($searchCriterias[$side] as $criteria) : ?>
3734
<li class="item"><strong><?= $block->escapeHtml(__($criteria['name'])) ?>:</strong> <?= $block->escapeHtml($criteria['value']) ?></li>
3835
<?php endforeach; ?>
3936
</ul>
4037
<?php endif; ?>
4138
<?php endforeach; ?>
4239
</div>
43-
<?php if ($block->getResultCount()): ?>
40+
<?php if ($block->getResultCount()) : ?>
4441
<div class="message notice">
4542
<div>
46-
<?= /* @escapeNotVerified */ __("Don't see what you're looking for?") ?>
47-
<a href="<?= /* @escapeNotVerified */ $block->getFormUrl() ?>"><?= /* @escapeNotVerified */ __('Modify your search.') ?></a>
43+
<?= $block->escapeHtml(__("Don't see what you're looking for?")) ?>
44+
<a href="<?= $block->escapeUrl($block->getFormUrl()) ?>"><?= $block->escapeHtml(__('Modify your search.')) ?></a>
4845
</div>
4946
</div>
5047
<?php endif; ?>
51-
<?php if ($block->getResultCount()): ?>
52-
<div class="search results"><?= $block->getProductListHtml() ?></div>
48+
<?php if ($block->getResultCount()) : ?>
49+
<div class="search results"><?= /* @noEscape */ $block->getProductListHtml() ?></div>
5350
<?php endif; ?>
5451
<?php $block->getSearchCriterias(); ?>

app/code/Magento/CatalogSearch/view/frontend/templates/result.phtml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,29 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
7-
// @codingStandardsIgnoreFile
8-
96
?>
10-
<?php if ($block->getResultCount()): ?>
7+
<?php if ($block->getResultCount()) : ?>
118
<?= $block->getChildHtml('tagged_product_list_rss_link') ?>
129
<div class="search results">
13-
<?php if ($messages = $block->getNoteMessages()):?>
10+
<?php if ($messages = $block->getNoteMessages()) : ?>
1411
<div class="message notice">
1512
<div>
16-
<?php foreach ($messages as $message):?>
17-
<?= /* @escapeNotVerified */ $message ?><br />
13+
<?php foreach ($messages as $message) : ?>
14+
<?= /* @noEscape */ $message ?><br />
1815
<?php endforeach;?>
1916
</div>
2017
</div>
2118
<?php endif; ?>
22-
<?= $block->getProductListHtml() ?>
19+
<?= /* @noEscape */ $block->getProductListHtml() ?>
2320
</div>
24-
<?php else: ?>
25-
21+
<?php else : ?>
2622
<div class="message notice">
2723
<div>
28-
<?= /* @escapeNotVerified */ ($block->getNoResultText()) ? $block->getNoResultText() : __('Your search returned no results.') ?>
29-
<?= $block->getAdditionalHtml() ?>
30-
<?php if ($messages = $block->getNoteMessages()):?>
31-
<?php foreach ($messages as $message):?>
32-
<br /><?= /* @escapeNotVerified */ $message ?>
24+
<?= $block->escapeHtml($block->getNoResultText() ? $block->getNoResultText() : __('Your search returned no results.')) ?>
25+
<?= /* @noEscape */ $block->getAdditionalHtml() ?>
26+
<?php if ($messages = $block->getNoteMessages()) : ?>
27+
<?php foreach ($messages as $message) : ?>
28+
<br /><?= /* @noEscape */ $message ?>
3329
<?php endforeach;?>
3430
<?php endif; ?>
3531
</div>

app/code/Magento/CatalogSearch/view/frontend/templates/search_terms_log.phtml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
// @codingStandardsIgnoreFile
76
?>
8-
<?php if ($block->getSearchTermsLog()->isPageCacheable()): ?>
7+
<?php if ($block->getSearchTermsLog()->isPageCacheable()) : ?>
98
<script type="text/x-magento-init">
109
{
1110
"*": {
1211
"Magento_CatalogSearch/js/search-terms-log": {
13-
"url": "<?= /* @escapeNotVerified */ $block->getUrl('catalogsearch/searchTermsLog/save') ?>"
12+
"url": "<?= $block->escapeUrl($block->getUrl('catalogsearch/searchTermsLog/save')) ?>"
1413
}
1514
}
1615
}

0 commit comments

Comments
 (0)