Skip to content

Commit 6fac5c2

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 7f192f5 + 91fe95e commit 6fac5c2

File tree

10 files changed

+139
-123
lines changed

10 files changed

+139
-123
lines changed

.github/workflows/php.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: PHPCS
2+
on: [push]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@master
8+
- name: PHPCS
9+
run: docker run --rm -v $PWD:/code:ro domw/phpcs phpcs --colors --standard=Magento2 --report=full,summary,gitblame --extensions=php,phtml ./
10+
- name: compatibility
11+
run: docker run --rm -v $PWD:/code:ro domw/phpcompatibility phpcs --standard=PHPCompatibility --runtime-set testVersion 5.6-7.3 --colors --warning-severity=0 --report=full,summary --extensions=php,phtml ./

Block/Adminhtml/System/Config/Form/Composer/Version.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright © MagePal LLC. All rights reserved.
44
* See COPYING.txt for license details.
55
* http://www.magepal.com | support@magepal.com
6-
*/
6+
*/
77

88
namespace MagePal\CheckoutSuccessMiscScript\Block\Adminhtml\System\Config\Form\Composer;
99

@@ -112,15 +112,15 @@ public function getComposerVersion($moduleName)
112112
try {
113113
$directoryRead = $this->readFactory->create($path);
114114
$composerJsonData = $directoryRead->readFile('composer.json');
115-
116115
if ($composerJsonData) {
117116
$data = json_decode($composerJsonData);
118-
return !empty($data->version) ? $data->version : __('Unknown');
117+
if (!empty($data->version)) {
118+
return $data->version;
119+
}
119120
}
121+
return __('Unknown');
120122
} catch (Exception $e) {
121-
//
123+
return __('Unknown');
122124
}
123-
124-
return 'Unknown';
125125
}
126126
}

Block/Adminhtml/System/Config/Form/Field/MiscScript.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
* Copyright © MagePal LLC. All rights reserved.
44
* See COPYING.txt for license details.
55
* http://www.magepal.com | support@magepal.com
6-
*/
6+
*/
77

88
namespace MagePal\CheckoutSuccessMiscScript\Block\Adminhtml\System\Config\Form\Field;
99

10-
use Exception;
1110
use Magento\Backend\Block\Template\Context;
1211
use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray;
1312
use Magento\Framework\View\Element\AbstractBlock;
13+
use Magento\Framework\Exception\LocalizedException;
1414
use MagePal\CheckoutSuccessMiscScript\Helper\Data;
1515

1616
/**
@@ -127,12 +127,12 @@ public function addColumn($name, $params)
127127
/**
128128
* @param string $columnName
129129
* @return mixed|string
130-
* @throws Exception
130+
* @throws LocalizedException
131131
*/
132132
public function renderCellTemplate($columnName)
133133
{
134134
if (empty($this->_columns[$columnName])) {
135-
throw new Exception('Wrong column name specified.');
135+
throw new LocalizedException(__('Wrong column name specified.'));
136136
}
137137
$column = $this->_columns[$columnName];
138138
$inputName = $this->_getCellInputElementName($columnName);

Block/Adminhtml/System/Config/Form/Module/Version.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
* Copyright © MagePal LLC. All rights reserved.
44
* See COPYING.txt for license details.
55
* http://www.magepal.com | support@magepal.com
6-
*/
6+
*/
77

88
namespace MagePal\CheckoutSuccessMiscScript\Block\Adminhtml\System\Config\Form\Module;
99

1010
use Magento\Backend\Block\Template\Context;
1111
use Magento\Config\Block\System\Config\Form\Field;
1212
use Magento\Framework\Data\Form\Element\AbstractElement;
13-
use Magento\Framework\Exception\LocalizedException;
1413
use Magento\Framework\Module\ModuleListInterface;
1514

1615
/**

Block/Checkout/Success.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright © MagePal LLC. All rights reserved.
44
* See COPYING.txt for license details.
55
* http://www.magepal.com | support@magepal.com
6-
*/
6+
*/
77

88
namespace MagePal\CheckoutSuccessMiscScript\Block\Checkout;
99

Helper/Data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright © MagePal LLC. All rights reserved.
44
* See COPYING.txt for license details.
55
* http://www.magepal.com | support@magepal.com
6-
*/
6+
*/
77

88
namespace MagePal\CheckoutSuccessMiscScript\Helper;
99

Model/Config/Backend/Serialized/MiscScriptArraySerialized.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright © MagePal LLC. All rights reserved.
44
* See COPYING.txt for license details.
55
* http://www.magepal.com | support@magepal.com
6-
*/
6+
*/
77

88
namespace MagePal\CheckoutSuccessMiscScript\Model\Config\Backend\Serialized;
99

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"magepal/magento2-preview-checkout-success-page":"Preview checkout success page from admin"
2222
},
2323
"type": "magento2-module",
24-
"version": "1.1.9",
24+
"version": "1.1.10",
2525
"license": [
2626
"proprietary"
2727
],

