X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FDebug%2FBabel.php;h=ab68f2b4038be0c1bacd31eb7d6f6256c1b8842d;hb=da5045667527a84d6a3fd6efaee2fb97b9a49778;hp=ecad73f4dcd82eee64b5bd39415b2883f9efbffc;hpb=f58d42e317cbf323fb2c802a0cb71a4799863008;p=friendica.git diff --git a/src/Module/Debug/Babel.php b/src/Module/Debug/Babel.php index ecad73f4dc..ab68f2b403 100644 --- a/src/Module/Debug/Babel.php +++ b/src/Module/Debug/Babel.php @@ -22,10 +22,14 @@ namespace Friendica\Module\Debug; 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; @@ -102,19 +106,32 @@ class Babel extends BaseModule 'content' => visible_whitespace($bbcode4) ]; - $item = ['body' => $bbcode]; - $tags = Text\BBCode::getTags($bbcode); - Item::setHashtags($item); + $body = Item::setHashtags($bbcode); $results[] = [ 'title' => DI::l10n()->t('Item Body'), - 'content' => visible_whitespace($item['body']) + 'content' => visible_whitespace($body) ]; $results[] = [ 'title' => DI::l10n()->t('Item Tags'), 'content' => visible_whitespace(var_export($tags, true)), ]; + + $body2 = PageInfo::appendToBody($bbcode, true); + $results[] = [ + 'title' => DI::l10n()->t('PageInfo::appendToBody'), + 'content' => visible_whitespace($body2) + ]; + $html3 = Text\BBCode::convert($body2); + $results[] = [ + 'title' => DI::l10n()->t('PageInfo::appendToBody => BBCode::convert (raw HTML)'), + 'content' => visible_whitespace($html3) + ]; + $results[] = [ + 'title' => DI::l10n()->t('PageInfo::appendToBody => BBCode::convert'), + 'content' => $html3 + ]; break; case 'diaspora': $diaspora = trim($_REQUEST['text']); @@ -125,9 +142,7 @@ class Babel extends BaseModule $markdown = XML::unescape($diaspora); case 'markdown': - if (!isset($markdown)) { - $markdown = trim($_REQUEST['text']); - } + $markdown = $markdown ?? trim($_REQUEST['text']); $results[] = [ 'title' => DI::l10n()->t('Source input (Markdown)'), @@ -203,6 +218,60 @@ class Babel extends BaseModule 'title' => DI::l10n()->t('HTML::toPlaintext (compact)'), 'content' => visible_whitespace($text), ]; + break; + case 'twitter': + $json = trim($_REQUEST['text']); + + $status = json_decode($json); + + $results[] = [ + 'title' => DI::l10n()->t('Decoded post'), + 'content' => visible_whitespace(var_export($status, true)), + ]; + + $postarray = []; + $postarray['object-type'] = Activity\ObjectType::NOTE; + + if (!empty($status->full_text)) { + $postarray['body'] = $status->full_text; + } else { + $postarray['body'] = $status->text; + } + + // When the post contains links then use the correct object type + if (count($status->entities->urls) > 0) { + $postarray['object-type'] = Activity\ObjectType::BOOKMARK; + } + + if (file_exists('addon/twitter/twitter.php')) { + require_once 'addon/twitter/twitter.php'; + + $picture = \twitter_media_entities($status, $postarray); + + $results[] = [ + 'title' => DI::l10n()->t('Post array before expand entities'), + 'content' => visible_whitespace(var_export($postarray, true)), + ]; + + $converted = \twitter_expand_entities($postarray['body'], $status, $picture); + + $results[] = [ + 'title' => DI::l10n()->t('Post converted'), + 'content' => visible_whitespace(var_export($converted, true)), + ]; + + $results[] = [ + 'title' => DI::l10n()->t('Converted body'), + 'content' => visible_whitespace($converted['body']), + ]; + } else { + $results[] = [ + 'title' => DI::l10n()->t('Error'), + 'content' => DI::l10n()->t('Twitter addon is absent from the addon/ folder.'), + ]; + } + + break; } } @@ -213,6 +282,8 @@ class Babel extends BaseModule '$type_diaspora' => ['type', DI::l10n()->t('Diaspora'), 'diaspora', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'diaspora'], '$type_markdown' => ['type', DI::l10n()->t('Markdown'), 'markdown', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'markdown'], '$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'), 'twitter', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'twitter'], '$results' => $results ]);