]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Debug/Babel.php
We can always send via SMTP, receiving mails is via IMAP
[friendica.git] / src / Module / Debug / Babel.php
index 1ce1ac4c6e92ab5f91db0235244c45c15ca6479a..17187a37c7b0d4af9bb56f4e577d3a71cea65d07 100644 (file)
@@ -14,7 +14,7 @@ use Friendica\Util\XML;
  */
 class Babel extends BaseModule
 {
-       public static function content()
+       public static function content(array $parameters = [])
        {
                function visible_whitespace($s)
                {
@@ -25,7 +25,7 @@ class Babel extends BaseModule
 
                $results = [];
                if (!empty($_REQUEST['text'])) {
-                       switch (defaults($_REQUEST, 'type', 'bbcode')) {
+                       switch (($_REQUEST['type'] ?? '') ?: 'bbcode') {
                                case 'bbcode':
                                        $bbcode = trim($_REQUEST['text']);
                                        $results[] = [
@@ -148,26 +148,38 @@ class Babel extends BaseModule
                                                'content' => htmlspecialchars($html2)
                                        ];
 
+                                       $bbcode2plain = Text\BBCode::toPlaintext($bbcode);
+                                       $results[] = [
+                                               'title'   => L10n::t('HTML::toBBCode => BBCode::toPlaintext'),
+                                               'content' => '<pre>' . $bbcode2plain . '</pre>'
+                                       ];
+
                                        $markdown = Text\HTML::toMarkdown($html);
                                        $results[] = [
                                                'title'   => L10n::t('HTML::toMarkdown'),
                                                'content' => visible_whitespace($markdown)
                                        ];
 
-                                       $text = Text\HTML::toPlaintext($html);
+                                       $text = Text\HTML::toPlaintext($html, 0);
                                        $results[] = [
                                                'title'   => L10n::t('HTML::toPlaintext'),
                                                'content' => '<pre>' . $text . '</pre>'
                                        ];
+
+                                       $text = Text\HTML::toPlaintext($html, 0, true);
+                                       $results[] = [
+                                               'title'   => L10n::t('HTML::toPlaintext (compact)'),
+                                               'content' => '<pre>' . $text . '</pre>'
+                                       ];
                        }
                }
 
                $tpl = Renderer::getMarkupTemplate('babel.tpl');
                $o = Renderer::replaceMacros($tpl, [
-                       '$text'          => ['text', L10n::t('Source text'), defaults($_REQUEST, 'text', ''), ''],
-                       '$type_bbcode'   => ['type', L10n::t('BBCode'), 'bbcode', '', defaults($_REQUEST, 'type', 'bbcode') == 'bbcode'],
-                       '$type_markdown' => ['type', L10n::t('Markdown'), 'markdown', '', defaults($_REQUEST, 'type', 'bbcode') == 'markdown'],
-                       '$type_html'     => ['type', L10n::t('HTML'), 'html', '', defaults($_REQUEST, 'type', 'bbcode') == 'html'],
+                       '$text'          => ['text', L10n::t('Source text'), $_REQUEST['text'] ?? '', ''],
+                       '$type_bbcode'   => ['type', L10n::t('BBCode'), 'bbcode', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'bbcode'],
+                       '$type_markdown' => ['type', L10n::t('Markdown'), 'markdown', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'markdown'],
+                       '$type_html'     => ['type', L10n::t('HTML'), 'html', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'html'],
                        '$results'       => $results
                ]);