|
10 | 10 | * CLI template |
11 | 11 | * |
12 | 12 | * @var $block \Magefan\Cli\Block\Adminhtml\Form |
| 13 | + * @var $mfSecureRenderer \Magefan\Community\Api\SecureHtmlRendererInterface |
13 | 14 | * |
14 | 15 | * @codingStandardsIgnoreStart |
15 | 16 | */ |
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 = ''; |
19 | 21 | ?> |
20 | 22 |
|
21 | 23 | <?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> |
26 | 29 | </div> |
27 | 30 | </div> |
28 | | -</div> |
29 | 31 | <?php } elseif (!count(array_filter($magentoCommands))) { ?> |
30 | 32 | <div class="messages"> |
31 | 33 | <div class="message message-error error"> |
|
35 | 37 | </div> |
36 | 38 | </div> |
37 | 39 | <?php } else {?> |
38 | | -<?php |
| 40 | + <?php |
39 | 41 | $mostUsed = $magentoCommands['most_used']; |
40 | 42 | $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> |
85 | 75 | </div> |
86 | 76 | </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) { ?> |
92 | 104 | <?php if ($command) { ?> |
93 | 105 | <li> |
94 | 106 | <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> |
96 | 108 | </li> |
97 | 109 | <?php } ?> |
98 | 110 | <?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> |
110 | 113 | </div> |
111 | | -</div> |
112 | 114 |
|
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) { |
116 | 119 | $(function(){ |
117 | 120 | $('#shell-area').click(function(){ |
118 | 121 | $('#command').focus(); |
|
134 | 137 |
|
135 | 138 | function addCommand() |
136 | 139 | { |
137 | | - var $e = $('#command'); |
138 | | - v = $.trim($e.val()); |
| 140 | + var e = $('#command'); |
| 141 | + v = $.trim(e.val()); |
139 | 142 | if (v) { |
140 | 143 | commandLog.push(v); |
141 | 144 | } |
142 | 145 | var commandLogIndex = 0; |
143 | | - $e.val(''); |
| 146 | + e.val(''); |
144 | 147 | } |
145 | 148 |
|
146 | 149 | function addContent(c) |
|
152 | 155 |
|
153 | 156 | var loading = false; |
154 | 157 | $('#command').keydown(function(e) { |
155 | | - var $e = $(this); |
| 158 | + var e = $(this); |
156 | 159 | if(e.which == 40) { //up |
157 | 160 | commandLogIndex--; |
158 | 161 | if (commandLogIndex < 0) { |
|
169 | 172 | if (loading) return; |
170 | 173 | loading = true; |
171 | 174 |
|
172 | | - if (!$.trim($e.val())) { |
| 175 | + if (!$.trim(e.val())) { |
173 | 176 | addContent('<br/>'); |
174 | 177 | loading = false; |
175 | 178 | return; |
176 | 179 | } |
177 | 180 |
|
178 | 181 | $.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()}, |
181 | 184 | type: 'POST', |
182 | 185 | dataType: 'json', |
183 | 186 | showLoader: true |
184 | 187 | }).done(function (data) { |
185 | 188 | loading = false; |
186 | 189 | if (data && data.message) { |
187 | | - addContent('<strong>$ </strong>' + $e.val() + '<br/>'); |
| 190 | + addContent('<strong>$ </strong>' + e.val() + '<br/>'); |
188 | 191 | addContent(data.message); |
189 | 192 | } 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.')) . "'); |
191 | 194 | } |
192 | 195 | }); |
193 | 196 | } |
|
205 | 208 | loading = true; |
206 | 209 |
|
207 | 210 | $.ajax({ |
208 | | - url: '<?php echo $block->escapeUrl($block->getUrl('*/*/cli')) ?>', |
| 211 | + url: '" . $block->escapeUrl($block->getUrl('*/*/cli')) . "', |
209 | 212 | data : {command:'php ' + command,current_password:$('#user_current_password').val()}, |
210 | 213 | type: 'POST', |
211 | 214 | dataType: 'json', |
|
216 | 219 | addContent('<strong>$ </strong>' + command + '<br/>'); |
217 | 220 | addContent(data.message); |
218 | 221 | } 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.')) . "'); |
| 223 | + } |
| 224 | +
|
| 225 | + if (data && data.newFormKey) { |
| 226 | + FORM_KEY = data.newFormKey; |
| 227 | + document.querySelector('input[name=\"form_key\"]').value = FORM_KEY; |
220 | 228 | } |
221 | 229 | }); |
222 | 230 | } |
|
237 | 245 | }); |
238 | 246 | }) |
239 | 247 | }); |
240 | | -</script> |
241 | | -<?php } ?> |
| 248 | + "; ?> |
| 249 | + |
| 250 | + <?= /* @noEscape */ $mfSecureRenderer->renderTag('script', [], $script, false) ?> |
| 251 | + <?php } ?> |
242 | 252 | <?php } ?> |
0 commit comments