view/adminhtml/templates/system/config/form/field/array.phtml

Lines changed: 110 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -3,145 +3,151 @@
33
* Copyright © MagePal LLC. All rights reserved.
44
* See COPYING.txt for license details.
55
* http://www.magepal.com | support@magepal.com
6-
*/
6+
*/
77

88
/**
99
* @var $block MagePal\CheckoutSuccessMiscScript\Block\Adminhtml\System\Config\Form\Field\MiscScript
1010
*/
11-
1211
?>
1312

1413
<?php
1514
$_htmlId = $block->getHtmlId() ? $block->getHtmlId() : '_' . uniqid();
1615
$_colspan = $block->isAddAfter() ? 2 : 1;
1716
?>
1817

19-
<div class="design_theme_ua_regexp" id="grid<?= /* @escapeNotVerified */ $_htmlId ?>">
18+
<div class="design_theme_ua_regexp" id="grid<?= $block->escapeHtmlAttr($_htmlId) ?>">
2019
<div class="admin__control-table-wrapper">
21-
<table class="admin__control-table" id="<?= /* @escapeNotVerified */ $block->getElement()->getId() ?>">
20+
<table class="admin__control-table" id="<?= $block->escapeHtmlAttr($block->getElement()->getId()) ?>">
2221
<thead>
23-
<tr>
24-
<?php foreach ($block->getColumns() as $columnName => $column): ?>
25-
<?php if ($column['type'] != 'textarea'):?>
26-
<th><?= /* @escapeNotVerified */ $column['label'] ?></th>
27-
<?php endif; ?>
28-
<?php endforeach;?>
29-
<th class="col-actions" colspan="<?= /* @escapeNotVerified */ $_colspan ?>">Action</th>
30-
</tr>
22+
<tr>
23+
<?php foreach ($block->getColumns() as $columnName => $column) : ?>
24+
<?php if ($column['type'] != 'textarea') :?>
25+
<th><?= $block->escapeHtml($column['label']) ?></th>
26+
<?php endif; ?>
27+
<?php endforeach;?>
28+
<th class="col-actions" colspan="<?= $block->escapeHtmlAttr($_colspan) ?>">
29+
<?= $block->escapeHtml(__('Action')); ?>
30+
</th>
31+
</tr>
3132
</thead>
3233
<tfoot>
33-
<tr>
34-
<td colspan="<?= count($block->getColumns())+$_colspan ?>" class="col-actions-add">
35-
<button id="addToEndBtn<?= /* @escapeNotVerified */ $_htmlId ?>" class="action-add" title="<?= /* @escapeNotVerified */ __('Add') ?>" type="button">
36-
<span><?= /* @escapeNotVerified */ $block->getAddButtonLabel() ?></span>
37-
</button>
38-
</td>
39-
</tr>
34+
<tr>
35+
<td colspan="<?= count($block->getColumns())+$_colspan ?>" class="col-actions-add">
36+
<button id="addToEndBtn<?= $block->escapeHtmlAttr($_htmlId) ?>"
37+
class="action-add"
38+
title="<?= $block->escapeHtmlAttr(__('Add')) ?>"
39+
type="button">
40+
<span><?= $block->escapeHtml($block->getAddButtonLabel()) ?></span>
41+
</button>
42+
</td>
43+
</tr>
4044
</tfoot>
41-
<tbody id="addRow<?= /* @escapeNotVerified */ $_htmlId ?>"></tbody>
45+
<tbody id="addRow<?= $block->escapeHtmlAttr($_htmlId) ?>"></tbody>
4246
</table>
4347
</div>
44-
<input type="hidden" name="<?= /* @escapeNotVerified */ $block->getElement()->getName() ?>[__empty]" value="" />
48+
<input type="hidden"
49+
name="<?= $block->escapeHtmlAttr($block->getElement()->getName()) ?>[__empty]"
50+
value="" />
4551

