Skip to content

Commit c690b13

Browse files
committed
MAGE-1379 Clean up formatting and remove deprecated calls
1 parent 0fed043 commit c690b13

File tree

26 files changed

+222
-220
lines changed

26 files changed

+222
-220
lines changed

view/adminhtml/templates/analytics/form.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ $form = $block->getViewModel();
1111
<input type="hidden" name="form_key" value="<?= $escaper->escapeHtmlAttr($block->getFormKey()) ?>" />
1212
<div class="inline-field">
1313
<select name="type" class="select admin__control-select"<?= /** phpcs:ignore Magento2.Security.XssTemplate.FoundUnescaped **/ $isFormDisabled ?>>
14-
<?php foreach ($form->getSections() as $key => $section) : ?>
14+
<?php foreach ($form->getSections() as $key => $section): ?>
1515
<option value="<?= $escaper->escapeHtmlAttr($key) ?>"<?= ($key == $form->getFormValue('type')) ? ' selected' : '' ?>>
1616
<?= $escaper->escapeHtml(ucwords($key)) ?>
1717
</option>

view/adminhtml/templates/analytics/graph.phtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/** @var \Magento\Backend\Block\Template $block */
33
/** @var \Magento\Framework\Escaper $escaper */
44
?>
5-
<?php if (!empty($block->getAnalytics())) : ?>
5+
<?php if (!empty($block->getAnalytics())): ?>
66
<div id="algolia-analyatics-diagram"></div>
77
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
88
<script type="text/javascript">
@@ -12,13 +12,13 @@
1212

