]> git.mxchange.org Git - friendica.git/blob - mod/babel.php
56455bdb21dd342192c01cfe59efe26ed3455038
[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 if(! function_exists('babel_content')) {
13 function babel_content(&$a) {
14
15         $o .= '<h1>Babel Diagnostic</h1>';
16
17         $o .= '<form action="babel" method="post">';
18         $o .= t('Source (bbcode) text:') . EOL . '<textarea name="text" >' . htmlspecialchars($_REQUEST['text']) .'</textarea>' . EOL;
19         $o .= '<input type="submit" name="submit" value="Submit" /></form>';
20
21         $o .= '<br /><br />';
22
23         $o .= '<form action="babel" method="post">';
24         $o .= t('Source (Diaspora) text to convert to BBcode:') . EOL . '<textarea name="d2bbtext" >' . 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
31                 $text = trim($_REQUEST['text']);
32                 $o .= "<h2>" . t("Source input: ") . "</h2>" . EOL. EOL;
33                 $o .= visible_lf($text) . EOL. EOL;
34
35                 $html = bbcode($text);
36                 $o .= "<h2>" . t("bb2html (raw HTML): ") . "</h2>" . EOL. EOL;
37                 $o .= htmlspecialchars($html). EOL. EOL;
38
39                 //$html = bbcode($text);
40                 $o .= "<h2>" . t("bb2html: ") . "</h2>" . EOL. EOL;
41                 $o .= $html. EOL. EOL;
42
43                 $bbcode = html2bbcode($html);
44                 $o .= "<h2>" . t("bb2html2bb: ") . "</h2>" . EOL. EOL;
45                 $o .= visible_lf($bbcode) . EOL. EOL;
46
47                 $diaspora = bb2diaspora($text);
48                 $o .= "<h2>" . t("bb2md: ") . "</h2>" . EOL. EOL;
49                 $o .= visible_lf($diaspora) . EOL. EOL;
50
51                 $html = Markdown($diaspora);
52                 $o .= "<h2>" . t("bb2md2html: ") . "</h2>" . EOL. EOL;
53                 $o .= $html. EOL. EOL;
54
55                 $bbcode = diaspora2bb($diaspora);
56                 $o .= "<h2>" . t("bb2dia2bb: ") . "</h2>" . EOL. EOL;
57                 $o .= visible_lf($bbcode) . EOL. EOL;
58
59                 $bbcode = html2bbcode($html);
60                 $o .= "<h2>" . t("bb2md2html2bb: ") . "</h2>" . EOL. EOL;
61                 $o .= visible_lf($bbcode) . EOL. EOL;
62
63
64
65         }
66
67         if(x($_REQUEST,'d2bbtext')) {
68
69                 $d2bbtext = trim($_REQUEST['d2bbtext']);
70                 $o .= "<h2>" . t("Source input (Diaspora format): ") . "</h2>" . EOL. EOL;
71                 $o .= visible_lf($d2bbtext) . EOL. EOL;
72
73
74                 $bb = diaspora2bb($d2bbtext);
75                 $o .= "<h2>" . t("diaspora2bb: ") . "</h2>" . EOL. EOL;
76                 $o .= visible_lf($bb) . EOL. EOL;
77         }
78
79         return $o;
80 }
81 }