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