2012-07-02 08:00:25 +02:00
|
|
|
<?php
|
|
|
|
|
2017-04-30 06:07:00 +02:00
|
|
|
use Friendica\App;
|
|
|
|
|
2017-03-27 01:06:22 +02:00
|
|
|
require_once 'include/bbcode.php';
|
|
|
|
require_once 'library/markdown.php';
|
|
|
|
require_once 'include/bb2diaspora.php';
|
|
|
|
require_once 'include/html2bbcode.php';
|
2012-07-02 08:00:25 +02:00
|
|
|
|
2018-01-05 01:42:48 +01:00
|
|
|
function visible_lf($s)
|
|
|
|
{
|
2017-03-27 01:06:22 +02:00
|
|
|
return str_replace("\n", '<br />', $s);
|
2012-07-02 08:00:25 +02:00
|
|
|
}
|
|
|
|
|
2018-01-05 01:42:48 +01:00
|
|
|
function babel_content()
|
|
|
|
{
|
|
|
|
$o = '<h1>Babel Diagnostic</h1>';
|
2012-07-02 08:00:25 +02:00
|
|
|
|
|
|
|
$o .= '<form action="babel" method="post">';
|
2017-03-27 01:06:22 +02:00
|
|
|
$o .= t('Source (bbcode) text:') . EOL;
|
2018-01-05 01:42:48 +01:00
|
|
|
$o .= '<textarea name="text" cols="80" rows="10">' . htmlspecialchars($_REQUEST['text']) . '</textarea>' . EOL;
|
2017-01-09 13:12:54 +01:00
|
|
|
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
|
2012-07-02 08:00:25 +02:00
|
|
|
|
|
|
|
$o .= '<br /><br />';
|
|
|
|
|
2012-07-13 07:12:48 +02:00
|
|
|
$o .= '<form action="babel" method="post">';
|
2017-03-27 01:06:22 +02:00
|
|
|
$o .= t('Source (Diaspora) text to convert to BBcode:') . EOL;
|
2018-01-05 01:42:48 +01:00
|
|
|
$o .= '<textarea name="d2bbtext" cols="80" rows="10">' . htmlspecialchars($_REQUEST['d2bbtext']) . '</textarea>' . EOL;
|
2017-01-09 13:12:54 +01:00
|
|
|
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
|
2012-07-13 07:12:48 +02:00
|
|
|
|
|
|
|
$o .= '<br /><br />';
|
|
|
|
|
2017-03-27 01:06:22 +02:00
|
|
|
if (x($_REQUEST, 'text')) {
|
2012-07-02 08:00:25 +02:00
|
|
|
$text = trim($_REQUEST['text']);
|
2018-01-05 01:42:48 +01:00
|
|
|
$o .= '<h2>' . t('Source input: ') . '</h2>' . EOL . EOL;
|
|
|
|
$o .= visible_lf($text) . EOL . EOL;
|
2012-07-02 08:00:25 +02:00
|
|
|
|
|
|
|
$html = bbcode($text);
|
2018-01-14 19:13:36 +01:00
|
|
|
$o .= '<h2>' . t('bbcode (raw HTML): ') . '</h2>' . EOL . EOL;
|
2018-01-05 01:42:48 +01:00
|
|
|
$o .= htmlspecialchars($html) . EOL . EOL;
|
2013-01-12 14:31:32 +01:00
|
|
|
|
|
|
|
//$html = bbcode($text);
|
2018-01-14 19:13:36 +01:00
|
|
|
$o .= '<h2>' . t('bbcode: ') . '</h2>' . EOL . EOL;
|
2018-01-05 01:42:48 +01:00
|
|
|
$o .= $html . EOL . EOL;
|
2012-07-02 08:00:25 +02:00
|
|
|
|
|
|
|
$bbcode = html2bbcode($html);
|
2018-01-14 19:13:36 +01:00
|
|
|
$o .= '<h2>' . t('bbcode => html2bbcode: ') . '</h2>' . EOL . EOL;
|
2018-01-05 01:42:48 +01:00
|
|
|
$o .= visible_lf($bbcode) . EOL . EOL;
|
2012-07-02 08:00:25 +02:00
|
|
|
|
|
|
|
$diaspora = bb2diaspora($text);
|
2018-01-14 19:13:36 +01:00
|
|
|
$o .= '<h2>' . t('bb2diaspora: ') . '</h2>' . EOL . EOL;
|
2018-01-05 01:42:48 +01:00
|
|
|
$o .= visible_lf($diaspora) . EOL . EOL;
|
2012-07-02 08:00:25 +02:00
|
|
|
|
|
|
|
$html = Markdown($diaspora);
|
2018-01-14 19:13:36 +01:00
|
|
|
$o .= '<h2>' . t('bb2diaspora => Markdown: ') . '</h2>' . EOL . EOL;
|
2018-01-05 01:42:48 +01:00
|
|
|
$o .= $html . EOL . EOL;
|
2012-07-02 08:00:25 +02:00
|
|
|
|
|
|
|
$bbcode = diaspora2bb($diaspora);
|
2018-01-14 19:13:36 +01:00
|
|
|
$o .= '<h2>' . t('bb2diaspora => diaspora2bb: ') . '</h2>' . EOL . EOL;
|
2018-01-05 01:42:48 +01:00
|
|
|
$o .= visible_lf($bbcode) . EOL . EOL;
|
2012-07-02 08:00:25 +02:00
|
|
|
|
|
|
|
$bbcode = html2bbcode($html);
|
2018-01-14 19:13:36 +01:00
|
|
|
$o .= '<h2>' . t('bbcode => html2bbcode: ') . '</h2>' . EOL . EOL;
|
2018-01-05 01:42:48 +01:00
|
|
|
$o .= visible_lf($bbcode) . EOL . EOL;
|
2012-07-02 08:00:25 +02:00
|
|
|
}
|
2012-07-13 07:12:48 +02:00
|
|
|
|
2017-03-27 01:06:22 +02:00
|
|
|
if (x($_REQUEST, 'd2bbtext')) {
|
2012-07-13 07:12:48 +02:00
|
|
|
$d2bbtext = trim($_REQUEST['d2bbtext']);
|
2018-01-05 01:42:48 +01:00
|
|
|
$o .= '<h2>' . t('Source input (Diaspora format): ') . '</h2>' . EOL . EOL;
|
|
|
|
$o .= '<pre>' . $d2bbtext . '</pre>' . EOL . EOL;
|
2012-07-13 07:12:48 +02:00
|
|
|
|
|
|
|
$bb = diaspora2bb($d2bbtext);
|
2018-01-05 01:42:48 +01:00
|
|
|
$o .= '<h2>' . t('diaspora2bb: ') . '</h2>' . EOL . EOL;
|
|
|
|
$o .= '<pre>' . $bb . '</pre>' . EOL . EOL;
|
2012-07-13 07:12:48 +02:00
|
|
|
}
|
|
|
|
|
2012-07-02 08:00:25 +02:00
|
|
|
return $o;
|
|
|
|
}
|