4652
<script>
4753
require([
4854
'mage/template',
4955
'jquery',
5056
'prototype'
5157
], function (mageTemplate, $j) {
52-
// create row creator
53-
window.arrayRow<?= /* @escapeNotVerified */ $_htmlId ?> = {
54-
55-
// define row prototypeJS template
56-
template: mageTemplate(
57-
'<tr id="<%- _id %>">'
58-
<?php foreach ($block->getColumns() as $columnName => $column): ?>
59-
<?php if ($column['type'] != 'textarea'):?>
60-
+ '<td>'
61-
+ '<?= /* @escapeNotVerified */ $block->renderCellTemplate($columnName) ?>'
62-
+ '<\/td>'
63-
<?php endif; ?>
64-
<?php endforeach; ?>
58+
// create row creator
59+
window.arrayRow<?= /* @noEscape */ $_htmlId ?> = {
60+
61+
// define row prototypeJS template
62+
template: mageTemplate(
63+
'<tr id="<%- _id %>">'
64+
<?php foreach ($block->getColumns() as $columnName => $column) : ?>
65+
<?php if ($column['type'] != 'textarea') :?>
66+
+ '<td>'
67+
+ '<?= /* @noEscape */ $block->renderCellTemplate($columnName) ?>'
68+
+ '<\/td>'
69+
<?php endif; ?>
70+
<?php endforeach; ?>
6571

66-
<?php if ($block->isAddAfter()): ?>
67-
+ '<td><button class="action-add" type="button" id="addAfterBtn<%- _id %>"><span><?= /* @escapeNotVerified */ __('Add after') ?><\/span><\/button><\/td>'
68-
<?php endif; ?>
72+
<?php if ($block->isAddAfter()) : ?>
73+
+ '<td><button class="action-add" type="button" id="addAfterBtn<%- _id %>"><span><?= $block->escapeHtml(__('Add after')) ?><\/span><\/button><\/td>'
74+
<?php endif; ?>
6975

70-
+ '<td class="col-actions"><button onclick="arrayRow<?= /* @escapeNotVerified */ $_htmlId ?>.del(\'<%- _id %>\')" class="action-delete" type="button"><span><?= /* @escapeNotVerified */ __('Delete') ?><\/span><\/button><\/td>'
71-
+'<\/tr>'
76+
+ '<td class="col-actions"><button onclick="arrayRow<?= /* @noEscape */ $_htmlId ?>.del(\'<%- _id %>\')" class="action-delete" type="button"><span><?= $block->escapeHtml(__('Delete')) ?><\/span><\/button><\/td>'
77+
+'<\/tr>'
7278

73-
<?php foreach ($block->getColumns() as $columnName => $column): ?>
74-
<?php if ($column['type'] == 'textarea'):?>
75-
+ '<tr id="<%- _id %>"><td colspan="<?= count($block->getColumns())+$_colspan ?>">'
76-
+ '<?= /* @escapeNotVerified */ $block->renderCellTemplate($columnName) ?>'
77-
+ '<div><?= $block->getTemplateButtonList() ?></div>'
78-
+ '<\/td></tr>'
79-
<?php endif; ?>
80-
<?php endforeach; ?>
81-
),
82-
83-
add: function(rowData, insertAfterId) {
84-
// generate default template data
85-
var templateValues;
86-
87-
// Prepare template values
88-
if (rowData) {
89-
templateValues = rowData;
90-
} else {
91-
var d = new Date();
92-
templateValues = {
93-
<?php foreach ($block->getColumns() as $columnName => $column): ?>
94-
<?= /* @escapeNotVerified */ $columnName ?> : '',
95-
'option_extra_attrs': {},
79+
<?php foreach ($block->getColumns() as $columnName => $column) : ?>
80+
<?php if ($column['type'] == 'textarea') :?>
81+
+ '<tr id="<%- _id %>"><td colspan="<?= count($block->getColumns())+$_colspan ?>">'
82+
+ '<?= /* @noEscape */ $block->renderCellTemplate($columnName) ?>'
83+
+ '<div><?= /* @noEscape */ $block->getTemplateButtonList() ?></div>'
84+
+ '<\/td></tr>'
85+
<?php endif; ?>
9686
<?php endforeach; ?>
97-
_id: '_' + d.getTime() + '_' + d.getMilliseconds()
98-
};
99-
}
87+
),
88+
89+
add: function(rowData, insertAfterId) {
90+
// generate default template data
91+
var templateValues;
92+
93+
// Prepare template values
94+
if (rowData) {
95+
templateValues = rowData;
96+
} else {
97+
var d = new Date();
98+
templateValues = {
99+
<?php foreach ($block->getColumns() as $columnName => $column) : ?>
100+
<?= /* @noEscape */ $columnName ?> : '',
101+
'option_extra_attrs': {},
102+
<?php endforeach; ?>
103+
_id: '_' + d.getTime() + '_' + d.getMilliseconds()
104+
};
105+
}
100106

101-
// Insert new row after specified row or at the bottom
102-
if (insertAfterId) {
103-
Element.insert($(insertAfterId), {after: this.template(templateValues)});
104-
} else {
105-
Element.insert($('addRow<?= /* @escapeNotVerified */ $_htmlId ?>'), {bottom: this.template(templateValues)});
106-
}
107+
// Insert new row after specified row or at the bottom
108+
if (insertAfterId) {
109+
Element.insert($(insertAfterId), {after: this.template(templateValues)});
110+
} else {
111+
Element.insert($('addRow<?= /* @noEscape */ $_htmlId ?>'), {bottom: this.template(templateValues)});
112+
}
107113

108-
// Fill controls with data
109-
if (rowData) {
110-
var rowInputElementNames = Object.keys(rowData.column_values);
111-
for (var i = 0; i < rowInputElementNames.length; i++) {
112-
if ($(rowInputElementNames[i])) {
113-
$(rowInputElementNames[i]).setValue(rowData.column_values[rowInputElementNames[i]]);
114+
// Fill controls with data
115+
if (rowData) {
116+
var rowInputElementNames = Object.keys(rowData.column_values);
117+
for (var i = 0; i < rowInputElementNames.length; i++) {
118+
if ($(rowInputElementNames[i])) {
119+
$(rowInputElementNames[i]).setValue(rowData.column_values[rowInputElementNames[i]]);
120+
}
114121
}
115122
}
123+
124+
// Add event for {addAfterBtn} button
125+
<?php if ($block->isAddAfter()) : ?>
126+
Event.observe('addAfterBtn' + templateValues._id, 'click', this.add.bind(this, false, templateValues._id));
127+
<?php endif; ?>
128+
129+
$j('#magepal_checkout_misc_script_scripts').trigger('contentUpdated');
130+
},
131+
132+
del: function(rowId) {
133+
$(rowId).remove();
134+
$(rowId).remove();
116135
}
136+
};
137+
138+
// bind add action to "Add" button in last row
139+
// phpcs:disable
140+
Event.observe('addToEndBtn<?= /* @noEscape */ $_htmlId ?>', 'click', arrayRow<?= /* @noEscape */ $_htmlId ?>.add.bind(arrayRow<?= /* @noEscape */ $_htmlId ?>, false, false));
141+
// phpcs:enable
142+
143+
// add existing rows
144+
<?php foreach ($block->getArrayRows() as $_rowId => $_row) : ?>
145+
<?= /* @noEscape */ "arrayRow{$_htmlId}.add(" . $_row->toJson() . ");\n"; ?>
146+
<?php endforeach; ?>
117147

118-
// Add event for {addAfterBtn} button
119-
<?php if ($block->isAddAfter()): ?>
120-
Event.observe('addAfterBtn' + templateValues._id, 'click', this.add.bind(this, false, templateValues._id));
121-
<?php endif; ?>
122-
123-
$j('#magepal_checkout_misc_script_scripts').trigger('contentUpdated');
124-
},
125-
126-
del: function(rowId) {
127-
$(rowId).remove();
128-
$(rowId).remove();
129-
}
130-
};
131-
132-
// bind add action to "Add" button in last row
133-
Event.observe('addToEndBtn<?= /* @escapeNotVerified */ $_htmlId ?>', 'click', arrayRow<?= /* @escapeNotVerified */ $_htmlId ?>.add.bind(arrayRow<?= /* @escapeNotVerified */ $_htmlId ?>, false, false));
134-
135-
// add existing rows
136-
<?php
137-
foreach ($block->getArrayRows() as $_rowId => $_row) {
138-
/* @escapeNotVerified */ echo "arrayRow{$_htmlId}.add(" . $_row->toJson() . ");\n";
139-
}
140-
?>
141-
142-
// Toggle the grid availability, if element is disabled (depending on scope)
143-
<?php if ($block->getElement()->getDisabled()):?>
144-
toggleValueElements({checked: true}, $('grid<?= /* @escapeNotVerified */ $_htmlId ?>').parentNode);
148+
// Toggle the grid availability, if element is disabled (depending on scope)
149+
<?php if ($block->getElement()->getDisabled()) :?>
150+
toggleValueElements({checked: true}, $('grid<?= /* @noEscape */ $_htmlId ?>').parentNode);
145151
<?php endif;?>
146152
});
147153
</script>

view/frontend/templates/checkout/misc-script.phtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
* Copyright © MagePal LLC. All rights reserved.
44
* See COPYING.txt for license details.
55
* http://www.magepal.com | support@magepal.com
6-
*/
6+
*/
77

88
/**
99
* @var $block MagePal\CheckoutSuccessMiscScript\Block\Checkout\Success
1010
*/
11-
12-
echo $block->getActiveScripts();
11+
?>
12+
<?= /* @noEscape */ $block->getActiveScripts(); ?>

0 commit comments

Comments
 (0)