1313
var data = new google.visualization.arrayToDataTable([
1414
['Date', 'Searches', {type: 'string', role: 'tooltip', p: {'html': true}}, {role: 'style'}],
15-
<?php foreach ($block->getAnalytics() as $item) : ?>
15+
<?php foreach ($block->getAnalytics() as $item): ?>
1616
['<?= $escaper->escapeHtml($item['formatted']) ?>', <?= $escaper->escapeHtml($item['count']) ?>,
1717
"<div style='padding: 1.5rem; line-height: 18px;'><strong style='font-size: 14px;'><?= $escaper->escapeHtml($item['formatted']) ?></strong><br/><br/>" +
1818
"<p>Searches: <strong style='color: #5468ff; padding-left: 3px;'><?= $escaper->escapeHtml($item['count']) ?></strong></p>" +
1919
"<p>Users: <strong style='color: #3a46a1; padding-left: 3px;'><?= $escaper->escapeHtml($item['users']) ?></strong></p>" +
2020
"<p>No Result Rate: <strong style='color: #3ab2bd; padding-left: 3px;'><?= $escaper->escapeHtml(round((int) $item['rate'] * 100, 2) . '%') ?></strong></p>" +
21-
<?php if (isset($item['ctr'])) : ?>
21+
<?php if (isset($item['ctr'])): ?>
2222
"<br/>" +
2323
"<p>CTR: <strong style='color: #5468ff; padding-left: 3px;'><?= $escaper->escapeHtml(round((int) $item['ctr'] * 100, 2) . '%') ?></strong></p>" +
2424
"<p>Conversion Rate: <strong style='color: #3a46a1; padding-left: 3px;'><?= $escaper->escapeHtml(round((int) $item['conversion'] * 100, 2) . '%') ?></strong></p>" +
@@ -58,7 +58,7 @@
5858
chart.draw(data, options);
5959
}
6060
</script>
61-
<?php else : ?>
61+
<?php else: ?>
6262
<div class="dashboard-diagram-nodata">
6363
<span><?= $escaper->escapeHtml(__('No Data Found')) ?></span>
6464
</div>

view/adminhtml/templates/analytics/overview.phtml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ $view = $block->getViewModel();
3434
<div class="stat"><?= $escaper->escapeHtml($view->getTotalResultRates()) ?></div>
3535
</div>
3636
</div>
37-
<?php if ($view->isClickAnalyticsEnabled()) : ?>
37+
<?php if ($view->isClickAnalyticsEnabled()): ?>
3838
<div class="row thirds top-thirds">
3939
<div class="one-third col-1">
4040
<div class="title">
@@ -109,7 +109,7 @@ $view = $block->getViewModel();
109109
</h3>
110110
</div>
111111
<div class="analytics-content">
112-
<?php if (count($view->getTopSearches())) : ?>
112+
<?php if (count($view->getTopSearches())): ?>
113113
<table class="data-table admin__table-primary">
114114
<thead>
115115
<tr class="headings">
@@ -118,15 +118,15 @@ $view = $block->getViewModel();
118118
</tr>
119119
</thead>
120120
<tbody>
121-
<?php foreach ($view->getTopSearches() as $search) : ?>
121+
<?php foreach ($view->getTopSearches() as $search): ?>
122122
<tr>
123123
<td><?= $search['search'] ?: '<i class="empty_search">' . $escaper->escapeHtml(__('empty search')) . '</i>'; ?></td>
124124
<td><?= $escaper->escapeHtml($search['count']) ?></td>
125125
</tr>
126126
<?php endforeach ?>
127127
</tbody>
128128
</table>
129-
<?php else : ?>
129+
<?php else: ?>
130130
<p class="no-data"><?= $escaper->escapeHtml(__('No searches yet!')); ?></p>
131131
<?php endif ?>
132132
</div>
@@ -141,7 +141,7 @@ $view = $block->getViewModel();
141141
</h3>
142142
</div>
143143
<div class="analytics-content">
144-
<?php if (count($view->getPopularResults())) : ?>
144+
<?php if (count($view->getPopularResults())): ?>
145145
<table class="data-table admin__table-primary">
146146
<thead>
147147
<tr class="headings">
@@ -150,11 +150,11 @@ $view = $block->getViewModel();
150150
</tr>
151151
</thead>
152152
<tbody>
153-
<?php foreach ($view->getPopularResults() as $search) : ?>
153+
<?php foreach ($view->getPopularResults() as $search): ?>
154154
<tr>
155155
<td>
156156
<?php $link = $view->getTypeEditUrl($search); ?>
157-
<?php foreach ($link as $type => $url) : ?>
157+
<?php foreach ($link as $type => $url): ?>
158158
<a href="<?= $escaper->escapeUrl($url) ?>"<?= ($type == 'view' ? ' target="_blank"' : '') ?>>
159159
<?= $escaper->escapeHtml(ucfirst($type)); ?>
160160
</a> |
@@ -166,7 +166,7 @@ $view = $block->getViewModel();
166166
<?php endforeach ?>
167167
</tbody>
168168
</table>
169-
<?php else : ?>
169+
<?php else: ?>
170170
<p class="no-data"><?= $escaper->escapeHtml(__('No results yet!')); ?></p>
171171
<?php endif ?>
172172
</div>
@@ -181,7 +181,7 @@ $view = $block->getViewModel();
181181
</h3>
182182
</div>
183183
<div class="analytics-content">
184-
<?php if (count($view->getNoResultSearches())) : ?>
184+
<?php if (count($view->getNoResultSearches())): ?>
185185
<table class="data-table admin__table-primary">
186186
<thead>
187187
<tr class="headings">
@@ -190,15 +190,15 @@ $view = $block->getViewModel();
190190
</tr>
191191
</thead>
192192
<tbody>
193-
<?php foreach ($view->getNoResultSearches() as $search) : ?>
193+
<?php foreach ($view->getNoResultSearches() as $search): ?>
194194
<tr>
195195
<td><?= $search['search'] ?: '<i class="empty_search">' . $escaper->escapeHtml(__('empty search')) . '</i>'; ?></td>
196196
<td class="a-right"><?= $escaper->escapeHtml($search['count']) ?></td>
197197
</tr>
198198
<?php endforeach ?>
199199
</tbody>
200200
</table>
201-
<?php else : ?>
201+
<?php else: ?>
202202
<p class="no-data"><?= $escaper->escapeHtml(__('No results yet!')); ?></p>
203203
<?php endif ?>
204204
</div>
@@ -209,7 +209,7 @@ $view = $block->getViewModel();
209209
</div>
210210
</div>
211211

212-
<?php if (!$view->isClickAnalyticsEnabled()) : ?>
212+
<?php if (!$view->isClickAnalyticsEnabled()): ?>
213213
<div class="algolia_block blue icon-stars">
214214
Enhance your Analytics with <b>Algolia Click Analytics</b> that provide you even more insights
215215
like Click-through Rate, Conversion Rate from searches and average click position.

view/adminhtml/templates/catalog/category/edit/merchandising.phtml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,34 @@ $configHelper = $block->getConfigHelper();
1616
Find out more about Algolia Merchandising, please refer to <a href="https://www.algolia.com/doc/integration/magento-2/merchandising/category-merchandising/?utm_source=magento&utm_medium=extension&utm_campaign=magento_2&utm_term=shop-owner&utm_content=doc-link" target="_blank">documentation</a>.
1717
</div>
1818

19-
<?php if ($block->isRootCategory()) : ?>
19+
<?php if ($block->isRootCategory()): ?>
2020

2121
<br>
2222
<div class="algolia_block icon-bulb">
2323
The root category is not displayed on Magento's frontend and therefore it's not indexed within Algolia records.
2424
To merchandise products, please select any sub-category.
2525
</div>
2626

27-
<?php return; endif; ?>
27+
<?php return;
28+
endif; ?>
2829

29-
<?php if (!$configHelper->isInstantEnabled() || !$configHelper->replaceCategories()) :
30+
<?php if (!$configHelper->isInstantEnabled() || !$configHelper->replaceCategories()):
3031
$instantSearchLink = $block->getUrl('adminhtml/system_config/edit/section/algoliasearch_instant');
3132
?>
3233

3334
<div class="algolia_block icon-stars">
3435
To merchandise products using Algolia
3536
you need to enable <strong>Instant search</strong> with <strong>Replace category pages</strong> feature.
36-
You can do it in Algolia's <a href="<?= $block->escapeUrl($instantSearchLink) ?>" target="_blank">Instant Search configuration</a>.
37+
You can do it in Algolia's <a href="<?= $escaper->escapeUrl($instantSearchLink) ?>" target="_blank">Instant Search configuration</a>.
3738
<br><br>
3839
<strong>Instant search</strong> with enabled <strong>Replace category pages</strong> feature gives your customers a great experience
3940
while browsing your catalog. It enables your customers to search and filter for products at real time resulting
4041
in better customer journey. With the speed and relevancy of Algolia your customers are more likely to purchase
4142
and enjoy the shopping on your store(s).
4243
</div>
4344

44-
<?php return; endif; ?>
45+
<?php return;
46+
endif; ?>
4547

4648
<div class="algolia_block display-product-msg icon-warning" <?= !$block->canDisplayProducts() ?: 'style="display:none;"' ?>>
4749
<p><strong>Products are not displayed for this category</strong></p>

view/adminhtml/templates/configuration.phtml

Lines changed: 101 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -30,108 +30,108 @@ var personalizationStatus = <?= /** phpcs:ignore Magento2.Security.EscapeOutput.
3030
var extensionNotices = <?= /** phpcs:ignore Magento2.Security.EscapeOutput.OutputNotEscaped */json_encode($extensionNotices); ?>;
3131

3232
document.addEventListener("DOMContentLoaded", function(event) {
33-
requirejs(['algoliaAdminBundle'], function(algoliaAdminBundle) {
34-
algoliaAdminBundle.$(function ($) {
35-
36-
var fixHelper = function(e, ui) {
37-
ui.children().each(function() {
38-
$(this).width($(this).width());
39-
});
40-
41-
return ui;
42-
};
43-
44-
setTimeout(function () {
45-
$('form[action*="algoliasearch"] .admin__control-table tbody').sortable({
46-
containment: "parent",
47-
items: 'tr',
48-
tolerance: 'pointer',
49-
helper: fixHelper,
50-
start: function (event, ui) {
51-
$(ui.item).css('margin-left', '10px');
52-
}
53-
});
54-
55-
$('form[action*="algoliasearch"] .admin__control-table tbody tr td').css('cursor', 'move');
56-
}, 1000);
57-
58-
59-
var url = window.location.href;
60-
if (url.indexOf('section/algoliasearch_') !== -1) {
61-
62-
// Hide click analytics config if not available
63-
if (isClickAnalyticsEnabled === false) {
64-
$('#algoliasearch_cc_analytics_cc_analytics_group table').hide();
65-
}
66-
67-
// Hide personalization config if not available
68-
if (personalizationStatus < 2) {
69-
$('#algoliasearch_personalization_personalization_group table').parent().parent().hide();
70-
}
71-
72-
// Adding links and videos to the config panel
33+
requirejs(['algoliaAdminBundle'], function(algoliaAdminBundle) {
34+
algoliaAdminBundle.$(function ($) {
35+
36+
var fixHelper = function(e, ui) {
37+
ui.children().each(function() {
38+
$(this).width($(this).width());
39+
});
40+
41+
return ui;
42+
};
43+
44+
setTimeout(function () {
45+
$('form[action*="algoliasearch"] .admin__control-table tbody').sortable({
46+
containment: "parent",
47+
items: 'tr',
48+
tolerance: 'pointer',
49+
helper: fixHelper,
50+
start: function (event, ui) {
51+
$(ui.item).css('margin-left', '10px');
52+
}
53+
});
54+
55+
$('form[action*="algoliasearch"] .admin__control-table tbody tr td').css('cursor', 'move');
56+
}, 1000);
57+
58+
59+
var url = window.location.href;
60+
if (url.indexOf('section/algoliasearch_') !== -1) {
61+
62+
// Hide click analytics config if not available
63+
if (isClickAnalyticsEnabled === false) {
64+
$('#algoliasearch_cc_analytics_cc_analytics_group table').hide();
65+
}
66+
67+
// Hide personalization config if not available
68+
if (personalizationStatus < 2) {
69+
$('#algoliasearch_personalization_personalization_group table').parent().parent().hide();
70+
}
71+
72+
// Adding links and videos to the config panel
7373
$('.algolia-admin-content').html(linksAndVideoTemplate);
7474

75-
// New notice management
76-
extensionNotices.each(function(notice){
77-
if (notice.method === 'before') {
78-
$(notice.selector).before(notice.message);
79-
} else if (notice.method === 'append') {
80-
$(notice.selector).append(notice.message);
81-
} else if (notice.method === 'after') {
82-
$(notice.selector).after(notice.message);
83-
}
84-
});
85-
}
86-
87-
// SYNONYMS
88-
89-
handleSynonyms($('#algoliasearch_synonyms_synonyms_group_enable_synonyms').val());
90-
91-
$(document).on('change', '#algoliasearch_synonyms_synonyms_group_enable_synonyms', function() {
92-
handleSynonyms($(this).val());
93-
});
94-
95-
function handleSynonyms(enabled) {
96-
var $rows = $('#row_algoliasearch_synonyms_synonyms_group_synonyms, #row_algoliasearch_synonyms_synonyms_group_oneway_synonyms, #row_algoliasearch_synonyms_synonyms_group_synonyms_file');
97-
98-
if (enabled === '1') {
99-
$rows.show();
100-
} else {
101-
$rows.hide();
102-
}
103-
}
104-
105-
// ORDERED / UNORDERED
106-
var $attributesRows = $('#algoliasearch_products_products_product_additional_attributes, #algoliasearch_categories_categories_category_additional_attributes');
107-
initAttributes($attributesRows);
108-
109-
$attributesRows.on('click', 'button[id^="addToEndBtn"]', function (e) {
110-
initAttributes($attributesRows);
111-
});
112-
113-
$attributesRows.on('change', 'select[name$="[searchable]"]', function (e) {
114-
handleAttributes($(this));
115-
});
116-
117-
function initAttributes($attributesRows) {
118-
$attributesRows.find('select[name$="[searchable]"]').each(function(e) {
119-
handleAttributes($(this));
120-
});
121-
}
122-
123-
function handleAttributes($selectBox) {
124-
var selectValue = $selectBox.val(),
125-
$input = $selectBox.parent('td').next().find('select[name$="[order]"]');
126-
127-
if(selectValue !== '1') {
128-
$input.hide();
129-
}
130-
else {
131-
$input.show();
132-
}
133-
}
134-
});
135-
});
75+
// New notice management
76+
extensionNotices.each(function(notice){
77+
if (notice.method === 'before') {
78+
$(notice.selector).before(notice.message);
79+
} else if (notice.method === 'append') {
80+
$(notice.selector).append(notice.message);
81+
} else if (notice.method === 'after') {
82+
$(notice.selector).after(notice.message);
83+
}
84+
});
85+
}
86+
87+
// SYNONYMS
88+
89+
handleSynonyms($('#algoliasearch_synonyms_synonyms_group_enable_synonyms').val());
90+
91+
$(document).on('change', '#algoliasearch_synonyms_synonyms_group_enable_synonyms', function() {
92+
handleSynonyms($(this).val());
93+
});
94+
95+
function handleSynonyms(enabled) {
96+
var $rows = $('#row_algoliasearch_synonyms_synonyms_group_synonyms, #row_algoliasearch_synonyms_synonyms_group_oneway_synonyms, #row_algoliasearch_synonyms_synonyms_group_synonyms_file');
97+
98+
if (enabled === '1') {
99+
$rows.show();
100+
} else {
101+
$rows.hide();
102+
}
103+
}
104+
105+
// ORDERED / UNORDERED
106+
var $attributesRows = $('#algoliasearch_products_products_product_additional_attributes, #algoliasearch_categories_categories_category_additional_attributes');
107+
initAttributes($attributesRows);
108+
109+
$attributesRows.on('click', 'button[id^="addToEndBtn"]', function (e) {
110+
initAttributes($attributesRows);
111+
});
112+
113+
$attributesRows.on('change', 'select[name$="[searchable]"]', function (e) {
114+
handleAttributes($(this));
115+
});
116+
117+
function initAttributes($attributesRows) {
118+
$attributesRows.find('select[name$="[searchable]"]').each(function(e) {
119+
handleAttributes($(this));
120+
});
121+
}
122+
123+
function handleAttributes($selectBox) {
124+
var selectValue = $selectBox.val(),
125+
$input = $selectBox.parent('td').next().find('select[name$="[order]"]');
126+
127+
if(selectValue !== '1') {
128+
$input.hide();
129+
}
130+
else {
131+
$input.show();
132+
}
133+
}
134+
});
135+
});
136136
});
137137
</script>

0 commit comments

Comments
 (0)