Add some more result panels to Babel

This commit is contained in:
Hypolite Petovan 2020-12-04 07:28:18 -05:00
parent a0f6d678c4
commit a382798999
2 changed files with 26 additions and 4 deletions

View file

@ -49,7 +49,7 @@ class Babel extends BaseModule
if (!empty($_REQUEST['text'])) { if (!empty($_REQUEST['text'])) {
switch (($_REQUEST['type'] ?? '') ?: 'bbcode') { switch (($_REQUEST['type'] ?? '') ?: 'bbcode') {
case 'bbcode': case 'bbcode':
$bbcode = trim($_REQUEST['text']); $bbcode = $_REQUEST['text'];
$results[] = [ $results[] = [
'title' => DI::l10n()->t('Source input'), 'title' => DI::l10n()->t('Source input'),
'content' => visible_whitespace($bbcode) 'content' => visible_whitespace($bbcode)
@ -67,6 +67,11 @@ class Babel extends BaseModule
'content' => visible_whitespace($html) 'content' => visible_whitespace($html)
]; ];
$results[] = [
'title' => DI::l10n()->t('BBCode::convert (hex)'),
'content' => visible_whitespace(bin2hex($html)),
];
$results[] = [ $results[] = [
'title' => DI::l10n()->t('BBCode::convert'), 'title' => DI::l10n()->t('BBCode::convert'),
'content' => $html 'content' => $html
@ -178,6 +183,25 @@ class Babel extends BaseModule
'content' => $html 'content' => $html
]; ];
$config = \HTMLPurifier_Config::createDefault();
$HTMLPurifier = new \HTMLPurifier($config);
$purified = $HTMLPurifier->purify($html);
$results[] = [
'title' => DI::l10n()->t('HTML Purified (raw)'),
'content' => visible_whitespace($purified),
];
$results[] = [
'title' => DI::l10n()->t('HTML Purified (hex)'),
'content' => visible_whitespace(bin2hex($purified)),
];
$results[] = [
'title' => DI::l10n()->t('HTML Purified'),
'content' => $purified,
];
$bbcode = Text\HTML::toBBCode($html); $bbcode = Text\HTML::toBBCode($html);
$results[] = [ $results[] = [
'title' => DI::l10n()->t('HTML::toBBCode'), 'title' => DI::l10n()->t('HTML::toBBCode'),

View file

@ -24,9 +24,7 @@
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title">{{$result.title}}</h3> <h3 class="panel-title">{{$result.title}}</h3>
</div> </div>
<div class="panel-body"> <div class="panel-body">{{$result.content nofilter}}</div>
{{$result.content nofilter}}
</div>
</div> </div>
{{/foreach}} {{/foreach}}
</div> </div>