Skip to content

Commit c03558b

Browse files
author
Bohdan Berezhniy
committed
11309-Script-tag-replace
1 parent a081f67 commit c03558b

File tree

1 file changed

+93
-88
lines changed

1 file changed

+93
-88
lines changed

view/adminhtml/templates/form.phtml

Lines changed: 93 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,24 @@
1010
* CLI template
1111
*
1212
* @var $block \Magefan\Cli\Block\Adminhtml\Form
13+
* @var $mfSecureRenderer \Magefan\Community\Api\SecureHtmlRendererInterface
1314
*
1415
* @codingStandardsIgnoreStart
1516
*/
16-
$exec = $block->execExist();
17-
$magentoCommands = $block->getMagentoCommands();
18-
$url = $block->getUrl('adminhtml/system_config/edit', ['section' => 'mfcli']);
17+
$exec = $block->execExist();
18+
$magentoCommands = $block->getMagentoCommands();
19+
$url = $block->getUrl('adminhtml/system_config/edit', ['section' => 'mfcli']);
20+
$script = '';
1921
?>
2022

2123
<?php if (!$block->isModuleEnabled()) {?>
22-
<div class="messages">
23-
<div class="message message-error error">
24-
<div data-ui-id="messages-message-error">
25-
<?= $block->escapeHtml(__(strrev(' ot etagivan esaelp noisnetxe eht elbane ot ,delbasid si ecafretnI eniL dnammoC nafegaM'))) ?><a href="<?= $block->escapeUrl($url) ?>" target="_blank"><?= $block->escapeHtml(__(strrev('ecafretnI eniL dnammoC > snoisnetxE nafegaM > noitarugifnoC > serotS'))) ?></a>
24+
<div class="messages">
25+
<div class="message message-error error">
26+
<div data-ui-id="messages-message-error">
27+
<?= $block->escapeHtml(__(strrev(' ot etagivan esaelp noisnetxe eht elbane ot ,delbasid si ecafretnI eniL dnammoC nafegaM'))) ?><a href="<?= $block->escapeUrl($url) ?>" target="_blank"><?= $block->escapeHtml(__(strrev('ecafretnI eniL dnammoC > snoisnetxE nafegaM > noitarugifnoC > serotS'))) ?></a>
28+
</div>
2629
</div>
2730
</div>
28-
</div>
2931
<?php } elseif (!count(array_filter($magentoCommands))) { ?>
3032
<div class="messages">
3133
<div class="message message-error error">
@@ -35,84 +37,85 @@
3537
</div>
3638
</div>
3739
<?php } else {?>
38-
<?php
40+
<?php
3941
$mostUsed = $magentoCommands['most_used'];
4042
$commands = $magentoCommands['commands'];
41-
?>
42-
<style>
43-
#shell-area{float:left;width:78%;margin:0;list-style:none;background:#141414;color:#45D40C;font:.8em 'Andale Mono',Consolas,'Courier New';line-height:1.6em;padding:10px; min-height:500px;max-height:500px;overflow-y: auto;}
44-
#shell-area input{width:80%; background: #141414;border:none;padding:10px;line-height:15px}
45-
#command-list ul{float:right;height:200px;width:20%;min-height:500px;max-height:500px;}
46-
#command-list ul{overflow:hidden;overflow-y:scroll;overflow-x:scroll;}
47-
#command-list li {padding-bottom: 10px}
48-
#command-list li .execute {padding-left: 10px}
49-
.row:after {content:'';display:table;clear:both;}
50-
.execute {cursor: pointer;}
51-
</style>
52-
53-
<div class="admin__scope-old">
54-
<div class="entry-edit form-inline">
55-
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" >
56-
<div class="entry-edit form-inline">
57-
<fieldset class="fieldset admin__fieldset ">
58-
<legend class="admin__legend legend">
59-
<span><?php echo $block->escapeHtml(__('Current User Identity Verification')) ?></span>
60-
</legend>
61-
<br>
62-
<div class="messages">
63-
</div>
64-
<div class="admin__field field field-current_password required _required" >
65-
<label class="label admin__field-label" for="user_current_password"><span><?php echo $block->escapeHtml(__('Your Password')) ?></span></label>
66-
<div class="admin__field-control control">
67-
<input id="user_current_password" name="current_password" value="" title="<?php echo $block->escapeHtml(__('Your Password')) ?>" class="input-text " type="password" >
68-
</div>
69-
</div>
70-
</fieldset>
71-
</div>
72-
</div>
73-
</div>
74-
</div>
75-
76-
<div class="row">
77-
<div id="shell-area">
78-
<div class="history-hld"></div>
79-
<div class="input-hld">
80-
<?php if ($exec) { ?>
81-
<?php echo $block->escapeHtml(__('Enter Command:')) ?><input id="command" />
82-
<?php } else { ?>
83-
<?php echo $block->escapeHtml(__('This command line is not accessible. Exec function is not allowed in PHP settings. Please use the standard CLI interface.')) ?>
84-
<?php } ?>
43+
?>
44+
<style>
45+
#shell-area{float:left;width:78%;margin:0;list-style:none;background:#141414;color:#45D40C;font:.8em 'Andale Mono',Consolas,'Courier New';line-height:1.6em;padding:10px; min-height:500px;max-height:500px;overflow-y: auto;}
46+
#shell-area input{width:80%; background: #141414;border:none;padding:10px;line-height:15px}
47+
#command-list ul{float:right;height:200px;width:20%;min-height:500px;max-height:500px;}
48+
#command-list ul{overflow:hidden;overflow-y:scroll;overflow-x:scroll;}
49+
#command-list li {padding-bottom: 10px}
50+
#command-list li .execute {padding-left: 10px}
51+
.row:after {content:'';display:table;clear:both;}
52+
.execute {cursor: pointer;}
53+
</style>
54+
55+
<div class="admin__scope-old">
56+
<div class="entry-edit form-inline">
57+
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" >
58+
<div class="entry-edit form-inline">
59+
<fieldset class="fieldset admin__fieldset ">
60+
<legend class="admin__legend legend">
61+
<span><?php echo $block->escapeHtml(__('Current User Identity Verification')) ?></span>
62+
</legend>
63+
<br>
64+
<div class="messages">
65+
</div>
66+
<div class="admin__field field field-current_password required _required" >
67+
<label class="label admin__field-label" for="user_current_password"><span><?php echo $block->escapeHtml(__('Your Password')) ?></span></label>
68+
<div class="admin__field-control control">
69+
<input id="user_current_password" name="current_password" value="" title="<?php echo $block->escapeHtml(__('Your Password')) ?>" class="input-text " type="password" >
70+
</div>
71+
</div>
72+
</fieldset>
73+
</div>
74+
</div>
8575
</div>
8676
</div>
87-
<div id="command-list">
88-
<ul>
89-
<?php if (count($mostUsed)) { ?>
90-
<p><?= $block->escapeHtml(__('Most Used Commands')) ?></p>
91-
<?php foreach ($mostUsed as $command) { ?>
77+
78+
<div class="row">
79+
<div id="shell-area">
80+
<div class="history-hld"></div>
81+
<div class="input-hld">
82+
<?php if ($exec) { ?>
83+
<?php echo $block->escapeHtml(__('Enter Command:')) ?><input id="command" />
84+
<?php } else { ?>
85+
<?php echo $block->escapeHtml(__('This command line is not accessible. Exec function is not allowed in PHP settings. Please use the standard CLI interface.')) ?>
86+
<?php } ?>
87+
</div>
88+
</div>
89+
<div id="command-list">
90+
<ul>
91+
<?php if (count($mostUsed)) { ?>
92+
<p><?= $block->escapeHtml(__('Most Used Commands')) ?></p>
93+
<?php foreach ($mostUsed as $command) { ?>
94+
<?php if ($command) { ?>
95+
<li>
96+
<span class="execute-label"><?= $block->escapeHtml($command) ?></span>
97+
<span class="execute" title="<?= $block->escapeHtml('Execute') ?>" data-name="<?= $block->escapeHtml($command) ?>">▶</span>
98+
</li>
99+
<?php } ?>
100+
<?php } ?>
101+
<br><hr><br>
102+
<?php } ?>
103+
<?php foreach ($commands as $command) { ?>
92104
<?php if ($command) { ?>
93105
<li>
94106
<span class="execute-label"><?= $block->escapeHtml($command) ?></span>
95-
<span class="execute" title="<?= $block->escapeHtml('Execute') ?>" data-name="<?= $block->escapeHtml($command) ?>">▶</span>
107+
<span class="execute" title="<?= $block->escapeHtml('Execute') ?>" data-name="<?= $block->escapeHtml($command) ?>">▶</span>
96108
</li>
97109
<?php } ?>
98110
<?php } ?>
99-
<br><hr><br>
100-
<?php } ?>
101-
<?php foreach ($commands as $command) { ?>
102-
<?php if ($command) { ?>
103-
<li>
104-
<span class="execute-label"><?= $block->escapeHtml($command) ?></span>
105-
<span class="execute" title="<?= $block->escapeHtml('Execute') ?>" data-name="<?= $block->escapeHtml($command) ?>">▶</span>
106-
</li>
107-
<?php } ?>
108-
<?php } ?>
109-
</ul>
111+
</ul>
112+
</div>
110113
</div>
111-
</div>
112114

113-
<?php if ($exec) { ?>
114-
<script>
115-
require(['jquery', 'Magento_Ui/js/modal/confirm'], function($, confirmation) {
115+
<?php if ($exec) { ?>
116+
117+
<?php $script .= "
118+
require(['jquery', 'Magento_Ui/js/modal/confirm'], function($, confirmation) {
116119
$(function(){
117120
$('#shell-area').click(function(){
118121
$('#command').focus();
@@ -134,13 +137,13 @@
134137
135138
function addCommand()
136139
{
137-
var $e = $('#command');
138-
v = $.trim($e.val());
140+
var e = $('#command');
141+
v = $.trim(e.val());
139142
if (v) {
140143
commandLog.push(v);
141144
}
142145
var commandLogIndex = 0;
143-
$e.val('');
146+
e.val('');
144147
}
145148
146149
function addContent(c)
@@ -152,7 +155,7 @@
152155
153156
var loading = false;
154157
$('#command').keydown(function(e) {
155-
var $e = $(this);
158+
var e = $(this);
156159
if(e.which == 40) { //up
157160
commandLogIndex--;
158161
if (commandLogIndex < 0) {
@@ -169,25 +172,25 @@
169172
if (loading) return;
170173
loading = true;
171174
172-
if (!$.trim($e.val())) {
175+
if (!$.trim(e.val())) {
173176
addContent('<br/>');
174177
loading = false;
175178
return;
176179
}
177180
178181
$.ajax({
179-
url: '<?php echo $block->escapeUrl($block->getUrl('*/*/cli')) ?>',
180-
data : {command:$e.val(),current_password:$('#user_current_password').val()},
182+
url: '" . $block->escapeUrl($block->getUrl('*/*/cli')) . "',
183+
data : {command:e.val(),current_password:$('#user_current_password').val()},
181184
type: 'POST',
182185
dataType: 'json',
183186
showLoader: true
184187
}).done(function (data) {
185188
loading = false;
186189
if (data && data.message) {
187-
addContent('<strong>$ </strong>' + $e.val() + '<br/>');
190+
addContent('<strong>$ </strong>' + e.val() + '<br/>');
188191
addContent(data.message);
189192
} else {
190-
alert('<?php echo $block->escapeHtml(__('Unexpected error. Please refresh the page or try later.')) ?>');
193+
alert('" . $block->escapeHtml(__('Unexpected error. Please refresh the page or try later.')) . "');
191194
}
192195
});
193196
}
@@ -205,7 +208,7 @@
205208
loading = true;
206209
207210
$.ajax({
208-
url: '<?php echo $block->escapeUrl($block->getUrl('*/*/cli')) ?>',
211+
url: '" . $block->escapeUrl($block->getUrl('*/*/cli')) . "',
209212
data : {command:'php ' + command,current_password:$('#user_current_password').val()},
210213
type: 'POST',
211214
dataType: 'json',
@@ -216,12 +219,12 @@
216219
addContent('<strong>$ </strong>' + command + '<br/>');
217220
addContent(data.message);
218221
} else {
219-
alert('<?php echo $block->escapeHtml(__('Unexpected error. Please refresh the page or try later.')) ?>');
222+
alert('" . $block->escapeHtml(__('Unexpected error. Please refresh the page or try later.')) . "');
220223
}
221224
222225
if (data && data.newFormKey) {
223226
FORM_KEY = data.newFormKey;
224-
document.querySelector('input[name="form_key"]').value = FORM_KEY;
227+
document.querySelector('input[name=\"form_key\"]').value = FORM_KEY;
225228
}
226229
});
227230
}
@@ -242,6 +245,8 @@
242245
});
243246
})
244247
});
245-
</script>
246-
<?php } ?>
248+
"; ?>
249+
250+
<?= /* @noEscape */ $mfSecureRenderer->renderTag('script', [], $script, false) ?>
251+
<?php } ?>
247252
<?php } ?>

0 commit comments

Comments
 (0)