<?php
/**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
use Friendica\BaseModule;
use Friendica\Content\PageInfo;
use Friendica\Content\Text;
-use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\DI;
-use Friendica\Model\Conversation;
use Friendica\Model\Item;
use Friendica\Protocol\Activity;
-use Friendica\Model\Tag;
use Friendica\Util\XML;
/**
*/
class Babel extends BaseModule
{
- public static function content(array $parameters = [])
+ protected function content(array $request = []): string
{
function visible_whitespace($s)
{
'content' => visible_whitespace($plain)
];
- $html = Text\BBCode::convert($bbcode);
+ $html = Text\BBCode::convertForUriId(0, $bbcode);
$results[] = [
'title' => DI::l10n()->t('BBCode::convert (raw HTML)'),
'content' => visible_whitespace($html)
'title' => DI::l10n()->t('PageInfo::appendToBody'),
'content' => visible_whitespace($body2)
];
- $html3 = Text\BBCode::convert($body2);
+ $html3 = Text\BBCode::convertForUriId(0, $body2);
$results[] = [
'title' => DI::l10n()->t('PageInfo::appendToBody => BBCode::convert (raw HTML)'),
'content' => visible_whitespace($html3)
'content' => $html
];
- $config = \HTMLPurifier_Config::createDefault();
- $HTMLPurifier = new \HTMLPurifier($config);
- $purified = $HTMLPurifier->purify($html);
+ $purified = Text\HTML::purify($html);
$results[] = [
'title' => DI::l10n()->t('HTML Purified (raw)'),
'content' => visible_whitespace($bbcode)
];
- $html2 = Text\BBCode::convert($bbcode);
+ $html2 = Text\BBCode::convertForUriId(0, $bbcode);
$results[] = [
'title' => DI::l10n()->t('HTML::toBBCode => BBCode::convert'),
'content' => $html2
];
} else {
$results[] = [
- 'title' => DI::l10n()->t('Error'),
+ 'title' => DI::l10n()->tt('Error', 'Errors', 1),
'content' => DI::l10n()->t('Twitter addon is absent from the addon/ folder.'),
];
}
$tpl = Renderer::getMarkupTemplate('babel.tpl');
$o = Renderer::replaceMacros($tpl, [
+ '$title' => DI::l10n()->t('Babel Diagnostic'),
'$text' => ['text', DI::l10n()->t('Source text'), $_REQUEST['text'] ?? '', ''],
'$type_bbcode' => ['type', DI::l10n()->t('BBCode'), 'bbcode', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'bbcode'],
'$type_diaspora' => ['type', DI::l10n()->t('Diaspora'), 'diaspora', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'diaspora'],
'$type_html' => ['type', DI::l10n()->t('HTML'), 'html', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'html'],
'$flag_twitter' => file_exists('addon/twitter/twitter.php'),
'$type_twitter' => ['type', DI::l10n()->t('Twitter Source / Tweet URL (requires API key)'), 'twitter', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'twitter'],
- '$results' => $results
+ '$results' => $results,
+ '$submit' => DI::l10n()->t('Submit'),
]);
return $o;