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