2012-07-02 06:00:25 +00:00
|
|
|
<?php
|
2018-01-21 18:33:59 +00:00
|
|
|
/**
|
|
|
|
* @file mod/babel.php
|
|
|
|
*/
|
2018-02-15 02:33:55 +00:00
|
|
|
|
2018-03-07 21:24:13 +00:00
|
|
|
use Friendica\Content\Text;
|
2018-01-21 18:33:59 +00:00
|
|
|
use Friendica\Core\L10n;
|
2017-04-30 04:07:00 +00:00
|
|
|
|
2018-01-05 00:42:48 +00:00
|
|
|
function visible_lf($s)
|
|
|
|
{
|
2017-03-26 23:06:22 +00:00
|
|
|
return str_replace("\n", '<br />', $s);
|
2012-07-02 06:00:25 +00:00
|
|
|
}
|
|
|
|
|
2018-01-05 00:42:48 +00:00
|
|
|
function babel_content()
|
|
|
|
{
|
|
|
|
$o = '<h1>Babel Diagnostic</h1>';
|
2012-07-02 06:00:25 +00:00
|
|
|
|
|
|
|
$o .= '<form action="babel" method="post">';
|
2018-01-24 21:51:32 +00:00
|
|
|
$o .= L10n::t("Source \x28bbcode\x29 text:") . EOL;
|
2018-01-05 00:42:48 +00:00
|
|
|
$o .= '<textarea name="text" cols="80" rows="10">' . htmlspecialchars($_REQUEST['text']) . '</textarea>' . EOL;
|
2017-01-09 12:12:54 +00:00
|
|
|
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
|
2012-07-02 06:00:25 +00:00
|
|
|
|
|
|
|
$o .= '<br /><br />';
|
|
|
|
|
2012-07-13 05:12:48 +00:00
|
|
|
$o .= '<form action="babel" method="post">';
|
2018-01-24 21:51:32 +00:00
|
|
|
$o .= L10n::t("Source \x28Diaspora\x29 text to convert to BBcode:") . EOL;
|
2018-01-05 00:42:48 +00:00
|
|
|
$o .= '<textarea name="d2bbtext" cols="80" rows="10">' . htmlspecialchars($_REQUEST['d2bbtext']) . '</textarea>' . EOL;
|
2017-01-09 12:12:54 +00:00
|
|
|
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
|
2012-07-13 05:12:48 +00:00
|
|
|
|
|
|
|
$o .= '<br /><br />';
|
|
|
|
|
2017-03-26 23:06:22 +00:00
|
|
|
if (x($_REQUEST, 'text')) {
|
2012-07-02 06:00:25 +00:00
|
|
|
$text = trim($_REQUEST['text']);
|
2018-01-21 18:33:59 +00:00
|
|
|
$o .= '<h2>' . L10n::t('Source input: ') . '</h2>' . EOL . EOL;
|
2018-01-05 00:42:48 +00:00
|
|
|
$o .= visible_lf($text) . EOL . EOL;
|
2012-07-02 06:00:25 +00:00
|
|
|
|
2018-03-07 21:24:13 +00:00
|
|
|
$html = Text\BBCode::convert($text);
|
|
|
|
$o .= '<h2>' . L10n::t("BBCode::convert \x28raw HTML\x28: ") . '</h2>' . EOL . EOL;
|
2018-01-05 00:42:48 +00:00
|
|
|
$o .= htmlspecialchars($html) . EOL . EOL;
|
2013-01-12 13:31:32 +00:00
|
|
|
|
2018-03-07 21:24:13 +00:00
|
|
|
$o .= '<h2>' . L10n::t('BBCode::convert: ') . '</h2>' . EOL . EOL;
|
2018-01-05 00:42:48 +00:00
|
|
|
$o .= $html . EOL . EOL;
|
2012-07-02 06:00:25 +00:00
|
|
|
|
2018-03-07 21:24:13 +00:00
|
|
|
$bbcode = Text\HTML::toBBCode($html);
|
|
|
|
$o .= '<h2>' . L10n::t('BBCode::convert => HTML::toBBCode: ') . '</h2>' . EOL . EOL;
|
2018-01-05 00:42:48 +00:00
|
|
|
$o .= visible_lf($bbcode) . EOL . EOL;
|
2012-07-02 06:00:25 +00:00
|
|
|
|
2018-03-07 21:24:13 +00:00
|
|
|
$diaspora = Text\BBCode::toMarkdown($text);
|
2018-03-04 22:43:41 +00:00
|
|
|
$o .= '<h2>' . L10n::t('BBCode::toMarkdown: ') . '</h2>' . EOL . EOL;
|
2018-01-05 00:42:48 +00:00
|
|
|
$o .= visible_lf($diaspora) . EOL . EOL;
|
2012-07-02 06:00:25 +00:00
|
|
|
|
2018-03-07 21:24:13 +00:00
|
|
|
$html = Text\Markdown::convert($diaspora);
|
2018-03-04 22:43:41 +00:00
|
|
|
$o .= '<h2>' . L10n::t('BBCode::toMarkdown => Markdown::convert: ') . '</h2>' . EOL . EOL;
|
2018-01-05 00:42:48 +00:00
|
|
|
$o .= $html . EOL . EOL;
|
2012-07-02 06:00:25 +00:00
|
|
|
|
2018-03-07 21:24:13 +00:00
|
|
|
$bbcode = Text\Markdown::toBBCode($diaspora);
|
2018-03-04 22:43:41 +00:00
|
|
|
$o .= '<h2>' . L10n::t('BBCode::toMarkdown => Markdown::toBBCode: ') . '</h2>' . EOL . EOL;
|
2018-01-05 00:42:48 +00:00
|
|
|
$o .= visible_lf($bbcode) . EOL . EOL;
|
2012-07-02 06:00:25 +00:00
|
|
|
|
2018-03-07 21:24:13 +00:00
|
|
|
$bbcode = Text\HTML::toBBCode($html);
|
|
|
|
$o .= '<h2>' . L10n::t('BBCode::toMarkdown => Markdown::convert => HTML::toBBCode: ') . '</h2>' . EOL . EOL;
|
2018-01-05 00:42:48 +00:00
|
|
|
$o .= visible_lf($bbcode) . EOL . EOL;
|
2012-07-02 06:00:25 +00:00
|
|
|
}
|
2012-07-13 05:12:48 +00:00
|
|
|
|
2017-03-26 23:06:22 +00:00
|
|
|
if (x($_REQUEST, 'd2bbtext')) {
|
2012-07-13 05:12:48 +00:00
|
|
|
$d2bbtext = trim($_REQUEST['d2bbtext']);
|
2018-01-24 21:51:32 +00:00
|
|
|
$o .= '<h2>' . L10n::t("Source input \x28Diaspora format\x29: ") . '</h2>' . EOL . EOL;
|
2018-01-05 00:42:48 +00:00
|
|
|
$o .= '<pre>' . $d2bbtext . '</pre>' . EOL . EOL;
|
2012-07-13 05:12:48 +00:00
|
|
|
|
2018-03-07 21:24:13 +00:00
|
|
|
$bb = Text\Markdown::toBBCode($d2bbtext);
|
|
|
|
$o .= '<h2>' . L10n::t('Markdown::toBBCode: ') . '</h2>' . EOL . EOL;
|
2018-01-05 00:42:48 +00:00
|
|
|
$o .= '<pre>' . $bb . '</pre>' . EOL . EOL;
|
2012-07-13 05:12:48 +00:00
|
|
|
}
|
|
|
|
|
2012-07-02 06:00:25 +00:00
|
|
|
return $o;
|
|
|
|
}
|