]> git.mxchange.org Git - friendica.git/blob - mod/babel.php
Merge pull request #2094 from annando/1511-api
[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(&$a) {
13
14         $o .= '<h1>Babel Diagnostic</h1>';
15
16         $o .= '<form action="babel" method="post">';
17         $o .= t('Source (bbcode) text:') . EOL . '<textarea name="text" >' . 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 . '<textarea name="d2bbtext" >' . htmlspecialchars($_REQUEST['d2bbtext']) .'</textarea>' . EOL;
24         $o .= '<input type="submit" name="submit" value="Submit" /></form>'; 
25
26         $o .= '<br /><br />';
27
28         if(x($_REQUEST,'text')) {
29
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
64         }
65
66         if(x($_REQUEST,'d2bbtext')) {
67
68                 $d2bbtext = trim($_REQUEST['d2bbtext']);
69                 $o .= "<h2>" . t("Source input (Diaspora format): ") . "</h2>" . EOL. EOL; 
70                 $o .= visible_lf($d2bbtext) . EOL. EOL; 
71
72
73                 $bb = diaspora2bb($d2bbtext);
74                 $o .= "<h2>" . t("diaspora2bb: ") . "</h2>" . EOL. EOL; 
75                 $o .= visible_lf($bb) . EOL. EOL; 
76         }
77
78         return $o;
79 }