]> git.mxchange.org Git - friendica.git/blob - mod/babel.php
Remove references to include/bb2diaspora.php
[friendica.git] / mod / babel.php
1 <?php
2 /**
3  * @file mod/babel.php
4  */
5
6 use Friendica\Content\Text\BBCode;
7 use Friendica\Content\Text\Markdown;
8 use Friendica\Core\L10n;
9
10 require_once 'include/html2bbcode.php';
11
12 function visible_lf($s)
13 {
14         return str_replace("\n", '<br />', $s);
15 }
16
17 function babel_content()
18 {
19         $o = '<h1>Babel Diagnostic</h1>';
20
21         $o .= '<form action="babel" method="post">';
22         $o .= L10n::t("Source \x28bbcode\x29 text:") . EOL;
23         $o .= '<textarea name="text" cols="80" rows="10">' . htmlspecialchars($_REQUEST['text']) . '</textarea>' . EOL;
24         $o .= '<input type="submit" name="submit" value="Submit" /></form>';
25
26         $o .= '<br /><br />';
27
28         $o .= '<form action="babel" method="post">';
29         $o .= L10n::t("Source \x28Diaspora\x29 text to convert to BBcode:") . EOL;
30         $o .= '<textarea name="d2bbtext" cols="80" rows="10">' . htmlspecialchars($_REQUEST['d2bbtext']) . '</textarea>' . EOL;
31         $o .= '<input type="submit" name="submit" value="Submit" /></form>';
32
33         $o .= '<br /><br />';
34
35         if (x($_REQUEST, 'text')) {
36                 $text = trim($_REQUEST['text']);
37                 $o .= '<h2>' . L10n::t('Source input: ') . '</h2>' . EOL . EOL;
38                 $o .= visible_lf($text) . EOL . EOL;
39
40                 $html = BBCode::convert($text);
41                 $o .= '<h2>' . L10n::t("bbcode \x28raw HTML\x28: ") . '</h2>' . EOL . EOL;
42                 $o .= htmlspecialchars($html) . EOL . EOL;
43
44                 $o .= '<h2>' . L10n::t('bbcode: ') . '</h2>' . EOL . EOL;
45                 $o .= $html . EOL . EOL;
46
47                 $bbcode = html2bbcode($html);
48                 $o .= '<h2>' . L10n::t('bbcode => html2bbcode: ') . '</h2>' . EOL . EOL;
49                 $o .= visible_lf($bbcode) . EOL . EOL;
50
51                 $diaspora = BBCode::toMarkdown($text);
52                 $o .= '<h2>' . L10n::t('BBCode::toMarkdown: ') . '</h2>' . EOL . EOL;
53                 $o .= visible_lf($diaspora) . EOL . EOL;
54
55                 $html = Markdown::convert($diaspora);
56                 $o .= '<h2>' . L10n::t('BBCode::toMarkdown =>  Markdown::convert: ') . '</h2>' . EOL . EOL;
57                 $o .= $html . EOL . EOL;
58
59                 $bbcode = Markdown::toBBCode($diaspora);
60                 $o .= '<h2>' . L10n::t('BBCode::toMarkdown => Markdown::toBBCode: ') . '</h2>' . EOL . EOL;
61                 $o .= visible_lf($bbcode) . EOL . EOL;
62
63                 $bbcode = html2bbcode($html);
64                 $o .= '<h2>' . L10n::t('bbcode => html2bbcode: ') . '</h2>' . EOL . EOL;
65                 $o .= visible_lf($bbcode) . EOL . EOL;
66         }
67
68         if (x($_REQUEST, 'd2bbtext')) {
69                 $d2bbtext = trim($_REQUEST['d2bbtext']);
70                 $o .= '<h2>' . L10n::t("Source input \x28Diaspora format\x29: ") . '</h2>' . EOL . EOL;
71                 $o .= '<pre>' . $d2bbtext . '</pre>' . EOL . EOL;
72
73                 $bb = Markdown::toBBCode($d2bbtext);
74                 $o .= '<h2>' . L10n::t('diaspora2bb: ') . '</h2>' . EOL . EOL;
75                 $o .= '<pre>' . $bb . '</pre>' . EOL . EOL;
76         }
77
78         return $o;
79 }